akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  std::string s;
  std::cin >> s;

  ll p = 0;
  rep(i, 0, sz(s)) {
    if (s[i] == 'p') p++;
  }

  put(sz(s) / 2 - p);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

long double comb(int a, int b) {
	long double ans = 1.0L;
	for (int i = 0; i < b; ++i) {
		ans *= (long double)(a - i);
		ans /= (long double)(i + 1);
	}
	return ans;
}

long double prob(long double percent, int a, int b) {
	long double ans = 1.0L;
	percent /= 100.0L;
	for (int i = 0; i < a; ++i) {
		if (i < b) {
			ans *= percent;
		}
		else {
			ans *= (1.0L - percent);
		}
	}
	ans *= comb(a, b);
	return ans;
}

void solve(){
	int n, m, l;
	cin >> n >> m >> l;
	vector<tuple<int, int, long double>> inputs;
	REP(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		inputs.push_back(make_tuple(a, b, (long double)l / (long double)c));
	}
	REP(i, n) {
		long double ans = 0;
		for (int q = 0; q <= m; ++q) {
			long double req_time = q * get<1>(inputs[i]);
			req_time += get<2>(inputs[i]);
			long double pre = prob(get<0>(inputs[i]), m, q);
			REP(j, n) {
				if (j == i) continue;
				long double tmp = 0.0L;
				for (int t = 0; t <= m; ++t) {
					long double now_time = t * get<1>(inputs[j]);
					now_time += get<2>(inputs[j]);
					if (now_time > req_time + eps) {
						tmp += prob(get<0>(inputs[j]), m, t);
					}
				}
				pre *= tmp;
			}
			ans += pre;
		}
		cout << ans << endl;
	}
}

#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main ()
{
    string s;
    cin >> s;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;
    cout << mp[s] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;


template<int Modulus> 
struct ModInt {
    long long x;
    ModInt(long long x = 0) :x((x%Modulus + Modulus)%Modulus) {}
    constexpr ModInt &operator+=(const ModInt a) {if ((x += a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator-=(const ModInt a) {if ((x += Modulus - a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator*=(const ModInt a) {(x *= a.x) %= Modulus; return *this;}
    constexpr ModInt &operator/=(const ModInt a) {return *this *= a.inverse();}

    constexpr ModInt operator+(const ModInt a) const {return ModInt(*this) += a.x;}
    constexpr ModInt operator-(const ModInt a) const {return ModInt(*this) -= a.x;}
    constexpr ModInt operator*(const ModInt a) const {return ModInt(*this) *= a.x;}
    constexpr ModInt operator/(const ModInt a) const {return ModInt(*this) /= a.x;}
    
    friend constexpr ostream& operator<<(ostream& os,const ModInt<Modulus>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<Modulus>& a) {return is >> a.x;}
    
    ModInt inverse() const {// x ^ (-1) 
        long long a = x,b = Modulus,p = 1,q = 0;
        while (b) {long long d = a/b; a -= d*b; swap(a,b); p -= d*q; swap(p,q);}
        return ModInt(p);
    }
    ModInt pow(long long N) {// x ^ N 
        ModInt a = 1;
        while (N) {
            if (N&1) a *= *this;
            *this *= *this;
            N >>= 1;
        }
        return a;
    }
};

using mint = ModInt<1000000007>;

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

    int N,K; cin >> N >> K;
    vector<int> L,R;
    for (int i = 1;i*i <= N;++i) {
        L.push_back(1);
        if (i*(i + 1) < N) R.push_back(N/i - N/(i + 1));
    }
    if (N == 2) L.push_back(1);
    irep(i,R.size()) L.push_back(R[i]);

    int x = L.size();

    vector<mint> dp(x + 1,0);
    rep(i,x) dp[i + 1] = dp[i] + L[i];
    rep(i,K - 1) {
        vector<mint> nex(x + 1,0);
        rep(j,x) {
            nex[j + 1] = nex[j] + dp[x - j] * L[j];
        }
        swap(nex,dp);
    }
    cout << dp.back() << '\n';
    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  rep(i, h) {
    string str;
    cin >> str;
    rep(j, w) { s[i][j] = str[j]; }
  }

  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) {
    int r = 0;
    int l = 0;
    rep(j, w) {
      if (s[i][j] == '.') r++;
      if ((s[i][j] == '#') || (j == w - 1)) {
        int k = l;
        while (k < r) {
          a[i][k] += r - l;
          k++;
        }
        r++;
        l = r;
      }
    }
  }
  rep(j, w) {
    int r = 0;
    int l = 0;
    rep(i, h) {
      if (s[i][j] == '.') r++;
      if ((s[i][j] == '#') || (i == h - 1)) {
        int k = l;
        while (k < r) {
          a[k][j] += r - l;
          k++;
        }
        r++;
        l = r;
      }
    }
  }
  int ans = 0;
  rep(i, h) { ans = max(ans, *max_element(a[i].begin(), a[i].end())); }
  cout << ans - 1 << endl;
  return 0;
}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "No" << endl
#define yes cout << "Yes" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define db(x) cout << #x << ": " << x << endl;
#define _db(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);
template<typename... T> void read(T&... x) {((cin >> x),...);}

int main() {
    godspeed;
    ll n; cin >> n;
    vl a(n), b(n);
    _for(i,0,n) cin >> a[i];
    _for(i,0,n) cin >> b[i];

    ll ans = 0;
    do {
        ans++;
    } while(next_permutation(all(a)));

    do {
        ans--;
    } while(next_permutation(all(b)));

    cout << abs(ans);
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=5e5+10,mod=998244353;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
int n,k,fac[N],iac[N];
int C(int a,int b){return b<0||a<b?0:1ll*fac[a]*iac[b]%mod*iac[a-b]%mod;}

int main()
{
	fac[0]=1;
	for(int i=1;i<=N-5;++i) fac[i]=1ll*fac[i-1]*i%mod;
	iac[N-5]=ginv(fac[N-5]);
	for(int i=N-5;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
	n=rd(),k=rd();
	if(n>k){puts("0");return 0;}
	int ans=0;
	for(int i=n,j=k-n;i<=k;++i,--j)
	{
		if(i>j)
		{
			ad(ans,C(k,j));
			if(i-j<=n) ad(ans,mod-C(k,j-(i-n+1)));
		}
		else if(i==j)
			ad(ans,C(k-1,j-1)),ad(ans,mod-C(k-1,j-1-(i-n+1)));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,a=0,b=0;
    cin>>n;
    for(i=1;i<=n;i+=2)
    {
    	for(j=1;j<=n;j++)
    	{
            if(i%j==0) a++;
		}
		if(a==8) b++;
		a=0;
	}
	cout<<b;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)


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

	vector<int> t(n);
	t.at(0) = 0;
	for (int i=0; i<n-1; i++) {
		if (s.substr(i, 2)=="AC") t.at(i+1) = t.at(i) + 1;
		else t.at(i+1) = t.at(i);
	}

	rep(i, q) {
		int l, r;
		cin >> l >> r;
		cout << t.at(r-1) - t.at(l-1) << endl;
	}
}

Measured memory_bytes: 1408
import * as fs from 'fs';

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split(' ');
const a: number = parseInt(args[0]);
const op: string = args[1];
const b: number = parseInt(args[2]);

if (op === '+') {
    console.log(a + b);
}
if (op === '-') {
    console.log(a - b);
}


Measured memory_bytes: 29608
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, res1, res2;
std::map<LL, LL>cnt, cnt1, cnt2;

int main()
{
	in >> N;
	std::vector<LL>v(N);
	std::vector<std::pair<LL, LL>>res1, res2;
	rep(i, N) in >> v[i];
	rep(i, N)
	{
		++cnt[v[i]];
	}
	if (cnt.size() == 1)
	{
		out << N / 2 << std::endl;
	}
	else
	{
		rep(i, N)
		{
			if (i % 2 == 0) ++cnt1[v[i]];
			else ++cnt2[v[i]];
		}
		for (auto i : cnt1)
		{
			res1.push_back(std::make_pair(i.second, i.first));
		}
		for (auto i : cnt2)
		{
			res2.push_back(std::make_pair(i.second, i.first));
		}
		std::sort(res1.rbegin(), res1.rend());
		std::sort(res2.rbegin(), res2.rend());
		LL ans = 114514;
		rep(i, 2)
		{
			if (i == 1 && res1.size() == 1) continue;
			rep(j, 2)
			{
				if (j == 1 && res2.size() == 1) continue;
				if (res1[i].second == res2[j].second) continue;
				ans = std::min(ans, N - res1[i].first - res2[j].first);
			}
		}
		out << ans << std::endl;
	}
	return 0;
}


Measured memory_bytes: 15860
// inputに入力データ全体が入る
function Main(input) {
    input = input.split("\n");
    var output = 'T';

    if (input[0] === 'T') {
        output = 'A';
    } else if (input[0] === 'C') {
        output = 'G'
    } else if (input[0] === 'G') {
        output = 'C'
    }

    console.log(output);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int n, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0) { cout << " " << i ;}
     else {
       x = i;
       while (x) {
         if (x % 10 == 3) { cout << " " << i ; break;}
         else { x /= 10;}
       }
     }
  }
  cout << endl;
  return 0;
}


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

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

int main()
{
    int K;
    int ans = 0;
    cin >> K;

    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            for(int k = 0;k < K;k++){
                ans += gcd(i + 1, gcd(j + 1, k + 1));
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3152
#include <cstring>
#include <iostream>
using namespace std;
int main () {
	int n;
	while (cin >> n, n) {
		int w, h;
		cin >> w >> h;
		int field[h + 1][w + 1];
		memset(field, 0, sizeof(field));
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			field[y][x] = 1;
		}
		int s, t, result = 0;
		cin >> s >> t;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				int count = 0;
				for (int y = 0; y < t; y++) {
					if (i + y > h) continue;
					for (int x = 0; x < s; x++) {
						if (j + x > w) continue;
						count += field[i + y][j + x];
					}
				}
				result = max(result, count);
			}
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 100011;

int n, i, j, x, y, bg, pos;
vector<int> list[maxN];
bool leaf[maxN];
int gr[maxN], gr_leaf[maxN];
vector<int> ord, ord2;
vector<int> ans;

void dfs(int node, int root) {
    ord.pb(node);
    for (auto to : list[node])
        if (!leaf[to])
            if (to != root)
                dfs(to, node);
}

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i < n; i++) {
        scanf("%d%d", &x, &y);
        list[x].pb(y);
        list[y].pb(x);
        gr[x]++; gr[y]++;
    }

    if (n == 2) {
        printf("1 2");
        return 0;
    }

    for (i = 1; i <= n; i++) {
        if (gr[i] > 1) continue;
        leaf[i] = true;
        gr_leaf[list[i][0]]++;
    }

    for (i = 1; i <= n; i++) {
        if (gr[i] - gr_leaf[i] > 2) {
            printf("-1");
            return 0;
        }
    }

    for (bg = 1; leaf[bg] || gr[bg] - gr_leaf[bg] == 2; bg++);
    dfs(bg, 0);

    ord2 = ord;
    reverse(ord2.begin(), ord2.end());
    for (i = 0; i < ord.size(); i++) {

        if (gr_leaf[ord[i]] < gr_leaf[ord2[i]]) break;
        if (gr_leaf[ord[i]] > gr_leaf[ord2[i]]) {
            swap(ord, ord2);
            break;
        }
    }

    gr_leaf[ord[0]]--;
    gr_leaf[ord.back()]--;

    pos = 2;
    ans = {1};

    for (auto e : ord) {
        for (i = 1; i <= gr_leaf[e]; i++) ans.pb(pos + i);
        ans.pb(pos);
        pos += gr_leaf[e] + 1;
    }

    ans.pb(n);

    for (auto e : ans) printf("%d ", e);


    return 0;
}


Measured memory_bytes: 12664
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def combinations_count(n, r):
    if n<=1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import math
from collections import deque
n, m = map(int, input().split())
ms = [list(map(int, input().split())) for _ in range(m)]
ms.reverse()
combs = combinations_count(n, 2)
res = deque([combs])
uf = UnionFind(n)
for i in ms[:-1]:
    if not (uf.same(i[0]-1,i[1]-1)):
        combs -= uf.size(i[0]-1)*uf.size(i[1]-1)
    res.appendleft(combs)
    uf.union(i[0] - 1, i[1] - 1)
for i in res:
    print(i)

Measured memory_bytes: 34004
#include <memory>
#include <map>
#include <cassert>
#include <array>
#include <iterator>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <numeric>

class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
      int n;
      in >> n;
      if (n / 100 == n % 10)
        out << "Yes\n";
      else
        out << "No\n";
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}

#include <iostream>

int main ()
{
  solve (std::cin, std::cout);
}


Measured memory_bytes: 256
#include<iostream>
int digit(int n){ int c=0;
  while(n!=0){ c++;n/=10;
  } return c;
}
int main(){
  int n,c=0; std::cin>>n;
  for(int i=1;i<=n;i++)
  if(digit(i)%2) c++;
  std::cout<<c; 
  return 0;
}  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include <queue>
#include <functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    ll h,w;
    cin >> h >> w;
    ll ans;
    
    if(h>w) swap(h,w);
    if(h%3==0 || w%3==0){
        cout << 0 << ENT;
        return 0;
    }else ans = h;
    
    for(int i=1; i<h; ++i){
        ll s1,s2,s3;
        s1 = i*w;
        if(w%2==0){
            s2 = (h-i)*(w/2);
            s3 = s2;
        }else{
            s2 = (h-i)*((w+1)/2);
            s3 = (h-i)*((w-1)/2);
        }
        ans = min(max(max(s1,s2),s3)-min(min(s1,s2),s3) , ans);
    }
    for(int i=1; i<w; ++i){
        ll s1,s2,s3;
        s1 = i*h;
        if(h%2==0){
            s2 = (w-i)*(h/2);
            s3 = s2;
        }else{
            s2 = (w-i)*((h+1)/2);
            s3 = (w-i)*((h-1)/2);
        }
        ans = min(max(max(s1,s2),s3)-min(min(s1,s2),s3) , ans);
    }

    
    
    
    
    cout << ans << ENT;
    
    return 0;
}

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


Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,a[3010];
int dp[3010][3010];

int taro(int l, int r){
    if (r-l <= 0) return 0;
    if (r-l == 1) return a[l];
    if (dp[l][r] < (1LL << 60)) return dp[l][r];
    int ltake = a[l];
    ltake += min( -a[l+1] + taro(l+2,r), -a[r-1] + taro(l+1, r-1));
    int rtake = a[r-1];
    rtake += min( -a[l] + taro(l+1,r-1), -a[r-2] + taro(l,r-2));

    return dp[l][r] = max(ltake, rtake);
}

signed main(){
    I(n);
    REP(i,n) I(a[i]);
    REP(i,n+1) REP(j,n+1) dp[i][j] = (1LL << 60);
    cout << taro(0,n) << endl;
}

Measured memory_bytes: 70912
#include<stdio.h>
#define N 100

int main(){
  int M[N][N];
  int n,u,k,v;
  int i,j;
  
  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      M[i][j] = 0;
    }
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d",&u,&k);
    //printf("%d %d\n",u,k);
    u--;

    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      if( j != 0 ) printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];

  ll res = 0;

  for (int i = 0; i < n; i++) {
    res += min(a[i], b[i]);
    b[i] -= a[i];
    if (b[i] > 0) {
      res += min(b[i], a[i + 1]);
      a[i + 1] = max(0, a[i + 1] - b[i]);
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

const int MAX_N = 105;
int N;
int b[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;
    std::deque<int> deq;
    deq.push_back(0);
    rep (i, 1, N) {
        std::cin >> b[i];
        deq.push_back(b[i]);
    }

    std::vector<int> ret;
    
    rev (i, N, 1) {
        bool found = false;
        rev (j, i, 1) {
            if (deq[j] == j) {
                //std::cout << "c:" << j << std::endl;
                ret.push_back(j);
                deq.erase(deq.begin() + j);
                found = true;
                break;
            }
        }
        if (!found) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    std::reverse(ret.begin(), ret.end());
    for (int i : ret) {
        std::cout << i << std::endl;
    }

    return 0;
}



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

using namespace std;
#define INF 1000000001

int main()
{
    int N,W;
    int max_val = 0;
    cin >> N >> W;
    vector<long > v(N,0);
    vector<long > w(N,0);
    for(int i = 0 ;i < N;i++){
        cin >> w[i] >> v[i];
        max_val+=v[i];
    }
    vector<vector<long> > dp(N+1,vector<long>(max_val+1,INF));

    dp[0][0] = 0;

    for(int i = 1;i <= N;i++){
        for(int j = 0; j <= max_val;j++){
            dp[i][j] = dp[i-1][j];
            if(j >= v[i-1]){
                if(dp[i-1][j-v[i-1]] != INF){
                    dp[i][j] = min(dp[i][j],dp[i-1][j-v[i-1]] + w[i-1]);
                }
            }
        }
    }
    int ans = 0;
    for(int j = max_val;j>=0;j--){
        if(dp[N][j] <= W) {
            ans = j;
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 80256
n = int(input())
flg = "False"
if n <= 9:
    print("Yes")
else:
    for i in range (2, 10):
        if n % i == 0 and n / i <= 9:
            print("Yes")
            flg = "True"
            break
        if i == 9 and flg == "False":
            print("No")

Measured memory_bytes: 3064
n, l = map(int, input().split())
L = [i+l for i in range(n)]
mi = min(L)
if 0 in L:
  print(sum(L))
elif mi>0:
  print(sum(L)-min(list(map(abs,L))))
else:
  print(sum(L)+min(list(map(abs,L))))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a == b)
    {
        cout << "Draw" << endl;
    }
    else if (a != 1 && b != 1 && a > b)
    {
        cout << "Alice" << endl;
    }
    else if (a != 1 && b != 1 && a < b)
    {
        cout << "Bob" << endl;
    }
    else if (a == 1)
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Bob" << endl;
    }
    return 0;
}

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

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)

int main() {
	ll a, b, n;
	ll ans;
	cin >> n >> a >> b;
	ans = (n / (a + b)) * a;
	if (n % (a + b) > a)ans += a;
	else ans += n % (a + b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())

n7 = N//7+1

ans = "No"
for i in reversed(range(n7+1)):
    if 7*i > N:
        continue
    elif 7*i == N:
        ans = "Yes"
        break
    else:
        r = N-7*i
        if r % 4 == 0:
            ans = "Yes"
            break
print(ans)


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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        String o = in.nextLine();
        String e = in.nextLine();

        int l1 = o.length();
        int l2 = e.length();

        int i;
        for(i=0;i<l1 && i<l2;i++){
            out.print(o.charAt(i));
            out.print(e.charAt(i));
        }

        if(i<l1){
            out.print(o.charAt(i));
        }
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

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


Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

int s(int n) {
	int ret = 0;
	while(n){
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

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

	lint x, y, ans = 0;
	cin >> x >> y;
	while (1) {
		ans++;
		if (x * 2 <= y)x *= 2;
		else break;
	}
	co(ans);
	gc();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5+1;
const int inf=1e9;
int main(){
	double X; cin>>X;
	long res = 100;
	rep(i,1,10000){
		res *= 1.01;
		if(res >= X){ cout<<i<<endl; break; }
	}
}

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
n,m,*a=map(int,open(0).read().split())
d=[0]*n*9
for i in range(n):
 for j in a:c=i+(0,2,5,5,4,5,6,3,7,6)[j];d[c]=max(d[c],(d[i]*10+j)*(i<1or d[i]>0))
print(d[n])

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

int main() {
int N;
cin >> N;
int num[200000];
int ans = 0;
for(int i = 0; i < N; i++){
cin >> num[i];
}
int m = N+1;
for(int i = 0; i < N; i++){
m = min(m, num[i]);
if(m == num[i]) ans++;




}

cout << ans << endl;
}

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

long long Roundup(long long a, long long b) {
	return (a + b - 1LL) / b;
}

int main() {
	long long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	cout << Roundup(N, min({ A, B, C, D, E })) + 4 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define FI first
#define SE second
#define mem(a) memset(a,0,sizeof(a))
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
const LL maxn = 1<<17;
const int mod = 1e9+7;
const int N = 4e5+5;
LL gcd(LL a,LL b) {
	return b?gcd(b,a%b):a;
}
LL lcm(LL a,LL b) {
	return a*b/gcd(a,b);
}
int main() {
	ios;
	int l,r,d;
	cin>>l>>r>>d;
	int t=r/d-l/d;
	if(l%d==0)t++;
	cout<<t;
	return 0;
}


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

using namespace std;

vector<string> solve(int h, int w, int pat1, int pat2) {
  vector<vector<string>> pat_s{{
                                   "####",
                                   "...#",
                                   "...#",
                                   "...#",
                               },
                               {
                                   "####",
                                   "...#",
                                   ".#.#",
                                   "...#",
                               },
                               {
                                   "####",
                                   "####",
                                   "####",
                                   "####",
                               }};

  int pat3 = h * w - (pat1 + pat2);

  vector<vector<int>> pat(h / 4, vector<int>(w / 4));

  int cnt = 0;
  for (int i = 0; i < pat.size(); ++i) {
    for (int j = 0; j < pat[i].size(); ++j, cnt++) {
      if (cnt < pat1) {
        pat[i][j] = 0;
      } else if (cnt < pat1 + pat2) {
        pat[i][j] = 1;
      } else {
        pat[i][j] = 2;
      }
    }
  }

  vector<string> res;
  for (int i = 0; i < pat.size(); ++i) {
    for (int j = 0; j < 4; ++j) {
      string r = "";
      for (int k = 0; k < pat[i].size(); ++k) {
        r += pat_s[pat[i][k]][j];
      }
      res.push_back(r);
    }
  }

  return res;
}

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;
  bool reversed = a < b;
  if (reversed) {
    swap(a, b);
  }

  int h = 100, w = 100;
  cout << h << ' ' << w << '\n';

  b--;
  int pat1 = a - b, pat2 = b;
  vector<string> ans = solve(h, w, pat1, pat2);
  for (auto &s : ans) {
    for (int i = 0; i < s.size(); ++i) {
      if (!reversed) {
        cout << s[i];
      } else {
        cout << (s[i] == '.' ? '#' : '.');
      }
    }

    cout << '\n';
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

bool sortByVal(const pair<int, int> &a, 
               const pair<int, int> &b) 
{ 
    return (a.second < b.second); 
} 

int main() {
    int N, K;
    cin >> N >> K;
    
    map<int, int> cnt;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;

        auto found = cnt.find(A);
        if (found == cnt.end()) {
            cnt[A] = 1;
        } else {
            cnt[A]++;
        }
    }

    vector<pair<int, int>> vec;
    for (auto const& x : cnt) {
        vec.push_back(pair<int, int>(x.first, x.second));
    }
    sort(vec.begin(), vec.end(), sortByVal); 

    int num = 0;
    int lim = max((unsigned long)0, vec.size() - K);
    for (int i = 0; i < lim; i++) {
        num += vec[i].second;
    }

    cout << num << endl;
}

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

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

if(A+B > C+D){
  cout << "Left" << endl;
}

if(A+B == C+D){
  cout << "Balanced" << endl;
}
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a;
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputDoubleArray(a,N) double a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//参考
// 入力
int N, M;
vector<vector<int> > G; // グラフ

// メモ化再帰
int dp[100100];

int rec(int v) {
    if (dp[v] != -1) return dp[v]; // 既に更新済み

    int res = 0;
    for (auto nv : G[v]) {//要素nvについてループを回す。
        chmax(res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}

int main() {
    // 入力受け取り
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);//GraphVector[x]にyを追加
    }
    for(int i=0; i<N; i++){
      
    }

    // 初期化
    for (int v = 0; v < N; ++v) dp[v] = -1;

    // 全ノードを一通り更新しながら答えを求める
    int res = 0;
    for (int v = 0; v < N; ++v) chmax(res, rec(v));
    cout << res << endl;
}

Measured memory_bytes: 8192
<?php

class Distance
{
    public function __construct(Point $point1, Point $point2)
    {
        $this->point1 = $point1;
        $this->point2 = $point2;
    }

    public function compute()
    {
        return sqrt(
            pow($this->point2->x() - $this->point1->x(), 2)
          + pow($this->point2->y() - $this->point1->y(), 2)
        );
    }
}

class Point
{
    private $x;
    private $y;

    public function __construct($x, $y)
    {
        $this->x = $x;
        $this->y = $y;
    }

    public function x()
    {
        return $this->x;
    }

    public function y()
    {
        return $this->y;
    }
}

fscanf(STDIN, '%f %f %f %f', $x1, $y1, $x2, $y2);

echo (new Distance(new Point($x1, $y1), new Point($x2, $y2)))
    ->compute(), PHP_EOL;

Measured memory_bytes: 15476
#include <bits/stdc++.h>
#define int long long
using namespace std;

int gcd(int a, int b){
	if(!a) return b;
	return gcd(b%a,a);
}

signed main() {
  int A, B;
  cin >> A >> B;
  
  int C = gcd(A, B);
  
  vector<int> yakusu;
  for(int i = 1; i*i <= C; i++ ){
    if( C % i == 0 ){
      yakusu.push_back(i);
      if(i != C/i) yakusu.push_back(C/i);
    }
  }
  
  sort(yakusu.begin(), yakusu.end());
  
  for( int i = 1; i < yakusu.size(); i++ ){
    if( yakusu.at(i) == -1 ) continue;
    for( int j = i+1; j < yakusu.size(); j++ ){
      if( yakusu.at(j) == -1 ) continue;
      if( yakusu.at(j) % yakusu.at(i) == 0 ){
      yakusu.at(j) = -1;
      }
    }
  }
  
  
  int ans = 0;
  for( int i = 0; i < yakusu.size(); i++ ){
    if( yakusu.at(i) != -1 ){
      ans++;
    }
  }
  cout << ans << endl;
        
  
}


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

typedef long long ll;
typedef vector<ll> vi;

vi a,b;
int n;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll s1,s2,p,q;
    while(cin >> n)
    {
        a = vi(n);
        for(int i = 0; i < n; i++)
            cin >> a[i];
        //s1 = accumulate(a.begin(), a.end(), 0);
        b = vi(n);
        for(int i = 0; i < n; i++)
            cin >> b[i];
        //s2 = accumulate(b.begin(), b.end(), 0);
        //if(s1 > s2)
        //    cout << "No" << '\n';
        //else
        {
            p = q = 0;
            for(int i = 0; i < n; i++)
                if(a[i] > b[i])
                    q += a[i]-b[i];
                else if(a[i] < b[i])
                {
                    ll d = b[i] - a[i];
                    if(d % 2 == 0)
                        p += d/2;
                    else
                    {
                        p += (d+1)/2;
                        q++;
                    }
                }
            if(p >= q)
                cout << "Yes" << '\n';
            else
                cout << "No" << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int c[10] = {};

  for(int i=0;i<4;i++){
    int x;
    cin >> x;
    c[x]++;
  }

  if (c[1] && c[7] && c[9] && c[4])
    puts("YES");
  else
    puts("NO");


  return 0;
}


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

using namespace std;
const int N = 2e6+100;
const int mod = 1e9+7; 
typedef long long ll;
ll cnt[N];
void Fac(ll x){
	for(ll i=2;i*i<=x;i++){
		if(x%i==0){
			ll num=0;
			while(x%i==0){
				++num;
				x/=i;
			}
			cnt[i]=max(cnt[i],num);
		}
	}
	if(x!=1) cnt[x]=max(cnt[x],1LL);
}
ll Pow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1) ans=(ans*a)%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans%mod;
}
int main(){
	ll n;
	cin>>n;
	vector<ll> a(n+1);
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	} 
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=Pow(a[i],mod-2);
		ans%=mod;
	}
	for(int i=1;i<=n;i++){
		Fac(a[i]);
	}
	long long res=1;
	for(ll i=1;i<=1000000;i++){
		res*=Pow(i,cnt[i]);
		res%=mod;
	}
	cout<<(ans*res)%mod<<endl;
	return 0;
}

Measured memory_bytes: 8320
# )が１個抜けていた
import heapq
Q = []
while True:
    t = input()
    if t == 'end':
        break
    elif t == 'extract':
        n = heapq.heappop(Q)
        print((-1)*n)
    else:
        a,b = t.split()
        heapq.heappush(Q,(-1)*int(b))



Measured memory_bytes: 45312
#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 RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 



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

int N, Q; string S;
cin >> N >> S >> Q;

vector<set<int>> pos(26, set<int>({1<<30}));
rep(i, 0, N) {
    pos[S[i] - 'a'].insert(i+1);
}

while(Q--){
    int q; cin >> q;
    if (q == 1){
        int i; char c; cin >> i >> c;
        pos[S[i-1] - 'a'].erase(i);
        pos[c - 'a'].insert(i);
        S[i-1] = c;
    }
    else {
        int l, r; cin >> l >> r;
        int c = 0;
        rep(i, 0, 26){
            if (pos[i].empty()) continue;
            if (*pos[i].lower_bound(l) < *pos[i].lower_bound(r+1)) ++c;
        }

        cout << c << "\n";
    }
}

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 24220
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,m,i,j,cc=0;
    cin>>n;
    ll ara[n+1],bra[n];
    ara[0]=0;
    for(i=0;i<n;i++){
        cin>>bra[i];
        ara[i+1]=ara[i]+bra[i];
    }
   // for(i=1;i<=n;i++)cout<<ara[i]<<spc;
    ll ans=1111111111111LL;
    for(i=n;i>=1;i--){
        ll x=ara[i]-bra[i-1];
        ll y=ara[n]-x;
        if(abs(x-y)<ans)ans=abs(x-y);
    }
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int q = sc.nextInt();

		int totalTime = 0;
		String[] queue = new String[200000];
		int[] restTime = new int[200000];

		for(int i = 0; i < count; i++) {
			String name = sc.next();
			int time = sc.nextInt();

			queue[i] = name;
			restTime[i] = time;
		}

		int qhead = 0;
		int qtail = count;

		while(qhead != qtail) {
			if(restTime[qhead] <= q) {
				totalTime += restTime[qhead];
				System.out.println(queue[qhead] + " " + totalTime);
				qhead++;
			} else {
				queue[qtail] = queue[qhead];
				restTime[qtail] = restTime[qhead] - q;
				totalTime += q;
				qhead++;
				qtail++;
			}
		}

	}

}


Measured memory_bytes: 79940
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1LL << 62);

int main()
{
  int64_t N, x, y;
  cin >> N;
  int64_t mis = INF, mas = -INF, mid = INF, mad = -INF;
  for (int i = 0; i < N; i++)
  {
    cin >> x >> y;
    mis = min(mis, x + y);
    mas = max(mas, x + y);
    mid = min(mid, x - y);
    mad = max(mad, x - y);
  }
  cout << max(mas - mis, mad - mid) << endl;
}


Measured memory_bytes: 3632
#include<map>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN 100005
#define X first
#define Y second
#define MOD 1000000007
#define inf 1e18
#define fr(a,b,c) for(ll a=b;a<c;++a)
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll t,n,i,j;

int main()
{
    fastio;
    cin>>n;
    vector<ll > h(n);
    for(i=0;i<n;i++)
        cin>>h[i];
    vector<ll > dp(n);
    dp[0]=1;
    for(i=1;i<n;i++){
        if(h[i]<=h[i-1]) dp[i]=dp[i-1]+1;
        else dp[i]=1;
    }
    //for(i=0;i<n;i++) cout<<dp[i]<<" ";
    //cout<<endl;
    cout<<*max_element(dp.begin(),dp.end())-1;
}


Measured memory_bytes: 1792