akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define no_of_test(x)        int x; cin>>x; while(x--)
const int mod = 1e9 + 7;
//actual code is at the top 
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	no_of_test(x)
	{
      int n;
	  cin>>n;
	  int a[n];
	  for(int i=0;i<n;i++)
	 {
		  cin>>a[i];
	 }
	  bool flag=true;
	  for(int i=0;i<n;i++)
	  {
		  if(a[i]%2==0)
		  {
			  if((a[i]%3==0)||(a[i]%5==0))
			  {
				  continue;
			  }
			  else
			  {
				  flag=false;
				  break;
			  }
			  
		  }
	  }
	  if(flag==true)
	  cout<<"APPROVED"<<'\n';
	  else
	  {
		  cout<<"DENIED"<<'\n';
	  }
	  
	}
	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<int>> edges(100010);
vector<bool> used(100010,false);
int ans = 0;

void dfs(int i,int p = -1) {
    int cnt = 0;
    for (int& j : edges[i]) if (j != p) {
        dfs(j,i);
        if (used[j]) {
            cnt++;
            used[i] = true;
        }
    }
    if (p > -1 && edges[i].size() > cnt+2) {
        ans += max(0,(int)edges[i].size()-2-cnt);
        used[i] = true;
    } else if (p < 0) {
        ans += max(0,(int)edges[i].size()-1-cnt);
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    for (int i = 0;i < n;++i) if (edges[i].size() > 2) {
        dfs(i);
        break;
    }
    if (ans) cout << ans << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 10880
package main

import (
	"fmt"
)

func main() {
	var r, g, b int
	fmt.Scan(&r, &g, &b)
	i := r*100 + g*10 + b

	if i%4 == 0 {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>

using IV = std::vector<int>;
IV ToFixedIntArray(std::istream& is, int n) {
	IV ret(n);
	auto* dst = ret.data();
	while(n > 0) {
		--n;
		is >> *dst++;
	}
	return ret;
}

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
int main() {
	DisableIOSync();

	const auto input = ToFixedIntArray(std::cin, 4);
	struct Range {
		int from, to;
	};
	const Range r0{input[0], input[1]},
				  r1{input[2], input[3]};
	const auto proc = [&r0, &r1](){
		if(r0.to <= r1.from)
			return 0;
		if(r0.from >= r1.to)
			return 0;
		if(r1.to <= r0.from)
			return 0;
		if(r1.from >= r0.to)
			return 0;
		return std::min(r0.to, r1.to) - std::max(r0.from, r1.from);
	};
	std::cout << proc() << std::endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
v = LI()
c = LI()
ans = 0
for i in range(n):
    if v[i] > c[i]:
        ans += v[i] - c[i]
print(ans)

Measured memory_bytes: 65404
/*
题意是求一个序列中"所有子序列的中位数"所组成的序列的中位数 
看题解了，完全不会。https://www.cnblogs.com/quzhizhou/p/9535597.html  

首先我们先二分最后序列的中位数。设tot为中位数 >= mid的区间个数，若中位数序列的中位数 >= mid，
则有tot >= n(n+1)/4。
我们另外构造一个序列b[i], 当a[i]>=mid时b[i]=1, 否则bi=-1. 
那么若区间[l, r]的中位数 >= mid, 则b[l]+...+b[r] >= 0. 
于是我们求出序列b[i]的前缀和序列sum[i]，那么问题就变成了求满足l <= r且sum[r]-sum[l-1]>=0的数对(l,r)数量(0<=l,r<=n)，
这个问题可以用与求逆序对数量相似的方法解决. 树状数组即可. 
*/ 
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int NN = 110000;
int a[NN], l, r, n, mid, ans;
int s[NN * 2];  
//树状数组，注意，[-n-1, n], 为了让每一个存的值都是>0, 都加上n即可（因为树状数组不能从0开始）
//所以开双倍空间给数组 

int lowbit(int x){
	return x & (-x);
} 

void add1(int x, int k){
	while (x <= n * 2){
		s[x] += k;
		x += lowbit(x);
	}
}

int getsum(int x){
	int sum = 0;
	while (x > 0){
		sum += s[x];
		x -= lowbit(x);
	}
	return sum;
}

int check(int mid){
	memset(s, 0, sizeof(s));  //树状数组清0 
	//for(int i=1;i<=2*n;i++)s[i]=0;
	//与求逆序对的方法相同 
	add1(n, 1);  //因为在每个数的基础上都加了n，所以这句话相当于在和等于0的点+1
	int sum = 0;
	ll tmp = 0;
	for (int i=1; i<=n; i++){
		if (a[i] >= mid) sum++;
		else sum--;
		tmp += getsum(sum + n);
		add1(sum + n, 1);
	} 
	//return tmp>=1ll*n*(n+1)/4;
	long long nn = n * (n + 1) / 4; //注意！nn必须给long long
	if (tmp >= 1ll*n*(n+1)/4) return true;
	else return false; 
}

int main(){
	//freopen("atcoderarc101d.in", "r", stdin);
	
	scanf("%d", &n);
	l = 0x7fffffff; r = 0;
	for (int i=1; i<=n; i++){
		scanf("%d", &a[i]);
		if (a[i] >= r) r = a[i];
		if (a[i] <= l) l = a[i];
	}
	//printf("%d %d\n", l, r);
	while (l <= r){
		mid = (l + r) / 2;
		if (check(mid)){
			ans = mid; 
			l = mid + 1;
		} else r = mid-1;
	}
	printf("%d", ans);
	
	return 0;
} 

Measured memory_bytes: 1536
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;
    int k = readint;
    int x = readint;
    int y = readint;

    int ans = min(n, k) * x + max(0, n - k) * y;
    writeln(ans);
}


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;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    string S;
    cin>>S;
    int n=S.size();
    cout<<S;
    if(S[n-1]=='s') cout<<"es";
    else cout<<"s";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];
    ll res = 1, p = 0;
    REP(i, n - 1){
        ll d = a[i + 1] - a[i];
        if(d * p < 0){
            res++;
            p = 0;
            continue;
        }
        if(d != 0) p = d;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

ll N;
const int MOD = 1.0e9 + 7;

ll pow_mod(ll n, ll k, ll mod) {
    if (k == 0) return 1;
    else if (k % 2 == 1) {
        return pow_mod(n, k-1, mod) * n % mod;
    }
    else {
        ll tmp = pow_mod(n, k/2, mod);
        return tmp * tmp % mod;
    }
}

ll neg_mod(ll n, ll mod)  {
    ll res = n % mod;
    if (res < 0) res += mod;
    return res;
}

int main() {
    cin >> N;

    ll ans = pow_mod(10, N, MOD);
    ans = neg_mod(ans - pow_mod(9, N, MOD), MOD);
    ans = neg_mod(ans - pow_mod(9, N, MOD), MOD);
    ans = (ans + pow_mod(8, N, MOD)) % MOD;
    
    cout << ans << endl;

    return 0; 
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

int calc(int a,int b){
  if(b == 0) return 1;
  if(b%2 == 0){
    int d = calc(a,b/2);
    return (d*d)%MOD;
  }
  return (a*calc(a,b-1))%MOD;
}

int comb(int n,int r){
  int tmp = 1,ttmp = 1;
  for(int i = n;i >= n-r+1;i--) tmp = (tmp*i)%MOD;
  for(int i = 1;i <= r;i++) ttmp = (ttmp*i)%MOD;
  return (tmp*calc(ttmp,MOD-2))%MOD;
}

signed main() {
  int X, Y;
  cin >> X >> Y;

  int i = 1;
  while(i <= X){
    int j = i*2;
    if(X-i == j-Y){
      cout << comb(i, X-i) << endl;
      return 0;
    }

    i++;
  }

  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<set>
#include<queue>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll m = (1e+9) + 7;

int main() {
	int n, tmp, count = 0;
	cin >> n;
	vector<int> a(n), ans(n, -1);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (i > n / 2 - 1) {
			ans[i] = a[i];
			count += a[i];
		}
	}
	for (int i = n / 2 - 1; i >= 0; --i) {
		tmp = ans[n / (i + 1) * (i + 1) - 1];
		for (int j = n / (i + 1) - 1; j > 0; --j) {
			if (ans[(i + 1) * j - 1] == -1) {
				ans[(i + 1) * j - 1] = tmp ^ a[i];
				count += ans[(i + 1) * j - 1];
			}
			tmp ^= ans[(i + 1) * j - 1];
		}
	}
	cout << count << endl;
	for (int i = 0; i < n; ++i) {
		if (ans[i] == 1) {
			if (i == n - 1) cout << i + 1 << endl;
			else cout << i + 1 << " ";
		}
	}
	return 0;
}

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

#include <atcoder/all>
typedef long long lint;
using namespace std;
using namespace atcoder;

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

lint convert(lint cost) {
    lint big = 1e10;
    return big - cost;
}

int main() {
    cin >> n >> k;
    a.assign(n, vector<lint>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    mcf_graph<lint, lint> g(2 * n + 2);
    int source = 2 * n;
    int sink = 2 * n + 1;
    g.add_edge(source, sink, n * k, convert(0));
    // row
    for (int i = 0; i < n; i++) {
        g.add_edge(source, i, k, 0);
    }
    // column
    for (int i = 0; i < n; i++) {
        g.add_edge(i + n, sink, k, 0);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            g.add_edge(i, j + n, 1, convert(a[i][j]));
        }
    }
    g.flow(source, sink, n * k);
    vector<string> ans(n, string(n, '.'));
    lint score = 0;
    auto edges = g.edges();
    for (auto e : edges) {
        if (e.from == source || e.to == sink) {
            continue;
        }
        int row = e.from;
        int column = e.to - n;
        if (e.flow != 1) {
            continue;
        }
        ans[row][column] = 'X';
        score += a[row][column];
    }
    cout << score << endl;
    for (auto e : ans) {
        cout << e << endl;
    }
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct RURM {
	using t1 = int;
	using t2 = int;
	static t1 id1() { return INT_MAX; }
	static t2 id2() { return -1; }
	static t1 op1(const t1& l, const t1& r) { return min(l, r); }
	static t1 op2(const t1& l, const t2& r) { return r != id2() ? r : l; }
	static t2 op3(const t2& l, const t2& r) { return r != id2() ? r : l; }
};

template <typename M>
class node {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
public:
	T1 val;
	T2 lazy;
	node<M> *l, *r;
	node() {}
	void init(T1 val_, T2 lazy_, node<M>* l_ = nullptr, node<M>* r_ = nullptr) {
		val = val_;
		lazy = lazy_;
		l = l_;
		r = r_;
	}
};

template <typename M>
class SaikyoSegmentTree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const ll n;
	vector<node<M>*> root;
	vector<node<M>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<M> *new_node() {
		pool[it].init(M::id1(), M::id2());
		return &pool[it++];
	}
	node<M> *fix(node<M> *t) {
		pool[it] = *t;
		return &pool[it++];
	}
	node<M> *push(node<M> *t, ll lb, ll ub) {
		t = fix(t);
		if (lb + 1 < ub) {
			if (t->l == nullptr) t->l = new_node();
			else t->l = fix(t->l);
			if (t->r == nullptr) t->r = new_node();
			else t->r = fix(t->r);
			t->l->lazy = M::op3(t->l->lazy, t->lazy);
			t->r->lazy = M::op3(t->r->lazy, t->lazy);
		}
		t->val = M::op2(t->val, t->lazy);
		t->lazy = M::id2();
		return t;
	}
	node<M> *suc(ll l, ll r, node<M> *t, ll lb, ll ub, T2 val) {
		if (ub <= l || r <= lb) return t;
		if (t == nullptr) t = new_node();
		if (l <= lb && ub <= r) {
			t->lazy = M::op3(t->lazy, val);
			return t;
		}
		t = push(t, lb, ub);
		t->l = suc(l, r, t->l, lb, (lb + ub) / 2, val);
		t->r = suc(l, r, t->r, (lb + ub) / 2, ub, val);
		t->val = M::op1(t->l == nullptr ? M::id1() : M::op2(t->l->val, t->l->lazy), t->r == nullptr ? M::id1() : M::op2(t->r->val, t->r->lazy));
		return t;
	}
	node<M> *sub(ll l, ll r, node<M> *t, ll lb, ll ub, T1& res) {
		if (t == nullptr || ub <= l || r <= lb) return t;
		if (l <= lb && ub <= r) {
			res = M::op1(res, M::op2(t->val, t->lazy));
			return t;
		}
		t = push(t, lb, ub);
		t->l = sub(l, r, t->l, lb, (lb + ub) / 2, res);
		t->r = sub(l, r, t->r, (lb + ub) / 2, ub, res);
		return t;
	}
public:
	SaikyoSegmentTree(ll n_, int PMAX = 1e7)
		: n(size(n_)), root(1, nullptr), pool(PMAX), it(0) {}
	void update(ll l, ll r, T2 val, int rt = -1) {
		if (rt == -1) rt = root.size() - 1;
		assert(0 <= rt && rt < (int)root.size());
		root.push_back(suc(l, r + 1, root[rt], 0, n, val));
	}
	T1 find(ll l, ll r, int rt = -1) {
		if (rt == -1) rt = root.size() - 1;
		assert(0 <= rt && rt < (int)root.size());
		T1 res = M::id1();
		root.push_back(sub(l, r + 1, root[rt], 0, n, res));
		return res;
	}
	int getversion() {
		return root.size() - 1;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	SaikyoSegmentTree<RURM> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}

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

using namespace std;

int a, b, x;

const double epsilon = 0.00000001D;
const double pi = 3.14159265D;

double V;

bool spill(double alfa)
{
    double beta = 90.0D - alfa;
    double c = alfa;
    double lat = a / tan(beta * pi / 180.0D);
    double volum = lat * a * a /* * sqrt(2.0D)*/ / 2.0D;
    double ramas = (b - lat) * a * a;

    if(lat < b)
    {
        //cout << alfa << "\n";
        //cout << fixed << setprecision(10) << lat << " " << ramas << " " << volum << "\n";

        return (x > ramas + volum);
    }

    lat = b / tan(alfa * pi / 180.0D);
    volum = lat * b * a / 2.0D;

    return (x > volum);
}

double cautBin()
{
    double i = 0;
    double pas = 1 << 6;
    while(pas > epsilon)
    {
        if(i + pas < 90.0D && spill(i + pas) == 0)
            i += pas;

        pas = pas / 2.0D;
    }

    return i;
}

int main()
{
    cin >> a >> b >> x;

    //cout << spill(45.0D) << "\n";


    cout << fixed << setprecision(10) << cautBin() << "\n";

    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  if(a == b && b == c) cnt = 1;
  else if(a != b && b != c && a != c) cnt = 3;
  else cnt = 2;
  cout << cnt << endl;
}

Measured memory_bytes: 3600
N,K = gets.split.map(&:to_i)
ss = []
maxd = {}
N.times{
  t,d = gets.split.map(&:to_i)
  ss << [d,t]
  maxd[t] = [maxd[t] || 0, d].max
}
#p tc
ss.sort!.reverse!
score = 0
tu = {}
ss[0...K].each{ |d,t| score += d; tu[t] = (tu[t] || 0) + 1 }
x = tu.keys.size
score += x ** 2
ans = score
unused = maxd.keys.reject{ |t| tu[t] }.map{ |t| maxd[t] }.sort

#p tc.keys, ss
(0...K).reverse_each{ |i|
  break if unused.size == 0
  d,t = ss[i]
  next if tu[t] <= 1
  a = unused.pop
  x += 1
  score = score - d + a + x**2 - (x-1)**2
  ans = score > ans ? score : ans
  tu[t] -= 1
}
p ans


Measured memory_bytes: 22256
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,H;

int fa[maxn],vi[maxn],Is[maxn],deg[maxn];

int find(int i){return fa[i]==i?i:fa[i]=find(fa[i]);}

void Work(){
	REP(i,0,H)if(deg[i]<0)return void(puts("NO"));
	REP(i,H,H*2)if(deg[i]>0)return void(puts("NO"));
	REP(i,0,H*2)if(deg[i])Is[find(i)]=1;
	REP(i,1,n)if(find(i)==i&&vi[i]&&!Is[i])return void(puts("NO"));
	puts("YES");
}

void Init(){
	read(n,H);
	REP(i,0,H*2)fa[i]=i;
	REP(i,1,n){
		int a,b,c,d;
		read(a,b,c,d);
		int x,y;
		x=c==0?-a:c;
		y=d==0?b:-d;
		x+=H;y+=H;
		deg[x]++;deg[y]--;
		fa[find(x)]=find(y);
		vi[x]=vi[y]=1;
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;  //これで"std::cout"が"cout"と書ける

//MACRO
typedef long long ll;                  //64bit以上を表現可能な型
#define INF 100000000                  //ほぼ無限
#define itn int                        //タイポ対策
#define all(x) (x).begin(), (x).end()  //sort(all(x))などとする
#define SZ(x) ((int)(x).size())        //size()簡略化
//repetition
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define repR(i, n) for (int i = n; i >= 0; i--)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;
template <class T>
bool chMAX(T &a, const T &b) {  //aよりbが大きければaに代入
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chMIN(T &a, const T &b) {  //aよりbが小さければaに代入
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

//
//
//

int main() {
    int h, w;
    cin >> h >> w;
    string a[h];

    rep(i, h) {
        cin >> a[i];
    }

    rep(i, w + 2) {
        cout << "#";
    }
    cout << endl;
    rep(i, h) {
        cout << "#" << a[i] << "#";
        cout << endl;
    }

    rep(i, w + 2) {
        cout << "#";
    }
    cout << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		String s = sc.next();
		String[] strs = s.split("");
		String before = "first";
		int count = 0;

		for (String str : strs) {
			if (!str.equals(before)) {
				count += 1;
				before = str;
			}
		}

		System.out.println(count);
	}

}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

/**
 *  約数を列挙する
 */
template<typename T>
std::vector<T> divisor(T n, bool sort = true) {
    std::vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    if(sort) std::sort(ret.begin(), ret.end());
    return ret;
}

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

    int N, M;
    std::cin >> N >> M;

    auto div_list = divisor(M, false);
    RSORT(div_list);
    for(const auto& v : div_list) {
        if(v <= M / N) {
            std::cout << v << std::endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, x;
    scl(n);
    vector<ll> v;
    for (int i = 0; i < n; i++)
    {
        scl(x);
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    ll y, z;
    ll cnt = 0;
    for (int i = 0; i < n - 2; i++)
    {
        x = v[i];
        for (int j = i + 1; j < n - 1; j++)
        {
            y = v[j];
            if (y > x)
            {
                for (int k = j + 1; k < n; k++)
                {
                    z = v[k];
                    if (z > y && z < x + y)
                    {
                        cnt++;
                    }
                }
            }
        }
    }
    pcl(cnt);
    return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(ll i = ll(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

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>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const long long INF = 1LL << 60;

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<ll>());
// 昇順ソート
// std::sort(data.begin(),data.end());

// vector型の「data」に xが存在するかを、True or Falseで返す
// vector_finder(data, x)
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

// ここから開始だよ！
ll N, T, A;
std::vector<ll> v;

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了
	
  cin >> N;
  cin >> T >> A;
  rep(i, N) {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  
  ll ans = -1;
  double doc = INF;
  rep(i, N) {
    double tmp;
    tmp = T - (v[i] * 0.006);
    tmp = abs(A-tmp);
    if (doc > tmp || doc == INF) {
      doc = tmp;
      ans = i;
    }
  }
  
  cout << ans+1 << endl;
	
	return 0;
}


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

bool isF1and0(string s){
    if(s[0]!='1') return false;
    bool result=true;
    repi(i,1,s.size()){
        if(s[i]!='0'){
            result=false;
            break;
        }
    }
    return result;
}

int main(){
    string N;
    cin >> N;
    if(isF1and0(N)){
        cout << 10 << endl;
    }else{
        int result = 0;
        rep(i,N.size()){
            result+=((int)N[i]-(int)'0');
        }
        cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
	int ans = 0;
	string s;
	cin >> s;
 
	for (int i = 0; i < s.size()-1; i++) {
		
		if (s[i] != s[i + 1]) {
			ans++;
				
		}
	}
	cout << ans<< endl;
	
 
 
	return 0;
 
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int i = n;
		for (; i <= 999; i++) {
			int a = i / 100;
			int b = (i / 10) % 10;
			int c = i % 10;
			
			if (a == b && b == c && c == a) break;
		}
		
		System.out.println(i);
		
		sc.close();
	}
}




Measured memory_bytes: 27108
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
ll dp[105][2]; 
// dp[a][b]:= 左から a bitまで見て 
// K以下が b=0:確定していない b=1確定している
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    rep(i,105)dp[i][0] = dp[i][1] = -1;
    dp[50][0] = 0;
    for(int bit=49;bit>=0;bit--){ // bit bit 目を考える
        ll mask = (1LL<<bit);
        ll num = 0; // bit bit 目が立っている A[i] の個数
        rep(i,N)if(A[i]&mask)num++; // もしもbitが立っていたらnumを加算

        if(dp[bit+1][1]>=0)chmax(dp[bit][1],dp[bit+1][1] + mask*max(num,N-num));
        if(dp[bit+1][0]>=0){
            if(K&mask){
                // もしも K の bit bit 目が 1 だったならば
                // 1を選んだ場合
                dp[bit][0] = dp[bit+1][0] + mask*(N-num);
                // 0を選んだ場合
                chmax(dp[bit][1],dp[bit+1][0] + mask*num);
            }else{
                dp[bit][0] = dp[bit+1][0] + mask*num; 
            }
        }
    }
    cout << max(dp[0][0],dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cassert>
#include <queue>

#define INF 922337203685477580
typedef long long ll;

using namespace std;

typedef struct {
  char type;
  ll value;
} Card;

int partition(Card *A, int p, int r) {
  ll x = A[r].value;
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j].value <= x) {
      i++;
      Card a = A[i];
      A[i] = A[j];
      A[j] = a;
    }
  }
  Card a = A[r];
  A[r] = A[i + 1];
  A[i + 1] = a;

  return i + 1;
}

void quickSort(Card *A, int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

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

  Card A[n];
  Card B[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i].type >> A[i].value;
  }
  for (int i = 0; i < n; i++) {
    B[i].type = A[i].type;
    B[i].value = A[i].value * 1000000000 + i;
  }

  quickSort(A, 0, n - 1);
  quickSort(B, 0, n - 1);

  int isStable = 1;
  for (int i = 0; i < n; i++) {
    if (A[i].type != B[i].type) {
      isStable = 0;
      break;
    }
  }
  if (isStable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  for (int i = 0; i < n; i++) {
    // cout << A[i].type << " " << A[i].value << " | " << B[i].type << B[i].value <<  endl;
    cout << A[i].type << " " << A[i].value << endl;
  }
  return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	string s, t;
	cin >> s >> t;
	int a = s.size(), b = t.size();
	if(b > a) {
		cout << "UNRESTORABLE" <<  endl;
		return 0;
	}
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	bool valid = true;
	for(int i = 0; i <= a - b; i++) {
		valid = true;
		for(int j = i; j < i + b; j++) {
			if(s[j] == t[j - i]) {
				continue;
			}
			else {
				if(s[j] == '?') {
					continue;
				}
				else {
					valid = false;
				}
			}
		}
		if(valid) {
			for(int j = i; j < i + b; j++) {
				s[j] = t[j - i];
			}
			for(int i = 0; i < a; i++) {
				if(s[i] == '?') {
					s[i] = 'a';
				}
			}
			break;
		}
	}
	if(!valid) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for(int i = a - 1; i >= 0; i--) {
		cout << s[i];
	}
	cout << endl;
	return 0;	
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
p = LF()

dp = [[0.0]*(N+1) for i in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(N):
        dp[i+1][j+1] += dp[i][j]*p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])

print(sum(dp[N][N//2+1:]))

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

using namespace std;

//#define FILE_IO

int N, M;
int f[100005];
vector <int> edg[100005];
vector <int> path;

void go(int nod)
{
    if(f[nod])  return;
    f[nod] = 1;
    path.push_back(nod);
    for(auto x: edg[nod])
        if(!f[x])
        {
            go(x);
            return;
        }
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &M);
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        edg[x].push_back(y);
        edg[y].push_back(x);
    }

    go(1);
    reverse(path.begin(), path.end()); path.pop_back(); f[1] = 0;
    go(1);

    printf("%d\n", path.size());
    for(auto x: path)
        printf("%d ", x);

    return 0;
}


Measured memory_bytes: 9976
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 9;

int n, q, t, i;
ll s[N], ans[N], f[N] , j, k;

int main () {
	scanf("%d%d", &n, &q);
	s[t = 1] = n;
	for (i = 1; i <= q; ++i) {
		scanf("%lld", &j);
		while (t && j <= s[t]) --t; s[++t] = j;
	}
	f[t] = 1;
	for (i = t; i > 0; --i) {
		k = s[i], j = i;
		while ((j = lower_bound(s + 1, s + j + 1, k) - s - 1) > 0) {
			f[j] += k / s[j] * f[i];
			k %= s[j];
		}
//		ans[n] += k / n * f[i];
//		ans[k % n] += f[i];
		ans[k] += f[i];
	}
	for (i = n - 1; i; --i) ans[i] += ans[i + 1];
	for (i = 1; i <= n; ++i) printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>

using namespace std;


int main(){

   // freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);

    int k;
    string str;
    cin >> k;
    cin>>str;

    if(str.length()<= k){
        cout<<str;
    }else{
        for (int i = 0; i < k; i++)
        {
            cout<<str[i];
        }
        cout<<"...";
    }
    
    return 0;
}

Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
int w[N];
signed main(){
  fast;
  int n,diff=inf,sum=0,s=0;
  cin>>n;
  for(int i=0;i<n;i++) cin>>w[i] , sum+=w[i];
  for(int i=0;i<n;i++) s+=w[i], diff=min(diff , abs(2*s - sum));
  cout<<diff<<endl;
}
  


Measured memory_bytes: 384
n = int(input())
s = input()
ans = 10**9
l = 0
r = 0
L = [0]
R = [0]
for i in range(n - 1):
    l += s[i].count('W')
    r += s[-i - 1].count('E')
    L.append(l)
    R.append(r)
for l, r in zip(L, R[::-1]):
    ans = min(ans, l + r)
print(ans)

Measured memory_bytes: 29508
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


n,k=map(int, input().split()) 
for i in range(1,k+1):
    if  i > n-k+1:
        print(0)
    else:
        print(cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod)%mod)
    

Measured memory_bytes: 4596
import java.util.Scanner;

//Is it Convex?
public class Main{

	static class Point {
		public double x;
		public double y;
		public Point(double x_, double y_) {
			x = x_; y=y_;
		}
		public String toString() {return "(" +x+", "+ y +")";}
	}
	
	static double extp(Point p1, Point p2) {
		return p1.x*p2.y - p2.x*p1.y;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String[] s = sc.next().split(",");
			Point[] p = new Point[4];
			for(int i=0;i<4;i++)p[i]=new Point(Double.parseDouble(s[i*2]),Double.parseDouble(s[i*2+1]));
			boolean l = true;
			boolean r = true;
			for(int i=0;i<4;i++){
				double dx = p[(i+1)%4].x-p[i].x;
				double dy = p[(i+1)%4].y-p[i].y;
				for(int j=0;j<4;j++){
					if(j==i||j==(i+1)%4)continue;
					double dx2 = p[j].x-p[i].x;
					double dy2 = p[j].y-p[i].y;
					double ex = extp(new Point(dx, dy), new Point(dx2, dy2));
					if(ex>0)r=false;
					else l=false;
				}
			}
			System.out.println(l||r?"YES":"NO");
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,q; cin >> n >> q;
  string s; cin >> s;
  vi t(n+1);
  rep(i, n){
    if(s[i] == 'A' && s[i+1] == 'C') t[i+1] = t[i] + 1;
    else t[i+1] = t[i];
  }

  vi l(q), r(q);
  rep(i, q){
    cin >> l[i] >> r[i];
    l[i]--;r[i]--;
  }

  rep(i, q){
    std::cout << t[r[i]]-t[l[i]] << '\n';
  }

}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var k = IO.ReadInt;
            var s = ReadLine();

            if (s.Length <= k)
            {
                WriteLine(s);
            }
            else
            {
                var st = s.Substring(0, k);
                st += "...";
                WriteLine(st);
            }
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
 
int main() {  
  int n, t;
  cin >> n>> t;
    vector<int> A(n), B(n);
    for (int i = 0; i < n; i++) {
        cin >> A.at(i) >> B.at(i);
    }
  int kotae=1001;
    for (int j = 0; j < n; j++) {
if (t>=B.at(j) && kotae>A.at(j)){kotae=A.at(j);}
    }
 
 
 
    if (kotae<1001) {
        cout << kotae << endl;
    }
    else {
        cout << "TLE" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    int a,b,c;
    int x=0,y=0,z=0,w=0;
    while(cin >> a >> b >> c){
        int l = max({a,b,c});
        int s = min({a,b,c});
        int m = a+b+c-l-s;
        if(s+m>l){
            x++;
            if(s*s+m*m==l*l) y++;
            if(s*s+m*m>l*l) z++;
            if(s*s+m*m<l*l) w++;
        }else{
            break;
        }
    }
    cout << x << ' ' << y << ' ' << z << ' ' << w << endl;
}


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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            //string n;
            //n = Console.ReadLine();
            //if (n[0] == '9' || n[1] == '9')
            //    Console.WriteLine("Yes");
            //else
            //    Console.WriteLine("No");
            //Console.ReadKey();
            int n;
            n = int.Parse(Console.ReadLine());
            if (n % 10 == 9 || n / 10 == 9)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
	public static void main(String[] args)
			throws java.io.IOException{
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
		float v = scan.nextFloat();
		double t = v / 9.8;
		double y = 4.9 * Math.pow(t,2);
		int i=1;
		while(true){
			if(5*(i-1)>=y){System.out.println(i);break;}
			i++;
		}
	}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


template<class Int> V<Int> sieve(Int a, Int b) {
  a = max<Int>(2, a); V<Int> res; Int q = ceil(sqrt(b));
  V<bool> mem(b - a, true), sub(q - 2, true);
  for (Int i = 2; i < q; ++i) {
    if (sub[i - 2]) {
      for (Int j = max(i, (a + i - 1) / i) * i; j < b; j += i) mem[j - a] = false;
      for (Int j = i * i; j < q; j += i) sub[j - 2] = false;
    }
  }
  for (Int i = a; i < b; ++i) if (mem[i - a]) res.push_back(i);
  return res;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  auto ps = sieve(2, 2154);
  for (int i = 0; i < n; ++i) {
    for (lint p : ps) {
      while (a[i] % (p * p * p) == 0) {
        a[i] /= p * p * p;
      }
    }
  }
  int res = 0;
  map<lint, int> mp;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) {
      res = max(res, 1);
    } else {
      ++mp[a[i]];
    }
  }
  for (const auto& e : mp) {
    lint a = e.first, b = 1;
    for (lint p : ps) {
      if (a % p == 0) {
        a /= p;
        b *= p;
        if (a % p == 0) {
          a /= p;
        } else {
          b *= p;
        }
      }
    }
    if (a > 1) {
      lint m = sqrt(a);
      if (m * m == a) {
        b *= m;
      } else {
        b *= a * a;
      }
    }
    if (!mp.count(b)) {
      res += e.second;
    } else if (e.first < b) {
      res += max(e.second, mp[b]);
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define INF (ll)1e18
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
    int a;
    in(a);
    out(a*(a+1)/2);
}























Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int count[26]={0};
  char s;
  while(cin >> s){
    int num=s-'a';
    for(char i='a';i<='z';i++)if(s==i)count[num]++;
  }
  bool g=true;
  for(int i=0;i<26;i++){
    if(count[i]%2!=0){
      g=false;
      break;
    }
  }
  if(g)cout << "Yes" << endl;
  else cout << "No"  << endl;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
)

func gcd(a, b int) int {
	for b != 0 {
		r := a % b
		a = b
		b = r
	}
	return a
}

func main() {
	var k int
	fmt.Scan(&k)

	sum := 0
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				g1 := gcd(a, b)
				g2 := gcd(g1, c)
				sum += g2
			}
		}
	}

	fmt.Println(sum)
}

Measured memory_bytes: 1776
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	int pm,pe,pj;
	while(n=in()){
		int i;
		for(i=0;i<n;i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||pj==100||pm+pe>=180||pm+pe+pj>=240){
				cout<<"A"<<endl;
			}else if(pm+pe+pj>=210||(pm+pe+pj>=150&&(pm>=80||pe>=80))){
				cout<<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0