akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define RG register
#define MAXN 60

using namespace std;

int n;
double v[MAXN], ans;

int main() {
  	cin >> n;
  	for(RG int i = 1; i <= n; ++i) cin >> v[i];
  	sort(v + 1, v + n + 1);
  	// ans = (v[1] + v[2]) / 2;
    ans = v[1];
  	for(RG int i = 2; i <= n; ++i) ans = (ans + v[i]) / 2;
  	cout << ans << 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";
}

int sum(int n){
	int ret=0;
	rep1(i,n+1)ret+=i;
	return ret;
}

signed main(void) {
	string s;
	cin >> s;
	int n=s.size();
	if(s[n-1]==('s'))s+="es";
	else s+="s";
	print(s);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	cout << N * (N + 1) / 2 << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var hwab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var h = hwab[0];
        var w = hwab[1];
        var a = hwab[2];
        var b = hwab[3];

        var row = new char[w];
        var line = "";
        var output = new StringBuilder();
        for (int i = 0; i < h; ++i)
        {
            if (i == 0)
            {
                for (int j = 0; j < a; ++j)
                {
                    row[j] = '1';
                }
                for (int j = a; j < w; ++j)
                {
                    row[j] = '0';
                }
                line = new string(row);
            }
            else if (i == b)
            {
                for (int j = 0; j < a; ++j)
                {
                    row[j] = '0';
                }
                for (int j = a; j < w; ++j)
                {
                    row[j] = '1';
                }
                line = new string(row);
            }
            output.AppendLine(line);
        }

        Console.WriteLine(output);
    }
}


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

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

  int a[N];
  int counter = 0;

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

  bool flag = true;
  while(flag) {
    for (int i = 0; i < N; i++){
      if (a[i] % 2 == 1) flag = false;
      else a[i] /= 2; 
    }
    if (flag) counter++;
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
n, m, k = list(map(int, input().split()))
ns = list(map(int, input().split()))
ms = list(map(int, input().split()))

nss = [0]
for i, v in enumerate(ns):
    nss.append(nss[i] + ns[i])

mss = [0]
for i, v in enumerate(ms):
    mss.append(mss[i] + ms[i])

mx = 0
j = m
for i in range(n + 1):
    if nss[i] > k:
        break

    while mss[j] > k - nss[i]:
        j -= 1
    
    mx = max(mx, i + j)

print(mx)


Measured memory_bytes: 47552
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

#define MAX_N 500000
#define INF 999999999999999

vector<long long>x[MAX_N];
long long d[MAX_N];
long long n,m,a,b,s,t,q;
queue<long long>Q;
long long sum1[MAX_N];
long long sum2[MAX_N];
long long sum;

void bfs(int P){
	for(int i=0;i<MAX_N;i++){
		d[i]=INF;
	}
	d[P]=0;
	Q.push(P);
	while(!Q.empty()){
		int w=Q.front();Q.pop();
		for(int i=0;i<x[w].size();i++){
			if(d[x[w][i]]==INF){
				d[x[w][i]]=d[w]+1;
				Q.push(x[w][i]);
			}
		}
	}
}

int main(){
	cin>>n>>m>>s>>t;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		x[a].push_back(b);
		x[b].push_back(a);
	}
	bfs(s);
	q=d[t];
	for(int i=1;i<=n;i++){
		if(d[i]<INF){
			sum1[d[i]]++;
		}
	}
	bfs(t);
	for(int i=1;i<=n;i++){
		if(d[i]<INF){
			sum2[d[i]]++;
		}
	}
	for(int i=0;i<q-1;i++){
		sum+=sum1[i]*sum2[q-i-2];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 25792
#include <stdio.h>

int main (void)
{
    char c;
    int i, q = 0;

    for (i = 0; i< 6; i++) {
        scanf("%c", &c);
        if (c == '1') {
            q++;
        }
    }
    scanf("%*s");

    printf("%d\n", q);
}

Measured memory_bytes: 128
import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int A = sc.nextInt();
    sc.close();

    long ans = (H + A - 1) / A;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
a,b,k=map(int,input().split())
ans = []
for i in range(a,a+k):
    if i>b:
        break
    ans.append(i)
for i in range(b,b-k,-1):
    if i<a:
        break
    ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
    print(i)


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

int main(){
  string a, b;
  cin >> a;
  cin >> b;
  for (int i = 0; i < a.size(); i++){
    cout << a[i];
    if (i < b.size()) cout << b[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace
import           Text.Printf


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]

  -- ansPrint n as
  modelAnswer n as

solve k as = solver as
  where
    as' = delete k as


comb x y = (loop1 x y 1) `div` (loop2 y 1)
  where
    loop1 _ 0 n' = n'
    loop1 n r n' = loop1 (n-1) (r-1) (n*n')
    loop2 0 n' = n'
    loop2 n n' = loop2 (n-1) (n*n')

comb' x = if x <= 0 then 0 else comb x 2


solver as = foldl' (\n m -> (+) n $ comb' . length $ m ) 0 $ group as

dpaNumber :: Int -> [Int] -> VU.Vector Int
dpaNumber n as = VU.create $ do
  dp <- VUM.replicate (n+1) 0

  forM_ as $ \a -> do
    VUM.modify dp (\n -> n+1) a

  return dp

ansPrint n as = do
  let as' = VU.fromList $ 0:as
      aNumber = dpaNumber n as
      aComb = VU.map comb' aNumber
      aCombExclude = VU.map (\n -> (comb' $ n-1)) aNumber

  forM_ [1..n] $ \i -> do
    let k = as' VU.! i
        aExclude = aCombExclude VU.! k
        ans = (\(n,m) -> aExclude + VU.sum n + (VU.sum $ VU.tail m))  $ VU.splitAt k aComb
    print ans

modelAnswer n as = do
  let aNumber = dpaNumber n as
      aSumCombination = VU.foldl' (\n m -> n + (comb' m)) 0 $ aNumber


  forM_ as $ \a -> do
    let aNum = aNumber VU.! a
    print $ aSumCombination - ((comb' aNum) - (comb' $ aNum-1))


Measured memory_bytes: 63100
#include <iostream>
#include <stack>
#define N 100005
using namespace std;

int main(){
  bool table[N];
  while(1){
    int n;
    int ans=0;
    cin >> n;
    if(n==0) break;

    int start;
    stack<int> p;
    p.push(0);
    cin >> start;
    if(start){
      table[0]=true;
    }
    else{
      table[0]=false;
      ans++;
    }
    for(int i=1;i<n;i++){
      int next;
      cin >> next;
      if(i%2){
        if(next){
          if(table[i-1]==true){
            table[i]=true;
          }
          else{
            table[i]=true;
	    int temp=p.top();
	    p.pop();
            ans-=i-temp;
	    if(temp==0) p.push(0);
          }
        }
        else{
	  ans++;
          if(table[i-1]==false){
            table[i]=false;
          }
          else{
            table[i]=false;
	    int temp=p.top();
	    p.pop();
            ans+=i-temp;
	    if(temp==0) p.push(0);
          }
        }
      }
      else{
        if(next) table[i]=true;
        else{
	  table[i]=false;
	  ans++;
	}
	if(table[i]!=table[i-1]){
	  p.push(i);
	}
      }
    }
    cout <<  ans << endl;
  }
  return 0;
}

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

#include <boost/functional/hash.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

void dfs(const vector<vector<int64_t>>& adjs, vector<int64_t>& g, int64_t v) {
    for (auto u : adjs[v]) {
        if (g[u] >= 0) {
            continue;
        }

        g[u] = g[v];
        dfs(adjs, g, u);
    }
}

int main() {
    int64_t n, k, l;
    cin >> n >> k >> l;

    vector<vector<int64_t>> road(n), rail(n);
    for (auto i : irange(0L, k)) {
        int64_t p, q;
        cin >> p >> q;
        --p;
        --q;
        road[p].push_back(q);
        road[q].push_back(p);
    }
    for (auto i : irange(0L, l)) {
        int64_t p, q;
        cin >> p >> q;
        --p;
        --q;
        rail[p].push_back(q);
        rail[q].push_back(p);
    }

    vector<int64_t> g1(n, -1), g2(n, -1);
    for (auto i : irange(0L, n)) {
        if (g1[i] < 0) {
            g1[i] = i;
            dfs(road, g1, i);
        }
        if (g2[i] < 0) {
            g2[i] = i;
            dfs(rail, g2, i);
        }
    }

    unordered_map<pair<int64_t, int64_t>, int64_t,
                  boost::hash<std::pair<int64_t, int64_t>>>
            m;
    for (auto i : irange(0L, n)) {
        m[make_pair(g1[i], g2[i])]++;
    }

    const auto* delim = "";
    for (auto i : irange(0L, n)) {
        cout << delim << m[make_pair(g1[i], g2[i])];
        delim = " ";
    }
    cout << endl;
}

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

double mysqrt(double x){
	double l = 0 , r = x ;
	for(int i = 0 ; i < 64 ; i++){
		double m = (l+r)/2.0;
		if(m * m < x){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}


int main(){
	int p,n;
	while(cin >> p >> n , n){
		double sp = mysqrt(p);
		int a1 = 0 , b1 = 1 , a2 = p , b2 = 1;
		
		for(int i = 1 ; i <= n ; i++){
		
			int l = 0 , r = n;
			
			for(int x = 0 ; x < 50 ; x++){
				int m = (l+r+1)/2;
				if( (double)m/i < sp){
					if(__gcd(m,i)==1){
						if(m*b1 > a1*i){
							a1 = m;
							b1 = i;
						}
					}
					l = m;
				}else{
					r = m-1;
				}
			}
	
			l = 0 , r = n;
			for(int x = 0 ; x < 50 ; x++){
				int m = (l+r)/2;
				if( (double)m/i > sp){
					if(__gcd(m,i)==1){
						if(m*b2 < a2*i){
							a2 = m;
							b2 = i;
						}
					}
					r = m;
				}else{
					l = m+1;
				}
			}
			
		}

		cout << a2<< "/" << b2 << " " << a1 << "/" << b1 << endl;
	}
}

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

using namespace std;
typedef long long LL;

#define MAXN 100000
#define MOD 1000000007

int sumdigit(int n) {
    int r = 0;
    while (n) {
        r += n % 10;
        n /= 10;
    }
    return r;
}

int f(int n) {
    int mn = 10000000;
    for (int i = 1; i <= n / 2; i++) {
        int j = n - i;
        mn = min(mn, sumdigit(i) + sumdigit(j));
    }

    return mn;
}

int main(int argc, char** argv) {
#ifdef OJ
    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
#endif
    std::ios::sync_with_stdio(false);

    int N;
    cin >> N;
    cout << f(N) << endl;

    return 0;
}

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


public class Test
{	
    public static void Main()
	{
	    int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        if(nums[0] + nums[1] >= nums[2]) Console.WriteLine("Yes");
        else Console.WriteLine("No");

	}
}

Measured memory_bytes: 13396
url = "https://atcoder.jp/contests/abc089/tasks/abc089_c"
import itertools
import math

def main():
    mojiretu = ('M', 'A', 'R', 'C', 'H')
    dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
    t = input()
    count = 0
    for i in range(int(t)):
        tmp = input()
        if tmp[0] in mojiretu:
            dic[tmp[0]] += 1
    for l in itertools.combinations(mojiretu, 3):
        count += dic[l[0]] * dic[l[1]] * dic[l[2]]
    print(count)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
 
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	int k, n; cin >> k >> n;
	vi v(n); FOR(i, n) cin >> v[i];
	vector<ll> dist;
	dist.PB(0);
	for(int i = 1; i < n; i++){
		dist.PB(v[i]-v[i-1]);
	}

	dist.PB(v[0] + k-v[n-1]);
	FOR(i, n-1) dist.PB(dist[i+1]);
	FOR(i, 2*n) dist[i+1] += dist[i];

	ll ans = 1e9;
	for(int i = n-1; i < 2*n; i++){
		ans = min(ans, dist[i] - dist[i-n+1]);
	}

	cout << ans << '\n';
 
	return 0;
}

Measured memory_bytes: 7280
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

void SolveA()
{
	string s;
	cin >> s;

	const char *ss = s.c_str();

	int bee = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (ss[i] == '1')
		{
			bee++;
		}
	}

	printf("%d\n", bee);
}

void SolveB()
{
	int n;
	scanf("%d", &n);

	vector<int> A;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		A.push_back(tmp);
	}

	int counter = 0;
	bool flagLoop = true;
	while (flagLoop)
	{
		bool flagAllEven = true;
		for (int i = 0; i < n; i++)
		{
			if (A[i] % 2 != 0)
			{
				flagAllEven = false;
				flagLoop = false;
			}
		}
		if (flagAllEven == true)
		{
			for (int i = 0; i < n; i++)
			{
				A[i] /= 2;
			}
			counter++;
		}
	}

	printf("%d\n", counter);
}

int main()
{
	//SolveA();
	SolveB();
}



Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
if m==1:
  a,b=map(int,input().split())
  print(str(a).zfill(6)+str(m).zfill(6));sys.exit()
cities=[None]*m
for i in range(m):
  p,y=map(int,input().split())
  cities[i]=[p,y,i]
cities.sort(key=lambda x:x[1]);cities.sort(key=lambda x:x[0])
i=0
c=1
while True:
  cities[i].append(c)
  c+=1
  if i!=m-1 and cities[i][0]!=cities[i+1][0]:c=1
  elif i==m-1:break
  i+=1
cities.sort(key=lambda x:x[2])
for i in cities:
  print(str(i[0]).zfill(6)+str(i[3]).zfill(6))

Measured memory_bytes: 31004
import kotlin.math.ceil

fun main() {
    val (n, x, t) = nextIntList()
    println(ceil(n.toDouble().div(x)).toInt().times(t))
}
// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)
// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }
// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 36404
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    ll n, k; cin >> n >> k;
    ll ans = 0;
    if(k == 0)
    {
        cout << n * n << endl;
        return;
    }
    for(ll b = k + 1; b <= n; b++)
    {
        ll cnt = max(0LL, b - k);
        ans += n / b * cnt;
        ans += max(0LL, n % b - k + 1);
    }
    cout << ans << endl;
}

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

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

typedef long long ll;
typedef vector<int> vi;            typedef vector<vi> vii;
typedef vector<ll> vl;             typedef vector<vl> vll;
typedef pair<int,int> pi;          typedef pair<pi,int> pii;
typedef pair<ll,ll> pl;            typedef pair<pl,ll> pll;
typedef pair<int,bool> pib;        typedef pair<ll,bool> plb;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define in insert
#define er erase
//user-defined hash table for pairs --------------------------------------------------------------------------------------------------
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

//returns (a^n mod p)---------------------------------------------------------------------------------------------------------------
ll power(ll a,ll n,ll p)
{
	if(n == 0)
	{
		return 1;
	}
	else if(n%2 == 0)
	{
		ll ans = power(a,n/2,p);
		return (ans*ans)%p;
	}
	else 
	{
		ll ans = power(a,n-1,p);
		return (ans*a)%p;
	}
}

//returns (a^-1 mod p)(if p is prime)----------------------------------------------------------------------------------------------
ll inverse(ll a,ll p)
{
   return power(a,p-2,p);
}
//----------------------------------------------------------------------------------------------------------------------------------


void solve()
{
   int n,k;
   cin>>n>>k;
   int a[n];
   for(int i=0;i<n;i++)
   {
   	  cin>>a[i];
   }
   for(int i=k;i<n;i++)
   {
   	  if(a[i-k] >= a[i])
   	  {
   	  	cout<<"No"<<endl;
   	  }
   	  else
   	  {
   	  	cout<<"Yes"<<endl;
   	  }
   }
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef PAVANSAI006
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    ll t = 1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
    
}

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

struct flower{
    int height;
    int bty;
};

ll solve(vector<flower> v,int n){
    ll dp[n+1];
    dp[1] = v[1].bty;
    map<ll,ll> meaningFull;
    meaningFull[v[1].height] = dp[1];
    ll ans = dp[1];
    for(int i=2;i<=n;i++){
        dp[i] = v[i].bty;
        auto it  = meaningFull.lower_bound(v[i].height + 1);
        if(it != meaningFull.begin()){
            it--;
            dp[i] += it->second;
        }
        meaningFull[v[i].height] = dp[i];
        it = meaningFull.upper_bound(v[i].height);
        while(it != meaningFull.end() && it->second <= dp[i]){
            auto temp = it;
            temp++;
            meaningFull.erase(it);
            it = temp;
        }
        ans = max(ans,dp[i]);
    }
    return ans;
}

int main() {
    int n;
    cin>>n;
    vector<flower> v(n+1);
    for(int i=1;i<=n;i++){
        cin>>v[i].height;
    }
    for(int i=1;i<=n;i++){
        cin>>v[i].bty;
    }
    cout<<solve(v,n)<<endl;
}


Measured memory_bytes: 17408
n = input()
head = n[0]
tail = '0' * (len(n) - 1)
m = str(int(head + tail) - 1)
sumn = 0
summ = 0
for i in n:
    sumn += int(i)
for i in m:
    summ += int(i)
print(max(sumn, summ))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using static Exter;
using System.Linq;
#if DEBUG
#else
using console = System.Console;
#endif

public class App
{
    public static void Main(string[] args)
    {
        cout = (readarr[2] / preadarr[0]) * preadarr[1];
    }
}
public static class Exter
{
    public static void rep(int loop,Action<int> act)
    {
        for(int i=0;i<loop;i++)
            act(i);
    }
    public static int ToInt(this string v)=>int.Parse(v);
    public static int Max(params int[] p)=>p.Max();
    public static long Max(params long[] p)=>p.Max();
    public static int Min(params int[] p)=>p.Min();
    public static long Min(params long[] p)=>p.Min();
    public static object cout
    {
        set
        {
            console.Write(value.ToString());
            console.WriteLine();
            
        }
    }
    public static int[] readarr
    {
        get 
        {
            preadarr = console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            return preadarr;
        }
    }
    public static int[] preadarr;
}


#if DEBUG
public static class console
{
    static int cursorLine = 0;
    static readonly string[] cin = new string[]
    {
                "5 100 90 80",
"98",
"40",
"30",
"21",
"80"
    };
    static public string ReadLine()
    { 
        return cin[cursorLine++];
    }
    static public void WriteLine()
    {
        Console.WriteLine();
    }
    static public void WriteLine<T>(T input)
    {
        Console.WriteLine(input);
    }
    static public void Write<T>(T input)
    {
        Console.Write(input);
    }
    static public void WriteLine(string s,params object[] arr)
    {
        Console.WriteLine(s,arr);
    }
}
#endif

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N;  cin >> N;
    vector<double> p(N);
    for(int i=0; i<N; i++) cin >> p[i];

    vector<vector<double>> dp(N, vector<double>(N+1,0));
    dp[0][1] = p[0];  dp[0][0] = 1 - p[0];
    for(int i=1; i<N; i++) for(int j=0; j<=i+1; j++){
        dp[i][j] = (1-p[i])*dp[i-1][j];
        if(j>0) dp[i][j] += p[i]*dp[i-1][j-1];
    }
    
    double ans = 0;
    for(int i=(N+1)/2; i<=N; i++){
        ans += dp[N-1][i];
    }
    cout << setprecision(15) << ans << endl;
}


Measured memory_bytes: 70656
#include <iostream>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    long H[N+1];
    for (int i = 1; i <= N; i++) {
        cin >> H[i];
    }

    int A[M], B[M];
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }

    unordered_map<int,long> maxH;

    for (int i = 0; i < M; i++) {
        int own;
        int counter;

        own = A[i];
        counter = B[i];
        maxH[own] = max(maxH[own], H[counter]);

        counter = A[i];
        own = B[i];
        maxH[own] = max(maxH[own], H[counter]);
    }

    int ans = 0;
    
    for (int i = 1; i <= N; i++) {
        if(maxH[i]<H[i]) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8868
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

//


fn run() {
    input! {
        h: usize,
        w: usize,
        s: [chars; h],
    }
    let mut b = vec![vec!['.'; h + w]; h + w];
    for i in 0..h {
        for j in 0..w {
            b[i + j][j - i + h - 1] = s[i][j];
        }
    }
    let mut row = vec![vec![0; h + w]; h + w];
    let mut col = vec![vec![0; h + w]; h + w];
    for i in 0..(h + w) {
        for j in 0..(h + w) {
            if b[i][j] == '#' {
                row[i][j] = 1;
                col[i][j] = 1;
            }
        }
    }
    for i in 0..(h + w) {
        for j in (0..(h + w - 1)).rev() {
            row[i][j] += row[i][j + 1];
        }
    }
    for i in (0..(h + w - 1)).rev() {
        for j in 0..(h + w) {
            col[i][j] += col[i + 1][j];
        }
    }
    let mut ans = 0u64;
    for i in 0..(h + w) {
        for j in 0..(h + w) {
            if b[i][j] == '.' {
                continue;
            }
            for k in (j + 1)..(h + w) {
                if b[i][k] == '.' {
                    continue;
                }
                let d = k - j;
                if i + d < h + w {
                    ans += row[i + d][j] - row[i + d][k + 1];
                }
                if i >= d {
                    ans += row[i - d][j] - row[i - d][k + 1];
                }
            }
        }
    }
    for j in 0..(h + w) {
        for i in 0..(h + w) {
            if b[i][j] == '.' {
                continue;
            }
            for k in (i + 1)..(h + w) {
                if b[k][j] == '.' {
                    continue;
                }
                let d = k - i;
                if j + d < h + w {
                    ans += col[i + 1][j + d] - col[k][j + d];
                }
                if j >= d {
                    ans += col[i + 1][j - d] - col[k][j - d];
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 12668
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
  int i,t[10],sum1=0,a;
  for(i=0;i<6;i++){
    cin >>t[i];
  }
  a=100;
  for(i=0;i<4;i++){
    if(a>t[i]){
      a=t[i];
    }
    sum1=sum1+t[i];
  }
  sum1=sum1-a;
  a=0;
  for(i=4;i<6;i++){
    if(a<t[i]){
      a=t[i];
    }
  }
  cout << sum1+a << endl;
  return(0);
}



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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

const int inf = 1e9+5;

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

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    forn(i, n) {
        cin >> a[i];
    }
    int ans = inf;
    forn(i, n) {
        int split = a[i];
        vector<int> cur, seg;
        forn(j, n) {
            if(a[j] < split) {
                int m = seg.size();
                sort(seg.begin(), seg.end());
                forn(p, m-k+1) {
                    cur.push_back(seg[p]);
                }
                seg.clear();
            } else {
                seg.push_back(a[j]);
            }
        }
        int m = seg.size();
        sort(seg.begin(), seg.end());
        forn(j, m-k+1) {
            cur.push_back(seg[j]);
        }
        
        sort(cur.begin(), cur.end());
        if((int) cur.size() < q) continue;
        debug() nav(split) nav(cur);
        min_self(ans, cur[q-1]-cur[0]);
    }
    
    cout << ans << endl;
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 384
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,Q = II()
s = str(input())
read = [tuple(map(str, input().split())) for _ in range(Q)]
t,d = map(list, zip(*read))

def is_l_not_delete(i):
    flag = True
    place = i
    for j in range(Q):
        if t[j]==s[place]:
            if d[j]=='L':
                place -= 1
            else:
                place += 1
        if place<0:
            flag = False
            break
        if place>=N:
            break
    return flag

def is_r_delete(i):
    flag = False
    place = i
    for j in range(Q):
        if t[j]==s[place]:
            if d[j]=='L':
                place -= 1
            else:
                place += 1
        if place<0:
            break
        if place>=N:
            flag = True
            break
    return flag

delete = 0

left = -1
right = N
while right-left>1:
    mid = left+(right-left)//2
    if is_l_not_delete(mid):
        right = mid
    else:
        left = mid
delete += right

left = -1
right = N
while right-left>1:
    mid = left+(right-left)//2
    if is_r_delete(mid):
        right = mid
    else:
        left = mid
delete += N-right

print(N-delete)

Measured memory_bytes: 106060
#include <iostream>
#include <queue>

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

    std::priority_queue<int> q;

    for (int i = 0; i < n; i++) {
        int temp;
        std::cin >> temp;
        q.push(temp);
    }

    for (int i = 0; i < m; i++) {
        int temp = q.top() / 2;
        q.pop();
        q.push(temp);
    }

    long long ans = 0;
    while (q.size()) {
        ans += q.top();
        q.pop();
    }

    std::cout << ans << std::endl;
}


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

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


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

int main(){
	int h,w,i,j,count=0;
  	char c[51][51];
  	cin>>h>>w;
  	
  	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>c[i][j];
        }
    }

  	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(c[i][j]=='.'){
              for(int k=i-1;k<=i+1;k++){
				for(int l=j-1;l<=j+1;l++){
					if(c[k][l]=='#'){
                      count++;
                    }
                }
              }
             cout<<count ;
                  	count=0;
            }else{
			cout<<"#";
            }
        }
  			cout<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;




int main() {

	int A = 0;
	int B = 0;
	int C = 0;
	int X = 0;
	int count = 0;
	int chi = 0;
	int chj = 0;
	int chk = 0;
	cin >> A >> B >> C >> X;

	for (int i = 0; i <= A;i++) {
		chi = 500 * i;
		if (chi <= X) {
			for (int j = 0; j <= B; j++) {
				chj = chi + 100 * j;
				if (chj <= X) {
					for (int k = 0; k <= C; k++) {
						chk = chj + 50 * k;
						if (chk == X) {
							count++;
							break;
						}
					}
				}
			}
		}
	}

	cout << count << endl;

	system("pause");
	return 0;
}

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

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

    int a, b, c;
    cin >> a >> b >> c;
    set<int> check = { a, b, c };
    cout << (check.size() == 2 ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int kaijo(int x)
{
    int ans = 1;
    rep(i, 1, x + 1) ans *= i;
    return ans;
}

string n_shin(int x, int n)
{
    string s;
    while (x > 0)
    {
        s += to_string(x % n + 1);
        x /= n;
    }
    while (s.size() < n)
    {
        s += '0';
    }
    s.reserve();
    //cout << s << endl;
    return s;
}

int main()
{
    int n;
    cin >> n;
    vi p(n), q(n);
    rep(i, 0, n) cin >> p[i];
    rep(i, 0, n) cin >> q[i];

    int a, b, sp = 0;
    vi array;
    rep(i, 1, n + 1) array.push_back(i);
    do
    {
        sp++;
        if (array == p)
            a = sp;
        if (array == q)
            b = sp;
    } while (next_permutation(array.begin(), array.end()));
    cout << abs(a - b) << endl;
}


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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll unsigned long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

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

int setwise(int arr[], int n)
{
    int result = arr[0];
    for (int i = 1; i < n; i++)
    {
        result = gcd(arr[i], result);

        if (result == 1)
        {
            return 1;
        }
    }
    return result;
}
int pairwise(int arr[], int n)
{
    int high = 0;
    for (int i = 0; i < n; i++)
        high = max(high, arr[i]);
    int count[high + 1] = {0};
    for (int i = 0; i < n; i++)
        count[arr[i]]++;
    int counter = 0;
    for (int i = high; i >= 1; i--)
    {
        int j = i;
        counter = 0;
        while (j <= high)
        {
            if (count[j] >= 2)
                return j;

            else if (count[j] == 1)
                counter++;
            j += i;
            if (counter == 2)
                return i;
        }
    }
}
void solve()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    if (pairwise(a, n) == 1)
        cout << "pairwise coprime";
    else if (setwise(a, n) == 1)
        cout << "setwise coprime";
    else
        cout << "not coprime";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;



int main() {

    int a, b, c;
    cin >> a >> b >> c;

    int res = a * 100 + b * 10 + c;

    if (res % 4 == 0 ) cout << "YES" << '\n'; else cout << "NO" << '\n';


    return 0;
}

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

          }
          else
               count++;
               continue;
     }




          cout<<"YES";
     return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd (ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}
int main( ) {
    //freopen("C.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x;
    cin >> n >> x;
    vl v(n);
    rep(i, 0, n){
        cin >> v[i];
        v[i]=abs(x-v[i]);
    }
    rep(i, 0, n-1){
        v[i+1]=gcd(v[i],v[i+1]);
    }
    cout << v[n-1] << endl;
    return 0;
}

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

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int k;scanf("%d",&k);
   printf("%d",a[k-1]);
}

Measured memory_bytes: 128
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def f(x,k,ans):
    if x < k:
        if x == 1:
            ans.append(k)
        return
    if x%k == 0:
        while x%k == 0:
            x //= k
        f(x,k,ans)
    else:
        f(x%k,k,ans)
    return
def divide(x):
    div=[]
    for check in range(1,int(x**0.5)+1):
        if(x%check==0):
            div.append(check)
            div.append(x//check)
    for check in range(1,int((x+1)**0.5)+1):
        if((x+1)%check==0):
            div.append(check)
            div.append((x+1)//check)
    div = list(set(div))
    div.sort()
    return div
def main():
    ans = []
    n = inp()
    Divide = divide(n-1)
    for e in Divide:
        if e == 1:
            continue
        f(n,e,ans)
    print(len(ans))
if __name__ == "__main__":
    main()

Measured memory_bytes: 64980
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N;
ll H[100001], DP[100001];
ll Calc(int turn){
  if (turn == 0) return DP[0] = 0;
  if (DP[turn] != -1) return DP[turn];

  ll ans = 1e16;
  for (int i = 1; i <= 2; i++){
    if (turn - i >= 0){
      ans = min(ans, Calc(turn - i) + abs(H[turn] - H[turn - i]));
    }
  }
  return DP[turn] = ans;
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> H[i];
  fill(DP, DP + N, -1);
  cout << Calc(N - 1) << endl;

  return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    int n,a;
    bool distinct = true;
    map<int,int> m;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>a;
        if(m[a])
        {
            distinct=false;
            cout<<"NO\n";
            return 0;
        }
        else m[a]=1;
    }
    cout<<"YES\n";
    
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
const int maxn=200100;

vector<int>v[maxn];
int n;

int dfs(int x,int fa)
{
	int ans=0;
	for(int i=0;i<v[x].size();i++)
	{
		int y=v[x][i];
		if(y==fa)continue;
		ans^=(dfs(y,x)+1);
	}
	return ans;
}

int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	if(dfs(1,0))cout<<"Alice";
	else cout<<"Bob";
}

Measured memory_bytes: 14336
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

b2=[]
b2.append(0)
for i in range(1,m+1):
  b2.append(b2[i-1]+b[i-1])
a.insert(0,0)
cnt=0
a_sum=0
for i in range(n+1):
  j=m
  a_sum+=a[i]
  while True:
    if k>=a_sum+b2[j]:
      cnt=max(cnt,i+j)
      m=j
      break
    j-=1
    if j <0:
      break
print(cnt)

Measured memory_bytes: 40696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, K, length = 0;
  	cin >> N >> K;
  
  	for(int i = 0; i < N; i++){
    	int x; 
      	cin >> x;
      	if(x < K - x)
          	length += 2 * x;
      	else
          	length += 2 * (K - x);
    }
  	cout << length << endl;
}

Measured memory_bytes: 256
func readInt () -> Int {
    return Int(readLine()!)!
}

func readInts () -> [Int] {
    return readLine()!.split(separator: " ").map{Int($0)!}
}

func readStrings () -> [String] {
    return readLine()!.split(separator: " ").map{String($0)}
}

func main() {
    let x = readInt()
    // dp table of x and k
    // x 1~179, k 3~360
    var k: Int?
    for i in 1...360 {
        if x * i % 360 == 0 {
            k = i
            break
        } else {
            k = nil
        }
    }
    print(k!)
}

main()


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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;
int A[222222];

int L[222222],R[222222];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    stack<int>st;

    for(int i=0;i<N;i++){
        while(st.size()&&A[st.top()]>=A[i])st.pop();
        if(st.size())L[i]=st.top();
        else L[i]=-1;
        st.push(i);
    }

    st=stack<int>();
    for(int i=N-1;i>=0;i--){
        while(st.size()&&A[st.top()]>A[i])st.pop();
        if(st.size())R[i]=st.top();
        else R[i]=N;
        st.push(i);
    }

    int ans=0;
    for(int i=0;i<N;i++){
        ans+=A[i]*(i-L[i])*(R[i]-i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528