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

int main(){
    long long  N;
    cin >> N;
    long long a[N+1];
    long long b[N];
    long long total = 0;
    for(long long i=0;i<N+1;i++){
        cin >> a[i];
    }
    for(long long i=0;i<N;i++){
        cin >> b[i];
    }

    for(long long i=0;i<N;i++){
        if(b[i]>a[i]){
            long long c = b[i] - a[i];
            total += a[i];
            a[i] = 0;
            if(c>a[i+1]){
                total += a[i+1];
                a[i+1] = 0;
            }else{
                a[i+1] -= c;
                total += c;
            }
        }else{
            a[i] -= b[i];
            total += b[i];
        }
        //cout << total << endl;
    }
    cout << total<< endl;


}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>

using namespace std;

#define MOD 1000000007
#define INF 1050000000

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

	

	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			if (a[i] - a[j] > k) {
				cout << ":(" << endl;
				return 0;
			}
		}
	}


	cout << "Yay!" << endl;













}

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

using namespace std;

int main(){
	int P[3];
	cin >> P[0] >> P[1] >> P[2];

	cout << min(P[0] + P[1], min(P[1] + P[2], P[2] + P[0])) << endl;
	return 0;
}


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

namespace CS.Solve
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var result = tmp[0] + tmp[1] / 2;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<climits> //INT_MIN/MAX
using namespace std;

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

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0,0,1,-1,1,1,-1,-1 };
int dy[8] = { 1,-1,0,0,1,-1,1,-1 };

/* -----  xtimex  Problem: ABC 0 ABCD / Link:  ----- */
/* ------蝠城｡---



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N, M;
ll a[60], b[60], c[60], d[60];
ll ans = 0LL;

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

    cin >> N >> M;
    FOR(i, 0, N) {
        cin >> a[i] >> b[i];
    }
    FOR(i, 0, M) {
        cin >> c[i] >> d[i];
    }

    FOR(i, 0, N) {
        ll m = 1e18; int id;
        FOR(j, 0, M) {
            ll x = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (x < m) {
                m= x;
                id = j;
            }
        }
        cout << id+1 << endl;

    }

    return 0;
    }


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    string S;
    in(S);
    if (S == "ABC") out("ARC");
    else out("ABC");

	return 0;
}


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

int n;

int div(vector<int> x){
	rep(i, n) if(x[i]&1 != 0) return 0;
	rep(i, n) x[i] >>= 1;
	return 1+div(x);
}

int main(void){
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans;
	ans = div(a);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	int n;
	cin>>n;

	vector<int> A(n);
	Cin(A);
	sort(begin(A), end(A));
	
	ll ans = A.back();
	A.pop_back();
	queue<int> q {{A.back(), A.back()}};
	A.pop_back();

	for(;A.size();) {
		ans += q.front();
		q.pop();
		q.push(A.back());
		q.push(A.back());
		A.pop_back();
	}		
	cout<<ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 4776
@inbounds function main()
  h,w,m=parse.(Int,split(readline()))
  hc=Dict{Int,Int}()
  wc=Dict{Int,Int}()
  hw=Set{Tuple{Int,Int}}()
  for i=1:m
    hi,wi=parse.(Int,split(readline()))
    push!(hw,(hi,wi))
    hc[hi]=get(hc,hi,0)+1
    wc[wi]=get(wc,wi,0)+1
  end
  mh=first(findmax(hc))
  mw=first(findmax(wc))
  hs = filter(hc) do (k,v)
    v == mh
  end |> keys
  ws = filter(wc) do (k,v)
    v == mw
  end |> keys
  for i=hs
    for j=ws
      if !((i,j) in hw)
        println(mh+mw)
        return 0
      end
    end
  end
  println(mh+mw-1)
end
main()

Measured memory_bytes: 250060
# import numpy as np
def main():
  N,M =map(int, input().split())
  s,c=[],[]
  for i in range(M):
    si,ci = map(int, input().split())
    s.append(si)
    c.append(ci)
  
  res=['']*N
  for si,ci in zip(s,c):
    if res[si-1]== '':
      res[si-1]=str(ci)	
    elif res[si-1]!= str(ci):
      print(-1)
      exit()

  
  if res[0]=='0':
    if N==1:
      print(0)
      exit()
    else:
      print(-1)
      exit()
  elif res[0]=='':
    res[0]=str(1)
   
  for i in range(N):
    if res[i]=='':
      res[i]=str(0)
  if M==0 and N==1:
    print(0)
    exit()
  print(int("".join(res)))
  
    
if __name__=="__main__":
  main()

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
#define READINTA(X) while((ct=readchar())>='0')(X)=(X)*10+ct-'0';
#define READINTB(X) while((ct=*ci++)>='0')(X)=(X)*10+ct-'0';
using namespace std;

uint16_t d, k;
uint32_t M = 0;
int_fast64_t c, sd = 0, sc = 0;
constexpr int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;

inline char readchar() {
    if(ci-cn==cm){fread_unlocked(cn,1,cm,stdin);ci=cn;}
    return *ci++;
}

int main() {
    READINTA(M);
    while(M--) {
        c = 0;
        if(ci-cn+20>cm) {
            d = readchar() - '0';
            readchar();
            READINTA(c);
        } else {
            d = *ci++ - '0';
            ci++;
            READINTB(c);
        }
        sc += c;
        sd += c * d;
    }
    printf("%lld\n", --sc + --sd / 9);
	return 0;
}

Measured memory_bytes: 256
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

string s, t;
int a, b;

void solution() {
    cin >> s >> t >> a >> b;
    string u;
    cin >> u;
    if (u == s) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b << endl;
    
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 256
from collections import deque
q = deque([1,2,3,4,5,6,7,8,9])
k = int(input())
for i in range(k-1):
  p = q.popleft()
  if p%10 != 0:
    q.append(10*p + p%10 - 1)
  q.append(10*p + p%10)
  if p%10 != 9:
    q.append(10*p + p%10 + 1)
  
    
print(q.popleft())

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

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

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

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

ll T1, T2, A1, A2, B1, B2;

ll solve() {
    ll X = T1 * A1 - T1 * B1;
    ll Y = T2 * A2 - T2 * B2;

    if(X + Y == 0) { return -1; }

    if((X < 0 && Y < 0) || (X > 0 && Y > 0) || Y == 0) { return 0; }

    if(X == 0) { return 1; }

    X = abs(X);
    Y = abs(Y);
    if(X > Y) { return 0; }

    ll ret = X / (Y - X) * 2;
    if(X % (Y - X) != 0) { ret++; }
    return ret;
}

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

    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

    ll ans = solve();
    if(ans == -1) {
        printf("infinity\n");
        return 0;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n+1];
    //int sum = 0;
    for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    }
    long b;
    long ans=0;
    long kill;
    for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 83340
#include <iostream>

using namespace std;

int x;

int main ()
{
	cin>>x;
	int ok=1;

	int x1=int(x%10);
	int x2=int((x/10)%10);
	int x3=int((x/100)%10);

	if(x2==x1 && x2==x3)
	{
		cout<<"Yes";
		ok=0;
	}

	x=10000+x/10;

	x1=int(x%10);
	x2=int((x/10)%10);
	x3=int((x/100)%10);

	if(x2==x1 && x2==x3 && ok!=0)
	{
		cout<<"Yes";
		ok=0;
	}

	if(ok)
		cout<<"No";
	return 0;
}

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

int main(){
    int n, num=3;
    string s;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> s;
        if (s == "Y") {
            num = 4;
        }
    }
    if (num == 3) {
        cout << "Three" << endl;
    }
    else {
        cout << "Four" << endl;
    }
}

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


char a[105];
int main()
{
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    if(a[i]!=a[i-1])
    ans++;
    if(ans==3)cout<<"Three";
    else if(ans==4)cout<<"Four";
    //system("pause");
    return 0;
}  

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())

def div2(x):
    ret = 0
    while x%2==0:
        x /= 2
        ret += 1
    return ret

ret = 0
for a in input().split(" "):
    a = int(a)
    ret += div2(a)

print(ret)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    edge(lint t, lint c) : to(t), cost(c) {
    }
};

// dijkstra
// depend:edge
vector<long long int> dijkstra(vector<vector<edge>> g, int start) {
    using lint = long long int;
    vector<lint> res(g.size(), LLONG_MAX);
    res[start] = 0;
    // first:距離、second:行き先
    priority_queue<pair<lint, lint>, vector<pair<lint, lint>>,
                   greater<pair<lint, lint>>>
        pq;
    pq.push({0, start});
    while (!pq.empty()) {
        lint dist = pq.top().first, now = pq.top().second;
        pq.pop();
        if (res[now] < dist) continue;
        for (int i = 0; i < (int)g[now].size(); i++) {
            edge e = g[now][i];
            if (res[e.to] > res[now] + e.cost) {
                res[e.to] = res[now] + e.cost;
                pq.push(make_pair(res[e.to], e.to));
            }
        }
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    //key[i]の第j-bitが1==i番目の鍵はj番目の宝箱を開けられる
    vector<int> key(m, 0);
    for (int i = 0; i < m; i++) {
        int b;
        cin >> a[i] >> b;
        //キーの作成
        for (int j = 0; j < b; j++) {
            int c;
            cin >> c;
            key[i] += 1 << (c - 1);
        }
    }
    //グラフの作成
    vector<vector<edge>> g((1 << n));
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < m; j++) {
            g[i].push_back(edge(i | key[j], a[j]));
        }
    }
    vector<lint> cost = dijkstra(g, 0);
    if (cost[(1 << n) - 1] == LLONG_MAX) {
        cout << -1 << endl;
    } else {
        cout << cost[(1 << n) - 1] << endl;
    }
}

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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
ll arr[mxn];
ll pre[mxn];
int n, m, k, q;
string s, t;

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    for (int i = 1; i <= n; i++) pre[i] = (pre[i - 1] + arr[i]) % MOD;
    ll ans = 0;
    for (int i = 1; i <= n; i++) (ans += arr[i] * pre[i - 1]) %= MOD;
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 6724
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
p = 10 ** 9 + 7
S = [0] * 2001
D = [0] * 2001
cnt = 0
for i, a in enumerate(A):
  D[a] += 1
  j = a
  r = 0
  while j:
    r += S[j]
    j -= j & -j
  cnt += i - r
  j = a
  while j <= 2000:
    S[j] += 1
    j += j & -j
cnt = cnt * K % p
k = 0
for d in D[::-1]:
  cnt += d * k * K * (K - 1) // 2
  k += d
  cnt %= p
print(cnt)

Measured memory_bytes: 3188
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007


#A
def check(n):
    n = list(map(int,list(str(n))))
    s = 0
    for i in n:
        s += f[i]
    return s == 0
n,k = LI()
d = LI()
f = [0 for i in range(10)]
for i in d:
    f[i] = 1
while 1:
    if check(n):
        print(n)
        quit()
    n += 1
#B

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 3944
import copy
import math

def judge(As,K,C):
    count = 0
    for i in range(len(As)):
        if As[i]%C == 0:
            m = As[i]//C - 1
        else:
            m = As[i]//C
        count += m
    if count <= K:
        return True
    else:
        return False

N, K = list(map(int,input().split()))
As = list(map(int,input().split()))

l = 0
r = max(As)
while(r-l>1):
    mid = (l+r)//2
    if judge(As,K,mid):
        r = mid
    else:
        l = mid
print(r)

Measured memory_bytes: 104020
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

#define     _test int _TC; cin >> _TC; while(_TC--)
#define     CS(x) cout << "Case " << x << ": ";
#define     precision(n) cout << fixed << setprecision(n);
#define     Clear(a, b) memset(a, b, sizeof(a))
#define     sq(x) ((x) * 1LL * (x))
#define     eb emplace_back
#define     all(_n) _n.begin(), _n.end()
#define     rall(_n) _n.rbegin(), _n.rend()
#define     endl "\n"
#define     show(x) cout << x << endl
#define     nl cout << endl
#define     sz(x) int(x.size())
#define     gcd(a, b) __gcd(a, b)
#define     lcm(a, b) (abs((a) * (b)) / gcd(a, b))
#define     parity(a, b) ((a&1) ^ (b&1))
#define     make_unique(x) sort(all((x))); (x).erase(unique(all((x))), (x).end())
#define     IN(a) for(auto &it : a) cin >> it

template <typename T> void print (T t){ for(const auto &it : t) cout << it << '\n'; }
template <typename T> using OS = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // order_of_key find_by_order

const    double Pi = acos(-1.0);
const    int Mod = 1e9 + 7;
const    int Inf = 1 << 30; // INT_MAX = (1LL << 31) -1 // Inf -> 1e9
const    int Maxx = 1e6 + 10;

/************************************[Code Starts Here]************************************/


void _case()
{
	int n, m; cin >> n;
	vector<int> v(n-1); IN(v);
	vector<int> f(n+1);
	for (int i = 0; i < n-1; i++) {
		f[v[i]]++;
	}
	for (int i = 1; i <= n; i++) show(f[i]);
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    _case();
    return 0;
}




Measured memory_bytes: 4772
using System;
using System.Linq;
using System.Collections.Generic;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int[] west = new int[n];
            int[] east = new int[n];
            int min = 10000000;
            int countWest = 0;
            int countEast = 0;

            for (int i = 0; i < n; i++)
            {
                if (s[i] == 'W') countWest++;
                if (s[i] == 'E') countEast++;
                west[i] = countWest;
                east[i] = countEast;
            }
            for (int i = 0; i < n; i++)
            {
                int left = (i - 1 >= 0) ? west[i - 1] : 0;
                int right = east[n - 1] - east[i];
                int count = left + right;
                min = Math.Min(min, count);
            }
            Console.WriteLine(min);
        }
    }
}


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

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < S.size(); j++) {
      if (S[i] == S[j] && i != j) {
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,S[1<<17],vis[1<<17];
long ans;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>S[i];
	for(int i=1;i<N;i++)
	{
		long now=0;
		int L=0,R=N-1;
		while(R>i&&(R%i||L<R))
		{
			ans=max(ans,now+=S[L]+S[R]);
			L+=i;R-=i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 768
S = list(input())
C = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
S.sort()
set(S)
for c in C:
    if c in(S):
        if c == "z":
            print('None')
        continue
    else:
        print(c)
        break

Measured memory_bytes: 4328
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl A(N);
  rep(i, N) cin >> A[i];

  stable_sort(A.begin(), A.end(), greater<ll>());

  ll h = 0, w = 0;

  rep(i, N - 1){
    if(A[i] == A[i + 1]){
      if(h == 0){
	h = A[i];
	i++;
      } else{
	w = A[i];
	break;
      }
    }
  }

  cout << h * w << endl;
  
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
// #define int ll
typedef long double ld;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int N = 300000+10;

int32_t main(){
	fast_io;
	int ans = 0;
	string s;
	cin >> s;
	if(s == "SUN") ans = 7;
	if(s == "MON") ans = 6;
	if(s == "TUE") ans = 5;
	if(s == "WED") ans = 4;
	if(s == "THU") ans = 3;
	if(s == "FRI") ans = 2;
	if(s == "SAT") ans = 1;
	show(ans);
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0) return 1;
	else if(N % 2 == 0) return power(MOD(a * a), N / 2);
	else return MOD(a * power(a, N - 1));
}

int inverse(int a){
	return power(a, p - 2);
}

int fact(int N){
	static vector<int> _fact(1, 1);
	for(int i = _fact.size(); i <= N; i++){
		_fact.push_back(MOD(i * _fact[i - 1]));
	}
	return _fact[N];
}
 
int fact_inv(int N){
	static vector<int> inv(2, 1), _fact_inv(2, 1);
	for(int i = inv.size(); i <= N; i++){
		inv.push_back(MOD(-(p / i) * inv[p % i]));
		_fact_inv.push_back(MOD(inv[i] * _fact_inv[i - 1]));
	}
	return _fact_inv[N];
}
 
int combination(int N, int k){
	if(k < 0 || N < k || N < 0) return 0;
	else return MOD(fact(N) * MOD(fact_inv(N - k) * fact_inv(k)));
}

signed main(){
	int N, i;
	scanf("%lld", &N);
	vector<int> x(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &x[i]);
	}
	int ans = 0;
	vector<int> sum_inv_fact(N + 1, 0);
	for(i = 1; i <= N; i++){
		sum_inv_fact[i] = MOD(sum_inv_fact[i - 1] + inverse(i));
	}
	for(i = 1; i < N; i++){
		ans = MOD(ans + (x[i] - x[i - 1]) * sum_inv_fact[i]);
	}
	printf("%lld\n", MOD(ans * fact(N - 1)));
	return 0;
}

Measured memory_bytes: 2936
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define ALL(v) v.begin(), v.end()
typedef pair<int, int> P;
int cnt[600];
ll dp[601][601];
ll g[601];
int main() {
	int N, K;
	cin >> N >> K;
	g[0] = 1;
	for (int i = 2; i <= 2 * N; i += 2) {
		g[i] = g[i - 2] * (i - 1) % MOD;
	}
	for (int i = 0; i < 2 * N; i++) cnt[i] = 1;
	vector<P> v;
	for (int i = 0; i < K; i++) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		cnt[A] = cnt[B] = 0;
		v.emplace_back(A, B);
	}
	for (int i = 1; i < 2 * N; i++) cnt[i] += cnt[i - 1];
	ll ans = 0;
	for (int len = 2; len <= 2 * N; len +=2) {
		for (int i = 0; i + len <= 2 * N; i++) {
			bool ok = 1;
			for (int j = 0; j < K; j++) {
				bool b1 = (i <= v[j].first && v[j].first < i + len);
				bool b2 = (i <= v[j].second && v[j].second < i + len);
				if (b1 != b2) {
					ok = 0;
					break;
				}
			}
			if (!ok) continue;
			int c1 = cnt[i + len - 1];
			if (i > 0) c1 -= cnt[i - 1];
			ll sum = g[c1];
			for (int j = i + 1; j + 1 < i + len; j +=2) {
				int c2 = cnt[i + len - 1];
				c2 -= cnt[j]; 
				ll t = dp[i][j] * g[c2] % MOD;
				(sum += MOD - t) %= MOD;
			}
			dp[i][i + len - 1] = sum;
			int c3 = cnt[2 * N - 1] - cnt[i + len - 1];
			if (i > 0) c3 += cnt[i - 1];
			(sum *= g[c3]) %= MOD;
			(ans += sum) %= MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3072
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

int main(){
	cin>>n;
	cout<<n*800-n/15*200<<endl;
}

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

int main(){
  ll n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  ll rissoku = min(a,min(b,min(c,min(d,e))));
  ll time ;
  if(n%rissoku==0){
    time = n/rissoku;
  }else{
    time = n/rissoku + (ll)1;
  }
  cout << time + (ll)4 << endl;
  

  return 0;
}

Measured memory_bytes: 256
import bisect

n=int(input())
a,b=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
index1=bisect.bisect_right(l,a)
index2=bisect.bisect_right(l,b)
print(min(index2-index1,index1,n-index2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,X;
	cin>>N>>X;
	vector<int> L(N);
	FDS(i,N)cin>>L[i];
	vector<int> rui(N);
	rui[0]=L[0];
	FDS(i,N-1){rui[i+1]=L[i+1]+rui[i];}
	int ans=0;
	FDS(i,N){
		if(rui[i]<=X) ans++ ;
	}
	cout<<ans+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int j=1;
    int count=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==j)
        {
            j++;
        }
        else
        {
            count++;
        }
    }
    if(count == n)
        cout<<-1<<endl;
    else
        cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1024
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int n, r[100], c[100];
ll dp[101][101];

ll rec(int s, int t) {
    if (s + 1 == t) return 0;
    if (dp[s][t] == 0) {
        dp[s][t] = INT32_MAX;
        for (int i = s + 1; i < t; i++) {
            dp[s][t] = min(dp[s][t], rec(s, i) + rec(i, t) + r[s] * r[i] * c[t - 1]);
        }
    }
    return dp[s][t];
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> r[i] >> c[i];
    cout << rec(0, n) << endl;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#define INF 1000000000000000009
#define MAX_V 301
typedef pair<ll, ll> p;
struct edge{ll to, cost;};
std::vector<std::vector<edge> > G(MAX_V);
priority_queue<p, std::vector<p>, greater<p> > que; //class, inner, compair
vector<ll> d(MAX_V+1, INF);

void dijkstra(int start, ll l){
  d[start]=0;
  que.push(p(0, start));
  while(!que.empty()){
    p p_now=que.top(); que.pop();
    ll v = p_now.second;
    if(d[v]<p_now.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if(e.cost>l) continue;
      ll a = (d[v]!=0&&d[v]%l==0?l:d[v]%l);
      ll b = (e.cost==l?l:e.cost%l);
      ll tmp = (a+b>l?1:0);
      ll nex;
      if(tmp==1) nex = (d[v]/l+(d[v]%l==0?0:1))*l + e.cost;
      else nex = d[v] + e.cost;
      if(d[e.to]>nex){
        d[e.to]=nex;
        que.push(p(d[e.to], e.to));
      }
    }
  }
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll N, M, L, a, b, c;
  std::cin >> N >> M >> L;
  vvl ans = vv(N+1, N+1, INF, ll);
  for(int i=0;i<M;i++){
    std::cin >> a >> b >> c;
    G[a].push_back(edge{b, c});
    G[b].push_back(edge{a, c});
  }
  ll Q;
  std::cin >> Q;

  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++) d[j] = INF;
    dijkstra(i, L);
    for(int j=1;j<=N;j++) {
      if(d[j]>=1000000000000000) ans[i][j] = INF;
      else ans[i][j] = d[j]/L + (d[j]%L==0?-1:0);
    }
  }
  ll s, t;
  for(int i=0;i<Q;i++){
    std::cin >> s >> t;
    std::cout << (ans[s][t]==INF?-1:ans[s][t]) << '\n';
  }
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; long long A[55] = {}; 
	cin >> N; long long S = 0; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; S += A[i]; 
	}
	while(1){
		bool finished = true; 		
		for(int i = 0; i < N; i++){
			long long p = A[i] / N; 
			A[i] = A[i] % N; 			
			for(int j = 0; j < N; j++){
				if(j == i) continue; 
				A[j] += p; 
			}
		}
		for(int i = 0; i < N; i++){
			if(A[i] >= (long long) N) finished = false; 
		}
		if(finished) break; 
	}
	long long T = 0; 
	for(int i = 0; i < N; i++){
		T += A[i]; 
	}
	cout << S - T << endl; 
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define fast_cin ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb push_back
#define all(con) (con).begin(), (con).end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define ff(i,a,b) for(int i=a;i<=b;i++)
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
 
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
 
int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
		res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}
 
const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
 
const int N = 1e5 + 10 ;
 
void solve() {
	int n;
	cin >> n ; 
	int a=0,b=0;
	rp(i,n) {
		int x;
		cin >> x;
		if(x&1) continue; 
		a++; 
		if(x%3==0 || x%5==0) b++; 
	}
	if(a==b) {
		cout << "APPROVED"<<endl;
	}
	else {
		cout << "DENIED"<<endl;
	}
}
 
signed main() {
        fast_cin;
	
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
        #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    	#endif
	
	int tests=1;
	// cin>>tests;
	while(tests--) {
		solve();
	}
 
return 0 ;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    set<int> A;
    rep(i, N){
        int a;
        cin >> a;
        auto it = A.find(a);
        if(it != A.end()){
            A.erase(it);
        }
        else A.insert(a);
    }
    output(A.size());
    return 0;
}

Measured memory_bytes: 4992
/*input
2 1000000000000
500000 1000000
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll is_query = -(1LL << 62);
 
struct Line {
    ll m, b;
    mutable function<const Line *()> succ;
 
    bool operator<(const Line &rhs) const {
        if (rhs.b != is_query) return m > rhs.m; //change it for max
        const Line *s = succ();
        if (!s) return 0;
        ll x = rhs.m;
        return b - s->b > (s->m - m) * x; //change it for max
    }
};
 
struct HullDynamic : public multiset<Line> {
    bool bad(iterator y) {
        auto z = next(y);
        if (y == begin()) {
            if (z == end()) return 0;
            return y->m == z->m && y->b <= z->b;
        }
        auto x = prev(y);
        if (z == end()) return y->m == x->m && y->b <= x->b;
        return (x->b - y->b) * (z->m - y->m) >= (y->b - z->b) * (y->m - x->m);
    }
 
    void insert_line(ll m, ll b) {
        auto y = insert({m, b});
        y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
        if (bad(y)) {
            erase(y);
            return;
        }
        while (next(y) != end() && bad(next(y))) erase(next(y));
        while (y != begin() && bad(prev(y))) erase(prev(y));
    }
 
    ll eval(ll x) {
        auto l = *lower_bound((Line) {x, is_query});
        return l.m * x + l.b;
    }
} hull;

ll h[200005], C, dp[200005];

int main(){
	int n; scanf("%d%lld", &n, &C);
	for(int i = 1; i <= n; i++){
		scanf("%lld", h + i);
	}
	hull.insert_line(-2 * h[1], h[1] * h[1] + C);
	for(int i = 2; i <= n; i++){
		dp[i] = hull.eval(h[i]) + h[i] * h[i];
		hull.insert_line(-2 * h[i], dp[i] + h[i] * h[i] + C);
	}
	printf("%lld\n", dp[n]);
	return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
const int MAXN=3010;
int n;
double sol;
double p[MAXN];
double dp[MAXN][MAXN];
//dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	dp[1][1]=p[1];
	dp[1][0]=1.0-p[1];
	for(int i=2;i<=n;i++){
		for(int j=0;j<=i;j++){
			dp[i][j]=dp[i-1][j]*(1.0-p[i]);
			if(j) dp[i][j]+=dp[i-1][j-1]*p[i];
		}
	}
	for(int i=1;i<=n;i++){
		if(i>n-i){
			sol+=dp[n][i];
		}
	}
	printf("%.10lf",sol);
	return 0;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int i){
	if(i == 1) return false; 
	if(i == 2 || i == 3) return true; 
	else if(i % 6 != 1 && i % 6 != 5) return false; 
	for(int j = 2; j * j <= i; j++){
		if(i % j == 0) return false; 
	}
	return true; 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	vector<int> P; 
	for(int i = 2; i < 1000; i++){
		if(is_prime(i)) P.push_back(i); 
	}
	int A[1000010] = {}; 
	bool exist[1000010] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i];
	int G = A[0]; 
	for(int i = 1; i < N; i++) G = gcd(G, A[i]); 
	if(G > 1){
		cout << "not coprime" << "\n"; 
		return 0; 	
	}
	for(int i = 0; i < N; i++){
		int now = A[i]; 
		for(int p : P){
			if(now % p == 0){
				while(now % p == 0) now /= p; 
				if(exist[p]){
					cout << "setwise coprime" << "\n"; 
					return 0; 
				}
				exist[p] = true; 
			}
		}
		if(now > 1){
			if(exist[now]){
				cout << "setwise coprime" << "\n"; 
				return 0; 
			}
			exist[now] = true; 
		}
	}
	cout << "pairwise coprime" << "\n"; 
}

Measured memory_bytes: 8488
N,K=(int(i) for i in input().split())
v=[int(i) for i in input().split()]

    
maxv=0
for i in range(1,min(K+1,len(v)+1)):
    for j in range(0,i+1):
        l=v[0:j]
        r=v[N-(i-j):]
        my=l
        my.extend(r)
        my=sorted(my)
        for k in range(0,min(K-i,len(my))):
            if my[k]<0:
                my[k]=0
            else:
                break
        if maxv<sum(my):
            maxv=sum(my)
print(maxv)

Measured memory_bytes: 41448
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
const int NUM=100010;
int head,tail;

typedef struct NameTime{
	char name[100];
	int time;
}NT;
NT A[NUM];

void push(NT x){
 	A[tail]=x;
 	tail=(tail+1)%NUM;
}
NT front(){
	NT x=A[head];
	head=(head+1)%NUM;
	return x;
}

int main(){
	int n,q;
	int laps=0,c;
	NT u;
	scanf("%d %d", &n, &q);
	for(int t=1;t<=n;t++){
		scanf("%s",A[t].name);
		scanf("%d",&A[t].time);
	}
	head=1; tail=n+1;

	while(head!=tail){
		u=front();
		c=min(u.time,q);
		u.time=u.time-c;
		laps+=c;
		if(u.time>0)push(u);
		else{
			printf("%s %d\n",u.name, laps);
		}

	}

return 0;
}


Measured memory_bytes: 13316
import sys
N = int(input())
an = map(int, input().split())
f = []
d = []
o = []
for a in an:
    if a % 4 == 0:
        f.append(a)
    elif a % 2 == 0:
        d.append(a)
    else:
        o.append(a)
if len(f) >= len(o):
    print('Yes')
    sys.exit()
if len(f) + 1 == len(o):
    if len(d) == 0:
        print('Yes')
        sys.exit()
print('No')

Measured memory_bytes: 14692
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		long count = 0;
		for (int i = 0; i <= n / r; i++) {
			for (int j = 0; j <= (n - i * r) / g; j++) {
				if ((n - i * r - j * g) % b == 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 1e5 + 7;

vector <int> g[N];
int d[N], mxd[N], par[N];

void dfs(int v, int p, int dep) {
    d[v] = mxd[v] = dep;
    par[v] = p;
    for (int u : g[v])
        if (u != p) {
            dfs(u, v, dep + 1);
            mxd[v] = max(mxd[v], mxd[u]);
        }
}

void solve() {
    int n, tak, aok;
    cin >> n >> tak >> aok;
    loop(i, n - 1) {
        int u, v;
        cin >> u >> v;
        g[v].pb(u);
        g[u].pb(v);
    }
    dfs(aok, 0, 0);
    int l = 0, r = d[tak], vt = tak;
    while (l < r) {
        if (r - l >= 3 || r == mxd[vt]) {
            --r; vt = par[vt];
        }
        else {
            ++r;
            int nv = (g[vt][0] == par[vt] ? g[vt][1] : g[vt][0]);
            for (int u : g[vt])
                if (u != par[vt] && mxd[vt] > mxd[nv])
                    nv = u;
            vt = nv;
        }
        if (l == r)
            break;
        ++l;
    }
    cout << l;
}

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


Measured memory_bytes: 18008
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn f(u: usize, p: usize, d: u32, dist: &mut Vec<u32>, edges: &Vec<Vec<usize>>) {
    if dist[u] < 10000000 {
        return;
    }

    dist[u] = d;

    for v in &edges[u] {
        if *v == p {
            continue;
        }
        f(*v, u, d + 1, dist, edges);
    }
}

fn main() {
    let nuv: Vec<usize> = read_vec();
    let n = nuv[0];
    let u = nuv[1] - 1;
    let v = nuv[2] - 1;
    let mut edges: Vec<Vec<usize>> = vec![vec![]; n];
    for _ in 0..n - 1 {
        let ab: Vec<usize> = read_vec();
        let a = ab[0] - 1;
        let b = ab[1] - 1;
        edges[a].push(b);
        edges[b].push(a);
    }
    let mut taka_dist: Vec<u32> = vec![1000000000; n];
    let mut aoki_dist: Vec<u32> = vec![1000000000; n];

    f(u, 1000000000, 0, &mut taka_dist, &edges);
    f(v, 1000000000, 0, &mut aoki_dist, &edges);

    let mut ans = 0;

    for u in 0..n {
        if taka_dist[u] > aoki_dist[u] {
            continue;
        }
        if aoki_dist[u] > ans {
            ans = aoki_dist[u];
        }
    }

    println!("{}", ans - 1);
}


Measured memory_bytes: 17660
#include <iostream>
#define rep(i) for(i=0;i<5;i++)
using namespace std;
int main(){
  int a[5],i;
  while(1){
    int b[3]={0};
    for(i=0;i<5;i++){
      cin>>a[i];
      if(!a[i])return 0;
      b[a[i]-1]++;
    }
    if(b[0]&&b[1]&&!b[2])rep(i)cout<<((a[i]==1)?1:2)<<endl;
    else if(b[0]&&!b[1]&&b[2])rep(i)cout<<((a[i]==3)?1:2)<<endl;
    else if(!b[0]&&b[1]&&b[2])rep(i)cout<<((a[i]==2)?1:2)<<endl;
    else rep(i)cout<<'3'<<endl;
  }
}

Measured memory_bytes: 3068