akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, k;
vector<int> v;

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

    cin >> n >> k;
    v.resize(n);
    rep(i, n) cin >> v[i];
    int ans = 0;
    for (int l = 0; l < n; l++)
    {
        for (int r = l + 1; r < n; r++)
        {
            int num = l + n - r + 1;
            int d = k - num;
            if (d < 0)
                continue;
            vector<int> x;
            int tmp = 0;
            for (int i = 0; i <= l; i++)
            {
                x.push_back(v[i]);
                tmp += v[i];
            }
            for (int i = r; i < n; i++)
            {
                x.push_back(v[i]);
                tmp += v[i];
            }
            sort(all(x));
            for (int i = 0; i < x.size(); i++)
            {
                if (x[i] > 0 || i >= d)
                    break;
                tmp -= x[i];
            }
            ans = max(ans, tmp);
        }
    }
    for (int i = 0; i < n; i++)
    {
        int tmp = 0;
        for (int j = 0; j <= i; j++)
            tmp += v[j];
        int d = k - i - 1;
        if (d < 0)
            break;
        vector<int> x;
        for (int j = 0; j <= i; j++)
            x.push_back(v[j]);
        sort(all(x));
        for (int j = 0; j < x.size(); j++)
        {
            if (x[j] > 0 || j >= d)
                break;
            tmp -= x[j];
        }
        ans = max(ans, tmp);
    }
    for (int i = n - 1; i >= 0; i--)
    {
        int tmp = 0;
        for (int j = n - 1; j >= i; j--)
            tmp += v[j];
        int d = k - n - i;
        if (d < 0)
            break;
        vector<int> x;
        for (int j = n - 1; j >= i; j--)
            x.push_back(v[j]);
        sort(all(x));
        for (int j = 0; j < x.size(); j++)
        {
            if (x[j] > 0 || j >= d)
                break;
            tmp -= x[j];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

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

int main()
{
    string s,t,l;
    cin>>s>>t;
    l = s;
    while(s != t)
    {
        s = s[s.size()-1] + s.substr(0,s.size()-1);
        if(s == l)return puts("No"),0;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
n = input()
p = list(map(int,input().split()))
list = []
cnt = 0
for i in range(len(p) - 2):
    list.append(p[i])
    list.append(p[i+1])
    list.append(p[i+2])
    if p[i + 1] != max(list) and p[i + 1] != min(list):
        cnt += 1
    list =[]
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int r, g, b;
  cin >> r >> g >> b;

  int num = 100 * r + 10 * g + b;
  if (num % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int main(){

    int N;cin >> N;

    vector<int> h(N);
    REP(i,N) cin >> h[i];
  
    auto dp = make_vec<int>(N+1);

    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i = 2; i < N ; i++) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));

    pl(dp[N-1])

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	ll a, b, n;
	cin >> a >> b >> n;
	ll x = n;
	if (n >= b - 1) x = b - 1;
	ll ans = a * (x % b) / b;
	cout << ans << endl;
}

Measured memory_bytes: 3652
use whiteread::parse_line;

fn main() {
    let a: usize = parse_line().unwrap();
    let b: usize = parse_line().unwrap();
    let c: usize = parse_line().unwrap();
    let x: usize = parse_line().unwrap();
    let mut cnt = 0;
    for s in 0..=a {
        for t in 0..=b {
            for u in 0..=c {
                if s * 500 + t * 100 + u * 50 == x {
                    cnt += 1;
                }
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2128
import fractions
a,b,c=map(int,input().split())

kouyaku=fractions.gcd(a,b)
#cがとりうる値を列挙
c_l=[]
for i in range(int(b/kouyaku)):
    c_l.append(i*kouyaku)
if c in c_l:
    print("YES")
else:
    print("NO")

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

int main(){
int N,M;
   cin>>N;
  vector<int>T(N);
  int sum=0;
  for(int i=0; i<N; i++){
   cin>>T[i];
   sum+=T[i];  }
  
  cin>>M;
  vector<int>P(M);
  vector<int>X(M);
  for(int i=0; i<M; i++){
   cin>>P[i]>>X[i];
   cout<<sum-T[P[i]-1]+X[i]<<endl;
  }
  
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

a,b = map(str,input().split())

if a == "H" and b == "H":
    tp = True
elif a=="D" and b == "H":
    tp = False
elif a=="D" and b=="D":
    tp = True
else:
    tp = False


if tp:
    print("H")
else:
    print("D")


Measured memory_bytes: 6340
#include<stdio.h>
int main()
{
	int a,b,c;
	do
	{
		scanf("%d%d%d",&a,&b,&c);
	}
	while(a>500&&a<1&&b>500&&b<1&&c<1&&c>1000);
	if(a+b>=c)
		printf("Yes");
	else
		printf("No");
	return 0;
}

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

using namespace std;

const int MAXN = 212345;

int a[MAXN], b[MAXN];

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

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

	for (int i = n; i > 0; --i) {
	
		int sum = 0;

		for (int j = i + i; j <= n; j += i) 
			sum += b[j];
		
		if (sum % 2 != a[i]) b[i] = 1;
		
	} 

	vector <int> v;

	for (int i = 1; i <= n; ++i) {
		if (b[i] == 1) {
			v.emplace_back (i);
		}
	}

	printf("%d\n", (int) v.size());
	for (int i : v) {
		printf("%d ", i);
	}
	if ((int)v.size()) puts("");

	return 0;
}


Measured memory_bytes: 2936
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        int N = IntRead();
        int[] box = SpIntRead(' ');
        var sorted = box.OrderByDescending(v => v);
        Console.WriteLine(sorted.Where((n,index) => index % 2 == 0).Sum() - sorted.Where((n,index) => index % 2 == 1).Sum());
    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
}


Measured memory_bytes: 13396
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7

def f():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    i = 1
    if n > 2 and a[-1] == 1:
        return 'Impossible'
    if a[-1] != a[-2]:
        return 'Impossible'
    if a[-1] % 2 == 1:
        if a[-1] // 2 + 1 != a[0]:
            return 'Impossible'
        if a[0] != a[1]:
            return 'Impossible'
        if n > 2 and a[0] == a[2]:
            return 'Impossible'
        i = 2
    else:
        if a[-1] // 2 != a[0]:
            return 'Impossible'
        if a[0] == a[1]:
            return 'Impossible'
    c = 2
    t = a[0]
    for j in range(i,n):
        if t != a[j]:
            if c < 2:
                return 'Impossible'
            if t + 1 != a[j]:
                return 'Impossible'
            c = 0
            t = a[j]
        c += 1
    return 'Possible'

print(f())


Measured memory_bytes: 5932
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CirclePond | diff CirclePond.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CirclePond.cpp && ./a.out

/*
 
 4/19/2020
 
 5:10-
 
 */

const double PI = acos(-1);
int R;
void solve() {
  cout<<2.0*PI*R<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>R;
  solve();
  
  return 0;
}


Measured memory_bytes: 3776
N = int(input())
A = list(map(int,input().split()))
S = []
P = A[:N]
Q = A[2*N:]
for i in range(N):
    Q[i] *= -1
R = A[N:2*N]
p = [0]*(N+1)
q = [0]*(N+1)
import heapq
heapq.heapify(P)
heapq.heapify(Q)
sp = sum(P)
sq = sum(Q)
p[0] = sp
q[0] = sq

for i in range(1,N+1):
    heapq.heappush(P,R[i-1])
    x = heapq.heappop(P)
    heapq.heappush(Q,-R[-i])
    y = heapq.heappop(Q)
    sp = sp + R[i-1] - x
    sq = sq - R[-i] - y
    p[i] = sp
    q[i] = sq
ans = -(10**100)
for k in range(N+1):
    ans = max(ans,p[k] + q[N-k])
    
print(ans)


Measured memory_bytes: 40724
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int X, Y;

int main(int argc, char* argv[]) {
  cin >> X >> Y;

  int two_crane = 4 * X - Y;
  int two_turtle = -2 * X + Y;
  if (two_crane >= 0 && two_crane % 2 == 0 && two_turtle >= 0 &&
      two_turtle % 2 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3620
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int

int n,a[400000],l,r,p,q;
lo c;




int main() {
	
	cin >> n;
	if (n <= 999) { cout << "ABC"; }
	else { cout << "ABD"; }
	//system("pause");
	return 0;

}



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

int main() {
  long long N, ans=1000000000000;
  cin >> N;
  for(long i=1;i*i<=N;i++) {
    if (N%i==0){
      ans=min(ans, i+(N/i)-2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,
        ass:[usize;n]
    }

    let mut bs = vec![(0usize, 0usize); n];
    for i in 0..n {
        bs[i] = (ass[i], i + 1);
    }
    bs.sort();
    for b in bs.iter() {
        print!("{} ", b.1);
    }
    println!("");
}


Measured memory_bytes: 8956
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int c = sc.nextInt();
    	int k = sc.nextInt();

    	int max = Math.max(Math.max(a, b), c);
    	int sum = a + b + c;

    	for (int i = 0; i < k; i++){
    		sum = sum + max;
    		max = max * 2;

    	}

    	// 出力
    	System.out.println(sum);
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 2e9;

int main() {
  int a, b;
  cin >> a >> b;
  if(a%b==0) {
    cout << -1 << endl;
    return 0;
  }
  else {
    for(int i=1; i<10000000; i++) {
      if((a*i)%b!=0) {
        cout << a*i << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN=100005;
int n,m,q,a[MAXN],pos[MAXN],beg=0,dest[MAXN];
bool vis[MAXN];
int cnt[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d",&q);
	for(int i=1;i<=q;++i)
		scanf("%d",a+i);
	for(int i=q;i>0;--i){
		if(!vis[a[i]]){
			pos[a[i]]=++beg;
			dest[beg]=a[i];
			vis[a[i]]=true;
		}
	}
	int t=0;
	for(int i=1;i<=m;++i)
		if(!vis[i])dest[beg+(++t)]=i;
	cnt[0]=n;
	int mx=0;
	for(int i=q;i>0;--i){
		int o=pos[a[i]];
		if(cnt[o-1]){
			--cnt[o-1];
			++cnt[o];
			mx=max(mx,o);
		}else if(mx<o-1){
			puts("No");
			return 0;
		}
	}	
	int st=n;
	for(int i=0;i<=beg;++i)
		if(cnt[i]){st=i;break;}
	for(int i=st+2;i<=m;++i)
		if(dest[i]<dest[i-1]){
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1920
def main():

    N, M, K = map(int, input().split())
    for i in range(N+1):
        for j in range(M+1):
            count = M*i + N*j-2*i*j 
            if count == K:
                return "Yes"

    return "No"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 2940
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - AtCoder Express 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500;

/* typedef */

/* global variables */

int xs[MAX_N][MAX_N], cs[MAX_N][MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);

  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--, r--;
    xs[l][r]++;
  }

  for (int i = 0; i < n; i++) {
    cs[i][0] = 0;
    for (int j = 0; j < n; j++) cs[i][j + 1] = cs[i][j] + xs[i][j];
  }

  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--;
    int sum = 0;
    for (int i = l; i < r; i++) sum += cs[i][r];
    printf("%d\n", sum);
  }
  return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    string S,line="abcdefghijklmnopqrstuvwxyz";
    cin>>S;
    cout<<line.substr(line.find(S.substr(0,1))+1,1)<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


map<ll, ll> ATIME;

ll attack(ll h){
    if(ATIME[h]) return ATIME[h];
    if(h == 1)
        return ATIME[1] = 1;
    return ATIME[h] = 1 + 2 * attack(h/2);
}

int main(){
    ll H; cin >> H;
    cout << attack(H) << endl;
    return 0;
}


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

typedef long long int ll;
const int N = 1e6+5;

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


    string s;cin>>s;
    int sz = s.size();
    ll res = 0,cnt = 0;
    for(int i=0;i<sz;i++)
    {
        if(s[i]=='B')cnt++;
        else res+=cnt;
    }
    cout<<res<< "\n";





    return 0;
}


Measured memory_bytes: 720
#include <iostream>

int main(void) {

    int N, M, C;
    int B[20];
    int ret = 0;

    std::cin >> N >> M >> C;

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

    for(int n=0; n<N; n++) {
        int val = C;
        for(int i=0; i<M; i++) {
            int a;
            std::cin >> a;
            val += B[i] * a;
        }
        if(val > 0) ret++;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  int a,b;
  std::cin >> a >> b;
  std::cout << a+b/2 << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    S = list(map(str, input().strip()))
    order = [tuple(map(str, input().split())) for _ in range(Q)]
    order = order[::-1]

    left, right = 0, N-1
    for a in order:
        t, d = a[0], a[1]

        if d == 'L':
            if S[left] == t:
                left += 1
                if left > N - 1:
                    return 0

            if right < N - 1 and S[right + 1] == t:
                right = min(N - 1, right + 1)

        else:
            if left > 0 and S[left - 1] == t:
                left = max(0, left - 1)

            if S[right] == t:
                right -= 1
                if right < 0:
                    return 0

    return right - left + 1


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 20744
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	a := io.NextInts(n)
	ans := solve(a)
	io.Println(ans)
}

func solve(a []int) (ans int) {
	sort.Slice(a, func(i, j int) bool { return a[i] > a[j] })
	q := []int{a[0]}
	for i := 1; i < len(a); i++ {
		ans += q[0]
		q = append(q[1:], []int{a[i], a[i]}...)
	}
	return ans
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

int main() {
	
	string s;
	cin>>s;
	bool check = true;
	if(s[0] != 'A')
	{
		check = false;
	}
	if(int(s[1]) >= 65 and int(s[1]) <= 90)
	{
		check = false;
	}
	bool checkc = false;
	if(s[s.size()-1] == 'C')
	{
		check = false;
	}
	if(int(s[s.size()-1]) >= 65 and int(s[s.size()-1]) <= 90)
	{
		check = false;
	}
	for(int i = 2; i < s.size()-1; i++)
	{
		if(int(s[i]) >= 65 and int(s[i]) <= 90 and s[i] != 'C')
		{
			check = false;
		}
		if(s[i] == 'C' and !checkc)
		{
			checkc = true;
		}
		else if(s[i] == 'C' and checkc)
		{
			check = false;
		}
	}
	if(check and checkc)
	{
		cout<<"AC";
	}
	else
	{
		cout<<"WA";
	}
	
	return 0;
}

Measured memory_bytes: 3596
def examA():
    S = I()
    X = [0,10**9,0]; Y = [0,1,0]
    X[2] = -S%(10**9)
    Y[2] = (S-1)//(10**9) +1
#    print(abs(X[1]*Y[2]-X[2]*Y[1]))
    print(X[0],Y[0],X[1],Y[1],X[2],Y[2])
    return

def examB():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examA()


Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int k;
  cin>>k;
  cout<<(k/2)*((k/2)+(k%2))<<"\n";
  return 0;
}

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


int main(){
	int a, b;
	char op;
	while (cin >> a >> op >> b && op != '?') {
		switch (op) {
		case '+':cout << a+b; break;
		case '-':cout << a-b; break;
		case '*':cout << a*b; break;
		case '/':cout << a / b; break;
		default:break;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3060
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    a, b, x = map(int, input().split())
    y = 2 * x / (a ** 2) - b
    if y >= 0:
        print(math.degrees(math.atan((b - y) / a)))
    else:
        print(math.degrees(math.atan(a * (b ** 2) / (2 * x))))



if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, top, ans;
char s[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++){
		ans = max(ans, top + (n - i)*9 + s[i] - '0' - 1);
		top += s[i] - '0';
	}
	ans = max(ans, top);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;
int main() {
	int x, y;
	while (cin >> x >> y&&(x != 0 || y != 0)) {
		if (x > y) swap(x, y);
		cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 3072
n, m = gets.split.map(&:to_i)
edges = Array.new(n+1){{}}
m.times do
    u, v, s = gets.split.map(&:to_i)
    edges[u][v] = s
    edges[v][u] = s
end

# 「仮に」頂点1を0として、各頂点の値を決めていく。
# この情報を元に、最後に「頂点0の値は何通り取れるか？」で答えを出す。
# もし途中でどうしても解消できない矛盾が発生したら、その時点で答えゼロで終了して良い。

# 頂点1を+として、辺をまたぐごとに+, -, +, ...とラベル付けする。+ならtrue、-ならfalse。
# 頂点1の値を1増やした時に、+の点の値は1増えて、-の点の値は1減ることになる。
plus = []
plus[1] = true

# 頂点1の値を0としたときの、各頂点の値。この時点では、値が非正になることは気にしない。
value = []
value[1] = 0

# 探索途中に、頂点1の値が途中で確定してしまうことがある。その時にこの変数に保存する。
# nilは未確定であることを示す
offset = nil

# DFSで探索。（BFSでもいい）
stack = [1]
while stack.length > 0
    u = stack.pop
    edges[u].each do |v, c|
    next if u == v

        # まだ訪れていない頂点なので、閉路ではない。符号と値を格納するだけ。
        unless value[v]
            plus[v] = !plus[u]
            value[v] = c - value[u]
            stack.push(v)
            next
        end

        # 偶閉路になった場合。
        # この場合は頂点1の値をずらしても2頂点の数の合計は変わらない。
        # そのため、値がずれていたら即矛盾。答えゼロで終了。
        # （例：aをどのように取っても、(3+a) + (5-a) = 10 にはできない。）
        if plus[v] != plus[u]
            if value[v] + value[u] != c
                puts 0
                exit
            end
            next
        end

        # 奇閉路になった場合。
        # この場合は頂点1の値を適切に取ることで整合を取れる可能性がある。
        # 例：(3+a) + (5+a) = 10 にしたいなら、a=1である必要がある。

        if !plus[v]
            diff = c - (value[v] + value[u])
        else
            diff = (value[v] + value[u]) - c
        end

        # ずれが奇数ならアウト
        if diff % 2 == 1
            puts 0
            exit
        end

        # 偶数の閉路が2箇所以上あって、それぞれが要求する頂点1の値が食い違う場合アウト
        if offset && offset != diff/2
            puts 0
            exit
        end

        # offsetは「頂点1の値がこの値でないと、整合性が取れない」という制約を示している
        offset = diff/2
    end
end


# ここからは、「全部の頂点の値が正か？」も考慮して、整数の付け方が何通りあるかを考える
# +, -それぞれのラベルが付いた点について、値の最小値を取る
posval = (1..n).select{|i|plus[i]}.map{|i|value[i]}
posneg = (1..n).select{|i|!plus[i]}.map{|i|value[i]}
posmin = posval.min
negmin = posneg.min

# offsetが存在する、つまり奇閉路による制約がある場合、答えは高々1通り。
# そのoffsetで非正な値の頂点が存在してしまう場合は0通り。
if offset
    if posmin - offset > 0 && negmin + offset > 0
        puts 1
    else
        puts 0
    end
# 奇閉路による制約が存在しない場合、全ての頂点が正になるという条件で任意のoffsetを選べる。
else
    puts [posmin+negmin-1, 0].max
end

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

int main()
{
    int cnt[3] = {};
    string S;

    cin >> S;
    for ( int i = 0; i < S.size(); i++ ) {
        cnt[S[i] - 'a']++;
    }
    sort(cnt, cnt + 3);
    if ( cnt[2] - cnt[0] <= 1 ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return ( 0 );
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N, M; cin >> N >> M;
VP LR(M), RL(M); 
rep(i, 0, M) {
    cin >> LR[i].first >> LR[i].second;
    RL[i].first = LR[i].second;
    RL[i].second = LR[i].first;
}

cout << max(0LL, (*min_element(ALL(RL))).first - (*max_element(ALL(LR))).first + 1LL) << endl;


}

// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

#define ll long long int
#define pii pair<int,int>
#define PII pair<ll,ll>

const ll sz=3e5+100;
int first[sz], last[sz];
map<int,int> mp[sz];

int main()
{
    int  n,m,i,j,k,p,x,y,a;

    cin>>n>>m>>a;
    for(i=1;i<=a;i++)
    {
        cin>>x>>y;
        ++first[x], ++last[y];
        mp[x][y]=1;
    }

    pair<int,int> ara[m+1];
    for(i=1;i<=m;i++) ara[i-1]={last[i],i};
    sort(ara,ara+m,greater<pii>());

    int mx=0;

    for(int i=1;i<=n;i++){
        j=0;
        while(j<m){
            if(mp[i][ara[j].second]==0) {
                    mx=max(mx, first[i]+last[ara[j].second]);
                    break;
            }
            else if(j>0 && last[ara[j].second]<last[ara[j-1].second]){
                break;
            }
            else {
                    mx=max(mx, first[i]+last[ara[j].second]-1);
                    ++j;
            }
        }
    }


    cout<<mx<<'\n';

}



Measured memory_bytes: 50524
#include <iostream>

using namespace std;

int N, k, ns[100000+9];
int dp[100000+9];
int main(){
    scanf("%d%d",&N,&k);
    for(int i=0;i<N;i++)scanf("%d",&ns[i]);
    dp[0]=0, dp[1]=abs(ns[0]-ns[1]);
    for(int i=2;i<N;i++){
        dp[i]=1e9;
        for(int j=max(0, i-k);j<i;j++) dp[i]=min(dp[i], dp[j]+abs(ns[i]-ns[j]));
    }
    cout<<dp[N-1]<<endl;
    return 0;
}


Measured memory_bytes: 4528
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Integer> num = new HashSet<>();
        for (int i=0; i<N; i++) {
            int di = sc.nextInt();
            num.add(di);
        }
        System.out.println(num.size());
    }
}


Measured memory_bytes: 23764
def opp(ch):
  if ch == "W": return "S"
  if ch == "S": return "W"
def test(th, nb, ans):
  if th == "S":
    if ans == "o": return nb
    if ans == "x": return opp(nb)
  if th == "W":
    if ans == "x": return nb
    if ans == "o": return opp(nb)
  
n = int(input().strip())
s = list(input())
res_list = [[x, y] for x in "SW" for y in "SW"] 
for ch in s[1:-1]:
  for res in res_list:
    res.append(test(res[-1], res[-2], ch))
    
for res in res_list:
  if test(res[-1], res[-2], s[-1]) == res[0] and test(res[0], res[-1], s[0])  == res[1]:
    print("".join(res))
    break
else:
  print(-1)   
  

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

using namespace std;
#define ll long long
int main()
{
    ll n , x , t ;
    cin>>n>>x>>t;

    if(n%x==0)
        n/=x;
    else
        n=(n/x)+1;
    cout<<n*t<<endl;
}


Measured memory_bytes: 3548
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

S = input()
K = int(input())

for s in S:
  num = int(s)
  if num == 1: K -= 1
  else: K = 0
  if K <= 0:
    print(num)
    exit()



Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll Q, H; cin >> Q >> H;
  ll S, D; cin >> S >> D;
  ll N; cin >> N;
  vector<ll> res = {
    N*S,
    (N/2) * D + (N % 2) * S,
    (N/2) * D + (N % 2) * 2*H,
    (N/2) * D + (N % 2) * 4*Q,
    2*N*H,
    4*N*Q
  };
  auto ans = boost::min_element(res);
  cout << *ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli; 
lli dp1[200005],dp2[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli temp1,temp2,m,t,x,y,b,temp,a,q,d,p,mx,n,k;
    
    
    cin>>n>>m>>k;
    
    for(int i =1;i<=n;i++)
    {
    	cin>>temp;
    	dp1[i]=dp1[i-1]+temp;
    }
    
    for(int i =1;i<=m;i++)
    {
    	cin>>temp;
    	dp2[i]=dp2[i-1]+temp;
    }
   	
   	
   	lli val1=dp1[1];
   	lli ptr=m;
   	while(dp2[ptr]+dp1[1]>k)
	{
		ptr--;
		if(ptr<0)break;
	}
   	lli count=0;
   	count=max(1+ptr,count);
   	
   	for(int i=2;i<=n;i++)
   	{
   		while(dp2[ptr]+dp1[i]>k)
   		{
   			ptr--;
   			if(ptr<0)break;
   		}
   		if(ptr<0)break;
   		
   		count=max(i+ptr,count);
   		
   	}
   	
   	val1=dp2[1];
   	ptr=n;
   	while(dp1[ptr]+dp2[1]>k)
	{
		ptr--;
		if(ptr<0)break;
	}
	
   	count=max(1+ptr,count);
   	
   	for(int i=2;i<=m;i++)
   	{
   		while(dp1[ptr]+dp2[i]>k)
   		{
   			ptr--;
   			if(ptr<0)break;
   		}
   		if(ptr<0)break;
   		
   		count=max(i+ptr,count);
   		
   	}
   	cout<<count<<endl;
}

	

Measured memory_bytes: 6716
N=int(input())
H=list(map(int,input().split()))
a=0
for i in range(N-1)[::-1]:
    if H[i]>H[i+1]:
        H[i]-=1
for i in range(N-1):
    if H[i]>H[i+1]:
        a=1
        break
if a==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;
 
signed main(){
    string S,T;
    cin>>S>>T;
 
    rep(i,S.size()){
        if(i+T.size()>S.size())break;
        string sub=S.substr(i,T.size());
        if(sub==T)cout<<i<<endl;
    }
    return 0;
}


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

int main() {

    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;

    vector<vector<int>> v(2020);
    for (int i = 0; i < N-1; ++i) {
        v[i].push_back(i+1);
        v[i+1].push_back(i);
    }
    v[X].push_back(Y);
    v[Y].push_back(X);

    vector<int> num(2020, 0);
    for (int i = 0; i < N; ++i) {
        queue<int> q;
        vector<int> visited(2020, -1);
        q.push(i);
        visited[i] = 0;
        int x;
        while(!q.empty()) {
            x = q.front();
            q.pop();
            for (int y: v[x]) {
                if (visited[y] < 0) {
                    q.push(y);
                    visited[y] = visited[x] + 1;
                    num[visited[y]]++;
                }
            }
        }
    }

    for (int i = 1; i < N; ++i) {
        cout << num[i]/2 << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int L;
    cin>>L;
    double ans=0;
    double n=L/3.0;
    ans=n*n*n;
    cout << fixed << setprecision(14);
    cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M 1000010
#define find(X, l, v) (lower_bound(X + 1, X + l + 1, v) - X)

using namespace std;

int n, A[M], B[M], V1[M], V2[M], L = 0, R, U = 0, D, tmp[M], vals[M], tmpt = 0, valt = 0;

long long BIT[M];

int get(int x)
{
	int a = A[x], b = B[x], ans = 0, C = 5e8;
	if(a == L) return 4 * C - b;
	if(a == R) return C + b;
	if(b == U) return a;
	if(b == D) return 3 * C - a;
	return -1;
}

bool cmp(int x, int y) {return V1[x] < V1[y];}

long long ask(int x)
{
	long long ans = 0;
	for(int i = x; i <= valt; i += (i & -i)) ans ^= BIT[i];
	return ans;
}

void add(int x, int v)
{
	for(int i = x; i; i -= (i & -i)) BIT[i] ^= v;
}
	
int main()
{
	scanf("%d%d%d", &R, &D, &n);
	for(int i = 1; i <= n * 2; i++) scanf("%d%d", &A[i], &B[i]);
	for(int i = 1; i <= n; i++)
		if((V1[i] = get(i * 2 - 1)) != -1 && (V2[i] = get(i * 2)) != -1) tmp[++tmpt] = i, vals[++valt] = V1[i], vals[++valt] = V2[i];
	sort(vals + 1, vals + valt + 1), unique(vals + 1, vals + valt + 1);
	for(int i = 1; i <= tmpt; i++) {
		V1[tmp[i]] = find(vals, valt, V1[tmp[i]]), V2[tmp[i]] = find(vals, valt, V2[tmp[i]]);
		if(V1[tmp[i]] > V2[tmp[i]]) swap(V1[tmp[i]], V2[tmp[i]]), swap(A[i * 2 - 1], A[i * 2]), swap(B[i * 2 - 1], B[i * 2]);
		long long s = (((((((long long)rand() % 65536) << 16) + rand() % 65536) << 16) + rand() % 65536) << 4) + rand() % 16;
		add(V1[tmp[i]], s);//!!!!!
		add(V2[tmp[i]], s);
	}
	for(int i = 1; i <= tmpt; i++) if(ask(V1[tmp[i]]) != ask(V2[tmp[i]] + 1)) return puts("NO"), 0; //!!!!!
	return puts("YES"), 0;
}

Measured memory_bytes: 16128
// AOJ 1369: Distribution Center
// 2017.11.3 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int x, y; } PP;
PP p[100002];
int l[200002], r[200002];

char buf[20], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int cmp(PP *a, PP *b) { return a->x - b->x; }

int main()
{
	int n, m, i;
	PP *pt;

	fgets(bp=buf, 20, stdin);
	n = getint(), bp++, m = getint();
	pt = p; i = m; while (i--) {
		fgets(bp=buf, 20, stdin);
		pt->x = getint(), bp++, pt->y = getint(), pt++;
	}
	qsort(p, m, sizeof(PP), cmp);
	for (i = 1; i <= n; i++) l[i] = i;
	memcpy(r, l, sizeof(int)*(n+1));

	pt = p; while (m--) {
		i = pt->y, pt++;
		l[i+1] = l[i], r[i] = r[i+1];
	}
	printf("%d", r[1]-l[1]+1);
	for (i = 2; i <= n; i++) printf(" %d", r[i]-l[i]+1);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 4108
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int a,b,c;
  cin  >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d",&a);

	b = a/1000;
	c = a%1000;

	if (c != 0) {
		b++;
	}
	b*=1000;
	printf("%d\n",b-a);
	return 0;
}




Measured memory_bytes: 1676
#include <stdio.h>
#define LL long long
LL a,v,b,w,t,x;
int main(){
	scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
	if(v==w){printf("NO\n");return 0;}
	if(a<b){
		if(a+v*t>=b+w*t)printf("YES\n");
		else printf("NO\n");
	}else{//a>b
		if(a-v*t<=b-w*t)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1648