akhauriyash/Code-Regression huggingface dataset:
/*
        HELLO WORLD
        -----------
        SHUBHAM
        -----------
        :) CODING
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ff                                         first
#define ss                                         second
#define pb                                         push_back
#define int                                        long long
#define mp                                         make_pair
#define pii                                        pair<int,int>
#define vi                                         vector<int>
#define mii                                        map<int,int>
#define umii                                       unordered_map<int,int>
#define pqb                                        priority_queue<int>
#define pqs                                        priority_queue<int,vi,greater<int>>
#define setbits(x)                                 __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                        1000000007
#define inf                                        1e18
#define ps(x,y)                                    fixed<<setprecision(y)<<x
#define mk(arr,n,type)                             type *arr=new type[n]
#define test(t)                                    int t;cin>>t;while(t--)
#define rep(i,n)                                   for(int i=0;i<n;i++)
#define rep1(i,n)                                  for(int i=1;i<=n;i++)
#define fio                                        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SIZE                                       100005
#define all(x)                                     (x).begin(),(x).end()
#define sclk()                                     auto start_time = Clock::now()
#define eclk()                                     auto end_time = Clock::now();  cout << "\nTime Taken : " << chrono::duration_cast<chrono::milliseconds>(end_time    - start_time).count() << " ms"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef std::chrono::high_resolution_clock Clock;

int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}

void f_io()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
}
int dp[105][100005];
int arr[105];
int solve(int n,int k)
{
    if(k==0)
        return 1;
    if(n<0 || k<0)
        return 0;
    if(dp[n][k]==-1)
    {
       dp[n][k]=(solve(n-1,k) + solve(n,k-1) - solve(n-1,k-1-arr[n]) + mod)%mod;
    }
    return dp[n][k];
}
int32_t main()
{
    memset(dp,-1,sizeof(dp));
    int n,k;
    cin>>n>>k;
    rep(i,n)
    {
        cin>>arr[i];
    }
    cout<<solve(n-1,k);
    return 0;
}


Measured memory_bytes: 86912
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveC();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);

		final long MOD = 1000000007;
		long N = sc.nextInt();
		long M = sc.nextInt();

		if (N - M > 1 || M - N > 1) {
			System.out.println(0);
		} else {
			if (N == M) {
				System.out.println(2 * perm(N, MOD) * perm(N, MOD) % MOD);
			} else {
				System.out.println(perm(N, MOD) * perm(M, MOD) % MOD);
			}
		}
	}

	private long perm(long N, long mod) {
		long mul = 1L;
		for (; N > 0; N--) {
			mul = (mul * N) % mod;
		}
		return mul;
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... lcmv) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,lcmv...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){ 
    cin.tie(nullptr); ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

int main() {
    ll N, M;
    cin >> N >> M;
    auto a = scan<vector<ll>>(N);
    for (ll& x : a) {
        x /= 2;
    }
    ll lcmv = 1;
    ll gcdv = a[0];
    for (ll b : a) {
        lcmv = lcm(lcmv, b);
        gcdv = gcd(gcdv, b);
        if (lcmv > M) {
            cout << 0 << LN;
            return 0;
        }
    }
    dump(lcmv, gcdv);
    if ((lcmv / gcdv) % 2 == 0) {
        cout << 0 << LN;
        return 0;
    }
    int count = 0;
    for (ll i = 1; i * lcmv <= M; i += 2) {
        count++;
    }
    cout << count << LN;
}


Measured memory_bytes: 1024
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():
    d = Debug()
    d.off()
    N = getInt()
    S = input()
    K = getInt()
    d.dmp((N, S, K),'N, S, K')
    keep = S[K-1]
    newS = ''
    for c in S:
        if c == keep:
            newS += c
        else:
            newS += '*'
    return newS

ans = prob()
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    for (int i=1; i<10; i++) {
        if (n%i == 0) {
            if (n/i < 10) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b;
        scanf("%d%d",&a,&b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<string.h>

struct guide{
    char s[10];
    int p,n;
};

int main(){
    int n,k=0;
    scanf("%d",&n);
    struct guide guide[n],tmp;
    for(int i=0;i<n;i++){
        guide[i].n=i+1;
        scanf("%s %d",guide[i].s,&guide[i].p);
    }
    for(int h=0;h<n;h++){
        for(int j=1;j<n;j++){
            if(strcmp(guide[j-1].s,guide[j].s)>0){
                tmp=guide[j-1];
                guide[j-1]=guide[j];
                guide[j]=tmp;
            }
            if(strcmp(guide[j-1].s,guide[j].s)==0){
                if(guide[j-1].p<guide[j].p){
                    tmp=guide[j-1];
                    guide[j-1]=guide[j];
                    guide[j]=tmp;
                }
            }
        }
    }
    while(k!=n){
        printf("%d\n",guide[k].n);
        k++;
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define Phuong ios_base::sync_with_stdio(0); cin.tie(0);
#define mpp make_pair
#define pb push_back

typedef long long ll;
using namespace std;
typedef pair<int,int> pii;

int main()
{
#ifndef RICARDO
    //freopen("input.inp", "r", stdin);
#endif // RICARDO
    Phuong;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int dem=0;
    for(int i=0; i<=n-3; ++i)
    {
        if (s[i]=='A' && s[i+1] =='B' && s[i+2] == 'C') dem++;
    }
    cout << dem;
    return 0;
}


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

const int N = 4005;
const int mod = 998244353;

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int mul(int x,int y) {
	return (long long) x * y % mod;
}

int pw(int x,int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = mul(ret, x);
		x = mul(x, x);
		y >>= 1;
	}
	return ret;
}

int n, k;
int fac[N], ifac[N], pw2[N];

int C(int n,int k) {
	if (n < k || k < 0) return 0;
	return mul(fac[n], mul(ifac[k], ifac[n - k]));
}

int candy(int n,int k) {
	return C(n + k - 1, k - 1);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> k >> n;
	fac[0] = 1; pw2[0] = 1;
	for (int i = 1; i <= n + k; ++i) fac[i] = mul(fac[i - 1], i), pw2[i] = mul(pw2[i - 1], 2);
	ifac[n + k] = pw(fac[n + k], mod - 2);
	for (int i = n + k - 1; i >= 0; --i) ifac[i] = mul(ifac[i + 1], i + 1);
	for (int i = 2; i <= k + k; ++i) {
		int f = 0, g = 0;
		for (int j = 1; j <= k; ++j) {
			int l = i - j;
			if (l < 1 || l > k) f++;
			else if (j < l) f++, g++;
		}
		int ans = 0;
		for (int j = 0; j <= g; ++j) {
			int coef = candy(n - j, f - g + j);
			if (i % 2 == 0) add(coef, candy(n - j - 1, f - g + j));
			coef = mul(coef, mul(pw2[j], C(g, j)));
			add(ans, coef);
		}
		cout << ans << '\n';
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  cin>>n;
  while(n--){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b)swap(a,b);
    if(b>c)swap(b,c);
    if(a*a+b*b==c*c){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == '9'  ||  n[1] == '9')
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
from collections import deque

n, x, m = map(int, input().split())

A = [-1] * (10 ** 5)

i = 1
A[x] = i
sum = []
sum.append(0)
sum.append(x)
while i < n:
    i += 1
    x = (x * x) % m
    if A[x] != -1:
        break
    A[x] = i
    sum.append(sum[-1] + x)

if i == n:
    print(sum[n])
    exit()

pre_i = A[x]
dis = i - pre_i
cnt = (n + 1 - pre_i) // dis
div = (n + 1 - pre_i) % dis
ans = sum[pre_i - 1]
ans += (sum[i - 1] - sum[pre_i - 1]) * cnt
if div != 0:
    ans += sum[pre_i + div - 1] - sum[pre_i - 1]
print(ans)



Measured memory_bytes: 71304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define INF (1ll<<60)
#define mod 1000000007
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
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,m;cin>>n>>m;
    vector<P> p(m);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        p[i]=make_pair(a,b);
    }
    sort(p.begin(),p.end());
    p.push_back({-1,-1});

    P Pair=make_pair(0,n-1);
    ll ans=0;
    rep(i,m+1){
        bool no=true;
        if(Pair.first<=p[i].first && p[i].first<Pair.second){
            Pair.first=p[i].first;
            no=false;
        }
        if(Pair.first<p[i].second && p[i].second<=Pair.second){
            Pair.second=p[i].second;
            no=false;
        }
        if(no==true || i==m){
            ans++;
            //cout<<"ch:"<<Pair.first<<" "<<Pair.second<<endl;
            Pair=p[i];
        }
    }

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

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    string s, t;
    cin >> s >> t;
    for(char c = 'a'; c <= 'z'; c++) {
        if(t == s + c) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

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


Measured memory_bytes: 3632
#include <stdio.h>
int main(){


         unsigned   long long int n,res;;
         int i;
            while(scanf("%llu",&n)==1){
                    res=1;

                for(i=2;i<=n;i++){
                    res=res*i;}
            printf("%llu\n",res);



            }

return 0;


}

Measured memory_bytes: 1032
N = int(input())
A = list(map(int,input().split(" ")))
A.sort()
used = [0] * N
pow2_set = reversed([ 1<<i for i in range(36)])
ans = 0
for pow2 in pow2_set:
    l,r = 0,N-1
    while l < r:
        if A[l] + A[r] < pow2:
            l += 1
        elif A[l] + A[r] == pow2:
            if used[l] == 0 and used[r] == 0:
                ans += 1
                used[l],used[r] = 1,1
            else:
                if used[l] == 1:
                    l += 1
                if used[r] == 1:
                    r -= 1
        else:
            r -= 1
 
print(ans)

Measured memory_bytes: 86364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    char c = 'a';
    int cnt = 1, same = 1, ans = 0;
    for(int i = 0; i < n; i++) {
        if(i == 0) c = s[i];
        else {
            if(c != s[i]) {
                ans += same - 1;
                cnt++;
                same = 1;
            } else {
                same++;
            }
            c = s[i];
        }
    }
    ans += same - 1;
    if(cnt & 1) ans += min(cnt / 2, k) * 2;
    else {
        int t = min((cnt - 2) / 2, k);
        ans += t * 2;
        k -= t;
        if(k > 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

n = int(input())
v = [0] + list(map(int, input().split()))

odd = {}
even = {}
for i in range(1, n+1):
    if i % 2 == 0:
        if v[i] not in even:
            even[v[i]] = 1
        else:
            even[v[i]] += 1
    else:
        if v[i] not in odd:
            odd[v[i]] = 1
        else:
            odd[v[i]] += 1

even = list(reversed(sorted(map(lambda x: (x[1], x[0]), list(even.items())))))
odd = list(reversed(sorted(map(lambda x: (x[1], x[0]), list(odd.items())))))

ans = 0
if len(even) == 1 and len(odd) == 1:
    if even[0][1] != odd[0][1]:
        ans = 0
    else:
        ans = n // 2
elif len(even) == 1:
    if even[0][1] != odd[0][1]:
        ans = n - (even[0][0] + odd[0][0])
    else:
        ans = n - (even[0][0] + odd[1][0])
elif len(odd) == 1:
    if even[0][1] != odd[0][1]:
        ans = n - (even[0][0] + odd[0][0])
    else:
        ans = n - (even[1][0] + odd[0][0])
else:
    if even[0][1] != odd[0][1]:
        ans = n - (even[0][0] + odd[0][0])
    else:
        ans = n - max( (even[1][0] + odd[0][0]) , (even[0][0] + odd[1][0]) )

print(ans)


Measured memory_bytes: 65516
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 18;
char C[CM + CL], * ci = C + CL, * owa = C + CM, c;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;

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


	fread(ci, 1, CM, stdin);
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';
	int D[10];
	int d = 1;
	rep(i, 10) {
		D[i] = d;
		d *= 10;
	}

	ll p[20][20] = {};
	rep(i, N) {
		if (ci - owa > 0) {
			memcpy(C, owa, CL);
			ci -= CM;
			fread(C + CL, 1, CM, stdin);
		}

		ll kari = 0;
		while ((c = *ci++) >= '0') kari = kari * 10 + c - '0';
		int d = 9;
		if (*(ci - 1) == '.') {
			ll tmp = *(ll*)ci;
			if ((tmp & ma0) ^ ma0) {
				int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
				tmp = tmp << dig & ma1;
				tmp = tmp * 10 + (tmp >> 8) & ma2;
				tmp = tmp * 100 + (tmp >> 16) & ma3;
				tmp = tmp * 10000 + (tmp >> 32) & ma4;
				ci += (72 - dig >> 3);
				d -= (64 - dig >> 3);
				kari = kari * D[(64 - dig >> 3)] + tmp;
			}
			else {
				tmp = tmp & ma1;
				tmp = tmp * 10 + (tmp >> 8) & ma2;
				tmp = tmp * 100 + (tmp >> 16) & ma3;
				tmp = tmp * 10000 + (tmp >> 32) & ma4;
				ci += 8;
				d -= 8;
				kari = kari * 100000000 + tmp;
				if (*ci >= '0') {
					kari = kari * 10 + *ci++ - '0';
					d--;
				}
				ci++;
			}
		}
		int a = __builtin_ctzll(kari) + d;
		if (a > 18) a = 18;
		int b = d;
		while (kari % 5 == 0) {
			b++;
			kari /= 5;
		}
		p[a][b]++;
	}
	ll kotae = 0;
	rep(a, 19) rep(b, 19) if (p[a][b]) {
		ll P = p[a][b];
		for (int x = max(a, 18 - a); x <= 18; x++) {
			if (x == a) {
				for (int y = max(b, 18 - b); y <= 18; y++) {
					if (y == b) kotae += P * (P - 1) / 2;
					else kotae += P * p[x][y];
				}
			}
			else {
				for (int y = 18 - b; y <= 18; y++) {
					kotae += P * p[x][y];
				}
			}
		}
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

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


int main() {
	int r, c;
	cin >> r >> c;
	vector<int> vec(c, 0);
	int total=0;
	for (int row=0; row!=r; ++row){
		int rowsum = 0;
		for (int col=0; col!=c; ++col){
			int val;
			cin >> val;
			cout << val << ' ';
			vec[col] += val;
			rowsum += val;
		}
		cout << rowsum << endl;
		total += rowsum;
	}
	for (auto v: vec){
		cout << v << ' ';
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
const double PI = 3.141592653589793;

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

int n,k,a[200010],f[200010];

bool bisearch(int x){
	int lim[200010];
	for(int i = 0;i < n;i++){
		lim[i] = x / f[i];
	}
	sort(lim,lim + n);
	int shugyo = 0;
	for(int i = 0;i < n;i++){
		shugyo += max(a[i] - lim[i],0ll);
	}
	return shugyo <= k;
}

signed main(){
	cin >> n >> k;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++) cin >> f[i];
	sort(a,a + n);
	int ng = -1,ok = INF;
	while(ok - ng > 1){
		int mid = (ok + ng) / 2;
		if(bisearch(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
int main(void) {
	int h1=0, h2=0, k1=0, k2=0, a=0, b=0, c=0, d=0,ha,hb,ka,kb;
	scanf("%d %d", &h1, &h2);
	scanf("%d %d", &k1, &k2);
	scanf("%d %d %d %d", &a, &b, &c, &d);
	ha = h1*a+((h1/10)*c);
	hb = h2*b+((h2/20)*d);
	ka = k1*a+((k1/10)*c);
	kb = k2*b+((k2/20)*d);
	if (ha + hb > ka + kb) {
		printf("hiroshi\n");
	}
	else if (ha + hb < ka + kb) {
		printf("kenjiro\n");
	}
	else {
		printf("even\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include <functional>
using namespace std;
static const int MAX = 100000;
typedef long long llong;

int n, m;
vector<int> v;

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

    int x;
    for (int i = 0; i < n;i++){
        scanf("%d", &x);
        v.push_back(x);
    }
    sort(v.begin(), v.end());

    int z;
    for (int i = 0; i < m; i++){
        z = v[v.size() - 1] / 2;
        //v[0]を二分探索で挿入
        v.insert(lower_bound(v.begin(), v.end(), z), z);
        v.pop_back();
    }

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

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 1000010;

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

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

    // 自分のチャンス
    vector<int> l(MAX_N, 0);
    vector<int> r(MAX_N, 0);
    REP(i, N) {
        if(A[i] > MAX_N) { continue; }
        if(i < N - 2) {
            int val = A[i] + i - 1;
            if(val < MAX_N && val >= 0) {
                l[A[i] + i - 1]++;
            }
        }
        if(i > 1) {
            int val = i - A[i] - 1;
            if(val < MAX_N && val >= 0) {
                r[i - A[i] - 1]++;
            }
        }
    }
    int ans = 0;
    REP(i, MAX_N) {
        ans += l[i] * r[i];
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 20360
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
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*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8


int main(){
    char S[29];cin>>S;
    ll K=0;
    sort(S,S+strlen(S));
    rep(i,strlen(S)-1){
        if(S[i]==S[i+1]){
            K++;
        }
    }
    cout << (K==0 ? "yes" : "no")  << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,temp;
	cin>>n;
	temp=n;
	int dig;
	string s="";
	while(n)
	{
		n=n-1;
		char a=(char)'a'+n%26;
		s=a+s;
		n=n/26;
		
		
	}
	cout<<s<<"\n";

	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3628
ans=[0 for i in range(26)]
n=int(input())
s=input()
for j in range(len(s)):
    ans[ord(s[j])-97]+=1
if n>1:
    for i in range(n-1):
        tmp=[0 for i in range(26)]
        s=input()
        for j in range(len(s)):
            tt=ord(s[j])-97
            tmp[tt]+=1
        for k in range(26):
            if tmp[k]<ans[k]:
                ans[k]=tmp[k]
a=""
for i in range(26):
    a+=chr(i+97)*ans[i]
print(a)

Measured memory_bytes: 70496
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int N; cin >> N;
    vector<ll> a(N,0);
    rep(i,N) cin >> a[i];
    map<int, int> counter;
    ll ans = 0;
    
    rep(i,N){
        counter[a[i]+i]++;
    }
    rep(i,N){
        ans += counter[i-a[i]];
    }

    cout << ans << endl;

}

Measured memory_bytes: 21756
#include<stdio.h>
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  long long n,m,a,h,w,s=0,i,j;
  scanf("%lld %lld",&w,&h);
  for(i=0;i<w+h;i++){
    scanf("%lld",&a);
    hin(a);
    s+=a;
  }
  n=w;
  m=h;
  for(i=0;i<h+w;i++){
    j=hout();
    if(j<=w){
      s+=N[j]*m;
      n--;
    }
    else{
      s+=N[j]*n;
      m--;
    }
  }
  printf("%lld\n",s);
  return 0;
}
		    


Measured memory_bytes: 5760
#include <stdio.h>
 
int width,height;
char map[20][21];
 
int tansaku(int x,int y) {
    int result=1;
    if(x<0 || x>=width || y<0 || y>=height)return 0;
    if(map[y][x]=='#')return 0;
    map[y][x]='#';
    result+=tansaku(x-1,y);
    result+=tansaku(x+1,y);
    result+=tansaku(x,y-1);
    result+=tansaku(x,y+1);
    return result;
}
 
int main(void) {
    int i,j;
    int sx,sy;
    while(1) {
        scanf("%d%d",&width,&height);
        if(width==0 && height==0)break;
        for(i=0;i<height;i++) {
            scanf("%s",map[i]);
            for(j=0;j<width;j++) {
                if(map[i][j]=='@'){sx=j;sy=i;}
            }
        }
        printf("%d\n",tansaku(sx,sy));
    }
    return 0;
}

Measured memory_bytes: 620
/*
Owner: dxxrk
Problem: Addition
Date: 22/11/2019
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	long long n; cin >> n;
	
	long long e = 0, o = 0;
	for(long long i = 0; i < n; i++){
		long long x; cin >> x;
		if(x & 1){
			o++;
		}
		else {
			e++;
		}
	}
	
	e += (o / 2);
	o %= 2;
	
	if(e + o == 1 || (e && !o)){
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int m=in.nextInt();
		char c[][]=new char[n][m];
		for(int i=0;i<n;i++)
		{
			c[i]=in.next().toCharArray();
		}
		if(c[0][0]=='#')
			System.out.println(0);
		int dp[][]=new int[n][m];
		for(int i=0;i<m;i++)
		{
			if(c[0][i]!='#')
				dp[0][i]=1;
			else
				break;
		}
		for(int i=0;i<n;i++)
		{
			if(c[i][0]!='#')
				dp[i][0]=1;
			else
				break;
		}
		for(int i=1;i<n;i++)
		{
			for(int j=1;j<m;j++)
			{
				if(c[i][j]=='#')
					continue;
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%((int)Math.pow(10, 9)+7);
			}
		}
		if(dp[n-1][m-1]!=0)
			System.out.println(dp[n-1][m-1]);
		else
			System.out.println(0);
	}
}


Measured memory_bytes: 37660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	k := sc.NextInt()

	ans := 0
	for i := 0; i < n; i++ {
		tmp := sc.NextInt()

		if (k - tmp) > tmp {
			ans += tmp * 2
		} else {
			ans += (k - tmp) * 2
		}
	}
	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

void Main()
{
	ll N;
	cin >> N;
	cout << divup(N, 2ll);
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << endl;

	return 0;
}


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

using namespace std;

signed main() {

    int n;
    cin>>n;
    int cnt=0;
    for (int i = 1; i <=n ; ++i) {
        string z=to_string(i);
        if(z.length()%2==1)
            cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
          
#define endl        "\n"
#define int         long long
#define all(v)      v.begin(),v.end()
#define sz(v)       (int)v.size()
#define pii         pair<int,int>
#define fi          first
#define se          second
#define mod         1e9+7
#define forn(i,a,b) for(int i=a;i<b;i++)
#define deb(x)      cout << #x << ' ' << x << endl
#define clock       cerr << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms" << endl;

void solve(){
	int n,m;
	cin>>n>>m;
	int h[n];
	forn(i,0,n) cin>>h[i];
	vector<int>v[100005];
	forn(i,0,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans=0;
	forn(i,0,n){
		int mx=-1;
		for(auto j:v[i]){
			mx=max(mx,h[j]);
		}
		if(mx<h[i])ans++;
	}
	cout<<ans<<endl;
}
 
int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 10252
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int parent[5250], n, m, a, b;
vector<int> edge[5250], ans;
bool used[5250];

void topo(int x){
    if(used[x])return;
    used[x] = true;
    for(int i = 0;i < edge[x].size();i++){
	topo(edge[x][i]);
    }
    cout << x << endl;
    ans.push_back(x);
}

int main(){
    cin >> n >> m;
    for(int i = 0;i < m;i++){
	cin >> a >> b;
	edge[b].push_back(a);
    }

    for(int i = 1;i < n;i++){
	topo(i);
    }
    bool original = true;
    for(int i = 0;i < n - 1;i++){
	int tmp = ans[i + 1], child = ans[i];
	if(find(edge[tmp].begin(), edge[tmp].end(), child) == edge[tmp].end()){
	    original = false;
	    break;
	}
    }
    if(original)cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 2032
from bisect import bisect_left
n=int(input())
a=[int(input()) for _ in range(n)]
dp=[float('inf') for _ in range(n)]
l=[]
l.append(a[0])
dp[0]=a[0]
for i in a[1:]:
    if l[-1]<i:
        l.append(i)
        dp[len(l)-1]=i
    else:
        x=bisect_left(l,i)
        dp[x]=i
        l[x]=i
print(len(l))


Measured memory_bytes: 13780
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
    VS c(h);
    REP(i,h){
        cin >> c[i];
    }

    REP(i,h){
        cout << c[i] << endl;
        cout << c[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)

if S == S[::-1]:
    if S[0:(N-1)//2] == ''.join(list(reversed(S[0:(N-1)//2]))):
        if S[(N+3)//2-1:N] == ''.join(list(reversed(S[(N+3)//2-1:N]))):
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3064
def main():
    n = int(input())
    # t, a = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()
    if n == 7 or n == 5 or n==3 :
        print("YES")
    else: print("NO")



if __name__ == '__main__':
    main()


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

typedef long long ll;

int cnt[32];
int K[31];
int A[31][31];
int main() {
  int N,M; cin >> N >> M;
  for ( int i = 0; i < N; i++ ) {
    cin >> K[i];
    for ( int j = 0; j < K[i]; j++ ) {
      cin >> A[i][j];
      cnt[A[i][j]]++;
    }
  }
  int ans = 0;
  for ( int i  = 1; i <= 30; i++ ) {
    //    cout << cnt[i] << endl;
    if (cnt[i]== N) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
import math
mod = 10**9 + 7

if abs(N-M)>=2:
    print(0)
elif abs(N-M) == 1:
    print(math.factorial(N)*math.factorial(M) % mod)
else:
    print(2*math.factorial(N)*math.factorial(M) % mod)

Measured memory_bytes: 5184
from collections import deque
import sys
input = sys.stdin.readline


n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    _from, to = map(int, input().split())
    edges[_from-1].append(to-1)

start, goal = map(int, input().split())

todo = deque([])
seen = [[False] * n for i in range(3)]
seen[0][start-1] = True
for to in edges[start-1]:
    dim = 1
    dist = 1
    todo.append([to, dim, dist])

while todo:
    node, dim, dist = todo.popleft()
    if seen[dim][node]:
        continue
    seen[dim][node] = True
    dim += 1
    if dim == 3:
        dim = 0
    for to in edges[node]:
        if seen[dim][to]:
            continue
        todo.append([to, dim, dist+1])
        if to == goal-1 and dim == 0:
            print((dist+1)//3)
            exit()

print(-1)

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

S = []
for i in range(m):
    a,b=map(int, input().split())
    S.append([a,b])
road = [[] for i in range(n)]
for i,(a,b) in enumerate(S):
    road[b-1].append(a-1)
    road[a-1].append(b-1)

ans = 0
for i,r_l in enumerate(road):
    cnt = 0
    if not r_l:
        ans+=1
        continue
    for r in r_l:

        if H[i] > H[r]:
            cnt +=1
    if cnt == len(r_l):
        ans+=1
print(ans)

Measured memory_bytes: 44420
n = gets.to_i
s = gets.chomp
ans = s.size
ss = s.count("#")
sc = 0
s.size.times do |i| 
    drf = sc + (s.size - i - ss + sc) 
    ans = [ans, drf].min
    if(s[i] == "#")
        sc += 1 
    else

    end
end
p [ans,s.count("#")].min

Measured memory_bytes: 2172
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static PrintWriter out = new PrintWriter(System.out);
	static Scanner stdIn = new Scanner(System.in);
	static FastScanner sc = new FastScanner();

	
	public static void main(String[] args) {
		int t = sc.nextInt();
		for(int i = 0; i < t; i++) {
			int n = sc.nextInt();
			int nowp = sc.nextInt();
			int cup = 0;
			int cdw = 0;
			for(int j = 1; j < n; j++) {
				int nexp = sc.nextInt();
				if(nexp - nowp < 0) {
					cdw = Math.max(nowp - nexp,cdw);
				}
				else {
					cup = Math.max(nexp - nowp, cup);
				}
				nowp = nexp;
			}
			out.println(cup + " " + cdw);
		}
		out.flush();
		
		
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
     
    public int nextInt() {
        return (int)nextLong();
    }
     
    public double nextDouble() {
        return Double.parseDouble(next());
    }
     
 
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);

    ll k;
    cin >> k;

    queue<ll> q;
    for(ll i = 1; i < 10; i++){
        q.push(i);
    }
    ll v;
    rep(i, k){
        v = q.front();
        q.pop();
        if(v % 10 != 0){
            q.push(v * 10 + v % 10 - 1);
        }
        q.push(v * 10 + v % 10);
        if(v % 10 != 9){
            q.push(v * 10 + v % 10 + 1);
        }
    }
    cout << v << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long min = sc.nextLong();
        for (int i = 1; i < 5; i++) {
            min = Math.min(min, sc.nextLong());
        }
        
        long a = (n-1) / min;
        System.out.println(5+a);
    }
}


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

int main(void) {
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  int64_t answer = 0;
  if (N % 2) {
    int l0 = 0;
    int r0 = N - 1;
    vector<int64_t> B(N);
    B[N / 2] = A[l0++];
    for (int i = 1; i <= N / 2; ++i) {
      B[N / 2 + i] = (i % 2) ? A[r0--] : A[l0++];
      B[N / 2 - i] = (i % 2) ? A[r0--] : A[l0++];
    }
    int64_t tmp_ansB = 0;
    rep(i, N - 1) { tmp_ansB += abs(B[i + 1] - B[i]); }
    answer = max(answer, tmp_ansB);

    int l1 = 0;
    int r1 = N - 1;
    vector<int64_t> C(N);
    C[N / 2] = A[r1--];
    for (int i = 1; i <= N / 2; ++i) {
      C[N / 2 + i] = (i % 2) ? A[l1++] : A[r1--];
      C[N / 2 - i] = (i % 2) ? A[l1++] : A[r1--];
    }
    int64_t tmp_ansC = 0;
    rep(i, N - 1) { tmp_ansC += abs(C[i + 1] - C[i]); }
    answer = max(answer, tmp_ansC);
  } else {
    int l0 = 0;
    int r0 = N - 1;
    vector<int64_t> D(N);
    for (int i = 0; i < N / 2; i++) {
      D[N / 2 - 1 - i] = (i % 2) ? A[l0++] : A[r0--];
      D[N / 2 + i] = (i % 2) ? A[r0--] : A[l0++];
    }
    int64_t tmp_ansD = 0;
    rep(i, N - 1) { tmp_ansD += abs(D[i + 1] - D[i]); }
    answer = max(answer, tmp_ansD);
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N;

    cin >> N;

    if(N % 10 == 3) {
        cout << "bon" << endl;
    } else if ((N % 10 == 0) || (N % 10 == 1) || (N % 10 == 6) || (N % 10 == 8)) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int main(){
	int k,s;
	cin>>k>>s;
	int co=0;
	rep(i,k+1)rep(j,k+1){
		int t=s-i-j;
		if(t<0||k<t)continue;
		co++;
	}
	cout<<co<<endl;
}










Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    string s;
    cin>>s;
    int al[26];
    int i, j;
    for(i=0;i<26;i++){
        al[i]=0;
    }
    int tmp;
    for(auto v:s){
        tmp = (int)v-'a';
        al[tmp]++;
        //cout<<tmp<<endl;
        //cout<<al[tmp]<<endl;
    }
    for(i=0;i<26;i++){
        if(al[i]==0){
            cout<<(char)(i+'a')<<endl;
            break;
        }
        else{
            if(i==25){
                cout<<"None"<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 512