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

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n + 1, 0);
	for (ll i = 1; i <= n; ++i)cin >> a[i];
	for (ll i = 1; i <= n; ++i)a[i] += a[i - 1];
	vector<ll> now;
	for (ll i = 0; i <= n; ++i) {
		for (ll j = i + 1; j <= n; ++j) {
			now.push_back(a[j] - a[i]);
		}
	}
	for (ll i = 60; i >= 0; --i) {
		vector<ll> tmp;
		for (ll x : now) {
			if (x & (1ll << i)) {
				tmp.push_back(x);
			}
		}
		if (tmp.size() >= k)now = tmp;
	}
	ll ans = now[0];
	for (ll i = 1; i < k; ++i) {
		ans &= now[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 6260
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n;
  int t[n], sum=0;
  for (size_t i = 0; i < n; i++) {
    cin >> t[i];
    sum += t[i];
  }
  cin >> m;
  int p[m], x[m];
  vector<int> ans(m,sum);
  for (size_t i = 0; i < m; i++) {
    cin >> p[i] >> x[i];
    ans[i] -= t[p[i]-1];
    ans[i] += x[i];
  }

  for (size_t i = 0; i < m; i++) cout << ans[i] << endl;
  return 0;
}


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

int w[100005],n,k;

int judge(long long p)
{
    int j=0;
    for(int i=0;i < k;i++){
        long long s=0;
        while(s+w[j] <= p){s+=w[j];j++;if(j==n) return n;}
    }
    return j;
}

int solve()
{
    int l=0,r=2e9;
    while(l < r){
        int mid = (l+r)/2;
        if(judge(mid)==n) r=mid;
        else l=mid+1;
    }
    return r;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i < n;i++) cin>>w[i];
    cout<<solve()<<endl;

    return 0;
}



Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
  int a,b,c;
  cin >>a >> b >> c;
  if(a==b) cout << c << endl;
  else if(a==c) cout << b << endl;
  else cout << a<< endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var ans = 0L

    for (ai in l.indices) {
        for (bi in l.indices) {
            if(ai == bi) continue
            // a-b < c
            // -a+b < c
            // a+b > c
            //System.err.println("ai=$ai, bi=$bi")
            val if1 = l.upperBound(l[ai]-l[bi])
            //System.err.println("if1=$if1")
            val if2 = l.upperBound(-l[ai]+l[bi])
            //System.err.println("if2=$if2")
            val underIf = Math.max(if1, if2)
            val upperIf = l.lowerBound(l[ai]+l[bi])
            //System.err.println("if3=$upperIf")
            var up = Math.max(0, upperIf - underIf)
            if(ai in underIf until upperIf) up--
            if(bi in underIf until upperIf) up--
            //System.err.println("up:$up")
            ans += up
        }
    }

    //System.err.println(ans)
    println(ans / 6)
}

/**
 * elementをキーとして、キー以上の要素の中で最も小さい位置のインデックスを返す。
 * 検索範囲は[fromIndex, toIndex)
 *
 * @param fromIndex この位置を含む範囲
 * @param toIndex この位置を含まない範囲
 * @return 0-indexedなインデックス
 */
fun <T : Comparable<T>> List<T>.lowerBound(
    element: T,
    fromIndex: Int = 0,
    toIndex: Int = size
): Int {
    rangeCheck(size, fromIndex, toIndex)

    var low = fromIndex - 1
    var high = toIndex

    while (high - low > 1) {
        val mid = low + (high - low) / 2
        val midVal = get(mid)
        if (midVal < element) low = mid
        else high = mid
    }

    return high
}

/**
 * elementをキーとして、キーより大きい要素の中で最も小さい位置のインデックスを返す。
 * 検索範囲は[fromIndex, toIndex)
 *
 * @param fromIndex この位置を含む範囲
 * @param toIndex この位置を含まない範囲
 * @return 0-indexedなインデックス
 */
fun <T : Comparable<T>> List<T>.upperBound(
    element: T,
    fromIndex: Int = 0,
    toIndex: Int = size
): Int {
    rangeCheck(size, fromIndex, toIndex)

    var low = fromIndex - 1
    var high = toIndex

    while (high - low > 1) {
        val mid = low + (high - low) / 2
        val midVal = get(mid)
        if (midVal <= element) low = mid
        else high = mid
    }

    return high
}

/**
 * Checks that `from` and `to` are in
 * the range of [0..size] and throws an appropriate exception, if they aren't.
 */
private fun rangeCheck(size: Int, fromIndex: Int, toIndex: Int) {
    when {
        fromIndex > toIndex -> throw IllegalArgumentException("fromIndex ($fromIndex) is greater than toIndex ($toIndex).")
        fromIndex < 0 -> throw IndexOutOfBoundsException("fromIndex ($fromIndex) is less than zero.")
        toIndex > size -> throw IndexOutOfBoundsException("toIndex ($toIndex) is greater than size ($size).")
    }
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c <= 21) cout << "win" << endl;
    else cout << "bust" << endl;
    
}

Measured memory_bytes: 256
a,b,h,m = gets.chomp.split(' ').map(&:to_i)
# p Math.cos(Math::PI/2) 
long  = 6*m #長針分
short = h*30 + m*0.5
# p long,short
rad = Math.cos(Math::PI*((long-short).abs)/180)
# p rad (a**2) + (b**2) - (2*a*b*rad)
# p rad
p Math.sqrt((a**2 + b**2 - 2*a*b*rad).abs)

Measured memory_bytes: 14700
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

struct Segtree {
	int size = 1;
	vector<int>dat, lazy;
	Segtree(int x) {
		while (size < x)size *= 2;
		dat.resize(size * 2 - 1, inf);
		lazy.resize(size * 2 - 1, inf);
	}
	void eval(int k, int l, int r) {
		chmin(dat[k], lazy[k]);
		if (r - l > 1) {
			chmin(lazy[k * 2 + 1], lazy[k]);
			chmin(lazy[k * 2 + 2], lazy[k]);
		}
		lazy[k] = inf;
	}
	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r == -1)r = size;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			chmin(lazy[k], x);
			eval(k, l, r); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
	int query(int a, int k = 0, int l = 0, int r = -1) {
		if (r == -1)r = size;
		eval(k, l, r);
		if (r - l == 1) {
			return dat[k];
		}
		if (a < (l + r) / 2) {
			return query(a, k * 2 + 1, l, (l + r) / 2);
		}
		return query(a, k * 2 + 2, (l + r) / 2, r);
	}
};
int n, m;
string s;
signed main() {
	cin >> n >> m >> s;
	Segtree S(2 * n);
	S.update(0, 1, 0);
	vector<int>v[114514];
	rep(i, n + 1) {
		if (s[i] == '1')continue;
		int q = S.query(i);
		if (q == inf)continue;
		v[q].push_back(i);
		S.update(i + 1, i + m + 1, q + 1);
	}
	int now = n, now2 = S.query(n);
	if (now2 == inf) {
		cout << -1 << endl; return 0;
	}
	vector<int>ans;
	while (now) {
		int ne = *lower_bound(all(v[now2 - 1]), now - m);
		ans.push_back(now - ne);
		now = ne; now2--;
	}
	reverse(all(ans));
	for (int i : ans)cout << i << " ";
	cout << endl;
}


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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    ll s;
    while (cin >> s) {
        const ll N = 1e9;

        ll k = sqrt(s);
        while (k * k >= s) k--;
        while (k * k < s) k++;

        ll t = k * k - s;

        ll x1, y1, x2, y2, x3, y3;
        if (t <= N) {
            x1 = 0; y1 = 0;
            x2 = k;
            y3 = k;
            y2 = k * k - s;
            x3 = 1;
        } else {
            x1 = 0; y1 = 0;
            x2 = k;
            y3 = k - 1;
            y2 = k * (k - 1) - s;
            x3 = 1;
        }

        printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);
    }


#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 256
//Littleboy123 Template 1.7
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

//pragmas

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")


typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef unsigned long long int ull;
typedef long double ld;
typedef unsigned long long ull;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define TC(n) cout << "Case #" << (n) << ": "
#define DEBUG(x) cout << "DEBUG " << #x << ' ' << x << '\n';
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

void init(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void infile(){
    freopen("output.out", "r", stdin);
}

void outfile(){
    freopen("output.out", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2, mod);
    tmp = (tmp * tmp) % mod;
    if(b & 1)
        tmp = (tmp * a) % mod;
    return tmp;
}

//End of template

int pref[200005];

int main(){
    init();

    ll n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    FOR(i, 0, n){
        if(s[i] == 'R'){
            cnt++;
        }
    }
    ll ans = 0;
    FOR(i, 0, cnt){
        if(s[i] == 'W'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;


int st[10], n, nrc, ans, aux;

const int c[5] = {0, 3, 5, 7};

void Back(int top)
{
    if(top == (nrc + 1))
    {
        int nr = 0;
        bool nr5, nr7, nr3;
        nr5 = nr7 = nr3 = false;
        for(int i = 1 ; i <= nrc ; i++)
            if(st[i] == 5)
                nr5 = true;
            else if(st[i] == 3)
                nr3 = true;
            else nr7 = true;
        if(nr3 && nr5 && nr7)
        {
            for(int i = 1 ; i <= nrc ; i++)
                nr = nr * 10 + st[i];
            ans += (nr <= n);
        }
    }
    else for(int i = 1 ; i <= 3 ; i++)
        {
            st[top] = c[i];
            Back(top + 1);
        }
}

int main()
{
    cin >> n;
    aux = n;
    while(aux)
    {
        ++nrc;
        aux /= 10;
    }
    aux = nrc;
    for(int i = 3 ; i <= aux ; i++)
    {
        nrc = i;
        Back(1);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
x = 0
for i in range(1,n-1):
    if (max(p[i-1], p[i]) == p[i] and max(p[i+1],p[i]) == p[i+1]) or (max(p[i-1], p[i]) == p[i-1] and max(p[i+1],p[i]) == p[i]):
        x += 1
print(x)

Measured memory_bytes: 3064
<?php
list($n, $m) = explode(" ", trim(fgets(STDIN)));
for($i = 0; $i < $m; $i++){
    list($p, $y) = explode(" ", trim(fgets(STDIN)));
    $data[] = [$p, $y];
    $map[$p][$i] = $y;
}
foreach($map as $p => &$m){
    sort($m);
    $map2[$p] = array_flip($m);
}
foreach($data as $row){
    printf("%06d%06d\n", $row[0], 1+$map2[$row[0]][$row[1]]);
}


Measured memory_bytes: 137332
N,K=map(int,input().split())
ans=0
for i in range(K,N+2):
  if i!=(N+1):
    anssub=N*(N+1)//2 -(N-i)*(N-i+1)//2 - i*(i-1)//2+1
  else:
    anssub=1
  ans+=anssub
ans=ans%(10**9+7)
print(ans)

Measured memory_bytes: 9180
import sys
input = lambda: sys.stdin.readline().rstrip()

def lcs(x, y):
    dp = [0  for _ in range(len(y)+1)]
    for i in range(len(x)):
        tmp = dp[:]
        num = x[i]
        for j in range(len(y)):
            if num == y[j]:
                dp[j+1] = tmp[j] + 1
            elif dp[j+1] < dp[j]:
                dp[j+1] = dp[j]  
    return dp[-1]

n=int(input())
for _ in range(n):
    print(lcs(input(),input()))


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;
  ll a[n], p[n + 1];
  REP(i, n){
    cin >> a[i];
    p[a[i]] = i + 1;
  }

  set<ll> st; //順序付き集合 i.e. 格納された値はソート済
  st.insert(0);
  st.insert(n + 1);

  ll ans = 0;

  for(int a = 1; a <= n; a++){
    st.insert(p[a]);
    auto itr = st.find(p[a]);
    itr--;
    ll left = *itr;
    itr++; itr++;
    ll right = *itr;
    //元々入っていたのは全てa未満の数の位置なので隣接するイテレータの指す値が"a未満の値が入っている最も近い位置"になっている
    ans += abs(p[a] - left) * abs(p[a] - right) * a;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 0xffffffffff;
const int N = 1e5 + 100;
ll n, k;


int main() {
	cin>>n>>k;
    ll ans = 0, t = 1;
    while(t <= n) {
    	ans ++;
        t = t * k;
    }
  cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
module Main where

import Data.IntSet (IntSet)
import qualified Data.IntSet as Set
import Data.IntMap (IntMap)
import qualified Data.IntMap.Strict as Map
import Control.Monad

pows = Set.fromList $ take 33 $ iterate (*2) 1

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  let m = Map.fromListWith (+) $ zip as (repeat 1)
  print $ go m 0
  where
    go :: IntMap Int -> Int -> Int
    go m n 
      | Map.null m = n
      | otherwise = let 
        (maxKey, cnt) = Map.findMax m 
        Just nextPow = Set.lookupGT maxKey pows
        m' = delete maxKey m
        key = nextPow - maxKey
        in if Map.member key m'
          then go (delete key m') (n+1)
          else go m' n

delete :: Int -> IntMap Int -> IntMap Int
delete k m = case Map.lookup k m of
  Nothing -> error "delete"
  Just 1 -> Map.delete k m
  Just n -> Map.update (Just . pred) k m

Measured memory_bytes: 103804
#include<bits/stdc++.h>
#define M 502
#define mo 1000000007
#define oo 1000000000
#define LL long long
using namespace std;

void read(int &x){
    char c; x=0;
    for (c=getchar(); c<48;)c=getchar();
    for (; c>=48; c=getchar())x=(x<<1)+(x<<3)+(c^48);    
}

int n,len,ans,i,j,l,r,a[400005],b,c;
int main(){
	read(n);
	for (i=1; i<=n; i++)read(a[i]);
	if (n%2==0){
		for (i=n; i>0; i=i-2)printf("%d ",a[i]);
		for (i=1; i<=n; i=i+2)printf("%d ",a[i]);
	}
	else{
		for (i=n; i>0; i=i-2)printf("%d ",a[i]);
		for (i=2; i<=n; i=i+2)printf("%d ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
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; }

using namespace std;

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;

	// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
	int rev;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
	bool operator<(const Edge& right) const {
		return dst < right.dst;
	}
};

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph& g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

signed main() {
	int n;
	cin >> n;
	Graph G(n + 1);
	rep(i, n) {
		int u, k;
		cin >> u >> k;
		rep(j, k) {
			int v;
			cin >> v;
			add_arc(G, u, v);
		}
	}

	REPS(i, n) {
		sort(ALLOF(G[i]));
	}

	vector<int> d(n + 1, 0), f(n + 1, 0);

	function<int(int, int)> dfs = [&](int n, int t) -> int {
		if (d[n]) {
			return t - 1;
		}

		d[n] = t;
		for (Edge e : G[n]) {
			chmax(t, dfs(e.dst, t + 1));
		}
		return f[n] = ++t;
	};

	int nowTime = 1;
	REPS(i, n) {
		nowTime = dfs(i, nowTime) + 1;
	}

	REPS(i, n) {
		cout << i << " " << d[i] << " " << f[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 3080
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

A, B = mi()

print(str(min(A, B))*max(A, B))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=26;
string s,t;
vvl a;

int main(){
	cin>>s>>t;
	int n=s.size(),m=t.size();
	a=vvl(M);
	for(int i=0;i<n;i++) a[s[i]-'a'].push_back(i);
	for(int i=0;i<n;i++) a[s[i]-'a'].push_back(n+i);
	for(int i=0;i<m;i++) if(a[t[i]-'a'].empty()){
		cout<<-1<<endl;
		return 0;
	}
	ll res=a[t[0]-'a'][0];
	for(int i=1;i<m;i++){
		ll I=t[i]-'a',nx=*upper_bound(a[I].begin(),a[I].end(),res%n);
		res+=nx-res%n;
	}
	cout<<res+1<<endl;
}

Measured memory_bytes: 2800
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_acc(x) (x).begin(),(x).end(),0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool {return abs(i) < abs(j);});
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

//出力するよ
void output(vector<int> s){
    int n=s.size();
    for(int i=0;i<n;i++){
        if(i!=0) cout<<" ";
        cout<<s[i];//<<endl;
    }
    cout<<endl;
}
int cnt;

void merge(vector<int> &a,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    vector<int> l(n1+1);
    vector<int> r(n2+1);
    for(int i=0;i<n1;i++) l[i]=a[left+i];
    for(int i=0;i<n2;i++) r[i]=a[mid+i];

    l[n1]=pow(10,10);
    r[n2]=pow(10,10);
    int i=0,j=0;

    for(int k=left;k<right;k++){
        //ここが比較しているところ
        cnt++;
        if(l[i]<r[j]){
            a[k]=l[i];
            i++;
        }else{
            a[k]=r[j];
            j++;
        }
    }
}

void mergeSort(vector<int> &a,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}

signed main(){
    int n; cin>>n;
    vector<int> s(n);
    cnt=0;
    for(int i=0;i<n;i++) cin>>s[i];

    mergeSort(s,0,n);
    output(s);
    cout<<cnt<<endl;
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>>s(h+2, vector<int>(w+2,-1));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char x;
			cin >> x;
			if (x == '.')s.at(i + 1).at(j + 1) = 10000;
		}
	}
	ll ans = 0;
	for (int i = 0; i < h+2; i++) {
		for (int j = 0; j < w + 2; j++) {
			if (s.at(i).at(j) == -1)continue;
			vector<vector<int>>sc = s;
			sc.at(i).at(j) = 0;
			queue<pair<int, int>>q;
			q.push({ i,j });
			ll res = 0;
			while (q.size() > 0) {
				int x = q.front().first;
				int y = q.front().second;
				if (sc.at(x + 1).at(y) > sc.at(x).at(y) + 1) {
					sc.at(x + 1).at(y) = sc.at(x).at(y) + 1;
					q.push({ x + 1,y });
					res = max(res, (ll)sc.at(x + 1).at(y));
				}
				if (sc.at(x - 1).at(y) > sc.at(x).at(y) + 1) {
					sc.at(x - 1).at(y) = sc.at(x).at(y) + 1;
					q.push({ x - 1,y });
					res = max(res, (ll)sc.at(x - 1).at(y));
				}
				if (sc.at(x).at(y + 1) > sc.at(x).at(y) + 1) {
					sc.at(x).at(y + 1) = sc.at(x).at(y) + 1;
					q.push({ x,y + 1 });
					res = max(res, (ll)sc.at(x).at(y + 1));
				}
				if (sc.at(x).at(y - 1) > sc.at(x).at(y) + 1) {
					sc.at(x).at(y - 1) = sc.at(x).at(y) + 1;
					q.push({ x,y - 1 });
					res = max(res, (ll)sc.at(x).at(y - 1));
				}
				q.pop();
			}
			ans = max(ans, res);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;
    scanf("%d",&n);
    int ans[n+1];
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a);
        ans[a]=i;
    }
    for(int i=1;i<=n;i++)printf("%d ",ans[i]);
    return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

/**
 *  最長増加部分列(LIS)を取得する
 *  @origin:     元の数列
 *  @continuous: 真の場合、以下の式を満たす最長増加部分列を取る
 *               LIS_{i} = LIS_{i + 1} - 1, where 1 <= i < n(LIS)
 *  @Return:     最長増加部分列
 *
 *  計算量: O(N) if continuous else O(NlogN)
 */
template<typename T>
std::vector<T> pick_up_LIS(const std::vector<T>& origin, bool continuous) {
    if(origin.size() == 0) return std::vector<T>();
    std::vector<T> lis;
    if(continuous) {
        auto max_val = *std::max_element(origin.begin(), origin.end());
        auto min_val = *std::min_element(origin.begin(), origin.end());
        auto range   = max_val - min_val + 1;
        auto offset  = min_val - 1;
        std::vector<T> dp(range + 1, 0);
        for(const auto& v : origin) {
            T p   = v - offset;
            dp[p] = dp[p - 1] + 1;
        }
        auto itr = std::max_element(dp.begin(), dp.end());
        auto r   = std::distance(dp.begin(), itr);
        lis.reserve(*itr);
        for(T i = *itr - 1; i >= 0; i--) {
            lis.push_back(r + offset - i);
        }
    }
    else {
        std::vector<T> dp(origin.size() + 1, std::numeric_limits<T>::max());
        dp[0] = std::numeric_limits<T>::min();
        for(const auto& v : origin) {
            auto itr   = std::lower_bound(dp.begin(), dp.end(), v);
            auto index = std::distance(dp.begin(), itr);
            dp[index]  = (v < dp[index]) ? v : dp[index];
        }
        auto itr = std::lower_bound(dp.begin(), dp.end(), std::numeric_limits<T>::max());
        lis.reserve(std::distance(dp.begin() + 1, itr));
        std::copy(dp.begin() + 1, itr, std::back_inserter(lis));
    }
    return lis;
}

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

    int N;
    std::cin >> N;

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

    auto lis = pick_up_LIS(P, true);
    std::cout << N - lis.size() << std::endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;

#define pb push_back
#define mp make_pair

int n, t;
int a[200010];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> t;
    for(int i = 0; i < n; i++) cin >> a[i];
    int to = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(to > a[i]){
            ans -= to - a[i];
        }
        to = a[i] + t;
        ans += to - a[i];
    }
    cout << ans << endl;
    return 0;
}


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

namespace DigitNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var str = Console.ReadLine();

                if(str == null)
                { 
                    break;
                }
                
                var sArray = str.Split();

                var sum = int.Parse(sArray[0]) + int.Parse(sArray[1]);

                Console.WriteLine(check(sum));
            }
        }

        static int check(int n)
        {
            int i;
            for (i = 1; n >= 10; i++, n /= 10)
            {
                
            }
            return i;
        }

    }
}

Measured memory_bytes: 5624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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 N, M, Q;
vector<int> a(50), b(50), c(50), d(50);
vector<int> A(10);
int ans = 0;

void dfs(int index, int v_pre){
    if (index == N){
        int sum = 0;
        REP(i, 0, Q){
            if (A[b[i] - 1] - A[a[i] - 1] == c[i])
                sum += d[i];
        }
        chmax(ans, sum);
        return;
    } else{
        REP(v, v_pre, M + 1){
            A[index] = v;
            dfs(index + 1, v);
        }
    }
}

int main(){
    cin >> N >> M >> Q;
    REP(i, 0, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    dfs(0, 1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES 1
#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 MOD 998244353ll
#define INF 1000000000000000000ll
#define EPS 1e-9
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll T, K;
string S;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	T = 1;
	
	for (ll q = 0; q < T; q++) {
		
		cin >> K >> S;
		
		if ((ll)S.length() <= K) cout << S << '\n';
		else {
			for (ll i = 0; i < K; i++) cout << S[i];
			cout << "...\n";
		}
		
	}
		
    return 0;
}

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

int main()
{
    map<string, int> m={};

    int max = 0;
    int n;
    cin >> n;

    string b[n + 5];

    rep(i, n)
    {
        cin >> b[i];
        m[b[i]]++;
        if(m[b[i]]>max){
            max = m[b[i]];
        }
    }
    sort(b, b + n);
    for (int i = 0; i < n; i++)
    {
        if(m[b[i]]==max){
            cout << b[i] << endl;
            m[b[i]] --;
        }
        
    }

    return 0;
}

Measured memory_bytes: 26880
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		long K = GetLong();
		long[] A = new long[N];
		for(int i = 0; i < N; i++)
			A[i] = GetLong();

		int numBits = 1;
		long tmp = K;
		while(tmp > 1)
		{
			tmp >>= 1;
			numBits++;
		}

		long X = 0;
		for(int d = numBits - 1; d >= 0; d--)
		{
			if((X | (1L << d)) > K)
				continue;

			int num1 = 0;
			for(int i = 0; i < N; i++)
				if(((A[i] >> d) & 1) == 1)
					num1++;

			if(num1 < (N + 1)/2)
				X |= (1L << d);			
		}

		long ans = 0;
		for(int i = 0; i < N; i++)
			ans += X^A[i];
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 32860
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll r,s,p;
    cin >> r >> s >> p;
    string t;
    cin>>t;
    
    ll res=0;
    rep(i,k){
        vector<char> vec;
        for (int j = i; j < n;j+=k){
            vec.push_back(t[j]);
        }
        VV dp(vec.size()+1,V(3));
        rep(j,vec.size()){
            if(vec[j]=='r'){
                dp[j+1][0]=max(dp[j][1],dp[j][2]);
                dp[j+1][1]=max(dp[j][0],dp[j][2]);
                dp[j+1][2]=max(dp[j][0],dp[j][1])+p;
            }else if(vec[j]=='s'){
                dp[j+1][0]=max(dp[j][1],dp[j][2])+r;
                dp[j+1][1]=max(dp[j][0],dp[j][2]);
                dp[j+1][2]=max(dp[j][0],dp[j][1]);
            }else{
                dp[j+1][0]=max(dp[j][1],dp[j][2]);
                dp[j+1][1]=max(dp[j][0],dp[j][2])+s;
                dp[j+1][2]=max(dp[j][0],dp[j][1]);
            }
        }
        res+=max({dp[vec.size()][0],dp[vec.size()][1],dp[vec.size()][2]});
        //rep(i, vec.size()) cout << vec[i] << " ";
        //cout << endl;
    }
    cout<<res<<endl;
}


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

int main() {
    string S;
    int i;

    cin >> S;

    char c1, c2;

    c1 = S[0];
    for (i = 0; i < S.size(); i++)

    c2 = S[i];

    cout << c1 << i - 2 << c2 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int N=0,M=0,a=0;
	cin>>N>>M;
	int A[M+1]={0};
	for(int i=1;i<=M;i++){
		cin>>A[i];
	}
	int B[N+1]={0};
	for(int i=1;i<=M;i++){
		for(int j=1;j<=N;j++){
			cin>>a;
			if(a==A[i]){
				B[j]++;
			}
			else{
				B[A[i]]++;
			}
		}
	}
	for(int j=1;j<=N;j++){
	cout<<B[j]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

const int Num = 1e5+10;
bool primes [Num+5];
vector <int> p = {2};

void sieve (){

    memset( primes , true , Num );

    primes[0] = primes[1] = false;

    int sq = sqrt(Num);
    for (int i = 3 ; i <= sq ; i += 2){
        if (primes[i]){
            p.push_back(i);
            for (int j = i*i ; j <= Num ; j += i)
                primes[j] = false;
        }
    }

    for (int i = (sq + (sq&1^1)) ; i < Num ; i += 2)
        if (primes[i])
            p.push_back(i);

}


void Suhaib_Sawalha (){

    sieve();
    int n;
    cin >> n;
    cout << *lower_bound(p.begin(),p.end(),n);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3832
K,S = map(int,input().split())
x,y,z = 0,0,0
n = 0

for i in range(K+1):
    x = i
    for j in range(K+1):
        y = j
        z = S-(x+y)
        if 0 <= z <=K:
            n += 1

print(n)

Measured memory_bytes: 67652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int n, s;
    cin >> n >> s;
    vector<int> x(n);
    REP(i,n) {cin >> x[i];}
    REP(i,n) {
        x[i] = abs(x[i] - s);
    }

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

    while (true) {
        int ok = n;
        int ng = -1;
        while (abs(ng - ok) > 1) {
            int m = (ng + ok) / 2;
            if (x[m] > 0) {
                ok = m;
            } else {
                ng = m;
            }
        }
        if(ok == n-1) {
            break;
        } else {
            for (int i = ok+1; i < n; i++) {
                x[i] = x[i] % x[ok];
            }
        }
        sort(x.begin(), x.end());
    }

    cout << x[n-1] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(a, b, c) for(ll c=a;c<b;c++)
#define re(b, c) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  ll p = 1000000007;
  vll a(n), as(n, 0), b(m), bs(m, 0);
  re(n, i) std::cin >> a[i];
  re(m, i) std::cin >> b[i];
  re(n, i) as[i] = ((i==0?0:as[i-1]) + a[i])%p;
  re(m, i) bs[i] = ((i==0?0:bs[i-1]) + b[i])%p;
  ll s = 0, t = 0;
  for(int i=0;i<n-1;i++) {
    ll ad =(as[n-1]-((n-i-1)*a[i])%p - as[i] + 2*p)%p;
    //std::cout << ad << '\n';
    s = (s + ad)%p;
  }
  for(int i=0;i<m-1;i++) {
    ll ad =(bs[m-1]-((m-i-1)*b[i])%p - bs[i] + 2*p)%p;
    //std::cout << ad << '\n';
    t = (t + ad)%p;
  }
  //std::cout << s  << " " << t << '\n';
  std::cout << (s*t)%p << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

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

	string S;
	ll ans1, ans2;

	cin >> S;

	// 0
	ans1 = 0;
	rep(i, S.size()) {
		if (i % 2 == 0 && S[i] == '1') {
			ans1++;
		}
		else if (i % 2 == 1 && S[i] == '0') {
			ans1++;
		}
	}

	// 1
	ans2 = 0;
	rep(i, S.size()) {
		if (i % 2 == 0 && S[i] == '0') {
			ans2++;
		}
		else if (i % 2 == 1 && S[i] == '1') {
			ans2++;
		}
	}

	cout << min(ans1,ans2) << "\n";
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<complex>
using namespace std;int main(){int m[10][7];for(int i=0;i<10;i++)for(int j=0;j<7;j++)m[i][j]=1;m[0][6]=0,m[1][0]=0,m[1][3]=0,m[1][4]=0,m[1][5]=0,m[1][6]=0,m[2][2]=0,m[2][5]=0,m[3][4]=0,m[3][5]=0,m[4][0]=0,m[4][3]=0,m[4][4]=0,m[5][1]=0,m[5][4]=0,m[6][1]=0,m[7][3]=0,m[7][4]=0,m[7][6]=0,m[9][4]=0;int n,a,set;while(true){cin>>n;if(n==-1)break;cin>>set;for(int i=6;i>=0;i--)cout<<m[set][i];cout<<endl;for(int i=1;i<n;i++){cin>>a;for(int i=6;i>=0;i--)cout<<abs(m[set][i]-m[a][i]);cout<<endl;set=a;}}return 0;}

Measured memory_bytes: 1232
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]
M = 10**9
color = []

for i in A:
    tmp = M-i
    if len(color) == 0:
        color.append(tmp)
    elif tmp >= color[-1]:
        color.append(tmp)
    else:
        color[bisect.bisect_right(color, tmp)] = tmp

print(len(color))

Measured memory_bytes: 10888
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

def main():
    n = int(input())
    if not (n%4) or not(n%7):
        print("Yes")
        return
    for i in range(4,n,4):
        for j in range(7,n,7):
            # print(i,j)
            if n < i+j:
                continue
            elif n == i+j:
                print("Yes")
                return
    print("No")
    return



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A, B; cin >> A >> B;
    int sum = 1;
    int ANS;
    for (int i=0;;i++){
        if (sum >= B) {
            ANS = i;
            break;
        }
        sum += A - 1;
    }
    cout << ANS << endl;
}



Measured memory_bytes: 3584
//ABC077-C(Snuke Festival)
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

//中部のパーツのサイズは上部のパーツのサイズより真に大きく、下部のパーツのサイズは中部のパーツのサイズより 真に大きい

int n;
vector <int> a,b,c;

int main(){
    
    cin>>n;
    for(int i=0; i<3; i++){
        for(int j=0; j<n; j++){
            int t;
            cin>>t;
            if(i==0)a.push_back(t);
            else if(i==1)b.push_back(t);
            else c.push_back(t);
        }
    }
    
    //a[x]<b[y]<c[z]を満たすx,y,zを全て求めてその個数を出力すればよい
    //b[y]を固定すると、(a[x]<b[y]を満たすxの個数)*(b[y]<c[z]を満たすzの個数)
    //これを全てのb[y]について行ったものの和を出力すればよい
    //愚直に配列を全て見るとO(N^2)で間に合わないのでa,cをソートしておき二分探索
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    long long ans=0;
    for(int y=0; y<n; y++){
        //末尾のイテレータからupper_boundのイテレータを引くと、あるkeyより大きい要素の個数
        //lower_boundのイテレータから先頭のイテレータを引くと、あるkeyより小さい要素の個数
        ans+=(lower_bound(a.begin(),a.end(),b[y])-a.begin())*(c.end()-upper_bound(c.begin(),c.end(),b[y]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int H, W;
  cin >> H >> W;
  int h, w;
  cin >> h >> w;
  int ans = (H - h) * (W - w);
  cout << ans << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
using vi = vector<int>;
using vvi = vector<vi>;

signed main(){
  while(1){
      string s,t;
      cin>>s;
      if(s[0]=='.')break;
      cin>>t;
      int f=0;
      s+='d';
      t+='d';
      int n=s.length();
      int m=t.length();
      int i=0,j=0;
      //cerr<<"st"<<endl;
      while(1){
          if(i==n&&j==m){
              if(s[i-1]!=t[j-1]){
                cout<<"DIFFERENT"<<endl;
                break;
              }
              if(f==1){
                  cout<<"CLOSE"<<endl;
                  break;
              }
              cout<<"IDENTICAL"<<endl;
              break;
          }
          if(i>=n&&j>=m){
              cout<<"DIFFERENT"<<endl;
              break;
          }
          if(s[i]==t[j]&&s[i]!='\"'){
              i++;
              j++;
              continue;
          }else if(s[i]==t[j]&&s[i]=='\"'){
              int ii=i+1,jj=j+1,ff=1;
              for(;ii<n;ii++){
                  if(s[ii]=='\"')break;
              }
              for(;jj<m;jj++){
                  if(t[jj]=='\"')break;
              }
              if(ii==n||jj==m){
                  i++;
                  j++;
                  continue;
              }
              if(ii-i!=jj-j){
                  f+=1;
                  //cerr<<"cnt_f"<<endl;

              }else{
                for(int i2=i;i2<=ii;i2++){
                    //cerr<<s[i2]<<" "<<t[i2-i+j];
                    if(s[i2]!=t[i2-i+j]){
                        f+=1;
                        //cerr<<"diff_f"<<ii-i<<endl;
                        break;
                    }
                }     
              }
              if(f>=2){
                  cout<<"DIFFERENT"<<endl;
                  break;
              }
            

              i=ii;
              j=jj;
          }else if(s[i]!=t[j]){
              cout<<"DIFFERENT"<<endl;
                  break;
          }

          if(i==n&&j==m){
              if(s[i-1]!=t[j-1]){
                cout<<"DIFFERENT"<<endl;
                break;
              }
              if(f==1){
                  cout<<"CLOSE"<<endl;
                  break;
              }
              cout<<"IDENTICAL"<<endl;
              break;
          }
          if(i>=n&&j>=m){
              cout<<"DIFFERENT"<<endl;
              break;
          }
          i++;
          j++;
          
      }

  }
}



Measured memory_bytes: 3064
#pragma GCC optimize("Ofast","-funroll-loops","-fdelete-null-pointer-checks")
#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx","popcnt")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define endl '\n'

const ll MOD = 1e9 + 7;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<vector<int>> g(n);
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		g[x-1].push_back(y-1);
		g[y-1].push_back(x-1);
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		bool ok = 1;
		for(int j : g[i]) {
			if(h[i] <= h[j]) {
				ok = 0;
				break;
			}
		}
		ans += ok;
	}
	cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll t=1;
	for(ll tt=1; tt <= t; tt++) {
		//cout << "case #" << tt << ":\n";
		solve();
	}

	return 0;
}



Measured memory_bytes: 8712