akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    s.at(i)= 'x';
  }
    cout<<s<<endl;
  



}

Measured memory_bytes: 256
// フェルマーの小定理
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	m = 1000000007
)

var (
	fac []int
)

func mpow(x int, n int) int {
	result := 1
	for n != 0 {
		if n&1 == 1 {
			result *= x
			result %= m
		}
		x *= x
		x %= m
		n >>= 1
	}
	return result
}

func mcomb(n int, k int) int {
	if n == 0 && k == 0 {
		return 1
	}
	if n < k || k < 0 {
		return 0
	}
	return (fac[n] * mpow(fac[n-k], m-2) % m) * mpow(fac[k], m-2) % m
}

func main() {
	N := readInt()
	K := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	fac = make([]int, N+1)
	fac[0] = 1
	for i := 0; i < N; i++ {
		fac[i+1] = fac[i] * (i + 1) % m
	}

	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	result := 0
	for i := 0; i < N-K+1; i++ {
		result += A[i] * mcomb(N-(i+1), K-1)
		result %= m
	}

	sort.Ints(A)
	t := 0
	for i := 0; i < N-K+1; i++ {
		t += A[i] * mcomb(N-(i+1), K-1)
		t %= m
	}

	result -= t
	result %= m
	result += m
	result %= m
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> a(N); REP(i, N) cin >> a[i];

	vector<ll> sum;

	REP(i, N)
	{
		ll tmp{0};
		for (ll j = i; j < N; ++j)
		{
			tmp += a[j];
			sum.push_back(tmp);
		}
	}

	ll res{0};
	for (ll bits = 40; bits >= 0; --bits)
	{
		ll tmp = res | (1ll<<bits);
		ll cnt{0};
		for (auto &e : sum)
		{
			if ((e & tmp) == tmp)
				++cnt;
		}

		if (cnt >= K) res = tmp;
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 6260
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = getLine >>= putChar . which 'H' 'D' . uncurry (==) . mp . words >> putChar '\n'

Measured memory_bytes: 380
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	rep(i,3){
		int h1,m1,s1,h2,m2,s2;
		cin>>h1>>m1>>s1>>h2>>m2>>s2;
		int t=(h2-h1)*3600+(m2-m1)*60+(s2-s1);
		int s=t%60;
		int m=t/60%60;
		int h=t/60/60;
		cout<<h<<" "<<m<<" "<<s<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$n = $sc->nextInt();
$num = [];
for ($i = 0; $i < $n; $i++) {
    $num[] = $sc->nextInt();
}
rsort($num);
$res = $num[0] - end($num);
echo $res;

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

int cnt = 0;
void merge(int *A, int left, int mid, int right){
    int n1 = mid - left, n2 = right - mid;
    int L[n1+1], R[n2+1];
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = INT_MAX, R[n2] = INT_MAX;

    int curL = 0, curR = 0;
    for (int k = left; k < right; k++){
        if (L[curL] <= R[curR]){
            A[k] = L[curL];
            curL++;
        }else{
            A[k] = R[curR];
            curR++;
        }
        cnt++;
    }
}

void mergeSort(int *A, int left, int right){
    if (left+1 < right){
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; i++) cin >> s[i];
    mergeSort(s, 0, n);
    for (int i = 0; i < n-1; i++) cout << s[i] << " ";
    cout << s[n-1] << "\n" << cnt << "\n";
    return 0;
}



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

// Union-Find木
struct UnionFind {
  vector<int> par, size;
  
  // Constructor
  UnionFind(int n) : par(n), size(n) {
    for(int i = 0; i < n; i++){
      par[i] = i;
      size[i] = 1;
    }
  }
  
  // n要素で初期化
  void init(int n) {
    par.resize(n);
    size.resize(n, 1);
    for(int i = 0; i < n; i++) par[i] = i;
  }
  
  // 根の検索
  int find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  
  // xとyの属する集合を併合
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return false;
    size[x] += size[y];
    size[y] = size[x];
    par[x] = y;
    return true;
  }
  
  // xとyが同じ集合に属するか
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  
  // 連結成分の大きさ
  int check(int x) {
    return size.at(find(x));
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m, k;
  cin >> n >> m >> k;
  
  vector<int> a(m), b(m), c(k), d(k);
  UnionFind friends(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
    friends.unite(a.at(i), b.at(i));
  }
  
  vector<int> x(n + 1);
  for (int i = 1; i <= n; i++) {
    x.at(i) = friends.check(i) - 1;
  }
  
  for (int i = 0; i < m; i++) {
    x.at(a.at(i))--;
    x.at(b.at(i))--;
  }
  
  for (int i = 0; i < k; i++) {
    cin >> c.at(i) >> d.at(i);
    if (friends.same(c.at(i), d.at(i))) {
      x.at(c.at(i))--;
      x.at(d.at(i))--;
    }
  }
  
  for (int i = 1; i <= n; i++) {
    if (i != 1) cout << " ";
    cout << x.at(i);
  }
  cout << '\n';
}

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

using namespace std;
typedef long long ll;
int _w;

ll gcd( ll a, ll b ) {
	return b ? gcd(b, a%b) : a;
}

ll T, a, b, c, d;

int main() {
	cin >> T;
	while( T-- ) {
		cin >> a >> b >> c >> d;
		if( d < b ) {
			puts("No");
			continue;
		}
		if( a < b ) {
			puts("No");
			continue;
		}
		if( c >= a ) {
			puts("Yes");
			continue;
		}
		if( c >= b ) {
			puts("Yes");
			continue;
		}
		ll e = (a-c)/b;
		a -= b*e;
		if( a == c ) {
			if( d % b == 0 ) {
				puts("Yes");
				continue;
			}
			a += d % b;
		}
		if( a < b ) {
			puts("No");
			continue;
		}
		a -= b;
		if( d % b == 0 ) {
			puts("Yes");
			continue;
		}
		d %= b;
		ll g = gcd(d, b);
		e = (c-a)/g;
		a += e*g;
		a += g;
		puts( a < b ? "No" : "Yes" );
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  string s; cin >> s;
  rep(i,SZ(s)) s[i]='x';
  cout << s << endl;
  return 0;
}


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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i)
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i)

#define DEBUG(...) fprintf(stderr , __VA_ARGS__)

template<typename T>inline int chkmin(T &x , const T &y){ return x > y ? x = y , 1 : 0; }
template<typename T>inline int chkmax(T &x , const T &y){ return x < y ? x = y , 1 : 0; }

template<typename T>inline T read(T &f)
{
	f = 0 ; int x = 1 ; char c = getchar();
	while(!isdigit(c)) x = c == '-' ? -1 : 1 , c = getchar();
	while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
	return f *= x;
}

using int64 = long long;
using uint64 = unsigned long long;

char S1[10] , S2[10];

int main()
{
	scanf("%s" , S1 + 1);
	scanf("%s" , S2 + 1);
	int ans = 0;
	rep(i , 1 , 3)
	{
		ans += S1[i] == S2[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    ($x:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        $x = buf.trim().parse().unwrap();
    };

    ($x:expr, $($y:expr), +) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        input_iter!(buf.split_whitespace(), $x, $($y), +);
    };

    ($v:expr; $size:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        for v in buf.split_whitespace() {
            $v.push(v.parse().unwrap());
        }
    };

    ($v:expr; $h_size:expr, $w_size:expr) => {
        for _ in 0..$h_size {
            let mut part_vec = Vec::new();
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).ok();
            for v in buf.split_whitespace() {
                part_vec.push(v.parse().unwrap());
            }
            $v.push(part_vec);
        }
    };
}

#[allow(unused_macros)]
macro_rules! input_iter {
    ($iter:expr, $x:expr) => {
        $x = $iter.next().unwrap().parse().unwrap();
    };

    ($iter:expr, $x:expr, $($y:expr), +) => {
        let mut iter = $iter;
        $x = iter.next().unwrap().parse().unwrap();
        input_iter!(iter, $($y), *);
    };
}

fn main() {
    let _n: i32;
    let mut h: Vec<i32> = Vec::new();
    input!(_n);
    input!(h; _n);
    let mut max = 0;
    let mut ans = 0;
    for hh in h {
        if hh >= max {
            ans += 1;
            max = hh;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n; cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++){
        ll hehe = i + 1; hehe *= i; hehe/=2;
        ans += hehe;
    }
    for(int i = 1; i < n; i++){
        int u, v; cin >> u >> v;
        if (u > v) swap(u,v);
        ll hehe = n - v + 1; hehe *= u; ans -= hehe;
    }
    cout << ans << '\n';
    return 0;
}

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

#define ll long long
#define modu 1000000007

using namespace std;

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

	int n;
	cin >> n;
	ll a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	ll ps[n];
	ll last=0;
	int o = 0;
	for(int i = n-1; i >= 0; i--)
	{
		ll now = last + a[i];
		ps[o] = now;
		last = now;
		o++;
	}
	reverse(ps, ps+n);


	ll sum=0;
	for(int i = 0; i < n; i++){
		ll psum=(ps[i]-a[i])%modu;
		ll psum2 = (psum * a[i])%modu;
		sum = (sum + psum2)%modu;
	}
	cout << sum << endl;
}


Measured memory_bytes: 6760
#include <stdio.h>

int main(void)
{
    char s[256];
    scanf("%s", s);
    
    int counter = 0;
    if(s[0] == '1') counter++;
    if(s[1] == '1') counter++;
    if(s[2] == '1') counter++;
    
    printf("%d", counter);

    return 0;
}

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

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

    int n;
    cin >> n;

    vector<int> a(n + 1, 0);
    REP(i, n) cin >> a[i];

    int count = 0;
    REP(i, n) {
        if (i + 1 == a[i]) {
            count++;
            if (i + 2 == a[i + 1])
                i++;
        }
    }

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


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

int main(){

  int A, B, K;
  cin >> A >> B >> K;
  
  vector<int> p;
  
  for (int i=min(A,B); i>0; i--){
    if( A%i == 0 && B%i == 0 ){
      p.push_back(i);
    }
  }

  cout << p.at(K-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>

void solve() {
    for (int i = 0; i < 3; ++i) {
        char c;
        std::cin >> c;
        std::cout << c;
    }
    std::cout << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

const int M = 1e9+7;

int mpow(long long a, int n)
{
  if (n % 2) return mpow(a, n-1) * a % M;
  if (n == 0) return 1;
  return mpow(a*a%M, n/2);
}

int main()
{
  int n, a, b; cin >> n >> a >> b;
  
  long long xa = 1, xb = 1, ya = 1, yb = 1;
  for (int i = 1; i <= a; ++i) ya = ya * i % M;
  for (int i = 1; i <= b; ++i) yb = yb * i % M;
  for (int i = n-a+1; i <= n; ++i) xa = xa * i % M;
  for (int i = n-b+1; i <= n; ++i) xb = xb * i % M;
  
  int ans = mpow(2, n);
  int sous = (xa * mpow(ya, M-2) + xb * mpow(yb, M-2) + 1) % M;
  ans = (ans - sous + M) % M;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n; cin >> n;
	if(n%2==0) cout << 0.5 << endl;
	else{
		double ans = double(n/2+1)/n;
		out16(ans);
	}
}




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

int main(){
  int N;
  bool flag = true;
  cin >> N;
  vector<int> t(N + 1);
  vector<int> x(N + 1);
  vector<int> y(N + 1);
  t.at(0) = 0;
  x.at(0) = 0;
  y.at(0) = 0;
  
  for(int i = 1;i <= N;i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  
  for(int i = 1;i <= N;i++){
    int time = t.at(i) - t.at(i - 1);
    int posx = abs(x.at(i) - x.at(i - 1));
    int posy = abs(y.at(i) - y.at(i - 1));
    int move = time - (posx + posy);
    
    if(move < 0 || move % 2 == 1){
      flag = false;
      break;
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
int N;
ll K;
typedef pair <int,int> P;
vector<P> arra;

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

  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    arra.push_back(P(a,b));
  }

  sort(arra.begin(), arra.end());
  
  ll sum = 0;
  int i = 0;
  for(; i < N; i++) {
    sum += arra[i].second;
    if(K <= sum) break;
  }

  cout << arra[i].first <<endl;
}


Measured memory_bytes: 1400
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      	int count = 1;
      	boolean flag = false;
      	int[] block = new int[n];
      	for (int i = 0; i < n; i++) {
          block[i] = sc.nextInt();
          if(block[i] == count) count++;
          if(block[i] == 1) flag = true;
        }
      	if(!flag) System.out.println(-1);
      	else System.out.println(n-count+1);
    }
}

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

typedef long long int ll;
ll n;
char a[200007];

int main() {
    ll res = 0, r = 0, w = 0;

    scanf("%lld", &n);
    for(ll i = 0; i < n; ++i) {
        cin >> a[i];
        if(a[i] == 'R') r++;
        else w++;
    }

    if(!w || !r) {
        printf("0\n");
        return 0;
    }

    for(ll i = n - 1; i >= n - w; --i) {
        if(a[i] == 'R') res++;
    }

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

}

Measured memory_bytes: 3872
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath> 
#define ll int
#define maxn 40010
using namespace std;
int T,n,m,ans=0;
char s[1000010];
int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c>'9'||c<'0')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
int main()
{
	int flag=0;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i+=2)
	{
		if(s[i]=='h'&&s[i+1]=='i')
		{
			flag=0;
		}
		else
		{
			flag=1;
			break;
		}
	}
	if(flag)
		printf("No\n");
	else
		printf("Yes\n");
    return 0;
}
/*

*/

Measured memory_bytes: 256
/*input
12345678 87654321 12345678 87654321
123456789
*/
#include<iostream>
using namespace std;

#define int long long 
#define double long double

#define f first
#define s second
#define mp make_pair
#define pb push_back

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int a,b,c,d,n;
  cin >> a >> b >> c >> d >> n;
  a*=4;b*=2;
  c = min(c,min(a,b));
  int one = c*n;
  int two = (n/2)*d + (n%2)*c;
  cout << min(one,two);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#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++)
int main() {
	int n; cin >> n;
	double out = 0;
	double x[502];
	double dis[502][502];
	rep(i, n) {
		cin >> x[i];
	}
	rep(i, n) {
		dis[0][i+1] = dis[i+1][n + 1] = x[i];
	}
	rep(i, n) {
		Rep(j, i + 1, n) {
			double h = max(x[j] - x[i], x[i] - x[j]);
			double w = x[j]+x[i];
			dis[i + 1][j + 1] = sqrt(w*w - h * h);
		}
	}
	double dp[502] = {}; dp[0] = 0;
	rep1(i, n + 1) {
		per(j, i) {
			dp[i] = max(dp[i], dp[j] + dis[j][i]);
		}
	}
	cout << fixed << setprecision(5) << dp[n + 1] << endl;
	return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<cstdio>

using namespace std;

#define MAX 251

int parent(int i){
	return i/2;
}
int left(int i){
	return 2*i;
}
int right(int i){
	return 2*i+1;
}

int main(){
	int H,A[251];
	scanf("%d",&H);
	for(int i=1;i<=H;i++) scanf("%d",&A[i]);
	for(int i=1;i<=H;i++){
		printf("node %d: key = %d, ",i,A[i]);
		if(parent(i)>=1)
		printf("parent key = %d, ",A[parent(i)]);
		if(left(i)<=H)
		printf("left key = %d, ",A[left(i)]);
		if(right(i)<=H)
		printf("right key = %d, ",A[right(i)]);
		printf("\n");
	}
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

  int ans = n * (n - 1) / 2;
  ans += m * (m - 1) / 2;

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


Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String[] cards;
		int n = Integer.parseInt(buf.readLine());
		int num;
		boolean[] S = new boolean[13];
		boolean[] H = new boolean[13];
		boolean[] C = new boolean[13];
		boolean[] D = new boolean[13];

		for(int i=0; i<13; i++){
			S[i] = H[i] = C[i] = D[i] = false;
		}

		for(int i=0; i<n; i++){
			cards = buf.readLine().split(" ");
			num = Integer.parseInt(cards[1]);
			if(cards[0].equals("S"))
				S[num-1] = true;
			else if(cards[0].equals("H"))
				H[num-1] = true;
			else if(cards[0].equals("C"))
				C[num-1] = true;
			else if(cards[0].equals("D"))
				D[num-1] = true;
		}
		for(int i=0; i<13; i++){
			if(S[i] == false)
				System.out.println("S " + (i+1));
		}
		for(int i=0; i< 13; i++){
			if(H[i] == false)
				System.out.println("H " + (i+1));
		}
		for(int i=0; i<13; i++){
			if(C[i] == false)
				System.out.println("C " + (i+1));
		}
		for(int i= 0; i<13; i++){
			if(D[i] == false)
			System.out.println("D " + (i+1));
		}
		
	}
}

Measured memory_bytes: 24192
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
S = sum(A)

for _ in range(int(input())):
    b, c = map(int, input().split())
    k = count[b]
    count[b] = 0
    count[c] += k
    S += (c - b) * k
    print(S)

Measured memory_bytes: 24192
n,m=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
if n>=m
    puts 0
else
    x.sort!
    # diffs=x.each_cons(2).map{|a,b|b-a}.sort
    diffs = []
    x.each_cons(2) do |a,b|
        diffs << b-a
    end
    diffs.sort!
    p diffs[0...m-n].inject(:+)
end


Measured memory_bytes: 9968
#include <bits/stdc++.h>
struct Node {
  int key;
  Node *prev, *next;
};
Node *nil;
void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Node* listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}
int main() {
  int n, tmp;
  std::string s;
  init();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    std::cin >> s;
    if (s.size() > 6) {
      if (s[6] == 'F') deleteFirst();
      else deleteLast();
    }
    else {
      scanf("%d", &tmp);
      if (s[0] == 'i') insert(tmp);
      else deleteKey(tmp);
    }
  }
  Node *nd = nil->next;
  while (nd != nil->prev) {
    printf("%d ", nd->key);
    nd = nd->next;
  }
  printf("%d\n", nd->key);
  return 0;
}



Measured memory_bytes: 34424
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#include<stdlib.h>

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>

#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=2500010;//maxn*maxs
const int maxs=1e8+10;

int pri[maxn / 10], cnt;
bool ispri[maxn];
ll dcpCount(ll x){
	ll ans = 1;
	for(ll i = 2; i * i <= x; i++){
		if(x % i == 0){
			ll temp = 0;
			while(x % i == 0){
				x /= i;
				temp++;
			}
			ans *= (temp+1);
		}
	} 	
    if(x > 1) ans *= 2;
	return ans;
}
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<n;i++){
        int ans=n-i;
        cnt=dcpCount(ans);
        sum+=cnt;
    }
    cout<<sum<<endl;
    system("pause");
    return 0;
}
	



Measured memory_bytes: 3168
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S = list(str(input()))
if len(S) == 3:
    S.reverse()

print("".join(S))

Measured memory_bytes: 10824
N = int(input())
l = list(map(int, input().split()))
count = 0
for i in range(N-2):
  if l[i] < l[i+1] < l[i+2]:
    count += 1
  elif l[i] > l[i+1] > l[i+2]:
    count += 1
  else:
    count += 0
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int main(int n) {
    cin >> n;
    int B[4][3][10] = {};
    int b, f, r, v;
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        B[b-1][f-1][r-1] += v;
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << B[i][j][k];
            }
            cout << endl;
        }
        if (i < 3) cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
x = int(input())

if 400 <= x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)
elif 1000 <= x < 1200:
    print(5)
elif 1200 <= x < 1400:
    print(4)
elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
elif 1800 <= x < 2000:
    print(1)
    

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b>>c;
  string ans="No";
  if(a==b&&b!=c) ans="Yes";
  if(b==c&&c!=a) ans="Yes";
  if(c==a&&a!=b) ans="Yes";
   cout<<ans<<endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void main() {
    int a,b,c,d; readf("%d %d %d %d\n", &a,&b,&c,&d);
    writeln(can(a,b,c,d) ? "Yes" : "No");
    string _ = readln;
}

bool can(int a, int b, int c, int d) {
    if (abs(a-c) <= d) return true;
    if (abs(a-b) <= d && abs(b-c) <= d) return true;
    return false;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

a=[0]*((10**6)+1)
for i in L:
    a[i]+=1

uni=[]
for i in range((10**6)+1):
    if a[i]==1:
        uni.append(i)
a=[0]*((10**6)+1)
L=list(set(L))
for i in L:
    for m in range(i*2,(10**6)+1,i):
        a[m]=1
ans=0
for i in uni:
    if a[i]==0:
        ans+=1 
print(ans)


Measured memory_bytes: 47360
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	vector<char> s(n+2);
	rep(i, n) cin >> s[i];
	a -= 1;
	b -= 1;
	c -= 1;
	d -= 1;
	s[a] = 'A';
	s[b] = 'B';
	if (c < d) {
		while (true) {
			int tmpa = a;
			int tmpb = b;
			if (s[b + 2] == '.'&&b + 2 <= d) {
				b += 2;
				s[b] = 'B';
				s[b - 2] = '.';
			}
			if (s[b + 1] == '.'&&b + 1 <= d) {
				b += 1;
				s[b] = 'B';
				s[b - 1] = '.';
			}
			if (s[a + 2] == '.'&&a + 2 <= c) {
				a += 2;
				s[a] = 'A';
				s[a - 2] = '.';
			}
			if (s[a + 1] == '.'&&a + 1 <= c) {
				a += 1;
				s[a] = 'A';
				s[a - 1] = '.';
			}
			if (a == c && b == d) { cout << "Yes"; return 0; }
			if (a == tmpa && b == tmpb) { cout << "No"; return 0; }
		}
	}
	else{
		while (true) {
			int tmpa = a;
			int tmpb = b;
			if (s[a + 2] == '.'&&a + 2 <= c) {
				a += 2;
				s[a] = 'A';
				s[a - 2] = '.';
			}
			else if (s[a + 1] == '.'&&a + 1 <= c) {
				a += 1;
				s[a] = 'A';
				s[a - 1] = '.';
			}
			else if (s[b + 1] == '.'&&b + 1 <= d) {
				b += 1;
				s[b] = 'B';
				s[b - 1] = '.';
			}
			else if (s[b + 2] == '.'&&b + 2 <= d) {
				b += 2;
				s[b] = 'B';
				s[b - 2] = '.';
			}
			if (a == c && b == d) { cout << "Yes"; return 0; }
			if (a == tmpa && b == tmpb) { cout << "No"; return 0; }
		}
	}
	}

	


Measured memory_bytes: 384
n, k = map(int, input().split())
XY = [list(map(int, input().split())) for _ in [0] * n]
a = XY.sort()
ans = float("inf")
for i in range(n - k + 1):
    for j in range(i + k, 1 + n):
        x = XY[j - 1][0] - XY[i][0]
        now = XY[i:j]
        now.sort(key=lambda x: x[1])
        for w in range(j - i - k + 1):
            ans = min(ans, x * (now[w + k - 1][1] - now[w][1]))

print(ans)

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

int main() {
	int N, ans=1;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	for (int i = 1; i < N; i++) {
		bool can = true;
		for (int j = 0; j < i; j++) {
			if (H[i] < H[j]) {
				can = false;
			}
		}
		if (can) {
			ans++;
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] candies = new int[2][n];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                candies[i][j] = sc.nextInt();
            }
        }
        int max = maxCandies(candies);
        System.out.println(max);
    }

    /**
     * Approach:
     * We will loop through `candies` & keep the aggregate number of candies
     * on the top row
     *
     * We will also calculate the diff of the candy on the bottom row vs. the next candy on the top row.
     * We will keep an aggregate of this diff - whenever the diff is below 0, we will set it to 0
     *
     * If it is positive, it will keep track of our score if we had switched to the bottom row.
     * If it is zero, it is better to stay on the top row throughout.
     *
     * The max is just the sum of the aggregate of top row plus the aggregate delta.
     *
     */
    private static int maxCandies(int[][] candies) {

        int topSum = 0; // Sum of staying on the top row
        int bottomDelta = 0; // Delta for switching to the bottom row
        int i = 0;
        for ( ; i < candies[0].length - 1; i++) {
           bottomDelta += candies[1][i] - candies[0][i + 1];
           if (bottomDelta < 0) bottomDelta = 0;
           topSum += candies[0][i];
        }
        topSum += candies[0][i] + candies[1][i];
        return topSum + bottomDelta;
    }

}


Measured memory_bytes: 25044
#include<stdio.h>
#include<string.h>
int main()
{
	char a[101];
	scanf("%s",a+1);
	int n=strlen(a+1),i;
	for(i=1;i<=n/2;i++)
	{
		if(a[i]!=a[n-i+1])
		{
			printf("No");
			return 0;
		}
		if(a[i]!=a[i+n/2+1])
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL x;

int main()
{
	cin>>x;
	LL cur=100;
	for(int i=1;;i++)
	{
		cur+=cur/100;
		if(cur>=x)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,now,a[100010],ans;
int main()
{
	scanf("%d%d",&n,&now);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)if(a[i]<=now)++ans,now-=a[i];
	if(now&&ans==n)--ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll cost,mincost;
int status;
ll n,m,x;
int arr[13][13];
ll costs[13];
int arr3[13];
void bruteforce(int y){
    if(y==n+1){
        ll arr2[m+1];
        for(int i=1;i<=m;i++)arr2[i]=0;
        cost=0;
        for(int i=1;i<=n;i++){
            if(arr3[i]==1){
                for(int j=1;j<=m;j++){
                    arr2[j]+=arr[i][j];
                }
                cost+=costs[i];
            }
        }
        int status2=1;
        for(int i=1;i<=m;i++){
            if(arr2[i]<x){
                status2=0;
                break;
            }
        }
        if(status2==1){
            status=1;
            mincost=min(mincost,cost);
        }
        return;
    }
    arr3[y]=1;
    bruteforce(y+1);
    arr3[y]=0;
    bruteforce(y+1);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m>>x;
    mincost=1000000000;
    status=0;
    for(int i=1;i<=n;i++){
        cin>>costs[i];
        for(int j=1;j<=m;j++)cin>>arr[i][j];
    }
    bruteforce(1);
    if(status==0){
        cout<<-1;
        return 0;
    }
    cout<<mincost;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> s = {};
    pair<string, int> p;
    REP(i, n){
        string c;
        int x;
        cin >> c >> x;
        // s.push_back(c);
        // p.push_back(x);
        s.push_back(make_pair(make_pair(c, -x), i));
    }

    sort(s.begin(), s.end());
    REP(i, n){
        cout << s[i].second+1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl

use strict;
use warnings;

my $h = <STDIN>;
my $w = <STDIN>;
my $n = <STDIN>;
my $ans = 0;
my $cnt = 0;

while ($ans<$n)
{
    if ($h>=$w)
    {
        $ans += $h;
        $w--;
    }
    else
    {
        $ans += $w;
        $h--;
    }
    $cnt++;
}


print "$cnt\n";

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

int main(void){
  int h,w;
  cin>>h>>w;
  
  vector<vector<char>>a(h,vector<char>(w));
  
  for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
    cin>>a.at(i).at(j); 
   }
  }
  
  for(int j=0;j<w+2;j++){
    cout<<'#';
  }
  cout<<'\n';
  
  for(int i=0;i<h;i++){
    cout<<'#';
   for(int j=0;j<w;j++){
    cout<<a.at(i).at(j); 
   }
    cout<<'#'<<endl;
  }
  for(int j=0;j<w+2;j++){
    cout<<'#';
  }
  
  return 0;
  
}

Measured memory_bytes: 3632
#変数: S, num, formula
    
s = input()
num = len(s) - 1

for i in range(2**num):
    op = ['-']*num
    
    for j in range(num):
        if(i>>j)&1:
            op[num-j - 1] = '+'
    formula = ''
    for op_n, op_m in zip(s,op+['']):
        formula += op_n + op_m
    if eval(formula)==7:
        print(formula+ '=7')
        break

Measured memory_bytes: 9128
n = gets.to_i

min_b = 10**10
same_flg = true
sum = 0

n.times do  |i|
  a, b = gets.chomp.split.map(&:to_i)
  sum += a
  if a < b
    same_flg = false
  elsif a > b
    min_b = [min_b, b].min
    same_flg = false
  end
end
min_b = 0 if min_b == 10**10

puts same_flg ? 0 : sum - min_b

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
map<int,int> m;
multiset<int> s;
int main(){
	int h=read(),w=read();
	for(int i=0;i<w;i++)
		m[i]=i,s.insert(0);
	for(int i=0;i<h;i++){
		int a=read()-1,b=read(),mx=-1;
		map<int,int>::iterator x=m.lower_bound(a);
		while(x!=m.end() and x->first<=b){
			mx=max(mx,x->second);
			int y=x->first-x->second;
			s.erase(s.find(y));
			m.erase(x++);
		}
		if(mx!=-1 and b<w){
			s.insert(b-mx);
			m[b]=mx;
		}
		if(s.empty())puts("-1");
		else cout << *s.begin()+i+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 22288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static class Node<E> {
		E value;
		Node<E> prev;
		Node<E> next;
		public Node(E value) {
			this.value = value;
			prev = null;
			next = null;
		}
		public String toString() {
			return value.toString();
		}
	}
	
	static class DoublyLinkedList<E> {		
		
		private Node<E> head;
		private Node<E> tail;
		private int size;
		
		public DoublyLinkedList() {
			head = tail = null;			
			size = 0;
		}
		
		public int getSize() {
			return size;
		}
		
		public boolean isEmpty() {
			return size == 0;
		}

		public void appendToHead(E element) {
			Node<E> node = new Node<E>(element);
			if (head == null && tail == null) {
				head = tail = node;
			} else {
				head.prev = node;
				node.next = head;
				head = node;
			}
			size++;
		}
		
		public void delete(E element) {

			if (isEmpty()) {
				return;
			}
			
			if (head.value.equals(element)) {
				deleteFirst();
			} else {
				Node<E> current = head.next;
				Node<E> current2 = tail;
				Node<E> current3 = null;
				while (current != null) {
					if (current.value.equals(element)) {
						Node<E> prev = current.prev;
						Node<E> next = current.next;
						prev.next = next;
						if (next != null) {
							next.prev = prev;
						} else {
							tail = prev;
						}
						size--;
						break;
					} else if (current == current2) {
						if (current3 != null) {
							current = current3;
						} else {
							break;							
						}
					} else {
						current = current.next;						
						if (current2.value.equals(element)) {
							current3 = current2;
						}
						current2 = current2.prev;
					}
				}
			}
		}

		public void deleteFirst() {			
			if (isEmpty()) {
				return;
			}
			if (size == 1) {
				head = null;
				tail = null;
			} else {
				head = head.next;
				head.prev = null;
			}
			size--;
		}
		
		public void deleteLast() {			
			if (isEmpty()) {
				return;
			}
			if (size == 1) {
				head = null;
				tail = null;
			} else {
				tail = tail.prev;
				tail.next = null;
			}
			size--;
		}

		public void print() {
			Node<E> current = head;
			while (current != null) {
				System.out.print(current);
				current = current.next;
				if (current != null) {
					System.out.print(" ");
				}
			}
			System.out.println("");
		}
	}
	
	public static void main(String[] args) throws NumberFormatException, IOException {
				
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		
		DoublyLinkedList<Integer> list = new DoublyLinkedList<Integer>();
		for (int i = 0; i < n; i++) {
			String command = reader.readLine();

			if (command.charAt(0) == 'i') {
				list.appendToHead(Integer.parseInt(command.substring(7)));
			} else if (command.charAt(6) == 'F') {
				list.deleteFirst();
			} else if (command.charAt(6) == 'L') {
				list.deleteLast();
			} else {
				list.delete(Integer.parseInt(command.substring(7)));
			}
		}
		list.print();
	}
}



Measured memory_bytes: 141348
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	ll n; cin >> n;
	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 100;
const int MOD1 = 998244353;
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
const int nul = 0;
const int SIZE = 1e6 * 3;

vector <int> fact;

int rev(int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }
    return res;
}

int c(int n, int k) {
    return (fact[n] * rev((fact[k] * fact[n - k]) % MOD, MOD - 2) % MOD);
}

//int c(int n, int k) {
//    return (fact[n] / fact[k] / fact[n - k]);
//}

int get(int n, int m) {
    return c(n + m - 2, n - 1);
}

int add(int a, int b) {
    if (a + b >= MOD) return a + b - MOD;
    else return a + b;
}

int mul(int a, int b) {
    return a * b % MOD;
}

signed main() {
#ifdef parasha
    freopen("A.in", "r", stdin);
#endif // parasha
    fast;
    fact.resize(N + 1, 1);
    for (int i = 2; i <= N; ++i) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    //cout << get(7, 5) << endl;
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int ans = 0;
    for (int i = b + 1; i <= w; i++) {
        //cout << i << endl;
        int n = h - a;
        int m = w - i + 1;
        //cout << n << " " << i << " " << b << " " << m << endl;
        ans = add(ans, mul(get(n, i), get(a, m)));
        //cout << ans << endl;
    }
    cout << ans << endl;
}












Measured memory_bytes: 4756
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;

int main()
{
   //freopen("data.in","r",stdin);
   //freopen("data.out,"w",stdout);
   char s[3];
   cin>>s;
   if(s[0]==s[2])
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define hell  1000000007
using namespace std;
typedef long long ll;
const int nax = 1005;
const long long inf = (1LL<<60)-1;
vector<pair<ll,pair<ll,ll> > > v;
ll n,m;
ll ans;
bool oo = false;
void bellman(ll n, ll m, int s){
	
	long long int D[n+1];
	
	for(int i=0;i<=n;i++) D[i] = -inf;
	
	D[s] = 0;
	
	for(int i=0;i<n-1;i++){
		
		for(int j=0;j<m;j++){
			
			ll x = v[j].first;
		    ll y = v[j].second.first;
			ll w = v[j].second.second;
			
			D[y] = max(D[y], D[x] + w);
		     
		}
	}
	
    ans = D[n];
	
	for(int i=0;i<n-1;i++){
	
     for(int j=0;j<m;j++){
			
			ll x = v[j].first;
			ll y = v[j].second.first;
			ll w = v[j].second.second;
			
			D[y] = max(D[y], D[x] + w);
			
    	}
    }
    
    if(D[n] > ans) oo = true;
	
}
int main(){

	cin >> n >> m;
 
 	for(int i=0;i<m;i++){
 		int a,b,c;
 		cin >> a >> b >> c;
		v.push_back(make_pair(a,make_pair(b,c)));
		
	}
	
	bellman(n,m,1);
	
	if(oo == true) cout << "inf";
	else cout << ans;
	
	return 0;
}

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

using namespace std;

const int MXN = 1010;
const double INF = 1e10;

int main ()
{
	int n, t, a, h;
	int ans;
	double best = INF;
	scanf("%d%d%d", &n , &t, &a);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &h);
		if (fabs(t - h * 0.006 - a) < best)
		{
			best = fabs(t - h * 0.006 - a);
			ans = i + 1; 
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
S = input()
K = int(input())

w = None
N = []
for c in S:
    if c!=w:
        w=c
        N.append(1)
    else:
        N[-1]+=1

ans = 0
if len(N)==1:
    ans = (N[0]*K)//2
elif S[0]!=S[-1]:
    for n in N:
        ans += n//2
    ans *= K
else:
    ans += N[0]//2 + N[-1]//2
    ans += ((N[0]+N[-1])//2)*(K-1)
    for n in N[1:-1]:
        ans += (n//2)*K

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
#define ll long long
#define pii pair < int , int >
#define DB printf("debug\n");
#define all(x) x.begin() , x.end()
#define forr(i,A,B) for(int i=A;i<B;++i)
using namespace std;
int main(){
	cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);

	int h,w;
	cin>>h>>w;
	char g[h][w];

	queue<pair<int,pair<int,int> > > q;

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>g[i][j];
			if(g[i][j]=='#'){
				q.push(mp(0,mp(i,j)));
			}
		}
	}

	int ans=0;
	int rot[4][2]={{-1,0},{1,0},{0,-1},{0,1}};

	while(!q.empty()){
		int fdis  = q.front().st , fh = q.front().nd.st, fw = q.front().nd.nd;
		q.pop();
		ans = max(ans,fdis);
		for(int i=0;i<4;i++){
			int ndis=fdis+1,nh=fh+rot[i][0],nw=fw+rot[i][1];
			if(g[nh][nw]=='.' and 0<=nh and nh<h and 0<=nw and nw<w){
				//printf("fdis=%d fh=%d fw=%d ndis=%d nh=%d nw=%d\n",fdis,fh,fw,ndis,nh,nw);
				g[nh][nw]='#';
				q.push(mp(ndis,mp(nh,nw)));
			}
		}
	}

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

Measured memory_bytes: 13328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        if (a + b == c || a + c == b || b + c == a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long k = Long.parseLong(sc.next());
		Map<Integer, Long> m = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			long b = Integer.parseInt(sc.next());
			if (m.get(a) != null) {
				b += m.get(a);
			}
			m.put(a, b);
		}
		long c = 0;
		for (Integer i:m.keySet()) {
			c += m.get(i);
			if (c >= k) {
				System.out.println(i);
				return;
			}
		}
	}
}

Measured memory_bytes: 66028
import sys

sys.setrecursionlimit(10000)

def dfs(pos):
    x = pos[0]
    y = pos[1]
    C[y][x] = -1
    
    for x_d, y_d in [[1,0],[1,1],[0,1],[1,-1],[-1,1],[-1,0],[-1,-1],[0,-1]]:        
        x_new = x+x_d
        y_new = y+y_d

        if not 0<=x_new<=w-1:
            continue

        if not 0<=y_new<=h-1:
            continue

        if C[y_new][x_new]!=1:
            continue

        dfs([x_new, y_new])

while True:
    w, h = map(int, input().split())
    if w==h==0:
        break
    
    C = [list(map(int, input().split())) for _ in range(h)]
    
    counter = 0
    for w_i in range(w):
        for h_i in range(h):
            
            if C[h_i][w_i]==1:
                counter += 1
                dfs([w_i,h_i])
    
    print(counter)


Measured memory_bytes: 9804