akhauriyash/Code-Regression huggingface dataset:
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
#include<chrono>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > pbds;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
/*--------------------------------------------------------------------------------------------------------------------------*/
void solve()
{
	int t;
	// cin >> t;
	int total = 0;
	t = 1;
	while (t--)
	{
		int x;
		cin >> x;
		int val = x / 200;
		cout << 10 - val << endl;
	}
}
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	auto start1 = high_resolution_clock::now();
	solve();
	auto stop1 = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop1 - start1);
#ifndef ONLINE_JUDGE
	cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif
	return 0;
}

Measured memory_bytes: 3612
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    input! {
        s1: String,
        s2: String,
    }
    let mut chars: Vec<char> = s2.chars().collect();
    chars.reverse();
    let s2: String = chars.into_iter().collect();
    if s1 == s2 {
        println!("YES");
    } else {
        println!("NO");
    }
} 


Measured memory_bytes: 4352
Q,H,S,D=map(int,input().split())
N=int(input())
q1=Q
q2=min(2*q1,H)
q4=min(2*q2,S)
q8=min(2*q4,D)
if N%2==0:
  print(N//2*q8)
else:
  print(N//2*q8+q4)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
typedef struct E{
	int to;
	struct E *nxt;
}edge;
edge *T[1<<18], *nil;
void push(int i, int j){
	edge *t = (edge*)malloc(sizeof(edge));
	(*t).to = j;
	(*t).nxt = T[i];
	T[i] = t;
	return;
}
int N, Q, C[1<<18];
void dfs(int x){
	static bool visited[] = {[0 ... 1] true, [2 ... 1<<18] false};
	edge *t = T[x];
	while(t != nil){
		if(!visited[(*t).to]){
			visited[(*t).to] = true;
			C[(*t).to] += C[x];
			dfs((*t).to);
		}
		t = (*t).nxt;
	}
}
int main(){
	for(int i=0; i<1<<18; i++)T[i] = nil;
	scanf("%d%d", &N, &Q);
	for(int i=1; i<N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		push(a, b);
		push(b, a);
	}
	while(Q--){
		int p, x;
		scanf("%d%d", &p, &x);
		C[p] += x;
	}
	dfs(1);
	for(int i=0; i<N; i++){
		if(i)putchar(32);
		printf("%d", C[i+1]);
	}putchar(10);
	return 0;
}


Measured memory_bytes: 27404
from math import ceil
from fractions import Fraction
n = int(input())

t = 1
a = 1

for i in range(n):
    ti, ai = map(int, input().split())
    si = ceil(max(Fraction(t,ti),Fraction(a,ai)))
    t = ti*si
    a = ai*si

print(a+t)


Measured memory_bytes: 5304
#include <iostream>
#include <numeric>

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

    double a = 0;
    double num = 0;

    for(int i=0;i<n;i++){
        std::cin >> num;
        a += 1.0/num;
    }

    std::cout << 1.0/a << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

template<typename T, typename F> struct SparseTable{
    int h, w;
    vector<vector<T>> table;
    T et;
    F f;

    SparseTable(int n, T et, F f, vector<T> &a): w(n), et(et), f(f){
        h = (n == 1 ? 1 : 32-__builtin_clz(n-1));
        table.resize(h);
        rep(i, h) table[i].resize(w);
        build(a);
    }

    inline void build(vector<T> &a){
        rep(i, h){
            int step = 1<<(i+1);
            for(int l=0, s=(1<<i)-1, t=1<<i, r=(1<<(i+1))-1; l<w; l+=step, s+=step, t+=step, r+=step){
                chmin(s, w-1);
                table[i][s] = a[s];
                rFor(j, s, l) table[i][j] = f(a[j], table[i][j+1]);
                if(s == w-1) break;

                chmin(r, w-1);
                table[i][t] = a[t];
                For(j, t+1, r+1) table[i][j] = f(table[i][j-1], a[j]);
                if(r == w-1) break;
            }
        }
    }

    T query(int l, int r){
        if(l == r) return et;
        --r;
        if(l == r) return table[0][l];
        int t = 31-__builtin_clz(l^r);
        return f(table[t][l], table[t][r]);
    }
};

int main(){
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    rep(i, n) scanf("%d", &a[i]);
    auto f = [](int x, int y){return gcd(x, y);};
    SparseTable<int, decltype(f)> st(n, 0, f, a);

    int ans = 0;
    rep(i, n) chmax(ans, gcd(st.query(0, i), st.query(i+1, n)));
    printf("%d\n", ans);
}

Measured memory_bytes: 10364
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    # key[i]:10進数でiを開けれる鍵の値段
    key = []
    for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key.append((binary, a))

    # dp[i]:10進数で宝iを開けてる時の最小値段
    dp = [inf]*(1<<n)
    dp[0] = 0
    for i, a in key:
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
    if dp[-1] == inf:
        print(-1)
    else:
        print(dp[-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 42460
import heapq
from collections import defaultdict
N,M = map(int,input().split())
AB = defaultdict(list)
for i in range(N):
    a,b = list(map(int,input().split()))
    if a not in AB:
        AB[a] = [-b]
    else:
        AB[a] += [-b]
work = 0
AB2 = []
heapq.heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heapq.heappush(AB2,j)
    if not AB2:
        continue
    b = heapq.heappop(AB2)
    work += -b
print(work)

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

lli dp[100010];

void tejas_919(int kkkk)
{
    int n, W;
    cin>>n>>W;
    fol(i,1,n+1)
    {
        int w, v;
        cin>>w>>v;
        loop(j,W-w,0)
            dp[j+w]=max(dp[j+w],dp[j]+v);
    }
    cout<<*max_element(dp,dp+100010)<<endl;
}

int main()
{
    #ifndef tejasp
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #endif
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);
    let mut aa = util::gets::<u64>();

    aa.sort();

    let mut t = 0;
    let mut sum = 0;
    for i in 0..n {
        if aa[i] > sum * 2 {
            t = i;
        }
        sum += aa[i];
    }

    println!("{}", n - t);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  string s;
  cin >> s;
  map<char,int> mp;
  for(char c : s) mp[c]++;
  if(mp.size() == s.size()) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

template<typename stl>
void show_vec(const stl& x)
{
    for(auto i : x)
        cerr << i << ' ';
    cerr << '\n';
}

void swap_range(vector<int>& dek, int l, int k)
{
    vector<int> ret;
    int r = l + k;
    /* cerr << "l : r" << l  << ':' << r << '\n'; */
    FOR(i, l, r)
    {
        /* cerr << "i:" << i << ' '; */
        ret.push_back(dek[i]);
    }
    /* cerr << "ret1:: " ; show_vec(ret); */
    REP(i, l)
        ret.push_back(dek[i]);
    /* cerr << "ret2:: " ; show_vec(ret); */
    FOR(i, l+k, dek.size())
        ret.push_back(dek[i]);
    /* cerr << "ret3:: " ; show_vec(ret); */
    dek = ret;
}


int main()
{
    ios::sync_with_stdio(false);
    int n, r;
    while(cin >> n >> r)
    {
        if(n == 0)
            return 0;
        vector<int> dek;
        RFOR(i, n+1, 1)
            dek.push_back(i);
        /* show_vec(dek); */
        REP(i, r)
        {
            int p, c;
            cin >> p >> c;
            swap_range(dek, p-1, c);
            /* show_vec(dek); */
        }
        cout << dek[0] << '\n';
    }
}

Measured memory_bytes: 3132
#include<stdio.h>
int main(void){
char s[1001],t[1001];
  scanf("%s",&s);
  scanf("%s",&t);
  int c=0,min=1001;
  for(int i=0;i<=strlen(s)-strlen(t);i++){
	for(int j=i;j<i+strlen(t);j++){
     // printf("%c vs %c\n",s[j],t[j-i]);
		if(s[j]!=t[j-i])c++;
    }
    if(c<=min)min=c;
    c=0;
  }
  printf("%d",min);
  return 0;
}

Measured memory_bytes: 1732
n = int(input())
As = list(map(int,input().split()))
ans = sum(map(int,input().split()))
c = list(map(int,input().split()))
for i in range(n-1):
  if As[i+1] ==As[i] +1:
    ans += c[As[i]-1]
  else:
    pass
print(ans)
  

Measured memory_bytes: 3060
from collections import Counter
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
X = Counter([a1, b1, a2, b2, a3, b3])
N = Counter([x[1] for x in X.items()])
if N[1] == 2 and N[2] == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3444
grid = list(list(map(int,input().split())) for _ in range(3))

N = int(input())

S = set(int(input()) for _ in range(N))

def check():
    for i in range(3):
        if all(grid[i][j] in S for j in range(3)):
            return True
        if all(grid[j][i] in S for j in range(3)):
            return True
    return all(grid[i][i] in S for i in range(3)) or all(grid[2-i][i] in S for i in range(3))

print('Yes' if check() else 'No')

Measured memory_bytes: 38384
# 再帰を用いて実装
module Color
   WHITE = 0
   GRAY = 1
   BLACK = 2
end
def bfs(u)
  $color[u] = Color::BLACK

  for v in 0...($m.size) do
    if !$m[u][v].zero? && $color[v] == Color::WHITE
      # puts "HIT! unit : #{v}, color : #{$color[v]}"
      $color[v] = Color::GRAY
      $d[v] = $d[u] + 1
      $q << v
    end
  end
  
end

n = gets.to_i
$m = Array.new(n) { Array.new(n, 0) }
n.times do
  u, k, *v_arr = gets.split.map(&:to_i)
  for v in v_arr
    $m[u-1][v-1] = 1
  end
end
# for u in $m
#   puts u.join(' ')
# end
$time = 1
$color = Array.new(n, Color::WHITE)
$d = Array.new(n, -1)
$q = []
$q << 0
$d[0] = 0
while !$q.empty? do
  u = $q.shift
  bfs(u)
end
for i in 0...n do
  print i+1
  print ' '
  puts $d[i]
end


Measured memory_bytes: 6956
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int sum = 0;
		int a = scan.nextInt(); //????????§???????????\???
		int b = scan.nextInt(); //????????§???????????\???
		int c = scan.nextInt(); //????????§???????????\???
		for (int x = a; x <= b; x++){
			if(c % x == 0){
				sum++;
			}
		}
		System.out.println(sum);

	}

}

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

int main(){
  int m1,m2,d1,d2;
  cin >> m1 >> d1;

  switch(m1) {
  case 1:
    if(d1 == 31) {m2=m1+1;d2=1;}
    break;
  case 2:
    if(d1 == 28) {m2=m1+1;d2=1;}
    break;
  case 3:
    if(d1 == 31) {m2=m1+1;d2=1;}
    break;
  case 4:
    if(d1 == 30) {m2=m1+1;d2=1;}
    break;
  case 5:
    if(d1 == 31) {m2=m1+1;d2=1;}
    break;
  case 6:
    if(d1 == 30) {m2=m1+1;d2=1;}
    break;
  case 7:
    if(d1 == 31) {m2=m1+1;d2=1;}
    break;
  case 8:
    if(d1 == 31) {m2=m1+1;d2=1;}
    break;
  case 9:
    if(d1 == 30) {m2=m1+1;d2=1;}
    break;
  case 10:
    if(d1 == 31) {m2=m1+1;d2=1;}
    break;
  case 11:
    if(d1 == 30) {m2=m1+1;d2=1;}
    break;
  case 12:
    if(d1 == 31) {m2=1;d2=1;}
    break;
  default :
    {m2 = m1;d2 = d1+1;}
  }
  cin >> m2 >> d2;
  if(m2 == m1){
    cout << 0;
  }else{
    cout << 1;
  }
}

Measured memory_bytes: 256
class Tree():
    def __init__(self):
        self.nodes = {}
    def add_node(self, id):
        if id not in self.nodes:
            self.nodes[id] = Node(id)        
    def add_child(self, parent_id, child_id):
        self.add_node(parent_id)
        self.add_node(child_id)
        self.nodes[parent_id].add_child(self.nodes[child_id])
    
class Node():
    def __init__(self, id):
        self.id = id
        self.parent = None
        self.children = []
        self.depth = 0
        self.nodetype = 'root'

    def add_child(self, child):
        self.children.append(child)
        child.parent = self
        child.update_depth()
        child.update_nodetype()
        self.update_nodetype()
        if self.parent:
            self.parent.update_nodetype()
            
    def update_depth(self):
        depth = self.depth
        if self.parent:
            self.depth = self.parent.depth + 1
        if depth != self.depth:
            for child in self.children:
                child.update_depth()
                
    def update_nodetype(self):
        if self.parent:
            if len(self.children):
                self.nodetype = 'internal node'
            else:
                self.nodetype = 'leaf'
        else:
            self.nodetype = 'root'
        
            
    def walk(self):
        yield self
        for child in self.children:
            for node in child.walk():
                yield node

    def __str__(self):
        parent = self.parent.id if self.parent else -1
        children = ', '.join([str(node.id) for node in self.children])
        return 'node {}: parent = {}, depth = {}, {}, [{}]'.format(self.id, parent, self.depth, self.nodetype, children)

    
tree = Tree()

n = int(input())
for i in range(n):
    line = input().split()
    id = int(line[0])
    tree.add_node(id)
    for ci in map(int, line[2:]):
        tree.add_child(id, ci)

for id in tree.nodes:
    print( tree.nodes[id])

Measured memory_bytes: 70776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;

  vector<vector<ll>> dp(N, vector<ll>(N, 0));
  for (ll i = 0, j = N - 1; i < N; i++)
  {
    if (i >= j)
      continue;
    dp.at(i).at(j) = (S.at(i) == S.at(j) ? 1 : 0);
  }
  for (ll i = N - 1, j = 0; j < N; j++)
  {
    if (i >= j)
      continue;
    dp.at(i).at(j) = (S.at(i) == S.at(j) ? 1 : 0);
  }

  for (ll i = N - 1; i > 0; i--)
  {
    for (ll j = N - 1; j > 0; j--)
    {
      if (i >= j)
        continue;
      dp.at(i - 1).at(j - 1) = 
        min((dp.at(i).at(j) + 1) * (S.at(i - 1) == S.at(j - 1) ? 1 : 0), 
            j - i);
    }
  }
  
  ll ans = 0;
  for (ll i = 0; i < N; i++)
  {
    for (ll j = 0; j < N; j++)
    {
      //cerr << dp.at(i).at(j) << " ";
      chmax(ans, dp.at(i).at(j));
    }
    //cerr << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 195840
#include<stdio.h>

int main(){

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

    int count=0;
    for(int i=1;i<n-1;i++){
        if(p[i-1]<p[i] && p[i]<=p[i+1] || p[i-1]>p[i] && p[i]>=p[i+1]){
            count++;
        }
    }
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int num = 0;
    cin >> num;

    if(num > 0)
    {
        int *x = new int[num];
        for(int i = 0; i< num; i++)
        {
            cin >> x[i];
        }

        for(int i = num - 1; i > 0;i--)
        {
            cout << x[i] << " ";
        }
        cout << x[0] << endl;
        delete x;
    }

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int n;
    cin >> n;
    vector<long> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=n-1;i>=0;i--){
        int sum = 0;
        for(int j=1;(i+1)*j<=n;j++){
            sum += b.at((i+1)*j-1);
        }
        b.at(i) = abs(sum -a.at(i))%2;
    }
    int sumb = 0;
    for(int i=0;i<n;i++){
        sumb += b.at(i);
    }
    cout << sumb << endl;
    for(int i=0;i<n;i++){
        if (b.at(i) == 1){
            cout << i+1 << " ";
        }
    }
}

Measured memory_bytes: 3968
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N, D] = r.nn()

    let c = 0

    for (let i = 0; i < N; i++) {
      const [X, Y] = r.nn()

      if (X ** 2 + Y ** 2 <= D ** 2) {
        c++
      }
    }

    return c
  }

  const _io = (i = 0) => {
    const str: string = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


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

using namespace std;

typedef long long ll;

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

int binary_search(const vector<int> &xs, const int val, bool f(const vector<int> &, int, int)) {
    int left = -1, right = (int) xs.size(), mid;
    while (right - left > 1) {
        mid = (left + right) / 2;
        if (f(xs, mid, val)) right = mid;
        else left = mid;
    }

    return right;
}

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

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

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    for (int i_b = 0; i_b < N; i_b++) {
        // int i_a = binary_search(a, b[i_b], [](const vector<int> &xs, int ind, int val) {
        //         return xs[ind] >= val;
        // });
        // int i_c = binary_search(c, b[i_b], [](const vector<int> &xs, int ind, int val) {
        //         return xs[ind] > val;
        // });
        // ans += i_a * (((int) c.size()) - i_c);
        
        auto lb1 = lower_bound(a.begin(), a.end(), b[i_b]);
        auto lb2 = upper_bound(c.begin(), c.end(), b[i_b]);
        ans += (lb1 - a.begin()) * (c.end() - lb2);
        // cout <<i_a << "," << i_b << "," << i_c << " - "
        //     << ((lb1 == a.end()) ? a.size() : *lb1) << "," << ((lb2 == a.end()) ? -1 : *lb2) << endl;
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int a[114514];
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)cout<<c;
	else if(a==c)cout<<b;
	else cout<<a;
}
//タムリンかわいい
//sanadayukimura73はエロい
//駒場東邦の理科室でsex

Measured memory_bytes: 256
#include<stdio.h>

int LinerSearch(int key,int n,int *array){
    int i = 0;
    array[n] = key;
    while(array[i] != key) i++;
    if(i == n) return -1;
    return i;
}
int main(){
    int n,q,c=0;
    scanf("%d",&n);
    int s[n+1];
    for(int i = 0;i < n;i++) scanf("%d",&s[i]);
    scanf("%d",&q);
    int t[q];
    for(int i = 0;i < q;i++) scanf("%d",&t[i]);
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(s[i] == s[j] && i != j) s[i] = -1;
        }
    }
    for(int i = 0;i < q;i++){
        if(LinerSearch(t[i],n,s) != -1) c++;
    }
    printf("%d\n",c);
    
}



Measured memory_bytes: 2760
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll a[N]={0,1,2,3,4,5,6,7,8,9};
int main(){
	ll n,k=9,p1=1,p2=0;
	scanf("%lld",&n);
	while(k<n){
		if(abs(a[p1]%10-a[p2])<=1)
			a[++k]=a[p1]*10+a[p2];
		p2++;
		if(p2==10) p1++,p2=0;
	}
	printf("%lld\n",a[n]);
}

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

int main(){
  int a,b;
  cin >> a >> b;
  vector<int> A(1000);
  rep(i,1001){
    if(i == 1) A[i] = i;
    else{
      A[i] = i + A[i-1]; 
    }
  }
  cout << A[b-a-1] - a << endl;
  return 0;
}

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

int main(){

    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || b + c == a || c + a == b){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        //bytesのiterを生成
        .bytes()
        //それをas charでchar型に変換したiterを生成
        .map(|c| c.expect("failed to read char") as char)
        //c.is_whitespace()がfalseになるまで（つまり普通の文字が出るまで）iterを進めたiterを生成
        .skip_while(|c| c.is_whitespace())
        // !c.is_whitespace()がtrue, 即ち（普通の文字の間）iterを進め, 進んだところまでのiterを生成
        .take_while(|c| !c.is_whitespace())
        // それをcollect()してiterからStringを作る
        .collect();
    // parse()で任意の型に変換して返す。
    token.parse().ok().expect("failed to parse token")
}

fn read_one_line_to_vec() -> Vec<i32> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let v: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c == &'\x0d' || c == &'\x0a')
        .take_while(|c| !(c == &'\x0d' || c == &'\x0a'))
        .collect();
    v.split_whitespace()
        .map(|c| { let string = c.to_string();
            string.parse::<i32>().unwrap()})
        .collect()
}

fn main() {
    // ALDS1_2_B_Selection_Sort.rs

    let _length: i32 = read();
    let mut a = read_one_line_to_vec();
    let mut count = 0;
    for i in 0..a.len(){
        let mut minimum_j = i;
        for j in i+1..a.len() {
            if a[j] < a[minimum_j] {
                minimum_j = j;
            }
        }
        if !(i==minimum_j) {
            a.swap(i, minimum_j);
            count+=1;
        }
    }
    print_vec(a);
    println!("{}", count);
}

fn print_vec(v: Vec<i32>) {
    let mut v_iter = v.iter();
    print!("{}", v_iter.next().as_ref().unwrap());
    for v in v_iter {
        print!(" {}", v)
    }
    println!();
}



Measured memory_bytes: 5028
#include <iostream>
#include <numeric>    // accumulate

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

    int N;
    cin >> N;
    
    ll array[N];

    REP(i,N){
        cin >> array[i];
    }

    ll sunukeSum = array[0];
    ll araiSum = accumulate(&array[1],&array[N],(ll)0);

    ll ans = (ll)1e+10;
    ll diffAbs;
    
    FOR(i,1,N){
        //debug(sunukeSum)
        //debug(araiSum)
        diffAbs = abs(sunukeSum-araiSum);
        ans = min(diffAbs,ans);
        sunukeSum += array[i];
        araiSum -= array[i];
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
SS = ARGF.gets.chomp
NN = SS.size

def ispalin(ss)
  st = 0
  ed = ss.size - 1

  while st < ed
    if ss[st] != ss[ed]
      return false
    end
    st += 1
    ed -= 1
  end
  return true
end

tf = ispalin(SS)
#p tf
tf = tf && ispalin(SS[0..((NN - 1) / 2 - 1)])
#p ispalin(SS[0..((NN - 1) / 2 - 1)])
tf = tf && ispalin(SS[((NN + 3) / 2 - 1)..(NN - 1)])
#p ispalin(SS[((NN + 3) / 2 - 1)..(NN - 1)])

puts tf ? "Yes" : "No"


Measured memory_bytes: 1788
Scanf.scanf "%d %d %d" (fun n m p ->
    let nei = Array.make n [] in
    let uvw = Array.init m (fun _ ->
        Scanf.scanf " %d %d %d" (fun a b c ->
            let a = a - 1 in let b = b - 1 in
            nei.(a) <- b :: nei.(a);
            a, b, c - p
        )
    )
    in

    let sentinel = min_int / 10 in
    let bellman start =
        let cost = Array.make n sentinel in
        cost.(start) <- 0;
        for i = 0 to n - 1 do
            Array.iter (fun (u, v, w) ->
                if cost.(v) < cost.(u) + w then (
                    cost.(v) <- cost.(u) + w;
                )
            ) uvw
        done;
        cost
    in

    let reachable n1 n2 =
        let visited = Array.make n false in

        let rec visit cur =
            visited.(cur) <- true;
            List.iter (fun next -> if not visited.(next) then visit next) nei.(cur)
        in
        visit n1;
        visited.(n2)
    in

    let cost = bellman 0 in

    let flag = Array.fold_left (fun acc (u, v, w) ->
        if cost.(u) + w > cost.(v) && reachable 0 u && reachable u (n - 1) then true else acc) false uvw
    in
    Printf.printf "%d\n" @@ if flag then (-1) else max 0 cost.(n - 1)
)

Measured memory_bytes: 17708
N=int(input())
T, A = map(float,input().split())
x=1000
H=[int(i) for i in input().split()]

for i in range(N):
 
 # 平均気温aを計算する
	m=float(H[i])
	a=T-0.006*m
	if abs(A-a)<x:
		x=abs(A-a)
		y=i+1
	#print(a)
print(y)    

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
using namespace std;



int main(void) {
	int N = 0;
	cin >> N;

	int num = 0;
	if ((1 <= N) && (N < 10)) {
		num = N;
	}
	else if ((10 <= N) && (N < 100)) {
		num = 9;
	}
	else if ((100 <= N) && (N < 1000)) {
		num = 9 + N - 99;
	}
	else if ((1000 <= N) && (N < 10000)) {
		num = 909;
	}
	else if ((10000 <= N) && (N < 100000)) {
		num = 909 + N - 9999;
	}
	else if (N == 100000) {
		num = 90909;
	}
	else {
		num = 0;
	}

	cout << num << endl;

	return 0;
}



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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

int n;
int a[100100];
map<int, int> mapp;
ll x, y;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		mapp[a[i]]++;
	}

	for(map<int, int>::iterator it = mapp.begin(); it != mapp.end(); it++) {
		pii p = *it;
		if(p.s >= 4) {
			if(p.f >= x) {
				x = p.f;
				y = p.f;
			}
		} else if(p.s >= 2) {
			if(p.f >= x) {
				y = x;
				x = p.f;
			}
		}
	}

	cout << x * y << endl;
	

	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main(){
  string S , T;
  cin >> S >> T; 
  int counter = 0 ;
  if ( S[1] == T[1] ) counter++;
  if ( S[2] == T[2] ) counter++; 
  if ( S[0] == T[0] ) counter++;
  cout << counter ;
  
}

Measured memory_bytes: 256
MOD = int(1e9+7)


def main():
    S = int(input())
    dp = [[0] * (S+1) for _ in range(S//3+2)]
    for i in range(3, S+1):
        dp[1][i] = 1
    for i in range(2, S//3+2):
        sm = sum(dp[i-1]) % MOD
        sm = (sm - sum(dp[i-1][S-2:S+1])) % MOD
        for j in range(3*i, S+1)[::-1]:
            dp[i][j] = sm
            sm = (sm - dp[i-1][j-3]) % MOD
    ans = 0
    for i in range(S//3+2):
        ans = (ans + dp[i][S]) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 82580
#include <stdio.h>

int main(void)
{
	int a, b, i = 0;
	int flag = 0;
	char s[11], t[11], u[11];

	scanf("%s %s", s, t);

	scanf("%d %d", &a, &b);

	scanf("%s", u);

	while (s[i] != '\0' && u[i] != '\0') {
		if (s[i] != u[i]) {
			flag = 1;
			break;
		}
		i++;
	}

	if (flag == 1) {
		printf("%d %d", a, b - 1);
	}
	else {
		printf("%d %d", a - 1, b);
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;

//static const ll MOD = 1000000007;

int main() {
    ll N, answer = 0;
    vector<ll> B;

    // input
    cin >> N;
    for (ll i = 0; i < N - 1; i++) {
        ll b;
        cin >> b;
        B.emplace_back(b);
    }

    // process
    for (ll i = N - 1; i >= 0; i--) {
        if (i == N - 1) {
            answer = B[N - 2];
        } else if (i == 0) {
            answer += B[0];
        } else {
            answer += min(B[i], B[i - 1]);
        }
    }

    cout << answer << endl;

    return 0;
}

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

int main(){
   int a;
   cin >> a;
   if (a < 1200) {
     cout << "ABC" << endl;
   }
   else if (a >= 2800){
     cout << "AGC" << endl;
   }
   else {
     cout << "ARC" << endl;
   }
  return 0;
}


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

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

	if ((a <= 0) && (b >= 0)) {
		cout << "Zero" << endl;
	} else if (a > 0) {
		cout << "Positive" << endl;
	} else {
		ll x = b - a + 1;
		if (x % 2 == 0) { cout << "Positive" << endl; }
		else { cout << "Negative" << endl; }
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

int main() {


    zoom;    
    int N, i, j, k; cin >> N;
    vector<int> ans(N + 1, 0);
    for(i = 1; i <= 100; i += 1) {
        for(j = 1; j <= 100; j += 1) {
            for(k = 1; k <= 100; k += 1) {
                int res = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i);
                if(res > N)
                    break;
                ans[res] += 1;
            }
        }
    }
    for(i = 1; i <= N; i += 1) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int   a[2000010];
int ans[2000010];
int   c[10010];

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

  for( int i = 1; i < 10010; i++ ){
    c[i] += c[i - 1];
  }

  for( int i = N - 1; i >= 0; i-- ){
    ans[c[a[i]] - 1] = a[i];
    c[a[i]]--;
  }

  for( int i = 0; i < N; i++ ){
    cout << ans[i];
    if( i == N - 1 ) cout << endl;
    else cout << " ";
  }
  
}



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

using namespace std;
typedef long long LL;
const double pi = acos(-1.0);
const double eps = 1e-7;
const LL N = 11;
typedef pair<LL,LL> pLL;

pLL a[N];
LL T,n,m,i,j,k,b[N],t,ans=0;

bool cmp(const pLL aa,const pLL bb)
{
    if(aa.first==bb.first)return aa.second<bb.second;
    return aa.first<bb.first;
}

int main()
{

    scanf("%lld%lld%lld%lld",&a[0].first,&a[1].first,&a[2].first,&a[3].first);
    a[0].second=1;a[1].second=2;a[2].second=4;a[3].second=8;
    a[0].first*=8;a[1].first*=4;a[2].first*=2;
    b[0]=a[0].first*4;b[1]=a[1].first*4;b[2]=a[2].first*4;b[3]=a[3].first*4;
    sort(a,a+4,cmp);
    scanf("%lld",&n);
    n*=4;
    for(i=0;i<4;i++){
        t=a[i].second;
        LL t1=n/t;
        ans+=t1*a[i].first*t/8;
        n%=t;
    }
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e2 + 9;

ll x; multiset<ll> s; vii vec;

int main()
{
    //FASTIO ONLINE__JUDGE();

    cin >> x; vec.resize(x);
    for ( ll& i : vec ) cin >> i;

    s.insert( vec.front() );
    for ( int i = 1; i < x; ++i ){
        auto it = s.lower_bound( vec[i] );


        if ( it == s.begin() ){
            s.insert( vec[i] ); continue;
        }
        it--;

        if ( *it < vec[i] ){
            s.erase(it); s.insert(vec[i]);
        }
        else{
            s.insert( vec[i] );
        }
    }
    cout << SZ(s);
    return 0;
}


void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 5760
#include <iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
using namespace std;
int main(){
int N=0;
int x=0;
string S;
int ans=0;
cin >>N>>S;
for(int i=0; i<N; i++){
if (S[i]=='I')
x++;
if (S[i]=='D')
x--;
if (ans<x) ans=x;
}

cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
char buf[22222];
signed main(){
  scanf("%s",buf);
  string s(buf);
  int n=s.size();
  int ans=0;
  vector<int> v;
  for(int i=0;i<n;i++){
    if(s[i]!='\\') continue;
    int h=0,tmp=0;
    for(int j=i;j<n;j++){
      if(s[j]=='/') h--;
      if(s[j]=='_') tmp+=h*2;
      else tmp+=h*2+1;
      if(s[j]=='\\') h++;
      //cout<<j<<":"<<h<<" "<<tmp<<endl;
      if(s[j]!='/') continue;
      if(h==0){
	ans+=tmp/2;
	v.push_back(tmp/2);
	i=j;
	break;
      }
    }
  }
  cout<<ans<<endl;
  cout<<v.size();
  for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i];
  cout<<endl;
  return 0;
}

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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test;
    test=1;
    // cin>>test;
    while(test--)
    {
        int n,m,i,j;
        cin>>n>>m;
        char s[50][50],s1[50][50];
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)cin>>s[i][j];
        }
        for(i=0;i<m;i++)
        {
            for(j=0;j<m;j++)cin>>s1[i][j];
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(i+m-1>=n or j+m-1>=n) continue;

                 bool match=true;
                for(int a=0;a<m;a++)
                {
                   
                    for(int b=0;b<m;b++)
                    {
                        if(s[i+a][j+b]!=s1[a][b])
                        match=false;
                    }
                }
                if(match)
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
        cout<<"No";
    
    
    }
}


Measured memory_bytes: 256
import sys
from itertools import permutations

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(input())
    RC = [list(map(int, input().split())) for _ in range(k)]

    res = [["."] * 8 for _ in range(8)]
    for pattern in permutations(list(range(8))):
        XY = set(tuple((idx, num) for idx, num in enumerate(pattern)))
        flg = True
        for r, c in RC:
            if (r, c) not in XY:
                flg = False
                break
        if not flg:
            continue

        for x, y in XY:
            for i in range(1, 8):
                if (x + i, y + i) in XY or (x + i, y - i) in XY or (x - i, y + i) in XY or (x - i, y - i) in XY:
                    flg = False
                    break
            else:
                continue
            break
        if flg:
            for x, y in XY:
                res[x][y] = "Q"
            break

    for i in res:
        print("".join(i))


if __name__ == '__main__':
    resolve()



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

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int k = int.Parse(str[1]);
        int[] a = new int[n];
        int[] types = new int[n+1];
        int type = 0;
        int ans = 0;
        int[] nums = new int[n];
        str = Console.ReadLine().Split(' ');

        for(int i = 0; i < n; i++){
            a[i] = int.Parse(str[i]);
            types[a[i]]++;
        }

        for(int i = 1; i <= n; i++){
            if(types[i] != 0){
                type++;
            }
        }

        Array.Sort(types);
     

        if(type <= k){
            Console.WriteLine(0);
        }else{
            for(int i = 1; i <=n; i++){
                if(types[i] != 0){
                    ans += types[i];
                    type--;
                }
                if(type <= k){
                    break;
                }
            }
            
            Console.WriteLine(ans);
        }        
    }
}



Measured memory_bytes: 32476