akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int A[N];
    double sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    double judge = sum / (4 * M);
    int countItem = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] >= judge) countItem++;
    }
    if (countItem >= M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans,a[100100];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(i>=a[i+1]){
               for(int j=i+1;a[j]==i;j++) ans^=1;
               ans|=(a[i]-i)&1;
               if(ans)cout<<"First"<<endl;
               else cout<<"Second"<<endl;
               return 0;
           }    
    }    
}

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

using namespace std;

int main() {
  string s; cin >> s;
  int zero = 0, one = 0;
  for (auto c : s) {
      if (c == '0') zero++;
      else one++;
  }
  
  cout << min(zero, one) * 2 << endl;

  return 0;
}


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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int a = Integer.parseInt(s[0]);
			String b = (s[1]);
			int c = Integer.parseInt(s[2]);

			if(b.equalsIgnoreCase("?")){
				break;
			}

			if(b.equals("+")){
				System.out.println((a + c));
			}else if(b.equals("-")){
				System.out.println((a - c));
			}else if(b.equals("*")){
				System.out.println((a * c));
			}else if(b.equals("/")){
				System.out.println((a / c));
			}
			continue;
		}
	}
}

Measured memory_bytes: 24316
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main = abc163a

abc163a = do
    [r] <- getIntList
    print $ 2.0 * pi * fromIntegral r

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 3908
s = input()
c = s.find('C', 2, len(s) - 1)

if s.startswith('A') and \
   s.count('C', 2, len(s) - 1) == 1 \
   and (s[1:c] + s[c+1:]).islower():
    print('AC')
else:
    print('WA')

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

using namespace std;

int n,m;
char a[5];
int b,c;

int main()
{
    scanf("%s",a);
    int flag = 0;
    for(int i = 0;i < 3;i++)
        if(a[i] != a[i+1])
            flag++;
    if(flag == 0)
    {
        printf("No\n");
        return 0;
    }
    for(int i = 0;i <= 3;i++)
    {
        while(a[i] == '.' && i < 3)
            i++;
        if(i > 3)
            break;
        for(int j = i + 1;j < 4;j++)
            if(a[i] == a[j])
            {
                a[i] = '.';
                a[j] = '.';
                break;
            }
    }
    for(int i = 0;i < 4;i++)
    {
        if(a[i] != '.')
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>

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

    int32_t N;
    std::cin >> N;
    std::vector<int32_t> X(N);
    for(auto& i : X){
        std::cin >> i;
    }
    std::vector<int32_t> sortedX(N);
    std::copy(X.begin(), X.end(), sortedX.begin());
    std::sort(sortedX.begin(), sortedX.end());
    for(int32_t i = 0; i < N; i++){
        if(X[i] < sortedX[N/2]){
            std::cout << sortedX[N/2] << std::endl;
        }
        else{
            std::cout << sortedX[N/2 - 1] << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
	int n,sw;cin>>n>>sw;
	int w[n],v[n];
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];

	ll dp[n+1][100100]={0};
	for(int i=0;i<n;i++){
		for(int sum=0;sum<=sw;sum++){
			if(sum>=w[i]) dp[i+1][sum]=max(dp[i+1][sum],dp[i][sum-w[i]]+v[i]);//i個目をとる時元のとどっちが大きいか
			dp[i+1][sum]=max(dp[i][sum],dp[i+1][sum]);//取っても取らなくても0∼i個目の最大値をdpへ
		}
	}
	cout<<dp[n][sw]<<"\n";
}

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

int main() {
	int N,M;  
  cin >> N >> M;
  	vector<int>A(N);
  
  for(int i = 0 ; i < N ; i++){
  	cin >> A.at(i) ;
  }
  
  int total = 0;
  for(int i = 0 ; i < N ; i++){
  	total += A.at(i) ;
  }
  
  int counter = 0;
  for(int i = 0 ; i < N ; i++){
  	if(A.at(i)*4*M>=total){
    	counter++ ;
    }
  }
  
  if(counter >= M){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
  
}


Measured memory_bytes: 3648
def main():
    N = int(input())
    h = list(map(int, input().split()))
    
    ans = 0
    while sum(h) > 0:
      ans += 1
      flag = False
      for i in range(N):
        if h[i] > 0:
          h[i] -= 1
          flag = True
        elif flag is True:
          break

    print(ans)
        
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import deque

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

A_sorted = sorted(A, reverse=True)
ans = 0
queue = deque([A_sorted[0]])
for a in A_sorted[1:]:
    ans += queue.popleft()
    queue.append(a)
    queue.append(a)
print(ans)


Measured memory_bytes: 32460
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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 Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    cout << (1000-n%1000)%1000 << endl;
}

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

using namespace std;
int main() {
  int x, a, b;
  cin >> x >> a >> b;

  if (a - b >= 0)
    cout << "delicious" << endl;
  else if (a - b < 0 && a - b + x >= 0)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;

  return 0;
}

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

bool check(LL x){
	if(x%2==0)return false;
	LL y=sqrt(x),i;
	set<LL>s;
	for(i=1;i<=y+1;i++){
		if(x%i==0){
			s.insert(i);
			s.insert(x/i);
		}
	}
	return (int)s.size()==8;
}

int main(){
	LL n,i,j;
	cin>>n;
	for(i=1,j=0;i<=n;i++)if(check(i)){
		j++;
	}
	cout<<j<<endl;
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int l,r;
    cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	
	int a;
	cin>>a;
	cout<<a+(a*a)+(a*a*a);

	

	return 0;
}

Measured memory_bytes: 3628
def can(l, k, p):
    s, a = 0, 0
    for li in l:
        if li > p: return False
        s += li

        if s > p:
            s = li
            k -= 1
        if k <= 0: return False
        
    return True

def bi(array, k, l, r):
    m = (l + r) // 2
    if l > r:
        return max(l, r)
    b = can(array, k, m)
    if b:
        return bi(array, k, l, m-1)
    else:
        return bi(array, k, m+1, r)
        
    
n, k = map(int, input().split())
l = [0] * n
for i in range(n):
    l[i] = int(input())
    
p = sum(l)
print(bi(l, k, 0, p))


Measured memory_bytes: 9412
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

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

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np
import collections as col

# main code
S = input()
T = input()

a = len(T)

b = []

for i in range(0,len(S)-a+1):
    b.append(S[i:i+a])

ans = 10000

for i in range(0,len(S)-a+1):
    aa = 0
    for j in range(0,a):
        if not b[i][j] == T[j]:
            aa += 1
    ans = min(ans,aa)

print(ans)

Measured memory_bytes: 27160
#include<stdio.h>
	int a[3][3],c[3][3];
int main(){
	
	int i,j,n,flag=0,k,s;
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	scanf("%d",&n);
	int b[n];
	for(k=0;k<n;k++){
		scanf("%d",&b[k]);
		for(i=0;i<3;i++){
	for(j=0;j<3;j++){
		if(b[k]==a[i][j]){
			c[i][j]=1;
		}
	}
	}

}
if(c[0][0]==1 && c[1][1]==1 && c[2][2]==1){
	printf("Yes");
}
else if(c[0][2]==1 && c[1][1]==1 && c[2][0]==1){
	printf("Yes");
}
else if(c[0][0]==1 && c[0][1]==1 && c[0][2]==1){
	printf("Yes");
}
 else if(c[1][0]==1 && c[1][1]==1 && c[1][2]==1){
	printf("Yes");
}
else if(c[2][0]==1 && c[2][1]==1 && c[2][2]==1){
	printf("Yes");
}
else if(c[0][0]==1 && c[1][0]==1 && c[2][0]==1){
	printf("Yes");
}
else if(c[0][1]==1 && c[1][1]==1 && c[2][1]==1){
	printf("Yes");
}
else if(c[0][2]==1 && c[1][2]==1 && c[2][2]==1){
	printf("Yes");
}




else{
	printf("No");
}


return 0;	
}

Measured memory_bytes: 128
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::min;

#[fastout]
fn main() {
    input! {
    n: usize,
    w: [i64; n]
    }
    let mut ans = std::i64::MAX;
    for i  in 0..n {
        let t = (w[i..].iter().sum::<i64>() - w[..i].iter().sum::<i64>()).abs();
        ans = min(t, ans);
    }
    println!("{}", ans);
}


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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    ll n,k;
    cin>>n>>k;

    vector<ll> a(n);
    vector<bool> pa(n,false);
    deque<ll> as;

    for(int i=0;i<n;i++)cin>>a.at(i),a.at(i)--;

    ll ct = 0;
    while(1){
        if(pa.at(ct)==true){
            ll at = 0;
            while(1){
                if(at==ct)break;
                at = a.at(at);
                k--;
                as.pop_front();
                if(k==0){
                    cout<<as.front()+1<<endl;
                    return 0;
                }
            }
            break;
        }
        as.push_back(ct);
        pa.at(ct)=true;
        ct = a.at(ct);
    }

    cout<<as.at(k%as.size())+1<<endl;

}



Measured memory_bytes: 6360
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main() {
  ll N, M;  
  cin >> N >> M;
  if(N!=1 && M!=1){
    ll ans = (N-2)*(M-2);
    cout << ans  <<endl;
  }
  if(N==1 && M!=1){
    cout<< M-2 << endl;
  }
  if(N!=1 && M==1){
    cout << N-2 << endl;
  }
  if(N==1 && M==1){
    cout << 1 << endl;
  }
  return 0;
}
  



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

int main(void){

    std :: string str;
    std :: cin >> str;

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

    return 0;
}

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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    ll n, h, cnt = 0;
    cin >> n >> h;

    vector <ll> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int tmp = a[n-1], idx;

    for (int i = n-1; i >= 0; i--) {
        if (tmp <= b[i]) idx = i;
        else break;
    }

    for (int i = n-1; i >= idx; i--) {
        h -= b[i];
        cnt++;
        if (h <= 0) {
            cout << cnt << endl;
            return 0;
        }
    }

    cnt += (h-1) / a[n-1] + 1;

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ", fgets(STDIN));
$ans = 9999;
for ($i = 0; $i < $n; $i++) {
    $div = 0;
    while ($a[$i] % 2 === 0) {
        $div++;
        $a[$i] /= 2;
    }
    $ans = min($ans,$div);
}
echo $ans;

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

int main() {
    int N;  cin >> N;
    vector<long long> A(N + 1);
    long long sumA = 0, sumB = 0;
    for (int i = 0; i < N + 1; ++i) {
        cin >> A[i];
        sumA += A[i];
    }
    if (N == 0) {
        if (A[0] == 1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }

    long long subSumA = sumA;

    long long B = 1 - A[0];
    sumB += B;
    bool ok = true;
    for (int i = 1; i < N + 1; ++i) {
        B = 2 * B - A[i];
        if (B < 0) {
            ok = false;
            break;
        }
        subSumA -= A[i];
        if (B > subSumA) {
            B = subSumA;
        }
        sumB += B;
    }

    if (ok) cout << sumA + sumB << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 4056
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var N = NextInt();
		var M = NextInt();
		var X = NextInt();

		var ans = 0;
		var cnt = 0;
		var flg = false;

		for (var i = 0; i < M; i++) {
			var A = NextInt();
			if (A > X & !flg) {
				ans = cnt;
				cnt = 0;
				flg = true;
			}
			cnt += 1;
		}
		ans = Math.Min(ans, cnt);
		WriteLine(ans);
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, k;
    cin >> n >> k;

    ll a[n];
    rep(i, 0, n){
        cin >> a[i];
    }

    ll s[n + 1];
    s[0] = 0;
    rep(i, 1, n + 1){
        s[i] = s[i - 1] + a[i - 1];
    }

    ll c[(n * (n + 1)) / 2];
    ll count = 0;
    rep(i, 1, n + 1){
        rep(j, i, n + 1){
            c[count] = s[j] - s[i - 1];
            count++;
        }
    }


    ll ans = 0;
    rrep(i, 40, 0){
        ll count = 0;
        rep(j, 0, (n * (n + 1)) / 2){
            if(((ans | (1LL << i)) & c[j]) == (ans | (1LL << i))){
                count++;
            }
        }
        if(count >= k){
            ans |= (1LL << i);
        }

    }


    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
static const int Max = 1000;
int getlong(string a, string b){
int n,m,i,j,as=0;
	int cs[Max + 1][Max + 1];
	n=a.size();
	m=b.size();

	a=' '+a;
	b=' '+b;
	cs[0][0]=0;
	for(i=1;i<=n;i++)
	cs[i][0]=0;
	for(i=1;i<=m;i++)
	cs[0][i]=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(a[i]==b[j])
			cs[i][j]=cs[i-1][j-1]+1;
			else
			cs[i][j]=max(cs[i][j-1],cs[i-1][j]);
		as=max(as,cs[i][j]);
		}
		
	}
	return as;
}
main(){
	int q,i;
	string a,b;
	cin>>q;
	for(i=0;i<q;i++){
		cin>>a>>b;
		printf("%d\n",getlong(a,b));
	}
	return 0;
}



Measured memory_bytes: 7188
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int a , b , c;
        cin >> a >> b >> c ;
        if( a + b == c || b + c == a  || c + a == b ){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        
        return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>

void drawRectangle( int H, int W)
{
	int i,j;
	
	for( i=0; i<H; i++) {
		for( j=0; j<W; j++) {
			printf( "#");
		}
		printf( "\n");
	}
	printf( "\n");
	return;
}

int main( void ) 
{
	int H,W;

	for( ; ; ) {
		scanf( "%d%d", &H, &W ); 
		if( 0==H && 0==W ) { break; }

		drawRectangle( H, W );
	}

	return 0;
}

Measured memory_bytes: 572
n,k = [int(i) for i in input().split()]

n0=n
i=0
kai = []
while(k!=1):
    kai.append(max(0,n-k+1))
    if n >= k:
        n = k-1
    k=(k+1)//2
kai.append(1)

#print(kai)

ans = 0.0
for i,c in enumerate(kai):
    ans += c*2**(-i)
#    print(ans)
print(ans/n0)

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

int main(void) {
	int N;
	int by1, by2, by4;

	cin >> N;
	by1 = by2 = by4 = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (a % 4 == 0)
			++by4;
		else if (a % 2 == 0)
			++by2;
		else
			++by1;
	}

	bool ans = true;
	if (N % 2 == 0) {
		if ((by1 > N / 2) || (by4 < by1))
			ans = false;
	}
	else {
		if (by1 > N / 2 + 1)
			ans = false;
		else if ((by1 == N / 2 + 1) && (by4 < by1 - 1))
			ans = false;
		else if ((by1 < N / 2 + 1) && (by4 < by1))
				ans = false;
	}

	if (ans)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
class Word(str:String){
    val nextDiverseWord:String?
    init{
        var next:String? = null
        when(str.length){
            26 -> when(str == str.toCharArray().sortedDescending().joinToString()){
                true -> next = null
                false -> {
                        loop@for (idx in 24 downTo 0) {
                            if (str[idx + 1] > str[idx]) {
                                val target = str.substring(idx + 1).toCharArray().filter { it > str[idx] }.min() ?: str[25]
                                next = str.substring(0 until idx) + target
                                break@loop
                            }
                        }
                }
            }
            else -> Array(26){0}.apply {
                for (c in str){
                    ++this[c - 'a']
                }
                next = str + ('a' + this.indexOfFirst { it == 0 })
            }
        }
        nextDiverseWord = next
    }
}

fun main(args:Array<String>):Unit{
    println(Word(readLine()!!).nextDiverseWord ?: -1)
}

Measured memory_bytes: 37828
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;

ll INF = 114514191919119;

int main(){

    ll N; cin >> N;

    vector<vector<ll > > vec(N, vector<ll >(26, 0));

    for(ll i = 0; i < N; i++){
        string t; cin >> t;
        for(ll j = 0; j < t.length(); j++){
            vec[i][t[j] - 'a'] += 1;
        }
    }

    string ans = ""; 
    for(ll i = 0; i < 26; i++){
        bool f = true;
        ll len = INF;
        for(ll j = 0; j < N; j++){
            if(vec[j][i] == 0){
                f = false;
                break;
            }
            //cout << vec[j][i] << endl;
            len = min(len, vec[j][i]);
        }
        if(f == true){
            //cout << len << endl;
            for(ll j = 0; j < len; j++){
                //cout << i + 'a' << endl;
                ans += i + 'a';
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int n,i;
    scanf("%d",&n);
    getchar();
    char s[101];
    char t[101];
    scanf("%s",s);
    scanf("%s",t);
    for(i=0;i<n;i++)
        printf("%c%c",s[i],t[i]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// ordered_set<ll> dp;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

bool dp[2001][2001];
string ss[10]={"1110111","0010010","1011101","1011011","0111010","1101011","1101111","1010010","1111111","1111011"};
    
void solve()
{
    ll n;
    cin>>n;
    pair<ll,ll> p[n+1];
    repf(i,1,n+1) 
    {
        cin>>p[i].fi;
        p[i].se=i;
    }
    sort(p+1,p+n+1);
    reverse(p+1,p+n+1);
    ll dp[n+1][n+1];
    memset(dp,0,sizeof dp);
    repf(i,1,n+1)
    {
        repf(j,0,i)
        {
            ll L=j;
            ll R=i-1-j;
            dp[L+1][R]=max(dp[L+1][R],dp[L][R]+abs(L+1-p[i].se)*p[i].fi);
            R=j;
            L=i-1-j;
            dp[L][R+1]=max(dp[L][R+1],dp[L][R]+abs(n-R-p[i].se)*p[i].fi);
        }
    }
    ll ans=0;
    repf(i,0,n+1) ans=max(ans,dp[i][n-i]);
    cout<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}     

Measured memory_bytes: 34956
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector< vector<int> > G;

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;

    G.assign(N, vector<int>() );

    //init
    for(int i=0; i<N-1; ++i){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X].push_back(Y);
    G[Y].push_back(X);

    vector<int> ans(N);

    for(int i=0; i<N; ++i){
        vector<int> visited;
        visited.assign(N, -1);
        queue<int> q;

        q.emplace(i);
        visited[i] = 0;

        while(!q.empty()){
            int cur_node = q.front();
            q.pop();

            for(auto nn : G[cur_node]){
                if(visited[nn] != -1) continue;
                visited[nn] = visited[cur_node] + 1;
                q.emplace(nn);
            }
        }

    for(int i=0; i< visited.size(); ++i){
            ans[visited[i]]++;
        }
    }

    for(int i=1; i<ans.size(); ++i){
        cout << ans[i]/2 << endl;
    }

    return 0;
} 

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define INF 		2000000007
#define MOD			10e9+7
#define MAX 		100005
// テンプレ終了
//====================================================================//

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
	int N;cin>>N;
	vector<int> A(N);
	REP(i,N)cin>>A[i];

	int ans = gcd(A[0],A[1]);
	REPS(i,1,N){
		ans = gcd(ans,A[i]);
	}

	cout << ans << endl;

	return 0;
}



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

int a; //cm
int b; //cm
int h, m;

int main(){
    static const long double pi = 3.1415926535897932384626433832795;
    cin >> a >> b;
    cin >> h >> m;
    long double phi_a = (30 * h + m / 2.0)/360.0 * 2*pi;
    long double phi_b = (6 * m)/360.0 * 2 * pi;
    long double ans = sqrt(a*a + b*b - 2*a*b*cosl(phi_a - phi_b));
    cout << fixed << setprecision(12) << ans;
	return 0;
}

Measured memory_bytes: 4164
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    int a,b;
    
    while(cin>>a){
        cin>>b;
        a=a+b;
        int ans=0;
        while(a>0){
            a=a/10;
            ans++;
        }
        cout<<ans<<endl;
    }




return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[n+1],b[n];
    for (int i = 0; i <= n; ++i) {
        cin>>a[i];
    }
    for (int j = 0; j < n; ++j) {
        cin>>b[j];
    }
    ll ans=0;
    for (int k = 0; k < n; ++k) {
        if(a[k]>=b[k])ans+=b[k];
        else{
            ans+=a[k];
            ans+=min(a[k+1],b[k]-a[k]);
            a[k+1]=max(a[k+1]+a[k]-b[k],0);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    ll x;
    cin >> x;
    ll ans = 0, a = 100;
    while(a < x) {
        a += a/100;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

// const int mxN = 1e9 + 7;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

string s[6];

int main()
{
	fast;
	int h, w, k, ans = 0;
	cin >> h >> w >> k;
	FOR(h)
	cin >> s[i];
	FOR(1 << h)
	{
		FOR(j, 1 << w)
		{
			int black = 0;
			FOR(i2, h)
			{
				FOR(j2, w)
				{
					if (i & (1 << i2) && j & (1 << j2) && s[i2][j2] == '#')
						black++;
				}
			}
			if (black == k)
				ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3624
using System;
using System.Linq;
public class Program {
  public static void Main() {
    long[] input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    if (input[3] % 2 == 0) {
      Console.WriteLine(input[0]-input[1]);
    } else {
      Console.WriteLine((input[0]-input[1])*-1);
    }
  }
}


Measured memory_bytes: 13268
#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;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int A[N];
    int B[N];
    ll d=0;
    ll cnt=0;
    vector<int> y;
    REP(i,N){
        cin>>A[i];
    }
    REP(i,N){
        cin>>B[i];
    }    
    REP(i,N){
        if(A[i]>=B[i]){
            y.pb(A[i]-B[i]);
        }else{
            d+=B[i]-A[i];
            cnt++;
        }
    }
    if(d<=0){
        cout<<0<<endl;
        return 0;
    }
    sort(all(y));
    REP(i,y.size()){
        d-=y[y.size()-i-1];
        if(d<=0){
            cout<<i+1+cnt<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 4988
N = int(input())
M = {}
for n in range(1, N+1):
  f = 2
  while n > 1:
    if n%f == 0:
      if not(f in M): M[f] = 0
      M[f] += 1
      n = n//f
    else:
      f += 1
#print(M)
fs2 = list(filter(lambda f: M[f] >= 2, M))
fs4 = list(filter(lambda f: M[f] >= 4, M))
fs14 = list(filter(lambda f: M[f] >= 14, M))
fs24 = list(filter(lambda f: M[f] >= 24, M))
fs74 = list(filter(lambda f: M[f] >= 74, M))
#print(fs2, fs4, fs14, fs24, fs74)
ps = set()
for f in fs74:
  ps.add(f**74)
for f1 in fs24:
  for f2 in fs2:
    if len({ f1, f2 }) == 2:
      ps.add(f1**24*f2**3)
for f1 in fs14:
  for f2 in fs4:
    if len({ f1, f2 }) == 2:
      ps.add(f1**14*f2**4)
for f1 in fs4:
  for f2 in fs4:
    for f3 in fs2:
      if len({ f1, f2, f3 }) == 3:
        ps.add(f1**4*f2**4*f3**2)
#print(ps)
r = len(ps)
print(r)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int X = Math.min(N,M);
        int count = Math.max(N,M);
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<count;i++){
            sb.append(X);
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 21460
n = int(input())
h = list(map(int,input().split()))
max_ = 0
tmp = 0
for i in range(n-1):
  if h[i+1] <= h[i]:
    tmp += 1
  else:
    tmp = 0
  if max_ < tmp:
    max_ = tmp # max_ の更新
print(max_)


Measured memory_bytes: 14224
#include<stdio.h>
int main(void){
	int p,q,H,W;
	while(1){
		scanf ("%d %d",&H,&W);
		if (H == 0 && W == 0) break;
		for (p = 0; p < H; p++){
			for (q = 0; q < W; q++){
				if (p == 0 || p == H-1 || q == 0 || q == W-1){
					printf ("#");
				}
				else printf (".");
			}
			printf("\n");
		}
		printf ("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import java.util.*;

// ARC 77-C
// http://arc077.contest.atcoder.jp/tasks/arc077_a

public class Main {
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		int H = in.nextInt();
		int W = in.nextInt();
		
		int[] freq = new int[26];
		for (int i = 0; i < H; i++) {
			char[] c = in.next().toCharArray();
			for (int j = 0; j < c.length; j++) {
				freq[c[j] - 'a']++;
			}
		}
		
		if (H == 1 || W == 1) {
			int numRemaining = 0;
			int index = 0;
			while (index < 26) {
				if (freq[index] >= 2) {
					freq[index] -= 2;
				} else {
					numRemaining += freq[index];
					index++;
				}
			}
			
			System.out.println(numRemaining == Math.max(H,  W) % 2 ? "Yes" : "No");
		} else {
			int num2Ok = 0;
			int num1Ok = 0;
			
			if (H % 2 == 1) {
				num2Ok += W / 2;
			}
			if (W % 2 == 1) {
				num2Ok += H / 2;
			}
			if (H % 2 == 1 && W % 2 == 1) {
				num1Ok = 1;
			}
			
//			System.out.printf("num2Ok: %d, num1Ok: %d\n", num2Ok, num1Ok);
			
			int index = 0;
			boolean answer = true;
			while (index < 26 && answer) {
//				System.out.printf("index: %d, freq[index]: %d\n", index, freq[index]);
				if (freq[index] >= 4) {
					freq[index] -= 4;
				} else if (freq[index] == 2 && num2Ok > 0) {
					freq[index] -= 2;
					num2Ok--;
					index++;
				} else if (freq[index] == 1 && num1Ok > 0) {
					freq[index] -= 1;
					num1Ok--;
					index++;
				} else if (freq[index] == 0) {
					index++;
				} else {
					answer = false;
				}
			}
			System.out.println(answer ? "Yes" : "No");
		}
	}
	
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 1000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << endl;
const int LG = 22;
 

 
#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
 
 
    string s;
    cin >> s;

    int l = s.length();
    int dp[l][13];
    init(dp,0);

    for(int i = 0; i < l; i++){
       
        if(i == 0){
            if(s[0] == '?'){
                for(int j = 0; j < 10; j++)
                    dp[i][j] = 1;
            }else{
                dp[i][s[i] - '0'] = 1;
            }

        }else{
            if(s[i] == '?'){
                for(int j = 0; j < 13; j++){
                    for(int k = 0; k < 10; k++){
                        dp[i][(j * 10 + k) % 13] += dp[i - 1][j];
                        dp[i][(j * 10 + k) % 13] %= M;
                    }
                }
            }else{
                for(int j = 0; j < 13; j++){
                    dp[i][(j * 10 + s[i] - '0') % 13] += dp[i - 1][j];
                    dp[i][(j * 10 + s[i] - '0') % 13] %= M;
                }
            }
        }
    }

    cout << dp[l - 1][5] << endl;
    
return 0;
}

Measured memory_bytes: 10704
#include<bits/stdc++.h>
#define Bye return 0
#define ll long long

using namespace std;

void solve(){
   int n, m; cin>>n>>m;

   vector<int> h(n), cont_got(n), cont_total(n);
   for (int i=0; i<n; i++) cin>>h[i];

   for (int i=0; i<m; i++){
       int u, v; cin>>u>>v; u--; v--;

       cont_got[u] += (h[u]>h[v]);
       cont_got[v] += (h[v]>h[u]);

       cont_total[u]++;
       cont_total[v]++;
   } 

   int res = 0;
   for (int i=0; i<n; i++)
        res += (cont_total[i] == cont_got[i]);

    cout<<res<<endl;
}

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

Measured memory_bytes: 4592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5],i,c;
    for(i=0; i<5; i++)
    {
        cin>>a[i];
        if(a[i]==0)
        c=i+1;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
ll n,k;
string s;
 
void solve(){
    ll unhp1,unhp2;
    unhp1=0;unhp2=0;
    rep(i,n){
        if(i==0 && s[i]=='L'){
            unhp1++;
        }
        if(i==n-1 && s[i]=='R'){
            unhp1++;
        }
        if(0<i){
            if(s[i-1]!=s[i] && s[i-1]=='R' && s[i]=='L') unhp2++;
        }
    }
    ll ans=0;
    if(k>=unhp2){
        ans+=2*unhp2;
        k-=unhp2;
    }
    else{
        ans+=2*k;
        k=0;
    }
    if(k>0 && unhp1>1) ans++;
    ll unhappy=2*unhp2+unhp1-ans;
    if(unhappy!=0) cout << n-unhappy << endl;
    else cout << n-1 << endl;
}
 
int main(){
    cin >> n >> k >> s;
    solve();
}
 


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>

using namespace std;


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

    int A,B;
    string S;
    cin>>A;
    cin>>B;
    cin>>S;

    bool isOk=true;
    for(int i=0;i<A;i++){
        if(S[i]=='-'){
            isOk=false;
        }
    }
    if(S[A]!='-'){
        isOk=false;
    }
    for(int i=A+1;i<A+B+1;i++){
        if(S[i]=='-') {
            isOk = false;
        }
    }

    if(isOk){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
#define eps 1e-9
using namespace std;
bool lessThan( double a, double b ){ 
	if ( a + eps < b ) return true; 
	else return false; 
}
int main(){
	int n;
	double T,A;
	cin>>n>>T>>A;
	double h[n+2], t;
	double minDif = 1e9;
	int id;
	for(int i=0;i<n;i++){
		cin>>h[i];
		t = T-0.006*h[i];
		if(fabs(A-t) < minDif) {
			id = i+1;
			minDif = fabs(A-t);
		}
	}
	printf("%d\n",id);
	return 0;
}

Measured memory_bytes: 256
/*
     AUTHOR : Ankit Kumar
     BRANCH : Information Technology
     INSTITUTE : Birla Institute of Technology
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MP make_pair
#define SET(a,val) memset(a,val,sizeof(a))
#define deci(n)         cout<<fixed<<setprecision(n);
#define show(a,l,r) for(int i=l;i<r;i++) cout<<a[i]<<" ";
const int N=100004;
const int dx[] = {-1, 0, 1, 0, -1,-1, 1, 1};
const int dy[] = { 0, 1, 0,-1, -1, 1,-1, 1};
char dir[]={'L','D','R','U'};
//int dx[]={2,-2,1,-1,2,-2,1,-1};//for knights
//int dy[]={1,1,2,2,-1,-1,-2,-2};
typedef long long int ll;
typedef long double ld;
const ll mod=1e9+7;
const ll inf=1e18+100;
int BIT[100005],n;
int prime[17],spf[17];
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
template<typename T> T min3(T a,T b,T c) {return min(a,min(b,c));}
template<typename T> T max3(T a,T b,T c) {return max(a,max(b,c));}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
ll mInv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
return x;
}
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x)% mod;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void update(int x, int delta)
{
    if(!x)
    {
        BIT[x]+=delta;
        return;
    }
      for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
ll query(int x)
{
     ll sum = BIT[0];
     for(; x > 0; x -= x&-x)
        sum += BIT[x];
     return sum;
}
void Sieve()
{
    for(int i=1;i<=N;i++)
        prime[i]=1;
    prime[0]=0;
    prime[1]=0;
    for (ll p=2; p*p<=N; p++)
    {
        if (prime[p] == 1)
        {
            for (ll i=p*p; i<=N; i += p)
                prime[i] = 0;
        }
    }
    for(int p=3;p<=N;p++)
        prime[p]+=prime[p-1];
}
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<N; i++)
        spf[i] = i;
    for (int i=4; i<N; i+=2)
        spf[i] = 2;
    for (ll i=3; i*i<N; i++)
    {
        if (spf[i] == i)
        {
            for (ll j=i*i; j<N; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
                         /******************Lets Code*******************/

int main()
{
    fast
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int d=n%10;
        if(d==2 || d==4 || d==5 || d==7 || d==9)
        cout<<"hon\n";
        else if(d==0 || d==1 || d==6 || d==8)
        cout<<"pon\n";
        else
        cout<<"bon\n";
    }
   	return 0;
}


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

const int64_t C = 1000000007;

int64_t inv(int64_t N){
  int64_t res = 1;
  int64_t pow = C-2;

  while(pow > 0){
    if (pow & 1){
      res = (res * N) % C;
    }
    N = (N * N) % C;
    pow /= 2;
  }
  return res;
}

int64_t comb(int N, int M){
  int64_t A=1, B=1;
  for(int i=0; i<M; i++){
    A = (A * (N-i)) % C;
    B = (B * (M-i)) % C;
  }

  return  (A * inv(B)) % C;
}


int main(){
  int X, Y;
  cin >> X >> Y;

  int A = 2*Y - X, B = 2*X - Y;

  if (A < 0 || B < 0 || A % 3 != 0 || B % 3 != 0){
    cout << 0 << endl;
    return 0;
  }

  A /= 3; B /= 3;

  cout << comb(A+B, min(A,B)) << endl;
}

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

using ll = long long;

bool done[200000];
int cnt[200000];
vector<int> edge[200000];

void dfs(int v) {
    done[v] = true;
    rep(i, edge[v].size()) {
        int j = edge[v][i];
        if (done[j]) continue;
        cnt[j] += cnt[v];
        dfs(j);
    }
    return;
}

int main() {
    rep(i, 200000) done[i] = false;
    rep(i, 200000) cnt[i] = 0;
    int N, Q, a, b, p, x;
    cin >> N >> Q;
    rep(i, N - 1) {
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    rep(i, Q) {
        cin >> p >> x;
        cnt[p - 1] += x;
    }
    dfs(0);
    rep(i, N) cout << cnt[i] << " ";
    cout << endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }


int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    vector<int> dp(n);
    rep(i,n) dp.at(i) = INF;
    dp.at(0) = 0;
    dp.at(1) = abs(h.at(1) - h.at(0));
    FOR(i,2,n-1) {
        chmin(dp.at(i),dp.at(i-1) + abs(h.at(i)-h.at(i-1)));
        chmin(dp.at(i),dp.at(i-2)+ abs(h.at(i)-h.at(i-2)));
    }
    cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 1024
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print("Yes")
else:
  print("No")
  

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

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  ll H = 0,W = 0;
  for (auto p : mp) {
    if (p.second >= 4) H = p.first, W = p.first;
    else if (p.second >= 2) {
      W = H, H = p.first;
    } 
  }
  cout << H * W << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll N;
  cin >> N;
  ll total = 0;
  for(int i = 1;i<= N;i++){
    if(i % 3 == 0 || i % 5 == 0){

    }else{
      total += i;
    }
  }
  cout << total << endl;
 return 0;
}

Measured memory_bytes: 3624
/*
R         R R R R        R        R R R      R      R    R    R      R    R R R R                                                     
R         R             R R       R    RR    R R    R    R    R R    R    R              
R         R            R   R      R R R      R  R   R    R    R  R   R    R   R R                 
R         R R R       R R R R     R R        R   R  R    R    R   R  R    R     R                       
R         R          R       R    R   RR     R    R R    R    R    R R    R     R           
R R R R   R R R R   R         R   R     RR   R      R    R    R      R    R R R R               

*/


#include<bits/stdc++.h>
using namespace std;
#define  bf            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll            long long
#define  pb            push_back
#define  pr            10
#define  mx            100000 // 10^6
#define  md            1000000007
#define  result(a)     cout<<a<<endl;
#define  forr(a,x)     for(int i=a;i<=x;i++)
#define  input(n,a)    int a[n];for(int i=0;i<n;i++)cin>>a[i];
#define  print(a)      for(auto it:a)cout<<it<<' '; //0-based 
#define  printt(n,a)   for(i=0;i<n;i++)cout<<a[i]<<' '; //1-based 
#define  sz(a)         cout<<a.size()<<endl; 
#define  prefx(n,a)    for(i=1;i<n;i++)a[i]=a[i-1]+a[i]; //0-based
#define  sortt(v)      sort(v.begin(),v.end());
#define  srt(n,a)      sort(a,a+n);
#define  rev(n,a)      reverse(a,a+n);
#define  revr(a)       reverse(a.begin(),a.end());
#define  yes           cout<<"yes\n";
#define  no            cout<<"no\n";

int main()
{
  int N,sum=0,tmp=0;
	scanf("%d", &N);
  tmp = N;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (N % sum == 0) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
  
}

Measured memory_bytes: 3812