akhauriyash/Code-Regression huggingface dataset:
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("Failed to read line");
    let vec : Vec<&str> = line.split_whitespace().collect();

    let f1 : f64 = vec[0].parse().unwrap_or(0.0);
    let f2 : f64 = vec[1].parse().unwrap_or(0.0);

    let f_mul = f1 * f2;

    let n_mul : i64 = f_mul as i64;

    println!("{}", n_mul);
}

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

using cat = long long;

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

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	cin >> N >> M;
	vector<int> A(2*N);
	for(int i = 0; i < 2*N; i++) cin >> A[i];
	sort(begin(A), end(A));
	int ans_l = -1, ans_r = M-1;
	while(ans_r-ans_l > 1) {
		int S = (ans_l + ans_r) / 2;
		vector<bool> small_group_end(2*N, false);
		int end_min = 0, end_max = 2*N-1;
		int a = 2*N-1, b;
		for(int i = 0; i < N; i++) {
			while(a >= 0 && A[a]+A[i] > S) a--;
			b = i+1;
			if(a < b) break;
			end_min = max(end_min, i+b);
			end_max = min(end_max, i+a);
			if(end_min <= 2*i+1 && end_max >= 2*i+1) small_group_end[2*i+1] = true; 
		}
		vector<bool> large_group_end(2*N, false);
		end_min = 0, end_max = 2*N-1;
		a = 0, b = 2*N-1;
		while(b >= 0 && A[b]+A[2*N-1]-M > S) b--;
		for(int i = 0; i < N; i++) {
			while(a < 2*N && A[a]+A[2*N-1-i] < M) a++;
			while(b+1 < 2*N && A[b+1]+A[2*N-1-i]-M <= S) b++;
			if(a > b) break;
			end_min = max(end_min, a-i);
			end_max = min(end_max, b-i);
			if(end_min <= 2*(N-1-i) && end_max >= 2*(N-1-i)) large_group_end[2*(N-1-i)] = true; 
		}
		bool ok = false;
		for(int i = 1; i < N; i++)
			if(small_group_end[2*i-1] && large_group_end[2*i]) ok = true;
		if(!ok) {
			ok = true;
			for(int i = 0; i < N; i++) if((A[i]+A[2*N-1-i])%M > S) ok = false;
		}
		if(ok) ans_r = S;
		else ans_l = S;
	}
	cout << ans_r << "\n";
	return 0;
}

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


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define LL long long
#define f first
#define s second
using namespace std;
struct c
{
    int x,y,r;
    c(int x,int y,int r):x(x),y(y),r(r){}
};
vector<c>v;
double dist(c s1,c s2)
{
    LL x=s1.x-s2.x,y=s1.y-s2.y,r=s1.r+s2.r;
    return max(0.0,sqrt(x*x+y*y)-r);
}
int n,x,y,r;
double djk()
{
    vector<double>cost(1050,1e12);
    priority_queue<pair<double,int>,vector<pair<double,int> >,greater<pair<double,int> > >q;
    q.push({0,0});
    int i; double w,tot;
    while(q.size())
    {
        i=q.top().s;
        w=q.top().f;
        q.pop();
        if(w>cost[i])continue;
        cost[i]=w;
        for(int j=1;j<v.size();j++)
        {
            tot=dist(v[i],v[j])+cost[i];
            if(tot<cost[j])
            {
                cost[j]=tot;
                q.push({tot,j});
            }
        }
    }
    return cost[1];
}
int main()
{
    cin>>x>>y; v.push_back(c(x,y,0));
    cin>>x>>y; v.push_back(c(x,y,0));
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x>>y>>r,
        v.push_back(c(x,y,r));
    cout<<fixed<<setprecision(9)<<djk();
}


Measured memory_bytes: 6260
/*  -*- coding: utf-8 -*-
 *
 * 2700.cc: Airport Codes
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

/* global variables */

string acs[MAX_N];

/* subroutines */

inline bool is_vowel(char c) {
  return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
}

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;

      acs[i].clear();
      bool vf = true;
      for (int j = 0; j < s.size(); j++) {
	if (vf) acs[i] += s[j];
	vf = is_vowel(s[j]);
      }
    }
    sort(acs, acs + n);
    //for (int i = 0; i < n; i++) puts(acs[i].c_str());

    int maxk = 0;
    for (int i = 1; i < n; i++) {
      string &ac0 = acs[i - 1], &ac1 = acs[i];
      int l0 = ac0.size(), l1 = ac1.size(), l = min(l0, l1);
      int k = 0;
      for (; k < l && ac0[k] == ac1[k]; k++);
      if (k >= l && l0 == l1) {
	maxk = -1;
	break;
      }
      if (maxk < k + 1) maxk = k + 1;
    }

    printf("%d\n", maxk);
  }
  return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,k,a[1001],sum=0;
    cin>>n>>k;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for (int i = 0; i < k; i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
    
   return 0;
}

Measured memory_bytes: 3660
n = gets.chomp.to_i
p_arr = gets.chomp.split(" ").map(&:to_i)

n_arr = []
(1..n).each do |i|
  n_arr << i
end

count = 0
p_arr.each_with_index do |p, i|
  count += 1 if p != n_arr[i]
end

if count == 0 || count == 2 then
  puts "YES"
else
  puts "NO"
end


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

using namespace std;

int n, t;

int main() {
  cin >> n >> t;
  vector<int> f(t + 3005, -1);
  f[0] = 0;
  vector<pair<int, int>> a;
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    a.emplace_back(x, y);
  }
  sort(a.begin(), a.end());
  int nt;
  int res = 0;
  for (int j = 0; j < n; j++) {
    for (int i = t - 1; i >= 0; i--) {
      if (f[i] == -1) continue;
      nt = i + a[j].first;
      f[nt] = max(f[nt], f[i] + a[j].second);
      if (nt >= t) res = max(res, f[nt]);
    }
  }
  for (int i = 0; i < t; i++) {
    if (f[i] == -1) continue;
    res = max(res, f[i]);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int flag=0;
    for(int i=1;i<=n;i++)
    {
        if(n%i==0)
        {
            if((i>=1 && i<=9) && ((n/i)>=1 && (n/i)<=9))
            {
                flag=1;
            }
        }
    }
    if(flag==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N;
  cin >> N;
  ll count =0;
  vector<ll> A;
  ll a,sum;
  for(int i=0;i<N;i++){
    cin >> a;
    if(a<0){
      count++;
      //cout<<count<<endl;
      a=-a;
    }
    sum+=a;
    A.push_back(a);
  }
  
  if(count%2!=0){
    sort(A.begin(),A.end());
    sum-=2*(*A.begin());
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, A[MAXN], val[MAXN];
vector <ll> v;
ll index_c(ll x)
{
	auto lb = lbd(v, x) - v.begin();
	if(v[lb] != x) return -LLINF;
	else return lb;
}
int main()
{
	FAST
	cin >> n;
	FOR(i,0,n) { cin >> A[i]; v.pb(A[i]); }
	sort(all(v)); v.resize(unique(all(v))-v.begin());
	FOR(i,0,n) { val[index_c(A[i])] ++; }
	ll co = 1;
	while(co <= (ll) 1e14) co *= 2;
	while(co > 0)
	{
		FOR(i, 0, n)
		{
			if(val[index_c(A[i])] == 0 || A[i] > co) continue;
			val[index_c(A[i])] --;
			if(index_c(co-A[i]) != -LLINF && val[index_c(co-A[i])] > 0) { val[index_c(co-A[i])] --; continue; }
			val[index_c(A[i])] ++;
		}
		co /= 2;
	}
	ll ans = 0;
	for(ll i = 0; i < v.size(); i++) ans += val[i];
	cout << (n-ans)/2 << "\n";
}


Measured memory_bytes: 5616
N = gets.to_i
Ss = gets.split.map(&:to_i)
INF = 10**9 + 5
M = 1 << N

def born?(xs, ss)
  i = 1
  ys = xs.dup
  xs.reverse_each do |x|
    return false unless i = (i ... M).find{|j| ss[j] < x}
    ys << ss[i]
    ss[i] = INF
  end
  return true if ys.size == M
  born?(ys.sort, ss)
end

ss = Ss.sort.reverse
xs = ss[0, 1]
ss[0] = INF
puts born?(xs, ss) ? 'Yes' : 'No'

Measured memory_bytes: 41476
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

void solve() {
  int x;
  cin >> x;
  if (x < 1) {
    cout << "1" << endl;
  } else {
    cout << "0" << endl;
  }
}

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


Measured memory_bytes: 3524
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	ll N, W; scanf("%lld %lld", &N, &W);
	vector<ll> v(N), w(N); for (ll i = 0; i < N; i++) scanf("%lld %lld", &v[i], &w[i]);
	pair<ll, ll> half[2] = { make_pair(0,N / 2),make_pair(N / 2, N) };
	vector<vector<pair<ll, ll>>> vvp(2);
	for (ll i = 0; i < 2; i++) {
		ll cnt = half[i].second - half[i].first;
		ll s = half[i].first;
		for (ll S = 0; S < (1 << cnt); S++) {
			ll tv = 0;
			ll tw = 0;
			for (ll j = 0; j < cnt; j++) {
				if ((S >> j) & 1) {
					tv += v[s + j];
					tw += w[s + j];
				}
			}
			vvp[i].emplace_back(tw, tv);
		}
	}
	sort(vvp[0].begin(), vvp[0].end());
	sort(vvp[1].begin(), vvp[1].end());
	for (ll i = 1; i < vvp[1].size(); i++) {
		chmax(vvp[1][i].second, vvp[1][i - 1].second);
	}
	ll res = 0;
	for (auto p : vvp[0]) {
		auto itr = lower_bound(vvp[1].begin(), vvp[1].end(), make_pair(W - p.first, INF));
		if (itr == vvp[1].begin()) continue;
		itr--;
		chmax(res, p.second + itr->second);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 43764
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

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

	return 0;
}

Measured memory_bytes: 256
N = int(input())
V = list(int(i) for i in input().split())
C = list(int(i) for i in input().split())
R = list(range(N))
for i in range(N) :
  R[i-1] = V[i-1]-C[i-1] if V[i-1]-C[i-1] >=0 else 0
  
print(sum(R))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int a[5],k;
    F(i,0,5) cin >> a[i];
    cin >> k;
    bool f=true;
    F(i,1,5){
        F(j,0,i){
            if(a[i]-a[j]>k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
/*input
4
1 2 3 4
*/

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int ans = 0, step = 0;
    for (int i = 0; i < n-1; ++i) {
        if (h[i] >= h[i+1]) {
            ++step;
        }
        else {
            ans = max(ans, step);
            step = 0;
        }
    }
    cout << max(ans, step) << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	ll n = sz(s);

	ll kmin = 0, kmax = n+1;
	while (kmax-kmin > 1) {
		ll k = (kmin+kmax)/2;
		
		bool ok2 = false;
		FOR(m,0,2) {
			bool ok = true;
			ll lo = m, hi = k;
			while (hi%2 != m) hi--;
			
			if (lo > hi) ok = false;

			for (char c: s) {
				if (c == '0') lo++;
				else if (lo > 0) lo--;
				else lo++;

				if (c == '1') hi--;
				else if (hi < k) hi++;
				else hi--;
				
				if (lo > hi) ok = false;
			}
			if (ok) ok2 = true;
		}

		if (ok2) kmax = k; else kmin = k;
	}
	cout << kmax << endl;
}



Measured memory_bytes: 4284
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	l := make([]int, n+1)
	l[0], l[1] = 2, 1
	for i := 2; i <= n; i++ {
		l[i] = l[i-1] + l[i-2]
	}
	puts(l[n])
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
A,B,C,D=map(int,input().split())


def gcd(x,y):
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return y

#print(gcd(C,D))
ANS=0
ANS+=(B//C)
#print(ANS)
ANS-=((A-1)//C)
#(ANS)
ANS+=(B//D)
#print(ANS)
ANS-=((A-1)//D)
#print(ANS)
ANS-=(B//(C*D//gcd(C,D)))
ANS+=((A-1)//(C*D//gcd(C,D)))
#print(C*D//gcd(C,D))
print(B-A+1-ANS)
    

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int P,Q,R;
    Scd3(P,Q,R);

    int ans = P+Q+R - max(P,max(Q,R));
    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

int n, a, b, c;
vint l;

int calc(vint v){
	vint sumLen(4);
	fill(ALL(sumLen), 0);
	int cost = -30;
	rep(i, n){
		if(v[i] != 3) cost += 10;
		sumLen[v[i]] += l[i];
	}
	rep(i, 3){
		if(sumLen[i] == 0) return INF;
	}
	//cout << abs(a-sumLen[0]) + abs(b-sumLen[1]) + abs(c-sumLen[2]) << endl;
	return cost + abs(a-sumLen[0]) + abs(b-sumLen[1]) + abs(c-sumLen[2]);
}


int dfs(int depth, vint v){
	if(depth == n) return calc(v);
	int res = INF;
	rep(i, 4){
		v[depth] = i;
		res = min(res, dfs(depth+1, v));
	}
	return res;
}


int main(void){
	cin >> n >> a >> b >> c;
	l.resize(n); rep(i, n) cin >> l[i];
	vint v(n);
	cout << dfs(0, v) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean hasNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        static String toKaigyo(String[] list){return String.join("\n",list);}
        static String toHanSp(String[] list){return String.join(" ",list);}
        static treeNode[] tree;
  		public static void main(String[] args){
          int N = getInt();
          int Q = getInt();
          tree = new treeNode[N];
          for(int i = 0; i < N; i++){
           	 tree[i] = new treeNode();
          }
          for(int i = 0; i < N-1; i++){
            int mae = getInt() - 1;
            int ato = getInt() - 1;
            tree[mae].addNode(ato);
            tree[ato].addNode(mae);
          }
          for(int i = 0; i < Q; i++){
           	 tree[getInt()-1].setCount(getInt());
          }
          
          String[] output = new String[N];
          bfs();
          //myout("");
          
          for(int i = 0; i < N; i++){
            //myout(tree[i].nodes + " " + tree[i].counter);
            output[i] = String.valueOf(tree[i].sum);
          }
          myout(String.join(" ",output));
          
        }
        //便利メソッド追加枠ここから
  		static void bfs(){
          ArrayDeque<Integer[]> queue = new ArrayDeque<Integer[]>(1000);
          Integer[] first = new Integer[2];
          first[0] = 0;
          first[1] = tree[0].counter;
          queue.addFirst(first);
          tree[0].access = true;
          while(queue.size() > 0){
            Integer[] tmp = queue.pollFirst();
            tree[tmp[0]].addCount(tmp[1]);
            ArrayList<Integer> children = tree[tmp[0]].nodes;
            for(int i = 0; i < children.size(); i++){
              if(!tree[children.get(i)].access){
                tree[children.get(i)].access = true;
                Integer[] addQueue = new Integer[2];
                addQueue[0] = children.get(i);
                addQueue[1] = tmp[1] + tree[children.get(i)].counter;
                queue.addLast(addQueue);
              }
            }
          }
        }
		public static class treeNode{
          ArrayList<Integer> nodes = new ArrayList<Integer>();
          int counter = 0;
          int sum = 0;
          boolean access = false;
          treeNode(){}
          void addNode(int node){
            nodes.add(node);
          }
          void addCount(int count){
            sum += count;
          }
          void setCount(int count){
            this.counter += count;
          }
        }
        //便利メソッド追加枠ここまで
}


Measured memory_bytes: 145208
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    string s;
    cin>>s;
    if(s.at(2)==s.at(3) && s.at(4)==s.at(5)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 1e6 + 5;
const int mod = 0;
vector<int> pr;
int main(){
	pr.reserve(200);
	pr.push_back(2);
	for(int i = 3; i <= 1000; i++){
		bool io = true;
		for(auto it: pr){
			if(it * it > i) break;
			if(i % it == 0){
				io = false;
				break;
			}
		}
		if(io) pr.push_back(i);
	}
	int n, g;
	set<int> ss;
	bool ic = true;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		int x;
		scanf("%d", &x);
		if(i == 1) g = x;
		else if(g != 1) g = __gcd(g, x);
		if(!ic) continue;
		for(auto it: pr){
			if(it * it > x) break;
			if(x % it == 0){
				if(ss.count(it)) {
					ic = false;
					break;
				}
				ss.insert(it);
				while(x % it==0) x /= it;
			}
		}
		if(!ic) continue;
		if(x != 1) {
			if(ss.count(x)) ic = false;
			ss.insert(x);
		}
	}
	if(g == 1){
		printf(ic ? "pairwise coprime" : "setwise coprime");
	}
	else printf("not coprime");


}

Measured memory_bytes: 7464
MOD = 10**9 + 7
N,M = map(int, input().split())
a = [int(input()) for _ in range(M)]

aa = [True] * (N+1)
for i in a:
    aa[i] = False

dp = [0] * (N+1)
dp[0] = 1
if aa[1]:
    dp[1] = 1

for i in range(2,N+1):
    if (aa[i] == False):
        dp[i] = 0
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] =  dp[i] % MOD
print(dp[N])


Measured memory_bytes: 14388
# A, B, C
# B+C, C+A, A+B => 0A1B1C, 1A0B1C, 1A1B0C 1time => B-A
# CAAB, BCAB, BCCA => 2A1B1C, 1A2B1C, 1A1B2C 2time => A-B
# BCABBCCA, CAABBCCA, CAABBCAB => 2A3B3C, 3A2B3C, 3A3B2C 3time => B-A
# CAABBCCACAABBCAB, BCABBCCACAABBCAB, BCABBCCACAABBCCA
#    => 6A5B5C, 5A6B5C, 5A5B6C 4time => A-B

# 

A,B,C,K = map(int, raw_input().split())


# tmp_A = 0
# tmp_B = 0
# tmp_C = 0

# while K>0:
#     tmp_A = A
#     tmp_B = B
#     tmp_C = C
#     A = tmp_B + tmp_C
#     B = tmp_A + tmp_C
#     C = tmp_A + tmp_B
#     K = K -1
#     if A>0 and B>0 and C>0 and abs(A-B) > pow(10,18):
#         break

# ans=A-B

# if abs(ans) > pow(10,18):
#     print 'Unfair'
# else:
#     print ans

if (K % 2) == 0:
    if abs(A-B) > pow(10,18):
        print 'Unfair'
    else:
        print A-B
else:
    if abs(B-A) > pow(10,18):
        print 'Unfair'
    else:
        print B-A


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

int main() {
	int n;
	cin>>n;
	int* h=new int[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int max=0,count=0;
	for(int i=1;i<n;i++){
		if(h[i-1]>=h[i]){
			count++;
		}else{
			if(max<count){
				max=count;
			}
			count=0;
		}
	}
	if(max<count){
		max=count;
	}
	cout<<max<<endl;
	return 0;
}


Measured memory_bytes: 640
n=int(input())
temp=[0]*n
for i in range(0,n):
  s,p=input().split()
  temp[i]=[i,s,int(p)]
temp=sorted(temp, key=lambda x: (x[1],-x[2]))
for i in range(0,n):
  print(temp[i][0]+1)



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

public class Main {

	char ask(int i) {
		out.println(i);
		out.flush();
		String s = in.nextToken();
		if (s.equals("Vacant")) {
			out.close();
			System.exit(0);
		}
		return s.charAt(0);
	}

	void solve() {
		int n = in.nextInt();
		char start = ask(0), end = ask(n - 1);
		int l = 0, r = n - 1;
		while (r - l > 2) {
			int m = (l + r) / 2;
			if (m % 2 == 1) {
				m--;
			}
			char ask = ask(m);
			if (ask == start) {
				l = m;
			} else {
				r = m;
			}
		}
		ask((l + r) / 2);
		throw new AssertionError();
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

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

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

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

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


Measured memory_bytes: 23720
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

ll gcd(ll a, ll b){
  return b?gcd(b,a%b):a;
}
int main(){
  ll a,b; 
  cin >> a >> b;
  ll g = gcd(a,b);
  cout << a*b/g <<endl;
  return 0;
}


Measured memory_bytes: 256
#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>
#include <iomanip>

#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(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C,D;cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int X = s.nextInt();
        int fiveHundred = X/500;
        X -= fiveHundred*500;
        int five = X/5;
        System.out.println(fiveHundred*1000+five*5);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define int long long
using namespace std;
double n,k,a[10000005];
bool OK(int req){
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=((a[i]-1)/req);
	}
	if(sum<=k){
		return true;
	}
	else{
		return false;
	}
}
signed main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int l=1,r=1e9+7,ans=1e9+7;
	while(l<=r){
		int mid=(l+r)/2;
		if(OK(mid)){
			ans=mid;
			r=mid-1;
		}
		else{
			l=mid+1;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5196
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

//const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__

void solve(void){
  
  int N;
  
  cin >> N;
  
  vector<int> d(N);
   
  REP(i,N){
    cin >> d[i];
  }
  
  ll ans=0;
  
  REP(i,N){
    REP2(j,i+1,N){
      ans += d[i]*d[j];
    }
  }
  
  cout << ans << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long 
int main()
{
	ll x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<string(y2-y1,'U');
	cout<<string(x2-x1,'R');
	cout<<string(y2-y1,'D');
	cout<<string(x2-x1,'L');
	cout<<"L";
	cout<<string(y2-y1+1,'U');
	cout<<string(x2-x1+1,'R');
	cout<<"DR";
	cout<<string(y2-y1+1,'D');
	cout<<string(x2-x1+1,'L');
	cout<<"U";
}


Measured memory_bytes: 256
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      h: usize, w: usize, k: usize,
      caa: [proconio::marker::Chars; h]
    };

    let mut ans = 0;

    for s in 0..(1 << h) {
        for t in 0..(1 << w) {
            let mut cnt = 0;
            for ss in 0..h {
                if (s >> ss) & 1 == 1 {
                    continue;
                }
                for tt in 0..w {
                    if (t >> tt) & 1 == 1 {
                        if caa[ss][tt] == '#' {
                            cnt += 1;
                        }
                    }
                }
            }
            if cnt == k {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2136
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
// scanf("%d", &x); => std::cin >> x;
// printf("%d\n", x); => std::cout << x << "\n";

int main() {
    int n;
    int Di[105];
    int Dj[105];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &Di[i], &Dj[i]);
    }

    int counter = 0;
    int max = 0;
    for (int i = 0; i < n; i++) {
        if (Di[i] == Dj[i]) {
            counter++;
            if (counter >= 3) {
                puts("Yes");
                return 0;
            }

        } else {
            max = counter;
            counter = 0;
        }
    }

    if (max >= 3) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	long long MIN = 1, MAX = N;
	for (long long i = 1; i < N; i++) {
		if (A.at(i - 1) >= A.at(i)) MIN++;
	}
	cout << MIN << endl << MAX << endl;
}



Measured memory_bytes: 3620
#pragma GCC optimize("O3,inline,unroll-loops")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 100020
using namespace std;

int v[N];

int main(void)
{
    int n, q, x, b, c;
    int i;
    long long o;

    scanf("%d", &n);
    for(i = o = 0; i < n; i ++)
    {
        scanf("%d", &x);
        o += x;
        v[x] ++;
    }

    scanf("%d", &q);
    while(q --)
    {
        scanf("%d %d", &b, &c);
        o += (long long)(c - b) * v[b];
        v[c] += v[b];
        v[b] = 0;
        printf("%lld\n", o);
    }

    return 0;
}


Measured memory_bytes: 4216
# -*- coding: utf-8 -*-

import sys
import numpy as np

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

# dp[この子までの範囲で][飴を配る総数] = 場合の数
dp = np.zeros((N+1, K+1), dtype=np.int64)
# 0番目まで(誰もいない)の範囲で0個配る場合の数は1通り
dp[0,0] = 1

for i, a in enumerate(A):
    # 今回のiを次の遷移させる区間の始点としてまとめて追加
    dp[i+1] = dp[i]
    # 今回のiをa+1個ずらして、遷移させる区間の終点としてまとめて追加
    dp[i+1,a+1:] -= dp[i,:-(a+1)]
    # 累積和すれば、元の状態からそれぞれa個先まで遷移させた状態になる
    # (区間の始点・終点の記録→累積和の流れはimos的な感じ)
    np.cumsum(dp[i+1], out=dp[i+1])
    dp[i+1] %= MOD

print(dp[N][K])


Measured memory_bytes: 90576
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int b6[12];
int b9[12];
int n;
int ans = 1<<30;


void dfs(int now, int sel) {
    if(now < 0) {
        return;
    }
    int p9 = 9;
    int p6 = 6;
    FOR(i, 1, 11) {
        int ddd = b9[i];
        if(ddd > now) break;
        p9 = ddd;
    }
    FOR(i, 1, 11) {
        int ddd = b6[i];
        if(ddd > now) break;
        p6 = ddd;
    }
    ans = min(ans, sel + now);
    dfs(now - p9, sel+1);
    dfs(now - p6, sel+1);
}

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

    cin >> n;

    REP(i, 12) {
        b6[i] = power(6, i);
        b9[i] = power(9, i);
    }

    dfs(n, 0);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
h,n = map(int, input().split())
ab = []
amax = 10**5
for _ in range(n):
  ab.append(tuple(map(int,input().split())))
amax = max(a for a,b in ab)
p = [0]*(h+amax+1)
for i in range(1,h+amax):
  p[i] = min(p[i-a]+b for a,b in ab)
print(p[h])

Measured memory_bytes: 9556
from itertools import combinations_with_replacement
n,m,q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

ans = 0
for i in combinations_with_replacement(range(1,m+1), n):
  t = 0
  for j in abcd:
    if i[j[1]-1] - i[j[0]-1] == j[2]: t += j[3]
  ans = max(ans, t)
print(ans)

Measured memory_bytes: 9108
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <algorithm>

using namespace std;

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

  vector<int> P, sortedP;

  for (int n=0; n<N; ++n) {
    int p;
    cin >> p;
    P.push_back(p);
    sortedP.push_back(p);
  }

  sort(sortedP.begin(), sortedP.end());

  int count = 0;
  for (int n=0; n<N; ++n) {
    if (P[n]!=sortedP[n])
      ++count;
  }

  cout << (count==2 || count==0 ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 1e5+5,mod = 1e9+7;
it add(int x,int y){ return x+y>=mod?x+y-mod:x+y; }
it mul(int x,int y){ return 1ll*x*y%mod; }
il inc(int &x,int y){ x=add(x,y); }
int n,k,ans,f[N];
int cnt[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(k);
	for(ri i=k;i>=1;--i){
		int tval=k/i;
		f[i]=qpow(tval,n,mod);
		for(ri j=2;j<=tval;++j) inc(f[i],mod-f[i*j]);
		inc(ans,mul(f[i],i));
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 4028
#include <stdio.h>

int main(void)
{
	int M,N,n=0;
	int i,j,a,t=0;
	
	scanf("%d%d",&M,&N);
	for(i=0;i<M;i++){
		t=0;
		for(j=0;j<N;j++){
			scanf("%d",&a);
			if(a) t++;
		}
		n<t?(n=t):(n=n);
	}
	printf("%d\n",n);

	return 0 ;
}

Measured memory_bytes: 600
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(n, k);
    VIN(ll, v, n);
    sort(all(v));
    ll s = 0;
    rep(i, k) {
        s += v[i];
    }
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<vector<int>> d(n + 1, vector<int>());
    for(int i = 0; i < n; i++) {
        int ti, di;
        cin >> ti >> di;
        d[ti].push_back(di);
    }
    for(auto& v : d) {
        sort(v.begin(), v.end());
    }
    sort(d.begin() + 1, d.end(), [](auto& v1, auto& v2) {
        return not v1.empty() and (v2.empty() or v1.back() > v2.back());
    });
    int ntypes = count_if(d.begin() + 1, d.end(), [](auto& v) { return not v.empty(); });
    ll ans = 0, deli = 0;
    priority_queue<ll, vector<ll>, greater<ll>> ds;
    for(ll x = 1; x <= min(k, ntypes); x++) {
        if(ds.size() > k - x) {
            deli -= ds.top(); ds.pop();
        }
        deli += d[x].back();
        d[x].pop_back();
        while(not d[x].empty()) {
            ds.push(d[x].back());
            deli += d[x].back();
            d[x].pop_back();
            if(ds.size() > k - x) {
                deli -= ds.top(); ds.pop();
            }
        }
        ans = max(ans, x * x + deli);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
N=int(input())
A=list(map(int,input().split(' ')))

AjtoN=sum(A)
Asum=0
for i in range(N):
    AjtoN-=A[i]
    Asum+=A[i]*AjtoN
    Asum=Asum%(10**9+7)

print(Asum)

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

int main() {
    int n;
    cin >> n;
    double value=0;
    vector<double> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n;i++) {
        if (i == 0) {
            value = v.at(i);
        }
        else {
            value = (value + v.at(i)) / 2;
        }
    }
    cout << value << endl;
}

Measured memory_bytes: 3796
import sys
X,Y=[int(x) for x in input().rstrip().split()]
y=float((Y-2*X)/2)
x=float(X-y)

if x.is_integer() and y.is_integer():
  if x==0 and y==0:
    print("No")
    sys.exit()

  if 0<=x and 0<=y:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 9196
/*
    B - ATCoder
    https://atcoder.jp/contests/abc122/tasks/abc122_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    string s;
    cin >> s;

    int max_length = 0, cur = 0;
    for (size_t i = 0; i < s.size(); i++) {
        char ch = s.at(i);
        if (ch == 'A' || ch == 'T' || ch == 'G' || ch == 'C')
            cur++;
        else
            cur = 0;

        if (max_length <= cur)
            max_length = cur;
    }

    cout << max_length << endl;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	a,b,c = readline() |> split |> parseMap
	k = readline() |> parseInt
	x = 0
	while b<=a
		b*=2
		x+=1
	end
	while c<=b
		c*=2
		x += 1
	end
	println(x<=k ? "Yes" : "No")
end

main()

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

const int mod = 1e9 + 7;

template< class T >
struct ConvexHullTrickAddQueryMonotone {
  deque< pair< T, T > > L;
  int isdec;

  ConvexHullTrickAddQueryMonotone() : isdec(-1) {}

  inline T getX(const pair< T, T > &a, const T &x) {
    return (a.first * x + a.second);
  }

  inline bool check(const pair< T, T > &a, const pair< T, T > &b, const pair< T, T > &c) {
    return ((b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first));
  }

  inline bool empty() { return (L.empty()); }

  void add(T a, T b) {
    pair< T, T > line(a, b);

    if(isdec == -1 && !L.empty()) {
      if(a < L[0].first) isdec = 1;
      else if(a > L[0].first) isdec = 0;
    }

    if(isdec == 1) {
      if(!L.empty() && L.back().first == a) {
        line.second = min(line.second, L.back().second);
        L.pop_back();
      }
      while(L.size() >= 2 && check(L[L.size() - 2], L.back(), line)) L.pop_back();
      L.emplace_back(line);
    } else {
      if(!L.empty() && L.front().first == a) {
        line.second = min(line.second, L.front().second);
        L.pop_front();
      }
      while(L.size() >= 2 && check(line, L[0], L[1])) L.pop_front();
      L.emplace_front(line);
    }
  }

  T getMinimumQuery(T x) {
    int low = -1, high = (int) L.size() - 1;
    while(high - low > 1) {
      int mid = (low + high) >> 1;
      if((getX(L[mid], x) >= getX(L[mid + 1], x))) low = mid;
      else high = mid;
    }
    return (getX(L[high], x));
  }

  T getMinimumQueryMonotone(T x) {
    while(L.size() >= 2 && getX(L[0], x) >= getX(L[1], x)) {
      L.pop_front();
    }
    return (getX(L[0], x));
  }
};


int main() {
  int N;
  int64 C;
  int64 H[200000];

  scanf("%d %lld", &N, &C);
  for(int i = 0; i < N; i++) scanf("%lld", &H[i]);
  ConvexHullTrickAddQueryMonotone< int64 > conv;
  conv.add(-2 * H[0], H[0] * H[0]);
  for(int i = 1; i < N; i++) {
    int64 uku = conv.getMinimumQueryMonotone(H[i]) + H[i] * H[i] + C;
    if(i + 1 == N) printf("%lld\n", uku);
    else conv.add(-2 * H[i], uku + H[i] * H[i]);
  }
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const Int MAX = 222;
Int dp[MAX]={};
Int nx[MAX]={};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  const Int INF = 1e18;
  for(Int j=0;j<MAX;j++) dp[j]=-INF;

  dp[200]=1000;
  for(Int i=0;i<n;i++){
    for(Int j=1;j<MAX;j++) nx[j]=-INF;

    for(Int j=1;j<MAX;j++){
      if(dp[j]<0) continue;
      chmax(nx[j],dp[j]);

      chmax(nx[as[i]],dp[j]);
      chmax(nx[as[i]],(dp[j]/j)*as[i]+(dp[j]%j));
    }

    for(Int j=1;j<MAX;j++) dp[j]=nx[j];
  }
  cout<<*max_element(dp+1,dp+MAX)<<newl;
  return 0;
}


Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var st = ReadLine();
        var s = "CODEFESTIVAL2016";
        var ct = 0;
        for (var i = 0; i < st.Length; i++)
            if (st[i] != s[i]) ct++;WriteLine(ct);
    }
}


Measured memory_bytes: 11092