akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int mex = 2e5 + 1;
int fact[mex+5], inv[mex+5];  

int toPower(int a, int p){
    int res = 1;
    while (p){
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}

int Inv(int x){ 
    return toPower(x, mod - 2); 
}

int add(int a, int b) {
    a %= mod; b %= mod;
    return ((a + b) % mod);
}

int sub(int a, int b) {
    a %= mod; b %= mod;
    return  ((a - b + mod) % mod);
}

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

void initialize(){
    inv[0] = Inv(fact[0]);fact[0] = inv[0] = 1;
    
    for(int i = 1; i <= mex; i++){
        fact[i] = (ll(i) * fact[i - 1]) % mod;
        inv[i] = Inv(fact[i]);
    }
}

int C(int n, int k){
    if (n < 0 || k < 0 || k > n) return 0;
    return ll(fact[n]) * inv[k] % mod * inv[n - k] % mod;                   
}

void solve() {
  initialize();
  int n, m, k;
  cin >> n >> m >> k;
  if(m == 1 && k < n-1) {
    cout << "0\n"; return;
  }
  int ex = m;
  for(int i = 1; i < n; i++) {
    ex = mul(ex, m-1);
  }
  int res = 0;
  for(int i = k+1; i <= n; i++) {
    int temp = C(n-1, i);
    temp = mul(temp, ex);
    temp = mul(temp, Inv(toPower(m-1, i)));
    res = add(res, temp);
  }
  int ans = toPower(m, n);
  ans = sub(ans, res);
  cout << ans << '\n';
}

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

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


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

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

const MOD: usize = 1e9 as usize + 7;

fn main() {
    input!{
      n: usize,
      m: usize,
      ss: [usize; n],
      ts: [usize; m],
    }
    let mut dp = vec![vec![0; m]; n];
    let mut acm = vec![vec![0; m+1]; n+1];
    for i in 0..n {
        for j in 0..m {
            if ss[i] == ts[j] {
                dp[i][j] = acm[i][j] + 1;
                dp[i][j] %= MOD;
            }
            acm[i+1][j+1] = acm[i][j+1] + acm[i+1][j] + (MOD - acm[i][j]) + dp[i][j];
            acm[i+1][j+1] %= MOD;
        }
    }
    let mut ans = 1;
    for i in 0..n {
        for j in 0..m {
            ans += dp[i][j];
            ans %= MOD;
        }
    }
    println!("{}", ans);
}


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

int dp[2][59][3010];
int main(){
	int N,M,S,n2,ii,io;
	while(1){
		cin>>N>>M>>S;
		if(N==0&&M==0&&S==0)break;
		n2=N*N;
		for(int j=0;j<=n2;j++){
			for(int k=0;k<=S;k++){
				dp[0][j][k]=0;
			}
		}
		dp[0][0][0]=1;
		for(int i=1;i<=M;i++){
			//for(int k=0;k<=n2;k++){//
			//	for(int j=0;j<=S;j++){//
			//		cout<<dp[i-1][k][j]<<" ";//
			//	}//
			//	cout<<endl;//
			//}//
			//cout<<endl;//
			if(i%2){
				ii=0;
				io=1;
			}
			else{
				ii=1;
				io=0;
			}

			for(int j=0;j<=n2;j++){
				for(int k=0;k<=S;k++){
					dp[io][j][k]=0;
				}
			}
			for(int j=0;j<=n2;j++){
				for(int k=0;k<=S;k++){
					if(dp[ii][j][k]!=0){
						if(k<=S-i&&j!=n2){
							dp[io][j+1][k+i]+=dp[ii][j][k];
							dp[io][j+1][k+i]%=100000;
						}
						dp[io][j][k]+=dp[ii][j][k];
						dp[io][j][k]%=100000;
					}
				}
			}
		}

		//for(int i=0;i<=n2;i++){//
		//	for(int j=0;j<=S;j++){//
		//		cout<<dp[M][i][j]<<" ";//
		//	}//
		//	cout<<endl;//
		//}//

		cout<<dp[M%2][n2][S]<<endl;
	}
	return 0;

}

Measured memory_bytes: 2344
#include<bits/stdc++.h>
#define ll long long
const ll mod=1e9+7;
using namespace std;
map<ll,ll> mmp;
ll n;
ll lajitijie(ll q){
	if(mmp[q])
		return mmp[q];
	return mmp[q]=(lajitijie(q/2)+lajitijie((q-1)/2)+lajitijie((q-2)/2))%mod;
}
int main(){
	mmp[0]=1,mmp[1]=2;
	scanf("%lld",&n);
	printf("%lld\n",lajitijie(n));
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		LinkedList<Integer> list = new LinkedList<Integer>();

		for (int i=0; i<n; i++) {
			String str = br.readLine();

			if (str.startsWith("insert")) {
				list.addFirst(Integer.parseInt(str.substring(str.indexOf(" ")+1)));
			}else if (str.equals("deleteFirst")) {
				list.pollFirst();
			}else if (str.equals("deleteLast")){
				list.pollLast();
			}else {
				list.remove((Integer)Integer.parseInt(str.substring(str.indexOf(" ")+1)));
			}
		}

		StringBuilder sb = new StringBuilder();
		sb.append(list.poll());
		for (Integer s : list) {
			sb.append(" ").append(s);
		}
		System.out.println(sb.toString());

		br.close();
	}
}

Measured memory_bytes: 134924
#include<iostream>
using namespace std;
int main()
{
    int a;
    int i = 0;
    string b;
    cin>>a;
    cin>>b;
    for (; i < a && i<b.length(); i++)
    {
        cout<<b[i];
    }
    if(a<b.length())
        cout<<"..."<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  cout << setprecision(10);
  int N, K, x=0;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    int hi;
    cin >> hi;
    if(hi>=K) x++;
  }
  cout << x << endl;
  return 0;
}

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 



const int D = 365;
vector<int> c(26, 0);
vector<vector<int>> s(D, vector<int>(26, 0));

ll calc_score(vector<int> &t){
  vector<int> last(26, -1);
  ll score = 0;
  for(int d=0; d<D; d++){
    int type = t[d];
    score += s[d][type];
    last[type] = d;
  
    for(int i=0; i<26; i++){
      score = score - c[i] * (d - last[i]);
    }
  }
  return score;
}

vector<int> best_oneday(vector<int> &t){
    int type = 0;
    vector<int> last(26, -1);
    for(int d=0; d<D; d++){
    
        ll score = 0;// d日目のみで得られるスコア
        for(int j=0; j<26; j++){
            vector<int>  saigo = last;
            ll get = s[d][j];
            saigo[j] = d;
            for(int k=0; k<26; k++){
              get -= c[k] * (d-saigo[k]);
            }
            if(get > score) type = j;      
        }
    last[type] = d; 
    t[d] = type;  
    //cout << type + 1 << endl;
  }
  return t;
}

int main(){
  // int D;
  // cin >> D;
  int tmp;
  cin >> tmp;
  //vector<int> c(26, 0);
  for(int i=0; i<26; i++) cin >> c[i];
  //vector<vector<int>> s(D, vector<int>(26, 0));
  for(int i=0; i<D; i++){
    for(int j=0; j<26; j++){
      cin >> s[i][j];
    }
  }


  
  vector<int> t(D);
  t = best_oneday(t);  

  const int LOOP = 100;
  for(int i=0; i<LOOP; i++){
    
    
  }
  for(int i=0; i<D; i++){
    cout << t[i] + 1 << endl;
  }
 
    
}


Measured memory_bytes: 3688
x, k, d = map(int, input().split())

min_x = x - k * d
max_x = x + k * d
if min_x >= 0:
    print(min_x)
elif max_x <= 0:
    print(abs(max_x))
else:
    a1 = max_x % (d * 2)
    a2 = abs(min_x) % (d * 2)
    print(min(a1, a2))

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


vector<ll>PF(ll n)
{
	vector<ll>v;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			while(n%i==0)n/=i;
			v.push_back(i);
		}
	}
	if(n!=1)v.push_back(n);
	return v;
}


int main()	
{
	ll a,b,sum=0;
	cin>>a>>b;
	vector<ll>p=PF(a);
	vector<ll>q=PF(b);
	for(int i=0;i<p.size();i++)
	{
		for(int j=0;j<q.size();j++)
		{
			if(p[i]==q[j])sum++;
		}
	}
	cout<<sum+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 6e5 + 9, M = 1e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7, MOD2 = 998244353;
const ll inf = 1e18;

int arr[N];

int main() {
    fastIO;
    int n, k, a;
    cin >> n;
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    int prv = arr[0], dir = 0;
    for (int i = 1; i < n; ++i) {
        if(arr[i] == prv) continue;
        if(dir == 0) {
            if(arr[i] - prv >= 1) {
                dir = 1;
                prv = arr[i];
            } else if(prv - arr[i] >= 1) {
                dir = -1;
                prv = arr[i];
            } else {
                assert(0);
            }
        } else {
            if(dir == 1) {
                if(arr[i] >= prv) {
                    prv = arr[i];
                } else {
                    ++ans;
                    prv = arr[i];
                    dir = 0;
                }
            } else {
                if(arr[i] <= prv) {
                    prv = arr[i];
                } else {
                    ++ans;
                    prv = arr[i];
                    dir = 0;
                }
            }
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 640
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  input.shift();
  input.splice(N,input.length);
  var S = input;
  var array = {};
  var max =1;
  for(var i=0;i<N;i++){
    if(array[S[i]]!=undefined){
      var num=array[S[i]];
      num++;
      array[S[i]]=num;
      max=Math.max(max,num);
    }else{
      array[S[i]]=1;
    }
  }
  var anssub=new Array();
  Object.keys(array).forEach(function(key){
    var val=this[key];
    if(val==max){
      anssub.push(key);
    }
  },array);
  anssub.sort(function(a, b){
    a = a.toString().toLowerCase();
    b = b.toString().toLowerCase();
    if(a < b){
        return -1;
    }else if(a > b){
        return 1;
    }
    return 0;
  });
  var ans = anssub.join("\n");

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 86520
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll s;cin >> s;
  ll res=1;
  map<ll,int> mp;
  while(1){
    if(mp[s]==1){
      break;
    }
    mp[s]++;
    if(s%2==0) s /= 2;
    else s = s*3+1;
    res++;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
import math
import pprint
import fractions
import collections
import itertools
from decimal import *
from collections import deque
from bisect import *
N=int(input())
l=[]
keys=[]
values=[]
ans=0
ma=10**6
x=[0]*(ma+1)
for i in range(1,ma):
    for j in range(i,ma+1,i):
        x[j]=x[j]+1
    #print(x)
for j in range(1,N):
    #print(i)
    m = N-j
    ans=ans+x[m]
print(ans)

Measured memory_bytes: 80900
# encoding: "utf-8"

from collections import defaultdict
from functools import reduce
from itertools import groupby, chain

class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, converter):
        assert(len(data) == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]

def main():
    _ = input()
    xs = Stdin.read_line(converter=int)
    ys = chain.from_iterable([[x-1, x, x+1] for x in xs])
    ys = sorted(list(ys))
    m = max(map(len, group(ys)))
    print(m)

def group(xs):
    result = list()
    prev = xs[0]
    temp = list()
    for x in xs:
        if x == prev:
            temp.append(x)
        else:
            result.append(temp)
            prev = x
            temp = [x]
    return result

if __name__ == "__main__":
    main()

Measured memory_bytes: 29960
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  REP(i,q){
    int sum;
    int v,w;
    scanf("%d %d",&v,&w);
    //cin >> v >> w;
    v--;
    w--;
    if(n == 1){
      sum = min(v,w);
    }
    else{
      while(1){
	if(v == w){
	  sum = v;
	  break;
	}
	else if(v < w){
	  if(w%n == 0)
	    w--;
	  w = w/n;
	}
	else{
	  if(v%n == 0)
	    v--;
	  v = v/n;
	}
      }
    }
    printf("%d\n",sum+1);
  }
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define mod 1000000007
#define mx 100003
#define ss second
#define ff first
#define ld long double
#define pii pair<int, int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[100002];
int main()
{
    IOS;
    int n, W;
    cin >> n >> W;
    ll w[n + 2], v[n + 2];
    memset(dp, 0, sizeof(dp));
    rep(i,1,n) cin >> w[i] >> v[i];
    for(int i =1; i <= n; i++) {
        for(int j = W; j >= 0; j--) {
            dp[j] = (w[i] > j) ? dp[j]: max(dp[j], dp[j-w[i]] + v[i]);
        }
    }
    cout << dp[W];

}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
max_A = -10**9
max_num = 0
min_A = 10**9
min_num = 0
for i in range(N):
  if(max_A < A[i]):
    max_A = A[i]
    max_num = i
  if(min_A > A[i]):
    min_A = A[i]
    min_num = i
if(max_A > 0 and min_A < 0):
  if(abs(max_A) >= abs(min_A)):
    print(2*N-1)
    for i in range(N):
      A[i] += max_A
      print(max_num+1, i+1)
    for i in range(N-1):
      print(i+1, i+2)
  else:
    print(2*N-1)
    for i in range(N):
      A[i] += min_A
      print(min_num+1, i+1)
    for i in range(N-1, 0, -1):
      print(i+1, i)
elif(min_A >= 0):
  print(N-1)
  for i in range(N-1):
    print(i+1, i+2)
elif(max_A <= 0):
  print(N-1)
  for i in range(N-1, 0, -1):
    print(i+1, i)
else:
  print(0)

Measured memory_bytes: 3064
s=input()
i=0
for tmp in list(s):
  i+=1
  if i%2==0:
    if tmp in ['L','U','D']:
      x='Y'  
      continue
    else:
      x='N'
      break
  else:
    if tmp in ['R','U','D']:
      x='Y'  
      continue
    else:
      x='N'
      break
  break
if x=='N':
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


MOD = 1000000007


def main():
    N = int(input())
    S1 = input()
    S2 = input()
    answer = 1
    cnt = 0
    while cnt < N:
        if cnt == 0:
            if S1[0] == S2[0]:
                answer *= 3
                cnt += 1
            else:
                answer *= 6
                cnt += 2
        else:
            if S1[cnt - 1] == S2[cnt - 1]:
                if S1[cnt] == S2[cnt]:
                    answer *= 2
                    cnt += 1
                else:
                    answer *= 2
                    cnt += 2
            else:
                if S1[cnt] == S2[cnt]:
                    answer *= 1
                    cnt += 1
                else:
                    answer *= 3
                    cnt += 2
        answer %= MOD

    print(answer % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, l, piall, applemin = 1000000,pm=1;
  cin >> n >> l;
  piall = n * (l - 1) + (1 + n) * n / 2;
  for (int i = 1; i < n + 1; i++) {
    if(abs(applemin)>abs(l+i-1)){
      applemin = l + i - 1;
    }
  }
  cout << piall - applemin << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int a[300000];


int main(void) {
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &a[i]);
    n--;

    for(int i=n; i>=0; i-=2)
        printf("%d ", a[i]);
    for(int i=1-(n%2); i<=n; i+=2)
        printf("%d ", a[i]);
    return 0;

}

Measured memory_bytes: 2816
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int N,A;
    cin >> N >> A;
    cout << N*N-A << endl;
    return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

void strcpy(auto & S, string * p, int sz, int offset_r, int offset_c, int offset_val) {
	for(int k = 0; k < sz; k++) for(int l = 0; l < sz; l++) if(p[k][l] != '.')
		S[offset_r+k][offset_c+l] = p[k][l] + offset_val * 4;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	if(N == 2) {
		cout << "-1\n";
		return 0;
	}
	string p3[] = {
		"aab",
		"d.b",
		"dcc"
	};
	string p4[] = {
		"aacd",
		"bbcd",
		"cdaa",
		"cdbb"
	};
	string p5[] = {
		"aabba",
		"b.cca",
		"bd..b",
		"ad..b",
		"abbaa",
	};
	string p7[] = {
		"....aba",
		"....aba",
		"....bab",
		"....bab",
		"aabb.cc",
		"bbaad..",
		"aabbd..",
	};
	vector<string> S(N);
	for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) S[i] += '.';
	int r = 1;
	while(N%2 == 0 && N >= 6) N /= 2, r *= 2;
	for(int rr = 0; rr < r; rr++) for(int rc = 0; rc < r; rc++) {
		int n = N;
		while(n >= 8 || n == 4) {
			n -= 4;
			strcpy(S, p4, 4, rr*N+n, rc*N+n, (rr+rc)%2);
		}
		if(n == 3) strcpy(S, p3, 3, rr*N, rc*N, (rr+rc)%2);
		if(n == 5) strcpy(S, p5, 5, rr*N, rc*N, (rr+rc)%2);
		if(n == 7) strcpy(S, p7, 7, rr*N, rc*N, (rr+rc)%2);
	}
	for(int i = 0; i < r*N; i++) cout << S[i] << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	cin>>x;
	if(x>=1800 && x<=1999)
	{
		cout<<1<<"\n";
	}
	else if(x>=1600 && x<=1799)
	{
		cout<<2<<"\n";
	}
	else if(x>=1400 && x<=1599)
	{
		cout<<3<<"\n";
	}
	else if(x>=1200 && x<=1399)
	{
		cout<<4<<"\n";
	}
	else if(x>=1000 && x<=1199)
	{
		cout<<5<<"\n";
	}
	else if(x>=800 && x<=999)
	{
		cout<<6<<"\n";
	}
	else if(x>=600 && x<=799)
	{
		cout<<7<<"\n";
	}
	else if(x>=400 && x<=599)
	{
		cout<<8<<"\n";
	}
	
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
using namespace std;

template <class T, class U>
T lexical_cast(const U& from) {
  T to;
  stringstream ss;
  ss << from; ss >> to;
  return to;
}

typedef double D;
const D EPS = 1e-8;

struct P {
  D x, y;
  P() { }
  P(D x_, D y_) : x(x_), y(y_) { }
};

struct L {
  P a, b;
  L() { }
  L(P a_, P b_) : a(a_), b(b_) { }
};

P operator +(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
P operator *(P a, D b) { return P(a.x * b, a.y * b); }
P operator /(P a, D b) { return P(a.x / b, a.y / b); }

int sig(D a, D b) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}

D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }
D norm(P p) { return inp(p, p); }
D abs(P p) { return sqrt(norm(p)); }
P rot90(P p) { return P(-p.y, p.x); }

P vec(P from, P to) { return to - from; }

P projection(L l, P p) { // 直線lに対する点pの写像
  P a = vec(l.a, l.b);
  P b = vec(l.a, p);
  D t = inp(a, b) / norm(a);
  return l.a + a * t;
}
P reflection(L l, P p) { // 直線lに対する点pの反射
  return p + vec(p, projection(l, p)) * 2;
}

int main() {
  for(string S; cin >> S; ) {
    for(int i = 0; i < (int)S.size(); ++i) {
      if(S[i] == ',') S[i] = ' ';
    }
    istringstream iss(S);
    double x1, y1, x2, y2, xq, yq;
    iss >> x1 >> y1 >> x2 >> y2 >> xq >> yq;
    L l(P(x1, y1), P(x2, y2));
    P p(xq, yq);
    P q = reflection(l, p);
    cout.setf(ios::fixed);
    cout.precision(4);
    cout << q.x << ' ' << q.y << endl;
  }
}

Measured memory_bytes: 1304
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int ans=1,n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		if(ans<k)
		ans+=ans;
		else
		ans+=k;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

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

	int n, number;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		cin >> number;
		a.push_back(number);
	}
	sort(a.begin(), a.end(), greater<int>());

	int alice = 0;
	int bob = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alice += a[i];
		}
		else {
			bob += a[i];
		}
	}
	cout << (alice - bob) << "\n";

	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n;
  cin >> n;
  string s[n];
  int t[n];
  for(int i=0;i<n;i++){
    cin >> s[i] >> t[i];
  }
  string target;
  cin >> target;
  int ans = 0;
  bool flag = false;
  for(int i=0;i<n;i++){
    if(flag) ans += t[i];
    if(s[i] == target) flag = true;
  }
  cout << ans << endl;
  return 0;
}


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

int main(int argc, const char * argv[])
{
    int w, n;
    
    cin >> w;
    cin >> n;
    
    int ary[w];
    for (int i=1; i<=w; i++) {
        ary[i-1] = i;
    }
    
    for (int i=0; i<n; i++) {
        int a, b;
        scanf("%d,%d",&a, &b);
        swap(ary[a-1], ary[b-1]);
    }

    for (int i=0; i<w; i++) {
        cout << ary[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define inf 2333333333333333
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)

using namespace std;
int n,m;
typedef pair<int,int>P;
queue<P>q;
void in(int &x){
    int y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(int x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

signed main(){
    in(n);
    if(n&1){
        For(i,1,n-1){
            For(j,i+1,n){
                if(j!=n-i){
                    m++;
                    q.push(P(i,j));
                    //o(i);p(' ');o(j);p('\n');
                }
            }
        }
    }else{
        For(i,1,n){
            For(j,i+1,n){
                if(j!=i && j!=n+1-i){
                    m++;
                    q.push(P(i,j));
                    //o(i);p(' ');o(j);p('\n');
                }
            }
        }
    }
    o(m);p('\n');
    while(!q.empty()){
        auto k=q.front();q.pop();
        o(k.first);p(' ');o(k.second);p('\n');
    }
    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll n=0,a=0,b=0;
    cin>>a>>b>>n;
    ll x=min(n,b-1);
    cout<<a*x/b-a*(x/b);
}


Measured memory_bytes: 3636
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

w,h,x,y = inm()
printn(str(w*h/2) + ' ')
print(1 if 2*x==w and 2*y==h else 0)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b)   {return a>b?a:b;}
ll min(ll a,ll b)   {return a<b?a:b;}
ull pow(ull n)
{
    if(n==0)
        return 1;
    ull p = pow(n/2);
    if(n%2==0)
         return ((p%mod)*(p%mod))%mod; 
     return (10l*(p%mod)*(p%mod))%mod;
}
ull pow1(ull n)
{
    if(n==0)
        return 1;
    ull p = pow1(n/2);
    if(n%2==0)
         return ((p%mod)*(p%mod))%mod; 
    return (9l*(p%mod)*(p%mod))%mod;
}
ull pow2(ull n)
{
    if(n==0)
        return 1;
    ull p = pow2(n/2);
    if(n%2==0)
         return ((p%mod)*(p%mod))%mod; 
    return (8l*(p%mod)*(p%mod))%mod;
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    ll n;
    cin>>n;
    if(n<2)
        {cout<<0; return 0;}
    
    ll p = pow(n);
    ll p1 = pow1(n);
    ll p2 = pow2(n);
    //cout<<p<<" "<<p1<<" "<<p2<<"\n";
    ll ans = p - (2*p1)%mod + p2;
    
    ans = (ans+mod)%mod;
    cout<<ans;
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int X = nextInt();
  int ans = 0;
  int s = 0;
  REP(i, N) {
    if (s <= X) {
      ans++;
    }
    int L = nextInt();
    s += L;
  }
  if (s <= X) ans++;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
/*
AizuOnline A0200
Title Traveling Alone: One-way Ticket of Youth
13/8/12 WA
*/
#include <stdio.h>
#include <limits.h>
#include <string.h>
//Global data section
#define STATIONS 100
int time_org[STATIONS+1][STATIONS+1];
int fair_org[STATIONS+1][STATIONS+1];

int buffer[STATIONS+1][STATIONS+1];
int n; // no of station info
int m; // no of station
int a,b,cost,tim,k,p,q,r;
//
void dump()
{
        int i,j;

        for(i=1;i<=m-1;i++)
                for(j=i+1;j<=m;j++)
                        printf("(%d-%d) %d\n",i,j,buffer[i][j]);
}
int cheapest(int shurui,int from,int to)
{
        int modified,i,j,b_from_i;
        if(shurui==0)
                memcpy(buffer,fair_org,sizeof(int)*(STATIONS+1)*(STATIONS+1));
        else
                memcpy(buffer,time_org,sizeof(int)*(STATIONS+1)*(STATIONS+1));

#ifdef DEBUG
        dump();
#endif
        do
        {
                modified=0;
                for(i=1;i<=m;i++)
                {
                        if(buffer[from][i]==INT_MAX || i==from)
                                continue;
                        b_from_i=buffer[from][i];
                        for(j=1;j<=m;j++)
                        {
                                if(buffer[i][j]==INT_MAX || j==from ||j==i)
                                        continue;

                                if(buffer[from][j]>b_from_i+buffer[i][j])
                                {
                                        buffer[from][j]=b_from_i+buffer[i][j];
                                        modified=-1;
                                }
                        }
                }
#ifdef DEBUG
                if(modified)
                        dump();                
#endif
        } while(modified);

        return(buffer[from][to]);
}
void init()
{
        int i,j;

        for(i=1;i<=m;i++)
                for(j=0;j<=m;j++)
                        fair_org[i][j]=time_org[i][j]=INT_MAX;
}
main()
{
        int i;

        while(EOF!=scanf("%d %d",&n,&m) && (n||m))
        {
                init();

                for(i=1;i<=n;i++)
                {
                        scanf("%d %d %d %d",&a,&b,&cost,&tim);
                        fair_org[a][b]=fair_org[b][a]=cost;
                        time_org[a][b]=time_org[b][a]=tim;
                }

                scanf("%d",&k);
                for(i=1;i<=k;i++)
                {
                        scanf("%d %d %d",&p,&q,&r);
                        printf("%d\n",cheapest(r,p,q));
                }
        }
return(0);
}

Measured memory_bytes: 732
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	double max = 0;
	double[] l, a, b;
	int n, m;
	boolean[] check;
	
	void calc(int d, int pre) {
		if (d == m) {
			double sum = 0;
			for (int i = 0; i < n-1; i++) {
				if (check[i]) {
					for (int j = i+1; j < n; j++) {
						if (check[j])
							sum += (l[i]-l[j])*(l[i]-l[j])+(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]);
					}
				}
			}
			max = Math.max(max, sum);
		} else {
			for (int i = pre+1; i < n; i++) {
				check[i] = true;
				calc(d+1, i);
				check[i] = false;
			}
		}
	}
	
	void run() {
		n = sc.nextInt();
		m = sc.nextInt();
		l = new double[n];
		a = new double[n];
		b = new double[n];
		check = new boolean[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextDouble();
			a[i] = sc.nextDouble();
			b[i] = sc.nextDouble();
		}
		
		calc(0, -1);
		out.printf("%.20f", max);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 21604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int i, j;
	vector<long double> x(n);
	vector<long double> y(n);
	for (i = 0; i < n; ++i) {
		cin >> x.at(i);
	}
	for (i = 0; i < n; ++i) {
		cin >> y.at(i);
	}

	long double d1, d2, d3, di;

	d1 = 0;
	d2 = 0;
	d3 = 0;

	for (i = 0; i < n; ++i) {
		d1 += abs(x.at(i) - y.at(i));
	}

	cout << fixed << setprecision(7) << d1 << endl;

	for (i = 0; i < n; ++i) {
		d2 += abs(x.at(i) - y.at(i))*abs(x.at(i) - y.at(i));
	}

	d2 = sqrt(d2);

	cout << fixed << setprecision(7) << d2 << endl;

	for (i = 0; i < n; ++i) {
		d3 += abs(x.at(i) - y.at(i)) * abs(x.at(i) - y.at(i)) * abs(x.at(i) - y.at(i));
	}

	d3 = cbrt(d3);

	cout << fixed << setprecision(7) << d3 << endl;

	di = abs(x.at(0) - y.at(0));

	for (i = 1; i < n; ++i) {
		di = max(di, abs(x.at(i) - y.at(i)));
	}

	cout << fixed << setprecision(7) << di << endl;

}


Measured memory_bytes: 3444
last_m = {}
this_m = {}

while s = gets
  break if s == "\n"
  data = s.split(",").map{|e|
    e.to_i
  }
  last_m[data[0]] = 0 unless last_m.key?(data[0])
  last_m[data[0]] += 1
end

while s = gets
  break if s == nil
  data = s.split(",").map{|e|
    e.to_i
  }
  this_m[data[0]] = 0 unless this_m.key?(data[0])
  this_m[data[0]] += 1
end

last_m.select{|k, v|
  this_m.member?(k)
}.sort_by{|k, v|
  k
}.each{|k, v|
  puts "#{k} #{v+this_m[k]}"
}

Measured memory_bytes: 6560
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>

using namespace std;
vector<long long int>A;
vector<long long int>cnt(1000050,0);

long long int pow(long long int x,long long int n){
 long long int res;
 if(n==0) return 1;
 res=pow(x*x,n/2);
 if(n%2==1){
  res = res*x;
 }
 return res;
}

int main(void){
 long long int N,P,K,tmp,ans=1;

 cin>>N>>P;
 K=sqrt(P);
 tmp=P;
 for(int i=2; i<=K;){
  if(P%i==0){
   A.push_back(i);
   for(;P%i==0;){
    P/=i;
    cnt[i]++;
   } 
  } 
  if(P==1)break;
  i++;
 }

 for(int i=0;i<A.size(); i++){
  if(cnt[A[i]]/N>0)ans*=pow(A[i],(cnt[A[i]]/N)); 
 }
 if(N==1)cout<<tmp<<endl;
 else cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 8064
s=list(input())
a=0
if s.count("R")==0:
    print(0)
elif s.count("R")==1:
    print(1)
elif s.count("R")==2 and s[0]=="R" and s[2]=="R":
    print(1)
elif s.count("R")==3:
    print(3)
else:
    print(2)

Measured memory_bytes: 61592
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> h(n + 1), dp(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> h[i];
  dp[2] = abs(h[2] - h[1]);
  for (int i = 3; i <= n; i++) {
    dp[i] =
        min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n];
  return 0;
}

Measured memory_bytes: 1024
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	vector<int>data(3);
	for (int i = 0; i < 3; i++) {
		cin >> data[i];
	}
	int K;
	cin >> K;
	for (int i = 0; i < K; i++) {
		sort(data.begin(), data.end());
		data[2] *= 2;
	}
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		ans += data[i];
	}
	cout << ans << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k,l,a[100000],st,go,mid;
ll f(ll x){
    vector<ll> v;
    ll cnt=0;
    if(n-x<=l)return 1;
    for(int i=x+1;i<=n-l;i++){
        if(a[x]+m-a[i]<0)return 0;
        cnt+=min(m,a[x]+m-a[i]);
    }
    if(max(0LL,k-l-x)*m>cnt)return 0;
    return 1;
}
int main(void){
    cin>>n>>m>>k>>l;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    st=-1;go=n-1;
    while(go-st>1){
        mid=(go+st)/2;
        if(f(mid)==1)go=mid;
        else st=mid;
    }
    cout<<n-go<<endl;
}


Measured memory_bytes: 1024
s = input()
n = len(s)

ans = 0
for i in range(2**(n-1)) :
  bit = i
  index = 0
  for j in range(n-1) :
    c = bit%2
    bit = bit//2
    if c == 1 :
      ans += int(s[index:j+1])
      index = j+1
    elif j == n - 2 :
      ans += int(s[index:j+1])*10
  ans += int(s[n-1])

print(ans)

Measured memory_bytes: 3064
/*input
20
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	map<int, int> cnt;
	for(int i = 1; i <= 100; i++) {
		for(int j = 1; j <= 100; j++) {
			for(int k = 1; k <= 100; k++) {
				cnt[i * i + j * j + k * k + i * j + j * k + i * k]++;
			}
		}
	}
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		cout << cnt[i] << endl;
	}
	return 0;
}




















Measured memory_bytes: 5356
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#define min(a,b) ((a)<(b)?(a):(b))
//#define abs(a) ((a)>(0)?(a):-(a))
int check(long int x){
  char num[12];
  int a=0,b=0,c=0,i;//3,5,7
  sprintf(num,"%ld",x);
  for(i=0;i<strlen(num);i++){
    if(num[i]=='3')a++;
    else if(num[i]=='5')b++;
    else if(num[i]=='7')c++;
  }
  if(a>0&&b>0&&c>0) return 1;
  else return 0;
}
void dfs(long int x,long int n,int *ans){
  if(x<=n){
    *ans+=check(x);
    dfs(10*x+3,n,ans);
    dfs(10*x+5,n,ans);
    dfs(10*x+7,n,ans);
  }
}
int main(){
  long int n;
  int ans=0;
  scanf("%ld",&n);
  dfs(0,n,&ans);
  printf("%d",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF=9999999;
const int MAXN=100000;

LL X,Y; 
LL gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int main(){
    X=read(),Y=read();
	if(X%Y==0){puts("-1"); return 0;}
	else printf("%lld\n",X*Y/gcd(X,Y)+X);
	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        System.out.println((int)notSameColorInRow(n, k));
    }

    //隣合わないように色を並べる
    double notSameColorInRow(int n, int k){
        return k * Math.pow(k-1, n-1);
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
//            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }

    //a以上b以下の数でxで割り切れるものの数をf(n)と置くと、
    //f(n) = f(b) - f(a-1)
    BigDecimal nbCanDivide(BigDecimal a, BigDecimal b, BigDecimal x){
//        System.out.println(String.format("%s %s %s", a, b, x));
        return canDivide(b, x).subtract(canDivide(a.subtract(BigDecimal.valueOf(1)), x));
    }
    BigDecimal canDivide(BigDecimal i, BigDecimal x){
//        System.out.println(String.format("%s %s", i, x));
        if(i.compareTo(BigDecimal.valueOf(0)) != -1){
//            System.out.println(((i/x) + 1));
            return i.divide(x, 1).add(BigDecimal.valueOf(1));
        } else {
            return BigDecimal.valueOf(0);
        }
    }

}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
string s;
int ans = 999;
int main(){
    cin >> s;
    for(int i = 0; i < s.length()-2; i++){
        int n = (int)(s[i]-'0')*100 + (int)(s[i+1]-'0')*10 + (int)(s[i+2]-'0');
        ans = min(ans,abs(n-753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256