akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    u32 N, K;
    cin >> N >> K;
    Vec<u32> S(N + 1, 0);
    for (int i = 0; i < K; i++) {
        u32 d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            u32 A;
            cin >> A;
            S[A]++;
        }
    }
    u32 sum = 0;
    for (int i = 1; i <= N; i++) {
        if (S[i] == 0) sum++;
    }
    cout << sum << endl;
}


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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

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

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


int main() {
  ll a,b ;
  cin >> a >> b;
  ll g = lcm(a,b);
  cout << g << endl;
  return 0;

}


Measured memory_bytes: 3572
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

q = ni()
lr = nan(q)

def ok(x):
    if x <= 1:
        return False
    i = 2
    flag1 = True
    while i * i <= x:
        if x % i == 0:
            flag1 = False
            break
        i += 1
    j = 2
    flag2 = True
    y = (x + 1) // 2
    while j * j <= y:
        if y % j == 0:
            flag2 = False
            break
        j += 1
    return flag1 and flag2

cu = [0] * (10 ** 5 + 7)
for i in range(1, 10 ** 5 + 7):
    cu[i] = cu[i - 1]
    if i % 2 != 0:
        cu[i] += ok(i)

for i in range(q):
    l, r = lr[i]
    print(cu[r] - cu[l - 1])

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

int main() {
	int n; cin >> n;
	vector<int> c(n), s(n), f(n);
	rep(i, 0, n - 1) cin >> c[i] >> s[i] >> f[i];
	c[n - 1] = 0; s[n - 1] = 0; f[n - 1] = 1;

	int i = 0;
	while (i < n) {
		ll ans = s[i];
		rep(j, i, n - 1) {
			ans += c[j];
			if (ans >= s[j + 1]) {
				if (ans % f[j + 1]) {
                  ans += (f[j + 1] - (ans % f[j + 1]));
                }
			}
			else ans = s[j + 1];
		}
		cout << ans << endl;
		i++;
	}

	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var alphabet = "abcdefghijklmnopqrstuvwxyz";
            var N = ReadLineLong();

            var num = 26;
            var Name = "";
            while (true)
            {
                N--;
                var m = (int)(N % num);
                N = N / num;
                Name = alphabet[m].ToString() + Name;
                if(N == 0) { break; }
            }

            Console.WriteLine(Name);
        }


        #region 使いまわし
        static string ReadLineStr() { return Console.ReadLine(); }
        static int ReadLineInt() { return Convert.ToInt32(Console.ReadLine()); }
        static (int, int) ReadLineInt2()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]));
        }
        static long ReadLineLong() { return Convert.ToInt64(Console.ReadLine()); }
        #endregion
    }
}


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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int64_t v[n];
	for(auto &i:v) cin >> i;
	int64_t dp[n + 1][n + 1]{}, dp2[n + 1][n + 1]{};
	for(int i = 0; i < n + 1; i++){
		dp2[i][0] = 1;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= i; j++){
			if(dp[i + 1][j] < dp[i][j]){
				dp[i + 1][j] = dp[i][j];
				dp2[i + 1][j] = dp2[i][j];
			}else if(dp[i][j] && dp[i + 1][j] == dp[i][j]){
				dp2[i + 1][j] += dp2[i][j];
			}
			if(dp[i + 1][j + 1] < dp[i][j] + v[i]){
				dp[i + 1][j + 1] = dp[i][j] + v[i];
				dp2[i + 1][j + 1] = dp2[i][j];
			}else if(dp[i + 1][j + 1] == dp[i][j] + v[i]){
				dp2[i + 1][j + 1] += dp2[i][j];
			}
		}
	}
	int ans = a;
	for(int i = a + 1; i <= b; i++){
		if(dp[n][ans] * i < dp[n][i] * ans){
			ans = i;
		}else if(dp[n][ans] * i == dp[n][i] * ans){
			dp2[n][ans] += dp2[n][i];
		}
	}
	cout << fixed << setprecision(10) << 1.0 * dp[n][ans] / ans << endl;
	cout << dp2[n][ans] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    for(int i=0;i<n;i++) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};
int main(){
  UnionFind tree(13);
  tree.unite(1,3);
  tree.unite(1,5);
  tree.unite(1,7);
  tree.unite(1,8);
  tree.unite(1,10);
  tree.unite(1,12);
  tree.unite(4,6);
  tree.unite(4,9);
  tree.unite(4,11);
  int n,m;cin>>n>>m;
  cout<<(tree.same(n,m)?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  int b=a/500;
  int c=a%500;
  int d=c/5;
  cout<<1000*b+5*d<<endl;
}


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

#define F0R(i, a) for (int i=0; i<(a); i++)

 
#define sz(x) (int)(x).size()

const char nl = '\n';

 
int main() {
   
	
    string S, T; cin >> S >> T;
    int ans = 0;
    F0R(i, sz(S)) if (S[i] != T[i]) ans++;
    cout << ans << nl;
	
	return 0;
}
 

Measured memory_bytes: 3832
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int k,x;
  cin>>k>>x;
  for(int i=1;i<k;i++){
    if(x-k+i>=-1000000) cout<<x-k+i<<" ";
  }
  cout<<x;
  for(int i=1;i<k;i++){
    if(x+i<=1000000) cout<<' '<<x+i;
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pi pair <int, int>
#define FAST_READ ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;





int main()
{
    FAST_READ;

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


    x -= a;
    int c = x / b;
    x -= (c*b);
    cout << x << "\n";
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	int ans(0);
	ll a;
	rep(i,n){
		cin >> a;
		while(a % 2 == 0){
			a = a>>1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

N = len(S)
end_index = int((N-1)/2)
temp = S[0:end_index]
#print(temp)
start = int((N+3)/2-1)
end = N+1
temp2 = S[start:end]
#print(temp2)

temp0 = S
if temp0 == temp0[::-1]:
    if temp == temp[::-1]:
        if temp2 == temp2[::-1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll res = a * c;
    res = max(a * d, res);
    res = max(b * c, res);
    res = max(b * d, res);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

void A() {
	for (int i = 0; i < 5; i++) {
		int x; cin >> x;
		if (x != i + 1) {
			cout << i + 1 << endl;
			return;
		}
	}
}

void B() {
	int X, Y; cin >> X >> Y;
	if (Y % 2 != 0) {
		pNo; return;
	}

	if (Y >= 2 * X && (Y - 2 * X) % 2 == 0) {
		pYes; return;
	}
	else {
		pNo; return;
	}
}

void C() {
	int X, N; cin >> X >> N;
	set<int> s;
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		s.insert(p);
	}

	int high = X + 1;
	int low = X - 1;

	while (true) {
		if (s.find(X) == s.end()) {
			cout << X << endl;
			return;
		}

		if (s.find(low) == s.end()) {
			cout << low << endl;
			return;
		}

		if (s.find(high) == s.end()) {
			cout << high << endl;
			return;
		}

		high++; low--;
	}
}
int main() {
	A();
}

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

int main() {
	int n;
	string s;

	cin >> n >> s;

	int m = n / 2;
	cout << (s.substr(0, m) == s.substr(m, m) && n % 2 == 0 ? "Yes" : "No" );
	
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm


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

int64_t N; cin >> N;
VI A(N); rep(i, 0, N) cin >> A[i];

VI L(N + 1, 0), R(N + 1, 0);
rep(i, 1, N+1){
    L[i] = boost::integer::gcd(L[i-1], A[i - 1]); 
    R[N - i] = boost::integer::gcd(R[N - i + 1], A[N - i]);
}

int64_t maxi = 0;
rep(i, 0, N)
    maxi = max(maxi, boost::integer::gcd(L[i], R[i+1]));

cout << maxi << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 2560
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

struct UnionFind {
  vector<int> d;
  UnionFind() { }
  UnionFind(int n) :d(n, -1) { }
  bool unite(int x, int y) {
    int a = root(x), b = root(y);
    if (a == b) return false;
    if (size(a) < size(b)) swap(a, b);
    d[a] += d[b];
    d[b] = a;
    return true;
  }
  int size(int v) { return -d[root(v)]; }
  int root(int v) { return d[v] < 0 ? v : d[v] = root(d[v]); }
  bool same(int x, int y) { return root(x) == root(y); }
};

void Calc() {
  int n = in;
  struct Data {
    int i, x, y;
    void In() {
      in, x, y;
    }
    bool operator<(const Data&d)const {
      return make_tuple(x, y) < make_tuple(d.x, d.y);
    }
  };

  vector<Data> d(n), dy(n);
  rep(i, n) {
    d[i].In();
    d[i].i = i;
    dy[i] = d[i];
    swap(dy[i].x, dy[i].y);
  }
  sort(all(d));
  sort(all(dy));

  vector<Data> x(n * 2 - 2);
  rep(i, n - 1) {
    x[i].x = d[i + 1].x - d[i].x;
    x[i].i = i;
    x[i].y = 0;
    x[i + n - 1].x = dy[i + 1].x - dy[i].x;
    x[i + n - 1].i = i;
    x[i + n - 1].y = 1;
    err(x[i + n - 1].x, dy[i + 1].x, dy[i].x);
  }
  sort(all(x));

  UnionFind uni(n);
  int cnt = 0;
  rep(i, 0, size(x)) {
    int a, b;
    if (x[i].y == 0) {
      a = d[x[i].i].i;
      b = d[x[i].i + 1].i;
    }
    else {
      a = dy[x[i].i].i;
      b = dy[x[i].i + 1].i;
    }
    if (uni.same(a, b)) continue;
    uni.unite(a, b);
    cnt += x[i].x;
    err(a, b, cnt, x[i].x, x[i].y);
  }
  cout << (cnt) << endl;

}


Measured memory_bytes: 5376
A, B, C = map(int, input().split(' '))

m = max(A, B, C)
div_a, mod_a = divmod((m - A), 2)
div_b, mod_b = divmod((m - B), 2)
div_c, mod_c = divmod((m - C), 2)

count = sum((div_a, div_b, div_c))
mod = sum((mod_a, mod_b, mod_c))

if mod == 1:
    count += 2
elif mod == 2:
    count += 1

print(count)


Measured memory_bytes: 3064
def f_d():
    n, k = map(int, input().split())
    *s, = map(int, list(input()))
    l, t, c = [], 1, 0
    for i in range(n):
        if s[i]==t:
            c += 1
        else:
            l.append(c)
            c, t = 1, t^1
    if c!=0:
        l.append(c)
    if len(l)%2==0:
        l.append(0)

    r, a = 2*k+1, 0
    li = ri = tmp = 0
    for i in range(0, len(l), 2):
        nli, nri = i, min(i+r, len(l))
        while li<nli:
            tmp -= l[li]
            li += 1
        while ri<nri:
            tmp += l[ri]
            ri += 1
        a = max(a, tmp)
    print(a)

if __name__ == "__main__":
    f_d()


Measured memory_bytes: 54776
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    double a, b, c, d, e, f;
    double x, y;

    while (cin >> a >> b >> c >> d >> e >> f)
    {
//        cout << "input numbers: " << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;

        y = (a*f - d*c) / (a*e - d*b);
        x = (c - b*y) / a;

//        cout << "before round: " << std::fixed << std::setprecision(4) << x << " " << y << endl;

        x = x * 1000.0;
        y = y * 1000.0;

        x = round(x);
        y = round(y);

        x = x / 1000.0;
        y = y / 1000.0;

//        cout << "after round: " << std::fixed << std::setprecision(4) << x << " " << y << endl;

        cout << std::fixed << std::setprecision(3) << x << " " << y << endl;
    }

    return 0;
}



Measured memory_bytes: 3336
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

#define mod 1000000007
#define MAX_N 100000

using namespace std;

int main()
{
    int X;

    scanf("%d", &X);
    printf((X >= 30) ? "Yes" : "No");

    return 0;
}


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

using namespace std;

#define mod 1000000007
#define int long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define all(x) x.begin(),x.end()

const int maxv=1e18;
int ar[100005];

int32_t main()
{
	int a;
	cin>>a;
	string s;
	cin>>s;
	int b=100*(s[0]-'0') + 10*(s[2]-'0') + s[3]-'0';
	a*=b;
	cout<<(a/100)<<endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

// a^b
long long PowerMod(long long a, long long b, int m)
{
    long long res = 1;

    for (int i = 0; b > 0; i++) {
        if (b & 1) {
            res = (res * a) % m;
        }
        a = (a * a) % m;
        b >>= 1;
    }

    return res;
}

// a!
long long FactorialMod(long long a, int m)
{
    long long res = 1;
    for (int i = a; i > 0; i--) {
        res = (res * i) % m;
    }
    return res;
}

// nCr
long long CombinationMod(long long n, long long r, int m)
{
    if (r > n / 2) {
        r = n - r;
    }

    long long res = 1;
    for (int i = 0; i < r; i++) {
        res = (res * (n - i)) % m;
    }
    res *= PowerMod(FactorialMod(r, m), m - 2, m);
    res %= m;

    return res;
}

void PrimeFactorization(int x, vector<pair<int, int> >& y)
{
    int xrest = x;

    for (int i = 2; i < x; i++) {
        if (i > xrest) {
            break;
        }
        if (xrest % i == 0) {
            y.push_back(make_pair(i, 1));
            xrest /= i;
            while (1) {
                if (xrest % i == 0) {
                    y.back().second++;
                    xrest /= i;
                } else {
                    break;
                }
            }
        }
    }

}

int main()
{
    const int MOD = 1e9 + 7;

    int N, M;
    cin >> N >> M;

    vector<pair<int, int> > v;
    PrimeFactorization(M, v);

    long long ans = 1;
    for (int i = 0; i < v.size(); i++) {
        ans *= CombinationMod(v[i].second + N - 1, v[i].second, MOD);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

typedef long long LL;
int Mod;
const int MN = 105, MK = 105;

int Binom[MN][MN], Pow[MK][MN];
int N, M, K;
int f[2][MN][MN];

int main() {
	scanf("%d%d%d%d", &N, &M, &K, &Mod);
	for (int i = 0; i <= std::max(N, M); ++i) {
		Binom[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			Binom[i][j] = (Binom[i - 1][j - 1] + Binom[i - 1][j]) % Mod;
	}
	for (int i = 0; i <= K; ++i) {
		Pow[i][0] = 1;
		for (int j = 1; j <= std::max(N, M); ++j)
			Pow[i][j] = (LL)Pow[i][j - 1] * i % Mod;
	}
	int o = 0;
	f[0][0][0] = 1;
#define Z0(x) for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) f[x][i][j] = 0;
	for (int t = 1; t <= K; ++t) {
		Z0(o ^ 1);
		for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) if (f[o][i][j]) {
			int x = f[o][i][j], y = (LL)Pow[K - t + 1][j] * Pow[t][M - j] % Mod;
			for (int a = 0; i + a <= N; ++a, x = (LL)x * y % Mod)
				f[o ^ 1][i + a][j] = (f[o ^ 1][i + a][j] + (LL)Binom[N - i][a] * x) % Mod;
		} o ^= 1;
		Z0(o ^ 1);
		for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) if (f[o][i][j]) {
			int x = f[o][i][j], y = (LL)Pow[K - t + 1][i] * Pow[t][N - i] % Mod;
			for (int b = 0; j + b <= M; ++b, x = (LL)x * y % Mod)
				f[o ^ 1][i][j + b] = (f[o ^ 1][i][j + b] + (LL)Binom[M - j][b] * x) % Mod;
		} o ^= 1;
		Z0(o ^ 1);
		for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) if (f[o][i][j]) {
			int x = f[o][i][j], y = (LL)(Mod - Pow[K - t][j]) * Pow[t][M - j] % Mod;
			for (int c = 0; i + c <= N; ++c, x = (LL)x * y % Mod)
				f[o ^ 1][i + c][j] = (f[o ^ 1][i + c][j] + (LL)Binom[N - i][c] * x) % Mod;
		} o ^= 1;
		Z0(o ^ 1);
		for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) if (f[o][i][j]) {
			int x = f[o][i][j], y = (LL)(Mod - Pow[K - t][i]) * Pow[t][N - i] % Mod;
			for (int d = 0; j + d <= M; ++d, x = (LL)x * y % Mod)
				f[o ^ 1][i][j + d] = (f[o ^ 1][i][j + d] + (LL)Binom[M - j][d] * x) % Mod;
		} o ^= 1;
	}
	printf("%d\n", f[o][N][M]);
	return 0;
}

Measured memory_bytes: 512
{-# OPTIONS_GHC -O3 -fexpose-all-unfoldings -fdicts-cheap -fdicts-cheap #-}

import Data.Array (array,(!))

main = do
  s <- readLn
  if s == 0
     then return ()
     else do
      print $ primeArr ! s
      main

primes :: [Integer]
primes = 2:3: filter isPrime [5,7..]

isPrime :: Integer -> Bool
isPrime n = all ((>0).(rem n)) $ takeWhile (\x -> x * x <= n) primes

primeArr = array (1,10000) [(i, pr)|i <- [1..10000] , let pr = sum (take i primes)]

Measured memory_bytes: 4836
#include<iostream>
#include<cstdio>
#include<cstring>

int n,m,k;

int got()
{
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		if(x==1)return i;
	}
	return -1;
}

int calc(int len)
{
	return len/(k-1)+(len%(k-1)!=0);
}

int main()
{
	scanf("%d%d",&n,&k);
	m=got();

	int ans=n;
	for(int l=std::max(1,m-k+1);l<=m;l++)
	{
		int r=std::min(n,l+k-1);
		ans=std::min(ans,1+calc(l-1)+calc(n-r));
	}
	printf("%d\n",ans);
	return 0;
}

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

const int MAX_C = 16;
const int MAX_D = 31;
const int MAX_W = 51;
const int MAX_X = 6;
const int INF = 1<<28;
int C, D, W, X;
int E[MAX_C][MAX_D], F[MAX_C][MAX_D];
int T[MAX_D][MAX_W][MAX_X];

int main() {
  while(cin >> C >> D >> W >> X && (C|D|W|X)) {
    for(int i = 1; i <= C; ++i)
      for(int j = 1; j <= D; ++j)
	cin >> E[i][j];
    for(int i = 1; i <= C; ++i) {
      for(int j = 1; j <= D; ++j) {
	cin >> F[i][j];
	if(E[i][j] == 0) F[i][j] = W*2;
      }
    }

    for(int j = 1; j <= D; ++j) {
      E[0][j] = F[0][j] = 0;
      for(int i = 1; i <= C; ++i) {
	E[i][j] = E[i][j] + E[i-1][j];
	F[i][j] = F[i][j] + F[i-1][j];
      }
    }

    fill(T[0][0],T[MAX_D][0],0);
    T[0][0][0] = 0;
    int ans = 0;
    for(int i = 1; i <= D; ++i) {
      for(int k = 0; k <= X; ++k) {
	for(int p = 0; p < C; ++p) {
	  for(int q = p+1; q <= C; ++q) {
	    int pk = k - (q-p >= 2);
	    if(pk < 0) break;
	    int value = E[q][i] - E[p][i];
	    int cost = F[q][i] - F[p][i];
	    for(int j = cost; j <= W; ++j) {
	      T[i][j][k] = max(max(T[i][j][k],T[i-1][j][k]),
			       T[i-1][j-cost][pk]+value);
	      ans = max(ans,T[i][j][k]);
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 908
#include <iostream>
#include <algorithm>
#include <cstring>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
	int n, m; cin >> n >> m;
	int coin[m];
	rep(i, m) cin >> coin[i];

	int num[n+1];
	memset(num, 1, sizeof(num));
	num[0] = 0;

	rep(i, m)rep(j, n+1){
		if(j - coin[i] >= 0){
			num[j] = min(num[j], num[j - coin[i]]+1);
		}
	}

	cout << num[n] << endl;
	return 0;
}



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

using namespace std;

int main(){

int arr[10000];

int a,b,c,x;

cin>>a>>b>>c;
for(int i=0;i<b;i++){
  cin>>x;
  arr[x]=1;
}    
int count=0;
for(int i=c;i<=a;i++){
 count = count + arr[i];
}

cout<<min(count,b-count);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {
   int x; cin >> x;
   rep(i,8){
       if(x >= 400 + 200*i && x < 400 + 200*(i+1)){
           cout << 8-i;
       }
   }

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };

           signed 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
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x,y;
    cin>>n;
    std::deque<int> num;
    std::deque<long double> X;
    std::deque<long double> Y;
    long double hoge=1;
    for (int i=0;i<n;i++) {
        cin>>x>>y;
        hoge*=(i+1);
        num.emplace_back(i);
        X.emplace_back(x);
        Y.emplace_back(y);
    }
    long double sum=0;
    do {
        for (int j=0;j+1<n;j++) {
            //cout<<num[j]<<" "<<num[j+1]<<endl;
            //cout<<sqrt((X[num[j]]-X[num[j+1]])*(X[num[j]]-X[num[j+1]])+(Y[num[j]]-Y[num[j+1]])*(Y[num[j]]-Y[num[j+1]]))<<endl;
            sum+=sqrt((X[num[j]]-X[num[j+1]])*(X[num[j]]-X[num[j+1]])+(Y[num[j]]-Y[num[j+1]])*(Y[num[j]]-Y[num[j+1]]));
        }
    } while (next_permutation(num.begin(),num.end()));
    printf("%.10Lf",sum/hoge);
    cout<<endl;
}

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

int main(void)
{
  int N = 0;
  cin >> N;
  string a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    int a_b = 0;
    int b_c = 0;
    int a_c = 0;
    if (a[i] != b[i])
      a_b = 1;
    if (c[i] != b[i])
      b_c = 1;
    if (a[i] != c[i])
      a_c = 1;
    if (a_b + b_c + a_c == 3)
      count += 2;
    else if (a_b + b_c + a_c == 0)
    {
      continue;
    }
    else
    {
      count += 1;
    }
  }
  cout << count;
  return 0;
}


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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int n, a[10];
    cin >> n;
    int odd = 0, even = 0;
    rep(i, n) {
        cin >> a[i];
        if(a[i] % 2) ++odd;
        else ++even;
    }
    int res = pow(3, n) - pow(2, even);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long int
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int MOD = 1000000007;
ll mod(ll x){
    return (x%MOD + MOD)%MOD;
}
ll mul(ll a , ll b){
    return mod(mod(a)*mod(b));
}
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
static int rowNbr[] = { -1, -1, -1, 0, 0, 1, 1, 1 }; 
static int colNbr[] = { -1, 0, 1, -1, 1, -1, 0, 1 }; 
int main()
{
    fast
    int n;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}




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

using namespace std;

int main(){
    string s;
    int K;
    cin >> s;
    cin >> K;
    char ans[100000];
    for(int i = 0;i < s.size()-1; i++){
        if(K > 'z'-s[i] && s[i] != 'a'){
            K -= ('z'-s[i]+1);
            ans[i] = 'a';
        }else{
            ans[i] = s[i];
        }
        cout << ans[i];
    }
    if('z' - s[s.size()-1] >= (K%26)) ans[s.size()-1] = s[s.size()-1]+(K%26);
    else ans[s.size()-1] = s[s.size()-1]-26+(K%26);
    //if(ans[s.size()-1] > 'z' || ans[s.size()-1] < 'a') ans[s.size()-1]-=26;
    cout << ans[s.size()-1] << endl;
    //cout << s.size() << endl;
}

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


int main(void)
{
    int i,j,top,dice[10],dice2[10];

    for(i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
    for(i=0;i<6;i++){
        scanf("%d",&dice2[i]);
    }
    
    for(i=0;i<8;i++){
        if(memcmp(dice,dice2,sizeof(dice))==0)break;
        if(dice[0]==dice2[0]){
            for(j=0;j<4;j++){
                top=dice2[1];
                dice2[1]=dice2[2];
                dice2[2]=dice2[4];
                dice2[4]=dice2[3];
                dice2[3]=top;
                if(memcmp(dice,dice2,sizeof(dice))==0) goto OUT;
            }
        }
        if(i<4){
                top=dice2[0];
                dice2[0]=dice2[1];
                dice2[1]=dice2[5];
                dice2[5]=dice2[4];
                dice2[4]=top;
        }else{
                top=dice2[0];
                dice2[0]=dice2[2];
                dice2[2]=dice2[5];
                dice2[5]=dice2[3];
                dice2[3]=top;
        }
    }
    OUT:

    if(memcmp(dice,dice2,sizeof(dice))==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2024
#include <iostream>

using namespace std;

int gcd(long long a, long long b) {
  while (!a == 0 && !b == 0) {
    if (a >= b) {
      a %= b;
    } else {
      b %= a;
    }
  }
  if (a == 0) {
    return b;
  } else {
    return a;
  }
}

int main() {
  long long a, b;
  while (cin >> a >> b) {
    long long g = gcd(a, b);
    long long l = a * b / g;
    cout << g << " " << l << endl;
  }
  return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;


int C[1000000];
int H;

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


void maxHeapify(int i) {
	int l = left(i);
	int r = right(i);
	int largest;
	// 左の子、自分、右の子で値が最大のノードを選ぶ
	if (l <= H && C[l] > C[i]) {
		largest = l;
	}
	else {
		largest = i;
	}
	if (l <= H && C[r] > C[largest]) {
		largest = r;
	}

	if (largest != i) { // i の子の方が値が大きい場合
		swap(C[i], C[largest]);//A[i] と A[largest] を交換
		maxHeapify(largest); // 再帰的に呼び出し
	}
}

/*void buildMaxHeap(int A[]) {
	for (int i = H / 2;i >= 1; i--) {
		maxHeapify(i);
	}
}*/

int main() {
	string str;
	int i = 1;
	int j = 1;


	while (1) {
		cin >> str;
		if (str == "insert") {
			H++;
			cin >> C[H];
			//maxHeapify(H);
			int l = H; 
			
			while (l > 1 && C[l] > C[l / 2]) {
				swap(C[l], C[l / 2]);
				l = l / 2;
			}
		}
		else if (str == "extract") {
			int max;
			cout << C[1] << endl;
		
			//swap(C[1], C[H]);
			max = C[1];
			C[1] = C[H];
			
			H--;
			maxHeapify(1);
		}
		if (str == "end") {
			break;
		}
	}

	//cout << endl;

	return 0;
}




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

int main()
{
    int N;
    cin >> N;
    long long ans = 1;
    long long e = pow(10, 18);
    vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < N; i++)
    {
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (a[i] > (long long)e/ans)
        {
            cout << -1 << endl;
            return 0;
        }
        
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int A, B;
	cin >> A >> B;

	int ans = 0;
	for (int i = A; i <= B; i++) {
		string s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3]) ans++;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Card[] cards = new Card[n];
      char suit;
      int  value;

      for ( int i=0; i<n; i++ ) {
        suit = (char)br.read(); br.skip(1);
        value = Integer.parseInt(br.readLine());
        cards[i] = new Card(suit, value, i);
      }

      quickSortOfCards(cards, 0, n-1);
      dispCardArray(cards);
    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }

  public void quickSortOfCards(Card[] card, int p, int r) {

    if( p < r) {
      int q = partitionOfCards(card, p, r);
      quickSortOfCards(card, p, q-1);
      quickSortOfCards(card, q+1, r);
    }
  }

  public int partitionOfCards(Card[] card, int p, int r) {

    int x = card[r].value;
    int i = p-1;
    Card t;

    for(int j=p; j<r; j++) {
      if(card[j].value <= x) {
        t = card[++i]; card[i] = card[j]; card[j] = t;
      }
    }
    t = card[i+1]; card[i+1] = card[r]; card[r] = t;

    return i+1;
  }

public void dispCardArray(Card[] target) {
  StringBuilder s = new StringBuilder();
  int l=target.length;
  boolean isStable = true;
  String sortState = "Stable";

  s.append(target[0]).append("\n");
  for (int i=1; i<l; i++) {
    s.append(target[i]).append("\n");
    if(isStable && target[i-1].value == target[i].value 
      && target[i-1].storedNo > target[i].storedNo) {
      sortState = "Not stable";
      isStable = false;
    }
  }

  System.out.println(sortState);
  System.out.print(s);
  }
}

class Card {
  char suit;
  int value;
  int storedNo;

  public Card( char suit, int value, int storedNo ) {
    this.suit  = suit;
    this.value = value;
    this.storedNo = storedNo;
  }
  public Card( Card card ) {
    this(card.suit, card.value, card.storedNo);
  }

  @Override
  public String toString() {
    return suit + " " + String.valueOf(value);
  }
}


Measured memory_bytes: 59696
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

int main(){
  int n;
  while(~scanf("%d", &n)){
    vector<int>a(n);
    rep(i, n) scanf("%d", &a[i]);

    int res = 0;

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

    rep(i, n)
      rep(j, i+1) res += a[j];

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

Measured memory_bytes: 1204
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=2000000000;
ll m,j,k;
int i,n,a[200001],d[200001],tot,b[200001];
int main(){
	scanf("%d",&n);m=(ll)(n)*(ll)(n+1)/2LL;
	for (i=1;i<=n;i++) scanf("%d",&a[i]),a[i]%=m;
	for (a[0]=a[n],i=1,k=-inf;i<=n;i++) d[i]=a[i]-a[i-1],k=max(k,(ll)d[i]);
	for (i=1;i<=n;i++)
	 if ((k-d[i])%n){
	 	puts("NO");return 0;
	 }else b[i]=(k-d[i])/n;
	for (i=2,j=a[1]-b[1];i<=n;i++) j-=(ll)(n-i+2)*(ll)b[i];
	puts(j?"NO":"YES");
	return 0;
}

Measured memory_bytes: 1408
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    C = [0] * (10**6 + 1)
    for a in A:
        if C[a] == 1:
            C[a] = -1
            continue
        if C[a] == -1:
            continue
        C[a] = 1
        for b in range(a + a, 10 ** 6 + 1, a):
            C[b] = -1
    ans = 0
    for a in A:
        if C[a] == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


Measured memory_bytes: 106676
(let* ((N (read))
       (M (read))
       (X (read))
       (Y (read))
       (Xi (loop :repeat N :collect (read)))
       (Z (apply #'min
                 (loop :repeat M :collect (read)))))
  (if (and (< X Z)
           (<= Z Y)
           (not (dolist (w Xi)
                  (if (>= w Z) (return t)))))
      (princ "No War") (princ "War")))

Measured memory_bytes: 6504
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <unordered_map>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    VI v;
    REP(i,3) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    if (v[0] + v[1] == v[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;

int n;
int ans = 0;
long long d;
long long x,y;

int main() {
	cin >> n >> d;
	d = d * d;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		ans += ( (x * x + y * y) <= d );
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632