akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline
write = sys.stdout.write
flush = sys.stdout.flush

def query(n):
    write("? %d\n" % n)
    flush()
    return readline().strip() == 'Y'
def answer(n):
    write("! %d\n" % n)
    flush()

"""
N = 188
q = 0
def dummy(n, N):
    return ((n <= N and str(n) <= str(N)) or (n > N and str(n) > str(N)))
def query(n):
    global q
    q += 1
    assert q <= 64
    print q, n, N, dummy(n, N)
    return dummy(n, N)
def answer(n):
    print "check", n, N
    assert n == N
"""

dig = None
for i in xrange(10):
    if not query(10**i):
        dig = i
        break
else:
    # 10**k
    for i in xrange(10):
        if query(10**i+1):
            answer(10**i)
            break
    exit(0)

left = 10**(dig-1); right = 10**dig
while left+1 < right:
    mid = (left + right) / 2
    if query(mid*10):
        right = mid
    else:
        left = mid
#print right
answer(right)


Measured memory_bytes: 3036
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;


using ll=long long int;


int main() {

	int a, b;
	cin >> a >> b;

	if (a + b < 10) {
		cout << a + b << endl;
	}
	else {
		cout << "error" << endl;
	}

	return 0;
}





Measured memory_bytes: 256
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

date_str = SR()
date_formatted = datetime.datetime.strptime(date_str, "%Y/%m/%d")
dt = datetime.datetime(2019, 4, 30, 23, 59)
if date_formatted <= dt:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 5576
#include <iostream>
using namespace std;
int main(){
    int x1, x2, y1, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x3 - (y3 - y2);
    y4 = y3 + (x3 - x2);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    int h[n+2]={0};
    for (i=1;i<=n;i++)
        cin>>h[i];
    /*cout<<"Initial array:\n";
    for (i=1;i<=n;i++)
        cout<<h[i]<<", ";
    cout<<endl;*/
    int st,cnt,cur,ans=0;
    while (1)
    {
        int f=0,pre[n+2]={0};
        st=0;
        cnt=0;
        cur=0;
        bool flag=false;
        for (i=1;i<=n;i++)
        {
            if (h[i]==0)
            {
                cnt++;
                //f=0;
                pre[st]-=cur;
                pre[i]+=cur;
                ans+=cur;
                cur=0;
                if (flag)
                    break;
            }
            else
            {
                flag=true;
                if (f==0)
                    st=i;
                if (cur==0)
                    cur=h[i];
                else
                    cur=min(cur,h[i]);
                f=1;
            }
        }
        if (cnt==n)
            break;
        if (cur>0)
        {
            pre[st]-=cur;
            pre[i]+=cur;
            ans+=cur;
        }
        cnt=0;
        for (i=1;i<=n;i++)
        {
            pre[i]+=pre[i-1];
            h[i]+=pre[i];
            if (h[i]==0)
                cnt++;
        }
        /*cout<<"Array stats after step "<<ans<<":\n";
        for (i=1;i<=n;i++)
            cout<<h[i]<<", ";
        cout<<endl;*/
        if (cnt==n)
            break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define REP(i,m,n) for(ll i = (ll)(m); i < (ll) (n) ;i++)
#define rep(i,n)  REP(i , 0 , n)
using namespace std;

ll l, r, tmp, s;
ll ans = 2018;


int main(){
	cin >> l >> r;
	s = r - l + 1;

	if (s >= 4038 || l == 0){
		cout << 0 << endl;
	}
	else{
		REP(i, l, r + 1){
			REP(j, l, r + 1){
				if (i != j){
					ans = min((i * j) % 2019, ans);
				}
			}
		}
		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <array>

using namespace std;

constexpr int64_t INF = 1e15;

class Edge {
public:
    int to;
    int64_t cap;
    int rev;
};

vector<Edge> G[110];
//bool used[110];
array<bool, 110> used;

void add_edge(int from, int to, int64_t cap){
    G[from] .push_back((Edge){to, cap, (int)G[to].size()});
    G[to] .push_back((Edge){from, 0, (int)G[from].size() - 1});
}

int64_t dfs(int v, int t, int64_t f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); ++i){
        Edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int64_t d = dfs(e.to , t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int64_t max_flow(int s, int t){
    int64_t flow = 0;
    while(true){
        fill(used.begin(), used.end(), false);
        int64_t f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

//int64_t a[110];

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

    int64_t sum = 0;
    for(int i = 1; i <= N; ++i){
        int64_t a;
        cin >> a;
        if(a <= 0){
            add_edge(0, i, -a);
        }
        else {
            add_edge(i, N + 1, a);
            sum += a;
        }
        
        for(int j = 2 * i; j <= N; j += i){
            add_edge(i, j, INF);
        }
    }

    cout << (sum - max_flow(0, N + 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var S = Read();
            var ans = "";
            var sby = 0;
            for (int i = 0; i < N; i++)
            {
                if (S[i] == '(')
                {
                    ans += "(";
                    sby++;
                }
                else
                {
                    if (sby > 0)
                    {
                        ans = ans + ")";
                        sby--;
                    }
                    else
                    {
                        ans = "(" + ans + ")";
                    }
                }
            }
            while (sby > 0)
            {
                ans += ")";
                sby--;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    int aa = 0;
    int a[n];
    rep(i, n)
    {
        cin >> a[i];
        aa += a[i];
    }
    int cnt = 0;
    rep(i, n)
    {
        if (a[i] * 4 * m >= aa)
        {
            cnt++;
        }
    }
    if (cnt >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

#define INF 2147483647
#define RMQ_SIZE 262144

using namespace std;

void update(int pos, int value);
int getSum(int right, int left);
int dfs(int a,int b,int k,int l,int r);

vector<int> tree(RMQ_SIZE, 0);

int main()
{
    int n, q;
    cin >> n >> q;

    for (int i = 0; i < q; i++) {
        int tmp, a, b;
        cin >> tmp >> a >> b;
        if (tmp) {
            cout << getSum(a, b+1) << endl;
        } else {
            update(a, b);
        }
    }
            
    return 0;
}


int dfs(int a,int b,int k,int l,int r)
{
    //* ????±????????????????????????¬???????????¢?´¢.
    if (r <= a || b <= l) {
        return 0;
    }
    //* ??¨?????¬?????????????±?????????\???????????????.
    if (a <= l && r <= b) {
        return tree[k];
    }
    int m = (l+r)/2;
    return dfs(a, b, k*2+1, l, m) + dfs(a, b, k*2+2, m, r);
}

int getSum(int right, int left)
{
    return dfs(right, left, 0, 0, RMQ_SIZE/2);
}

void update(int pos, int value)
{
    pos += (RMQ_SIZE/2 -1);
    tree[pos] += value;
    while (pos) {
        pos = (pos-1)/2;
        tree[pos] = tree[pos*2+1] + tree[pos*2+2];
    }
}

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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int A, B, C;
    cin >> A >> B >> C;
    cout << (A == B && B == C ? "Yes" : "No") << "\n";
    
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A+B)>(C+D)) {
    cout << "Left" << endl;
  }
  if ((A+B)==(C+D)) {
    cout << "Balanced" << endl;
  }
  if ((A+B)<(C+D)) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define long long long
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

vector<int> a[1005];
void dump(const vector<int> &v)
{
  if (v.empty()) { cout << '\n'; return; }

  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << (i+1 < v.size() ? ' ' : '\n');
  }
}

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;


  while(q--) {
    int com, t, x;
    cin >> com;

    if (com == 0) {
      cin >> t >> x;
      a[t].emplace_back(x);
    }
    else if (com == 1) {
      cin >> t;
      dump(a[t]);
    }
    else {
      cin >> t;
      a[t].clear();
    }
  }

  return 0;
}




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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b);
  for(int i=0; i<a; i++){
    cin >> s[i];
  }
  for(int i=0; i<b; i++){
    cin >> t[i];
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  for(int i=0; i<q; i++){
    ll x, ans=100000000009;
    cin >> x;
    auto Iter1 = upper_bound(s.begin(), s.end(), x);
    auto Iter2 = upper_bound(t.begin(), t.end(), x);
    int m = Iter1 - s.begin();
    int n = Iter2 - t.begin();
    ll s1, s2, t1, t2;
    if(m!=0) s1 = abs(x-s[m-1]);
    if(m!=a) s2 = abs(x-s[m]);
    if(n!=0) t1 = abs(x-t[n-1]);
    if(n!=b) t2 = abs(x-t[n]);
    if(m!=0&&n!=b) ans = min(ans,s1 + t2 + min(s1,t2));
    if(m!=a&&n!=0) ans = min(ans, s2 + t1 + min(s2,t1));
    if(m!=a&&n!=b) ans = min(ans, max(s2, t2));
    if(m!=0&&n!=0) ans = min(ans, max(s1, t1));
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4800
run (function * (write, gets) {
	var n = parseInt(yield, 10);

	for (var i=0; i<n; ++i) {
		if ('Y' === (yield)) {
			write("Four");
			return;
		}
	}

	write("Three");
});

/**
 * @param {(write: (line: string, end?: string) => void, gets: () => IterableIterator<string|null>) => IterableIterator<any>} main 
 */
function run (main) {
	var istream = process.stdin;
	var ostream = process.stdout;

	/**
	 * @type {[string|null]}
	 */
	var words = [];
	/**
	 * @type {[string]}
	 */
	var lines = [];
	var rest = "";
	var ended = false;
	var INPUT_MODE_LINE = 0;
	var INPUT_MODE_WORD = 1;
	var input_mode = INPUT_MODE_WORD;

	/**
	 * @param {string} line 
	 * @param {string} [end] 
	 */
	function write (line, end) {
		ostream.write(line + (undefined === end ? os.EOL : end));
	}
	function *gets () {
		if (0 < lines.length) {
			return lines.shift();
		} else {
			input_mode = INPUT_MODE_LINE;
			/**
			 * @type {string}
			 */
			var line = yield;
			input_mode = INPUT_MODE_WORD;
			return line;
		}
	}

	var main_itr = main(write, gets);

	/**
	 * @param {string|null} chunk 
	 */
	function get_chunk (chunk) {
		istream.pause();
		if (null === chunk) {
			lines.push(null);
		} else {
			rest += chunk;
			var line_exp = /.*(\r?\n|\r)/g;
			var line_match, lastIndex = 0;
			while (null !== (line_match = line_exp.exec(rest))) {
				lastIndex = line_exp.lastIndex;
				lines.push(line_match[0]);
			}
			rest = rest.substring(lastIndex);
		}
		loop();
	}

	function loop () {
		while (0 < lines.length) {
			switch (input_mode) {
				case INPUT_MODE_LINE:
				{
					words.push(lines.shift());
				}
				break;
				case INPUT_MODE_WORD:
				{
					if (null === lines[0]) {
						words.push(lines.shift());
					} else {
						var word_exp = /[^\s]+/g;
						var line_match;
						if (null !== (line_match = word_exp.exec(lines[0]))) {
							words.push(line_match[0]);
							lines[0] = lines[0].substring(word_exp.lastIndex);
						} else {
							lines.shift();
						}
					}
				}
				break;
			}

			while (0 < words.length) {
				var result = main_itr.next(words.shift());
				if (undefined !== result.value) {
					if ('string' === typeof result.value) {
						write(result.value, "");
					} else {
						write(`${result.value}`, "");
					}
				}
				if (result.done) return;
			}
		}

		ended ? setTimeout(get_chunk, 0, null) : process.stdin.resume();
	}
	istream.on('data', get_chunk);
	istream.on('end', function () {
		ended = true;
		get_chunk(null);
	});

	istream.setEncoding('utf8');
	get_chunk(null);
};

var os = require('os');


Measured memory_bytes: 22084
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  int N;
  cin >> N;
  if (N%2==0){
    cout << pow(N/2, 2) << endl;
  } else {
    cout << (N/2) * (N/2 + 1) << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=105;
namespace G{
	int f[N][N],x[N],y[N],vis[N],n,tim;
	inline void init(int _n){
		n=_n,tim=1;
		memset(f,0,sizeof f);
		memset(vis,0,sizeof vis);
		memset(x,0,sizeof x);
		memset(y,0,sizeof y);
	}
	int dfs(int u){
		vis[u]=tim;
		rep(v,1,n)
			if(f[u][v]){
				if(!y[v]||vis[y[v]]!=tim&&dfs(y[v])){
					y[v]=u,x[u]=v;
					return 1;
				}
			}
		return 0;
	}
	inline void solve(){
		rep(i,1,n)
			if(!x[i]){
				dfs(i);
				tim++;
			}
		// cerr<<tim<<endl;
	}
}
int bl[N][N],a[N][N],b[N][N],c[N][N],used[N][N];
int n,m;


int main(){
	read(n),read(m);
	rep(i,1,n)
		rep(j,1,m){
			read(a[i][j]);
			bl[i][j]=(a[i][j]-1)/m+1;
		}
	rep(j,1,m){
		G::init(n);
		rep(i,1,n)rep(k,1,m)
			G::f[i][bl[i][k]]|=!used[i][k];
		G::solve();
		rep(i,1,n){
			int cur=0;
			rep(k,1,m)
				if(!used[i][k]&&G::x[i]==bl[i][k]){
					cur=k;break;
				}
			used[i][cur]=1;
			b[i][j]=a[i][cur];
			c[bl[i][cur]][j]=a[i][cur];
		}
	}
	rep(i,1,n){
		rep(j,1,m)
			printf("%d ",b[i][j]);
		puts("");
	}
	rep(i,1,n){
		rep(j,1,m)
			printf("%d ",c[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,m,a,b;
char s[2333][2333];
void putt()
{
	vector<pii> vs;
	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
			if(s[i][j]=='.'&&s[i][j+1]=='.'
			&&s[i+1][j]=='.'&&s[i+1][j+1]=='.')
			{
				vs.pb(pii(i,j));
				s[i][j]=s[i][j+1]=s[i+1][j]=s[i+1][j+1]='*';
			}
	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
			if(s[i][j]=='.'&&s[i][j+1]=='.'&&a)
			{
				--a; s[i][j]='<'; s[i][j+1]='>';
			}
	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
			if(s[i][j]=='.'&&s[i+1][j]=='.'&&b)
			{
				--b; s[i][j]='^'; s[i+1][j]='v';
			}
	while(a&&!vs.empty())
	{
		pii g=vs.back();
		vs.pop_back();
		int i=g.fi,j=g.se;
		if(a) {s[i][j]='<'; s[i][j+1]='>'; --a;}
		++i; if(a) {s[i][j]='<'; s[i][j+1]='>'; --a;}
	}
	while(b&&!vs.empty())
	{
		pii g=vs.back(); vs.pop_back();
		int i=g.fi,j=g.se;
		if(b) {s[i][j]='^'; s[i+1][j]='v'; --b;}
		++j; if(b) {s[i][j]='^'; s[i+1][j]='v'; --b;}
	}
}
int main()
{
	cin>>n>>m>>a>>b; int a_=a,b_=b;
	if(a+b>n*m/2||a>n*(m/2)||b>m*(n/2))
	{
		puts("NO");
		return 0;
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			s[i][j]='.';
	putt();
	if(a==0&&b==0)
	{
		puts("YES");
		for(int i=1;i<=n;++i,puts(""))
			for(int j=1;j<=m;++j)
			{
				if(s[i][j]=='*') s[i][j]='.';
				putchar(s[i][j]);
			}
		return 0;
	}
	a=a_,b=b_;
	memset(s,0,sizeof s);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			s[i][j]='.';
	if(n>=3&&m>=3);else
	{
		puts("NO");
		return 0;
	}
	for(int i=n-2;i<=n;++i)
		for(int j=m-2;j<=m;++j)
			s[i][j]='*';
	if(a) {s[n-2][m-2]='<'; s[n-2][m-1]='>'; --a;}
	if(a) {s[n][m-1]='<'; s[n][m]='>'; --a;}
	if(b) {s[n-1][m-2]='^'; s[n][m-2]='v'; --b;}
	if(b) {s[n-2][m]='^'; s[n-1][m]='v'; --b;}
	putt();
	if(a==0&&b==0)
	{
		puts("YES");
		for(int i=1;i<=n;++i,puts(""))
			for(int j=1;j<=m;++j)
			{
				if(s[i][j]=='*') s[i][j]='.';
				putchar(s[i][j]);
			}
		return 0;
	}
	puts("NO");
}


Measured memory_bytes: 9548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextLong();
            var M = Input.NextLong();

            if (N * 2 >= M) {
                Console.WriteLine(M / 2);
            } else {
                Console.WriteLine(N + (M - 2 * N) / 4);
            }

        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b\n";
    }else if(a<b){
        cout<<"a < b\n";
    }else{
        cout<<"a == b\n";
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define DOWN(T) std::greater<T>()
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
using vpii = vector<pii>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------

vi a;
int n;


int f(int positive) {
	int s = 0;
	int ans = 0;
	REP(i, n) {
		s += a[i];
		if (i % 2 == positive) {
			if (s <= 0) {
				ans += abs(s) + 1;
				s = 1;
			}
		}
		else {
			if (s >= 0) {
				ans += abs(s) + 1;
				s = -1;
			}
		}
	}
	return ans;
}

signed main()
{
	QUICK_CIN;
	debug_input;

	cin >> n;
	REP(i, n) {
		int c;
		cin >> c;
		a.push_back(c);
	}

	cout << min(f(1), f(0)) << endl;

}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

void func_A() {

    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe";
    else cout << "safe";
}

void func_B() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (a > 0) {
        c -= b;
        if (c <= 0) break;
        a -= d;
    }

    if (c <= 0) cout << "Yes";
    else cout << "No";
 
}

void func_C() {


}

void func_D() {


}

int main() {

    //func_A();
    func_B();
    //func_C();
    //func_D();

    return 0;

}

Measured memory_bytes: 3596
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll x(n);
  rep(i, n){
    cin >> x[i];
  }
  ll ans = INF;
  repr(i, 1, 101){
    ll tmp = 0;
    rep(j, n){
      tmp += (x[j]-i)*(x[j]-i);
    }
    chmin(ans, tmp);
  }
  print(ans);
}


Measured memory_bytes: 256
from collections import Counter

N, M = map(int, input().split())
Alist = list(map(int, input().split()))
Blist = [0]
for i in range(len(Alist)):
    Blist.append((Blist[-1] + Alist[i])%M)

c = Counter(Blist)

ans = 0
for key, val in c.items():
    ans += val * (val - 1) / 2

print(int(ans))

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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int n, A[MAX], B[MAX];

bool check(){
	int C[MAX], D[MAX];
	for(int i=0; i<=n; i++) C[i]=A[i], D[i]=B[i];
	sort(C, C+n+1); sort(D, D+n+1);
	for(int i=0; i<=n; i++)
		if(C[i]!=D[i]) return false;
	return true;
}

int m=0;

int f(int x){
	static map<int, int> mem;
	if(mem.find(x)!=mem.end()) return mem[x];
	return mem[x]=++m;
}

int U[MAX], sz[MAX];
int find(int x){
	return x==U[x] ? x : U[x]=find(U[x]);
}
void unite(int x, int y){
	x = find(x), y = find(y);
	if(x!=y) U[y] = x, sz[x]+=sz[y];
}

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

	cin>>n;
	for(int i=1; i<=n; i++) cin>>A[i], A[0]^=A[i];
	for(int i=1; i<=n; i++) cin>>B[i], B[0]^=B[i];

	if(!check()){ cout<<"-1\n"; return 0; }


	for(int i=0; i<=n; i++){
		A[i] = f(A[i]); B[i] = f(B[i]);
	}

	for(int i=1; i<=m; i++) U[i] = i, sz[i] = 1;

	int ans=n+1;
	for(int i=0; i<=n; i++)
		if(A[i]!=B[i]){
			unite(A[i], B[i]);
		} else {
			ans--;
		}
	
	for(int i=1; i<=m; i++){
		if(i!=find(i) || sz[i]==1) continue;
		if(find(i)!=find(A[0])) ans++;
		if(find(i)==find(A[0]) && A[0]!=B[0]) ans--;
	}

	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
int main(){
int x[100],a,k=0,y[100],i,m=0;
while(scanf("%d",&a)!=EOF){
if(a==0)
y[m++]=x[--k];
else if(a!=0){
x[k]=a;
k++;
}
}
for(i=0;i<m;i++)
printf("%d\n",y[i]);
return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}

bool isP(string s){
    for(int i = 0 ; i < sz(s) / 2; ++i){
        if(s[i] != s[sz(s) - 1 - i]){
            return false;
        }
    }
    return true;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int  a , b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = a; i <= b; ++i){
        stringstream s;
        s << i;
        string str = s.str();
        if(isP(str)) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {
  
  int N;
  cin >> N;
  vector<ll> count(26, 0);

  rep(i,N) {
    string S;
    cin >> S;
    count[S[0] - 'A']++;
  }

  string march = "MARCH";
  ll ans = 0;
  for (int i = 0; i < 5; i++) for (int j = i + 1; j < 5; j++) for (int k = j + 1; k < 5; k++) {
    ans += count[march[i] - 'A'] * count[march[j] - 'A'] * count[march[k] - 'A'];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int N, K, c[200009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		a--;
		c[a]++;
	}
	sort(c, c + N, greater<int>());
	int s = N;
	for (int i = 0; i < K; i++) s -= c[i];
	cout << s << "\n";
	return 0;
}

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

int my_strlen(char *str){
  int len = 0;
  while(str[len]){
    len++;
  }
  return len;
}

int main(){
  char A[101];
  char B[101];

  scanf("%s", A);
  scanf("%s", B);

  int a = my_strlen(A);
  int b = my_strlen(B);

  if(a>b){
    printf("GREATER\n");
  }else if(b>a){
    printf("LESS\n");
  }else{
    int i = 0;
    while(i < a){
      if(A[i]>B[i]){
        printf("GREATER\n");
        return 0;
      }else if(B[i]>A[i]){
        printf("LESS\n");
        return 0;
      }
      i++;
    }
    printf("EQUAL\n");
  }
}


Measured memory_bytes: 128
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string strA,strB;
	cin >> strA >> strB;
	int sizeA,sizeB;
	sizeA = strA.size();
	sizeB = strB.size();
	if( sizeA != sizeB ){
		if( sizeA > sizeB ){
			cout << "GREATER" << endl;
		}else{
			cout << "LESS" << endl;
		}
		return;
	}
	for(int i=0;i<sizeA;++i){//sizeA==sizeB
		if( strA[i] == strB[i] ) continue;
		if( strA[i] > strB[i] ){
			cout << "GREATER" << endl;
		}else{
			cout << "LESS" << endl;
		}
		return;
	}
	cout << "EQUAL" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
long long asc(const void *a,const void *b){
    return *(long long*)a - *(long long*)b;
}
int main(void){
    long long n,m,i,j,ans=0;
    scanf("%lld%lld",&n,&m);
    long long a[n][2];
    for(i=0;i<n;i++) scanf("%lld %lld",&a[i][0],&a[i][1]);
    qsort(a,n,sizeof(a[0]),asc);
    i = 0;
    while(1){
        if(m>a[i][1]){
            m-=a[i][1];
            ans += a[i][0]*a[i][1];
        }
        else{
            ans+=m*a[i][0];
            break;
        }
        i++;
    }
    printf("%lld",ans);
}

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

A=[[] for _ in range(N-1)]
B=[0]*N
C=[0]*N
D=[0]*N

for i in range(N-1):
    a,b=map(int,input().split())
    A[a-1].append(b)
    C[b-1]=i+1

for i in range(N-1): 
    c=0
    for j in A[i]:
        while True:
            c+=1
            if c!=B[i]:
                B[j-1]=c
                break

print(max(B))            

for i in range(1,N):
    D[C[i]]=B[i]

for i in range(1,N):
    print(D[i])




Measured memory_bytes: 22144
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B;
	
	cin>>A>>B;
	
	cout<<max(max(A+A-1,B+B-1),A+B)<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
vector<int> G[100050];
int h[100050];
signed main(void)
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		read(h[i]);
	reg int u,v;
	for(int i=1;i<=m;++i)
	{
		read(u);read(v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	reg int ans=0;
	for(int i=1;i<=n;++i)
	{
		reg bool flg=true;
		for(int j=0;j<(int)G[i].size();++j)
		{
			if(h[i]<=h[G[i][j]])
			{
				flg=false;
				break;
			}
		}
		if(flg)
			++ans;
	}
	cout<<ans<<endl;
	return 0;
}




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

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

	int C = A + B;
	bool flag = false;
	if (A % 3 == 0 || B % 3 == 0 || C % 3 == 0)
		flag = true;

	if (flag)
		cout << "Possible\n";
	else
		cout << "Impossible\n";
	return 0;
}


Measured memory_bytes: 256
N = int(input())
dictres = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(N):
  res = input()
  if res == 'AC':
    dictres['AC'] += 1
  elif res == 'WA':
    dictres['WA'] += 1
  elif res == 'TLE':
    dictres['TLE'] += 1
  elif res == 'RE':
    dictres['RE'] += 1
for i, j in dictres.items():
  print("{} x {}".format(i, j))

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

using namespace std;

using ll = long long;

template<int MOD>
struct ModInt {
   using Mint = ModInt;
   int val;
   ModInt(ll __val = 0) { fix(__val % MOD + MOD); }
   Mint& fix(int __val) { val = __val; if (val >= MOD) val -= MOD; return *this; }
   explicit operator int() { return val; }
   Mint operator + (const Mint &mt) const { return Mint().fix(val + mt.val); }
   Mint operator - (const Mint &mt) const { return Mint().fix(val - mt.val + MOD); }
   Mint operator * (const Mint &mt) const { return Mint().fix(ll(val) * mt.val % MOD + MOD); }
   Mint& operator += (const Mint &mt) { return *this = *this + mt; }
   Mint& operator -= (const Mint &mt) { return *this = *this - mt; }
   Mint& operator *= (const Mint &mt) { return *this = *this * mt; }
   Mint pow(int y) const {
      Mint x = *this;
      Mint ans(1);
      for (; y > 0; y >>= 1, x *= x) {
         if (y & 1) ans *= x;
      }
      return ans;
   }
   Mint operator -() const { return Mint().fix(MOD - val); }
   Mint inv() const { return pow(MOD - 2); }
   Mint operator / (const Mint &mt) const { return *this * mt.inv(); }
   Mint& operator /= (const Mint &mt) const { return *this / mt; }
   friend ostream& operator<<(ostream& os, const Mint& mt) { return os << mt.val; }
};

using Mint = ModInt<1000000007>;

const int MAXN = 1000100;

Mint fact[MAXN];
Mint ifact[MAXN];
Mint pow2[MAXN];
Mint pow3[MAXN];

void precalc() {
   fact[0] = 1;
   for (int i = 1; i < MAXN; ++i) fact[i] = fact[i - 1] * i;
   ifact[MAXN - 1] = fact[MAXN - 1].inv();
   for (int i = MAXN - 1; i > 0; --i) ifact[i - 1] = ifact[i] * i;
   pow2[0] = pow3[0] = 1;
   for (int i = 1; i < MAXN; ++i) {
      pow2[i] = pow2[i - 1] * 2;
      pow3[i] = pow3[i - 1] * 3;
   }
}

Mint C(int N, int K) {
   if (N < K || K < 0) return Mint(0);
   return fact[N] * ifact[K] * ifact[N - K];
}

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   precalc();
   int N, M, K;
   cin >> N >> M >> K;
   vector<Mint> dpM(M + K + 1);
   vector<Mint> dpK(M + K + 1);
   dpM[0] = dpK[0] = 1;
   for (int i = 1; i <= M + K; ++i) {
      dpM[i] = dpM[i - 1] * 2;
      if (i > M) dpM[i] -= C(i - 1, M);
      dpK[i] = dpK[i - 1] * 2;
      if (i > K) dpK[i] -= C(i - 1, K);
   }
   Mint ans = 0;
   for (int i = 0; i <= M + K; ++i) {
      ans += C(N - 1 + i, i) * (dpM[i] + dpK[i] - pow2[i]) * pow3[M + K - i];
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 20608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define maxn 100010
#define inf 1000000007
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int head[maxn],nxt[maxn*2],to[maxn*2],c[maxn*2],tot;
void add(int u,int v,int x)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
    c[tot]=x;
}
int rt;
int f[maxn],size[maxn];
void get_rt(int x,int las)
{
    size[x]=1;
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        get_rt(to[i],x);
        size[x]+=size[to[i]];
        f[x]=max(f[x],size[to[i]]);
    }
    f[x]=max(f[x],n-size[x]);
    if(f[x]<f[rt])  rt=x;
}
ll ans;
void dfs(int x,int las,ll d)
{
    size[x]=1;
    ans+=d;
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        dfs(to[i],x,d+c[i]);
        size[x]+=size[to[i]];
    }
}
int main()
{
    n=read();
    for(int i=1;i<n;i++)
    {
        int q=read(),w=read(),e=read();
        add(q,w,e);
        add(w,q,e);
    }
    f[0]=inf;
    get_rt(1,0);
    dfs(rt,0,0);
    int mn=inf,flag=0;
    if(f[rt]==n/2&&(n+1)&1)  flag=1;
    for(int i=head[rt];i;i=nxt[i])
    {
        mn=min(mn,c[i]);
        if(flag&&size[to[i]]==n/2)
        {
            mn=c[i];
            break;
        }
    }
    cout<<2*ans-mn<<endl;
    return 0;
}

Measured memory_bytes: 7808
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;

    int[] r;
    int n;
    foreach (int i; 1..5000) {
        n += i;
        r ~= i;
        if (n >= N) break;
    }
    if (n > N) {
        r[n-N-1] = 0;
    }
    foreach (x; r) if (x) {
        writeln(x);
    }
}

Measured memory_bytes: 380
#include<stdio.h>


int main(){
     
    int H;
    int A;
    
    
    
    scanf("%d %d", &H, &A);
    int Damage = H%A;
    Damage == 0 ? printf("%d", H/A ):printf("%d", H/A+1);
    
    
    
    
     
     
     
     
    
    return 0;
}

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

A, B = map(int, input().split())
AB = A * B

exists = False
# 1から３までループ
for C in range(1, 4):
    if (AB * C % 2 == 1):
        exists = True
        break

if (exists):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
n,k=map(int,input().split())
c=[[0]*(n+1) for _ in range(n+1)]
for i in range(n+1):
  c[i][0]=1
mod=10**9+7
for i in range(1,n+1):
  for j in range(1,i+1):
    c[i][j]=c[i-1][j]+c[i-1][j-1]
for i in range(1,k+1):
  print(c[n-k+1][i]*c[k-1][i-1]%mod)

Measured memory_bytes: 356536
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a, b;
string s;

signed main() {
	cin >> s;
	n = s.size();
	each(i,s) (i=='0' ? a : b)++;
	cout << min(a,b) * 2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    string str;
    cin >> str;
    string ans;
    if(str == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const ll INF = 1LL << 60;

int main(){

    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> vec(n);
    for(int i = 0;i < n;i++){
        cin >> vec[i];
    }
    ll ans = 0;
    for(int i = 0;i < n-1;i++){
        ans += min((vec[i+1]-vec[i])*a,b);
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
	int s;
	cin >> s;
	int h = s / 3600;
	//int m = s /60 - h*60;
	int m =s%3600/60;
	s=s%60;
	cout << h<<":"<<m<<":" <<s << endl;
	return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 (b<a) { a=b; return 1; } return 0; }



int n, a[101010];
pair<int,int> cnt[101010], cnt2[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < 101010; i++){
		cnt[i] = make_pair(0,i);
		cnt2[i] = make_pair(0,i);
	}
	for(int i = 0; i < n; i+=2){
		cnt[a[i]].first++;
		cnt2[a[i+1]].first++;
	}
	sort(cnt+1,cnt+101010, greater<pair<int,int>>());
	sort(cnt2+1,cnt2+101010, greater<pair<int,int>>());
	if(cnt[1].second == cnt2[1].second){
		if(cnt[1].first+cnt2[2].first > cnt[2].first+cnt2[1].first){
			cnt2[1] = cnt2[2];
		}
		else{
			cnt[1] = cnt[2];
		}
	}
	cout << n-cnt[1].first-cnt2[1].first << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256