akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] f = new int[n][10];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                f[i][j] = sc.nextInt();
            }
        }
        int[][] p = new int[n][11];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 11; j++) {
                p[i][j] = sc.nextInt();
            }
        }
        long ans = Long.MIN_VALUE;
        for (int i = 1; i < 1<<10; i++) {
            int[] c = new int[n];
            for (int j = 0; j < 10; j++) {
                if((i >> j & 1) == 1){
                    for (int k = 0; k < n; k++) {
                        if(f[k][j] == 1) c[k]++;
                    }
                }
            }
            long tmp = 0;
            for(int l = 0; l < n; l++) tmp += p[l][c[l]];
            ans = Math.max(ans, tmp);
        }

        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 27812
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	int n_even = n / 2;
	double p = 1.0 * (n - n_even) / n;

	printf("%.9f\n", p);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
P = input().split()
P = [int(i) for i in P]
Q = input().split()
Q = [int(i) for i in Q]

Nlist = [i+1 for i in range(N)]
k = 1
for i in range(N-1):
  k = k * (i+1)
count = 1
for i in range(N):
  n = Nlist.index(P[i])
#  print('n = ', n)
#  print('k = ', k)
  count = n * k + count
  Nlist.remove(P[i])
  if i == N-1:
    break
  else:
    k = k / (N-(i+1))

    
    
Nlist2 = [i+1 for i in range(N)]
k2 = 1
for i in range(N-1):
  k2 = k2 * (i+1)
count2 = 1
for i in range(N):
  n2 = Nlist2.index(Q[i])
#  print('n = ', n2)
#  print('k = ', k2)
  count2 = n2 * k2 + count2
  Nlist2.remove(Q[i])
  if i == N-1:
    break
  else:
    k2 = k2 / (N-(i+1))

#print('count = ', count)
#print('count2 = ', count2)


if count >= count2:
  print(int(count - count2))
if count < count2:
  print(int(count2 - count))


#print('N = ', N)
#print('P = ', P)
#print('Q = ', Q)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047


void solve(){
	int a, b; cin >> a >> b;
	string s; cin >> s;
	
	FOR(i, 0, a + b + 1){
		if (i == a && s[i] != '-'){
			cout << "No\n";
			return;
		}
		else if (i != a && s[i] == '-'){
			cout << "No\n";
			return;
		}
	}
	
	cout << "Yes\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	solve();
	
	return 0;
}


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

int main(){
	int N,M;
	long long K;
	cin >> N >> M >> K;
	vector<long long> A(N),B(M);
	for(auto &i:A)cin >> i;
	for(auto &i:B)cin >> i;
	
	vector<long long> Asum(N+1,0),Bsum(M+1,0);
	for(int i=0;i<N;i++)Asum[i+1]=Asum[i]+A[i];
	for(int i=0;i<M;i++)Bsum[i+1]=Bsum[i]+B[i];
	
	int ans=0;
	for(int i=0;i<=N && Asum[i]<=K;i++){
		int tmp=i;
		auto it=upper_bound(Bsum.begin(),Bsum.end(),K-Asum[i]);
		tmp+=(it-Bsum.begin())-1;
		ans=max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  string s;
  int k;
  cin >> s;
  cin >> k;

  string ans = "1";
  for(int i=0; i<k; i++) {
    if(s[i] != '1') {
      ans = s[i];
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define st first
#define	se second
#define mkp make_pair
struct cmp
{
	bool operator()(const pii & a, const pii & b)
	{
		return a.second > b.second;
	}
};
const int maxn = 2e5+5;
std::vector<int> vv[maxn];
int val[maxn];
int ans[maxn];
std::vector<int> v;
int getid(int x)
{
	return lower_bound(v.begin(),v.end(),x) - v.begin() + 1;
}

struct Node
{
	int l,r,num;
}node[maxn << 2];
void build(int l,int r,int no)
{
	node[no].l = l;
	node[no].r = r;
	node[no].num = 0;
	if(l == r)
		return;
	int mid = l + r >> 1;
	build(l,mid,no<<1);
	build(mid + 1, r, no<<1|1);
}

void update(int x,int no,int num)
{
	if(node[no].l > x || node[no].r < x)
		return;
	if(node[no].l == node[no].r)
	{
		node[no].num = num;
		return;
	}
	update(x,no<<1,num);
	update(x,no<<1|1,num);
	node[no].num = max(node[no<<1].num,node[no<<1|1].num);
}


int query(int l,int r,int no)
{
	if(l > r)
		return 0;
	if(node[no].l > r || node[no].r < l)
		return 0;
	if(node[no].l >= l && node[no].r <= r)
		return node[no].num;
	return max(query(l,r,no<<1),query(l,r,no<<1|1));
}

void dfs(int x,int fa)
{
	int per = query(val[x],val[x],1);//记一个之前的值 因为算完了这个子树 要把值改回去
	int s = query(1,val[x] - 1,1);
	ans[x] = max(s + 1, ans[fa]);
	update(val[x],1,s +1);
	for (int i = 0; i < vv[x].size(); i ++ )
	{
		int v = vv[x][i];
		if(v == fa)
			continue;
		dfs(v,x);
	}
	update(val[x],1,per);
}

int main()
{
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i ++ )
	{
		scanf("%d",&val[i]);
		v.push_back(val[i]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for (int i= 1; i < n; i ++ )
	{
		int x,y;
		scanf("%d%d",&x,&y);
		vv[x].push_back(y);
		vv[y].push_back(x);
	}
	int m = v.size();
	build(1,m,1);
	for (int i = 1; i <= n; i ++ )
	{
		val[i] = getid(val[i]);
	}
	dfs(1,0);
	for (int i = 1; i <= n; i ++ )
	{
		printf("%d ",ans[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 29840
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	int *count = new int[10]();
	count[a]++;
	count[b]++;
	count[c]++;
	if(count[a] == 2 || count[b] == 2 || count[c] == 2)
		cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
// vim: foldmethod=marker
#include <iostream> // cout, endl, cin{{{
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
typedef long long ll;/*}}}*/

int main(int argc, char *argv[])
{
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
}


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

const int M = 998244353;
const int N  = 4005;

LL C[N][N];
LL p2[N];

void pre()
{
    for (int i=0; i<N; i++)     C[i][0] = 1;
    for (int i=1; i<N; i++)
        for (int j=1; j<N; j++)
            C[i][j] = (C[i-1][j-1] + C[i-1][j])%M;

    p2[0] = 1;
    for (int i=1; i<N; i++)
        p2[i] = (2*p2[i-1])%M;
}

LL f(int n, int single, int pairs) {
    int mx = single + pairs;
    LL ans = 0;

    for (int p=0; p<=pairs; p++) {
        LL choosepairs = (p2[p] * C[pairs][p])%M;
        LL ways = C[n+single-1][p+single-1];
        ans = (ans + choosepairs*ways)%M;
    }
    return ans;
}

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

    for (int x=2; x<=2*k; x++) {
        int pairs = 0;
        for (int i=1; i<=k; i++)
            if (i<x-i && x-i<=k)    pairs++;
        int single = k-2*pairs;
        if (x%2) cout<<f(n, single, pairs)<<endl;
        else     cout<<(f(n-1, single-1, pairs) + f(n, single-1,pairs))%M<<endl;
    }
}


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

int main()
{
    int N,M;
    cin>>N>>M;
    
    vector<vector<int>> a(M,vector<int>(2));
    
    for(int i= 0;i<M;i++)
    {
        int t,b;
        cin >> t>>b;
        t--;
        b--;
        a[i][0] = t;
        a[i][1] = b;
    }
    
    vector<int> ans(N,0);
    vector<int> ball(N,1);
    ans[0] = 1;
    for(int i=0;i<M;i++)
    {
        ball[a[i][0]] --;
        ball[a[i][1]] ++;
        if(ans[a[i][0]]>0)
        {
            ans[a[i][1]]++;
        }
        if(ball[a[i][0]] == 0)
        {
            ans[a[i][0]]=0;
        }
        
    }
    
    
    int k = 0;
    for(int i=0;i<N;i++)
    {
        if(ans[i] > 0)
        {
            k++;
        }
    }
    
    
    
    cout << k<<endl;
    return 0;
    
}


 

Measured memory_bytes: 6528
/**
 * Created by karayuu on 2019/06/17
 */
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    when {
        a == b -> println("Draw")
        a == 1 -> println("Alice")
        b == 1 -> println("Bob")
        a < b -> println("Bob")
        else -> println("Alice")
    }
}


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

int main(){
    long long n,a,b,ans;
    a = 2;
    b = 1;
    ans = 0;
    cin>>n;
    if(n==1) cout<<1<<endl;
    else{
        for(int i=1;i<n;i++){
        ans = a+b;
        a=b;
        b=ans;
    }
    cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 256
class Node:
    def __init__(self):
        self.parent = -1
        self.children = []
        self.type = ''
        self.depth = 0

def walk_tree(v, d=0):
    Nodes[v].depth = d
    for child in Nodes[v].children:
        walk_tree(child, d+1)

N = int(input())
Nodes = [Node() for _ in range(N)]
for _ in range(N):
    idx, k, *children = [int(x) for x in input().split()]
    Nodes[idx].children = children
    if k:
        Nodes[idx].type = 'internal node'
    else:
        Nodes[idx].type = 'leaf'
    for child in children:
        Nodes[child].parent = idx
root = [i for i, x in enumerate(Nodes) if x.parent == -1][0]
Nodes[root].type = 'root'
walk_tree(root)
for i, node in enumerate(Nodes):
    print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, node.parent, node.depth, node.type, ', '.join(map(str, node.children))))


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif


struct edge {
    int from, to;
    ll cost;
};

class BellmanFord {
    int V;
    int E;
    vector<edge> edges;
    vector<ll> dist;
    vector<bool> negative;

public:
    BellmanFord(int v, int e) : V(v), E(e), negative(v) {
        dist.resize(V, INF);
    }

    void add_edge(int from, int to, ll cost) {
        edges.push_back({from, to, cost});
    }

    ll get_total_cost(int v) {
        return dist[v];
    }

    // v に到達するまでに負ループがあるかを検出する
    bool is_negative(int v) {
        return negative[v];
    }

    // ベルマンフォード法の実行・全辺の負閉路を検出 trueを返す時に負閉路を含む
    bool exec() {
        bool updated = false;
        dist[0] = 0;
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < E; ++j) {
                edge edge = edges[j];
                if (dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost) {
                    dist[edge.to] = dist[edge.from] + edge.cost;
                    if (i == V - 1) updated = true;
                }
            }
        }

        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < E; ++j) {
                edge edge = edges[j];
                if (dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost) {
                    negative[edge.to] = true;
                }
                if (negative[edge.from]) {
                    negative[edge.to] = true;
                }
            }
        }
        return updated;
    }
};

void Main() {
    int N, M;
    cin >> N >> M;
    BellmanFord bellmanFord(N, M);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        bellmanFord.add_edge(a, b, -c);
    }
    bellmanFord.exec();

    if (bellmanFord.is_negative(N - 1)) {
        cout << "inf" << '\n';
    } else {
        cout << -bellmanFord.get_total_cost(N - 1) << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 384
f1 x b =
  let i = x `div` 500
      j = x `mod` 500
  in
    if j == 0 then (i * b) else ( (i+1) * b )

f2 x a b =
  let i = x `div` 1000
      r = x - i * 1000
  in
    if r > 500
    then i * a + minimum [ a, b * 2 ]
    else if r == 500
         then minimum [a, b]
         else if r > 0
              then i * a + b
              else i * a

ans a b x =
  if a >= 2 * b
  then f1 x b
  else f2 x a b

main = do
  l <- getLine
  let [a,b,x] = map read $ words l :: [Int]
      o = ans a b x
  print o



Measured memory_bytes: 3680
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

const int mod = 1000000007;
const int Maxn = 500005;
int n, xsum, cnt, s[Maxn];
int dp[2][1 << 20];
vector <int> g[1 << 20];
inline void add(int &x, int y) { (x += y) >= mod && (x -= mod); }
inline int mul(int x, int y) { return 1LL * x * y - 1LL * x * y / mod * mod; }

int main(int argc, const char *argv[]) {
  ios_base :: sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cout << fixed << setprecision(12);
  cin >> n;
  for (int i = 1; i <= n; ++ i) {
    int a; cin >> a; xsum ^= a;
    s[i] = s[i - 1];
    if (xsum) g[xsum].push_back(i);
    else ++ cnt, ++ s[i];
  }
  s[n + 1] = s[n];
  for (int i = 1; i < (1 << 20); ++ i) {
    if (g[i].empty()) continue;
    g[i].push_back(n), dp[0][i] = 1;
    for (int j = 1; j < g[i].size(); ++ j) {
      int k = s[g[i][j]] - s[g[i][j - 1]];
      add(dp[1][i], dp[0][i]);
      add(dp[0][i], mul(k, dp[1][i]));
    }
  }
  if (xsum) {
    cout << dp[0][xsum] << endl;
    return 0;
  }
  int ans = 1;
  for (int i = 1; i < cnt; ++ i) add(ans, ans);
  for (int i = 1; i < (1 << 20); ++ i) add(ans, dp[1][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 44032
import Control.Applicative
import Control.Monad

solver :: Int -> Int -> Int
solver n x =
  let cand = [(y1, y2, y3) | y1 <- [1..n], y2 <-[1..(y1-1)], y3 <- [1..(y2-1)],
              y1 + y2 + y3 == x]
  in
      length cand

main :: IO()
main = do
  (n:x:_) <- map (read :: String -> Int) . words <$> getLine
  unless (n == 0 && x == 0) $ do
    print $ solver n x
    main

Measured memory_bytes: 5000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    int sum = 0;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l.at(i);
        sum += l.at(i);
    }
    const int consum = sum;
    for (int i = 0; i < n; i++) {
        sum = consum;
        sum -= l.at(i);
        if (l.at(i) >= sum) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);
        int s=scanner.nextInt();
        int h=s/3600;
        int m=(s/60)%60;
        int sec=s%60;
        
        System.out.println(h+":"+m+":"+sec);
    }
}



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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using mii = map<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  int n;cin>>n;
  vi t(n),a(n);rep(i,n) cin>>t[i]>>a[i];
  repi(i,n-1) {
    if (t[i] >= t[i-1] && a[i] >= a[i-1]) continue;
    int p = max(div_ceil(t[i-1],t[i]),div_ceil(a[i-1],a[i]));
    t[i] *= p;
    a[i] *= p;
  }
  int ans = t[n-1] + a[n-1];
  cout << ans << endl;
}

Measured memory_bytes: 256
// Last Change: 01/07/2019 13:04:42.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

ll Cost(int prev, int next) {
  ll ans = prev - next;
  return abs(ans);
}

ll DP(vector<int>& h, vector<ll>& dp, int n) {
  if (dp[n] == -1) {
    dp[n] = min(DP(h, dp, n - 1) + Cost(h[n], h[n - 1]),
                DP(h, dp, n - 2) + Cost(h[n], h[n - 2]));
  }
  return dp[n];
}

int main() {
  int N;
  cin >> N;
  vector<int> h(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> h[i];
  }

  vector<ll> dp(N + 1, -1); // index段目まで行くときの最小コスト
  dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  ll ans = DP(h, dp, N);

  cout << ans << endl;

  //LoopUntilZeroInpput();
}


Measured memory_bytes: 5376
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int n;
int a[200020];
int pos[200020];

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

    while (cin >> n) {
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            pos[a[i]] = i;
        }

        set<int> seen;
        seen.insert(-1);
        seen.insert(n);

        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            auto r = seen.upper_bound(pos[i]);
            auto l = prev(r);
            ll k = (ll)(*r - pos[i])*(pos[i] - *l);
            ans += i*k;
            seen.insert(pos[i]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 11136
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)

int main() {
	int N; cin >> N;
	char s[101];
	rep(i, 0, N)
	{
		cin >> s[i];
		if (s[i] == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s= sc.nextInt();
        long div=1_000_000_007;
        long[]ans=new long[s+1];
        
        for (int i = 1; i <= s; i++) {
            if(i<=2)      ans[i]=0;
            else if(i==3) ans[i]=1;
            else          ans[i]=(((ans[i-1]+ans[i-3])%div)+div)%div;
        }
        System.out.println(ans[s]);
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll m,k;
vl ans;

int main(){
  cin >> m >> k;
  if(m == 0){
    if(k != 0){
      cout << -1 << endl;
      return 0;
    }
    cout << 0 << " " << 0 << endl;
    return 0;
  }else if(k == 0){
    for(ll i = 0;i < (1 << m);i++){
      ans.push_back(i);
      ans.push_back(i);
    }
  }else if(m == 1){
    cout << -1 << endl;
    return 0;
  }else{
    if((1 << m) <= k){
      cout << -1 << endl;
      return 0;
    }
    for(ll i = 0;i < (1 << m);i++){
      if(i == k) continue;
      ans.push_back(i);
    }
    ans.push_back(k);
    for(ll i = ((1 << m)-1);i >= 0;i--){
      if(i == k) continue;
      ans.push_back(i);
    }
    ans.push_back(k);
  }
  for(ll i = 0;i < ans.size()-1;i++){
    cout << ans[i] << " ";
  }
  cout << ans[ans.size()-1] << endl;
}


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxD = 10 + 9;
const int maxN = 10 + 9;

ll x[maxN][maxD];
int n, d;

bool isSquare(ll x){
	ll sq = (ll)sqrt((double)x);
	return (sq * sq == x);
}

ll sqDist(int i, int j){
	ll ans = 0;
	for(int run = 0; run < d; run++){
		ans += (x[i][run] - x[j][run]) * (x[i][run] - x[j][run]);
	}

	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> d;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < d; j++){
			cin >> x[i][j];
		}
	}
	
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			if(isSquare(sqDist(i, j)))
				ans++;
		}
	}
	
	cout << ans << '\n';

	return 0;
}

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

int main() {
    string s;
    cin >> s;
    deque<char> a(s.begin(), s.end());
    int ans = 0;
    while (1 < a.size()) {
        if (a.front() == a.back()) {
            a.pop_front();
            a.pop_back();
        }
        else if (a.front() == 'x') {
            a.push_back('x');
            ans++;
        }
        else if (a.back() == 'x') {
            a.push_front('x');
            ans++;
        }
        else {
            ans = -1;
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 512
#include <iostream>

#include <deque>

#include <stdio.h>

#include <cstdio>

#include <algorithm>

#include<bits/stdc++.h>

#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define sp <<" "
#define nw <<"\n"
#define ca "Case "<<tc++<<": "
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define ull unsigned LL
#define check cout<<"* ";
#define show_vector for(int q=0;q<v.size();q++){cout<<v[q]<<" ";}
#define REP(i,n) for (int i=0;i<(n);++i)
#define N_MAX 26


const int inf=1<<30;
const long long int INF=1e10;
const int MOD=1e9+7;
const int maxn = 1e5+10;
int a[200005],b[1000005];

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
/*
int ck_prime(int n)
{
    int coun;
     coun=0;
     if(n>1){
      for(int i=2;i*i<=n;i++){
        if( n%i==0 ){
            coun++;
            break;
          }
        }
      }
     if(n==1){
       coun=coun;
         }
    if(coun==0){
           return 1; // n is prime
        }
    return 0;
}
*/
int main()
{
    int n,x;
    vector<int>a;
    vector<int>b;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        a.pub(x);
    }
    for(int i=1;i<=n;i++){
        cin>>x;
        b.pub(x);
    }
    int sumX=0,sumY=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            sumX+=a[i];
            sumY+=b[i];
        }
    }
    cout<<sumX-sumY nw;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int arr[105];
double ans=0;
int main() {
   int a ;
   cin>>a;
   for(int i=1;i<=a;i++){
       cin>>arr[i];
   }
   for(int i=1;i<=a;i++){
       ans+=(double)1/arr[i];
   }
   cout<<fixed<<setprecision(5)<<1/ans;
}

Measured memory_bytes: 256
// Mon Sep 14 19:59:49 IST 2020  


#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int64 ii = (int64)a ; ii < (int64)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7;
const int64 big = INT64_MAX;

const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}
void printSet(multiset <int>v){
    cout << "===\n";
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}
  
int tests(){ 
    string s;
    cin >> s;
    if(s.back() == 's')
        s += "es";
    else
        s += "s";
    cout << s << '\n';
    return 0;
}    
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 


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

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

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

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while (1) {
    if (cur == nil) break;
    if (isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

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

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

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

void deleteKey(int key) { deleteNode(listSearch(key)); }

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

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (i = 0; i < n; i++) {
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F')
          deleteFirst();
        else if (com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 34336
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    string s;
    cin>>s;
    int n = sz(s);
    if(s[n - 1] == 's'){
        s += "es";
    }else{
        s += "s";
    }
    cout<<s<<"\n";
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int n,a,b,c,i,l;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	l=0;
		scanf("%d %d %d",&a,&b,&c);
	if(a<c&&b<c){
		if(a*a+b*b==c*c){
		l=1;
			printf("YES\n");	
		}
	}
	else if(a<b&&c<b){
		if(a*a+c*c==b*b){
		l=1;
			printf("YES\n");
		}
	}
	else if(b<a&&c<a){
		if(c*c+b*b==a*a){
			l=1;
			printf("YES\n");
		}
	}
	if(l==0){
	printf("NO\n");
	}
	}
	return 0;
}

Measured memory_bytes: 1012
### 解説読んでから書いたコード ###

n, m = map(int, input().split())
MOD = 1000000007
if m > 0:
    a = [int(input()) for i in range(m)]
else:
    a = []

a.append(-1) # 末尾に-1を追加(壊れている床がもう無い事を示す)
a_i = 0

## n段目への移動方法は、step[n]通り存在する
## step[n] = step[n-2] + step[n-1]

step = [0] * (n+2)
step[-1] = -1 # 存在しない段(計算用)
step[0] = 1 # 0段目は1通り

for i in range(1, n+1):
    if a[a_i] == i:
        step[i] = -1 # 壊れている床は-1
        a_i += 1
    else:
        if step[i-2] == step[i-1] == -1:
            print(0) # 2段続けて壊れている場合は0通り
            exit()
        elif step[i-2] == -1 or step[i-1] == -1:
            step[i] = max(step[i-2], step[i-1]) # [1,2]段前が壊れている場合
        else:
            step[i] = (step[i-2] + step[i-1]) % MOD # 通常の場合

print(step[n])

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

int main(){
    ll N; cin >> N;
 
    vector<ll>A(N);
    for (ll i = 0; i < N; i++) cin >> A[i];
 
    sort(A.begin(), A.end(), greater<ll>());

    priority_queue<ll, vector<ll>> Q;
    Q.push(A.at(0));
 
    ll ans = 0;
    for (ll i = 1; i < N; i++) {
        ans += Q.top();
        Q.pop();
        Q.push(A.at(i));
         Q.push(A.at(i));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int cnt=0;
	ll n;
	cin>>n;
	vector<ll> a(n+1,0);
	if(n>=6)
	{
		vector<ll> v(3);
		v[0]=v[1]=v[2]=1;
		queue<pair<int,vector<ll> > > q;
		q.push(make_pair(6,v));
		set<vector<ll> > s;
		while(!q.empty())
		{
			int x=q.front().first;
			vector<ll> xx=q.front().second;
			q.pop();
			if(x<=n)
			{
				if(xx[0]==xx[1]&&xx[1]==xx[2])
				{
					a[x]+=1;
				}
				else if(xx[0]==xx[1])
				{
					a[x]+=3;
				}
				else if(xx[1]==xx[2])
				{
					a[x]+=3;
				}
				else
				{
					a[x]+=6;
				}
				xx[0]++;
				vector<ll> xy=xx;
				sort(xy.begin(),xy.end());
				if(s.find(xy)==s.end())
				{
					s.insert(xy);
					int y=xx[0]*xx[0]+xx[1]*xx[1]+xx[2]*xx[2]+xx[0]*xx[1]+xx[1]*xx[2]+xx[2]*xx[0];
					q.push(make_pair(y,xy));
				}
				xx[0]--;
				xx[1]++;
				xy=xx;
				sort(xy.begin(),xy.end());
				if(s.find(xy)==s.end())
				{
					s.insert(xy);
					int y=xx[0]*xx[0]+xx[1]*xx[1]+xx[2]*xx[2]+xx[0]*xx[1]+xx[1]*xx[2]+xx[2]*xx[0];
					q.push(make_pair(y,xy));
				}
				xx[1]--;
				xx[2]++;xy=xx;
				sort(xy.begin(),xy.end());
				if(s.find(xy)==s.end())
				{
					s.insert(xy);
					int y=xx[0]*xx[0]+xx[1]*xx[1]+xx[2]*xx[2]+xx[0]*xx[1]+xx[1]*xx[2]+xx[2]*xx[0];
					q.push(make_pair(y,xy));
				}
			}
		} 
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<endl;
	return 0;
}


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

int main(){
	string s;
	cin >> s;
	
	for(int i = 0; i < 3;++i){
		if(s[i] == '1') s[i] = '9';
		else if (s[i] == '9') s[i] = '1';
	}
	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int x, y, z, ans;
    cin >> x >> y >> z;
    x -= z;
    for(int i=0;;i++){
      x -= y+z;
      if(x<0){
        ans = i;
        break;
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  double ans,a;
  for(int i=0;i<n;i++){
    cin >> a;
    ans += 1/a;
  }
  
  cout << setprecision(10) << 1/ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var s = readLine()!!

    while (s.isNotEmpty()) {
        when {
            s.endsWith("dream") -> {
                s = s.dropLast(5)
            }
            s.endsWith("dreamer") -> {
                s = s.dropLast(7)
            }
            s.endsWith("erase") -> {
                s = s.dropLast(5)
            }
            s.endsWith("eraser") -> {
                s = s.dropLast(6)
            }
            else -> {
                println("NO")
                return
            }
        }
    }
    println("YES")
}

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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back
int add[(int)(1e6)];
const int MOD = 1e9 + 7;
 
int takemod(int a, int mod = MOD){a %= mod;if (a < 0) a += mod; return a;}
 
int fast_exp(int base, int expo, int mod = MOD) {
    int res = 1;
    while(expo > 0) {
        if(expo&1) res = (res*base) % mod;
        base = (base*base) % mod;
        expo >>= 1;
    }
    return res;
}
 
int modinv(int a, int mod = MOD){return takemod(fast_exp(takemod(a), mod-2, mod), mod);}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int N;
    cin >> N;
    int v = 0;
    int a[N];
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        int p = a[i];
        for(int j = 2; j * j <= a[i]; j++) {
            int c = 0;
            while(p % j == 0){
                p /= j;
                c ++;
            }
            add[j] = max(add[j], c);
        }
        if(p > 1) {
            add[p] = max(add[p], 1ll);
        }
        v = (v + fast_exp(a[i], MOD - 2, MOD)) % MOD;
    }
    int lcm = 1;
    for(int i = 2; i < 1e6; i++) {
        lcm = (lcm * fast_exp(i, add[i], MOD)) % MOD;
    }
    int ans = lcm * v % MOD;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = S.size();
  {
    int turn = 0;
    int tmp = 0;
    rep(i,S.size()){
      if(S[i]-'0' != turn) tmp++;
      turn = 1-turn;
    }
    ret = min(ret, tmp);
  }
  {
    int turn = 1;
    int tmp = 0;
    rep(i,S.size()){
      if(S[i]-'0' != turn) tmp++;
      turn = 1-turn;
    }
    ret = min(ret, tmp);
  }
  
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 512
import math
cup = list(map(int, input().split()))
a = cup[0]
b = cup[1]
x = cup[2]
Area_x = x / a
if Area_x > a * b / 2:
    deg = math.degrees(math.atan((2 * b - 2 * Area_x / a) / a))
else:
    deg = math.degrees(math.atan((b**2 /(2 * Area_x))))
print(deg)

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

using namespace std;

int triangle(int x){
  return x * (x+1) / 2;
}

int main(){
  int n;
  cin >> n;
  int max_number = 1;
  while (triangle(max_number) <= n) {
    ++max_number;
  }
  --max_number;
  int need = n - triangle(max_number);
  for(int i=1;i<=max_number;++i){
    if(i<=max_number-need)cout << i << endl;
    else cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
ll a[4],res=6e18;
ll solve(ll n, int S){
	assert((S>>2&1)&&(S>>3&1));
	ll qaq=0;
	/*if(S>>3&1)res+=n/8*a[3],n%=8;
	if(S>>2&1)res+=n/4*a[2],n%=4;
	if(S>>1&1)res+=n/2*a[1],n%=2;
	if(S>>0&1)res+=n/1*a[0],n%=1;*/
	qaq+=n/8*a[3],n%=8;qaq+=n/4*a[2],n%=4;
	return qaq;
}
int main() {
	rep(i,0,3)read(a[i]);rep(i,1,3)a[i]=min(a[i],a[i-1]*2);
	ll n;read(n);
	n*=4;
	cout<<solve(n,15);
	return 0;
}


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

using namespace std;
typedef long long ll;


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

    int h[n+1], dp[n+1];

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

    dp[0] = 0, dp[1] = 0, dp[2] = abs(h[2]-h[1]);

    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
    }

    cout << dp[n];

    return 0;
}


Measured memory_bytes: 1024
n,m = map(int,raw_input().split())
a = [[0 for i in range (m)]for j in range(n)]
b = [0 for i in range(m)]
c = [0 for i in range(n)]

for i in range(n):
    x = map(int,raw_input().split())
    for j in range(m):
        a[i][j] = x[j]
for i in range(m):
    b[i] = int(raw_input())

for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
    print c[i]

Measured memory_bytes: 6548
#include <iostream>
using namespace std;
int main(){

    int S,h,m,s;
    
    cin >> S;
    
    s = S % 60 ;
    m = ((S - s)/60)%60 ;
    h = (S - s - 60*m) / 3600 ;
    
    
    cout << h << ":" << m << ":" << s << endl;
    
    
    
    
    
    
}


Measured memory_bytes: 3104
#include <iostream>
#include<bits/stdc++.h>
#define fori(j,n) for(long long  i=j;i<n;i++)
#define pb push_back
#define ss string
#define ll long long
#define li  long
#include<string.h>
#define pf printf
#define sf scanf
bool isvowel(char s){ if(s=='a'||s=='A'||s=='e'||s=='E'||s=='i'||s=='I'||s=='o'||s=='O'||s=='u'||s=='U') return true;  else  return false;}
 ll fact(ll  n){ll mul=1;for(ll i=1;i<=n;i++)mul=mul*i;return mul;}
ll gcd(ll m,ll n){while(n!=0){ll r=m%n;m=n;n=r;}return m;}
using namespace std;
bool sortas(const pair<ll,ll> &a,const pair<ll,ll> &b){return a.second<b.second;}


 int main(){

    int n;
    cin>>n;

    int a,b;
    cin>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}


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

#define int long long

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int a, b, n;

    cin >> a >> b >> n;

    if (n >= b - 1) {
        cout << a * (b - 1) / b - a * ((b - 1) / b);
    } else {
        cout << a * n / b - a * (n / b);
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <decimal/decimal>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

int main(){
    ll n,m; cin>>n>>m;
    ll inf=1001001001001001001;
    vector<vector<ll>> lrc(m,vector<ll>(3));
    rep(i,m) cin>>lrc[i][0]>>lrc[i][1]>>lrc[i][2];
    sort(lrc.begin(),lrc.end());
    vector<ll> dis(n,inf);
    dis[0]=0;
    rep(i,m){
        ll l=lrc[i][0],r=lrc[i][1],c=lrc[i][2];
        rep(j,r-l){
            chmin(dis[r-j-1],dis[l-1]+c); 
            if(dis[r-j-1]<dis[l-1]+c) break;   
        }
    }
    if(dis[n-1]==inf) cout<<-1<<endl;
    else cout<<dis[n-1]<<endl;
}


Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <vector>
#define llt long long int

using namespace std;
int main()
{
    int n, d;
    cin >> n >> d;

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

    int res = 0;

    for (int i = 0; i < n-1; i++) {
        for (int j = i + 1; j < n; j++)
        {
            int dis = 0;
            for (int k = 0; k < d; k++)
            {
                dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }

            for (int k = 1; k < 130; k++)
            {
                if (k*k == dis)
                    res++;
            }
        }
    }

    cout << res << endl;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int N = read();
  vector<string> citys;
  vi scores;
  vi indices(N);
  iota(ALL(indices), 0);
  REP(i, N) {
    citys.PB(readString());
    scores.PB(read());
  }
  sort(ALL(indices), [&citys, &scores](size_t i1, size_t i2) {
    return (citys[i1] == citys[i2]) ? (scores[i1] > scores[i2])
                                    : (citys[i1] < citys[i2]);
  });
  REP(i, N) { print(indices[i] + 1); }
}


Measured memory_bytes: 2304
m,k=map(int,input().split())
if k>=2**m:
  print(-1)
elif m==0:
  print(0,0)
elif m==1:
  if k==0:
    print(0,0,1,1)
  elif k==1:
    print(-1)
else:
  ris=[str(i) for i in range(2**m)]
  ris.remove(str(k))
  l=" ".join(ris)
  r=" ".join(ris[::-1])
  print(l,str(k),r,str(k))

Measured memory_bytes: 16020
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 1000 * 1000 + 47;

const int L = 4000 * 10;
int A[MAX];
int B[MAX];
int P[MAX];

int n;
void print(int A[])
{
	FOR(i, 0, n) cout << A[i] + 1 << " ";
	cout << endl;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> n;
	FOR(i, 0, n)
	{
		cin >> P[i];
		P[i]--;
	}

	FOR(i, 0, n)
	{
		A[i] = i * L;
		B[i] = L * (n - i);
	}

	FOR(i, 0, n)
	{
		B[P[i]] += i;
	}

	print(A);
	print(B);
}

Measured memory_bytes: 4864