akhauriyash/Code-Regression huggingface dataset:
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

template<typename Monoid> struct Segment_Tree{
    //二項演算
    Monoid ope(Monoid a, Monoid b) {return min(a, b);}
    //単位元
    Monoid unit;
    int n;
    vector<Monoid> seg;
    //要素数N(0-indexed)のxを単位元とするセグメント木を構築
    Segment_Tree(int N, Monoid x){
        unit = x;
        n = 1;
        while(n < N) n <<= 1;
        seg.assign(2*n, unit);
    }
    //i番目の要素をxに変更
    void change(int i, Monoid x){
        i += n;
        seg[i] = x;
        while(i > 0){
            i /= 2;
            seg[i] = ope(seg[2*i], seg[2*i+1]);
        }
    }
    //query(a, b)で[a, b)における演算の結果を取得
    Monoid query(int a, int b, int i = 1, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return unit;
        elif(a <= l && r <= b) return seg[i];
        else{
            Monoid vl = query(a, b, 2*i, l, (l+r)/2);
            Monoid vr = query(a, b, 2*i+1, (l+r)/2, r);
            return ope(vl, vr);
        }
    }
    //i番目の要素を取得
    Monoid at(int i){
        return seg[n+i]; 
    }
    //初期化する
    void clear(){
        fill(seg.begin(), seg.end(), unit);
    }
};

const int MAX_N = 1e5;
//seg2[i]:=A[2*i],seg1[i]=A[2*i+1]
Segment_Tree<pii> seg2(MAX_N, pii(inf, inf)), seg1(MAX_N, pii(inf, inf));
int p[2*MAX_N];
using P = pair<int, pii>;
priority_queue<P, vector<P>, greater<P> > que;

//[l,r)での辞書順最小のペアのインデックスを返す
pii dfs1(int l, int r){
    //辞書順最小のもの
    int L, R;
    pii a, b;
    if(l%2 == 0){
        a = seg2.query(l/2, r/2);
        L = a.second;
        b = seg1.query(L/2, r/2);
        R = b.second;
    }
    else{
        a = seg1.query(l/2, r/2);
        L = a.second;
        b = seg2.query((L+1)/2, (r+1)/2);
        R = b.second;
    }
    return pii(L, R);
}

int main(){
    int N;
    cin >> N;
    rep(i, N){
        cin >> p[i];
        if(i%2 == 0) seg2.change(i/2, pii(p[i], i));
        else seg1.change(i/2, pii(p[i], i));
    }
    vector<int> ans;
    que.push(P(p[dfs1(0, N).first], pii(0, N)));
    while(!que.empty()){
        int l = que.top().second.first, r = que.top().second.second;
        que.pop();
        pii x = dfs1(l, r);
        int L = x.first, R = x.second;
        ans.pb(p[L]), ans.pb(p[R]);
        if(l < L) que.push(P(p[dfs1(l, L).first], pii(l, L)));
        if(L+1 < R) que.push(P(p[dfs1(L+1, R).first], pii(L+1, R)));
        if(R+1 < r) que.push(P(p[dfs1(R+1, r).first], pii(R+1, r)));
    }
    for(auto &e: ans) cout << e << ' ';
    cout << endl;
}

Measured memory_bytes: 7848
#include<stdio.h>
#define H 250
int parent(int i);
int left(int i);
int right(int i);

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int h,i;
  int A[H];
  scanf("%d",&h);
  for(i = 1; i <= h; i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= h) printf("left key = %d, ",A[left(i)]);
    if(right(i) <= h) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string go = string(tx - sx, 'R') + string(ty - sy, 'U'),
         back = string(tx - sx, 'L') + string(ty - sy, 'D');
  cout << go + back + "DR" + go + "UL" + "UL" + back + "DR" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int a[3000000];
int main()
{
	int n,i,j,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0,j=1;i<n;i++)
	{
		if(a[i]==j)
		{
		s++;j++;}
	}
	if(j==1)
	printf("-1\n");
	else
	printf("%d\n",n-s);
	
}

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

int main(){
  double x1,x2,x3,x4,y1,y2,y3,y4;
  double abx,aby,cdx,cdy,abr,cdr;
  int n;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    abx=x1-x2;
    aby=y1-y2;
    cdx=x3-x4;
    cdy=y3-y4;
    
    abr=sqrt(abx*abx+aby*aby);
    cdr=sqrt(cdx*cdx+cdy*cdy);

    abx=abx/abr;
    aby=aby/abr;
    cdx=cdx/cdr;
    cdy=cdy/cdr;

    if(abx==cdx&&aby==cdy)
      cout<<"YES\n";
    else if(abx==-1*cdx&&aby==-1*cdy)
      cout<<"YES\n";
    else
      cout<<"NO\n";
  }
  return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    S = input().strip()
    if S[-1] in '24579':
        print('hon')
    elif S[-1] in '0168':
        print('pon')
    else:
        print('bon')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61684
#include<stdio.h>

int main(){
	int i,j,d=0;
	while(scanf("%d",&d)!=EOF){
		int s=0;
		for(i=1;i*d<600-d;i++){
			s=s+(i*d*i*d)*d;
		}
		s=s+(600-d)*(600-d)*d;
		printf("%d\n",s);
	}
return 0;
}

Measured memory_bytes: 596
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	LL k, a, b;
	cin >> k >> a >> b;
	LL bis = 1;
	if (b > a+2) {
		while (k > 0) {
			if (bis >= a&&k>=2) {
				k -= 2;
				bis -= a;
				bis += b;
			}
			else {
				bis++;
				k--;
			}
		}
		cout << bis;
	}
	else {
		while (k > 0) {
			bis++;
			k--;
		}
		cout << bis;
	}
	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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

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

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

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

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

fn main() {
    input!{
      l: chars,
    }
    let n = l.len();
    let mut dp = vec![vec![0; 2]; n+1];
    const OK: usize = 1;
    const EQ: usize = 0;
    dp[0][EQ] = 1;
    for i in 0..n {
        dp[i+1][OK] = dp[i][OK] * 3 % MOD;
        if l[i] == '1' {
            dp[i+1][EQ] += dp[i][EQ] * 2;
            dp[i+1][EQ] %= MOD;
            dp[i+1][OK] += dp[i][EQ];
            dp[i+1][OK] %= MOD;
        } else {
            dp[i+1][EQ] += dp[i][EQ];
            dp[i+1][EQ] %= MOD;
        }
    }
    // for i in 0..n+1 {
    //     debug!(i, dp[i]);
    // }
    let ans = dp[n][OK] + dp[n][EQ];
    println!("{}", ans % MOD);
}


Measured memory_bytes: 10492
A = [list(map(int,input().split())) for _ in range(3)]

R1 = [A[i][1] - A[i][0] for i in range(3)]
R2 = [A[i][2] - A[i][1] for i in range(3)]
C1 = [A[1][i] - A[0][i] for i in range(3)]
C2 = [A[2][i] - A[1][i] for i in range(3)]

ok = True
for x in [R1,R2,C1,C2]:
  if len(set(x)) != 1:
    ok = False
    break
    
if not ok:
  print('No')
else:
  print('Yes')
  

  





Measured memory_bytes: 3064
using System;

class Untitled
{
	static void Main(string[] args)
	{
		// ???????????´??° x, y ?????????????????????????????????????°?????????????????????????????????°??????????????????????????????
		// x, y???0????????????
		bool parsed = false;
		int a = 0, b = 0;
		string s = null;
		while (!string.IsNullOrEmpty (s = Console.ReadLine ())) {
			string[] strs = s.Split (' ');
			if (strs.Length >= 2) {
				parsed = Int32.TryParse (strs [0], out a);
				if (parsed) {
					parsed = Int32.TryParse (strs [1], out b);
				}
			}

			if (parsed) {
				if (a == 0 && b == 0)
					break;
				if (a < b) {
					System.Console.WriteLine (a + " " + b);
				} else {
					System.Console.WriteLine (b + " " + a);
				}
			}
			parsed = false;
			a = b = 0;
			s = null;
		}
	}
}

Measured memory_bytes: 9372
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		for (int i = 1; i <= 365; i++) {
			int num = (int) (Math.random() * 26.0);
			out(num + 1);

		}

	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static void debug() {
		out("---");
	}

	static void debug(long a) {
		out("-------");
		out(a);
		out("-------");
	}

	static void debug(String a) {
		out("-------");
		out(a);
		out("-------");
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static long min(long d, long e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

bool dfs(int a, int layer, const vector<vi>& g, vi& btoa,
			vi& A, vi& B) {
	if (A[a] != layer) return 0;
	A[a] = -1;
	trav(b, g[a]) if (B[b] == layer + 1) {
		B[b] = -1;
		if (btoa[b] == -1 || dfs(btoa[b], layer+2, g, btoa, A, B))
			return btoa[b] = a, 1;
	}
	return 0;
}

int hopcroftKarp(const vector<vi>& g, vi& btoa) {
	int res = 0;
	vi A(g.size()), B(btoa.size()), cur, next;
	for (;;) {
		fill(all(A), 0);
		fill(all(B), -1);
		/// Find the starting nodes for BFS (i.e. layer 0).
		cur.clear();
		trav(a, btoa) if(a != -1) A[a] = -1;
		rep(a,0,sz(g)) if(A[a] == 0) cur.push_back(a);
		/// Find all layers using bfs.
		for (int lay = 1;; lay += 2) {
			bool islast = 0;
			next.clear();
			trav(a, cur) trav(b, g[a]) {
				if (btoa[b] == -1) {
					B[b] = lay;
					islast = 1;
				}
				else if (btoa[b] != a && B[b] == -1) {
					B[b] = lay;
					next.push_back(btoa[b]);
				}
			}
			if (islast) break;
			if (next.empty()) return res;
			trav(a, next) A[a] = lay+1;
			cur.swap(next);
		}
		/// Use DFS to scan for augmenting paths.
		rep(a,0,sz(g)) {
			if(dfs(a, 0, g, btoa, A, B))
				++res;
		}
	}
}


int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int> > a(n, vector<int>(m));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	vector<vector<int> > b(m, vector<int>(n, 0));
	for(int _ = 0; _ < m; _++){
		vector<vector<int> > g(n);
		vector<int> btoa(n, -1);
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(a[i][j] == 0) continue;
				int st = i;
				int en = (a[i][j] - 1) / m;
				g[st].push_back(en);
			}
		}
		assert(hopcroftKarp(g, btoa) == n);
		for(int i = 0; i < n; i++){
			int r = btoa[i];
			for(int j = 0; j < m; j++){
				if(a[r][j] == 0) continue;
				if((a[r][j] - 1) / m == i){
					swap(a[r][j], b[_][r]);
				}
			}
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(j > 0) cout << ' ';
			cout << b[j][i];
		}
		cout << '\n';
	}
	for(int j = 0; j < m; j++){
		sort(b[j].begin(), b[j].end());
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(j > 0) cout << ' ';
			cout << b[j][i];
		}
		cout << '\n';
	}
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    long x;
    void Solve() {
        //input
        x = io.Long;
        //cal
        var ans = x <=  6 ? 1 :
                  x <= 11 ? 2 :
                  (x / 11) * 2 + (x % 11 == 0 ? 0 : 
                                  x % 11 <= 6 ? 1 :
                                                2);
        //ret
        WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  return Pow(A * A % MOD, N / 2) * A % MOD;
}

int main(){
  ll N; cin >> N;
  ll ans = Pow(10, N);

  ans -= Pow(9, N) * 2; ans %= MOD;
  ans += Pow(8, N); ans %= MOD;
  if (ans < 0) ans += MOD;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[100100];
ll X[100100];
int main(){
    int N, Q;
    cin >> N >> Q;
    vector<ll> sum(N);
    bool even = (N%2 == 0);
    vector<ll> skip(N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
        if(i == 0) sum[i] = a;
        else sum[i] = a + sum[i-1];
    }
    REP(i,Q){
        ll x;
        cin >> x;
        X[i] = x;
    }

    int start = even;
    int k;
    for(int i = start, k = 0; i < N; i+=2, k++){
        if(k == 0) skip[k] = A[i];
        else skip[k] = A[i] + skip[k-1];
    }

    //sort(X, X+Q);


    for(int i = 0; i < Q; i++){
        ll x = X[i];
        int left = 0;
        int right = N;
        //while(right - left > 0){
        while(right - left > 1){
            int mid = (left + right)/2;
            ll m = A[mid];
            if(m < x){
                left = mid;
                continue;
            }
            ll diff = abs(x - m);
            int t = N - mid;
            int a;
            a = lower_bound(A, A+N, x+diff) - lower_bound(A, A+N, x-diff) + 1;
            if(t > a){
                left = mid;
            }
            else if(t <= a){
                right = mid;
            }
        }
        //printf("right:%d\n", right);
        ll ans = 0;
        ans += sum[N-1] - sum[right-1];
        int num = N - right;
        int rem = N - 2*num;
        if(rem > 0){
            ans += skip[(rem-1)/2];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)||s.at(1)==s.at(2)&&s.at(2)==s.at(3)){
    cout<<"Yes"<<endl;
  }
  
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

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;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s; cin >> s;
    stack<int> st;
    rep(i,s.size()){
        if(s[i]=='0'){
            st.push(0);
        }else if(s[i]=='1'){
            st.push(1);
        }else{
            if(!st.empty()){
                st.pop();
            }
        }
    }
    stack<int> ans;
    while(!st.empty()){ans.push(st.top());st.pop();}
    while(!ans.empty()){cout<<ans.top();ans.pop();}
                                
}



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

bool p[1000002];

void mkPrime(void){
	memset(p,true,sizeof(p));
	p[0] = p[1] = false;
	for(int i=0;i<=1000000;i++){
		if(p[i]){
			for(int j=i+i;j<=1000000;j+=i){
				p[j] = false;
			}
		}
	}
}

int main(void){
	int n;
	mkPrime();

	while(cin>>n,n){
		int ans = 0;
		for(int i=0;i<n;i++){
			if(i > n-i) break;
			if(p[i] && p[n-i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
/*
ID: Aman Raj
LANG: C++
TASK: subset
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
  //# define mod 1e9+7

int main()
 {

   ifstream fin("tcase.txt");
    ofstream fout("subset.out");
   ll n;cin>>n;
            vector<ll> v(n);
      // v.resize(n);
          for(ll i=0;i<n;i++)
          {
              cin>>v[i];
          }
          vector<vector<ll> > dp(n+1,vector<ll>(n+1,1e18L));

          for(ll l=n;l>=1;l--)
          {  ll s=0;
              for(ll r=l;r<=n;r++)
              {   s+=v[r-1];
                  if(l==r)
                  {
                      dp[l][r]=0;
                  }
                  else
                  {
                      for(ll x=l;x<r;x++)
                      {
                          dp[l][r]=min(dp[l][r],dp[l][x]+dp[x+1][r]+s);
                      }
                  }
              }
          }


       cout<<dp[1][n];
}


Measured memory_bytes: 1536
N, L = [s for s in input().split()]


apples_taste = []
abs_apples_taste = []

for i in range(int(N)):
  apples_taste.append(i+int(L))
  abs_apples_taste.append(abs(i+int(L)))

abs_apples_taste.sort()
if abs_apples_taste[0] in apples_taste:
  print(sum(apples_taste) - abs_apples_taste[0])
else:
  print(sum(apples_taste) + abs_apples_taste[0])

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

int main()
{
  string s;
  cin>>s;
  int count_a=0,count_b=0;
  int ans=1;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='A'){
      count_a++;
    }
    else
    {
      count_b++;}}
  if(count_a ==0 || count_b==0)
  {ans=0;
  }
  if(ans)
  {cout<<"Yes"<<endl;
  }
  else
  {cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
const long long md=1e9+7;
long long n,k,ans,ans2,a[2020];
map<long long,long long>mp;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]>a[j])
			{
				ans++;
			}
		}
	}
	for(map<long long,long long>::iterator it1=mp.begin();it1!=mp.end();it1++)
	{
		for(map<long long,long long>::iterator it2=mp.begin();it2!=mp.end();it2++)
		{
			if((it1->first)<=(it2->first))
			{
				continue;
			}
			ans2+=(it1->second*it2->second)%md;
			ans2%=md;
		}
	}
	long long sum=(k*(k-1)/2)%md;
	cout<<(ans*k%md+ans2*sum%md)%md<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int n, x, y;
    cin >> n>>x>>y;
    --x; --y;
    vi ans(n);
    rep(i,n){
        vi dist(n, INT_MAX);
        queue<int> q;
        auto push = [&](int a, int d) {
            if(dist[a] != INT_MAX) return;
            q.push(a);
            dist[a] = d;
        };
        q.push(i);
        dist[i] = 0;
        while(!q.empty()) {
            int v = q.front(); q.pop();
            int d = dist[v];
            if(v-1>=0) push(v-1, d+1);
            if(v+1<n)  push(v+1,d+1);
            if(v==x)   push(y, d+1);
            if(v==y)   push(x, d+1);
        }
        rep(i,n) ans[dist[i]]++;
    }
    rep(i,n) ans[i] /= 2;
    FOR(i,1,n) cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
#include <string>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P= pair<ll,ll>;
const ll MOD = 1000000007;
int main() {
    ll N;
    cin>>N;
    vector<ll> A(N);
    vector<ll> B(N+1,0);
    
    ll answer=0;
    rep(i,N){
      cin>>A[i];
      B[i+1]=B[i]+A[i];
    }
    for(int i=0;i<N;i++)
    {
      ll sum=(B[N]-B[i+1])%MOD;
      answer +=A[i]*sum;
      answer %=MOD;
    }
    //if(D/S>T)cout<<"No"<<endl;
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    string p="";
    int sum = 0;
    int result = 0;
    for (int i=0; i < s.size() - t.size() + 1; i++) {
        sum = 0;
        string temp = s.substr(i, t.size());
        for (int j = 0; j < t.size(); j++) {
            if (temp[j] == t[j]) {
                sum++;
            }
        }
        if (result < sum) {
            result = sum;
        }
    }
    
    cout << t.size() - result << endl;
}

Measured memory_bytes: 3612
import sys
import decimal # 10進法に変換，正確な計算

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

def main():
    h, n = map(int, input().split())
    a = list(map(int, input().split()))    
    for i in a:
        h -= i
        if h <= 0:
            print("Yes")
            return
    print("No")
    

main()

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,check="CF"; cin >> S;
    int now=0;
    for (char c:S){
        if (c==check[now]) ++now;
        if (now==2){cout << "Yes" << '\n'; return 0;}
    }
    cout << "No" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n,k; 
vector<int> a;
vector<int> dp;

int rec(int key){

    if(dp.at(key) !=  -1) return dp.at(key);

    int res = -1;

    for(int go : a){
        if(key - go >= 0){
            if(res != -1 && rec(key-go) == res) return dp.at(key) = 1;
            else res = abs(1-rec(key-go));
        }
    }

    return dp.at(key) = res;

}

int main(){

    cin >> n >> k;
    a.resize(n);
    rep(i,n) cin >> a.at(i);
    dp.assign(k+1,-1);

    rep(i,a.at(0)) dp.at(i) = 0;

    string ans = rec(k) ? "First" : "Second";
    cout << ans << endl;

    return 0;   

}


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

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ar[N];
    int okCnt = 0;
    int soso = 0;
    for(int i=0; i<N; i++){
        cin >> ar[i];
        if(ar[i] %4 == 0) okCnt++;
        else if(ar[i] % 2 ==0) soso++;
    }
    soso /= 2;
    okCnt += soso;
    int no = N - okCnt;

    if(okCnt+1 >= N-okCnt)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll N,A,B,K;
    cin >> N >> A >> B >> K;
    COMinit();
    ll ans=0;
    rep(i,N+1){
        ll sum=K-A*i;
        if (sum<0||sum%B!=0){
            continue;
        }
        ll j=sum/B;
        if (i+j>2*N){
            continue;
        }
        ans+=COM(N,i)*COM(N,j)%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
//bismillah
//created by anaksoleh
//24 Dec 2019
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
int N,W;
bool computed[103][100005];
ll dp[103][100005];
ll value[103];
ll weight[103];

ll solve(ll n,ll c)
{
    if(n == 0)return 0;
    if(computed[n][c])return dp[n][c];

    ll best = solve(n-1,c);
    if(c >= weight[n]){
        best = max(best,solve(n-1,c - weight[n]) + value[n]);
    }
    computed[n][c] = true;
    dp[n][c] = best;
    return best;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N >> W;
    for(int i = 1 ; i <= N ; i++){
        cin >> weight[i] >> value[i];
    }
    solve(N,W);
    cout << dp[N][W] << '\n';

    return 0;
}

Measured memory_bytes: 89728
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_array<T: FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: u32 = read();
    let mut a = read_array::<u32>(n);
    a.sort_by(|x, y| x.cmp(y).reverse());
    let mut alice = 0;
    let mut bob = 0;
    for (i, &x) in a.iter().enumerate() {
        if i % 2 == 0 {
            alice += x;
        } else {
            bob += x;
        }
    }
    println!("{}", alice - bob);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 105;
int main() {
	string s; cin >> s;
	int cnt = 0, ans = 0;
	for(int i = 0; i < s.size(); i++)	{
		if(s[i] == 'R') {
			cnt = 1;
			while(i + 1 < s.size() && s[i + 1] == 'R') {
				cnt++;
				i++;
			}
			ans = max(ans, cnt);
		}
	}
	cout << ans << "\n";
	return 0; 
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int n;
 cin >> n;
 vector<int> a(n);
 for(int i=0;i<n;i++) cin >> a[i];
 for(int i=n-2;i>=0;i--){
  if(a[i]>a[i+1]) a[i]--; 
 }
 bool ok=1;
 for(int i=1;i<n;i++){
  ok&=(a[i]>=a[i-1]);
 }
 if(ok) cout << "Yes" << endl;
 else cout << "No" << endl;
 return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    int n,x; cin>>n>>x;
    V l(n+1);
    l[0] = 0;
    for(int i=1; i<=n; i++) cin >> l[i];
    for(int i=1; i<=n; i++) l[i] += l[i-1];
    int ans = 0;
    for(int i=0; i<=n; i++){
        if(l[i] > x) break;
        ans++;
    }
    OUT(ans);
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,x;
	int ans=0;
	cin >>n>>x;
	int at = 0;
	int l;
	rep(i, n) { 
		cin >> l;
		
		at += l;
		if (at <= x) {
			ans++;
		}
	}

	cout<<ans+1<<endl;
}


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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int x = 0;
            for (int i = 0; i < 3; i++)
            {
                if (a[i] == '1')
                {
                    x += 1;
                }
            }
            Console.WriteLine(x);           
        }
    }
}


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

int main(){
	while(true){
		double a,b,c,d,e,f;
		cin>>a>>b>>c>>d>>e>>f;
		if(cin.fail()) break;
		double x=(c*e-b*f)/(a*e-b*d);
		double y=(c*d-a*f)/(b*d-a*e);
		if(x==0) x=0;
		if(y==0) y=0;
		cout<<fixed<<setprecision(3)<<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
def check(s, m, parity):
    lo = parity
    hi = m - (m - parity) % 2

    for c in s:
        if c == '0':
            lo += 1
            hi += 1
        elif c == '1':
            lo -= 1
            hi -= 1
        else:
            lo -= 1
            hi += 1

        if lo < 0:
            lo += 2
        if hi > m:
            hi -= 2

        if lo > hi:
            return False

    return True


s = input()
l, r = 0, len(s)
while l + 1 < r:
    m = (l + r) // 2
    if check(s, m, 0) or check(s, m, 1):
        r = m
    else:
        l = m
print(r)


Measured memory_bytes: 70664
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a[100001], b[100001];
    cin >> n;
    priority_queue<pair<llong, int> > sum_A_plus_B;
    rep(i, n) {
        cin >> a[i] >> b[i];
        sum_A_plus_B.push(make_pair(a[i] + b[i], i));
    }

    llong ans = 0; 
    rep(i, n) {
        if (i % 2 == 0) ans += a[sum_A_plus_B.top().second];
        else ans -= b[sum_A_plus_B.top().second];

        sum_A_plus_B.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2932
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

#define INF 100000000

int N, A, B, C, l[10];

int min(int len, ...) {
    int i, _min, num;
    va_list ap;
    va_start(ap, len);

    _min = va_arg(ap, int);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, int);
        if (num < _min)
            _min = num;
    }
    va_end(ap);
    return _min;
}

int dfs(int cur, int a, int b, int c) {
    int ret0, ret1, ret2, ret3;
    if (cur == N+1) {
        if (min(3, a, b, c) > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else return INF;
    }
    ret0 = dfs(cur + 1, a, b, c);
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    return min( 4, ret0, ret1, ret2, ret3 );
}

int main(void) {
    int i;
    scanf("%d%d%d%d", &N, &A, &B, &C);
    for (i=1;i<=N;i++) scanf("%d", &l[i]);

    printf("%d\n", dfs(1,0,0,0));

    return 0;
}

Measured memory_bytes: 128
fun main() {
    val h = nextInt()
    val w = nextInt()
    val k = nextInt()
    val s = Array(h) {
        next().toCharArray()
    }
    var min = h + w
    for (i in 0 until (Math.pow(2.0, (h - 1).toDouble()).toInt())) {
        val cutList = mutableListOf<Cut>()
        var current = Cut()
        cutList += current
        current.lines += s[0]
        var mod = 1
        for (j in 1 until h) {
            if (i and mod != 0) {
                current = Cut()
                cutList += current
            }
            current.lines += s[j]
            mod *= 2
        }
        var count = Integer.bitCount(i)
        var ok = true
        var needCut = false
        loop@ for (j in 0 until w) {
            for (cut in cutList) {
                if (cut.add(j) > k) {
                    ok = false
                    break@loop
                }
                if (cut.sum > k) {
                    needCut = true
                }
            }
            if (needCut) {
                count++
                for (cut in cutList) {
                    cut.sum = 0
                    cut.add(j)
                }
                needCut = false
            }
        }
        if (ok) {
            min = Math.min(min, count)
        }
    }
    println(min)
}

class Cut {
    val lines = mutableListOf<CharArray>()
    var sum = 0

    fun add(i: Int): Int {
        var res = 0
        for (line in lines) {
            res += line[i] - '0'
        }
        sum += res
        return res
    }
}

val scanner = java.util.Scanner(System.`in`)
fun next(): String = scanner.next()
fun nextInt() = scanner.nextInt()
fun nextLong() = scanner.nextLong()
fun nextLine(): String = scanner.nextLine()
fun nextList() = nextLine().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextIntArray(n: Int) = IntArray(n) { nextInt() }
fun nextLongList() = nextList().map(String::toLong)
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")

fun main(args: Array<String>) = main()

Measured memory_bytes: 62508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int N,Q;
map<int,int>M;
ll modpow(ll base, ll expo){
	ll res=1;
	while(expo>0){
		if(expo&1)res=res*base%MOD;
		base=base*base%MOD;
		expo>>=1;
	}
	return res;
}
ll nCr(ll n, ll r){
	ll res=1;
	FOR(i,n-r+1,n)res=res*i%MOD;
	ll d=1;
	FOR(i,1,r)d=d*i%MOD;
	return res*modpow(d,MOD-2)%MOD;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll N,M,K;
	cin>>N>>M>>K;
	cout<<(N*N%MOD*(M*(M*(M+1)/2)%MOD-M*(M+1)%MOD*(2*M+1)%MOD*modpow(6,MOD-2)%MOD+MOD)%MOD+M*M%MOD*(N*(N*(N+1)/2)%MOD-N*(N+1)%MOD*(2*N+1)%MOD*modpow(6,MOD-2)%MOD+MOD)%MOD)%MOD*nCr(N*M-2,K-2)%MOD<<"\n";
}
/*
1 3
#.#


2 3
#.#
..#

3 3
##.
#.#
..#

3
2 5
6 1
3 7
Ans:6

4
3 7
2 9
8 16
10 8
Ans:9
*/


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef deque<ll> dqll;

#define MOD 1000000007

int main() {
  ll N;

  cin >> N;

  vll lst(N);

  for (int i = 0; i < N; i++) {
    cin >> lst[i];
  }

  ll costA = 0;
  ll costB = 0;

  ll sum = 0;
  for (ll i = 0; i < N; i++) {
    if(i % 2 == 0){ // +
      if(sum + lst[i] > 0){
        sum += lst[i];
      } else{
        costA += abs(sum + lst[i] - 1);
        sum = 1;
      } // if +
    } else{ // -
      if(sum + lst[i] < 0){
        sum += lst[i];
      } else{
        costA += abs(sum + lst[i] - (-1));
        sum = -1;
      }
    } // else -
  }

  sum = 0;
  for (ll i = 0; i < N; i++) {
    if(i % 2 != 0){ // +
      if(sum + lst[i] > 0){
        sum += lst[i];
      } else{
        costB += abs(sum + lst[i] - 1);
        sum = 1;
      } // if +
    } else{ // -
      if(sum + lst[i] < 0){
        sum += lst[i];
      } else{
        costB += abs(sum + lst[i] - (-1));
        sum = -1;
      }
    } // else -
  }

  ll ans = min(costA, costB);
  cout << ans << endl;

  return 0;
}


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

int main(){
  int N; cin >>N;
  int H[N];
  for(int i=0;i<N;i++){
    cin >>H[i];
  }

  for(int i=1;i<N;i++){
    if(H[i]-H[i-1]>0) H[i] -= 1;
    else if(H[i]-H[i-1]<0) {
      cout << "No" <<endl;
      return 0;
    }
  }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,m;
double a[200010],d[200010];
double res=0;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	d[0]=0;
	for (int i=0;i<n;i++) d[i+1]=d[i]+(double)(1+a[i])/2.0;
	for (int i=0;i<=n-m;i++) res=max(res,d[i+m]-d[i]);
	cout <<setprecision(10);
	cout <<res;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;

int n, k, h[maxn], dp[maxn];

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

int main()
{
	n = read(), k = read();
	for(int i = 1; i <= n; i ++)
	{
		h[i] = read();
	}
	dp[1] = 0;
	for(int i = 2; i <= n; i ++)
	{
		dp[i] = inf;
		for(int j = 1; j <= k; j ++)
		{
			int res = i - j;
			if(res < 1)break;
			int ans = dp[res] + abs(h[i] - h[res]);
			dp[i] = min(dp[i], ans);
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;
	cin>>s;

	lli gNum=0,pNum=0;

	lli ans = 0;
	REP(i,0,s.size()){
		if(s.at(i)=='g')gNum++;
		else pNum++;
	}

	cout<<(gNum-pNum)/2<<endl;

	return 0;
}

Measured memory_bytes: 512