akhauriyash/Code-Regression huggingface dataset:
use std::collections::{BTreeMap, BTreeSet};

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner(s.lock());

    let n: usize = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let b: Vec<u64> = sc.vec(n);
    if solve(a, b) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn solve(a: Vec<u64>, b: Vec<u64>) -> bool {
    let n = a.len();

    let mut ba = (0..n).map(|i| (b[i], a[i])).collect::<Vec<_>>();
    ba.sort();

    let mut a = (0..n).map(|i| (ba[i].1, i)).collect::<Vec<_>>();
    a.sort();

    for i in 0..n {
        if ba[i].0 < a[i].0 {
            return false;
        }
    }

    let mut vis = vec![false; n];
    let mut cur = 0;
    vis[cur] = true;
    cur = a[cur].1;
    while cur != 0 {
        vis[cur] = true;
        cur = a[cur].1;
    }

    if vis.contains(&false) {
        return true;
    }
    for i in 1..n {
        let a = a[i].0;
        let b = ba[i - 1].0;
        if b >= a {
            return true;
        }
    }
    false
}

fn push(map: &mut BTreeMap<u64, usize>, v: u64) {
    *map.entry(v).or_insert(0) += 1;
}

fn remove(map: &mut BTreeMap<u64, usize>, v: u64) {
    let c = *map.get(&v).unwrap();
    if c == 1 {
        let removed = map.remove(&v).unwrap();
        assert_eq!(removed, 1);
    } else if c > 1 {
        map.insert(v, c - 1);
    } else {
        unreachable!()
    }
}

pub struct Scanner<R>(R);

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int n;
    cin >> n;

    string s;
    cin >> s;

    int can=0,ans=0;

            for(int i=0;i<=9;i++){
                for(int j=0;j<=9;j++){
                    for(int k=0;k<=9;k++){
                        for(int l=0;l<s.size();l++){
                            int x=s.at(l)-'0';
                            if(can == 0){
                                if(x == i)can++;
                            }
                            else if(can == 1){
                                if(x == j)can++;
                            }
                            else if(can ==2){
                                if(x == k)can++;
                            }
                        }
                        if(can == 3)ans++;
                        can=0;
                    }
                }
            }
    cout << ans << endl;
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

char letter(string& s, int& idx, int d) {
    switch (s[idx]) {
    case '+':
        idx++;
        return letter(s, idx, d+1);
    case '-':
        idx++;
        return letter(s, idx, d-1);
    case '?':
        idx++;
        return 'A';
    default:
        return (s[idx++] - 'A' + d + 26*10) % 26 + 'A';
    }
    assert(0);
}

string cipher(string& s, int& idx) {
    stringstream ss;
    for (; idx < (int)s.length();) {
        switch (s[idx]) {
        case '[': {
            idx++;
            string r = cipher(s, idx);
            for (int i = r.length()-1; i >= 0; i--) ss << r[i];
            break;
        }
        case ']':
            idx++;
            return ss.str();
        default:
            ss << letter(s, idx, 0);
        }
    }
    return ss.str();
}

int main() {
    string s;
    while (cin >> s, s != ".") {
        int idx = 0;
        //s = "-----A";
        //cout << letter(s, idx, 1) << endl;
        cout << cipher(s, idx) << endl;
    }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

long long suma(string s)
{
    long long a = 0;
    for (int i = 0; i < s.size(); i++)
    {
        char c = s.at(i);
        a += atoi(&c);
    }
    return a;
}

int main()
{
    while (true)
    {
        string s;
        cin >> s;
        if (s == "0")
        {
            break;
        }
        cout << suma(s) << endl;
    }

    return 0;
}


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

namespace CSharpConsoleApp {

    public class Program {
        public static int Main() {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var A = input[0];
            var B = input[1];
            var C = input[2];
            var D = input[3];
            double result = 0;
            if (B <= C)
                result = 0;

            else if (A <= C && D <= B)
                result = D - C;
            else if (C <= A && B <= D)
                result = B - A;

            else if (A <= C && C <= B)
                result = B - C;
            else if (A <= D && D <= B)
                result = D - A;
            result.QBox();
            return 0;
        }
    }
}

public static class Extensions {
    public static void QBox<T>(this T t) {
        Console.WriteLine(t);
    }
}

Measured memory_bytes: 13268
# 062 B
# import sys
# input = sys.stdin.readline

H,W= map(int,input().split())
f = [0] * (H + 2)
for i in range(H):
    block_ = "#"* (W+2)
    if i ==0:
        print(block_)
    x = input()
    x = "#"+ x +"#"
    print(x)
    if i == H-1:
        print(block_)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<map>
#define LL long long
using namespace std;
const int NN=100 +13;
const int mod=998244353;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
int n;
char s[NN]={};
#define PP string
#define PU pair<PP,int>
map<PU,LL> f;
LL v(string s){
	LL res=0;
	for(int i=s.size()-1;i>=0;--i){
		res=res*2+s[i];
	}
	return res;
}
LL dp(string x,int l){
	//printf("%lld %d",v(x),l);
	if(l==0)return 1;
	if(l==1)return v(x)+1;
	LL res=f[make_pair(x,l)];
	if(res)return res-1;
	string a(n,0);
	a[0]=x[0];
	string b;
	b.assign(x,1,n-1);
	b.push_back(0);
	res+=dp(a,1)*dp(b,l-1)%mod;
	string tp;
	for(int len=1;len<=l;++len){
		tp.assign(n,0);
		for(int i=0;i<len;++i){
			tp[i]=x[i];
		}
		for(int i=len;i<l;++i){
			if(x[i]==0&&tp[i%len]!=0)tp[i%len]=0;
			if(i%len==len-1){
				string now(n,0);
				for(int j=i+1;j<n;++j){
					now[j-i-1]=x[j];
				}
				res+=dp(tp,len)*dp(now,l-i-1);
				res%=mod;
			}
		}
	}
	f[make_pair(x,l)]=res+1;
	return res;
}
int main(){
	//freopen("test.in","r",stdin);
	scanf("%s",s);
	n=strlen(s);
	string x(n,0);
	for(int i=n-1;i>=0;--i){
		x[i]=s[i]-'0';
	}
	printf("%lld\n",dp(x,n));
}


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

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

    if(N<K){
        cout << N * X << endl;
    }
    else{
        cout << (K * X) + (N - K) * Y << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define REP(n) for(int i = 0; i < n; i++)
#define all(p) p.begin(), p.end()
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
template<class X=int>inline X min(X a,X b,X c){return min(min(a,b),c);}
template<class X=int>inline X min(X a,X b,X c,X d){return min(min(a,b,c),d);}
template<class X=int> inline X max(X a,X b,X c){return max(max(a,b),c);}
template<class X=int> inline X max(X a,X b,X c,X d){return max(max(a,b,c),d);}
template<class X=int> inline X mid(X s,X e){return (s+(e-s)/2);}
template<class X=int> inline X len(X s,X e){return (e-s+1);}
const int MOD = 1e9 + 7;
const int INF = 987654321;
const bool TESTCASES = 0;
const bool CODEJAM = 0;

void solve()
{
	int n;
	cin >> n;
	vector<int> v(n + 1, 0);
	for(ll i = 1; i <= 100; i++) for(ll j = 1; j <= 100; j++) for(ll k = 1; k<= 100; k++)
	{
		ll ans = i*i + j*j + k*k + i*j + i*k + j*k;
		if(ans <= n) v[ans]++;
	}
	for(int i = 1; i <= n; i++) cout << v[i] << "\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int T = 1;
	if(TESTCASES) cin >> T;
	for(int t = 1; t <= T; t++)
	{
		if(CODEJAM) cout << "Case #" << t << ": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll A[100005];
int main(){
    ll max=0;
    cin >> n;
    for( ll i=0; i<n; i++){
        cin >> A[i];
        if( A[i] > max) max = A[i];
    }
    bool flg=true;
    ll cnt;
    ll mask=1;
    for( ll mask=1; mask<=max; mask=mask<<1){
        cnt=0;
        for( ll i=0; i<n; i++){
            if( (A[i]&mask)!=0 ) cnt++;
        }
        if( cnt%2 != 0){
            flg=false;
            break;
        }
    }

    if( flg==true ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, d[1000], s[1000], maxn; vector<int>W, X;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> s[i]; d[s[i]]++; }
	for (int i = 1; i < 12; i++) {
		if (d[i] >= 3) { cout << "0" << endl; return 0; }
		if (d[i] == 1)W.push_back(i);
		if (d[i] == 2) { X.push_back(i); X.push_back(24 - i); }
	}
	X.push_back(0);
	if (d[0] >= 1) { cout << "0" << endl; return 0; }
	if (d[12] >= 2) { cout << "0" << endl; return 0; }if (d[12] == 1)X.push_back(12);
	for (int i = 0; i < (1 << W.size()); i++) {
		vector<int>Y = X;
		for (int j = 0; j < W.size(); j++) {
			if ((i / (1 << j)) % 2 == 0)Y.push_back(W[j]);
			else Y.push_back(24 - W[j]);
		}
		sort(Y.begin(), Y.end());
		int minx = 24;
		for (int j = 0; j < Y.size(); j++)minx = min(minx, (Y[(j + 1) % Y.size()] - Y[j] + 24) % 24);
		maxn = max(maxn, minx);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
dp = [0]*(10**5+1)
a = gets.split.map(&:to_i)
sum = a.inject(:+)

a.each do |i|
    dp[i]+=1
end

#p dp

q = gets.to_i
q.times do
    i,j = gets.split.map(&:to_i)
    sum += dp[i]*(j-i)
    dp[j] += dp[i]
    dp[i]=0
    
    p sum
end



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

#define  vt            vector
#define  db            long double
#define  int           long long
#define  pb            push_back
#define  inf           (int)1e20
#define  mxn           (int)2e5+5
#define  pii           pair<int,int>
#define  pq            priority_queue

#define  si(x)         (int)x.size()
#define  all(x)        x.begin(),x.end()
#define  mem(a,x)      memset(a,x,sizeof(a))
#define  forr(i,n)     for(int i=0;i<n;i++)

#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}

int mainx()
{
	int n;
	cin >> n;
	vt<int> a(n , 0);
	for (int i = 0 ; i < n ; i++)
		cin >> a[i];
	int dp[n + 1] = {0};
	dp[0] = -1;
	dp[1] = 0;
	dp[2] = abs(a[0] - a[1]);
	for (int i = 3 ; i <= n ; i++)
	{
		dp[i] = min(abs(a[i - 1] - a[i - 2]) + dp[i - 1] , abs(a[i - 1] - a[i - 3]) + dp[i - 2]);
	}
	// pnr(dp);
	cout << dp[n] << endl;

	return 0;
}


inline void include() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
}
int32_t main() {
	//include();
	ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	//cout << fixed << setprecision(20);

	int tt = 1;
	//cin>>tt;
	for (int t = 1 ; t <= tt ; t++ )
	{
		mainx();
	}
	return 0 ;
}


Measured memory_bytes: 4780
#include<iostream>
using namespace std;
int main(){
  int n[101];
  int i;
  int num;
  cin >> num;
  for(i=0;i<num;i++) cin >> n[i];
  cout << n[num-1];
  for(i=1;i<num;i++) cout <<" "<< n[num-i-1];
  cout << endl;
  return 0;
}


Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	vector<string>v;
	rep(i, 0, 8) {
		string s; cin >> s; v.push_back(s);
	}

	cout << 90 << endl;
	rep(j, 0, 8) {
		rrep(i, 0, 8) {
			cout << v[i][j];
		}
		cout << endl;
	}

	cout << 180 << endl;
	rrep(i, 0, 8) {
		rrep(j, 0, 8) {
			cout << v[i][j];
		}
		cout << endl;
	}

	cout << 270 << endl;
	rrep(j, 0, 8) {
		rep(i, 0, 8) {
			cout << v[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;


int main(){
	int x,a,b;
	cin>>x>>a>>b;
	char ans =( abs(x-a)<=abs(x-b)? 'A':'B' );
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
r={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
d=input().split()
for x in input():
    d=[d[y]for y in r[x]]
print(d[0])



Measured memory_bytes: 5568
INF = (10 ** 9 + 7)
L = gets.chomp.to_s
dp_not_tight = 1
dp_tight = 2
L[1..-1].each_char.with_index do |char, index|
  if char == "0"
    dp_not_tight *= 3
  else
    dp_not_tight = dp_not_tight * 3 + dp_tight
    dp_tight *= 2
  end
  if index % 20 == 0
    dp_not_tight %= INF
    dp_tight %= INF
  end
end
puts (dp_not_tight + dp_tight) % INF

Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<string>
#include<map>

#define REP(i,j,k) for( int i=j; i<k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

typedef long long LL;

int main(){
	
	LL n,a[5],x=1000000000000001;
	
	cin >> n;
	rep(i,5) cin >> a[i];
	
	rep(i,5) x = min(x,a[i]);
	
	LL ans = n/x + 4;
	if(n%x) ans++;
	
	cout << ans << endl;
	
	return 0;
	
}


Measured memory_bytes: 764
#include <cstdio>
int main(){
  int n;
  scanf("%d", &n);
  int h[n];
  int c = 0;
  int d = 0;
for(int i = 0; i<n ; i++){
  scanf("%d", &h[i]);
  if(i != 0){
	if(h[i] <= h[i-1]){ d++;
		}else{
			if(c < d){ c=d;}
			d=0;
		}
	}
  }
			if(c < d){ c=d;}
  
  printf("%d\n", c );
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define mod 1000000007
int main()
{
    long long int n,m;
    scanf("%lld%lld",&n,&m);
    int i;
    long long int ans=1;
    if(n<m)
    {
        int temp=n;
        n=m;
        m=temp;
    }
    if(n>m+1)
    {
        printf("0");
    }
    else if(n==m)
    {
        for(i=1;i<=n;i++)
        {
            ans=ans*i;
            ans=ans%mod;
            ans=ans*i;
            ans=ans%mod;
        }
        ans=ans*2;
        ans=ans%mod;
        printf("%lld",ans);
    }
    else if(n==m+1)
    {
        for(i=1;i<=m;i++)
        {
            ans=ans*i;
            ans=ans%mod;
            ans=ans*i;
            ans=ans%mod;
        }
        ans=ans*n;
        ans=ans%mod;
        printf("%lld",ans);
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

string s, t, ans;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cin >> t;
    int n = s.size();
    int m = t.size();
    bool ok = false;
    int idx = -1;
    rep(i, n - m + 1) {
      bool tmp = true;
      rep(j, m) {
        if (s[i + j] != '?' && s[i + j] != t[j]) {
          tmp = false;
          break;
        }
      }
      if (tmp) {
        ok = true;
        idx = i;
      }
    }
    if (idx == -1) {
      cout << "UNRESTORABLE" << endl;
      return 0;
    }
    ans = s;
    rep(i, n) {
      if (i == idx) {
        rep(j, m) ans[i + j] = t[j];
      }
      if (ans[i] == '?') {
        ans[i] = 'a';
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

    int main(){
        int total_num, absent_num;
        int i, temp, garbage;

        /* ??????????????????????????? */
        scanf("%d", &total_num);
        scanf("%d", &absent_num);

        temp = total_num - absent_num;

        for(i = 0; i < temp; i++){
            scanf("%d", &garbage);
        }

        printf("%d\n", (temp -1));
        
        return 0;
    }

Measured memory_bytes: 1852
#include<iostream>
#include<map>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
    string S;cin >> S;
    map<char,int> m;

    for(int i=0;i<S.size();++i)
    {
        m[S[i]]++;
    }
    int max_ = max(m['a'],max(m['b'],m['c']));
    int min_ = min(m['a'],min(m['b'],m['c']));

    if(max_ - min_ >1)
    {
        cout << "NO"<<endl;
    }
    else
    {
        cout << "YES"<<endl;
    }
    
}

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

lint f(lint h) {
    if(h == 0)  return 0;
    return f(h/2) * 2 + 1;
}

int main() {
    lint h;
    cin >> h;

    cout << f(h) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    int num = 0;
    string str = "";
    cin >> str;
    for(int i = 0; i < str.size(); i++)
    {
        if(str[i] == '+')
        {
            num++;
        }
        else
        {
            num--;
        }
    }
    cout << num << endl;
}
    


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

typedef long long ll;

int main(){
	ll X;
	cin >> X;
	
	ll A=0,B=0;
	bool f=false;
	for(ll i=0; i<=1000; i++){
		for(ll j=1; j<=1000; j++){

			if(X%(i+j) == 0){
				ll x = i*i*i*i - i*i*i*j + i*i*j*j - i*j*j*j + j*j*j*j;
				if(x == X/(i+j)){
					A=i; B=-j; f=true; break;
				}
			}
			if(i-j == 0)continue;
			if(X%(i-j) == 0){
				ll x = i*i*i*i + i*i*i*j + i*i*j*j + i*j*j*j + j*j*j*j;
				if(x == X/(i-j)){
					A=i; B=j; f=true; break;
				}
			}
			
		}
		if(f)break;
	}

	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X>>T;
	cout<<(N+X-1)/X*T<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3588
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	class Era {
		String name;
		int start, last;

		Era(String name, int base, int year) {
			this.name = name;
			this.start = year - base + 1;
			this.last = year;
		}
	}

	void run() {
		MyScanner sc = new MyScanner();

		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}
			Era[] era = new Era[n];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				int k1 = sc.nextInt();
				int k2 = sc.nextInt();
				era[i] = new Era(s, k1, k2);
			}
			L: for (int i = 0; i < m; i++) {
				int y = sc.nextInt();
				for (int j = 0; j < n; j++) {
					if (era[j].start <= y && y <= era[j].last) {
						System.out.println(era[j].name + " " + (y - era[j].start + 1));
						continue L;
					}
				}
				System.out.println("Unknown");
			}
		}
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}

Measured memory_bytes: 42528
#include <iostream>
using namespace std;
int main(void) {
	long long n, m;
	cin >> n >> m;
	if (n > m) swap(n, m);
	if (n == 1 && m == 1) {
		cout << 1 << endl;
		exit(0);
	}
	if (n == 1) {
		cout << m - 2 << endl;
		exit(0);
	}
	cout << n * m - n * 2 - m * 2 + 4 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
using ll = long long;
using ld = long double;
ll MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> vec(n, vector<int>(26));
    for (int i = 0; i < n;i++){
        string s;
        cin >> s;
        for (int j = 0; j < s.size();j++){
            vec[i][s[j] - 'a']++;
        }
    }
    vector<char> res;
    for (int i = 0; i < 26;i++){
        int MIN = vec[0][i];
        for (int j = 0; j < n;j++){
            MIN = min(MIN, vec[j][i]);
        }
        for (int j = 0; j < MIN;j++){
            res.push_back((char)(i + 'a'));
        }
    }
    for (int i = 0; i < res.size();i++){
        cout << res[i] ;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <regex>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0;i < n;i++)
using namespace std;

int n, m;
string s, t;
int main() {
	cin >> s >> t;
	rep(i, s.size() + t.size())
		i % 2 == 0 ? cout << s[i / 2] : cout << t[i / 2];
	cout << endl;
	return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (int)(b); i < _b; ++i)
#define fr(i, a, b) for (int i = (a), _b = (int)(b); i <= _b; ++i)

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const int N = 1000000 + 15;
const int M = 55;
const int multipleTest = 0;

int n;

void solve() {
    int res = 0;
    cin >> n;
    int len = 0;
    rep(i, 1, n + 1) {
        int u; scanf("%d", &u);
        if (u == i) ++len;
        else {
            if (len > 0) {
                res += (len + 1) / 2;
            }
            len = 0;
        }
    }
    res += (len + 1) / 2;
    cout << res;
    
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        solve();
    }
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}


Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,m;
    int tc;
    ll now;
    string chaeng = "";
    cin >> now;
    while(now > 0) {
        curr = now % 26;
        curr--;
        if(curr == -1) curr = 25;
        chaeng += 'a' + curr;
        if(now % 26 == 0) {
            now /= 26;
            now--;
        } else now /= 26;
    }
    reverse(chaeng.begin(), chaeng.end());
    cout << chaeng << endl;
    return 0;
}


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

int main()
{
	int n, i, count=1;
	scanf("%d", &n);
	char s[n][11];

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

	qsort(s, n, sizeof(char)*11, strcmp);

	for (i = 0; i < n-1; i++) {
		if (strcmp(s[i], s[i + 1]) != 0)
			count++;
	}

	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 5740
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//============
//Dinic Method
//============

const int MAX_V=1010;
const int INF=INT_MAX;

struct edge{int to, cap, rev;};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, 0, G[from].size()-1});
}

void bfs(int s){
	memset(level, -1, sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front(); que.pop();
		for(int i = 0; i < G[v].size(); i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int f){
	if(v == t) return f;
	for(int &i = iter[v]; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t] < 0)return flow;
		memset(iter, 0, sizeof(iter));
		int f;
		while((f = dfs(s,t,INF)) > 0){
			flow += f;
		}
	}
}

//=============


int main(void){
	int N,a[110],b[110],c[110],d[110];
	scanf("%d",&N);
	reg(i,1,N){
		add_edge(0,i,1);
		scanf("%d%d",&a[i],&b[i]);
	}
	reg(i,1,N){
		add_edge(i+N,2*N+1,1);
		scanf("%d%d",&c[i],&d[i]);
	}
	reg(i,1,N){
		reg(j,1,N){
			if(a[i]<c[j] && b[i]<d[j]){
				add_edge(i,N+j,1);
			}
		}
	}
	printf("%d\n",max_flow(0,2*N+1));
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    ll H;
    cin >> H;

    ll ans = 0;
    ll c = 1;
    while(H > 0){
        ans += c;
        c *= 2;
        H /= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from operator import itemgetter
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
stairs = [0] * (n + 1)
a = [int(input()) for i in range(m)]
mod = (10 ** 9 + 7)
stairs[0] = 1

if n == 1:
    print(1)
    exit()

for i in a:
    stairs[i] = -100


for i in range(1, n + 1):
    if stairs[i] >= 0:
        stairs[i] = max(stairs[i-1], 0) + max(stairs[i-2], 0)
        stairs[i] = stairs[i] % mod


print(stairs[n] % mod)


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

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

int main(){

    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  map<int, ll> counts;
  set<int> nums;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    nums.insert(a);
    counts[a] += b;
  }
  int ans = 0;
  set<int>::iterator it;
  for (it = nums.begin(); it != nums.end(); it++) {
    K -= counts[*it];
    ans = *it;
    if (K <= 0) {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

    ll l; cin >> l;
    string S; cin >> S;

    if ((l%2)==1) {
        cout << "No" << '\n';
        return 0;
    }

    REP(i, l/2) {
        if (S[i] != S[(l/2)+i]) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a[3];
    for(int i=0;i<3;i++) cin>>a[i];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

s = input()
ans = [0]*len(s)
cnt = 0
for i in range(len(s)-1):
    if "R" in s[i]:
        cnt += 1
        if "L" in s[i+1]:
            ans[i+1] += math.ceil(cnt/2)
            ans[i] += math.ceil(cnt/2)
            if cnt%2 == 0:
                ans[i+1] += 1
            cnt = 0
for i in range(len(s)-1, 0, -1):
    if "L" in s[i]:
        cnt += 1
        if "R" in s[i-1]:
            ans[i-1] += math.ceil(cnt/2)
            ans[i] += math.ceil(cnt/2)
            if cnt%2 == 0:
                ans[i-1] += 1
            cnt = 0
for i in range(len(s)):
    if ans[i] != 0:
        ans[i] -= 1
    print(ans[i], end=" ")

Measured memory_bytes: 4976
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		// 文字列の出力
		String s = "Odd";
      	if (a*b%2==0) {
          s="Even";
        }
		// 出力
		System.out.println(s);
	}
}

Measured memory_bytes: 21844
import math

n, m = map(int, input().split())
if abs(n-m) == 0:
    print(2*math.factorial(n)*math.factorial(m) % 1000000007)
elif abs(n-m) == 1:
    print(math.factorial(n)*math.factorial(m) % 1000000007)
else:
    print(0)

Measured memory_bytes: 5192
import sys


def solve():
    N, K, *H = map(int, sys.stdin.read().split())
    dp = [0] * N
    for i in range(1, N):
        h_i = H[i]
        s = i-K if i-K > 0 else 0
        dp[i] = min(d_j + abs(h_i - h_j) for d_j, h_j in zip(dp[s:i], H[s:i]))
    return dp[-1]


if __name__ == "__main__":
    answer = solve()
    print(answer)


Measured memory_bytes: 59948
/*input
3 3 1
2 1 2 3
.@.
.@.
.@.
*/

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

const ll INF = 1e18;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  int si, sj, ti, tj;
  cin >> si >> sj >> ti >> tj;
  --si; --sj; --ti; --tj;
  vector<string> g(h);
  rep(i, h) cin >> g[i];

  auto toId = [&](int i, int j, int v) {
    return (i*w+j)*4+v;
  };
  auto modCeilK = [&](ll x) {
    return (x+k-1)/k*k;
  };

  vector<ll> dist(h*w*4, INF);
  priority_queue<P, vector<P>, greater<P>> q;
  auto push = [&](int i, int j, int v, ll x) {
    int id = toId(i, j, v);
    if (dist[id] <= x) return;
    dist[id] = x;
    q.emplace(x, id);
  };
  rep(v, 4) push(si, sj, v, 0);
  while (!q.empty()) {
    ll d = q.top().first;
    int id = q.top().second;
    q.pop();
    if (dist[id] != d) continue;
    int i = id/4/w;
    int j = id/4%w;
    int v = id%4;
    rep(nv, 4) {
      push(i, j, nv, modCeilK(d));
      int ni = i+di[v], nj = j+dj[v];
      if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
      if (g[ni][nj] == '.') push(ni, nj, v, d+1);
    }
  }

  ll ans = INF;
  rep(v, 4) ans = min(ans, dist[toId(ti, tj, v)]);
  if (ans == INF) {
    cout << -1 << endl;
  }
  else {
    ans = modCeilK(ans)/k;
    cout << ans << endl;
  }
}

Measured memory_bytes: 44096
s = input()
k = int(input())

if len(s) >=k:
    flag = True
    for i in range(k):
        if s[i] != "1":
            flag = False
            break
    if flag:
        print(1)
        exit()
for i in s:
    if i != "1":
        print(i)
        exit()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

const double PI = 3.1415926535897932384626433832795;


string createS(string sd, string t, int n) {
  eprintf("createS(%s, %s, %d) => ", sd.c_str(), t.c_str(), n);
  string res = sd;
  res.replace(n, t.size(), t);
  REP(i, res.size()) {
    if(res[i] == '?')  {
      res[i] = 'a';
    }
  }
  eprintf("%s\n", res.c_str());
  return res;
}

int main() {
  const string NO = "UNRESTORABLE";
  string sd;
  cin >> sd;
  string t;
  cin >> t;
  vector<string> answers;
  
  if(sd.size() < t.size()) {
    cout << NO << endl;
    return 0;
  }

  REP(i, sd.size() - t.size() + 1) {
    eprintf("i:%d-----\n", i);
    bool flag = true;
    REP(j, t.size()) {
      eprintf("  sd[i+j]:%c t[j]:%c", sd[i+j], t[j]);
      if (sd[i+j] == t[j] || sd[i+j] == '?') {
        eprintf("  ok\n");
        continue;
      }
      else {
        eprintf("  ng\n");
        flag = false;
      }
    }
    if(flag == true) {
      eprintf("  found:%d\n", i);
      answers.push_back(createS(sd, t, i));
    }
  }

  if(!answers.empty()) {
    sort(ALL(answers));
    cout << answers[0] << endl;
  }
  else {
    cout << NO << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

A = sorted(A)
C = sorted(C)
ans = 0

for i in B:
    ans += (bisect.bisect_left(A, i)) * (N - bisect.bisect_right(C, i))

print(ans)

Measured memory_bytes: 23644
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

s = input()

print(len(s)//2 - s.count("p"))

Measured memory_bytes: 10524
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <limits>
#include <ctype.h> 
#include <stdio.h> 
#include <set> 
#include <iomanip>
#include <cstdint>
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '




int main() {
	int a = 0, b = 0;
	cin >> a >> b;
	int res = a+b;
	int res1 = a-b;
	int res2 = a*b;
	int ans = -10000;
	ans = max(ans,res);
	ans = max(ans,res1);
	ans = max(ans,res2);
	cout << ans << endl;

    return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N)cin >> A[i];
	SORT(A);
	int ans = A[N - 1] - A[0];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

bool check(ll x) {
  bool flag[10];
  flag[3] = flag[5] = flag[7] = false;
  while (x > 0) {
    flag[x % 10] = true;
    x /= 10;
  }
  return (flag[3] && flag[5] && flag[7]);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, ans = 0;
  cin >> n;
  stack<ll> s;
  s.push(0);
  while (!s.empty()) {
    ll num = s.top();
    s.pop();
    if (num > n) {
      continue;
    }
    if (check(num)) {
      ++ans;
    }
    s.push(num * 10 + 3);
    s.push(num * 10 + 5);
    s.push(num * 10 + 7);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using   namespace std;
typedef long long int ll;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,k,n) for(i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
double dp[3005][3005];
double findAns(double* arr,ll n,ll idx,ll hsf){
	if(idx==n){
		if(hsf>n-hsf) return 1;
		return 0;
	}
	if(dp[idx][hsf]>-1) return dp[idx][hsf];
	double myans=0;
	myans+=arr[idx]*findAns(arr,n,idx+1,hsf+1);//head
	myans+=(1-arr[idx])*findAns(arr,n,idx+1,hsf);//tail
	return dp[idx][hsf]=myans;
}
void solve(){
	ll i,j,n;
	cin>>n;
	double* arr = new double[n];
	fo(i,0,n){
		cin>>arr[i];
	}
	mset(dp,-1);
	double ans = findAns(arr,n,0,0);
	cout<<fixed<<setprecision(12)<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 71040
#include <stdio.h>
#include <string.h>
int main(){
    char s[101];
    long long k,i=0;
    scanf("%s%lld",s,&k);
    while(s[i]=='1'){
        k--;
        i++;
    }
    if(k<=0)printf("1");
    else printf("%d",s[i]-48);
}

Measured memory_bytes: 128
(defun f (x &optional (l nil))
  (if (= x 0)
      l
      (prog2
        (push (mod x 10) l)
        (f (floor x 10) l))))

(let ((s (f (read))))
     (if (or (and
              (equal (first s) (second s))
              (equal (second s) (third s)))
             (and
              (equal (second s) (third s))
              (equal (third s) (fourth s))))
         (princ "Yes")
         (princ "No")))

Measured memory_bytes: 24468
main :: IO ()
main = do
    s' <- getLine
    t  <- getLine
    putStrLn $ solve s' t

solve :: String -> String -> String
solve s' t | length s' < length t = "UNRESTORABLE"
           | otherwise            = solve' s' t
    
solve' :: String -> String -> String
solve' s' t | null smallests = "UNRESTORABLE"
            | otherwise      = minimum smallests
  where
    smallests = 
        [ smallest a ++ t ++ smallest b 
        | (a, x', b) <- substrings (length t) s'
        , match x' t
        ]

smallest :: String -> String
smallest = map (\c -> if c == '?' then 'a' else c)

substrings :: Int -> String -> [(String, String, String)]
substrings n xs | length xs < n = []
                | otherwise     = go [] (take n xs) (drop n xs)
  where 
    go xs ys [] = [(xs, ys, [])]
    go xs (y : ys) (z : zs) =
        (xs, (y : ys), (z : zs)) : go (xs ++ [y]) (ys ++ [z]) zs

match :: String -> String -> Bool
match [] [] = True
match (x : xs) (y : ys) | x == y    = match xs ys
                        | x == '?'  = match xs ys
                        | otherwise = False

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

using std::string;


int main(){
    string buffer;
    while(true) {
        getline(std::cin, buffer);
        if(buffer == string("0")) break;

        int sum = 0;
        for(auto each : buffer) {
            sum += std::stoi(string(1, each));
        }
        printf("%d\n", sum);
    }
}


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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<" : "<<x<<endl
#define ALL(v) (v).begin(),(v).end()

int n,m;
int q[125252];
int po[252521];
int tail;
bool used[252521];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d",q+i);
  tail=0;
  FORR(i,0,m){
    int a = q[i]-1;
    if(!used[a]){
      po[tail++] = a;
      used[a] = true;
    }
  }
  REP(i,n)if(!used[i])po[tail++] = i;
  REP(i,n){
    printf("%d\n",po[i]+1);
  }
  return 0;
}

Measured memory_bytes: 4564
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, K := ReadInt(), ReadInt()
	ans := 0
	for b := 1; b <= N; b++ {
		p, r := N/b, N%b
		ans += p * Max(0, b-K)
		ans += Max(0, r-K+1)
		if K == 0 {
			ans -= 1
		}
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 1840