akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int N, M;
vector<vector<int>> G; // グラフ

// メモ化再帰
int dp[100100];
int rec(int v){
	if(dp[v] != -1) return dp[v]; // 既に更新済み
	
	int res = 0;
	for (auto nv: G[v]) {
		chmax(res, rec(nv) + 1);
	}
	return dp[v] = res;	
}
int main()
{
	cin >> N >> M;
	G.assign(N, vector<int>());
	rep(i,M){
		int x, y;
		cin >> x >> y;
		--x, --y;
		G[x].push_back(y);
	}

	rep(v,N) dp[v] = -1;

	int res = 0;
	rep(v,N) chmax(res,rec(v));
	cout << res << endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll A;
  scanf("%lld", &A);

  string str;
  cin >> str;

  ll v1 = stoll(str.substr(0, 1));
  ll v2 = stoll(str.substr(2, 1));
  ll v3 = stoll(str.substr(3, 1));

  // cout << v1 << endl;
  // cout << v2 << endl;
  // cout << v3 << endl;

  ll a = 0;

  a += (A * v1) * 100;
  a += (A * v2) * 10;
  a += (A * v3) * 1;

  a = a / 100;

  cout << a << endl;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
const int INF = 1 << 30;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

class Solver {
  public:
    bool solve() {
        int H, W, K; cin >> H >> W >> K;
        vector<string> G(H); cin >> G;

        int sx = -1, sy = -1;
        rep(i, H) rep(j, W) if(G[i][j] == 'S') {
            sy = i;
            sx = j;
            goto OK;
        }
  OK:
        assert(sx >= 0 and sy >= 0);
        
        auto eval = [&](pii p) {
            return min({p.first, H - p.first - 1, p.second, W - p.second - 1});
        };
        auto div = [&](int a) {
            return a / K + (a % K != 0);
        };
        auto calc_cost = [&] (pii pos, int c) -> int {
            return div(eval(pos)) + div(c) + (pos.first == sy and pos.second == sx);
        };

        vector<vector<int>> G2(H, vector<int>(W, INF));        
        queue<pii> que;
        que.push(make_pair(sy, sx));
        G2[sy][sx] = 0;
        int ans = INF;       
        while(que.size() > 0) {            
            pii now = que.front(); que.pop();
            int cost = G2[now.first][now.second];
            set_min(ans, calc_cost(now, cost));
            rep(i, 4) {
                int nx = now.second + dx[i], ny = now.first + dy[i];
                if(0 <= ny and ny < H and 0 <= nx and nx < W) {
                    if(G2[ny][nx] == INF and G[ny][nx] == '.') {                        
                        que.push(make_pair(ny, nx));
                        G2[ny][nx] = cost + 1;
                    }
                }
            }
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 3456
import java.util.*;
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();
		if(b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<cmath>
#define MAXN 10*10*10*10*10

using namespace std;

long long a[100500];

signed main()
{
	long long n;
	scanf("%lld", &n);
	
	for (long long i=0; i<n; i++)
	{
		scanf("%lld", &a[i]);
	}
	
	long long res = a[0];
	if (res == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	
	for (long long i = 0; i<n; i++)
	{
		if (a[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	
	for (long long i = 1; i<n; i++)
	{
		if ((long long)pow(10,18)/res < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		
		res = a[i]*res;
	}
	
	printf("%lld", res);
	
	return 0;
} 


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

using namespace std;

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

    int a_sum = 0;

    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        a_sum += a;
    }
    
    if(a_sum >= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[1000005],b[1000005],sum=0;
int main()
{
	int k,n;
	cin>>k>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++)
		b[i]=a[i+1]-a[i];
	b[n]=k-a[n]+a[1];
	sort(b+1,b+n+1);
	for(int i=1;i<=n-1;i++)
		sum+=b[i];
	cout<<sum;

	return 0;
}

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

using namespace std;

int main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
  #endif
  int N;
  cin>>N;
  if(N%1000==0)
  	cout<<"0";
  else
  	cout<<(1000-(N%1000));
  return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int D;
    cin >> D;

    vi c(26);
    REP(i, 26) cin >> c[i];

    vi last(26, 0);

    vi ans(D);
    REP(i, D) {
        vll s(26);
        REP(j, 26) cin >> s[j];

        vll p(26);
        ll p_all = 0;
        REP(j, 26) {
            p[j] = c[j] * (i + 1 - last[i]);
            p_all += p[j];
        }

        REP(j, 26) {
            s[j] -= p_all - p[j];
        }

        int idx = max_element(ALL(s)) - s.begin();

        last[idx] = i + 1;
        ans[i] = idx + 1;
    }

    for(auto &e: ans) {
        print(e);
    }
    
}


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

int main(void){
    unsigned int a, b;
    int ret = -1;
    cin >> a >> b;
    for (int i = 1; i < 12500; i++){
        unsigned int tax_8 = (i * 8) / 100;
        if (a != tax_8){
            continue;
        }
        unsigned int tax_10 = (i) / 10;
        if (b != tax_10){
            continue;
        }
        ret = i;
        break;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array = new int[3];
		for (int i = 0; i < 3; i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);
		System.out.println(array[0] + " " + array[2]);
	}
}



Measured memory_bytes: 26328
#include <stdio.h>
#include <string.h>
void no(){
  printf("No");
}
int main(){
  int n,i,j,t;
  scanf("%d",&n);
  char buf[n][11];
  for(i=0;i<n;i++){
    scanf("%s\n",buf[i]);
    if(i!=0){
      t=strlen(buf[i-1]);
      if(buf[i-1][t-1]==buf[i][0]){
        for(j=0;j<i;j++){
          if (strcmp(buf[j],buf[i])==0){
            no();
            return 0;
          }
        }
      }
      else{
        no();
        return 0;
      }
    }
  }
  printf("Yes");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>

#define MOD 1000000007

int main()
{
    ll N;
    INX(N);

    vll A(N);
    for (ll i = 0; i < N; i++)
    {
        INX(A[i]);
    }

    ll result = 0;
    ll tmp = A[N - 1];
    for (ll i = N - 2; i >= 0; i--)
    {
        result += A[i] * tmp;
        result %= MOD;
        tmp += A[i];
        tmp %= MOD;
    }
    OUTX(result);    


    return 0;
}


Measured memory_bytes: 4836
fn main() {
    let mut sc = new(std::io::stdin());
    let a:usize = sc.next();
    let b:usize = sc.next();
    let c:usize = sc.next();
    let d:usize = sc.next();
    let e:usize = sc.next();
    let f:usize = sc.next();

    let mut water = vec![false; 3010];
    for i in 0..3010 {
        for j in 0..3010 {
            let v = i * a * 100 + j * b * 100;
            if v < 3010 {
                water[v] = true;
            }
        }
    }
    let mut sugar = vec![false; 3010];
    for i in 0..3010 {
        for j in 0..3010 {
            let v = i * c + j * d;
            if v < 3010 {
                sugar[v] = true;
            }
        }
    }
    let mut best = 0.0;
    let mut bestTot = 0;
    let mut bestSugar = 0;
    for i in 0..3010 {
        for j in 0..3010 {
            if (i > 0 || j > 0) && water[i] && sugar[j] {
                if i + j <= f && (100 + e) * j <= e * (i + j) {
                    let d = j as f64 / (i + j) as f64;
                    if d >= best {
                        best = d;
                        bestTot = i + j;
                        bestSugar = j;
                    }
                }
            }
        }
    }
    println!("{} {}", bestTot, bestSugar);
}

use std::io;
use std::io::BufRead;

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

pub fn new<R: io::Read>(r: R) -> Scanner<R> {
    Scanner::new(r)
}

impl<R: io::Read> Scanner<R> {
    #[inline]
    fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: ")).unwrap()
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '2')ans++;
	}
	print(ans);




	return 0;
}

Measured memory_bytes: 256
s = input()
mod = 10 ** 9 + 7
memo = [0] * (len(s) + 1)
memo[0] = 1
dp = [[0 for _ in range(13)] for __ in range(len(s) + 1)]
dp[0][0] = 1
for i, si in enumerate(s[::-1]):
    memo[i+1] = memo[i] * 10 % 13
    if si == '?':
        for n in range(10):
            a = n * memo[i]
            for j in range(13):
                dp[i+1][(j + a) % 13] = (dp[i+1][(j + a) % 13] + dp[i][j]) % mod
    else:
        a = int(si) * memo[i]
        for j in range(13):
            dp[i+1][(j + a) % 13] = (dp[i+1][(j + a) % 13] + dp[i][j]) % mod
print(dp[len(s)][5])


Measured memory_bytes: 69376
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] p = new long[n+1];
        long[] ruip = new long[n+1];
        for(int i = 1; i <= n; i++){
            p[i] = sc.nextLong();
            ruip[i] += p[i] + ruip[i-1];  
        }
        long tmp = 0;
        int index = 0;
        for(int i = k; i <= n; i++){
            if(tmp < ruip[i] - ruip[i-k]){
                tmp = ruip[i] - ruip[i-k];
                index = i;
            }
        }
        double ans = 0;
        for(int i = index; i >= index-(k-1); i--){
            ans += calc(p[i]);
        }
        System.out.println(ans);
    }

    public static double calc(long a){
        return 1+(a-1)*0.5;
    }
}

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

int main() {

  string a, b, c;
  cin>> a >> b >> c;
  
  int x=a.size();
  int y=b.size();
  
  if(a.at(x-1)==b.at(0)&&b.at(y-1)==c.at(0)){
    cout <<"YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define dbug printf("I am here\n");
    #define Fast ios_base::sync_with_stdio(false); cin.tie(0);
    #define vs            v.size()
    #define ss             s.size()
    #define be            v.begin(),v.end()
    #define pii             pair<int,int>
    #define ll               long long
    #define pb             push_back
    #define mpp            make_pair
    using namespace std;

   int main(){
       
    ll int a,b,c,d,n,k;
    int tst;
    string s,s1;
    cin>>s>>s1;
    int cnt = 0;
    for(int i = 0;i<ss;i++){
        if(s[i] != s1[i]) cnt ++;
    }
    cout<<cnt<<endl;
    return 0 ;
}


Measured memory_bytes: 3912
import sys
import timeit


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def main():
    c = LIR(3)
    a = [0] * 3
    b = [0] * 3
    ans = 'No'
    for i in range(101):
        a[0] = i
        b[0] = c[0][0] - a[0]
        for j in range(101):
            a[1] = j
            b[1] = c[1][1] - a[1]
            for k in range(101):
                a[2] = k
                b[2] = c[2][2] - a[2]
                current = [[a[i] + b[j] for j in range(3)] for i in range(3)]
                if c == current:
                    ans = 'Yes'
                    break
    print(ans)


# res = timeit.timeit('main()', globals=globals(), number=1)
# print(res / 1)
main()


Measured memory_bytes: 9296
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

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

    double mkaku = m * 6;
    double hkaku = h * 30 + m * 0.5;

    mkaku = mkaku * PI / 180.0;
    hkaku = hkaku * PI / 180.0;

    if (mkaku == hkaku)
    {
        cout << abs(a - b) << endl;
        return 0;
    }

    double min_kaku = INT_INF;
    if (mkaku >= hkaku)
    {
        min_kaku = min(min_kaku, mkaku - hkaku);
        min_kaku = min(min_kaku, 360 - mkaku + hkaku);
    }
    else
    {
        min_kaku = min(min_kaku, hkaku - mkaku);
        min_kaku = min(min_kaku, 360 - hkaku + mkaku);
    }

    double ans;
    ans = (a * a) + (b * b) - (2 * a * b * cos(min_kaku));
    ans = sqrt(ans);

    printf("%.9lf\n", ans);
    return 0;
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 1005;

int n;
string s[MAXN];
int dist[MAXN][18];
bool nxt_short[MAXN][18][18];
vector<int> nxt_long[MAXN][18];

struct node{
	int x, y, d;
	bool operator<(const node &n)const{
		return d> n.d;
	}
};

priority_queue<node> pq;

void enq(int x, int y, int d){
	if(dist[x][y] > d){
		dist[x][y] = d;
		pq.push({x, y, d});
	}
}

void dijkstra(){
	for(int i=0; i<n; i++){
		for(int j=0; j<i; j++){
			if(s[i].substr(0, sz(s[j])) == s[j]){
				enq(i, sz(s[i]) - sz(s[j]), sz(s[j]));
			}
		}
	}
	while(sz(pq)){
		auto x = pq.top();
		pq.pop();
		if(x.y == 0){
			cout << x.d << endl;
			return;
		}
		for(int i=1; i<=x.y; i++){
			if(nxt_short[x.x][x.y][i]){
				enq(x.x, x.y - i, x.d + i);
			}
		}
		for(auto &k : nxt_long[x.x][x.y]){
			enq(k, sz(s[k]) - x.y, x.y + x.d);
		}
	}
	puts("0");
}

int main(){
	cin >> n;
	for(int i=0; i<n; i++) cin >> s[i];
	sort(s, s + n, [&](const string &x, const string &y){
		return sz(x) < sz(y);
	});
	for(int i=0; i<n; i++){
		for(int j=1; j<=sz(s[i]); j++){
			string x = s[i].substr(sz(s[i]) - j, j);
			for(int k=0; k<n; k++){
				if(sz(s[k]) <= sz(x) && x.substr(0, sz(s[k])) == s[k]){
					nxt_short[i][j][sz(s[k])] = 1;
				}
				if(sz(s[k]) > sz(x) && s[k].substr(0, sz(x)) == x){
					nxt_long[i][j].push_back(k);
				}
			}
		}
	}
	memset(dist, 0x3f, sizeof(dist));
	dijkstra();
}



Measured memory_bytes: 9840
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;
#define fi first
#define se second
 
int uf[256];
int rk[256];
 
void uf_init() {
    for(int i = 0; i < 256; i++) {
        uf[i] = i;
        rk[i] = 0;
    }
}
 
int uf_find(int x) {
    if(uf[x] == x)
        return x;
    return uf[x] = uf_find(uf[x]);
}
 
bool uf_same(int a, int b) {
    return uf_find(a) == uf_find(b);
}
 
void uf_merge(int a, int b) {
    int aa, bb;
    aa = uf_find(a);
    bb = uf_find(b);
    if(aa == bb)
        return;
    if(rk[aa] < rk[bb]) {
        uf[aa] = bb;
    }
    else {
        if(rk[aa] == rk[bb])
            rk[aa]++;
        uf[bb] = aa;
    }
}
 
struct edge {
    pii p; // ?????¢
    ll b; // ????????????
    ll c; // ?????????
};
 
bool cost_cmp(const edge & a, const edge & b) {
    return a.c < b.c;
}
bool time_cmp(const edge & a, const edge & b) {
    return a.b < b.b;
}
 
int main() {
    int N, M;
    while(cin >> N >> M, N || M) {
        vector<pii> h;
        vector<edge> eg;
        h.resize(N);
        for(int i = 0; i < N; i++) {
            cin >> h[i].fi;
            h[i].se = i;
        }
        for(int i = 0; i < M; i++) {
            int a, b, c;
            edge e;
            cin >> a >> b >> c;
            a--; b--;
            if(a > b) swap(a,b);
            e.p = pii(a,b);
            e.b = min(h[a].fi, h[b].fi);
            e.c = c;
            eg.push_back(e);
        }
        sort(eg.begin(), eg.end(), time_cmp);
        sort(h.begin(), h.end());
 
        int T = -1;
        for(int i = 0; i < h.size(); i++) {
            uf_init();
            for(int j = 0; j < eg.size(); j++) {
                if(eg[j].b < h[i].fi)
                    continue;
                edge e;
                e = eg[j];
                uf_merge(e.p.fi, e.p.se);
            }
            bool flg = true;
            int tmp = uf_find(h[i].se);
            for(int j = i; j < h.size(); j++) {
                if(tmp != uf_find(h[j].se))
                    flg = false;
            }
            if(flg == false) {
                break;
            }
            T = h[i].fi;
            while(i < h.size()-1 && h[i].fi == h[i+1].fi) i++;
        }
        ll res = 0;
        uf_init();
        while(T >= 0) {
            vector<edge> v;
            ll nex_t = -1;
            for(int i = 0; i < eg.size(); i++) {
                if(T <= eg[i].b)
                    v.push_back(eg[i]);
                else
                    nex_t = max(nex_t, eg[i].b);
            }
            sort(v.begin(), v.end(), cost_cmp);
            for(int i = 0; i < v.size(); i++) {
                edge e = v[i];
                if(!uf_same(e.p.fi, e.p.se)) {
                    res += e.c;
                    uf_merge(e.p.fi, e.p.se);
                }
            }
            T = nex_t;
        }
        cout << res << endl;
    }
}

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

int main()
{
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        if(floor((double)i * 1.08) == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=5e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  string s;
  cin>>s;
  if(s=="RRR") cout<<"3"<<endl;
  else if(s=="RRS" || s=="SRR") cout<<"2"<<endl;
  else if(s=="SSS") cout<<"0"<<endl;
  else cout<<"1"<<endl;
  return 0;
}


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

int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        if(i*108/100 == n){
            printf("%d\n", i);
            return 0;
        }
    }
    printf(":(\n");
}

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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}

Measured memory_bytes: 3624
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

N = int(input())
ans = 0
for m in range(10):
    for s in it.product("753", repeat=m):
        dump(s)
        if '3' in s and '5' in s and '7' in s and int("".join(s)) <= N:
            ans += 1
print(ans)


Measured memory_bytes: 43376
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

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

int main(){
  int h, w;cin>>h>>w;
  int cnt=0;
  vector<vector<char>> field(h, vector<char>(w));
  rep(i, h){
  	rep(j, w){
      char c;cin>>c;
      if(c=='.')cnt++;
      field[i][j]=c;
    }
  }
  int ans=0;
  char mark[] = {'*', '-'};
  field[0][0]=mark[0];
  while(true){
    ans++;
    bool updated=false;
  	rep(i, h){
      rep(j, w){
      	if(field[i][j]==mark[(ans+1)&1]){
          rep(k, 4){
          	int nx=i+dx[k], ny=j+dy[k];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&field[nx][ny]=='.'){
              field[nx][ny]=mark[ans&1];
              updated=true;
            }
          }
          field[i][j]='#';
        }
      }
    }
    if(field[h-1][w-1]!='.')break;
    if(!updated){ans=-1;break;}
  }
  if(ans==-1)cout<<-1<<endl;
  else cout<<cnt-(ans+1)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int a,b,s,d;

while(scanf("%d %d",&a,&b)!=EOF){

s=a+b;
d=0;
while(!(s<1)){
  s=s/10;
  d++;
}
printf("%d\n",d);
}
return 0;
}

Measured memory_bytes: 596
K,A,B = gets.split.map(&:to_i)

if (B-A)/2 <= 1

    puts (1+K)

    

else

    if K < A

        puts (1+K)

    else
        
        n = (K-(A+1))/2

        if (K-(A+1)) % 2 == 0

            puts (B+n*(B-A))

        else

            puts (B+n*(B-A)+1)

        end


    end

end


Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007

#define MAX_N (1<<18)

int N, Q, A, B;
struct SegTree {
  int seg[MAX_N*2-1];
  int adds;
  SegTree() {
    for (int i=0; i<MAX_N*2-1; i++) seg[i] = INF;
    adds = 0;
  }

  void update(int i, int x) {
    i += MAX_N-1;
    x -= adds;
    if (seg[i] <= x) return;
    seg[i] = x;
    while (i > 0) {
      i = (i-1) / 2;
      seg[i] = min(seg[i*2+1], seg[i*2+2]);
    }
  }
  int query(int a, int b, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return seg[k] + adds;
    return min(
      query(a, b, k*2+1, l, (l+r)/2),
      query(a, b, k*2+2, (l+r)/2, r)
    );
  }

  void add_all(int x) {
    adds += x;
  }
};

SegTree f, g;
int X[200001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Q >> A >> B;
  A--, B--;
  X[0] = B;
  rep(i, Q) {
    cin >> X[i+1];
    X[i+1]--;
  }

  f.update(A, -A);
  g.update(A, +A);

  rep(i, Q) {
    int to_add = abs(X[i+1] - X[i]);

    int v = INF;
    v = min(v, f.query(0, X[i+1]+1) + X[i+1]);
    v = min(v, g.query(X[i+1], N) - X[i+1]);

    f.add_all(to_add);
    g.add_all(to_add);
    f.update(X[i], v - X[i]);
    g.update(X[i], v + X[i]);
  }

  int m = INF;
  rep(i, N) {
    m = min(m, f.query(i, i+1) + i);
    m = min(m, g.query(i, i+1) - i);
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline A abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;cin >>x;
  if(x) cout <<"0\n";
  else cout <<"1\n";

  return(0);
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		String w = sc.nextLine();


		int count =0;
		while (true) {
			String ti = sc.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			if ( ti.equalsIgnoreCase(w) ) count++;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 26072
def examA():
    S = SI()
    T = SI()
    if S==T[:len(S)]:
        if len(S)+1==len(T):
            print("Yes")
            return
    print("No")
    return

def examB():
    A, B, C, K = LI()
    ans = 0
    if A>=K:
        ans = K
    else:
        ans += A
        K -= A
        if K>B:
            K -= B
            ans -= K
    print(ans)
    return

def examC():
    N, M, X = LI()
    C = [LI()for _ in range(N)]
    loop = 2**N
    ans = inf
    for l in range(loop):
        cur = 0
        A = [0]*M
        for j in range(N):
            if (1<<j)&l>0:
                cur += C[j][0]
                for k in range(M):
                    A[k] += C[j][k+1]
        flag = True
        for i in range(M):
            if A[i]<X:
                flag = False
                break
        if flag:
            ans = min(ans,cur)
    if ans==inf:
        print(-1)
        return
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
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,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 78416
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

lli dp[51][51][21][28];
bool used[51][51][21][28] = {};
int s[50][20] = {};
//s[l]~s[r-1]の位置posの値が全てval以上である
lli solve(int l, int r, int pos, int val){
	lli &ret = dp[l][r][pos][val];
	if(used[l][r][pos][val]) return ret;
	used[l][r][pos][val] = true;
	if(l == r || (r-l==1 && pos >= 20)){
		ret = 1;
		return ret;
	}
	if(val == 27 || pos >= 20){
		ret = 0;
		return ret;
	}

	ret = 0;
	//val と val以上 に分割
	for(int i=l; i<=r; i++){
		if(i != l){
			//前半はちょうどvalのみ
			if(!(s[i-1][pos]==val || s[i-1][pos]=='?')) break;
			//?は空白にはなれない
			if(val==0 && s[i-1][pos]=='?') break; 
		}
		ret += solve(l, i, pos+1, 0) *solve(i, r, pos, val+1) %mod;
	}
	ret %= mod;
	return ret;
}

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		string str;
		cin >> str;
		for(int j=0; j<20; j++){
			s[i][j] = 0;
		}
		for(int j=0; j<(int)str.length(); j++){
			if(str[j] == '?') s[i][j] = '?';
			else s[i][j] = str[j] -'a'+1;
		}
	}
	cout << solve(0, n, 0, 0) << endl;
	return 0;
}


Measured memory_bytes: 10384
from math import log2,ceil
def main():
    A,B,C=map(int,input().split())
    K=int(input())
    if A<B<C:
        print("Yes")
    else:
        op=0
        if B<=A:
            val=ceil(log2(A/B))
            op+=val
            B<<=val
            if B==A:
                B*=2
                op+=1
        if C<=B:
            val=ceil(log2(B/C))
            op+=val
            C<<=val
            if C==B:
                C*=2
                op+=1
        if op<=K:
            print("Yes")
        else:
            print("No")
if __name__=='__main__':
    main()

Measured memory_bytes: 62460
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]
N = n*(n-1)//2
index = [[0]*(n) for i in range(n)]
ind = 0
from collections import defaultdict
ns = [[] for _ in range(N)]
for i in range(n):
    for j in range(i+1,n):
        index[i][j] = ind
        index[j][i] = ind
        ind += 1
for i in range(n):
    for j in range(n-2):
        u = index[i][a[i][j]]
        v = index[i][a[i][j+1]]
        ns[u].append(v)
### サイクル検出 cycle detection
seen = [False] * N
done = [False] * N
vals = [None] * N
def dfs(u):
    s = [u]
    while s:
        u = s.pop()
        if u>=0:
            # 非負の値: 新しい頂点に到達
            seen[u] = True
            s.append(~u)
            for v in ns[u]:
                if done[v]:
                    continue
                elif not seen[v]:
                    s.append(v)
                else:
                    # 閉路発見
                    return True
        else:
            u = ~u
            done[u] = True
            # ここに帰りがけ処理を書く
            val = 0
            for v in ns[u]:
                # uの子はすべて処理が終わっている
                val = max(val, vals[v]+1)
            vals[u] = val
    return False

ans = -float("inf")
for u in range(N):
    if seen[u]:
        continue
    pos = dfs(u)
    if pos:
        print(-1)
        break
else:
    print(max(vals)+1)

Measured memory_bytes: 167764
class Player
  attr_accessor :hp, :at, :win
  def initialize(hp,at)
    @hp = hp
    @at = at
    @win = false
  end
  def attack(aite)
    aite.hp -= @at
    @win = true if aite.hp <= 0
  end
  def win?
    @win
  end
end

a,b,c,d = gets.chomp.split.map &:to_i
takahashi = Player.new(a,b)
aoki = Player.new(c,d)

cnt = 1
while takahashi.hp > 0 && aoki.hp >0
  takahashi.attack(aoki) if cnt.odd?
  aoki.attack(takahashi) if cnt.even?
  cnt += 1
end

print "Yes" if takahashi.win?
print "No" if aoki.win?


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

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

const int N = 1e5 + 5;

int cnt[N];

int32_t main()
{
    IOS
    int n;
    cin >> n;
    int sm = 0;
    for(int i = 0; i < n; i++)
    {
    	int x;
    	cin >> x;
    	cnt[x]++;
    	sm += x;
    }
    int q;
    cin >> q;
    while(q--)
    {
    	int b, c;
    	cin >> b >> c;
    	sm -= b * cnt[b];
    	sm += c * cnt[b];
    	cnt[c] += cnt[b];
    	cnt[b] = 0;
    	cout << sm << endl;
    }
    return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> g[n + 1];
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<bool> visit(n + 1);
    vector<int> paraent(n + 1);
    queue<int> q;
    q.push(1);
    visit[1] = 1;
    while (!q.empty())
    {
        int cur = q.front();
        q.pop();
        for (auto x : g[cur])
        {
            if (!visit[x])
            {
                visit[x] = 1;
                q.push(x);
                paraent[x] = cur;
            }
        }
    }
    cout << "Yes\n";
    for (int i = 2; i <= n; i++)
        cout << paraent[i] << endl;
}

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

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

ll N, M, T;

//ll A[50001/64 + 1][50001];
ll A[50001][50001/64 + 1];
int B[50001], cnt[50001];

int detect_ok(){ 
    rep(k, N/64 + 1){
        ll total = 0xffffffffffffffffLL;
        rep(i, N){
            //total &= A[k][i];
            total &= A[i][k];
        }
        rep(j, 64){
            if (total & (1LL << j)){
                return k * 64 + j;
            }
        }
    }
    return -1;
}

int main()
{
    cin >> N >> M >> T;
    vector<ll> X(M), Y(M);
    
    rep(i, M){
        ll x, y;
        cin >> x >> y;
        X[M - 1 - i] = x - 1;
        Y[M - 1 - i] = y - 1;
    }
    
    if (T == 1){
        
        //rep(i, N)A[i/64][i] = 1LL << (i%64);
        rep(i, N)A[i][i/64] = 1LL << (i%64);
        
        
        rep(i, M){
            ll x = X[i];
            ll y = Y[i];
            rep(k, N/64 + 1){
                //A[k][x] = A[k][x] | A[k][y];
                //A[k][y] = A[k][x];
                A[x][k] = A[x][k] | A[y][k];
                A[y][k] = A[x][k];

            }
        }
        //rep(i, N)
        //fprintf(stderr, "A[0][%d] = %d\n", i, A[0][i]);
        int res = detect_ok();
        if (res == -1){
            cout << -1;
            return 0;
        }
        string str = "";
        B[res] = 1;
        rep(i, M){
            ll x = X[i];
            ll y = Y[i];
            if (B[x] == 0){
                str += "v";
            } else {
                str += "^";
            }
            if (B[x] + B[y])B[x] = B[y] = 1;
        }
        reverse(str.begin(), str.end());
        cout << str;
        return 0;
    } 
    // T = 2;
    if (N == 2){
        cout << -1;
        return 0;
    }
    rep(i, N){
        B[i] = i;
        cnt[i]++;
    }
    string str = "";
    rep(i, M){
        ll x = X[i];
        ll y = Y[i];
        if (cnt[B[x]] >= 2){
            str += "v";
            cnt[B[x]]--;
            cnt[B[y]]++;
            B[x] = B[y];
        } else {
            str += "^";
            cnt[B[x]]++;
            cnt[B[y]]--;
            B[y] = B[x];
        }
    }
    reverse(str.begin(), str.end());
    cout << str;
        
    return 0;
}


Measured memory_bytes: 307840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll h;
  cin >> h;
  ll m;
  cin >> m;

  double hr = 360.0 / 720.0 * (h*60+m);
  double mr = 360.0 / 60 * m;
  double r = abs(hr - mr) / 180.0 * M_PI;

  printf("%.20lf\n", sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(r)));

  return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  if (fopen(Task".in", "r")){
    freopen(Task".in", "r", stdin);
    freopen(Task".out", "w", stdout);
  }
  int a, b, c; cin >> a >> b >> c;
  int res = max({a, b, c});
  while (1){
    if ((3 * res - a - b - c) % 2 == 0){
      cout << (3 * res - a - b - c) / 2;
      return 0;
    }
    ++res;
  }
}


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

int main()
{
    int stnum;
    char t;
    double w,h;
    list<int> himan;
    while(cin >> stnum >> t >> w>>t>>h)
    {
        if(w/h/h >= 25)
            himan.push_back(stnum);
    }
    if(himan.size()==0)cout << "ツ該ツ督鳴づ按つオ"<<endl;
    else
    {
        for(list<int>::iterator it=himan.begin();it!=himan.end();++it)
        {
            cout << *it<< endl;
        }

    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    string s;
    cin >> s;
    if(s=="Sunny")
    cout << "Cloudy" << endl;
    if(s=="Cloudy")
    cout << "Rainy" << endl;
    if(s=="Rainy")
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
class JNum{
	static constexpr uint64_t mod = 1000000007;
	uint64_t num;
public:
	JNum(uint64_t x):num(x%mod){}
	JNum operator+(const JNum& j)const{
		return (num + j.num)%mod;
	}
	JNum operator*(const JNum& j)const{
		return (num * j.num)%mod;
	}
	void operator+=(const JNum& j){
		num += j.num;
		num %= mod;
	}
	void operator*=(const JNum& j){
		num *= j.num;
		num %=mod;
	}
	uint64_t out()const{return num;}
};
using namespace std;
template<typename T>
void get(T& t){cin >> t;}
int main(void){
	int W,H;
	get(H);get(W);
	int cnt[26] = {0};
	for(int i=0;i<H;i++){
		string s;
		get(s);
		for(char c:s)cnt[c - 'a']++;
	}
	int jouyo[3] = {0};
	for(int i=0;i<26;i++){
		if(cnt[i]%4==0)jouyo[0]++;
		else if(cnt[i]%2==0)jouyo[2]++;
		else jouyo[1]++;
	}
	bool ok;
	if(W%2==0 && H%2==0){
		ok = jouyo[1] + jouyo[2]==0;
	}
	else if(W%2==0){
		ok = jouyo[1]==0 && jouyo[2] <= W/2;
	}
	else if(H%2==0){
		ok = jouyo[1]==0 && jouyo[2] <= H/2;
	}
	else{
		ok =jouyo[1]<=1 && jouyo[2] <= W/2 + H/2;
	}
	if(ok)cout << "Yes"<<endl;
	else cout << "No"<<endl;
	return 0;
}


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

LL A,B,C,D,N;

int main()
{
#ifdef h10
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
#endif
	scanf("%lld%lld%lld%lld%lld",&A,&B,&C,&D,&N);
	C=min(C,A<<2);
	C=min(C,B<<1);
	printf("%lld\n",min((N>>1)*D+(N&1)*C,N*C));
}


Measured memory_bytes: 256
x, a=map(int,input().split())
y, b=map(int,input().split())
z, c=map(int,input().split())
r, d=map(int,input().split())

if x==2 or  x==4:
    t=8000//x*a
    print(t)
elif x==1:
    t=6000*a
    print(t)

else:
    t=3000*a
    print(t)
    
if y==2 or  y==4:
    t=8000//y*b
    print(t)
elif y==1:
    t=6000*b
    print(t)

else:
    t=3000*b
    print(t)
    
if z==2 or  z==4:
    t=8000//z*c
    print(t)
elif z==1:
    t=6000*c
    print(t)

else:
    t=3000*c
    print(t)
    

if r==2 or  r==4:
    t=8000//r*d
    print(t)
elif r==1:
    t=6000*d
    print(t)

else:
    t=3000*d
    print(t)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, sum =0;
    cin >> N;

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

    for (int i = 0; i < N; i++){
        for (int j = i+1; j < N; j++){
            sum += d[i] * d[j];
        }
    }

    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

bool is_left_ok(ll i, std::string& s, std::vector< std::pair<char, ll> >& vq)
{
  for (auto q : vq) {
    if (s[i] == q.first) i += q.second;
    if (i < 0) return true;
    if (i >= (ll)s.size()) return false;
  }

  return false;
}

bool is_right_ok(ll i, std::string& s, std::vector< std::pair<char, ll> >& vq)
{
  for (auto q : vq) {
    if (s[i] == q.first) i += q.second;
    if (i < 0) return false;
    if (i >= (ll)s.size()) return true;
  }

  return false;
}


int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  //std::ifstream ifs("input.def");
  //std::cin.rdbuf(ifs.rdbuf());

  ll N, Q;
  std::cin >> N >> Q;

  std::string s;
  std::cin >> s;

  std::vector< std::pair<char, ll> > vq(Q);
  for (ll i = 0; i < Q; i++) {
    char t, d;
    std::cin >> t >> d;
    vq[i].first = t;
    vq[i].second = d == 'L' ? -1 : +1;
  }

  ll ok = -1;
  ll ng = N;
  while (ng - ok > 1) {
    ll mid = (ok + ng) / 2;
    if (is_left_ok(mid, s, vq)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  ll left = ok;

  ng = -1;
  ok = N;
  while (ok - ng > 1) {
    ll mid = (ok + ng) / 2;
    if (is_right_ok(mid, s, vq)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  ll right = ok;

  ll sum = std::max(0LL, right - (left + 1));
  print(sum);

  return 0;
}


Measured memory_bytes: 3732
m = int(input())
s = list(map(int,input().split()))
s_max = 0
count = 0

for i in range(m-1):
    if s[i] >= s[i+1]:
        count = count + 1
    else:
        count = 0
    
    if count > s_max:
        s_max = s_max + 1

print(s_max)


Measured memory_bytes: 14224
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[10010], b[10010];
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    ll margin = 0;
    ll need = 0;
    rep(i, N) {
        if(a[i] < b[i]) margin += (b[i] - a[i]) / 2;
        if(b[i] < a[i]) need += (a[i] - b[i]);
    }
    //cout << margin << " " << need << endl;
    if(margin >= need) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3700