akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  cout << dup(n,2) << endl;
  return 0;
}

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

int main(){
	int a,b;
	char op;
	
	while(1){
	cin>>a>>op>>b;
	
	if(op=='?')
	break;
	
	else if(op=='+')
	cout<<a+b<<endl;
	
	else if(op=='-')
	cout<<a-b<<endl;
	
	else if(op=='*')
	cout<<a*b<<endl;
	
	else if(op=='/')
	cout<<a/b<<endl;
	
	else break;
	}
	
	return 0;
}

Measured memory_bytes: 1160
n=int(input())
p=list(map(int,input().split()))
l=[0]+[i for i in range(n+1)]
r=[i+1 for i in range(n+1)]+[n+1]
d=[0]*(n+1)
for i in range(n):d[p[i]]=i+1
ans=0
for i in range(1,n+1):
  ans+=((r[r[d[i]]]-r[d[i]])*(d[i]-l[d[i]])+(r[d[i]]-d[i])*(l[d[i]]-l[l[d[i]]]))*i
  l[r[d[i]]],r[l[d[i]]]=l[d[i]],r[d[i]]
print(ans)

Measured memory_bytes: 19428
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
void print() { cout << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail){cout << head << " "; print(forward<Tail>(tail)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    print(N*N*N);
    
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[] A;

    private void solve() {
        N = nextInt();
        A = new int[N + 2];
        for(int i = 1;i < N + 1;i++) {
            A[i] = nextInt();
        }

        int sum = 0;
        int prev = A[0];
        for(int i = 1;i < N + 2;i++) {
            sum += Math.abs(prev - A[i]);
            prev = A[i];
        }

        for(int i = 1;i < N + 1;i++) {

            out.println(sum - Math.abs(A[i] - A[i+1]) - Math.abs(A[i-1] - A[i]) + Math.abs(A[i-1] - A[i + 1]));
        }

    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 41668
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int prime[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    prime[0] = 1;
    prime[1] = 1;
    for(int i = 2; i < 1000; i++) {
        int j = 2;
        while(i * j <= 100000) {
            prime[i*j] = 1;
            j++;
        }
    }
    int sum[100010] = {};
    REP(i, 1, 100000) {
        int flag = 0;
        if (prime[i] == 0 && prime[(i+1)/2] == 0) flag = 1;
        sum[i] = sum[i-1] + flag;
    }

    int Q; cin >> Q;
    int l, r;
    rep(i, Q) {
        cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }

    return 0;
}


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

    #define ll long long int
    using namespace std;
    int main()
    {
        ll x,k,d;
        cin>>x>>k>>d;
        x = abs(x);
        ll opt = x/d;
        ll mod = x%d;
        if(opt < k) {
            x = mod;
            k -= opt;
            if(k & 1)
                x = d - x;
        }
        else 
            x -= d*k;
        cout<<x<<endl;
        return 0;

    }


Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
int searchfront(int,int*,int,int,int);
int search(int,int*,int,int,int);
int main(){
  int i,j,n,nr[20],q,qr[200];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&nr[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&qr[i]);
  for(i=0;i<q;i++){
    if(searchfront(n,nr,0,0,qr[i]) == 1) printf("yes\n");
    else printf("no\n");
  }
    
}
int searchfront(int n,int *a,int m,int all,int key){
  int i,ans;
  for(i=0;i<n;i++){
    ans =  search(n,a,i,all,key);
    if(ans == 1) return 1;
  }
  return 0;

}

int search(int n,int *a,int m,int all,int key){
  int i,ans;
  all += a[m];
  // if(key ==17)  printf("%d %d \n",all,m);
  if(key == all) return 1;
  if(all > key) return 0;
  for(i=m+1;i<n;i++){
    ans = search(n,a,i,all,key);
    if(ans == 1) return 1;
  }
  return 0;

}



Measured memory_bytes: 2108
#import collections
# c = collections.Counter()
#import itertools as it
#import math
#import numpy as np
#import sys 
#sys.exit()
 
#a = input()

#k = int(input())
#a, b  = map(int, input().split())
'''
#  = list(map(int, input().split()))
'''
n,k = map(int, input().split())
#n = input()
p = list(map(int, input().split()))

'''
n,k = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
'''
 
#-------------------------------#
#len(t)==len(s)+1
#print(t[0:-1])

p.sort()
#print(p)
P=[]
for i in range(k):
    P.append(p[i])
print(sum(P))  

Measured memory_bytes: 9264
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }


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

	string s, t; cin >> s >> t;
	string out;
	lint i = 0;
	while (i < s.length()) {
		out.push_back(s[i]);
		if (i >= t.length())break;
		out.push_back(t[i]);
		i++;
	}
	co(out);
	gc();
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			var rootN = Math.Ceiling(Math.Sqrt(N));

			var yakusuNum = new long[N + 1];
			yakusuNum[1] = 1;
			for (long i = 2; i < N+1; i++) {
				yakusuNum[i] = 2;
			}

			for (int i = 2; i <= rootN; i++) {

				for (int j = i; j < N; j++) {

					if (i*j > N) {
						break;
					}
					yakusuNum[i * j] += i == j ? 1 : 2;
				}

			}

			long sum = 0;

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


			//答えの出力
			var ans = sum;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 106188
#include <iostream>
using namespace std;
char s[10000];
int a[10000];
int flag[10000];
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int l=0,r=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]=='W') 
        r++;
    }
    int ans=n-r-1;
    for(int i=1;i<n;i++)
    {
        if(s[i-1]=='E')  l++;
        if(s[i]=='W') r--;
        ans=min(ans,n-l-r-1);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

vi primes={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int main(){
  int N;cin>>N;
  map<int, int> counter;
  for (int i=2;i<=N;++i){
    int j=i;
    for (int m=0;m<25;++m){
      int p=primes[m];
      while(j%p==0){
        counter[p]++;
        j/=p;
      }
    }
  }

  int C74=0, C24=0, C14=0, C4=0, C2=0;
  
  for (auto p: counter){
    if(p.second>=74) C74++;
    if(p.second>=24) C24++;
    if(p.second>=14) C14++;
    if(p.second>=4) C4++;
    if(p.second>=2) C2++;
  }
  

  int ans=0;
  ans+=C74;
  ans+=C24*(C2-1);
  ans+=C14*(C4-1);
  ans+=C4*(C4-1)*(C2-2)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 105
#define C 105
#define M 10105
using namespace std;

int n, c, dp[2][C][M];

int a[N], b[N], cost[N];

int main(){

  cin>>n>>c;
  
  for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>cost[i];

  memset(dp,-1,sizeof(dp));

  dp[0][0][0]=0;
  
  for(int i=0;i<n;i++){

    int nI=(i+1)%2, I=i%2;
    
    for(int j=0;j<=c;j++){
      
      for(int k=0;k<M;k++){
	
	if(dp[I][j][k]==-1) continue;
	
	dp[nI][j][k]=max(dp[nI][j][k],dp[I][j][k]);

	if(c<j+cost[i]) continue;

	dp[nI][j+cost[i]][k+a[i]]=
	  max(dp[nI][j+cost[i]][k+a[i]],dp[I][j][k]+b[i]);
	
	dp[nI][j+cost[i]][k+b[i]]=
	  max(dp[nI][j+cost[i]][k+b[i]],dp[I][j][k]+a[i]);
	
      }      
      
    }

    for(int j=0;j<=c;j++)
      for(int k=0;k<M;k++) dp[I][j][k]=-1;
    
  }

  int ans=0;
  
  for(int i=0;i<2;i++) 
    for(int j=0;j<=c;j++)
      for(int k=0;k<M;k++)
	ans=max(ans,min(k,dp[i][j][k]));

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

Measured memory_bytes: 11380
# D - Summer Vacation

import heapq

n, m = map(int, input().split())

w = [[0] for _ in range(m+1)] 

for _ in range(n):
    a, b = map(int, input().split())
    if a<=m:
        w[a].append(b)

ans = 0
hq = []
for i in range(1, m+1):
    for j in w[i]:
        heapq.heappush(hq, -j)
    ans += heapq.heappop(hq)

print(ans * -1)


Measured memory_bytes: 21644
num = input()

for mask in range(1 << 3):
    tmp = int(num[0])
    ans_str = num[0]
    for i in range(3):
        if mask >> i & 1 == 1:
            tmp += int(num[i + 1])
            ans_str += '+' + num[i + 1]
        else:
            tmp -= int(num[i + 1])
            ans_str += '-' + num[i + 1]
    if tmp == 7:
        print(ans_str + '=7')
        exit()


Measured memory_bytes: 9184
nums=gets.strip.split(" ").map do |i|
  i.to_i
end

n = nums[0] #冊数
m=nums[1] #アルゴリズムの数
x=nums[2] #目標スコア
a=[]
n.times{
  c=gets.strip.split(" ").map do |i|
    i.to_i
  end
  a.push(c)
}
sum = 999999999999999999
i = 0
patern = 2**n
while i < patern
  arr = Array.new(m+1,0)
  n.times{|j|
    if i % 2**j == i%2**(j+1)
      p =0
      while p< m+1
        arr[p]+=a[j][p]
        p+=1
      end
    end
  }
  flag=true
  m.times{|j|
    flag=false if arr[j+1]<x
  }
  sum=arr[0]if flag && arr[0] <sum 
  i+=1
end


puts -1 if sum == 999999999999999999
puts sum unless sum == 999999999999999999


Measured memory_bytes: 14544
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
if n.even? then
  ref = ((1..(n-1)).step(2).to_a * 2).sort
  ans = 2**(n/2) % (10**9 + 7)
else
  ref = ((2..(n-1)).step(2).to_a * 2 + [0]).sort
  ans = 2**((n-1)/2) % (10**9 + 7)
end
if a == ref then
  puts ans
else
  puts 0
end

  


Measured memory_bytes: 12272
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int N;
  cin >> N;
  vector<int> B(N);
  rep(i, N)
  {
    int b;
    cin >> b;
    B.at(i) = b - 1;
  }
  int pos = 0;
  int step = 1;
  set<int> H;
  while (1) {
    pos = B.at(pos);
    if (pos == 1)
      break;
    if (H.count(pos) == 0) {
      H.insert(pos);
      step++;
      continue;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << step << endl;
}

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

const long MAX = 2000000;
const long INFTY (1<<30); // 2^30

long H, A[MAX + 1];

void maxHeapify(long i){
	long l = 2 * i;
	long r = 2 * i + 1;

	long largest;
	if (l <= H && A[l] > A[i]){
		largest = l;
	}
	else {
		largest = i;
	}
	if (r <= H && A[r] > A[largest]){
		largest = r;
	}

	if (largest != i){
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

long extract(){
	long maxv;
	if (H < 1) return -INFTY;
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxv;
}

void increaseKey(long i, long key){
	if (key < A[i]) return;
	A[i] = key;
	while (i > 1 && A[i / 2] < A[i]){
		swap(A[i], A[i / 2]);
		i /= 2;
	}
}

void insert(long key){
	H++;
	A[H] = -INFTY;
	increaseKey(H, key);
}

int main(){
	long key;
	string com;

	while (1){
		cin >> com;
		if (com[0] == 'e' && com[1] == 'n') break;
		if (com[0] == 'i'){
			cin >> key;
			insert(key);
		}
		else {
			cout << extract() << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 9388
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int num, kowasu = 0, now = 1;
	int brick[200000] = {0};
	scanf("%d", &num);
	for (int i = 0; i < num; i++) {
		scanf("%d", &brick[i]);
	}
	for (int i = 0; i < num; i++) {
		if (now != brick[i]) {
			kowasu++;
		}
		else {
			now++;
		}
	}
	if (kowasu == num) {
		printf("-1\n");
	}
	else {
		printf("%d\n", kowasu);
	}
	
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    ll q,h,s,d,n;
    scanf("%lld%lld%lld%lld%lld",&q,&h,&s,&d,&n);

    h = min(q*2,h);
    s = min(h*2,s);
    d = min(s*2,d);


    ll ans = 0;

    if(n%2==1){
        ans += s;
        n--;
    }

    ans += (n/2)*d;
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    string s[x];
    for (int i=0;i<x;i++)
        cin>>s[i];
    sort(s,s+x);
    for (int i=0;i<x;i++)
        cout<<s[i];
    return 0;
}


Measured memory_bytes: 256
#include<time.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int main(void){
    int a,b;
    cin>>a>>b;
    int ans=a+b;
    ans=max(ans,a-b);
    ans=max(ans,a*b);
    cout<<ans;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    map<ll, ll> a;
    rep(i, 0, m){
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        a[tmp1]++;
        a[tmp2]++;
    }

    fore(i, a){
        if(i.second % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 5632
#include<iostream>

using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int c = a + x;
	if (b <= a) {
		cout << "delicious" << endl;
	} else if (b <= a + x) {
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}
}

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

int N, res = 0;
string C;

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

    int l = 0, r = N-1;
    while(true){
        while(l < N && C[l] == 'R') ++l;  //最左白石
        while(0 <= r && C[r] == 'W') --r;  //最右赤石
        if(l > r) break;
        ++res; ++l; --r;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3752
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void hmax(int a){
  int l=2*a,r=2*a+1,largest, c;
  if(l<=H && A[l]>A[a])largest=l;
  else largest=a;
  if(r<=H && A[r]>A[largest])largest=r;
  if(largest != a){
    c=A[a];
    A[a]=A[largest];
    A[largest]=c;
    hmax(largest);
  }
}

int extract(){
  int maxv;
  if(H<1)return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  hmax(1);
  return maxv;
}

void iK(int i, int key){
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    swap(A[i], A[i/2]);
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  iK(H, key);
}

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s", com);
    if(com[0]=='e' && com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d", &key);
      insert(key);
    }else{
      printf("%d\n", extract());
    }
  }
  return 0;
}





Measured memory_bytes: 6456
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int gcd(int a, int b){
    if(b != 0) return gcd(b, a%b);
    else return a;
}

int main(){
    int n, d[55];
    ll ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> d[i];
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mp make_pair
#define fir first
#define sec second
using namespace std;
const int N=1e5+11;
const int inf=1e18;
int n,m,cnt,head[N],dis[N];
struct Edge{int nxt,to,val;}edge[N<<1];
void ins(int x,int y,int z){
    edge[++cnt].nxt=head[x];
    edge[cnt].to=y;head[x]=cnt;
    edge[cnt].val=z;
}
priority_queue<pair<int,int> > q;
void dijkstra(){
    memset(dis,0x3f,sizeof(dis));
    dis[1]=0;q.push(mp(0,1));
    while(!q.empty()){
        auto u=q.top();q.pop();
        int x=u.sec;if(dis[x]!=-u.fir) continue;
        for(int i=head[x];i;i=edge[i].nxt){
            int y=edge[i].to;
            if(dis[y]>dis[x]+edge[i].val){
                dis[y]=dis[x]+edge[i].val;
                q.push(mp(-dis[y],y));
            }
        }
    }
}
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
signed main(){
    n=read(),m=read();
    for(int i=2;i<=n;i++)
        ins(i,i-1,0);
    for(int i=1;i<=m;i++){
        int l=read(),r=read(),z=read();
        ins(l,r,z);
    }
    dijkstra();
    printf("%lld\n",dis[n]>=inf?-1:dis[n]);
    return 0;
}


Measured memory_bytes: 7672
N = int(input())
B = list(map(int,input().split()))

A = [0]*N
A[0] = B[0]
A[N-1] = B[N-1-1]
for i in range(1,N-1):
    A[N-1-i] = min(B[N-1-i],B[N-1-i-1])
print(sum(A))

Measured memory_bytes: 3064
n, targetw = map(int,input().split())
dp = [[0 for i in range(targetw+1)] for j in range(n+1)]

for i in range(n):
	tmpv, tmpw = map(int, input().split())
	for j in range(1, targetw+1):
		if j >= tmpw:
			dp[i+1][j] = max(dp[i][j-tmpw]+tmpv, dp[i][j])
		else:
			dp[i+1][j] = dp[i][j]

print(dp[n][targetw])


Measured memory_bytes: 42456
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  int N,M;cin>>N>>M;
  vector<vint> end(3*M+10);
  repeat(i,N){
    int L,R;cin>>L>>R;
    L+=M;
    end[R].push_back(L);
    end[R+M].push_back(L+M);
  }
  vll used(3*M+10);
  priority_queue<int> Q;
  ll mx=0;
  repeat(i,3*M){
    for(int e:end[i])Q.push(-e);
    while(!Q.empty()&&-Q.top()<i)Q.pop();
    if(i>0)used[i]=used[i-1];
    if(!Q.empty()){
      used[i]++;
      Q.pop();
    }
    if(i>M)mx=max(mx,used[i]-used[i-M]);
  }
  cout << N-mx<<endl;
  return 0;
}


Measured memory_bytes: 26496
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int h, w, k; std::cin >> h >> w >> k;
	std::vector<std::string> state(h); for (auto& line : state) std::cin >> line;
	std::vector<std::vector<int>> result(h, std::vector<int>(w, 0));
	int current = 1;
	int last = -1;
	for (auto i = 0; i < h; ++i) {
		int s_count = 0;
		for (auto j = 0; j < w; ++j) {
			if (state[i][j] == '#') {
				++s_count;
			}
		}
		if (s_count > 0) {
			for (auto j = 0; j < w; ++j) {
				result[i][j] = current;
				if (state[i][j] == '#' && --s_count > 0) {
					++current;
				}
			}
			for (int k = i - 1; k > last; --k) {
				for (auto j = 0; j < w; ++j) {
					result[k][j] = result[i][j];
				}
			}
			++current;
			last = i;
		}
	}
	for (auto i = last + 1; i < h; ++i) {
		for (auto j = 0; j < w; ++j) {
			result[i][j] = result[last][j];
		}
	}
	for (auto& line : result) {
		for (auto i = 0; i < line.size(); ++i) {
			if (i != 0) std::cout << ' ';
			std::cout << line[i];
		}
		std::cout << '\n';
	}
}

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

int N, A[200];

int main()
{
  int dmin = 100;
  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
    int d = 0;
    while(A[i] % 2 == 0) {
      A[i] /= 2;
      ++d;
    }
    dmin = min(dmin, d);
  }
  cout << dmin << endl;
  return 0;
}


Measured memory_bytes: 256
//ManyFormulas.cpp (C)
#include <iostream>
#include <string>
using namespace std;

int main(){
  int N;
  string S;
  cin >> S;
  N = S.size();
  long long Ans = 0;
  long long t;
  if(N==1) printf("%d\n",S[0]-'0');
  else{
    for(int mask = 0; mask < (1<<(N-1)); mask++){
      t = S[0] - '0';
      for(int i = 0; i < N-1; i++){
        if(mask&(1<<i)){
          Ans += t;
          t = 0;
        }
        t *= 10;
        t += S[i+1] - '0';
        if(i == N-2&&t!=0) Ans += t;
      }
    }
    printf("%lld\n",Ans );
  }
  return 0;
}


Measured memory_bytes: 256
hoge=input()
ans=0
for i in range(len(hoge)):
  for j in range(len(hoge)):
    huga=hoge[i:1+j]
    if(len(huga)==huga.count("A")+huga.count("C")+huga.count("T")+huga.count("G")):
      ans=max(ans,len(huga))

print(ans)

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

int main()
{
    int X, Y, A, B, C;
    cin>>X>>Y>>A>>B>>C;
    vector<int> p(A), q(B), r(C);
    for (int &t: p)
        cin>>t;
    for (int &t: q)
        cin>>t;
    for (int &t: r)
        cin>>t;

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());

    long long ans = 0;
    int pi = A;
    for (int i=0; i<X; i++)
        ans += p[--pi];
    int qi = B;
    for (int i=0; i<Y; i++)
        ans += q[--qi];
    int ri = C-1;

    while (true)
    {
        if (ri<0)
            break;
        if (pi<A && qi<B && p[pi]<q[qi] || pi<A && qi>=B)
        {
            if (p[pi]>=r[ri])
                break;
            ans -= p[pi++];
            ans += r[ri--];
        }
        else if (pi<A && qi<B && q[qi]<=p[pi] || qi<B && pi>=A)
        {
            if (q[qi]>=r[ri])
                break;
            ans -= q[qi++];
            ans += r[ri--];
        }
        else
            break;
    }
    cout<<ans<<endl;
}


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

using namespace std;
int a[100005];
int main() {
    int n, x;
    scanf("%d %d", &n, &x);
    for (int i = 0; i < n; ++i) scanf("%d", a + i);
    long long res = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i - 1] + a[i] > x) {
            int sum = a[i - 1] + a[i];
            int deduct = a[i] >= sum - x ? sum - x : a[i];
            res += sum - x;
            a[i] -= deduct;
        }
    }
    printf("%lld\n", res);

}


Measured memory_bytes: 4208
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	while(n--){
		int y, m, d;
		cin >> y >> m >> d;
		int answer = 0;
		while(y != 1000 || m != 1 || d != 1){
			int mlim = (y % 3 != 0) ? 19 + m % 2 : 20;
			if(d++ == mlim){
				d = 1;
				if(m++ == 10){
					++y;
					m = 1;
				}
			}
			++answer;
		}
		cout << answer << endl;
	}
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;

    char A[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = -1; i < h + 1; i++) {
        if (i == -1 || i == h) {
            for (int j = -1; j < w + 1; j++) {
                cout << '#';
            }
        }
        else {
            for (int j = -1; j < w + 1; j++) {
                if (j == -1 || j == w) {
                    cout << '#';
                }
                else {
                    cout << A[i][j];
                }
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b,c;
  cin>>a>>b>>c;
  int p=abs(a-b)+abs(b-c);
  int q=abs(a-c)+abs(b-c);
  int r=abs(c-a)+abs(a-b);
  int ans=p;
  if(q<ans)ans=q;
  if(r<ans)ans=r;
  cout(ans);
  return 0;
}

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

const int N = 100 * 1000 + 10;

int n, m;
int P[N], ans;
int mark[2][N], number = 1;
vector <int> adj[N];

void input() {
    int x, y;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> P[i];
        P[i]--;
    }

    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        adj[x - 1].push_back(y - 1) ;
        adj[y - 1].push_back(x - 1) ;
    }
    return;
}

void dfs(int v) {
    mark[0][v] = number;
    mark[1][P[v]] = number;

    for (int i = 0; i < adj[v].size() ; i++)
        if (!mark[0][adj[v][i]])
            dfs(adj[v][i]) ;
    return;
}

void solve() {
    for (int i = 0; i < n; i++)
        if (!mark[0][i]) {
            dfs(i) ;
            number++;
        }

    for (int i = 0; i < n; i++)
        if (mark[0][i] == mark[1][i])
            ans++;
    return;
}

int main() {
    input() ;
    solve() ;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s,t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k=123456*2;
void sosu(int a[]){
    int b[k]={};
    for(int i=0;i<k;i++){
        b[i]=1;
    }
    for(int i=0;i<k;i++){
        if(i<=1){
            b[i]=0;
        }else{
            for(int j=0;i*(j+2)<k;j++){
                b[i*(j+2)]=0;
            }
        }
    }
    for(int i=0;i<k;i++){
        if(b[i]){
            a[i]=i;
        }
    }
}

int main(){
    int n;
    while(cin>>n and n){
        int a[k]={};
        sosu(a);
        int count=0;
        for(int i=0;i<k;i++){
            if(a[i]>n and a[i]<=2*n){
                count++;
            }
        }
        cout<<count<<endl;
    }
    return 0;
}



Measured memory_bytes: 5004
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
int dp[2][210000];
int a[2][210000];

int main() {
	cin >> n;
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < n; ++j)
			cin >> a[i][j];
	dp[0][0] = a[0][0];
	dp[1][0] = a[0][0] + a[1][0];
	for (int i = 1; i < n; ++i) {
		dp[0][i] = dp[0][i - 1] + a[0][i];
		dp[1][i] = max(dp[1][i - 1], dp[0][i]) + a[1][i];
	}
	cout << dp[1][n - 1] << "\n";
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<map>
using namespace std;

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

    vector<string> s(N);
    for (int i = 0; i < N; i++)
        cin >> s[i];

    map<string, int> mp;
    for (int i = 0; i < N; i++) {
        sort(s[i].begin(), s[i].end());

        mp[s[i]]++;
    }

    long long ans = 0;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        long long cnt = it->second;

        ans += cnt * (cnt - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 18176
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

d,t,s = inpl()
if d <= t*s:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 72488
#include<stdio.h>

const int N = 10000;
int main()
{
	int a[N] = {0}, n, maxn = -1000000, minn = 1000000;
	long long sum = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if(a[i] > maxn)
		{
			maxn = a[i];
		}
		if(a[i] < minn)
		{
			minn = a[i];
		}
		sum += a[i];
	}
	printf("%d %d %lld\n", minn, maxn, sum);
	
	return 0;
}


Measured memory_bytes: 2800
#include <stdio.h>
int main(){
    int m,n,i,j,Ai,Aj,ok;
    char a[51][51],b[51][51];
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++){
        scanf("%s",&a[i]);
    }
    for(i=0; i<m; i++){
        scanf("%s",&b[i]);
    }
    for(int Ai=0; Ai<n-m+1; Ai++){
        for(Aj=0; Aj<n-m+1; Aj++){
            ok=1;
            for(i=0; i<m; i++){
                for(j=0; j<m; j++){
                    if(a[Ai+i][Aj+j]!=b[i][j]){
                        ok=0;
                    }
                }
            }
            if(ok==1){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
}

Measured memory_bytes: 128
def gi; gets.to_i end
def gs; gets.chomp end
def gli; gets.split(' ').map(&:to_i) end
def d(n); Math.log10(n).to_i + 1 end
class Integer
  # 約数の組み合わせを列挙する
  def divisor_combinations
    (1..Math.sqrt(self).to_i).
      select { |i| self % i == 0 }.
      map { |i| [i, self / i] }
  end
end

a, b, x = gli
x = x.to_f / a # 奥行き一定のため2次元平面で考える
if x >= a * b / 2.0 # 水の量が半分より多い場合
  # tanθ = h / a
  # θ = atan(h / a)
  # x = a * b - a * h / 2
  # a * h / 2 = a * b - x
  # h = (2 / a)(a * b - x)
  # θ = atan((2 / a / a)(a * b - x))
  y = 2.0 * (a * b - x) / (a * a * 1.0)
else # 水の量が半分より少ない場合
  # h = ?
  # tanθ = b / h
  # θ = atan(b / h)・・・(1)
  # h * b / 2 = x
  # h = x * 2 / b・・・(2)
  # rad = atan(b * b / x * 2)
  y = b * b / (x * 2.0)
end

rad = Math.atan(y)
deg = rad * 180.to_f / Math::PI
puts deg


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  int ans = 10000000;
  rep(j, 2){
    int count = 0;
    char pre = s[0];
    rep(i, s.length()){
      if(s[i] != pre){
        count++;
        pre = s[i];
      }
    }
    ans = min(ans, count);
    reverse(s.begin(), s.end());
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int const INF = 10000000;

int DP[16][100000];
int cost[16][100000];

int cost_origin[16][17];

int main(){
	
	int N;
	
	while(true){
		cin >> N;
		if(N == 0){
			break;
		}
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j <= N; j++){
				cin >> cost_origin[i][j];
			}
		}
		
		for(int i = 0; i < (1 << N); i++){
			for(int j = 0; j < N; j++){
				cost[j][i] = cost_origin[j][0];
			}
			int num = i;
			for(int j = 1; j <= N; j++){
				if(num % 2 == 1){
					for(int k = 0; k < N; k++){
						cost[k][i] = min(cost[k][i], cost_origin[k][j]);
					}
				}
				num /= 2;
			}
		}
		
		for(int i = 0; i < N; i++){
			DP[i][0] = 0;
		}
		
		for(int i = 1; i < (1 << N); i++){
			int hoge = i;
			int num = 1;
			for(int j = 0; j < N; j++){
				DP[j][i] = INF;
				if(hoge % 2 != 0){
					int state = i - num;
					for(int k = 0; k < N; k++){
						DP[j][i] = min(DP[j][i], DP[k][state] + cost[j][state]);
					}
				}
				hoge /= 2;
				num *= 2;
			}
		}
		
		int ans = INF;
		
		for(int i = 0; i < N; i++){
			ans = min(ans, DP[i][(1 << N) - 1]);
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 11384
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int a,b,c;
	cin>>a>>b>>c;
	a+=b;a+=c;
	if(a>=22)
	cout<<"bust\n";
	else
	cout<<"win\n";
}
void q2(){
	int n; cin>>n;
	if(n&1){
		cout<<"No\n";
		return ;
	}
	n/=2;
	string s;
	cin>>s;
	int fg=1;
	for(int i=0;i<n;++i)
	if(s[i]!=s[i+n])
	fg=0;
	fg==1 ? cout<<"Yes\n" : cout<<"No\n";
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q1();
	return 0;
}
	


Measured memory_bytes: 256
N = int(input())

lob = []

for _ in range(N):
    X, L = map(int,input().split())
    lob.append([X + L, X - L])

lob.sort()

ans = 0
last = (-1) * 10 ** 9 - 1
for l in lob:
    if last <= l[1]:
        ans += 1
        last = l[0]

print(ans)

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

int main(){
    int t;
    cin >> t;
    int s,m;
    s = t%60;
    t /= 60;
    m = t%60;
    t /= 60;
    cout << t << ":" << m << ":" << s  << endl;
    return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int now = -1;
		int count =0;
		for (int i=0;i<N;i++) {
			int temp = sc.nextInt();
			if (now==temp) {
				now =-1;
				count ++;
			} else {
				now = temp;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;

ll fat[1000005], inv[1000005];

ll solve(ll a, ll b){
    
    ll n = a+b;
    ll res = (fat[n]*inv[a])%mod;
    res = (res*inv[b])%mod;
    return res;
}

ll modpow(ll b, ll e){
    if(e == 0 || b == 0) return 1;
    if(e == 1) return (b%mod);
    ll res = modpow(b, e/2);
    res = (res*res)%mod;
    if(e%2 == 1)
        res = (res * (b%mod))%mod;
    return res;
}

int main(){

    fat[0] = 1;
    inv[0] = 1;
    for(ll i = 1; i <= 1e6; i++){
        fat[i] = (fat[i-1] * i)%mod;
        inv[i] = modpow(fat[i], mod-2);
    }

    ll res = 0;
    ll x, y; cin >> x >> y;
    for(int i = 0; i <= x; i++){
        ll xx = x-i, yy = y-2*i;
        if(xx >= 0 and yy >= 0 and xx == yy*2)
            res = (res + solve(i, yy))%mod;
    }
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 16000
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
X = min(int(input()) for _ in range(5))
print((N + X - 1) // X + 4)



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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  map<int, int> A;
  for (int i = 0; i < N; i++) A[a.at(i)]++;
  
  int ans = 0;
  for (int X = 1; X < 100000; X++){
    int sum = 0;
    if(A.count(X - 1)) sum += A.at(X - 1);
    if(A.count(X)) sum += A.at(X);
    if(A.count(X + 1)) sum += A.at(X + 1);
    ans = max(ans, sum);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 6556