akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define len(x) (int)(x).size()
#define rep(i,x) for(int i=0;i<x;++i)

typedef long long ll;
typedef long double ld;

using namespace std;
const ld eps = 1e-6;
signed main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int k , n; cin >> n >> k;
    vector < int > a(n);
    for(auto &i : a)cin >> i;
    ll curr = 0;
    for(int i = 0 ; i < k - 1; ++i)
        curr += (a[i]+1);
    int j = 0;
    ll ans = 0;
    for(int i = k - 1; i < n; ++i){
        curr += (a[i]+1);
        if(i - j + 1 > k){
            curr -= (a[j]+1);
            ++j;
        }
//        cerr << curr << " ";
        ans = max(ans , curr);
    }
    cout << ans/2 << ((ans&1)?".5":".0");
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll l ,r ;cin >>  l >> r;
	if(l <=3 && r>=673) cout << '0';
	else if((l<=3 && r <673) || (l>3 && r <673)){
		ll m =INF ;
		for(ll i=l;i<r;i++){
			for(ll j=i+1;j<=r;j++){
				m = min(m , (i*j)%2019);
			}
		}
		cout << m;

	}
	else if(l>3 && r>=673){
		if(l<673) cout << '0';
		else {
			if(r-l >673) cout << '0';
			else {
				int flag= 0 ;
				ll m =INF ;
				for(ll i=l;i<r;i++){
					for(ll j=i+1;j<=r;j++){
						if((i%3==0 && j%673 ==0)||(i%673==0 && j%3==0) ){
					m = 0 ;
					flag = 1;
				}
				else m = min(m ,(i*j)%2019);
				if(flag) break;
			}
				if(flag) break;
		}
				cout << m;		
			}
		
		}
	
	}
	return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut hs = vec![0i16; n];
    for i in 0..(n - 1) {
        hs[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    hs[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    let mut max_h = 0;
    for i in 0..n {
        if hs[i] >= max_h {
            ans += 1;
            max_h = hs[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (int) 1e9 + 7;

int main(){
    
    int n, m;
    cin >> n >> m;
    
    vector<int> h(n,0), ans(n,1);
    rep(i,n) cin >> h[i];
    
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        
        if(h[a] > h[b]){
            ans[b] = 0;
        } else if(h[a] < h[b]){
            ans[a] = 0;
        } else {
            ans[a] = 0;
            ans[b] = 0;
        }
    }
    
    int count = 0;
    
    rep(i,n) if(ans[i] == 1) count++;
    
    cout << count << "\n";
    
    return 0;
}



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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    bool e = false;
    REP(i, 3)
    {
        if (S[i] == S[i + 1])
            e = true;
    }
    if (e)
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<long long int>A(N);
	vector<pair<long long int, long long int>> P(M);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		long long int b, c;
		cin >> b >> c;
		P[i] = make_pair(c, b);
	}
	sort(A.begin(), A.end());
	sort(P.begin(),P.end());
	reverse(P.begin(), P.end());
	long long int count = 0;
	for (int i = 0; i < M; i++) {
		while (A[count] < P[i].first && P[i].second > 0 && count < N) {
			P[i].second--;
			A[count] = P[i].first;
			count++;
		}
	}
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
//p175

#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define MAX 500000 //5*1e5
#define INF 2000000000 //2*1e9 //sentinel
typedef long long ll;


ll merge(int A[],int n,int left,int mid,int right){

  int n1=mid-left;
  int n2=right-mid;
  ll cnt=0; //number of inversions

  int L[MAX],R[MAX];

  rep(i,n1) L[i]=A[left+i];
  rep(i,n2) R[i]=A[mid+i];
  L[n1]=R[n2]=INF;

  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
      cnt+=n1-i;// mid+j-k-1;
    }  
  }
  return cnt;
}

//[left,right)
ll mergesort(int A[],int n,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    ll v1=mergesort(A,n,left,mid);
    ll v2=mergesort(A,n,mid,right);
    ll v3=merge(A,n,left,mid,right);
    return v1+v2+v3;
  }else{
    return 0;
  }
}

int main(){
  int A[MAX],n;
  cin>>n;
  rep(i,n)cin>>A[i];

  ll ans=mergesort(A,n,0,n);

  cout<<ans<<endl;
}

Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char c[6];
    for(int i=0;i<6;i++)cin>>c[i];
    (c[0]==c[5] and c[1]==c[4] and c[2]==c[3])?cout<<"YES":cout<<"NO";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
  
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 2e6 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
 
int n;
string s, t;

main() {             	
//  freopen(".in", "r", stdin);                          
//  freopen(".out", "w", stdout);
 
//	srand(time(NUll));
 
	speed;

	cin >> n >> s;

	for(int i = 0; i < n/2; i++)
		t += s[i];

	string c = "";
	for(int i = n/2; i < n; i++)
    	c += s[i];

	cout << (c == t ? "Yes" : "No");
     	
    return 0;                                        
}     

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        r: i64,
        d: i64,
        mut x2000: i64,
    }
    for _ in 0..10 {
        x2000 = r * x2000 - d;
        println!("{}", x2000);
    }
}


Measured memory_bytes: 4352
class Node
  attr_accessor :go, :come

  def initialize(id)
    @id = id
    @go = []
    @come = []
  end

  def to_s
    "[#{@id}]"
  end

  def inspect
    to_s
  end
end

class Arrow
  attr_accessor :source, :sink, :label
  
  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
    source.go << self
    source.come << self
  end
  
  def to_s
    "#{source}-#{label}->#{sink}"
  end

  def inspect
    to_s
  end
end

class Result
  attr_accessor :target, :spell

  def initialize(target, spell)
    @target = target
    @spell = spell
  end

  def to_s
    "#{target}: #{spell}"
  end

  def inspect
    to_s
  end
end

def advance(table, nodes, arrows)
  next_table = {}
  nodes.each do |node|
    best = table[node]
    arrows.each do |arrow|
      next unless arrow.source == node
      result = table[arrow.sink]
      next unless result
      test = Result.new(arrow.sink, arrow.label + result.spell)
      if !best || test.spell < best.spell
        best = test
      end
    end
    next_table[node] = best if best
  end
  next_table
end

def check(table, node)
  used = {}
  loop do
    result = table[node]
    return false unless result
    node = result.target
    return true unless node
    return false if used[node]
    used[node] = true
  end
end

def work(nodes, arrows, start, goal)
  table = {goal => Result.new(nil, '')}
  (nodes.size*7).times do
    table = advance(table, nodes, arrows)
  end
  puts check(table, start) ? table[start].spell : 'NO'
end

while line = STDIN.gets
  n, a, s, g = line.split.map(&:to_i)
  break if n == 0 && a == 0 && s == 0 && g == 0

  nodes = (0...n).map{|i| Node.new(i)}

  arrows = (0...a).map do |i|
    x, y, lab = STDIN.gets.split
    x = x.to_i
    y = y.to_i
    Arrow.new(nodes[x], nodes[y], lab)
  end

  start = nodes[s]
  goal = nodes[g]

  work(nodes, arrows, start, goal)
end

Measured memory_bytes: 23272
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

struct station{ll c,s,f;};

int main(void){
	ll n,c,s,f;
	cin>>n;
	vector <station> stations;
	rep(i,n-1){
		cin>>c>>s>>f;
		station sta = {c,s,f};
		stations.push_back(sta);
	}
	rep(i,n-1){
		ll time = 0;
		for(int j=i; j<n-1; j++){
			if(stations[j].s >= time){
				time = stations[j].s + stations[j].c;
				continue;
			}
			if(time%stations[j].f != 0){
				time += stations[j].f - time%stations[j].f;
			}
			time += stations[j].c;
		}
		cout<<time<<endl;
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
import math

def dist(x, y):
  return math.sqrt(x ** 2 + y ** 2)

(n, d) = map(int, input().split())
res = 0

for _ in range(n):
  (x, y) = map(int, input().split())
  res += 1 if dist(x, y) <= d else 0

print(res)


Measured memory_bytes: 9188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 2e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n;
int a[maxN];
int b[maxN];

inline bool lonely(int x) {
	return b[x] != b[x - 1] && b[x] != b[x + 1];
}

int get(int val) {
	rep (i, 1, n) b[i] = (a[i] <= val) ? 0 : 1;
	int mid = n / 2 + 1, l, r;
	if (!lonely(mid)) return b[mid];
	for (l = mid; l > 1; -- l) if (!lonely(l)) break; ++ l;
	for (r = mid; r < n; ++ r) if (!lonely(r)) break; -- r;
	int dis = min(mid - l + 1, r - mid + 1);
	return b[mid] ^ (dis & 1);
}

int main() {

	n = 2 * ri() - 1;
	rep (i, 1, n) a[i] = ri();

	int l = 1, r = n, mid;
	while (l < r) {
		mid = (l + r) >> 1;
		if (get(mid) == 0) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", l);

	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

signed main() 
{
        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
        vector<string>sb,ea,other,both;
        int n;
        cin>>n;
        int ans = 0;
        forn(i,1,n)
        {
            string s;
            cin>>s;
            forn(j,0,s.size()-2)
            {
                if(s[j]=='A' and s[j+1]=='B')ans++;
            }
            int xx=s.size()-1;
            if(s[xx]=='A' and s[0]=='B')both.pb(s);
            else if(s[xx]=='A')ea.pb(s);
            else if(s[0]=='B')sb.pb(s);
        }
        //cout<<ans;
        //nl;
        
        int a = ea.size(),b=sb.size();
        if(both.size()){ans+=both.size()-1;
        
        if(a)ans++,a--;
        if(b)ans++,b--;
        }
        
        cout<<min(a,b) + ans;



        return 0;

}

//       g++ -g c.cpp ; ./a.exe

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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll A, B;
    cin >> A >> B;

    if((A < 10) && (B < 10)){_PR(A * B);}
    else{_PR(-1);}

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int N,W,v[200],w[200];
int dp[20000][200] = {0};
int ex(int sum,int n)
{
    int res=0;
    if(dp[sum][n] != 0)return dp[sum][n];
    if(sum > W)return 0 - v[n - 1];
    if(n == N)return 0;
    dp[sum][n] = max(ex(sum,n + 1),ex(sum + w[n],n + 1) + v[n]);
    return dp[sum][n];
}
int main()
{
    scanf("%d%d",&N,&W);
    for(int i = 0; i < N; i++)
    {
        scanf("%d%d",&v[i],&w[i]);
    }
    printf("%d\n",ex(0,0));
}

Measured memory_bytes: 11260
import java.util.BitSet;
import java.util.HashMap;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		BitSet gdp = gdp(300000);
		while(true){
			int n = in.nextInt();
			if(n == 1) return;
			StringBuilder sb = new StringBuilder();
			sb.append(n+": ");
			for(int i=gdp.nextSetBit(0); i!=-1 && i<=n; i=gdp.nextSetBit(i+1)){
				if(n%i==0) sb.append(i+" ");
			}
			System.out.println(sb.toString().trim());
		}
	}
	
	public static BitSet gdp(int max){
		BitSet gdn = new BitSet(max+1);
		for(int i=1; i<=max; i++){
			int mod = i%7;
			if(mod == 6 || mod == 1) gdn.set(i);
		}
		BitSet gdp = (BitSet)gdn.clone();
		gdp.clear(1);
		for(int i=gdn.nextSetBit(2); i!=-1; i=gdn.nextSetBit(i+1)){
			for(long j=gdn.nextSetBit(2); j!=-1 && j*i<=max; j=gdn.nextSetBit((int)j+1)){
				gdp.clear((int)j*i);
			}
		}
		return gdp;
	}
}

Measured memory_bytes: 22368
#include <iostream>

uint32_t gcd(uint32_t a, uint32_t b) {
  if (b == 0) return a;
  return gcd(b, b % a);
}

int main() {
  uint32_t A = 0, B = 0, K = 0;
  std::cin >> A >> B >> K;

  uint32_t k = 0, cd = gcd(A, B);
  while (cd > 0) {
    if (A % cd == 0 && B % cd == 0) k++;
    if (k == K) {
      std::cout << cd << std::endl;
      break;
    }
    cd--;
  }

  return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let mul: i32 = buf
        .trim()
        .split(' ')
        .map(|x| x.parse::<i32>().unwrap())
        .fold(1, |res, x| res * x);
    if mul % 2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=(1<<62)-1;
const double eps=1e-6;
const int mod=1000000007;
int a[111111];
int a1[111111],a2[111111];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i+=2){
		a1[a[i]]++;
	}
	for(int i=1;i<n;i+=2){
		a2[a[i]]++;
	}
	int mx11=0,mx12=0,mx21=0,mx22=0,mxn11=0,mxn12=0,mxn21=0,mxn22=0;
	for(int i=0;i<=100000;i++){
		if(a1[i]>mx11){
			mx12=mx11;mxn12=mxn11;
			mx11=a1[i];mxn11=i;
		}
		else if(a1[i]>mx12){
			mx12=a1[i];mxn12=i;
		}
	}
	for(int i=0;i<=100000;i++){
		if(a2[i]>mx21){
			mx22=mx21;mxn22=mxn21;
			mx21=a2[i];mxn21=i;
		}
		else if(a2[i]>mx22){
			mx22=a2[i];mxn22=i;
		}
	}
	if(mxn11!=mxn21){
		cout<<n-mx11-mx21<<endl;
	}
	else{
		cout<<n-mx11-max(mx12,mx22)<<endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int cost(int v) {
    return v * v;
}
int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 1001001001;
    for(int y=-100;y<=100;y++) {
        int res = 0;
        for(int x=0;x<n;x++) {
            res += cost(a[x] - y);
        }
        ans = min(ans, res);
    }
    cout << ans;
}


Measured memory_bytes: 256
N,A,B,C = input().split()

N= int(N)
A= int(A)
B= int(B)
C= int(C)

stick =[]
leng = []
left_nums = ""
all_zero = ""


for i in range(N):

    x = int(input())
    stick.append(x)
    left_nums += "1"
    all_zero += "0"


for i in range(2 ** N):

    uses_int = format(i,'b')
    uses = uses_int.zfill(N)

    lensum = 0
    
    for j in range(N):

        if (uses[j] == "1"):
            lensum += stick[j]

    leng.append( [lensum , uses] )

#print (leng)


order = ((A,B,C),(A,C,B),(B,A,C),(B,C,A),(C,A,B),(C,B,A))


mini_last = 3001

for i in range(6): #ABC全ての順番において最小を調べる

    point = 0
    lefts = left_nums # 1がN個並んでいる文字列
    

    for j in range(3): #A,B,Cそれぞれの場合において最小を考察&出力

            
            goal = order[i][j] #近づける値

            mini_point = 1001
            mini_num = ""

            for k in leng:

                if (  abs( k[0] - goal ) + ( k[1].count('1') - 1 ) * 10 <= mini_point and abs( k[0] - goal ) + ( k[1].count('1') - 1 ) * 10 >= 0  and k[1] != all_zero ):

                    flag = True
                    for m in range(len(lefts)):

                        if (lefts[m] == "0" and k[1][m] == "1"):
                            flag = False
                            #print ("lefts:",lefts," nowk1:",k[1])

                    if (flag):
                        mini_point = abs( k[0] - goal ) + ( k[1].count('1') - 1 ) * 10
                        mini_num = k[1]


            for m in range(len(mini_num)):

                if (mini_num[m] == "1"):
                    lef_lis = list(lefts)
                    lef_lis[m] = "0"
                    lefts = "".join(lef_lis)

            point += mini_point

            #print ("mp:",mini_point ," mn:",mini_num)

    if (point < mini_last):
        mini_last = point


print (mini_last)


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

using lint = long long;
#define bit(n) (lint(1) << n)

lint comp(lint n) {
    lint s = 1;
    while (s <= n) {
        s *= 2;
    }
    return s - n;
}

int main() {
    int n;
    cin >> n;
    map<lint, int, greater<lint>> num;
    for (int i = 0; i < n; i++) {
        lint a;
        cin >> a;
        num[a]++;
    }

    int ans = 0;
    while (num.size() > 0) {
        auto it = num.begin();
        lint n = it->first;
        lint c = comp(n);
        if (n != c and num[c] > 0) {
            num[n]--;
            if (num[n] == 0) {
                num.erase(n);
            }
            num[c]--;
            if (num[c] == 0) {
                num.erase(c);
            }
            ans++;
        } else if (n == c and num[n] > 1) {
            num[n] -= 2;
            if (num[n] == 0) {
                num.erase(n);
            }
            ans++;
        } else {
            num.erase(n);
            num.erase(c);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
///Users/wantedly/Documents/git/atcoder-swift/Sources/atcoder-swift/main

let k = cin.n
var (a,b) = cin.pair

while(a <= b) {
  if a%k == 0 {
    print("OK")
    a = 9999
    break
  }
  a += 1
}

if a != 9999 {
  print("NG")
}

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var n: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var line: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { line.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { line.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in n } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}

Measured memory_bytes: 14116
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



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

  ll N; cin>>N;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  map<ll,ll> mp;
  for(auto a:A) mp[a]++;
  
  for(auto a:A){
    
    mp[a]--; if(mp[a]==0) mp.erase(a);
    cout<<(*mp.rbegin()).first<<'\n';
    
    mp[a]++;
  }
  
         
  return 0;
}


Measured memory_bytes: 12084
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	vector<int> vals;
	for (int ii = 0; ii < 3; ii++) {
		int val;
		cin >> val;
		vals.push_back(val);
	}
	sort(vals.begin(), vals.end());

	int sum = vals[0] + vals[1];
	int k;
	cin >> k;
	for (int ii = 0; ii < k; ii++) {
		vals[2] *= 2;
	}
	sum += vals[2];
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,k;
    cin >> n >> k;
    vi v;
    int now = 1;
    v.push_back(now);
    while(n/now != 1){
        int ok = now, ng = n;
        while(ng - ok > 1){
            int mid = (ok + ng)/2;
            if(n/mid == n/now)ok = mid;
            else ng = mid;
        }
        now = ok+1;
        v.push_back(now);
    }
    v.push_back(n+1);
    sort(all(v));
    rep(i,v.size()-1)v[i] = v[i+1] - v[i];
    v.pop_back();
    int m = v.size();
    vvi dp(2,vi(m,0));
    rep(i,m)dp[0][i] = v[i];
    rep(i,k-1){
        int now = i%2;
        int ne = (i+1)%2;
        rep(j,m-1)dp[now][j+1] += dp[now][j];
        rep(j,m){
            (dp[ne][j] = dp[now][m-1-j] * v[j] % MOD) %= MOD;
        }
        rep(j,m)dp[now][j] = 0;
    }
    int ans = 0;
    now = (k-1)%2;
    rep(j,m)(ans += dp[now][j]) %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 2296
#include<bits/stdc++.h>
using namespace std;
int h,w,k;
char s[55][55];
int main()
{
    cin>>h>>w;
    for(int i=1;i<=h;i++)
    	for(int j=1;j<=w;j++)
    		cin>>s[i][j];
    for(int i=1;i<=h;i++)
    {
		for(int j=1;j<=w;j++)
    	{
    		if(s[i][j]=='#')
    			cout<<s[i][j];
    		if(s[i][j]=='.')
    		{
    			k=0;
    			if(s[i-1][j-1]=='#') k++;
				if(s[i-1][j]=='#') k++;
				if(s[i-1][j+1]=='#') k++;
				if(s[i][j-1]=='#') k++;
				if(s[i][j+1]=='#') k++;
				if(s[i+1][j+1]=='#') k++;
				if(s[i+1][j]=='#') k++;
				if(s[i+1][j-1]=='#') k++;
				cout<<k;
			}
		}
		cout<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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 ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    int ans = 0;
    REP(i,N){
        ans += 2*min(a[i],K-a[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
		if((a==b&&b!=c)||(a==c&&b!=c)||(c==b&&a!=c)){
	cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
	f = 0; _T fu = 1; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
	while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
	f *= fu;
}

template <typename T>
void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

int n, base;

int main() {
	read(n);
	for (int i = 0; i <= 16; i++) {
		if (n < (1 << i)) break;
		base = i;
		if (n == (1 << i)) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	for (int i = 2; i < n; i += 2) {
		printf("%d %d\n", 1, i);
		printf("%d %d\n", i, i + 1);
		printf("%d %d\n", 1, i + 1 + n);
		printf("%d %d\n", i + 1 + n, i + n);
	}
	printf("%d 3\n", n + 1);
	if (n % 2 == 0) {
		int x = (1 << base), y = n - x + 1;
		printf("%d %d\n", n, x);
		printf("%d %d\n", n * 2, y + n);
	}
	return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


ll dp[1010][1010];
int main() {
  ll h,w;
  cin>>h>>w;
  vector<vector<char>> a(h);
  dp[1][1]=1;
  rep(i,h){
    a[i].resize(w);
    rep(j,w){
      cin>>a[i][j];
      if(a[i][j]=='.'){
        dp[i+1][j+1]+=(dp[i][j+1]+dp[i+1][j])%MOD;
      }
    }
  }
  cout<<dp[h][w];
  
  return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 200010;
const int maxK = 19;
int a[maxN];
int b[maxN];
int main()
{
	int n;
	scanf("%d",&n); 
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int head = 1,tail = n;
	int num = n;
	while(num>=1)
	{
		b[head++] = a[num--];
		if(num<1)
			break;
		b[tail--] = a[num--];
	}
	for(int i=1;i<n;i++)
		printf("%d ",b[i]);
	printf("%d\n",b[n]);
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <set>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll n, x, m; cin >> n >> x >> m;

  ll ans = x;
  ll curr = x;
  vector<int> seen(100005, -1);
  seen[x] = 0;
  for (int i = 1; i < n; i++) {
    curr = (curr*curr) % m;
    if (seen[curr] != -1) {
      ll start = curr;
      ll loop_size = i-seen[curr];
      ll rest_size = (n - i)%loop_size;
      ll rounds = (n - i)/loop_size;
      
      ll loop = 0;
      ll curr = start;
      for (int j = 0; j < loop_size; j++) {
        loop += curr;
        curr = (curr*curr) % m;
      }

      ans += (loop * rounds);

      ll rest = 0;
      curr = start;
      for (int j = 0; j < rest_size; j++) {
        rest += curr;
        curr = (curr*curr) % m;
      }

      ans += rest;

      break;
    } else seen[curr] = i;

    ans += curr;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3688
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false


int main() {
	string S[3];
	for (int i = 0; i < 3; i++) {
		cin >> S[i];
		reverse(all(S[i]));
	}
	int turn = 0;
	while (true) {
		if (S[turn].empty()) {
			cout << char(turn + 'A') << endl;
			return 0;
		}
		int tmp = turn;
		turn = S[turn].back() - 'a';
		S[tmp].pop_back();
	}

	return 0;
}

Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('');

  if(xs[0]==xs[1] || xs[1]==xs[2] || xs[2] == xs[3]){
    console.log('Bad');
  }else{
    console.log('Good');
  }
   
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> cnt(h, vector<int>(w));
    rep(i, h)
    {
        vector<int> done(w);
        rep(j, w)
        {
            if (s[i][j] == '#')
                continue;
            if (done[j])
                continue;
            int l = 0;
            while (j + l < w) {
                if (s[i][j + l] == '#')
                    break;
                ++l;
            }
            rep(k, l)
            {
                cnt[i][j + k] += l;
                done[j + k] = 1;
            }
        }
    }
    rep(j, w)
    {
        vector<int> done(h);
        rep(i, h)
        {
            if (s[i][j] == '#')
                continue;
            if (done[i])
                continue;
            int l = 0;
            while (i + l < h) {
                if (s[i + l][j] == '#')
                    break;
                ++l;
            }
            rep(k, l)
            {
                cnt[i + k][j] += l;
                done[i + k] = 1;
            }
        }
    }

    int ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 26492
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>>v(2,vector<int>(n));
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>v[i][j];
        }
    }
    vector<int>result(n);
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<n;j++)
        {
            int temp=v[i][j];
            int a=0,b=0;
            if(i>0)
            {
                a=v[i-1][j];
            }
            if(j>0)
            {
                b=v[i][j-1];
            }
            v[i][j]+=max(a,b);
        }
    }
    cout<<v[1][n-1];
}

Measured memory_bytes: 3608
s = str(input())
l = len(s)
#lr = [1 if s[i] == 'R' and s[i+1] == 'L' else 0 for i in range(l-1)]
'''
lrR = [-1 for _ in range(l-1)]
if s[0] == 'R':
    for j in range(0, l-1):
        if s[j] == 'R' and s[j+1] == 'L':
            lrR[0] = j
            break
for i in range(1, l-1):
    if s[i] == 'R' and s[i-1] == 'R':
        lrR[i] = lrR[i-1]
    elif s[i] == 'R' and s[i-1] == 'L':
        for j in range(i, l-1):
            if s[j] == 'R' and s[j+1] == 'L':
                lrR[i] = j
                break

lrL = [-1 for _ in range(l-1)]
if s[l-2] == 'L':
    for j in reversed(range(0, l-1)):
        if s[j] == 'R' and s[j+1] == 'L':
            lrL[l-2] = j
            break
for i in reversed(range(1, l-1)):
    print(i)
    if s[i] == 'L' and s[i+1] == 'L':
        print('a')
        lrL[i] = lrL[i+1]
    elif s[i] == 'L' and s[i+1] == 'R':
        print('b')
        for j in reversed(range(i)):
            print(j, s[j], s[j+1])
            if s[j] == 'R' and s[j+1] == 'L':
                lrL[i] = j
                break
    print(lrL)
print(lrR)
print(lrL)
#print(lr)
'''
ans = [0 for _ in range(l)]
pretmp = ['', -1]
for i in range(l):
    tmp = -1
    if s[i] == 'R':
        if pretmp[0] == 'R':
            tmp = pretmp[1]
        else:
            for j in range(i, l-1):
                if s[j] == 'R' and s[j+1] == 'L':
                    tmp = j
                    break
        if tmp == -1:
            ans[l-1] += 1
            continue
        if (tmp - i) % 2 == 0:
            ans[tmp] += 1
        else:
            ans[tmp+1] += 1
    elif s[i] == 'L':
        if pretmp[0] == 'L':
            tmp = pretmp[1]
        else:
            for j in reversed(range(0, i)):
                if s[j] == 'R' and s[j+1] == 'L':
                    tmp = j
                    break
        if tmp == -1:
            ans[0] += 1
            continue
        if (i - tmp) % 2 == 0:
            ans[tmp] += 1
        else:
            ans[tmp+1] += 1
    #print(ans)
    pretmp = [s[i], tmp]

for i in range(l-1):
    print(ans[i],end=' ')
print(ans[l-1])

Measured memory_bytes: 4876
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[1024];
    int n;
    int i, j;
	
    fgets(s, 2001, stdin);
    if (s[strlen(s) - 1] == '\n'){
        s[strlen(s) - 1] = '\0';
    }
		
	for (i = 0; s[i] != '\0'; i++){
	    if (strncmp(&s[i], "apple", 5) == 0){
	     	strncpy(&s[i], "peach", 5);
	    }
		else if (strncmp(&s[i], "peach", 5) == 0){
	        strncpy(&s[i], "apple", 5);
	    }
    }
     printf("%s\n", s);
     
    return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=100+5;
int a[N];
bool check(int a,int b,int c){

   if(a==b||a==c||b==c) return 0;
   return (a+b>c&&a+c>b&&b+c>a);
}
int main(){
    GO();
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                  cnt+= check(a[i],a[j],a[k]);
            }
        }
    }
    cout<<cnt<<"\n";
}





































































































































































































Measured memory_bytes: 3664
#include <iostream>
#include <string>

int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a < b && b < c)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




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


	if(n%2){
		ll mid=n/2;
		ll i=1;
	while(i<=m){
		cout<<i<<" "<<mid*2+1-i<<endl;
		i++;
	}
	}
	else{
		ll cnt=0;
		ll i=1;
		ll mid=n/2;
		ll j=mid+1;
		ll las=j+m-1;
		while(i<mid&&cnt<m){
			cout<<i<<" "<<mid<<endl;
			i++;
			mid--;
			cnt++;
		}
		while(j<las&&cnt<m){
			cout<<j<<" "<<las<<endl;
			j++;
			las--;
		}
	}

}


Measured memory_bytes: 3620
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    x,y = map(int, readline().split())

    i = 1
    while x * 2**i <= y:
        i += 1

    ans = i
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
n,m,x,y=map(int,input().split())
lis_x = list(map(int,input().split()))
lis_y = list(map(int,input().split()))
lis_x.sort()
lis_y.sort()
rest = []
for i in range(100):
    if i > lis_x[-1] and i <= lis_y[0]:
        rest.append(i)
for i in range(len(rest)):
    if x < rest[i] and rest[i] <= y:
        print('No War')
        exit()
print('War')


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

using i64 = int64_t;

i64 dp[102][12][1003]={0};

int main(){
    int n, s;
    while(cin >> n >> s, n != 0){
        for(int i=0;i<=100;++i){
            for(int j=0;j<=10;++j){
                for(int k=0;k<=1000;++k){
                    dp[i][j][k] = 0;
                }
            }
        }

        dp[0][0][0] = 1; dp[0][1][0] = 1;
        for(int i=0;i<100;++i){
            for(int j=0;j<=n;++j){
                for(int k=0;k<=s;++k){
                    dp[i+1][j][k] += dp[i][j][k];
                    if(j == n || k+i+1 > s)continue;
                    dp[i+1][j+1][k+i+1] += dp[i][j][k];
                }
            }
        }
        cout << dp[100][n][s] << endl;
    }

    return 0;
}



Measured memory_bytes: 12160
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <iostream>
#include <utility>
#include <sstream>
#include <cstring>
#include <bitset>
#include <climits>
 
using namespace std;
#define  AS(arr)  (sizeof(arr)/sizeof(arr[0]))
#define ALL(c) (c).begin(),(c).end() 
#define SIZE(a) int((a).size())
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef long long LL;
int a[100005];

int main(void){
    int N;
    cin >> N;
    long long ret = 0;
    REP(i, N) cin >> a[i];
    REP(i, N)
    {
        ret += a[i] / 2;
        a[i] %= 2;
        if( a[i+1] >= 1 && a[i] == 1)
        {
            ret += 1;
            a[i]--;
            a[i+1]--;
        }
        
    }
    cout << ret << endl;

}


Measured memory_bytes: 640