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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  string s, t;
  cin >> s >> t;
  int cor = 0;
  for (int i=0; i<s.size(); i++){
      if (s[i] == t[i]){
          cor++;
      }
  }
  cout << cor;
  return 0; 
}

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

int main() {
    string s;
    int k;

    cin >> s >> k;

    unordered_map<string, int> m;

    for (int i = 0; i < s.size(); i++) {
        for (int j = i; j < min(i + k, (int)s.size()); j++) {
            string ss = s.substr(i, j - i + 1);
            if (m.find(ss) == m.end()) {
                m[ss] = 1;
            }
        }
    }

    vector<string> t;

    for (auto ss : m) {
        t.push_back(ss.first);
    }

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

    cout << t[k - 1] << endl;

    return 0;
}


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

#define MOD		1000000007
#define ll		long long int
#define pll		pair<ll, ll>
#define pb		push_back
#define endl	"\n"
#define f 		first
#define s 		second
#define fastio 	ios_base::sync_with_stdio(false);cin.tie(NULL)

ll power(ll x, ll y) { ll ans = 1; x %= MOD; while (y) {if (y & 1)ans = (x * ans) % MOD; x = (x * x) % MOD; y >>= 1;} return ans;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)


int main() {
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++) {
        cin >> arr[i];
	}

	ll ans = 0;

	for(int i = 1; i < n; i++) {
        if(arr[i] < arr[i - 1]) {
            ans += (-arr[i] + arr[i - 1]);
            arr[i] = arr[i - 1];
        }
	}

	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

vector<ll> v[100001];
ll a[100000];
ll b[100000];
unordered_map<ll,ll> um;
bool f[100000];
ll N;

int main(){
    cin >> N;
    for(int i=0;i<N-1;i++){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    ll K = 0;
    for(int i=0;i<N;i++){
        K = max(K, (ll)v[i].size());
        sort(v[i].begin(),v[i].end());
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<K;j++) f[j] = true;
        ll p = 0;
        for(int j=0;j<v[i].size();j++){
            ll x = i;
            ll y = v[i][j];
            if(x > y){
                f[um[y*100000+x]] = false;
                continue;
            }
            while(!f[p]) p++;
            um[x*100000+y] = um[y*100000+x] = p;
            f[p] = false;
        }
    }
    cout << K << endl;
    for(int i=0;i<N-1;i++){
        cout << um[a[i]*100000+b[i]] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 16328
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    for i in range(K, N):
        if A[i] > A[i-K]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 97540
#include<iostream>
#include<algorithm>
using namespace std ;
int main()
{
	int n,x,a[105]  ; cin >> n >>x;
	for(int i=0;i<n;i++)
		cin >> a[i] ;
	sort(a,a+n) ;
	int m=0;
	while(x>=a[m]&&m<n-1) {x-=a[m] ;m++;}
	if(x==a[m]) m++;
	cout << m ;
	return 0 ;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[300005];

vector<ll> solve(ll N, ll A, ll B) {
    vector<ll> v;
    ll t = 0;
    while (v.size() < N) {
        if (N - t == A) {
            for (ll i = t + 1; i <= N; ++i) {
                v.push_back(i);
            }
            break;
        }
        for (ll i = std::min(N - (A - 1), t + B); i > t; --i) {
            v.push_back(i);
        }
        t = std::min(N - (A - 1), t + B);
        A--;
    }
    return v;
}

ll LIS(vector<ll> v) {
    ll n = v.size();
    REP(i, n + 1) {
        dp[i] = INF;
    }

    REP(i, n) {
        *lower_bound(dp, dp + n, v[i]) = v[i];
    }

    return lower_bound(dp, dp + n, INF) - dp;
}

ll LDS(vector<ll> v) {
    ll n = v.size();
    REP(i, n + 1) {
        dp[i] = 0;
    }

    REP(i, n) {
        ll ok = -1, ng = n;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (dp[mid] > v[i])
                ok = mid;
            else
                ng = mid;
        }
        dp[ng] = v[i];
    }
    REP(i, n + 1) {
        if (dp[i] == 0)
            return i;
    }
    return 0;
}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    vector<ll> v = solve(N, A, B);

    if (A != LIS(v) || B != LDS(v)) {
        cout << -1 << endl;
    }
    else {
        REP(i, N) {
            cout << v[i] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 11372
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define REP(i,num)for(int i=0;i<(num);++i)
#define MOD 1000000007

using namespace std;

int main() {
    string S,T;
    int i;
    cin>>S>>T;
    bool ans=true;
    vector<int> a(27,0);
    vector<int> b(27,0);
    REP(i,S.size()){
        a[S[i]-'a']++;
        b[T[i]-'a']++;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    REP(i,27){
        if(a[i]!=b[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";

    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    LL N; cin >> N;
    VL A(N+1);
    VL capl(N+1);
    REP(i,N+1) cin >> A[i];
    LL cap = 1;
    bool ok = true;
    REP(i,N+1){
        if(cap < A[i]){
            ok = false;
            break;
        }
        cap -= A[i];
        capl[i] = cap;
        if(cap >= (1e15)) cap = LINF;
        else cap *= 2;
    }
    //REP(i,N+1){
    //    cout << capl[i] << " " ;
    //}
    //cout << endl;
    //
    //
    if(N == 0 and A[0] == 0){
        cout << -1 << endl;
        return 0;
    }
    REP(i,N+1){
        if(capl[i] < 0) ok = false;
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    LL ans = A[N];
    LL acc = A[N];
    for(int i = N-1; i >= 0; i--){
        dump(i)
        LL tmp = acc + A[i];
        if(capl[i] < acc){
            dump("d1")
            acc = A[i] + capl[i];
            ans += acc;
        }else{
            dump("d2")
            acc = tmp;
            ans += acc;
        }
        dump(acc)
            dump(ans)
    }
    cout << ans << endl;

}

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

using namespace std;

int main()
{
	int n;
	while(cin >> n,n!=0)
	{
		vector<int> s(n);
		for(int i=0;i<n;i++)
			cin >> s[i];
		sort(s.begin(),s.end());
		long long ans=0;
		for(int i=1;i<n-1;i++)
			ans+=s[i];
		ans/=(n-2);
		cout << ans << endl;
	}






}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
const int N=1e6+5;
int n,i,j,w,l,nxt[N],id[N],ans;
char s[N],t[N],tt[N];
int main(){
	scanf("%d%s%s",&n,s+1,t+1);
	for(i=1;i<=n;++i)if(s[i]!=t[i])break;
	if(i>n)return puts("0"),0;
	for(i=n;i;--i)nxt[i]=s[i]==s[i+1]?nxt[i+1]:i;
	for(i=1;i<=n;++i)if(t[i]!=t[i-1])tt[++w]=t[i],id[w]=i;id[w+1]=n+1;
	for(i=l=w,j=n;i;--i){
		for(;j && (j>id[i] || s[j]!=tt[i]);--j);
		if(!j)return puts("-1"),0;
		for(;id[l]+i-l>j;--l);
		if(i-l==0)ans=std::max(ans,nxt[id[i]]>=id[i+1]-1?0:1);
			else ans=std::max(ans,i-l+1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11136
K = gets.to_i

Node = Struct.new(:no, :cost)

deque = []
visit = []

deque.push(Node.new(1, 0))  # start node      = 1

while !deque.empty?
  node = deque.shift
  #
  if node.no==0 # goal
    p node.cost + 1
    break
  end
  #
  visit[node.no] = true
  #-----------------
  # x10 move
  #-----------------
  nxt = (node.no*10) % K
  if !visit[nxt]
    deque.unshift(Node.new(nxt, node.cost))
  end
  #-----------------
  # +1 move
  #-----------------
  nxt = (node.no+1) % K
  if !visit[nxt]
    deque.push(Node.new(nxt, node.cost+1))
  end
end

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  VI v(n);
  REP(i, n) {
    cin >> v[i];
  }

  ll sum = 0;
  FOR(i, 0, n - 2) {
    FOR(j, i + 1, n - 1) {
      sum += v[i] * v[j];
    }
  }

  ANS(sum);
  return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = Console.ReadLine().Trim();
        var pre = new string[] { "SS", "SW", "WW", "WS" };
        var ok = false;
        foreach (var x in pre)
        {
            var ret = checkA(a, x);
            if (ret != "no") { Console.WriteLine(ret); ok = true; break; }
        }
        if (!ok) Console.WriteLine(-1);
    }
    public static bool check0(string a, string x)
    {
        var aL = a.Length;
        if ((a[0] == 'o' && x[0] == 'S') | (a[0] == 'x' && x[0] == 'W'))
            if (x[1] == x[aL - 1]) return true;
            else return false;
        else if (x[1] == x[aL - 1]) return false;
        else return true;
    }
    public static string checkA(string a, string st)
    {
        var aL = a.Length;
        var na = new char[aL + 1];
        na[0] = st[0]; na[1] = st[1];
        for (int i = 1; i < aL; i++)
        {
            if ((a[i] == 'o' && na[i] == 'S') | (a[i] == 'x' && na[i] == 'W')) na[i + 1] = na[i - 1];
            else na[i + 1] = notWS(na[i - 1]);
        }
        if (na[0] == na[aL])
        {
            var w = new string(na);
            var w1 = w.Substring(0, w.Length - 1);
            if (check0(a, w1)) return w1;
            else return "no";
        }
        else return "no";
    }
    public static char notWS(char a)
    {
        if (a == 'W') return 'S';
        else return 'W';
    }
}

Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

string s[3];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	FOR(i, 3) cin >> s[i];
	FOR(i, 3) cout << s[i][0];
	cout << endl;

	return 0;
}

Measured memory_bytes: 384
import Control.Applicative
import Data.List
import Data.Array

solve :: Int -> String -> Int
solve n s = minimum (map numNotFaceLeader [0..n-1])
    where indicatorW = fmap (\x -> if x == 'W' then 1 else 0) s
          indicatorE = fmap (\x -> if x == 'E' then 1 else 0) s
          cumulativeW = listArray (0, n) (scanl (+) 0 indicatorW)
          cumulativeE = listArray (0, n) (scanl (+) 0 indicatorE)
          partialSumW :: Int -> Int -> Int
          partialSumW start end = (cumulativeW ! end) - (cumulativeW ! start)
          partialSumE :: Int -> Int -> Int
          partialSumE start end = (cumulativeE ! end) - (cumulativeE ! start)
          numNotFaceLeader :: Int -> Int
          numNotFaceLeader leader = (partialSumW 0 leader) + (partialSumE (leader+1) n)

main :: IO ()
main = do
    n <- readLn
    s <- getLine
    putStrLn $ show (solve n s)


Measured memory_bytes: 60156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

ll modExp(ll x, ll n, ll mod)
{
    if (n==0) return 1;
    if (n==1) return x%mod;
    ll ans = modExp(x,n/2, mod);
    ans = (ans*ans)%mod;
    if (n%2) ans*=x;
    return ans%mod;
}

ll rem(string &s, ll divisor)
{
    ll pow2 = 1;
    ll ans=0;
    for (int i=(int)s.length()-1; i>=0; --i)
    {
        ans+=(s[i]-'0')*pow2;
        pow2*=2;
        pow2%=divisor;
        ans%=divisor;
    }
    return ans;
}

ll getAns(ll currem)
{
    ll count=0;
    // cout << currem << endl;
    while (currem!=0)
    {
        ++count;
        currem%=__builtin_popcount(currem);
    }
    return count;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    string s;
    cin >> s;
    ll count=0;
    for (auto c:s) if (c=='1') count++;
    ll remdec = -1, reminc=-1;
    if (count>1) remdec=rem(s, count-1);
    reminc = rem(s, count+1);
    // cout << "T : " << count-1 << endl;
    for (int i=0; i<N; ++i)
    {
        if (s[i]=='1') {
            if (count==1) 
            {
                // String already zero
                cout << 0 << "\n"; continue;
            }
            else cout << 1+ getAns( (remdec +count-1 - modExp(2, N-1-i, count-1))%(count-1)) << "\n";
        }
        else if (s[i]=='0') {
            cout << 1+getAns( (reminc+ modExp(2,N-1-i, count+1))%(count+1) ) << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;
import java.util.LinkedList;
import java.lang.Math;
import java.util.Arrays;
import java.util.Collections;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int[] A = new int[n];
        sc.close();
        for(int i=0;i<A.length;i++){
            A[i]=0;
        }

        int k;
        for(int i=1;i<n;i++){
            for(int j=i+1;j<=n;j++){
                k=Math.min(j-i,Math.abs(i-x)+Math.abs(j-y)+1);
                A[k]=A[k]+1;
            }
        }        
        sc.close();
        for(int i=1;i<A.length;i++){
            System.out.println(A[i]);
        }

        // System.out.print(k);
        
    //     for(int i=0;i<A.length;i++){
    //         System.out.println(A[i]);
    //     }
    //     for(int i=0;i<B.length;i++){
    //         System.out.println(B[i]);
    //     }
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main() {
    int n,k;
    cin >> n >> k;
    combination comb(n);
    for(int i = 1;i<=k;i++) {
        mint ans = comb(n-k+1,i)*comb(k-1,i-1);
        cout << ans.x << endl;
    }
}

Measured memory_bytes: 3628
using System;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(Console.ReadLine());
	public J()
	{
		var X = F();
		var t = Math.Max(0, (int)((Math.Sqrt(8.0 * X + 1) - 1) / 2) - 3);
		var s = t * (t + 1L) / 2;
		while (s < X) { t++; s += t; }
		Console.WriteLine(t);
	}
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

vl eratos(const ll n) {
    vb is_prime(n + 1);
    vl p;

    for (int i = 0; i <= n; i++) {
        is_prime[i] = true;
    }

    for (int i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;

        for (int j = 2 * i; j <= n; j += i) {
            is_prime[j] = false;
        }
        p.emplace_back(i);
    }
    return p;
}


int main() {
    cin >> s >> k;
    ll idx = 0;
    while (idx < s.size() && s.at(idx) == '1' && idx < k - 1) {
        idx++;
    }
    if (idx == s.size()) {
        MSG(s.at(s.size() - 1))
    } else {
        MSG(s.at(idx))
    }
}


Measured memory_bytes: 3572
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b
end #for auto indent of eclipse

n,k = inp

p (k>1)? n-k : 0

Measured memory_bytes: 1788
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

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

    let w: String = sc.next();
    let mut count: i32 = 0;

    loop {
        let mut t: String = sc.next();
        if t == "END_OF_TEXT" {
            break;
        }
        t = t.to_lowercase();
        if t == w {
            count += 1;
        }
    }
    println!("{}", count);
}



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

#define int long long
#define REP(i, l, r) REPEAT(i,l,r,true) // [l, r)
#define rep(i, n) REP(i,0,n)           // [0, n)
#define REPEAT(i, l, r, condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n, l, r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...) true
#define showlr(n,l,r) true
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int, int>;

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

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &e:v)is >> e;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> v) {
    os << "{";
    for (T &e:v)os << e << (v.size() - (int) (&e - &v[0]) > 1 ? ", " : "");
    os << "}";
    return os;
}

void _DEBUG() {}

template<typename H, typename... T>
void _DEBUG(H a, T...b) {
    cerr << a << (sizeof...(b) ? "," : "\n");
    _DEBUG(b...);
}

inline void in() {}

template<typename H, typename... T>
void in(H &a, T &... b) {
    cin >> a;
    in(b...);
}

inline void out() {}

template<typename H, typename... T>
void out(H a, T... b) {
    cout << a << (sizeof...(b) ? " " : "\n");
    out(b...);
}

template<class T>
void resz(int n, T &v) { v.resize(n); }

template<class H, class... T>
void resz(int n, H &a, T &... b) {
    a.resize(n);
    resz(n, b...);
}

template<typename V, typename H>
void resize(vector<V> &v, const H a) { v.resize(a); }

template<typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
    v.resize(a);
    for (auto &v:v) resize(v, b...);
}

const int INF = 1LL << 55;
const int MOD = 1000000007;
const double EPS = 1e-8;

/*------------end of definitions------------*/

int A, B;

signed main() {

    in(A, B);
    out(max({A + B, A - B, A * B}));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  if(x<600){
    cout << 8 << endl;
  }else if(x<800){
    cout << 7 << endl;
  }else if(x<1000){
    cout << 6 << endl;
  }else if(x<1200){
    cout << 5 << endl;
  }else if(x<1400){
    cout << 4 << endl;
  }else if(x<1600){
    cout << 3 << endl;
  }else if(x<1800){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using Graph = vector<VE>;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h; cin >> h;
	int ans = 0;
	int now = 1;
	while (h != 0) {
		ans += now; h /= 2; now *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Rummy
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int T, card[16];
bool is_same_number(int a, int b, int c){
  if (a == b && b == c)
    return true;
  else
    return false;
}
bool is_sequence(int a,int b,int c){
  if (a+2 == c && b+1 == c)
    return true;
  else
    return false;
}
bool is_good_set(int a, int b, int c){
  return (is_same_number(a,b,c) || is_sequence(a,b,c));
}
bool is_all_good_set(){
  if (is_good_set(card[0],card[1],card[2])&&is_good_set(card[3],card[4],card[5])&&is_good_set(card[6],card[7],card[8]))
    return true;
  else
    return false;
}
int win(){
  // card ??????????????????
  sort(card, card+9);
  do{
    if (is_all_good_set()) // ??????card?????????????????????????????¶????????? 
      return 1;
  } while (next_permutation(card, card+9)); 
  // ??¨???????????????????????????????????????????????¶????????????????????£??? 
  return 0;
}
int main(){
  cin >> T;
  for (int t=0; t<T; ++t) {
    for (int i=0; i<9; ++i) { 
      cin >> card[i];
    }
    string color;
    for (int i=0; i<9; ++i) {
      cin >> color;
        if (color == "G") 
          card[i] += 10;
        else if (color == "B") 
          card[i] += 20;
    }
    cout << win() << endl;
  }
}
// ??????????????¨???
// red:0 , blue:10 , green:20
// 1-9

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
double work(int n,double d,double x)
{//cout<<n<<' '<<d<<' '<<x<<endl;
	if (!n) return 0;
	return work(n-1,d+(double)d/n+2.5*x/n,(double)(n+2)/n*x)+d+(double)(n+n-1)*x/2;
}
int main()
{
	int n;double d,x;scanf("%d%lf%lf",&n,&d,&x);
	printf("%.10lf\n",work(n,d,x));
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IN(type, n) type n; cin >> n

int main() {
  IN(ll, X);
  IN(ll, K);
  IN(ll, D);

  X = abs(X);
  // if (X - K * D >= 0) {
  //   cout << X - K * D << endl;
  // } else {
    // ll x1 = X % D;
    // ll x2 = abs(x1 - D);
    // if ((K - (X / D)) % 2 == 0) cout << x1 << endl;
    // else cout << x2 << endl;

    ll cnt = min(X / D, K);
    X -= D * cnt;
    K -= cnt;
    if (K % 2 == 1) X -= D;
    cout << abs(X) << endl;
  // }

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll n;
	std::cin >> n;

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

	std::sort(a.begin(), a.end(), std::greater<ll>());

	ll alice = 0, bob = 0;
	for(int i = 0;i < n;i+=2)
	{
		alice += a[i];
		if(i+1 < n) bob += a[i+1];
	}

	std::cout << alice - bob << std::endl;

	return 0;
}

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;

void solve(){
   map<long ,long >mp;
   long  x,y;
   cin>>x;
   bool f=true;
   for(int i=0;i<x;i++){
        cin>>y;
        if(mp[y]!=0){
           f=false;
        }
        mp[y]++;
   }
   if(f)
   cout<<"YES";
   else
   {
      cout<<"NO";
   }
      
}
int main(){
//   #ifndef ONLINE_JUDGE
//      freopen("in.txt", "r", stdin);
//      freopen("out.txt", "w", stdout);
//   #endif  
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
  return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int MAXN = 100005;
const int MOD = 1e9 + 7;

int N, M, A, B, fac[2 * MAXN], inv[2 * MAXN];

long long res = 0;

int qpow(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (long long)ret * a % MOD;
		a = (long long)a * a % MOD;
		b >>= 1;
	}
	return ret;
}

void init()
{
	fac[0] = 1;
	for (int i = 1; i < 2 * MAXN; i++)
		fac[i] = (long long)fac[i - 1] * i % MOD;
	for (int i = 0; i < 2 * MAXN; i++)
		inv[i] = qpow(fac[i], MOD - 2);
}

int C(int n, int m) 
{
	return (long long)fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M >> A >> B;
	init();
	for (int i = 1; i <= N - A; i++)
	{
		res = (res + (long long)C(i + B - 2, B - 1) * C(N - i + M - B - 1, N - i) % MOD) % MOD;
	}
	cout << res << endl;
	return 0;	
}

Measured memory_bytes: 1792
n = int(input())
c = list(input())
num_r = c.count("R")
right=num_r
ans = 0
b_num_r = c[:num_r].count("R")
"""
for i in range(num_r):
    if c[i] == "W":
        while right != n-1 or c[right] != "W" 
"""
print(num_r - b_num_r)

Measured memory_bytes: 11996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;


int main() {
  int n,a;
  cin>>n>>a;
  if(n<=a)cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    n *= 2;
    int l[n];
    for(int i = 0;i < n;i++)
    {
        cin >> l[i];
    }
    sort(l,l + n,greater<int>());
    int ans = 0;
    for(int i = 0;i + 1 < n;i+=2)
    {
        ans += min(l[i],l[i + 1]);
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-4;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

ld getdis(vector<ld>&l, vector<ld>&r) {
	ld sum = 0;
	for (int i = 0; i < 3; ++i) {
		sum += powl(r[i] - l[i], 2);
	}
	return sqrt(sum);
}

int main() {
	int N; cin >> N;
	while (N--) {

		vector<ld>lens(3);
		for (int i = 0; i < 3; ++i)cin >> lens[i];
		int M; cin >> M;
		vector<vector<ld>>points(M,vector<ld>(3));
		for (int i = 0; i < M; ++i) {
			for (int j = 0; j < 3; ++j) {
				cin >> points[i][j];
			}
		}
		vector<int>anss;
		for (int p = 0; p < M; ++p) {
			for (int q = 0; q < M; ++q) {
				for (int r = 0; r < M; ++r) {
					if (p == q || q == r || r == p)continue;
					ld a = getdis(points[p], points[q]);
					ld b = getdis(points[q], points[r]);
					ld c = getdis(points[r], points[p]);
					ld rate = a / lens[0];
					a /= rate;
					b /= rate;
					c /= rate;
					if ((abs(a - lens[0]) < eps) && (abs(b - lens[1]) < eps) && (abs(c - lens[2]) < eps)) {
						anss = vector<int>{ r,p,q };
					}
				}
			}
		}
		for (int i = 0; i < 3; ++i) {
			cout << anss[i] + 1;
			if (i == 2)cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 3080
INF = 10 ** 9
n, m = gets.split.map(&:to_i)
students = []
n.times { students << gets.split.map(&:to_i) }
points = []
m.times { points << gets.split.map(&:to_i) }
ans = []
students.each do |s_x, s_y|
  dist = INF
  point = 0
  points.each_with_index do |(p_x, p_y), i|
    tmp_dist = (s_x - p_x).abs + (s_y - p_y).abs
    if dist > tmp_dist
      dist = tmp_dist
      point = i + 1
    end
  end
  ans << point
end
ans.each { |a| puts a }


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

string str;
char st[15],c;

int main()
{
    bool T=false;
    cin >> str;
    int t=str.size();
    for (int i=0;i<t;i++)
    {
        cin >> st[i];
        if (st[i]!=str[i])
            T=true;
    }
    cin >> c;
    if (T)
        cout << "No\n";
    else
        cout << "Yes\n";

}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(i64, a, b, c, x, y);
  c *= 2;

  i64 minv = LINF;
  reps(i, 0, 100000) {
    i64 norm = i * c + a * max<i64>(0, x - i) + b * max<i64>(0, y - i);
    chmin(minv, norm);
  }

  OUTL(minv);

  return 0;
}


Measured memory_bytes: 256
n=int(input())
A=[int(input()) for _ in range(n)]

if A[0]!=0:print(-1);exit()

cnt=0
for i in range(1,n):
    if A[i-1]+1==A[i]:
        cnt +=1
    elif A[i-1]==A[i]:
        cnt +=A[i]
    elif A[i-1]>A[i]:
        cnt +=A[i]
    else:print(-1);exit()

print(cnt)

Measured memory_bytes: 104192
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
ll N, M, S;
ll dist[55][2600];
vector<vector<ll>>E[55];
ll C[55], D[55];
ll MX = 2550;
 
void dijkstra() {
	min_priority_queue<vector<ll>>q;
	//dist,city,state
	for (int i = 0; i < 55; i++) {
		for (int j = 0; j < 2600; j++) {
			dist[i][j] = inf;
		}
	}
	q.push({0,0,min(S,MX)});
	dist[0][min(S, MX)] = 0;
	while (q.size()) {
		auto v = q.top();
		q.pop();
		ll d = v[0];
		int city = v[1];
		int curmoney = v[2];
		if (dist[city][curmoney] < d)continue;
		fore(x, E[city]) {
			int to = x[0];
			int money = x[1];
			ll cost = x[2];
			if (money > curmoney)continue;
			if (curmoney < MX) {
				if (d + cost < dist[to][curmoney - money]) {
					dist[to][curmoney - money] = d + cost;
					q.push({dist[to][curmoney - money],to,curmoney-money});
				}
			}
			else {
				if (d + cost < dist[to][MX]) {
					dist[to][MX] = d + cost;
					q.push({ dist[to][MX],to,MX });
				}
			}
		}
		if (curmoney < MX){
			if (d + D[city] < dist[city][min(MX, curmoney + C[city])]) {
				dist[city][min(MX, curmoney + C[city])] = d + D[city];
				q.push({ d + D[city],city,min(MX,curmoney + C[city]) });
			}
		}
	}
}
 
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	cin >> N >> M >> S;
	for (int i = 0; i < M; i++) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--, v--;
		E[u].pb({ v,a,b });
		E[v].pb({ u,a,b });
	}
	for (int i = 0; i < N; i++)cin >> C[i] >> D[i];
 
	dijkstra();
	for (int i = 1; i < N; i++) {
		ll tmp = inf;
		for (int j = 0; j < 2600; j++)tmp = min(tmp,dist[i][j]);
		puts(tmp);
	}
	
	return 0;
}

Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> button(N);
    for (int i = 0; i < N; i++){
        cin >> button[i];
    }
    int next = 1;
    int ans = 1;
    for (int i = 0; i < N; i++){
        next = button[next-1];
        if (next == 2){
            cout << ans << endl;
            break;
        }
        ans ++;
    }
    if (next != 2){
        cout << "-1" << endl;
    }
    
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!
import heapq

X,Y,A,B,C=map(int,input().split())

def label(lis,num):
    temp=[]
    for i in range(len(lis)):
        temp.append([lis[i],num])
    return temp

Red=label(list(map(lambda x:int(x)*-1,input().split())),1)
Green=label(list(map(lambda x:int(x)*-1,input().split())),2)
White=label(list(map(lambda x:int(x)*-1,input().split())),0)

App=Red+Green+White

heapq.heapify(App)

a,b,c=X,Y,0
ans=0
while a+b!=c:
    score,color=heapq.heappop(App)
    if color==1 and a>0:
        ans-=score
        a-=1
    elif color==2 and b>0:
        ans-=score
        b-=1
    elif color==0:
        ans-=score
        c+=1
print(ans)
#print(App)

Measured memory_bytes: 48556
import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]
ab.sort(key=lambda t: t[1])
ans = 0
prev_b = -1

for a, b in ab:
    if a>=prev_b:
        ans += 1
        prev_b = b

print(ans)

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

int main() {
    int a[3], k;
    cin >> a[0] >> a[1] >> a[2] >> k;

    sort(a, a+3);
    for (int i = 0; i < k; i++) {
        a[2] *= 2;
    }

    cout << a[0] + a[1] + a[2] << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
//***********************************************************
// Bellmanford
//***********************************************************
template <typename X>
struct Node{ // Status of node
  int idx; // index of node
  X dist; // distance from start node
  
  Node() = default;

  Node(int idx, X dist) : idx(idx), dist(dist) {}

  bool operator == (const Node& r) const {
    return (idx == r.idx && dist == r.dist);
  }

  bool operator != (const Node& r) const {
    return !(*this == r);
  }

  bool operator < (const Node& r) const { 
    return dist > r.dist;
  }

  bool operator > (const Node& r) const {
    return dist < r.dist;
  }  
};

template <typename X>
struct Edge{ // status of edge
  int from; 
  int to;
  X cost;

  Edge() = default;

  Edge(int from, int to, X cost) : from(from), to(to), cost(cost) {}
};

template <typename X>
class Graph{
private:
  int n; // number of node
  int m; // number of edge
  vector<vector<Edge<X>>> edge; // edge list
  vector<Node<X>> node; // node list

  vector<vector<X>> d; // d[i][j] := shortest distance from node "i" to node "j"
  const X inf = 1e+9; // initial value of d
public:
  explicit Graph(int n) : n(n) {
    edge.resize(n);
  }

  Graph(int n, int m, vector<int> from, vector<int> to, vector<X> cost) : n(n), m(m) {
    edge.resize(n);
    rep(i,m) {
      add_edge(from[i], to[i], cost[i]);
      //      add_edge(to[i], from[i], cost[i]);      
    }
  }

  void add_edge(int from, int to, X cost) {
    edge[from].emplace_back(from, to, cost);
  }

  //***********************************
  // Bellmanford
  //***********************************
  bool Bellmanford(int s) {
    d.resize(n);
    d[s].resize(n, inf);
    d[s][s] = 0;
    
    bool flag = true;
    rep(i,n) {
      rep(v,n) {
	if(d[s][v] == inf) continue;
	for(auto next: edge[v]) {
	  int w = next.to;
	  X cost = next.cost;
	  if(d[s][w] > d[s][v] + cost) {
	    d[s][w] = d[s][v] + cost;
	    if(i == n - 1) flag = false;
	  }
	}
      }
    }
    return flag;
  }
  
  X Get_d(int start, int goal) {
    //    if(d[start][goal] == inf) return -1;
    return d[start][goal];
  }

  X Get_inf() { return inf; }
  
};

int main()
{
  int n,m;cin >> n >> m;
  int r; cin >> r;
  vector<int> a(m), b(m), c(m);
  rep(i,m) cin >> a[i] >> b[i] >> c[i];

  Graph<int> gp(n, m, a, b, c);
  if(gp.Bellmanford(r)) {
    rep(i,n) {
      if(gp.Get_d(r, i) == gp.Get_inf()) cout << "INF" << "\n";
      else cout << gp.Get_d(r, i) << "\n";
    }
  }
  else cout << "NEGATIVE CYCLE" << "\n";
  
  return 0;
}



Measured memory_bytes: 3256
n,k = map(int, input().split())
S = input()

ans = []
c = 1
# RL圧縮
for i in range(1,n):
    if S[i-1] == S[i]:
        c += 1
    else:
        ans.append(c)
        c = 1
ans.append(c)
# ansの個数は1個毎に減っていく
if len(ans) // 2  <= k:
    print(n-1)
else:
    d = len(ans) - 2*k
    print(n-d)


Measured memory_bytes: 9900