akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define abs(N) (((N)>0)?(N):(-1)*(N))


int main() {
	int N,M;
	cin >> N >> M;
	vector<int> v;

	for (int i = 1; i <= sqrt(M); ++i) {
		if(M%i==0){
			v.push_back(i);
			if(i*i!=M)	v.push_back(M/i);
		}
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		if(v[i]>=N){
			cout << v[v.size()-1-i] << endl;
			return 0;
		}
	}
	return 0;
}


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

int main()
{
    int n, k;
    std::cin >> n >> k;

    std::vector<int> p(n);
    for (auto& val : p)
    {
        std::cin >> val;
    }

    std::sort(p.begin(), p.end());

    int ans = 0;
    for (auto i = 0; i < k; ++i)
    {
        ans += p[i];
    }

    std::cout << ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

string s;
int n;

int solve(int x) {
	int last = -1;
	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] - 'a' == x) {
			last = i;
			continue;
		}
		if (last == -1) {
			ans = max(ans, n - i);
		} else {
			ans = max(ans, min(n - i, last - i));
		}
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> s;
	n = s.length();
	int ans = 1000;
	for (int i = 0; i < 26; i++) {
		ans = min(ans, solve(i));
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) cin >> c.at(i).at(j);
  
  string ans = "Yes";
  if (c.at(0).at(1) - c.at(0).at(0)
      != c.at(1).at(1) - c.at(1).at(0)
      || c.at(1).at(1) - c.at(1).at(0)
      != c.at(2).at(1) - c.at(2).at(0)) ans = "No";
  if (c.at(0).at(2) - c.at(0).at(1)
      != c.at(1).at(2) - c.at(1).at(1)
      || c.at(1).at(2) - c.at(1).at(1)
      != c.at(2).at(2) - c.at(2).at(1)) ans = "No";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}


$N = $data[0][0];
$M = $data[0][1];

//for ($i = 0;$i < $N; $i++) {
//    $G[$i] = [];
//}

for ($i = 1;$i <= $M; $i++) {
    $a = $data[$i][0];
    $b = $data[$i][1];
    $G[$a][] = $b;
    $G[$b][] = $a;
}


$dist = array_fill(1, $N, -1);
$parents = array_fill(1, $N, -1);

$startN = 1;
$dist[$startN] = 0;

$queue = new SplQueue();
$queue->push($startN);

while(!$queue->isEmpty()) {
    $v = $queue->dequeue();

    foreach ($G[$v] as $next_v) {
        if ($dist[$next_v] !== -1) continue;
        $dist[$next_v] = $dist[$v] + 1;
        $parents[$next_v] = $v;
        $queue->enqueue($next_v);
    }
}


if (array_search(-1, $dist) !== false) {
    echo 'No';
    exit;
}


$sliced = array_slice($parents, 1);
echo "Yes\n";
echo join("\n", $sliced);




Measured memory_bytes: 173464
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<list>
using namespace std;
const int p =1e5+5;
int main()
{
	int a[p];
	int n;
	cin>>n;
	a[0]=0;
	a[n+1]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int sum = 0;
	for(int i=0;i<n+1;i++)
	{
		sum+=fabs(a[i+1]-a[i]);
	}
	for(int i=1;i<n+1;i++)
	{
		int y = sum;
		y=y-(fabs(a[i+1]-a[i])+fabs(a[i]-a[i-1]))+fabs(a[i+1]-a[i-1]);
		cout<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
n = int(input())
arr = [ ([], []) for i in range(n+1)]
for i in range(n):
    m = int(input())
    for j in range(m):
        a, b = map(int, input().split())
        if b == 1:
            arr[i][0].append(a-1)
        else:
            arr[i][1].append(a-1)
cur = [0 for i in range(n)]
ans = 0
def solve(i):
    global ans, cur, n, arr
    if i == n:
        flag = 0
        for j in range(n):
            if cur[j] == 1:
                for honest in arr[j][0]:
                    if cur[honest] == 0:
                        flag = 1
                for no in arr[j][1]:
                    if cur[no] == 1:
                        flag = 1
        if flag == 0:
            ans = max(ans, sum(cur))
        return
    cur[i] = 1
    solve(i+1)
    cur[i] = 0
    solve(i+1)
solve(0)
print(ans)

Measured memory_bytes: 52696
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


int main() {
    int N;
    cin >> N;
    vint A(N);
    v2ll dp(N + 1, vll(2, 0));
    rep(i, N) {
        cin >> A[i];
    }
    dp[1][0] = A[0];
    dp[1][1] = -A[0];
    REP(i, 2, N + 1) {
        dp[i][0] = max(dp[i - 1][0] + A[i - 1], dp[i - 1][1] - A[i - 1]);
        dp[i][1] = max(dp[i - 1][0] - A[i - 1], dp[i - 1][1] + A[i - 1]);
    }
    cout << dp[N][0] << endl;
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long count=0;
  cin >> N;
  vector<int>vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  
  
  for(int i=0;i<N;i++){
    if(i==N-1){
      count+= vec.at(i)/2;
    }
    else if(vec.at(i)%2==1){
      count += vec.at(i)/2;
      if(vec.at(i+1)>0){
        vec.at(i+1)--;
        count++;
      }
    }
    else{
      count += vec.at(i)/2;
    }
  }
  
  cout << count <<endl;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pb push_back
#define INF INT_MAX
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main()
{
    iso;
    double a,b;
    cin>>a>>b;
    cout<<ceil(a/(2*b+1));
}


Measured memory_bytes: 256
read n
a=({a..z})
x=26
d=1
while((n>x))
do
    n=$((n-x))
    d=$((d+1))
    x=$((x*26))
done
n=$((n-1))
for i in `seq $d`
do
    x=$((x/26))
    c=$c${a[n/x]}
    n=$((n%x))
done
echo $c


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

/*
   There are N dishes, numbered 1,2,..,N. Initially, for each i (1<=i<=N),
   Dish i has ai (1<=ai<=3) pieces of sushi on it.

   Taro will perform the following operation repeatedly until all the pieces of
   sushi are eaten:

   Roll a die that shows the numbers 1,2...,N

   with equal probabilities, and let i be the outcome. If there are some pieces
   of sushi on Dish i , eat one of them; if there is none, do nothing.

   Find the expected number of times the operation is performed before all the
   pieces of sushi are eaten.
 */

const int N = 305;
int n, fq[4];
long double prob[N][N][N], ev[N][N][N];

int32_t main() {
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    fq[a]++;
  }

  prob[fq[1]][fq[2]][fq[3]] = 1;

  for (int c = n; c >= 0; c--) {
    for (int b = n; b >= 0; b--) {
      for (int a = n; a >= 0; a--) {
        if (a + b + c == 0 || a + b + c > n)
          continue;

        long double prob_waste = (long double) (n - (a + b + c)) / n;

        //geometric progression sum
        long double ev_waste = prob_waste / (1 - prob_waste);
        ev[a][b][c] += ev_waste * prob[a][b][c];

        if (a > 0) {
          //remove from one pile with 1 plate
          prob[a-1][b][c] += prob[a][b][c] * (long double)a / (a + b + c);
          ev[a-1][b][c] += ev[a][b][c] * (long double)a / (a + b + c);
        }

        if (b > 0) {
          //remove from one pile with 2 plates
          prob[a+1][b-1][c] += prob[a][b][c] * (long double)b / (a + b + c);
          ev[a+1][b-1][c] += ev[a][b][c] * (long double)b / (a + b + c);
        }

        if (c > 0) {
          //remove from one pile with 3 plates
          prob[a][b+1][c-1] += prob[a][b][c] * (long double)c / (a + b + c);
          ev[a][b+1][c-1] += ev[a][b][c] * (long double)c / (a + b + c);
        }
      }
    }
  }

  printf("%.10Lf\n", ev[0][0][0] + fq[1] + 2 * fq[2] + 3 * fq[3]);
  return 0;
}


Measured memory_bytes: 874752
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef long long LL;
const int N=200005;
int n,fa[N],x[N][2];
struct ufs{
	int fa[N];
	void init(int n){rep(i,1,n)fa[i]=i;}
	int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
}o;
struct cmp{
	bool operator()(const int&k1,const int&k2)const{
		if(1LL*x[k1][0]*x[k2][1]!=1LL*x[k2][0]*x[k1][1])return 1LL*x[k1][0]*x[k2][1]>1LL*x[k2][0]*x[k1][1];
		return k1<k2;
	}
};
set<int,cmp>S;
int main(){
	scanf("%d",&n);
	o.init(n);
	rep(i,2,n)scanf("%d",&fa[i]);
	rep(i,1,n){
		int v;
		scanf("%d",&v);
		x[i][0]=v==0;
		x[i][1]=v==1;
		if(i>1)S.insert(i);
	}
	LL ans=0;
	while(SZ(S)){
		int k1=*S.begin();
		int k2=o.fd(fa[k1]);
		D("mer %d\n",k1);
		S.erase(S.begin());
		S.erase(k2);
		ans+=1LL*x[k2][1]*x[k1][0];
		x[k2][0]+=x[k1][0];
		x[k2][1]+=x[k1][1];
		o.fa[k1]=k2;
		if(o.fd(k1)!=1){
			S.insert(o.fd(k1));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){

	char N;
	cin >> N;
	char a[N];

	for(int i = 0; i < N; i++){
		cin >> a[i];
	}

	int count;
	for(int i = 0; i < N; i++){
		if( a[i] == 'Y'){
			count++;
		}
	}

	if(count != 0){
		cout << "Four";
	}
	else{
		cout << "Three";
	}

	return 0;

}

Measured memory_bytes: 256
fun sqrtFloor(x: Long): Long {
  var l = 0L
  var u = 2000000000L
  while (Math.abs(u - l) >= 2) {
    val m = (l + u) / 2
    if (m * m <= x) {
      l = m
    } else {
      u = m
    }
  }
  return l
}

fun main(args: Array<String>) {
  val q = readLine()!!.toInt()
  repeat(q) {
    // a <= b
    val (a, b) = readLine()!!.split(" ").map(String::toLong).sorted()
    if (a == 1L && b == 1L) {
      println(0)
      return@repeat
    }
    val product = a * b - 1
    val r = sqrtFloor(product)
    var ans = 2 * r
    // Don't double count (r, r)
    if (r == product / r) {
      ans -= 1
    }
    val aSet = mutableSetOf<Long>()
    if (a <= r) {
      aSet.add(a)
    }

    val a1 = product / b
    if (a1 > 0) {
      val b1 = product / a1
      if (b1 == b) {
        val a2 = a1 + 1
        val b2 = product / a2
        if (b1 - 1 == b2) {
          aSet.add(a1)
        }
      }
    }

    // println(aSet.size)
    ans -= aSet.size

    println(ans)
  }
}

Measured memory_bytes: 37808
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 68620
import sys
sys.setrecursionlimit(2000)

def check_2(num):
    if num % 2 != 0:
        return 0
    return check_2(num // 2) + 1


def check_5(num):
    if num % 5 != 0:
        return 0
    return check_5(num // 5) + 1


def f_2(num):
    if num < 2:
        return 0
    return f_2(num - 2) + check_2(num)


def f_5(num):
    if num < 5:
        return 0
    return f_5(num - 2) + check_5(num)


N = int(input())
if N < 10:
    print(0)
    exit()
if N % 2 != 0:
    print(0)
    exit()
i = 1
ans = 0
while N // ((5 ** i) * 2) > 0:
    ans += N // ((5 ** i) * 2)
    i += 1
print(ans)


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vl;
#define kill(N) cout<<N<<'\n'
#define forn(N) for(long long i=0; i<N; i++)
#define pb push_back

long long N,M,fac[500005],inv_fac[500005]; const long long MOD=1000000007,bagiMOD=1000000005;


void factotor(){
	fac[0]=1;
	for(long long i=1; i<=M; i++){
		fac[i]=fac[i-1]*i%MOD;
	}
}
long long fpower(long long a, long long b){
	if(b==0){
		return 1;
	}else if(b==1){
		return a;
	}else if(b%2==0){
		long long tmp=fpower(a,b/2)%MOD;
		return tmp*tmp%MOD;
	}else{
		long long tmp=fpower(a,b/2)%MOD;
		return tmp*tmp%MOD*a%MOD;
	}
}
void inverse_fac(){
	for(long long i=0; i<=M; i++){
		inv_fac[i]=fpower(fac[i],bagiMOD);
	}
}
long long sub(long long a, long long b){
	if(a>=b)return a-b;
	return a+MOD-b;
}
int main(){
	cin>>N>>M;
	factotor(); inverse_fac();
	long long total=0;
	for(long long i=0; i<=N; i++){
		if(i%2==0){
			total+=fac[M-i]*inv_fac[i]%MOD*inv_fac[N-i]%MOD;
			total=total%MOD;
		}else{
			total=sub(total,fac[M-i]*inv_fac[i]%MOD*inv_fac[N-i]%MOD);
		}
	}
	total=total*fac[M]%MOD*inv_fac[M-N]%MOD*inv_fac[M-N]%MOD*fac[N]%MOD;
	cout<<total<<'\n';
}

Measured memory_bytes: 11384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}


fn main() {
    input!{
        r: f64,
    }
    println!("{}", 2.0 * 3.14159 * r);
}


Measured memory_bytes: 2216
import Foundation

let input: String = readLine()!
let k = Int(input)!

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")

let a = Int(split[0])!
let b = Int(split[1])!

var ans = "NG"

var j = 0
var i = 0
repeat {
    i += 1
    j = k * i
    if j >= a && j <= b {
        ans = "OK"
        break
    }
} while ( b > j )

print(ans)

Measured memory_bytes: 14072
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    int ans[3];
    rep(i, n+1) {
        rep(j, i+1) {
            ll mon = j*1000 + (i-j)*5000 + (n-i)*10000;
            if(mon == y) {
                cout << n-i << ' ' << i-j << ' ' << j << endl;
                return 0;
            }
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
n = int(input())
s = [str(input()) for _ in range(n)]
s.append('zzzzzzzzzzz')
s.sort()

l_cnt = []
c_max = 1
cnt = 1
bfo = 'xxxxxxxxxxx'

for i in s:
    if i == bfo:
        cnt += 1
        c_max = max(c_max, cnt)
    else:
        l_cnt.append([bfo, cnt])
        bfo = i
        cnt = 1

for j in range(len(l_cnt)):
    if j == 0:
        continue
    else:
        if c_max == l_cnt[j][1]:
            print(l_cnt[j][0])


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

int main()
{
  string ch;
  int n;
  
  while(1)
    {
      cin >> ch;
      if(ch == "-")
	break;
      cin >> n;
      int h[n];
      for(int i=0; i<n; i++)
	{
	  cin >> h[i];
	  ch = ch.substr(h[i], ch.size()) + ch.substr(0, h[i]);
	}
      cout << ch << endl;
    }
}

Measured memory_bytes: 1216
program AIsing2020C
    implicit none
    integer(8)::N,i,j,k,A(10000),m
    read*,N
    A=0
 
    do i=1,100
        do j=1,100
            do k=1,100
                m=i**2+j**2+k**2+i*j+j*k+k*i
                if(m<=10000)A(m)=A(m)+1
            end do
        end do
    end do
 
    do i=1,N
        print'(i0)',A(i)
    end do
end program AIsing2020C

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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

vector<ll> monsters;

int main ()
{
    int n, k; cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        ll x; cin >> x;
        monsters.pb(x);
    }

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

    ll sum = 0;

    for (int i = 0; i < (n-k); i++)
        sum += monsters[i];

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
int main(void) {
	int x[11];
	int r, d, i;
	scanf("%d%d%d", &r, &d, &x[0]);
	x[1] = r * x[0] - d;
	printf("%d\n", x[1]);
	for (i = 2; i < 11; i++) {
		x[i] = r * x[i - 1] - d;
		printf("%d\n", x[i]);
	}

	getchar();
	getchar();

	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

vector<int> g[N];
int vis[N], ans[N];

void dfs(int n) {
    if (vis[n]) return;
    vis[n] = 1;
    for (auto i : g[n]) {
        dfs(i);
        ans[n] = max(ans[n], 1 + ans[i]);
    }
    if (g[n].size() == 0) ans[n] = 1;
}

signed main(){
    IOS;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
    }
    for (int i  =1; i <= n; i++) {
        if (vis[i]) continue;
        dfs(i);
    }
    int mx = 0;
    for (int i = 1; i <= n; i++)
        mx = max(mx, ans[i]);
    cout << mx - 1<< endl;
    return 0;
}

Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b;
   cin>>a>>b;
   int mx=(a+b);
   mx=max(mx,max(a-b,a*b));
   cout<<mx<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

// https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
ll modPow(long long a, long long n) {
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  long long t = modPow(a, n / 2);
  return (t * t) % MOD;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	for(int i=1; i< p+1; i++) {
		a = (a * (n - i + 1)) % MOD;
		b = (b * i) % MOD;
	}
	return a * (modPow(b, MOD - 2)) % MOD;
}

int main() {
    // input, ready
    vector<int> vec(3);
    cin >> vec[0] >> vec[1] >> vec[2];
    sort(vec.begin(),vec.end());
    int minNum = vec[0];
    int middleNum = vec[1];
    int maxNum = vec[2];

    int ans = 0;
    ans += (maxNum - middleNum);
    minNum += (maxNum - middleNum);
    if ((maxNum- minNum)%2 == 0) ans += ((maxNum- minNum)/2);
    else {
      ans += ((maxNum- minNum)/2);
      ans += 2;
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  uli w,h;
  scanf("%lld %lld",&w,&h);
  vector<pair<uli,int> >d;
  for(int i=0;i<w;i++){
    uli x;
    scanf("%lld",&x);
    d.push_back(pair<uli,int>(x,0));
  }
  for(int i=0;i<h;i++){
    uli x;
    scanf("%lld",&x);
    d.push_back(pair<uli,int>(x,1));
  }
  sort(d.begin(),d.end());
  uli ans=0ll;
  uli x=0ll,y=0ll;
  for(pair<uli,int>e:d){
    uli inc=0;
    if(e.second==0){
      inc=e.first*(h+1);
      inc-=e.first*(x);
      y++;
    }
    else{
      inc+=e.first*(w+1);
      inc-=e.first*(y);
      x++;
    }
    ans+=inc;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 4464
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
vector<bool> isPr;
void isPrime( ll n ){
  isPr.assign(n+1,true);
  isPr.at(0) = false;
  isPr.at(1) = false;
  isPr.at(2) = true;
  for(ll now=2;now<=n;++now){
    if( isPr[now] ){
      if( (double)now >= sqrt(n) ) return;
      ll cnt = 2;
      while( now*cnt <= n ){
        isPr[now*cnt] = false;
        cnt++;
      }
    }
  }
}

int main(){
  ll q;
  cin >> q;
  isPrime(100000);
  vector<ll> sum(100001);
  ll now = 0;
  for(ll i=1;i<=100000;i+=2){
    if( isPr[i] && isPr[(i+1)/2] ){
      ++now;
      sum[i] = now;
    }else{
      sum[i] = now;
    }
  }
  rep(i,q){
    ll l,r;
    cin >> l >> r;
    ll ans;
    if( isPr[l] && isPr[(l+1)/2] ){
      ans = sum[r]-sum[l]+1;
    }else{
      ans = sum[r]-sum[l];
    }
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define lld long double
#define ll long long int
#define modulo 1000000007
#define pb emplace_back

void solve(){
lld n=0,q=0,x=0,y=0,k=0,m=0;
cin>>n>>q;
ll b=(ll)(n*q);
cout<<b<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
    int t=1;
	//cin>>t;
     while(t--){
     	solve();
	 }
     return 0;
} 

Measured memory_bytes: 3804
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    double a,b;
    cin>>a>>b;
    cout<<fixed<<setprecision(10)<<a/b;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N, K = list(map(int, input().split()))
max_i = min(K, N - K + 1)

MAX = N * 2
PRIME = 10 ** 9 + 7

fac = [0] * MAX
finv = [0] * MAX


def invMod(a, m):
    a %= m
    b, x, y = m, 1, 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        x -= t * y
        x, y = y, x
    return x % m


def binomInit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, MAX):
        fac[i] = (fac[i - 1] * i) % PRIME
        finv[i] = (finv[i - 1] * invMod(i, PRIME)) % PRIME
        

def binom(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % PRIME


binomInit()
    

for i in range(1, K + 1):
    blue_part = binom(K - 1, i - 1)
    red_part = binom(N - K + 1, i)
    print((blue_part * red_part) % PRIME)


Measured memory_bytes: 43504
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);


int main() {
    string s;
    cin >> s;
    auto is_even = [&] (string s0) -> bool {
        int n = s0.size();
        return s0.substr(0, n/2) == s0.substr(n/2);
    };
    while(!s.empty()) {
        s.pop_back();
        s.pop_back();
        if (is_even(s)) {
            cout << s.size() << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
	LL a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(a==b)cout<<"YES";
	else
	{
		if(v<=w)cout<<"NO";
		else
		{
			if(abs(a-b)>(v-w)*t)cout<<"NO";
			else cout<<"YES";
		}
	}
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

#define rep(i,N) for (int i = 0; i < N; i++)
#define llong long long

int N;
string s;

int main() {
    cin >> N >> s;
    int res = 1;
    rep(i,N-1) if (s[i] != s[i+1]) res++;
    cout << res << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head+1) % LEN;
  return x;
}

int min(int a,int b){
  return a<b ? a : b;
}

int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }

  head = 1; tail = n+1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t>0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 11952
#include<stdio.h>
#include<string.h>
int main()
{
	int X,Y;
	
	char S[20];
	char T[20];
	char U[20];
    
    scanf("%s %s",S,T);
    scanf("%d %d",&X,&Y);
    scanf("%s",U);


	if(strcmp(S,U)==0)
	{
		
		
	X--;
	printf("%d %d",X,Y);
	} 	
	
  else 
	{
		
	Y--;
	printf("%d %d",X,Y);
	}
	
	return 0;
}

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

using namespace std;

int main(void) {
  int a, b;
  cin >> a >> b;

  if(a + b == 15) {
    cout << "+" << endl;
  }
  else if(a * b == 15) {
    cout << "*" << endl;
  }
  else {
    cout << "x" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
ll a[200001],b[200001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	if(n%2){
		cout<<b[n/2]-a[n/2]+1;
	}else{
		ll mn=a[n/2]+a[n/2-1],mx=b[n/2]+b[n/2-1];
		cout<<mx-mn+1;
	}
	re 0;
}

Measured memory_bytes: 6740
def main():
    from bisect import bisect_right
    n=int(input())
    a=[int(input()) for _ in range(n)]

    color=[]
    for i in range(n-1,-1,-1):
        num=a[i]
        idx=bisect_right(color,num)
        if idx==len(color):
            color.append(num)
        else:
            color[idx]=num
    
    print(len(color))    
if __name__=='__main__':
    main()

Measured memory_bytes: 7836
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
		    int T = sc.nextInt();
		    int D = sc.nextInt();
		    int L = sc.nextInt();
		    if (T == 0) return;
		    int ans = 0;
		    int index = 0;
		    int time = 0;
		    boolean b = false;
		    for (int i = 0; i < T; i++) {
			int x = sc.nextInt();
			if (x >= L) {
			    if (!b) {
				b = true;
				index = i;
			    }
			    time = D;
			}
			else time--;
			if (time == 0 || (i == T - 1 && time > 0)) {
			    ans += i - index;
			    b = false;
		        }
		    }
		    System.out.println(ans);
		}
	}
}



Measured memory_bytes: 245396
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;
	
int main(){
	int n;
	cin >> n;
	
	vector<long long> a(n);
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	sort(a.begin(),a.end(),greater<int>());
	
	map<int,int> mp;
	
	for(int i=0;i<n;i++){
		mp[a[i]]++;
	}
	
	int cnt_max=0;
	
	for(int i=2;i<=100000;i++){
		int now_sum=mp[i]+mp[i-1]+mp[i-2];
		if(mp[i]!=0 && mp[i-1]==0 && mp[i-2]!=0)now_sum=1;
		cnt_max=max(cnt_max,now_sum);
	}
	
	cout << cnt_max << endl;
	return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

void solve()
{
 ll n,ac=0,wa=0,tle=0,re=0;
 cin>>n;
  for(int i=0;i<n;i++){
    string a;
    cin>>a;
    if(a=="AC"){ac++;}
    if(a=="WA"){wa++;}
    if(a=="TLE"){tle++;}
    if(a=="RE"){re++;}
  }
  cout<<"AC"<<" x "<<ac<<endl;
  cout<<"WA"<<" x "<<wa<<endl;
  cout<<"TLE"<<" x "<<tle<<endl;
  cout<<"RE"<<" x "<<re<<endl;
  return ;
}

int main()
{
 ios_base::sync_with_stdio(0);
 cin.tie(0);cout.tie(0);

     solve();

    return 0;
}



Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<
typedef struct {
	int h;
	int w;
}Point;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	string S;
	cin>>S;
	
	int dp[N+2][N+2];
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			dp[i][j]=0;
		}
	}
	
	for(int i=N-1;i>=0;i--){
		for(int j=N-1;j>=0;j--){
			if(S[i]==S[j])dp[i][j]=dp[i+1][j+1]+1;
		}
	}
	
	int ans=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i<j)ans=max(ans,min(dp[i][j],j-i));
		}
	}
	cout<<ans<<endl;
	
	
}
	


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll a, b;
  cin >> a >> b;

  a--;
  b--;

  ll h, w;
  h = 100;
  w = 100;

  vs s;

  string initial;
  rep(i, 100) {
    initial += '#';
  }
  rep(i, 50) {
    s.push_back(initial);
  }
  initial = "";
  rep(i, 100) {
    initial += '.';
  }
  rep(i, 50) {
    s.push_back(initial);
  }

  ll i = 0;
  while (a) {
    s[2 * (i / 100)][i % 100] = '.';
    i += 2;
    a--;
  }

  i = 0;
  while (b) {
    s[51 + 2 * (i / 100)][i % 100] = '#';
    i += 2;
    b--;
  }
  cout << h << " " << w << endl;
  rep(y, 100) {
    cout << s[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

#define ALL(x) x.begin(), x.end()
using namespace std;

typedef vector<vector<int> > G;
const int inf = 1e9;

int n, m;
G graph;
vector<int> ans;

int visited[100100];

void dfs(int u){

    ans.push_back(u);
    visited[u] = 1;

    for(int i=0; i<graph[u].size(); i++){
        int v = graph[u][i];
        if( !( visited[v] ) ){
            return dfs(v);
        }
    }
    return;
}

int main(void){
    cin >> n >> m;
    graph = G(n+100);
    for(int i=0; i<m; i++){

        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);

    }
    
    dfs(1);
    reverse(ALL(ans));
    ans.pop_back();
    dfs(1);

    cout << ans.size() << endl;

    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 10104
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll n; cin >> n;
    vll a(n);
    bool f = true;
    cin >> a[0];
    rep(i, 1, n){
        cin >> a[i];
        if(a[i] > a[i-1]){
            f = false;
        }
    }
    if(f){
        prtl(1000);
        return 0;
    }
    vll v(0); v.emplace_back(a[0]);
    rep(i, 1, n){
        if(a[i] == a[i-1]){
            continue;
        }else{
            v.emplace_back(a[i]);
        }
    }
    ll s = sz(v);
    vll sl(0);
    rep(i, 1, s){
        if(i == s-1){
            if(v[i] > v[i-1]){
                sl.emplace_back(i);
            }
        }else{
            if(v[i] > v[i-1]&&v[i] > v[i+1]){
                sl.emplace_back(i);
            }
        }
    }
    ll t = 0;
    ll sk = 1000;
    rep(i, 0, sz(sl)){
        ll cp = INF;
        rep(j, t, sl[i]){
            chmin(cp, v[j]);
        }
        ll m = sk/cp;
        sk += (v[sl[i]] - cp)*m;
        t = sl[i]+1;
    }   
    prtl(sk);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-6
//#define p 2173412051LL
#define sz 2

using namespace std;

int main() {
	bool ok = true;
	int n, x;
	scanf( "%d", &n );
	while( n-- ) {
		scanf( "%d", &x );
		if( x % 2 == 0 && x % 3 != 0 && x % 5 != 0 )
			ok = false;
	}
	if( ok )
		printf( "APPROVED" );
	else
		printf( "DENIED" );
	return 0;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,h[100111],a,b;
bool check(int x)
{
	LL cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(h[i]<=1ll*x*b)continue;
		cnt+=(h[i]-x*b+a-1)/a;
	}
	return cnt<=x;
}
int main()
{
	get3(n,a,b);a-=b;
	for(int i=1;i<=n;i++)get1(h[i]);
	int l=0,r=1000000000,mid;
	while(l<r-1)
	{
		mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	printendl(r);
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  int a, b;
  cin >> a >> b;
  if(a <= 9 && b <= 9) {
    cout << a*b << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i,n) {
		cin >> a[i];
	}
	int CurrentMoney = 1000;
	rep(i, n - 1) {
		if (a[i] < a[i + 1]) {
			int stocks = CurrentMoney / a[i];
			CurrentMoney += (a[i + 1] - a[i])*stocks;
		}
	}
	print(CurrentMoney);
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<233<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Love) for(int Kanna=0;Kanna<n;Kanna++)cout<<Hashimoto[Kanna]<<(Kanna==Love-1?"\n":" ");
#define FOR(Love,Hashimoto,Kanna) for(int Love=Hashimoto;Love<Kanna;Love++)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n;
pair<pii,int> a[111111];
vector<pair<ll,pii > > edge;
int f[111111];
int F(int a){
	return f[a]==a?a:f[a]=F(f[a]);
}


int I_Love_Hashimoto_Kanna() {
  fastio;
  FOR(i,0,111111)f[i]=i;
  cin>>n;
  FOR(i,0,n){
  	cin>>a[i].first.first>>a[i].first.second;
  	a[i].second=i;
	}
	FOR(tot,0,2){
	  sort(a,a+n);
	  FOR(i,0,n-1){
      edge.push_back({(ll)min(abs(a[i].first.first-a[i+1].first.first),abs(a[i].first.second-a[i+1].first.second)),{a[i].second,a[i+1].second}});
		  swap(a[i].first.first,a[i].first.second);
	  }
	  swap(a[n-1].first.first,a[n-1].first.second);
	}
	SORT(edge);
	ll ans=0;
	FOR(i,0,edge.size()){
		int a,b,c;
		c=edge[i].first;
		a=edge[i].second.first;
		b=edge[i].second.second;
		a=F(a);
		b=F(b);
		if(a==b){
			continue;
		}
		ans+=c;
		f[a]=b;
	}
	cout<<ans<<endl;
	
  return 0;
}



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

using namespace std;


int gcd(int a, int b){
	return b == 0 ? a : gcd(b, a % b);
}

int main(){
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		a[i] = abs(x - tmp);
	}
	sort(a.begin(), a.end());

	int ans = gcd(a[0] , a[1]);

	for(int i = 2; i < n; i++){
		ans = gcd(ans , a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
s=input()
n = 2**(len(s)-1)
ans = 0

if len(s) == 1:
    ans = s
else:
    for i in range(n):
        t = ""
        a = str(bin(i))[2:].zfill(len(s)-1)
        for j in range(len(a)):
            if a[j] == "1":
                t += s[j] + "+"
            else:
                t += s[j]
        t += s[-1]
        ans += eval(t)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
  int x,y,size,m[14][14]={0},max=0,none=0;
  while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
    if(size>=1){
      m[x+2][y+2]++;
      m[x+2][y+1]++;
      m[x+2][y+3]++;
      m[x+1][y+2]++;
      m[x+3][y+2]++;
    }
    if(size>=2){
      m[x+1][y+1]++;
      m[x+1][y+3]++;
      m[x+3][y+1]++;
      m[x+3][y+3]++;
    }
    if(size==3){
      m[x+2][y]++;
      m[x+2][y+4]++;
      m[x][y+2]++;
      m[x+4][y+2]++;
    }
  }
  for(y=0;y<10;y++){
    for(x=0;x<10;x++){
      if(m[x+2][y+2]>max)max=m[x+2][y+2];
      if(!m[x+2][y+2])none++;
    }
  }
  cout<<none<<endl<<max<<endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();
    
    int x;
    cin >> x;
    
    cout << (x == 3 or x == 5 or x == 7 ? "YES" : "NO");
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256