akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    ll N, M; cin >> N >> M;
    ll fact[100010];
    fact[0] = 1;
    for(int i = 1; i < 100010; i++) fact[i] = (fact[i - 1] * i) % MOD;
    cin >> N >> M;
    if(abs(N - M) <= 1) cout << (fact[N] * fact[M] * (N == M ? 2 : 1)) % MOD << endl;
    else COUT(0);
}

Measured memory_bytes: 1024
#include "stdio.h"
#include "queue"
#include "utility"
#include "climits"

using namespace std;

typedef pair<int, int>P;

int H, W, N;
char field[1001][1001];
int dis[1001][1001];
P target[10];
P start;
P Now;
P dir[4] = { make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1) };
queue<P>Q;
int ans;

int main() {
	scanf("%d %d %d", &H, &W, &N);
	for (int i = 0; i < H; i++) {
		scanf("%s", field[i]);
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (field[i][j] >= '1'&&field[i][j] <= '9') {
				target[field[i][j] - '0'].first = i;
				target[field[i][j] - '0'].second = j;
			}
			if (field[i][j] == 'S') {
				target[0].first = i;
				target[0].second = j;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W; k++) {
				dis[j][k] = INT_MAX;
			}
		}
		dis[target[i].first][target[i].second] = 0;
		Q.push(target[i]);
		while (!Q.empty()) {
			Now = Q.front();
			for (int j = 0; j < 4; j++) {
				if (Now.first + dir[j].first >= 0 && Now.first + dir[j].first < H&&Now.second + dir[j].second >= 0 && Now.second + dir[j].second < W) {
					if (field[Now.first + dir[j].first][Now.second + dir[j].second] != 'X') {
						if (dis[Now.first][Now.second] + 1 < dis[Now.first + dir[j].first][Now.second + dir[j].second]) {
							Q.push(make_pair(Now.first + dir[j].first, Now.second + dir[j].second));
							dis[Now.first + dir[j].first][Now.second + dir[j].second] = dis[Now.first][Now.second] + 1;
						}
					}
				}
			}
			Q.pop();
		}
		ans += dis[target[i + 1].first][target[i + 1].second];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 7592
//https://atcoder.jp/contests/dp/tasks/dp_d
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

#define f(i,a,b) for(int i = a;i<b;i++)
#define rep(i,a,b) for(int i = a;i<=b;i++)
#define fd(i,a,b) for(int i = a;i>b;i--)
#define repd(i,a,b) for(int i = a;i>=b;i--)

#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define pb push_back
#define sz(x) (int) (x).size()
#define all(x) x.begin(),x.end()
using namespace std;
const int mod = 1000000007;
const int maxn = 200000;
int n,w;
vector<int> wt(101),v(101);
ll dp[101][100001];
ll knapsack(int i, int w){
    if(i==n) return 0;
    if(dp[i][w]!=-1) return dp[i][w];
    ll a1 = 0,a2 = 0;
    if(wt[i]<=w)
        a1 = v[i] + knapsack(i+1,w-wt[i]);
    a2 = knapsack(i+1,w);
    return dp[i][w] = max(a1,a2);
}
int main(){
    cin>>n>>w;
    f(i,0,n) cin>>wt[i]>>v[i];
    memset(dp,-1,sizeof(dp));
    cout<<knapsack(0,w)<<endl;
}

Measured memory_bytes: 82500
use std::io::stdin;
use std::collections::HashMap;

#[allow(dead_code)]
fn input_ints() -> Vec<i32> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => Vec::<i32>::new(),
    }
}

#[allow(dead_code)]
fn input_strs() -> Vec<String> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.to_string()).collect(),
        Err(_) => Vec::<String>::new(),
    }
}

#[allow(dead_code)]
struct UnionFindTree {
    par: Vec<usize>,
    rank: Vec<i32>,
}

impl UnionFindTree {
    fn new(n: usize) -> UnionFindTree {
        UnionFindTree {
            par: (0..n).collect(),
            rank: vec![0; n],
        }
    }

    fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let refx = self.par[x];
            self.par[x] = self.root(refx);
            self.par[x]
        }
    }

    #[allow(dead_code)]
    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    fn unite(&mut self, x: usize, y: usize) {
        let x = self.root(x);
        let y = self.root(y);

        if x == y {
            return;
        }

        if self.rank[x] < self.rank[y] {
            self.par[x] = y;
        } else {
            self.par[y] = x;
            if self.rank[x] == self.rank[y] {
                self.rank[x] += 1;
            }
        }
    }
}

#[allow(dead_code)]
fn show_vec<T: std::fmt::Display>(v: Vec<T>) {
    if v.len() == 0 {
        return;
    }

    print!("{}",v[0]);

    if v.len() == 1 {
        return;
    }

    for i in 1..v.len() {
        print!(" {}", v[i]);
    }
    println!("");
}

#[allow(unused_variables)]
fn solve() {
    let inputs = input_ints();
    let n = inputs[0] as usize;
    let k = inputs[1] as usize;
    let l = inputs[2] as usize;

    let mut road_tree = UnionFindTree::new(n);
    let mut rail_tree = UnionFindTree::new(n);

    for i in 0..k {
        let connects = input_ints();
        road_tree.unite(connects[0] as usize - 1, connects[1] as usize - 1);
    }

    for i in 0..l {
        let connects = input_ints();
        rail_tree.unite(connects[0] as usize - 1, connects[1] as usize - 1);
    }

    let mut h = HashMap::new();

    for i in 0..n {
        let p = (road_tree.root(i), rail_tree.root(i));
        let val = h.entry(p).or_insert(0);
        *val += 1;
        // match h.get(&p) { 
        //     Some(cnt) => *cnt += 1,
        //     None => h.insert(&p, 0),
        // }
    }

    for i in 0..n {
        let p = (road_tree.root(i), rail_tree.root(i));
        print!("{} ",h.get(&p).unwrap());
    }

    println!("");
}

fn main() {
    solve();
}



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

using lli = long long int;

struct Mod {
  static constexpr lli M = 1000000007;
  lli n;
  Mod(): n(0) {}
  Mod(lli m): n(m) {
    if (m > M)
      n = m % M;
    else if (m < 0)
      n = (m % M + M) % M;
  }
  explicit operator lli() const { return n; }

  Mod& operator+=(const Mod& a) {
    n = (n + a.n) % M;
    return *this;
  }
  Mod& operator-=(const Mod& a) {
    n = (n + M - a.n) % M;
    return *this;
  }
  Mod& operator*=(const Mod& a) {
    n = (n * a.n) % M;
    return *this;
  }
  Mod operator+(const Mod& a) const {
    Mod res = *this;
    return res += a;
  }
  Mod operator-(const Mod& a) const {
    Mod res = *this;
    return res -= a;
  }
  Mod operator*(const Mod& a) const {
    Mod res = *this;
    return res *= a;
  }
};


int main() {
  int N; cin >> N;
  Mod a(1), b(1), c(1);
  for (int i = 0; i < N; i++) {
    a *= 10;
    b *= 9;
    c *= 8;
  }
  Mod r(a - b*Mod(2) + c);
  cout << r.n << endl;

  return 0;
}


Measured memory_bytes: 3628
input = gets.strip.split(" ")

n,q,s = input[0].to_i,input[1].to_i,0
process = Hash.new

n.times do
  input = gets.strip.split(" ")
  name,time = input[0],input[1].to_i
  process[name] = time
end

list = process.dup

while list.empty? == false
  tmp = list.first
  if (tmp[1] - q) > 0
    list.delete(tmp[0])
    list[tmp[0]] = tmp[1] - q
    s += q
  else
    list.delete(tmp[0])
    s += tmp[1]
    name,time = tmp[0],s
    puts "#{name} #{time}"
  end
end

Measured memory_bytes: 21176
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
  a_min = heapq.heappop(a)
  heapq.heappush(a,(-1)*(-a_min // 2))
print(-sum(a))

Measured memory_bytes: 72216
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]


N = int(input())
V = list(map(int, input().split()))

V.sort()
tmp = V[0]
for i in range(1,N):
    tmp = (tmp + V[i])/2

print(tmp)

Measured memory_bytes: 63980
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) (((a)+(b)-1)/(b))
#define all(x) x.begin(), x.end()
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define dbg(msg, var) cerr << msg << " " << var << endl;

using namespace std;

const int MAX = 100010;
const int MOD = 123456789;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// End Template //

int main()
{sws;

    int n, a, b;
    cin >> n;
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a==b) sum++;
        else sum=0;

        if(sum==3){
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int B[150];

void solve() {
    //cout.precision(10);
    cin >> N;
    for(int i = 1; i <= N - 1; i++) cin >> B[i];
    B[0] = 1e9;
    B[N] = 1e9;
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        ans += min(B[i-1], B[i]);
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
k, l, r = gets.split.map &:to_i
$p, $e, $t = $<.map &:to_f

def f(k, l, r)
	h = (l + r) / 2
	if k == 0
		return (h - $t).abs <= $e ? 1 : 0
	end

	return 1 if $t - $e <= l && r <= $t + $e
	return 0 if r < $t - $e || $t + $e < l

	if h < $t
		(1-$p) * f(k-1, h, r) + $p * f(k-1, l, h)
	else
		(1-$p) * f(k-1, l, h) + $p * f(k-1, h, r)
	end
end

puts "%.6f" % f(k, l.to_f, r.to_f)

Measured memory_bytes: 6148
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

int n, k;
vector < vector<int> > g;
vector<int> mt;
vector<char> used;

bool try_kuhn(int v) {
	if (used[v])  return false;
	used[v] = true;
	for (size_t i = 0; i < g[v].size(); ++i) {
		int to = g[v][i];
		if (mt[to] == -1 || try_kuhn(mt[to])) {
			mt[to] = v;
			return true;
		}
	}
	return false;
}
int main()
{
#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);

	cin >> n;
	k = n;
	vector<pair<int, int>> a, b;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		a.push_back({ x,y });
	}
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		b.push_back({ x,y });
	}

	g.resize(n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (b[j].first > a[i].first && b[j].second > a[i].second)
			{
				g[i].push_back(j);
			}
		}
	}

	mt.assign(k, -1);
	for (int v = 0; v < n; ++v) {
		used.assign(n, false);
		try_kuhn(v);
	}

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (mt[i] >= 0)
			ans++;
	}


	cout << ans;


	return 0;
}

Measured memory_bytes: 256
h , w , k = map(int,input().split())
ans = []
cake = []
cou = 0
for i in range(h):
    cake.append(list(input()))
fla = 0
for i in range(h):
    if cake[i].count("#") == 0:
        if i == 0:
            fla = 1
            ans.append([]) 
        elif i != 0:
            if fla == 0:
                ans.append(ans[i-1])
            elif fla == 1:
                ans.append([])
    else:
        cou += 1
        p = 0
        kar = []
        for j in range(w):
            if cake[i][j] == "#":
                if p == 0:
                    p = 1
                elif p != 0:
                    cou += 1
            kar.append(cou)
        ans.append(kar)
        if fla == 1:
            fla = 0
            tyu = 0
            while True:
                if ans[tyu] == []:
                    ans[tyu] = kar
                else:
                   break
                tyu += 1
for i in range(h):
    print(*ans[i])

Measured memory_bytes: 8272
import heapq


def abc151d_maze_master():
    h, w = map(int, input().split())
    s = []
    max_val = 0
    for i in range(h):
        s.append(input())
    for hi in range(h):
        for wi in range(w):
            if s[hi][wi] == '#': continue
            flg = [[-1] * w for _ in range(h)]
            flg[hi][wi] = 0
            q = [(0, hi, wi)]
            heapq.heapify(q)
            while len(q) > 0:
                d, hj, wj = heapq.heappop(q)
                for dh, dw in zip([0, 0, 1, -1], [1, -1, 0, 0]):
                    if 0 <= hj + dh < h and 0 <= wj + dw < w and s[hj + dh][wj + dw] != '#' and \
                            (flg[hj + dh][wj + dw] == -1 or flg[hj + dh][wj + dw] > flg[hj][wj] + 1):
                        heapq.heappush(q, (d + 1, hj + dh, wj + dw))
                        flg[hj + dh][wj + dw] = flg[hj][wj] + 1
                # print(q)
            max_val = max(max_val, max([max(v) for v in flg]))
    print(max_val)


abc151d_maze_master()

Measured memory_bytes: 9216
#include <iostream>
#include <stack>
#include <unordered_set>
using namespace std;

int main(int argc, const char * argv[]) {
    int N,M;
    cin>>N>>M;
    
    unordered_set<stack<int>*> stcGrp;
    
    stack<int> **grps=new stack<int>*[N];
    for(int i=0;i<N;++i){
        grps[i]=NULL;
    }
    int max=1;
    for(int i=0;i<M;++i){
        int a1,b1;
        cin>>a1>>b1;
        --a1;
        --b1;
        stack<int> *tGrp;
        if(grps[a1]==NULL){
            if(grps[b1]==NULL){
                tGrp=new stack<int>();
                stcGrp.insert(tGrp);
                tGrp->push(a1);
                tGrp->push(b1);
                grps[a1]=tGrp;
                grps[b1]=tGrp;
            }else{
                tGrp=grps[b1];
                grps[a1]=tGrp;
                tGrp->push(a1);
            }
        }else{
            if(grps[b1]==NULL){
                tGrp=grps[a1];
                grps[b1]=tGrp;
                tGrp->push(b1);
            }else if(grps[b1]!=grps[a1]){
                stack<int> *delGrp;
                if(grps[b1]->size()<grps[a1]->size()){
                    delGrp=grps[b1];
                    tGrp=grps[a1];
                }else{
                    delGrp=grps[a1];
                    tGrp=grps[b1];
                }
                while(!delGrp->empty()){
                    int idx=delGrp->top();
                    delGrp->pop();
                    tGrp->push(idx);
                    grps[idx]=tGrp;
                }
                stcGrp.erase(delGrp);
                delete delGrp;
            }else{
                continue;
            }
        }
        if(max<tGrp->size()){
            max=(int)tGrp->size();
        }
    }
    cout<<max<<endl;
    for(unordered_set<stack<int>*>::iterator itr=stcGrp.begin(),end=stcGrp.end();itr!=end;++itr){
        delete *itr;
    }
    delete[] grps;
    return 0;
}


Measured memory_bytes: 164292
import Data.List
import Control.Monad

main = do
  n <- readLn :: IO Int
  s <- replicateM n getLine
  m <- readLn :: IO Int
  t <- replicateM m getLine
  let ss = map (\x -> (head x, length x)) . group . sort $ s
      tt = map (\x -> (head x, length x)) . group . sort $ t
      point = [0] ++ map (check tt) ss
  print $ maximum point

check :: [(String, Int)] -> (String, Int) -> Int
check [] (s, i) = i
check ((t, j):xx) (s, i) =
  if s == t
    then i - j
    else check xx (s, i)


Measured memory_bytes: 636
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>

using namespace std;
using ll = long long int;


int main(void){
  
  int n, k;
  cin>>n>>k;

  vector<int> p(n);
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    p[i] = x;
  }

  vector<double> pr(n);
  for(int i=0;i<n;i++){
    double x = 0;
    for(int j=1;j<=p[i];j++){
      x += (double)j/(double)p[i];
    }
    pr[i] = x;
  //  cout<<x<<" ";
  }
 // cout<<endl;
  double max = 0;

  for(int i=0;i<k;i++){
    max += pr[i];
  }
  double calc = max;
 // cout<<"calc:"<<calc<<endl;

  for(int i=k;i<n;i++){
    calc = calc + pr[i] - pr[i-k];
    //cout<<<<endl;
    if(calc > max) max = calc; 
  }
  cout<<setprecision(10)<<max<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

double f(int t, int x) {
  return (double)t - ((double)x * 0.006);
}

int main() {
  int n;
  cin >> n;
  int t, a;
  cin >> t >> a;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  vector<double> avet(n);
  rep(i, n) {
    avet[i] = f(t, h[i]); 
  }

  double p = 1000000000;
  int index = 0;
  rep(i, n) {
    double tmp = abs(avet[i] - a);
    if(p > tmp) {
      p = tmp;
      index = i;
    }
  }
  index++;
  cout << index << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstdlib> 
using namespace std;
int a[100005];
int main(){
	int n,ans;
	cin>>n;
	ans=n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int s=1;
	for(int i=1;i<n;i++){
		if(a[i]==a[i-1]){
			s++;
		}else{
			ans-=s/2*2;
			s=1;
		}
	}
	ans-=s/2*2;
	s=1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
def solve():
    from sys import stdin
    f_i = stdin
    
    n = int(f_i.readline())
    
    phrase = [0] * 394
    for i in range(n):
        s, l, p = map(int, f_i.readline().split())
        for i in range(s, l + 1):
            if p > phrase[i]:
                phrase[i] = p

    dp = [0] * 394
    for pl, p in enumerate(phrase[1:], start=1):
        if p:
            for k, t in enumerate(zip(dp, dp[pl:]), start=pl):
                dp_j, dp_k = t
                if dp_j + p > dp_k:
                    dp[k] = dp_j + p
    
    ans = []
    m = int(f_i.readline())
    for i in range(m):
        w = int(f_i.readline())
        if dp[w]:
            ans.append(str(dp[w]))
        else:
            print(-1)
            break
    else:
        print('\n'.join(ans))

solve()


Measured memory_bytes: 5636
#include <stdio.h>
#include <math.h>
 
int main(void){
	int a;
	int i,j,k;
	int max = 1;

	scanf("%d",&a);

	for(i = 2;i <= a;i++){
		for(j = 2;j < a;j++){
			k = pow(i,j);
			if(k <= a &&max < k)max = k;
			if(k > a)break;
		}
	}
	printf("%d\n",max);
	return 0;

}

Measured memory_bytes: 512
#include<stdio.h>
#define N 100
int main(){
  int a[N][N],b[N],c[N];
  int n,m;
  scanf("%d %d",&n,&m);

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

  for(int i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      c[i]+=a[i][j]*b[j];
    }
  }

  for(int i=0;i<n;i++){
    printf("%d\n",c[i]);
  }

}



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

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (k > 0)
	{
		if (c <= b) {
			c *= 2;
			k--;
		}
		else if(b <= a){
			b *= 2;
			k--;
		}
		else {
			c *= 2;
			k--;
		}
	}

	if (a < b && b < c) {
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, A, B, C, t;
int dp[128][128];

int main(){
  scanf("%d%d%d", &N, &A, &B);
  scanf("%d", &C);
  vi c;
  rep(i, N){
    scanf("%d", &t);
    c.PB(t);
  }

  sort(c.begin(), c.end(), greater<int>());

  int sum = A, cal = C;
  int res = C/A;
  rep(i, N){
    sum += B;
    cal += c[i];
    res = max(res, cal/sum);
  }

  printf("%d\n", res);
  return 0;
}

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

bool is_square(int x) {
    int i;
    bool ans = false;
    for(i = 1; i <= sqrt(x); i++) {
        if (i*i == x) {
            ans = true;
        }
    }
    return ans;
}

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

    int tmp = stoi(to_string(a) + to_string(b));

    string ans = "No";
    if (is_square(tmp)) {
        ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;

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

int main() {
	int A, B, C, D, X, Y;
	cin >> A >> B >> C >> D;
	X = abs(C - A), Y = abs(D - B);
	cout << X + Y - GCD(X, Y);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<string> v(n);
  for(int i; i < n; i++)
    cin >> v.at(i);
  
  int j = 0;
  while(j < n - 1){
    if((v.at(j)).at((v.at(j)).size() - 1) != ((v.at(j + 1)).at(0))){
      break;
    }
    j++;
  }
  
  if(j < n - 1)
    cout << "No" << endl;
  else{
    int k = 0;
    int l = 1;
    
    while(k < n - 1){
      while(l < n){
        
        if(v.at(k) != v.at(l))
          l++;
        else
          break;
      }
        
      if(l != n){
        cout << "No" << endl;
        break;
      }
      
      k++;
      l = k + 1;
    }
    
    if(k == n - 1)
      cout << "Yes" << endl;
  }
}
      
        

Measured memory_bytes: 256
"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf-8"));

function main(input) {
  const date = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
  input = input.trim().split("\n")[0];
  let result = 0;
  switch (input) {
    case "SUN":
      result = 7;
      break;
    case "MON":
      result = 6;
      break;
    case "TUE":
      result = 5;
      break;
    case "WED":
      result = 4;
      break;
    case "THU":
      result = 3;
      break;
    case "FRI":
      result = 2;
      break;
    case "SAT":
      result = 1;
      break;
  }
  console.log(result);
}


Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

#include<vector>

class Combination{
    long long int maxn;
    long long int mod;
    std::vector<long long int> factorial;
    std::vector<long long int> inverse;

    public:

    Combination(long long int n,long long int m):maxn(n),mod(m){
        factorial.push_back(1);
        inverse.push_back(1);

        for(long long int i = 1; i <= n; i++){
            factorial.push_back((factorial.back()*i)%mod);
            inverse.push_back([&](long long int x,long long int n) -> long long int{
                long long int ret = 1;
                while(n > 0){
                    if(n&1)ret = (ret*x)%mod;
                    x = (x*x)%mod;
                    n >>= 1;
                }
                return ret;
            }(factorial.back(),mod-2));
        }
    }

    long long int getFactorial(int idx){
        if(idx > maxn || idx < 0)return -1;
        return factorial[idx];
    }

    long long int getInverse(int idx){
        if(idx > maxn || idx < 0)return -1;
        return inverse[idx];
    }

    long long int comb(long long int n,long long int r){
        return (((factorial[n]*inverse[n-r])%mod)*inverse[r])%mod;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,a,b,c;
    cin >> n >> a >> b >> c;

    ll base = a+b;

    Combination cb(2*n+1,MOD);

    ll ans = 0;

    for(int i = 0; i < n; i++){
        ll t = (ll)i;
        ll ap1 = (a*mypow(base,MOD-2))%MOD;
        ap1 = mypow(ap1,n);
        ll bp1 = (b*mypow(base,MOD-2))%MOD;
        bp1 = mypow(bp1,t);
        ll ap2 = (a*mypow(base,MOD-2))%MOD;
        ap2 = mypow(ap2,t);
        ll bp2 = (b*mypow(base,MOD-2))%MOD;
        bp2 = mypow(bp2,n);
        ll x = (cb.comb(t+n-1,n-1)*((ap1*bp1)%MOD + (ap2*bp2)%MOD))%MOD;
        ans += (((((x * (t + n))%MOD) * 100)%MOD)*mypow(100-c,MOD-2))%MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ex = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'o') ex++;
  }
  cout << 700 + 100 * ex << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// a^n mod を計算する
// O(logn)
ll modpow(ll a, ll n, ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    ll ans=0;
    rep(d,61){
        ll tmp=modpow(2,d);
        ll c0=0,c1=0;
        rep(i,n){
            if(a[i] & 1LL<<d) c1++;
            else c0++;
        }
        //cout<<d<<" "<<c0<<" "<<c1<<endl;
        tmp=(tmp*c1)%MOD;
        tmp=(tmp*c0)%MOD;
        ans=(ans+tmp)%MOD;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,i;
	cin>>n;
	vector<ll> a(n);
	for(i=0;i<n;i++) cin>>a[i];
	ll f=0;
	for(i=0;i<n;i++)
	{
	    if(a[i]%2 == 0)
	    {
	        if(!((a[i]%3 == 0)|| (a[i]%5 == 0))) {f = 1;break;}
	    }
	}
	if(f==1) cout<<"DENIED\n";
	else cout<<"APPROVED\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

string cor = "CODEFESTIVAL2016";

int main() {
  string str;
  cin >> str;
  int res = 0;
  for (int i = 0; i < str.size(); ++i) {
	if (str[i] != cor[i]) ++res;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
//Shubham Vijayvargiya

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define sz(a) (int)(a.size())
#define set(a,b) memset(a,b,sizeof(a))
#define let(x,a) __typeof(a) x(a)
#define rep(i, begin, end) for (ll i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) (v).begin(),(v).end()
#define sll(x) { scanf("%lld",&x); }
#define si(x) { scanf("%d",&x); }
#define slf(x) { scanf("%lf",&x); }
#define pll(x) { printf("%lld\n",x); }
#define pi(x) { printf("%d\n",x); }
#define tcases() long long testcases; cin>>testcases ; while(testcases--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << std::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 <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<long long,long long> pll;
typedef vector<long long> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;

const ll mod=1000000007;
//-----------------------------------------------------------------------------------------------------------------------------------------------//

ll a[100009];

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

	ll n,s=0;
	sll(n);
	rep(i,0,n){
		sll(a[i]);
		s+=a[i];
	}
	sort(a,a+n);
	int ans=1;

	ll b=0;
	s-=a[n-1];
	if(2*s>=a[n-1])
		b=1;
	rep(i,n-1,0){
		if(!b)
			break;
		ans++;
		s-=a[i];
		if(2*s<a[i])
			b=0;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N;
      cin >> N;
      vector<int> stick (N);
      for(int i = 0;i < N;i++){
          cin >> stick[i];
      }
      SORT(stick);
      REV(stick);

      int ans = 0;
      for(int i = 0;i < N;i++){
          for(int j = i+1;j < N;j++){
              for(int k = j+1;k < N;k++){
                  if(stick[i] < stick[j] + stick[k]){
                      ans++;
                  }
                  else{
                      break;
                  }
              }
          }
      }
      cout << ans << endl;
}


Measured memory_bytes: 256
a = []
for i in range(5):
    a.append(input())
ans = 0
a.sort(key = lambda x: x[-1])
flag = True
for s in a:
    if s[-1] == '0' and flag:
        ans += int(s)
    elif flag:
        ans += int(s)
        flag = False
    else:
        x = int(s[-1])
        ans += int(s) + 10 -x
print(ans)


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans=0;
  while(a!=b||a!=c){
    ans++;
    if(a>b&&a>c){
      b++;
      c++;
    }else if(b>a&&b>c){
      a++;
      c++;
    }else if(c>a&&c>b){
      a++;
      b++;
    }else if(a<b&&b==c){
      a+=2;
    }else if(b<c&&c==a){
      b+=2;
    }else if(c<a&&a==b)
      c+=2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

void solve() {
	int x, a, b; cin >> x >> a >> b;
	int n; cin >> n;
	rep(i, n) {
		string s; cin >> s;
		if (s == "nobiro") {
			x += a;
			if (x < 0)x = 0;
		}
		else if (s == "tidime") {
			x += b;
			if (x < 0)x = 0;
		}
		else {
			x = 0;
		}
	}
	cout << x << endl;
}

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



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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

// to avoid error on mingw
string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int M = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(8);
    ios_base::sync_with_stdio(false);

    int N;
    cin >> N;

    while(N--) {
        int a[10];
        rep(i, 10)
            cin >> a[i];

        bool probEnd = false;
        rep(i, 2<<10) {
            int left = 0, right = 0;
            bool failed = false;

            rep(j,10) {
                bool isRight = ( (i>>j) & 0x1 );
                if(isRight) {
                    if(right > a[j]) {
                        failed = true;
                        break;
                    }
                    right = a[j];
                }
                else {
                    if(left > a[j]) {
                        failed = true;
                        break;
                    }
                    left = a[j];
                }
            }

            if(!failed) {
                cout << "YES" << endl;
                probEnd = true;
                break;
            }
        }

        if(!probEnd)
            cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
using namespace std;

bool isPrime(int x) {
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i <= sqrt(x); i++) {
		if (x % i == 0) return false;
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a.at(i);
	}
	int count = 0;
	int x;
	for (int i = 0; i < n;i++) {
		x = a.at(i);
		if (isPrime(x)) {
			count++;
		}
	}
	
	cout << count << endl;
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 2005;
const int maxm = 4000005;
const int N = 4e6;
const int mod = 1e9+7;

int fac[maxm],inc[maxm];
int n,K,ans,dp[maxn][maxn];
LL fpm(LL p,LL k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
LL comb(int n,int m) {
	return (LL)fac[n]*inc[m]%mod*(LL)inc[n-m]%mod;
}
int main()
{
	#ifdef Amberframe
		freopen("agc002f.in","r",stdin);
		freopen("agc002f.out","w",stdout);
	#endif
	scanf("%d %d",&n,&K);fac[0]=inc[0]=1;
	for (int i=1;i<=N;i++) fac[i]=(LL)fac[i-1]*i%mod;
	inc[N]=fpm(fac[N],mod-2);
	for (int i=N;i>=2;i--) inc[i-1]=(LL)inc[i]*i%mod;
	
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
	for (int j=i;j>=0;j--)
		dp[i][j]=(dp[i][j+1]+dp[i-1][j-1]*comb(i*K-j-1,K-2))%mod;
	printf("%d",K>1?dp[n][0]*(LL)fac[n]%mod:1);
	return 0;
}

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

const int32_t MAX_N = 3000;

bool isCalc[MAX_N + 5][MAX_N + 5][2];
int32_t a[MAX_N + 5];
int64_t dp[MAX_N + 5][MAX_N + 5][2];

int64_t CalcDp(int32_t low, int32_t high, int32_t turn) {
	if(low > high) {
		return 0;
	}
	else if(isCalc[low][high][turn]) {
		return dp[low][high][turn];
	}

	if(turn == 0) {
		dp[low][high][turn] = std::max(CalcDp(low + 1, high, 1) + a[low], CalcDp(low, high - 1, 1) + a[high]);
	}
	else {
		dp[low][high][turn] = std::min(CalcDp(low + 1, high, 0) - a[low], CalcDp(low, high - 1, 0) - a[high]);
	}

	isCalc[low][high][turn] = true;
	return dp[low][high][turn];
}

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

	int32_t n;
	std::cin >> n;

	for(int32_t i = 0; i < n; i++) {
		std::cin >> a[i];
	}

	std::cout << CalcDp(0, n - 1, 0) << '\n';
}



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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
const ll INF = 1LL << 60;

int N;
vector<ll> H, DP;

inline void input() {
	cin >> N;
	H.resize(N);
	DP.resize(N);
	rep(i, N) cin >> H.at(i);
	rep(i, N) DP.at(i) = INF;
	DP.at(0) = 0;
}

inline void Main() {
  // code
	input();
	repi(i, 1, N) {
		if(i-1 >= 0) chmin(DP.at(i), DP.at(i-1)+abs(H.at(i)-H.at(i-1)));
		if(i-2 >= 0) chmin(DP.at(i), DP.at(i-2)+abs(H.at(i)-H.at(i-2)));
	}
	cout << DP.at(N-1) << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n;
  cin >> n;
  vi v(n);
  cin >> v;
  vvi dp(n - 1, vi(21));
  dp[0][v[0]] = 1;
  rep(i, n - 2) rep(j, 21) {
    if (j + v[i + 1] <= 20) dp[i + 1][j + v[i + 1]] += dp[i][j];
    if (j - v[i + 1] >= 0) dp[i + 1][j - v[i + 1]] += dp[i][j];
  }
  cout << dp.back()[v[n - 1]] << endl;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,k;
  double tmp,sum=0.0,mx=0.0;
  cin >> n >> k;
  queue<double> q;
  rep(i,n){
    cin >> tmp;
    tmp++;
    q.push(tmp);
    sum+=tmp;
    if(i>k-1){
      sum-=q.front();
      q.pop();
    }
    if(mx<sum)mx=sum;
  }
  printf("%.6lf\n",mx/2.0);
}

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

int main() {

    char s[20];

    scanf("%s", s);
    s[0] = '2';
    s[1] = '0';
    s[2] = '1';
    s[3] = '8';

    printf("%s", s);

    return 0;
}


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

int main() {
  int A, B, count;
  cin >> A >> B;
  vector<int>C(B+1);
  vector<int>D(B+1);
  vector<int>E(B+1);
  vector<int>F(B+1);
  for (int i = A; i < B + 1; i++) {
    C.at(i) = i / 10000;
    D.at(i) = i - i / 10 * 10;
    if (C.at(i) == D.at(i)) {
      E.at(i) = i/1000-i/10000*10;
      F.at(i) = i/10-i/100*10;
      if (E.at(i) == F.at(i)) {
        count++;
      }
    }
  }
  cout << count;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
    int n;
    string s;
    cin>>s;
    int dp[2020]={}; 

	n=s.length();
    ll total=0;
    for(int i=0;i<n;++i){
        int ndp[2020]={};
        ndp[(int)s[i]-48]=dp[0]+1;
        for(int j=1;j<2020;++j){
            int k=(10*j+(int)s[i]-48)%2019;
            ndp[k]+=dp[j];
        }
        total+=ndp[0];
        for(int j=0;j<2020;++j)dp[j]=ndp[j];
    }   
    cout<<total<<endl;
	return 0;
}


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

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int H, W, N;
    cin >> H >> W >> N;

    int m = max(H, W);
    int mi = min(H, W);

    double t = N;
    t /= m;
    t = ceil(t);

    int res = t;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  vector<vector<pair<int,int>>> xy(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
    for (int j = 0; j < a[i]; ++j)
    {
      int x,y;
      cin>>x>>y;
      xy[i].push_back(make_pair(x-1,y));
    }
  }

  int ans=0;
  for (int bit = 1; bit < (1<<n); ++bit)
  {
    bool flag=true;
    for (int i = 0; i < n; ++i)
    {
      if((bit&(1<<i))==0) continue; //i is unkind
      for (int j = 0; j < a[i]; ++j)
      {
        if((1&(bit>>xy[i][j].first))!=xy[i][j].second)
        {
          flag=false;
          break;
        }
      }
      if(flag==false) break;
    }
    if(flag)
    {
      int tmp=0;
      for (int k = 0; k < n; ++k)
      {
        if(bit&(1<<k)) tmp++;
      }
      ans=(tmp>ans?tmp:ans);
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (long long)1000000007
#define ll long long
using namespace std;

int main() {
     ll h,w,i,j;
     string str;
     cin>>h>>w;
     char grid[h+1][w+1];
     for(i=1;i<=h;i++){
        cin>>str;
        for(j=1;j<=w;j++){
        	grid[i][j]=str[j-1];
        }
     }
     ll gridd[h+1][w+1];
     memset(gridd,0,sizeof gridd);
    
     for(i=1;i<=h;i++){
     	for(j=1;j<=w;j++){
     		gridd[i][j]=grid[i][j]=='#'?-1:0;
     	}
     }
     
     
     /*for(i=1;i<=h;i++){
     	for(j=1;j<=w;j++){
     		cout<<gridd[i][j]<<" ";
     	}
     	cout<<endl;
     }*/
     
     
     
     for(i=1;i<=w;i++){
     	if(grid[1][i]=='#')
     	break;
     	else
     	gridd[1][i]=1;
     }
     for(i=1;i<=h;i++)
     {
     	if(grid[i][1]=='#'){break;}
     	else{gridd[i][1]=1;}
     	
     }
     
     /* for(i=1;i<=h;i++){
     	for(j=1;j<=w;j++){
     		cout<<gridd[i][j]<<" ";
     	}
     	cout<<endl;
     }
     cout<<endl<<endl;
     */
     for(i=2;i<=h;i++){
     	for(j=2;j<=w;j++){
     		if(gridd[i][j]==-1)continue;
     	      if(gridd[i-1][j] > 0) gridd[i][j] = (gridd[i][j] + gridd[i-1][j] )%MOD;
            if(gridd[i][j-1] > 0) gridd[i][j] = (gridd[i][j] + gridd[i][j-1] )%MOD;
     	}
     }
     
     
   /*  for(i=1;i<=h;i++){
     	for(j=1;j<=w;j++){
     		cout<<gridd[i][j]<<" ";
     	}
     	cout<<endl;
     }*/
     
     
     
     cout<<gridd[h][w]%MOD<<endl;
    
	return 0;
}

Measured memory_bytes: 9088
b,i,j;main(n){float a,x;char t[9],l[9];
for(;;){
for(i=0;i<9;i++)
t[i]=l[i]='0';
scanf("%f",&a);
if(a<0)break;
b=a;
for(i=0;b;)
t[i++]='0'+b%2,b/=2;
b=a;a-=b;x=0.5;
for(j=0;a>0&&j<5;j++)
  {if(a-x>=0)l[j]='1',a-=x;x/=2;}
if(j>4)puts("NA");else{for(b=0;b++<8-i;)printf("0");for(;i;)printf("%c",t[--i]);printf(".");for(;j>i;)printf("%c",l[i++]);for(;4>i++;)printf("0");puts("");}}exit(0);}

Measured memory_bytes: 0