akhauriyash/Code-Regression huggingface dataset:
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.regex, std.conv, std.stdio, std.typecons;

void main()
{
  auto rd = readln.split.map!(to!size_t);
  auto r = rd[0], c = rd[1];
  auto tij = iota(r).map!(_ => readln.split.map!(to!int).array).array;

  auto sij = new int[][](r + 1, c + 1);
  foreach (i; 0..r) sij[i][0..c][] = tij[i][];

  foreach (i; 0..r) sij[i][$-1] = tij[i].sum;
  foreach (j; 0..c) sij[$-1][j] = tij.map!(a => a[j]).sum;
  sij[$-1][$-1] = sij[$-1][0..c].sum;

  sij.each!(si => si.map!(a => a.to!string).join(" ").writeln);
}

Measured memory_bytes: 3144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	int flag=0, i, j, H, W;
	char a[10][10];
	scanf("%d%d", &H, &W);
	for (i=0;i<H;i++) scanf("%s", &a[i]);

	for (i=0;i<H && !flag;i++) {
		for (j=0;j<W && !flag;j++) {
			if (i>0 && j>0 && j<W-1 && i<H-1 && (a[i-1][j] == '#' && a[i][j-1] == '#' && a[i][j+1] == '#' && a[i+1][j] == '#')) {
				flag = 1;
			} else if (i>0 && j>0 && j<W-1 && (a[i-1][j] == '#' && a[i][j-1] == '#' && a[i][j+1] == '#')) {
				flag = 1;
			} else if (i>0 && j>0 && i<H-1 && (a[i-1][j] == '#' && a[i][j-1] == '#' && a[i+1][j] == '#')) {
				flag = 1;
			} else if (i>0 && i<H-1 && j<W-1 && (a[i-1][j] == '#' && a[i][j+1] == '#' && a[i+1][j] == '#')) {
				flag = 1;
			} else if (j>0 && i<H-1 && j<W-1 && (a[i][j-1] == '#' && a[i][j+1] == '#' && a[i+1][j] == '#')) {
				flag = 1;
			} else if (i>0 && j>0 && (a[i-1][j] == '#' && a[i][j-1] == '#')) {
				flag = 1;
			}
		}
	}

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

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x,y;
	cin>>x>>y;
	ll ans=0;
	while(y>=x) {
		ans++;
		x*=2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
n, m = list(map(int, input().split()))
lr = [list(map(int, input().split())) for _ in range(0, m)]
sum = [0] * (n + 1)
for (l, r) in lr:
  sum[l - 1] += 1
  sum[r] -= 1

cur = 0
ans = 0
for i in range(0, n + 1):
  cur += sum[i]
  if cur == m:
    ans += 1

print(ans)


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

using namespace std;

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

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

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

pll A[105];
ll dp[105][10005];

int main() {
    ll N, W;
    cin >> N >> W;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    memset(dp, 0, sizeof(dp));
    REP(i, N) {
        REP(j, W + 1) {
            dp[i + 1][j] = std::max(dp[i][j], dp[i + 1][j]);
            if (j - A[i].second >= 0)
                dp[i + 1][j] = std::max(dp[i][j - A[i].second] + A[i].first, dp[i + 1][j]);
        }
    }

    ll max = 0;
    REP(i, W + 1) {
        max = std::max(max, dp[N][i]);
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 11316
module Mod = struct
  module type S = sig val modulo : int end
  module Make (S : S) = struct
    open S
    let modulo = modulo
    let (+) a b = (a + b) mod modulo
    let ( * ) a b = (a * b) mod modulo
    let rec ( ** ) a n =
      if n = 0 then 1
      else if n mod 2 = 1 then a * a**(n-1)
      else let t = a ** (n/2) in t * t
    let inv a = a ** (modulo-2)
  end
end
module M = Mod.Make(struct let modulo = 1000000007 end)

let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let s = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let t = Array.init m (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let dp = Array.init (n+1) (fun _ -> Array.make (m+1) 0) in
  for i = 0 to n do
    for j = 0 to m do
      let open M in
      if i = 0 || j = 0 then dp.(i).(j) <- 1 else
      dp.(i).(j) <-
        if s.(i-1) = t.(j-1) then
          dp.(i).(j-1) + dp.(i-1).(j)
        else
          dp.(i).(j-1) + dp.(i-1).(j) + (modulo - dp.(i-1).(j-1));
    done;
  done;
  Printf.printf "%d\n" dp.(n).(m)


Measured memory_bytes: 33532
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long n,w;
    long ans=0;
    cin>>n>>w;
    vector<vector<long>> nums(n,vector<long>(2));
    long sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<2;j++)
        {
            cin>>nums[i][j];
            if(j==1)
                sum+=nums[i][j];
        }
    }
    
    vector<long> dp(100001,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=sum-nums[i][1];j>=0;j--)
        {
            dp[j+nums[i][1]]=min(dp[j+nums[i][1]],dp[j]+nums[i][0]);
        }
    }
    // int ans=0;
    for(long i=0;i<=sum;i++)
    {
        if(dp[i]<=w)
            ans=max(i,ans);
    }
    cout<<ans<<endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/15  Problem: diverta2019-2 B / Link: https://atcoder.jp/contests/diverta2019-2  ----- */

struct UnionFind {
	vector<int> data;
	int allsize;
	UnionFind(int n) :allsize(n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			allsize--;
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
	int allgroup() { return allsize; }
};



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

	LL N; cin >> N;
	vector<int> x(N), y(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}
	vector<PII>a;
	FOR(i, 0, N) {
		FOR(j, 0, N) {
			if (i == j)continue;
			if (x[i] - x[j] || y[i] - y[j]) {
				a.push_back(PII(x[i] - x[j], y[i] - y[j]));
			}
		}
	}
	int ans = N;
	for (auto it : a) {
		UnionFind uf(N);
		FOR(i, 0, N) {
			FOR(j, 0, N) {
				if (i == j)continue;
				if (x[i] - it.first == x[j] &&
					y[i] - it.second == y[j]) {
					uf.unionSet(i, j);
				}
			}
		}
		ans = min(ans, uf.allgroup());
	}
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	int n;
	cin >> n;
	int x = 1;
	int t = 0;
	while (n) {
		
		if (n % 10 == 1)
			t += 9*x;
		else t += x*1;
		x *= 10;
		n /= 10;
	}
	cout << t << endl;;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[9] = {0, 1, 1, 0, -1,-1,-1, 0, 1};
int dy[9] = {0, 0, 1, 1, 1 ,0 ,-1,-1,-1};

using namespace std;

map<pair<int,int>,long long> mp;
long long h,w,n;

void inmap(int a,int b){
	if(a>1 && b>1 && a < h && b < w){
		mp[make_pair(a,b)]++;
	}
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	cin >> h >> w >> n;
	//	vector<int> a(n),b(n);
	int a,b;
	for(int i = 0;i<n;i++){
		cin >> a >> b;
		REP(di,9)inmap(a + dy[di], b + dx[di]);
	}
	vector<long long> ct(10,0);
	for(auto itr = mp.begin(); itr != mp.end(); ++itr){
		if(itr->second<10)
			ct[itr->second]++;
	}
	ct[0] = (h-2)*(w-2)- accumulate(ct.begin(),ct.end(),0LL);
	REP(i,10){
		cout << ct[i] << endl;
	}
  return 0;
}


Measured memory_bytes: 56448
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	int N,A;
	cin >> N >> A;
	int X[N+1];
	FOR(i,0,N) cin >> X[i+1];

	long dp[N+1][N+1][2501];

	FOR(i,0,N+1){
		FOR(j,0,N+1){
			FOR(k,0,2501){
				if (i == 0 && j == 0 && k == 0){
					dp[i][j][k] = 1;
				}else if(i > 0){
					if (X[i] > k){
						dp[i][j][k] = dp[i-1][j][k];
					}
					else if(j >= 1 && k >= X[i]){
						dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i]];
					}
				}else{
					dp[i][j][k] = 0;
				}
			}
		}
	}

	long ans = 0;
	FOR(j,1,N+1){
		ans += dp[N][j][j*A];
	}

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

Measured memory_bytes: 50304
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>

using namespace std;

int sum_digit(int n){
  if( n == 0 ) return 0;
  else return n%10 + sum_digit(n/10);
}
int absolute(int a){
  if(a < 0) return -a;
  else return a;
}
int main()
{
  int i,sum = 0;
  vector<int> food(5);
  int localmax = 10;
  int number = 100;
  for( i = 0; i < 5; i++){
    cin >> food.at(i);
    if(food.at(i) % 10 > 0 && food.at(i) % 10 < localmax){
      localmax = food.at(i) % 10;
      number = i;
    }
  }
  
  for( i = 0; i < 5; i++){
    if(i == number) continue;
    if(food.at(i) % 10 == 0) sum += food.at(i);
  	else sum += food.at(i) + 10-(food.at(i) % 10);
  }
  if(number != 100) sum += food.at(number);
  cout << sum << endl;
}

Measured memory_bytes: 384
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <vector <ll>> matrix;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

const int mod = 1000000007;
template <typename T1, typename T2>
void modadd(T1 &a, const T2 &b) {
    a += b;
    
    if (a >= mod)
        a -= mod;
}

mt19937 rng(20010709);
const int INF = 1000000001;
const int N = 16;
const int M = 1 << N;

int n, a[N][N];
ll cost[M], dp[M];

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

	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	for (int mask = 0; mask < M; mask++) {
		for (int i = 0; i < n; i++) {
			if ((mask >> i) % 2 == 0) {
				int nextMask = mask ^ (1 << i);
				cost[nextMask] = cost[mask];

				for (int j = 0; j < n; j++) {
					if ((nextMask >> j) % 2)
						cost[nextMask] += a[i][j];
				}
			}
		}
	}

	fill(dp, dp + M, -1e18);
	dp[M - 1] = 0;

	for (int mask = M - 1; mask > -1; mask--) {
		for (int submask = mask; submask > 0; submask = (submask - 1) & mask)
			umax(dp[mask ^ submask], dp[mask] + cost[submask]);
	}

	cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int n, A[50];

int solve(int i, int m) {
    if(m==0) return 1;
    if(i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(void) {
    int q, M, i;

    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++) {
        scanf("%d", &M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


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

//tが入る場所が複数あるとき、一番後ろに入れば辞書順最小
int main(){
  string s, t; cin >> s >> t;
  for(int i=s.size()-t.size()+1; i>=0; i--) {
    string ss = s;
    Rep(j, i, i+t.size()) {
      if(ss[j] != t[j-i] && ss[j] != '?') break;
      else ss[j] = t[j-i];
      if(j == i+t.size()-1) {
        for(char c : ss) {
          if(c == '?') cout << 'a';
          else cout << c;
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))[::-1]
B = list(map(int, input().split()))[::-1]
ans = 0
for i in range(n):
    t = min(B[i], A[i])
    ans += t
    B[i] -= t
    A[i] -= t
    t = min(B[i], A[i + 1])
    ans += t
    B[i] -= t
    A[i + 1] -= t
print(ans)    

Measured memory_bytes: 18624
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c = na()
print('Yes' if a <= c <= b else 'No')


Measured memory_bytes: 3572
n, a, b, c = map(int, input().split())
ss = [None] * n
for i in range(n):
    ss[i] = input()

abc = {"A": a, "B": b, "C": c}
ans = [None] * n
# 3つある→ aをなくしにかかる
# 2つある→ bを1にしにかかる
# 0, 1, c→ c>=2のとき、
No = False
for i,s in enumerate(ss):
    zero = [i for i, item in abc.items() if item==0]
    one = [i for i, item in abc.items() if item==1]
    two = [i for i, item in abc.items() if item>=2]
#     print(s)
#     print(zero, one, two)
    if len(zero)==0:
        if s in ["AB", "AC"]:
            ans[i] = "A"
            abc["A"] += 1
            abc[s[1]] -= 1
        else:
            ans[i] = "C"
            abc["C"] += 1
            abc["B"] -= 1
    elif len(zero)==1 and len(two)>=1:
        z = zero[0]
        t = two[0]
        if z in s:
            # zに加える
            ans[i] = z
            abc[z] += 1
            abc[s.replace(z, "")] -= 1
        else:
            # twoから引く
            tmp = s.replace(t, "")
            ans[i] = tmp
            abc[tmp] += 1
            abc[t] -= 1
    elif len(zero)==1 and len(one)==2:
        z = zero[0]
        if s[0] in one and s[1] in one:
            # １手先を見て、
            ns = ss[i+1] if i+1<=n-1 else None
            if (ns is None) or (z not in ns):
                # 次も同じなのでどちらでもよい
                ans[i] = one[0]
                abc[one[0]] += 1
                abc[one[1]] -= 1
            else:
                # nsのzでないほうに加える
                tmp = ns.replace(z, "")
                ans[i] = tmp
                abc[tmp] += 1
                abc[s.replace(tmp, "")] -= 1
        else:
            # 0に加える
            z = zero[0]
            ans[i] = z
            abc[z] += 1
            abc[s.replace(z, "")] -= 1
    else:
        # 0が２つ以上
        assert len(zero) >= 2
        if len(zero)==3:
            No = True
            break
        elif s[0] in zero and s[1] in zero:
            No = True
            break
        else:
            # zに加える
            z = (set(s) & set(zero)).pop()
            ans[i] = z
            abc[z] += 1
            abc[s.replace(z, "")] -= 1
            
if No:
    print("No")
else:
    print("Yes")
    print("\n".join(ans))

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  
  int ha = 0;
  for(int i = 0; i < n - 1; i++){
    if(s.at(i) == s.at(i + 1)) ha++;
  }
  
  ha = min(2*k + ha, n - 1);
  cout << ha << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+n)

int main(void)
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a += b;
	c += d;

	if (a == c)
		cout << "Balanced" << endl;
	else if (a > c)
		cout << "Left" << endl;
	else
		cout << "Right" << endl;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  int h, w;
  cin >> h >> w;
  vector<string> S(h + 2);
  for (int i = 1; i <= h; i++) {
    string s;
    cin >> s;
    S[i] = '.' + s + '.';
  }
  string pd = "";
  for (int i = 0; i < w + 2; i++) pd += '.';
  S[0] = pd;
  S[h + 1] = pd;

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (S[i][j] == '#') {
        cout << '#';
      } else {
        int c = 0;
        for (int d = 0; d < 8; d++) {
          int ni = i + dy[d];
          int nj = j + dx[d];
          if (S[ni][nj] == '#') c++;
        }
        cout << c;
      }
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;

#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;

#define pb push_back

const int N = 250000;
int n, a, b, c, d;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    ll ans = 0, cnta = 0;

    for(int i = 0; i + 1 < s.length(); ++i) {
        if(s[i] == 'A') cnta++;
        else if(s[i] == 'B' && s[i+1] == 'C') {
            ans += cnta;
            i++;
        } else cnta = 0;
    }
    cout << ans;
    return 0;
}

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

using namespace std;
int main(int argc, char const *argv[]) {
  int N;
  long long H;
  cin >> N >> H;

  vector<long long> a(N);
  vector<long long> b(N);

  long long a_max = 0;
  long long b_sum = 0;

  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    if (a_max < a[i]) {
      a_max = a[i];
    }
    b_sum += b[i];
  }

  long long ans = 0;
  long long sum = 0;
  sort(b.begin(), b.end(), greater<long long>());
  for (int i = 0; i < N; i++) {
    if (b[i] < a_max || sum >= H) {
      break;
    }
    sum += b[i];
    ans++;
  }
  if (sum < H) {
    ans += ((H - sum) % a_max == 0 ? (H - sum) / a_max : (H - sum) / a_max + 1);
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
using namespace std;

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    if(a == 1){
        cout << "Hello World" << endl;
    }else{
        cout << b + c << endl;
    }

}


Measured memory_bytes: 256
q,h,s,d = map(int,input().split())
n = int(input())
a = [q*8,h*4,s*2,d]
min_s = min(a[:3]) // 2
min_d = min(a)
b,c = divmod(n,2)
print(b*min_d + c * min_s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    double A,B,H,M;
    cin>>A>>B>>H>>M;

    double sa=30*H+0.5*M;
    double sb=6*M;
    double sx=abs(sa-sb);
    sx=min(sx,360-sx);
    double ans=A*A+B*B-2*A*B*cos(sx/180.0*PI);
    ans=sqrt(ans);
    cout << fixed << setprecision(18);
    cout << ans << endl;







}


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

const int MAXN = 60;
typedef long long LL;
int head[MAXN], nxt[MAXN];
int n, X, D, sz[MAXN], rk[MAXN];
LL hav[MAXN];
LL ms[MAXN];
void dfs(int u) {
	sz[u] = 1;
	for (int i = head[u]; i; i = nxt[i]) {
		dfs(i);
		sz[u] += sz[i];
		ms[u] += ms[i];
	}
}
const int MAXR = 50 * 50 * 50 + 10;
LL pre[MAXN][MAXR];
void getmin(LL & x, LL y) { x > y ? x = y : 0; }
void getmax(LL & x, LL y) { x < y ? x = y : 0; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> X >> D;
	for (int i = 1; i <= n; ++i) {
		std::cin >> ms[i];
		if (i > 1) {
			int t; std::cin >> t;
			nxt[i] = head[t]; head[t] = i;
		}
		rk[i] = i;
	}
	dfs(1);
	std::sort(rk + 1, rk + 1 + n, [] (int a, int b) {
		return sz[a] * ms[b] > sz[b] * ms[a];
	});
	hav[1] = 0x3f3f3f3f3f3f3f3fLL;
	for (int i = 2; i <= n; ++i) hav[i] = D;
	for (int i = 1; i <= n; ++i)
		hav[i] = std::min(hav[i], X / ms[i]);
	memset(pre, 0x3f, sizeof pre);
	pre[0][0] = 0;
	const int R = n * n * n;
	for (int i = 1; i <= n; ++i) {
		const int u = rk[i];
		const int up = std::min((LL) n, hav[u]);
		hav[u] -= up;
		for (int j = 0; j <= R; ++j) if (pre[i - 1][j] <= X)
			for (int k = 0; k <= up; ++k)
				getmin(pre[i][j + k * sz[u]], pre[i - 1][j] + k * ms[u]);
	}
	LL ans = 0, * f = pre[n];
	for (int j = 0; j <= R; ++j) if (f[j] <= X) {
		LL now = j, rest = X - f[j];
		for (int i = 1; i <= n; ++i) {
			if (rest < 0) break;
			const int u = rk[i];
			getmax(ans, now + std::min(hav[u], rest / ms[u]) * sz[u]);
			now += hav[u] * sz[u], rest -= hav[u] * ms[u];
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 58880
#include <iostream>
#include <cstring>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(typeof(a) i=a;i!=(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
#define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0]))
using namespace std;

int main(){
    string S;
    int K;
    cin >> S >> K;
    int len = S.size();
    REP(i,len-1){
        int t = ('z' - S[i] + 1) % 26;
        if(t <= K){
            K -= t;
            S[i] = 'a';
        }
    }
    S[len-1] = 'a' + ((S[len-1] - 'a' + K) % 26);
    cout << S << endl;
}

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

using namespace std;


int main() {
  #ifdef LOCAL
  freopen("sol.in", "r", stdin);
  freopen("sol.out", "w+", stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, c;
  cin >> n >> c;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(c + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= c; j++) {
      if (w[i - 1] <= j) {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);   
      } else {
        dp[i][j] = dp[i - 1][j];
      }
      if (j > 0) {
        dp[i][j] = max(dp[i][j], dp[i][j - 1]);
      }
    }
  }
  cout << dp[n][c] << '\n';
  return 0;
}

Measured memory_bytes: 80256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
ll a[100000];
ll b[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n ;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        if((a[n-1-i]+ans)%b[n-1-i]!=0)
        ans+=b[n-1-i]-((a[n-1-i]+ans)%b[n-1-i]);
        }
    cout << ans << "\n";
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;
/*
class SegmentTree{
	vector<llong> tree;
	size_t n;

	public:
	SegmentTree(size_t n_){
		if(n_ == 0)throw std::invalid_argument();
		n = 1 << (32 - __builtin_clz(n_));
		size_t treesize = 2*n;
		tree = vector<llong>(treesize,LLONG_MIN);
	}
	~SegmentTree(){}

	void update(size_t idx, llong x){
		idx += n;
		tree[idx] = x;
		while(idx >>= 1){
			tree[idx] = max(tree[idx<<1 +0] + tree[idx<<1 +1]);
		}
	}

	llong query(llong a, llong b){
		llong ret = LLONG_MIN;
		a += n; b += n;
		for(; a < b; a >>= 1, b >>= 1){
			if(a&1)ret = max(ret, tree[a++]);
			if(b&1)ret = max(ret, tree[--b]);
		}
		return ret;
	}
};
*/

signed main(){
	while(true){
		int n,m; cin >> n >> m;
		if(n == 0)break;
		vector<llong> s(m),k(m);
		vector<vector<llong> > c(m, vector<llong>());
		for(int i = 0; i < m; i++){
			cin >> s[i] >> k[i];
			c[i].resize(k[i]);
			for(int j = 0; j < k[i]; j++){
				cin >> c[i][j];
				c[i][j]--;
			}
		}
		vector<llong> l(n,0),u(n,0);
		for(int i = 0; i < m; i++){
			if(k[i] == 1)l[c[i][0]]+=s[i];
			for(int j = 0; j < k[i]; j++){
				u[c[i][j]] += s[i];
			}
		}
		map<llong, int> ll;
		for(auto e : l){
			if(ll.find(e) == ll.end())ll[e] = 0;
			ll[e] += 1;
		}
		auto mm = ll.lower_bound(0);
		for(auto &e : l){
			if(mm->second == 1 && mm->first == e){
				e = next(mm)->first;
			}
			else{
				e = mm->first;
			}
		}
		llong ans = 0;
		for(int i = 0; i < n; i++){
			ans = max(ans, u[i]-l[i]);
		}
		cout << (ans+1) << endl;
	}



	return 0;
}




Measured memory_bytes: 3812
import Data.List

main = getContents >>= putStr.formatOut.calc.formatIn

formatIn :: String -> [[String]]
formatIn = map words.tail.lines

formatOut :: [[String]] -> String
formatOut = f.map unlines 
  where f [[],[],[],[]] = ""
        f s  = unlines $map init s
calc :: [[String]] -> [[String]]
calc n = [f "S", f "H", f "C", f "D"]
  where f c = map unwords $(g c)  \\ (filter (\s -> (head s) == c) n)
        g c =  map (\x -> [c,show x]) [1..13]

Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int a, b, x; cin >> a >> b >> x;    
    cout << (x + ((max(0LL, (x - b)) / (a - b)) % MOD) * (b % MOD) ) % MOD << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	int max_value = 0;
	int sum_value = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		sum_value += tmp;
		max_value = max(max_value, tmp);
	}

	cout << sum_value - max_value / 2 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	rep(i,H) cin >> a[i];
	vector<bool> ver(W), hor(H);
	rep(j,W){
		int num=0;
		rep(i,H) if(a[i][j]=='.') num++;
		if(num==H) ver[j]=true;
	}
	rep(i,H){
		int num=0;
		rep(j,W) if(a[i][j]=='.') num++;
		if(num==W) hor[i]=true;
	}
	vector<string> ans(H);
	rep(i,H){
		if(hor[i]) continue;
		rep(j,W){
			if(ver[j]) continue;
			ans[i].push_back(a[i][j]);
		}
	}
	rep(i,H){
		if(ans[i].size()==0) continue;
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,m,a[maxn];
int main(){
	n=read(),m=read();
	int a=n+m,b=n-m,c=n*m;
	printf("%d\n",max(a,max(b,c)));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<2;i++){
    if(n>10){
      n%=10;
    }
    if(n<=10){
      break;
    }
  }
  if(n==2||n==4||n==5||n==7||n==9){
    cout<<"hon"<<endl;
  }
  if(n==0||n==1||n==6||n==8){
    cout<<"pon"<<endl;
  }
  if(n==3){
    cout<<"bon"<<endl;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <queue>
#include <unordered_map>
#define ll long long
#define pii pair <int, int>
#define pll pair <long long, long long>
#define plxy pair <long long, pll>
#define INT_MAX 1e18
#define Keep_calm_You_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
ll ans[N][3];
int main()
{
     ll n,a[N],b[N],c[N];
     cin>>n;
     for(ll i=0;i<n;i++)
     {
         cin>>a[i]>>b[i]>>c[i];
     }
     ans[0][0]=a[0];
     ans[0][1]=b[0];
     ans[0][2]=c[0];
     for(ll i=1;i<n;i++)
     {
         ans[i][0]=a[i]+max(ans[i-1][1],ans[i-1][2]);
         ans[i][1]=b[i]+max(ans[i-1][0],ans[i-1][2]);
         ans[i][2]=c[i]+max(ans[i-1][0],ans[i-1][1]);
     }
     cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
int main(void)
{
	float n,s;
	double max;
	double min;

	max=-1;
	min=100000;

	while(scanf("%f",&n)!=EOF){
		if(n>max){
			max=n;
		}
		if(n<min){
			min=n;
		}
	}
	s=max-min;
	printf("%.1f\n",s);
	return 0;
}

Measured memory_bytes: 1076
N, X = map(int, input().split())
L = list(map(int, input().split()))
l = [0]
if L[0] <= X:
  l.append(L[0])
  for x in range(N - 1):
    a = l[-1] + L[x + 1]
    if a <= X:
      l.append(a)
    elif a > X:
      break

print(len(l))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 2005
using namespace std;
int ans=2e9,tot,n,d[N],m,dep[N];
struct papa {
	int to,next;
} e[N<<1];
inline void addedge(int x,int y) {
	e[++tot].to=y;
	e[tot].next=d[x];
	d[x]=tot;
}
inline int read() {
	int X=0,w=0;
	char ch=0;
	while(!isdigit(ch)) {
		w|=ch=='-';
		ch=getchar();
	}
	while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w?-X:X;
}
inline void dfs(int now,int fa) {
	if(dep[now]>(m>>1)) tot++;
	for(int i=d[now]; i; i=e[i].next) {
		int x=e[i].to;
		if(x==fa) continue;
		dep[x]=dep[now]+1;
		dfs(x,now);
	}
}
int main() {
	n=read(),m=read();
	for(int i=1; i<n; i++) {
		int x=read(),y=read();
		addedge(x,y),addedge(y,x);
	}
	if(m&1) {
		for(int i=1; i<=n; i++)
			for(int j=d[i]; j; j=e[j].next) {
				int x=e[j].to;
				tot=0,dep[x]=0;
				dfs(x,i);
				dep[i]=0;
				dfs(i,x);
				ans=min(ans,tot);
			}
		printf("%d\n",ans);
		return 0;
	}
	for(int i=1; i<=n; i++)
		tot=0,dep[i]=0,dfs(i,-1),ans=min(ans,tot);
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

template<typename T> struct SegTree_dual{
    using F=function<T(T, T)>;
    int sz=1;
    T et;
    F f, g;
    vector<T> node;

    SegTree_dual(int sz_, T et_, F f_, F g_): et(et_), f(f_), g(g_){
        while(sz<sz_) sz<<=1;
        node.resize(sz<<1, et);
    }

    void update(int l, int r, T x){
        for(l+=sz, r+=sz; l<r; l>>=1, r>>=1){
            if(l&1){
                node[l]=g(node[l], x);
                l++;
            }
            if(r&1){
                --r;
                node[r]=g(node[r], x);
            }
        }
    }

    T query(int i){
        i+=sz;
        T val=node[i];
        i>>=1;
        while(i){
            val=f(val, node[i]);
            i>>=1;
        }
        return val;
    }
};

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    SegTree_dual<int> st(n, 0, plus<>(), plus<>());

    while(q--){
        int c;
        scanf("%d", &c);
        if(c==0){
            int s, t, x;
            scanf("%d%d%d", &s, &t, &x);
            st.update(s-1, t, x);
        }
        else{
            int i;
            scanf("%d", &i);
            printf("%d\n", st.query(i-1));
        }
    }
}


Measured memory_bytes: 3904
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    vl cs(26, LINF);
    rep(i, n) {
        string s; cin>>s;
        ll m = sz(s);
        vl temp(26);
        rep(j, m) temp[s[j] - 'a']++;
        rep(j, 26) chmin(cs[j], temp[j]);
    }
    rep(i, 26) {
        if (cs[i] == LINF) continue;
        char c = i + 'a';
        rep(j, cs[i]) {
            cout<<c;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////


i64 gcd(i64 l, i64 r){
  while(r){
    l = l % r;
    swap(l, r);
  }
  return l;
}

i64 lcm(i64 l, i64 r){
  return l / gcd(l, r) * r;
}


int main(){
    i64 A, B, C, D;
    cin >> A >> B >> C >> D;
    A--;
    i64 a = A - A / D - A / C + A / lcm(C, D);
    i64 b = B - B / D - B / C + B / lcm(C, D);
    cerr << a << " " << b << endl;
    cout << b - a << endl;
    return 0;
}


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

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a.begin(), a.end());
	int q;
	scanf("%d", &q);
	vector<int> b(q);
	for(int i = 0; i < q; i++)
		scanf("%d", &b[i]);
	sort(b.begin(), b.end());
	printf("%d\n", includes(a.begin(), a.end(), b.begin(), b.end()));
}



Measured memory_bytes: 4408
const input = require("fs").readFileSync("/dev/stdin", "utf8")
let cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(i=>parseInt(i))

const [X, Y] = nexts(2)
t = (Y - 2 * X) / 2
c = X - t
if (t >= 0 && c >= 0 && t + c == X && 4*t + 2*c == Y && Number.isInteger(t) && Number.isInteger(c)) {
    console.log('Yes')
} else {
    console.log('No')
}
// if (turtle >= 1 && turtle )


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

#define min(a,b) (((a) > (b)) ? (b) : (a))
#define max(a,b) (((a) < (b)) ? (b) : (a))
int main(void) {
    int W,H,N;
    int *x,*y,*a;
    char buf[16];
    char *p;
    int minmax[4];
    int i;
    int area;

    p = fgets(buf, 16, stdin);
    (void)sscanf(buf, "%d %d %d", &W, &H, &N);

    x = malloc(sizeof(int) * N * 3);
    y = x + N;
    a = y + N;

    for(i=0;i<N;i++) {
        p = fgets(buf, 16, stdin);
        (void)sscanf(buf, "%d %d %d", &x[i], &y[i], &a[i]);
    }

    minmax[0] = 0; // 0 - x
    minmax[1] = W; // w - W
    minmax[2] = 0; // 0 - y
    minmax[3] = H; // 0 - H
    
    for(i=0;i<N;i++) {
        switch (a[i]) {
            case 1:
                minmax[0] = max(x[i], minmax[0]);
                break;
            case 2:
                minmax[1] = min(x[i], minmax[1]);
                break;
            case 3:
                minmax[2] = max(y[i], minmax[2]); 
                break;
            case 4:
                minmax[3] = min(y[i], minmax[3]);
                break;
        }
    }

    if((minmax[0] >= minmax[1]) || (minmax[2] >= minmax[3])) {
        area = 0;
    } else {
        area = (minmax[1] - minmax[0]) * (minmax[3] - minmax[2]);
    }

    printf("%d\n", area);
    free(x);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[51],b[51];
	cin>>a>>b;
	int la,lb;
	la=strlen(a);
	lb=strlen(b);
	for(int i=0;i<=lb-1;i++)
	{
		cout<<a[i]<<b[i];
	}
	if(la>lb)
	{
		cout<<a[la-1];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'



int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif
 
    ll n;cin>>n;
    ll s=0;
    for(ll i=0;i<n;i++)
    {
        ll x;cin>>x;
        s^=x;
    }
    if(s) cout<<"No";
    else cout<<"Yes";

    #ifdef APNA_IO
        end_routine();
    #endif
}


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

int main() {
  int A;
  cin >> A;
  
  vector<int> nums(4);
  for(int i =0; i<4; i++){
    nums.at(3-i) = A%10;
    A /= 10;
  }
  
  int i = 0;
  for(; i<(1<<3); i++){
    int seven = nums[0];
    for(int j=0; j<3; j++){
      if(i & (1 << j)){
        seven += nums[j+1];
      }else{
        seven -= nums[j+1];
      }
    }
    if(seven == 7) break;
  }
  
  cout << nums[0];
  for(int j=0; j<3; j++){
    if(i & (1 << j)){
      cout << '+' << nums[j+1];
    }else{
      cout << '-' << nums[j+1];
    }
  }
  cout << "=7" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll fact[300000];
ll add(ll a,ll b){return (a+b+mod+mod)%mod;}
ll mul(ll a,ll b){return (a*b)%mod;}
ll mpow(ll a,ll b){
  if(b==0)return 1;
  ll res=mpow(mul(a,a),b/2);
  if(b&1)res=mul(res,a);
  return res;
}
ll divi(ll a,ll b){
  return mul(a,mpow(b,mod-2));
}
ll nCr(ll n,ll r){
  return divi(fact[n],mul(fact[r],fact[n-r]));
}
ll calc(ll n,ll x){
  if(x==0)return 1;
  return add( nCr(n+x,x) , -nCr(n+x,x-1) );
}
int main(){
  fact[0]=1;
  for(ll i=1;i<300000;i++)
    fact[i]=mul(fact[i-1],i);
  
  ll N,M,K,ans=0;
  cin>>N>>M>>K;
  for(ll i=0;i<=K;i++){
    ll tmp=mul( calc(N+i,i),calc(M+K-i,K-i) );
    ans=add(ans,mul(nCr(N+M+K+K,N+i+i),tmp));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5412
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int digitsum(int x) {
	int sum = 0;
	while (x) {
		sum += x % 10;
		x /= 10;
	}
	return sum;
}
int main()
{
	int N;
	cin >> N;
	if (N % digitsum(N) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll N;
  cin >> N;
  ll ans{};
  rep(i, 1, N+1){
    ans += i;
  }
  cout << ans << rt;
}

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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  vi a(7);
  rep(i, 7) cin >> a[i];

  int ans = a[0]/2*2 + a[1] + a[3]/2*2 + a[4]/2*2;
  if(a[0]%2 and a[3]%2 and a[4]%2) ans += 3;

  if(a[0] and a[3] and a[4]){
    int tmp = 3;
    tmp += (a[0]-1)/2*2 + a[1] + (a[3]-1)/2*2 + (a[4]-1)/2*2;
    ans = max(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var K = sc.nextInt();
        var V = sc.ArrayLong(N);
        var VR = new long[N];
        for (int i = 0; i < N; i++) {
            VR[i] = V[i];
        }
        Array.Reverse(VR);

        var lst = new List<List<long>>();
        var loop = Min(N, K);
        for (int i = 0; i <= loop; i++) {
            for (int l = 0; l <= i; l++) {
                for (int r = l; r <= i; r++) {
                    lst.Add(V.Take(l).Concat(VR.Take(i - r)).ToList());
                }
            }
        }

        var max = long.MinValue;

        for (int i = 0; i < lst.Count; i++) {
            var tmp = lst[i];
            var cnt = K - tmp.Count;
            tmp.Sort();
            for (int j = 0; j < cnt; j++) {
                if (j >= tmp.Count) break;
                if (tmp[j] < 0) {
                    tmp[j] = 0;
                    j--;
                }

            }
            max = Max(max, tmp.Sum());
        }
        WriteLine(max);
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 26444