akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(ll X) {
	int keta = 0;
	char C[11];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

ll facN, facK;
int A[100001];
ll fac[100001];

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


	int N = getint();
	int kazu = 0;
	rep1(i, N) {
		int a = getint();
		if (A[a]) kazu = A[a] + N - i;
		else A[a] = i;
	}

	fac[0] = 1;
	rep1(i, N + 1) fac[i] = fac[i - 1] * i % mod;
	facN = fac[N + 1];
	facK = fac[kazu];
	fac[N + 1] = modpow(fac[N + 1], mod - 2);
	for (int i = N + 1; i > 0; i--) fac[i - 1] = fac[i] * i % mod;


	rep1(i, N + 1) {
		ll kotae = fac[i] * fac[N + 1 - i] % mod * facN;
		if (kazu >= i - 1) {
			kotae = kotae - fac[i - 1] * fac[kazu - i + 1] % mod * facK;
		}
		kotae %= mod;
		if (kotae < 0) kotae += mod;
		putint(kotae);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

int main(void) {
	int n, h, s_h = 0, count = 0;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%d", &h);
		if (s_h <= h) {
			s_h = h;
			count++;
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

llint modpow(llint a, llint n) {
    if(n==0) return 1LL;
    if(n%2==1) return a*modpow(a, n-1)%MOD;

    llint t;
    t = modpow(a, n/2);
    return t*t%MOD;
}

int main(void) {
    llint n, k;
    cin >> n >> k;

    llint ans = 0, tmp;
    vector<llint> res(k);
    for(llint ik=k;ik>=1;ik--) {
        tmp = modpow(k/ik, n);
        llint jk = ik;
        while(1) {
            jk += ik;
            if(jk>k) break;
            tmp -= res[jk-1];
            if(tmp<0) tmp += MOD;
        }
        res[ik-1] = tmp;
        ans += ik * res[ik-1];
        ans %= MOD;
    }

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


Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

#define fst first
#define snd second
#define all(c) ((c).begin()), ((c).end())

const long long INF = (1ll << 50);
struct graph {
	typedef long long flow_type;
	struct edge {
		int src, dst;
		flow_type capacity, flow;
		size_t rev;
	};
	int n;
	vector<vector<edge>> adj;
	graph(int n) : n(n), adj(n) { }
	void add_edge(int src, int dst, flow_type capacity) {
		adj[src].push_back({ src, dst, capacity, 0, adj[dst].size() });
		adj[dst].push_back({ dst, src, 0, 0, adj[src].size() - 1 });
	}
	flow_type max_flow(int s, int t) {
		vector<int> level(n), iter(n);
		function<int(void)> levelize = [&]() { // foward levelize
			level.assign(n, -1); level[s] = 0;
			queue<int> Q; Q.push(s);
			while (!Q.empty()) {
				int u = Q.front(); Q.pop();
				if (u == t) break;
				for (auto &e : adj[u]) {
					if (e.capacity > e.flow && level[e.dst] < 0) {
						Q.push(e.dst);
						level[e.dst] = level[u] + 1;
					}
				}
			}
			return level[t];
		};
		function<flow_type(int, flow_type)> augment = [&](int u, flow_type cur) {
			if (u == t) return cur;
			for (int &i = iter[u]; i < adj[u].size(); ++i) {
				edge &e = adj[u][i], &r = adj[e.dst][e.rev];
				if (e.capacity > e.flow && level[u] < level[e.dst]) {
					flow_type f = augment(e.dst, min(cur, e.capacity - e.flow));
					if (f > 0) {
						e.flow += f;
						r.flow -= f;
						return f;
					}
				}
			}
			return flow_type(0);
		};
		for (int u = 0; u < n; ++u) // initialize
			for (auto &e : adj[u]) e.flow = 0;

		flow_type flow = 0;
		while (levelize() >= 0) {
			fill(all(iter), 0);
			for (flow_type f; (f = augment(s, INF)) > 0; )
				flow += f;
		}
		return flow;
	}
};

int main() {
	cin >> N;
	vector<pair<ll,ll>> rb(2*N);
	for (int i = 0; i < 2 * N; i++) {
		cin >> A >> B;
		rb[i] = { A,B };
	}
	graph g(2 * N+2);
	for (int i = 0; i < N; i++) {
		for (int j = N; j < 2 * N; j++) {
			if (rb[i].first < rb[j].first&&rb[i].second < rb[j].second) {
				g.add_edge(i, j, 1);
			}
		}
	}
	for (int i = 0; i < 2 * N; i++) {
		if(i<N)g.add_edge(2 * N, i, 1);
		else  g.add_edge(i, 2 * N + 1, 1);
	}
	cout << g.max_flow(2*N, 2 * N + 1) << endl;
}

Measured memory_bytes: 512
mod = 10 ** 9 + 7

n, k = map(int, input().split())
otv = 0
D = [0] * (k + 1)
for i in range(1, k + 1):
    D[i] = pow(k // i, n, mod)

for i in range(k // 2, 0, -1):
    for j in range(i * 2, k + 1, i):
        D[i] -= D[j]

for i in range(1, k + 1):
    otv = (otv + D[i] * i) % mod

print(otv)

Measured memory_bytes: 11468
#include<stdio.h>

int main(){

    int A, B;
    scanf("%d%d", &A, &B);

    if(A+B == 3){
        printf("3\n");
    }else if(A+B == 4){
        printf("2\n");
    }else if(A+B == 5){
        printf("1\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1]&&s[2] == s[3]&&s[0]!=s[2]) {
		cout << "Yes";
	}
	else if (s[0] == s[2] && s[1] == s[3]&&s[0]!=s[1]) {
		cout << "Yes";
	}
	else if (s[0] == s[3] && s[1] == s[2]&&s[0]!=s[1]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int inf = 2147483647;
const int N = 81, M = 101, K = 321;
const int H = 2 * (M + N);

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I LL read() {
	LL x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

struct edge {
	int x, y, c; LL d; int next;
} e[1000001]; int len, last[H];
struct node {int x, y; LL t;} a[K], b[N];
int lx[101], rx[101], ly[101], ry[101];
int st, ed, pre[H]; LL d[H];
int n, m; LL ans;
queue<int> q;
char ss[10];
bool v[H];

I void ins(cr x, cr y, cr c, LL d) {
	e[++len] = edge{x, y, c, d, last[x]}, last[x] = len;
	e[++len] = edge{y, x, 0, -d, last[y]}, last[y] = len;
}

I bool spfa() {
	q.push(st);
	memset(v, 0, sizeof(v)); v[st] = 1;
	memset(d, 63, sizeof(d)); d[st] = 0;
	while(!q.empty()) {
		reg x = q.front(); q.pop();
		for(reg k = last[x]; k; k = e[k].next) {
			reg y = e[k].y;
			if(d[y] > d[x] + e[k].d && e[k].c) {
				d[y] = d[x] + e[k].d, pre[y] = k;
				if(!v[y]) v[y] = 1, q.push(y);
			}
		} v[x] = 0;
	} if(d[ed] < 0) return 1;
	return 0;
}

I void Flow(cr k) {
	LL sum = 0; reg s = 0;
	while(spfa()) {
		sum += d[ed], s++;
		for(reg x = ed; x != st; x = e[pre[x]].x) e[pre[x]].c--, e[pre[x] ^ 1].c++;
	} if(k != s) return ;
	ans = max(ans, -sum);
}

I void solve(cr k) {
	len = 1, memset(last, 0, sizeof(last));
	st = 0, ed = 200 + 2 * k + 1;
	fo(i, 1, n) ins(b[i].x, b[i].y + 100, 1, -b[i].t);
	fo(i, 1, k) rx[i] = ry[i] = 100, lx[i] = ly[i] = 1;
	fo(i, 1, m) {
		if(a[i].t == 'L') lx[a[i].y + 1] = _max(lx[a[i].y + 1], a[i].x + 1);
		if(a[i].t == 'R' && k > a[i].y) rx[k - a[i].y] = _min(rx[k - a[i].y], a[i].x - 1);
		if(a[i].t == 'D') ly[a[i].y + 1] = _max(ly[a[i].y + 1], a[i].x + 1);
		if(a[i].t == 'U' && k > a[i].y) ry[k - a[i].y] = _min(ry[k - a[i].y], a[i].x - 1);
	} fo(i, 2, k) lx[i] = _max(lx[i], lx[i - 1]), ly[i] = _max(ly[i], ly[i - 1]);
	fd(i, k - 1, 1) rx[i] = _min(rx[i], rx[i + 1]), ry[i] = _min(ry[i], ry[i + 1]);
	fo(i, 1, k) {
		if(lx[i] > rx[i] || ly[i] > ry[i]) continue;
		ins(st, 200 + i, 1, 0), ins(200 + i + k, ed, 1, 0);
		fo(j, lx[i], rx[i]) ins(200 + i, j, 1, 0);
		fo(j, ly[i], ry[i]) ins(j + 100, 200 + i + k, 1, 0);
	} Flow(k);
}

int main() {
	n = read();
	fo(i, 1, n) b[i].x = read(), b[i].y = read(), b[i].t = read();
	m = read();
	fo(i, 1, m) scanf("%s", ss + 1), a[i].t = ss[1], a[i].x = read(), a[i].y = read();
	fo(i, 1, n) solve(i);
	pr2(ans);
	return 0;
}



Measured memory_bytes: 1024
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	string s;
	cin >> s;
	cout << (set<char>(s.begin(), s.end()).size() == s.size() ? "yes" : "no") << '\n';
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> x(n);
    REP (i, n) {
        cin >> x[i];
    }
    int64_t answer = INT64_MAX;
    REP (p, 101) {
        int64_t sum = 0;
        for (int x_i : x) {
            sum += (x_i - p) * (x_i - p);
        }
        answer = min(answer, sum);
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

int main() {
	ll n, k; cin >> n >> k;
	ll ans = k;
	Loop(i, n - 1) {
		ans *= k - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		StringBuilder all = new StringBuilder();
		StringBuilder out = new StringBuilder();
		
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if((h + w) <= 0){break;}
				for(int j = 0; j < h; j++){
					for(int i = 0; i < w; i++){
						out = out.append("#");
					}
					out = out.append("\n");
				}
			all = all.append(out + "\n");
			out.delete(0, out.length());
		}
	
		System.out.print(all);
	}
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

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

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*FUNCs=================================================*/
long long GCD(long long a, long long b){
    return (b ? GCD(b, a%b) : a);
}

// LCM == a*b/GCD(a,b)
/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    ll n, m; cin >> n >> m;
    vll a(n);
    rep(i,n) {
        cin >> a[i];
        a[i]/=2;
    }
    ll lcm = a[0];
    for(auto i : a) {
        lcm = lcm*i/GCD(lcm, i);
    }
    for(auto i : a) {
        if(lcm/i%2==0) {
            cout << 0 << '\n';
            return 0;
        }
    }
    cout << (m / lcm + 1)/ 2 <<'\n';
}

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

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

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int k;
    cin >> k;

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

    int ans = a[0] + a[1] + a[2] * pow(2, k);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		String S = next();
		char[] C = S.toCharArray();
		int cnt = 0;
		for(int i=0;i<1000;i++) {
			String s = String.valueOf(i);
			if(i < 100) {
				s = "0" + s;
				if(i < 10) {
					s = "0" + s;
				}
			}

			char[] c = s.toCharArray();
			int ci = 0;
			for(int j=0;j<N&&ci<3;j++) {
				if(c[ci] == C[j]) {
					ci++;
				}
			}
			if(ci == 3)cnt++;
		}
		out.println(cnt);

	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
#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, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Tree {
	using T = pair<ll, int>;
	int n;
	vector<vector<T>> edge;
	vector<ll> d;

public:
	Tree(int N) : n(N), edge(N), d(N, INT64_MAX) {}
	void add(int a, int b, ll c) {
		edge[a].emplace_back(c, b);
		edge[b].emplace_back(c, a);
	}
	void dijkstra(int k) {
		priority_queue<T, vector<T>, greater<T>> pq;
		pq.emplace(0, k);
		while (!pq.empty()) {
			ll c;
			int i;
			tie(c, i) = pq.top();
			pq.pop();
			if (c > d[i]) continue;
			d[i] = c;
			for (auto p : edge[i]) {
				ll x;
				int j;
				tie(x, j) = p;
				if (c + x < d[j]) {
					pq.emplace(c + x, j);
				}
			}
		}
	}
	ll distance(int i) {
		return d[i];
	}
};

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

	int N;
	cin >> N;
	Tree tree(N);
	REP(i, N - 1) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		--a;
		--b;
		tree.add(a, b, c);
	}
	int Q, K;
	cin >> Q >> K;
	--K;
	tree.dijkstra(K);
	REP(i, Q) {
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		cout << tree.distance(x) + tree.distance(y) << endl;
	}

	return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
int main(){
	int i,j,c=0,n;
	scanf("%d",&n);
	for(i=0;i<=25;i++){
		for(j=0;j<=14;j++){
			if(i*4 + j*7 == n){
				c++;
			}
		}
	}
	if(c==0){
		printf("No");
	}
	else{
		printf("Yes");
	}
}

Measured memory_bytes: 256
def main():
    W,a,b = map(int,input().split())
    L1, R1 = a,a+W
    L2, R2 = b,b+W
    if not( R2 < L1 or R1 < L2 ):
        print(0)
    elif R2 < L1:
        print(L1-R2)
    else:
        print(L2-R1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long lint;
using namespace std;
 
int main(){
  int a,b;
  cin>>a>>b;
  if(9<a||9<b){
    cout<<-1<<endl;
  }else{
    cout<<a*b<<endl;
  }
}

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

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

    ull n, a, b, i, j;
    cin>>n>>a>>b;
    i=a+b;
    j=n/i;
    j=j*a;
    i=n%i;
    if(i<=a) j=j+i;
    else j=j+a;
    cout<<j<<endl;

    return 0;
}



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

int main(){
	int n;cin>>n;
	if(__builtin_popcount(n)==1){
		puts("No");return 0;
	}
	puts("Yes");
	vector<P>v;
	int a[]{1+n,2,3,1,2+n,3+n};
	rep(i,5)v.push_back(P(a[i],a[i+1]));
	for(int i=4;i+1<=n;i+=2){
		v.push_back(P(i,i+1));
		v.push_back(P(i+1,1));
		v.push_back(P(1,n+i));
		v.push_back(P(n+i,n+i+1));
	}
	if(n%2==0){
		int x=n^(n-1)^1;
		v.push_back(P(n,n-1));
		if(x%2==0){
			v.push_back(P(x+n,n*2));
		}
		else{
			v.push_back(P(x,n*2));
		}
	}
	for(auto p:v){
		printf("%d %d\n",p.first,p.second);
	}
}

Measured memory_bytes: 3952
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

const int maxn = 100010;
typedef long long ll;
int n, e, t;
ll a[maxn], f[maxn];

int main(){
  scanf("%d%d%d", &n, &e, &t);
  for(int i = 1;i <= n;++i)scanf("%lld", &a[i]);
  memset(f, 0x3f, sizeof(f));f[0] = 0;
  ll mn = 0x3f3f3f3f3f3f3f3fLL;
  for(int i = 1, j = 0;i <= n;++i){
    while(j + 1 < i && t <= 2LL * (a[i] - a[j + 1])){
      mn = min(mn, f[j] - 2LL * a[j + 1]);
      j++;
    }
    if(t > 2LL * (a[i] - a[j + 1]))f[i] = f[j] + t;
    f[i] = min(f[i], 2LL * a[i] + mn);
    //  cout<<"for "<<i<<' '<<f[i]<<endl;
  }
  printf("%lld\n", f[n] + e);
  return 0;
}


Measured memory_bytes: 1792
#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

#define y0 y0ChloeGraceMoretz
#define y1 y1ChloeGraceMoretz
typedef long long ll;
int nextInt() { int n; scanf("%d", &n); return n; }
ll nextLong() { ll n; scanf("%lld", &n); return n; }
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;


char s[19];
int len;
ll res = 0;

void f(int pos, ll sum, ll cur) {
	if (pos == len) {
		res += sum + cur;
		return;
	}
	f(pos + 1, sum, cur * 10 + (s[pos] - '0'));
	f(pos + 1, sum + cur, (s[pos] - '0'));
}

int main() {
	//freopen("in.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	scanf("%s", s);
	len = strlen(s);
	f(1, (ll)0, (ll) (s[0] - '0'));
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long unsigned n;
	cin>>n;
	std::vector<long long unsigned> v;
	for(auto i=0;i<n;i++)
	{
		long long unsigned a;
		cin>>a;
		v.push_back(a);
		if(a==0)
		{
			cout<<0;
			return 0;
		}
	}

	long long unsigned ans=v[0];
	long long unsigned c=1e18;
	for (long long unsigned i=1;i<v.size();i++)
	{
		if(v[i]>c/ans) {
			cout<<-1;
			return 0;
		}
		ans*=v[i];

	}
	if(ans>0&&ans<=c)
		cout<<(long long int)ans;
	else cout<<-1;


	return 0;
}

Measured memory_bytes: 4248
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	ans = True
	for i,s in enumerate(S):
		if (i % 2 == 1 and s=='R') or (i % 2 == 0 and s=='L'):
			ans=False
	if(ans):
		print('Yes')
	else:
		print('No')

main()

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_2_D {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            List<int> A = new List<int>();
            for (int i = 0; i < n; i++) {
                A.Add(int.Parse(Console.ReadLine()));
            }

            ShellSort(A, n);
            StringBuilder sb = new StringBuilder();
            A.ForEach(a => sb.AppendLine(a.ToString()));
            Console.Write(sb);
        }

        static void ShellSort(List<int> A, int n) {
            int cnt = 0;
            List<int> G = new List<int>();
            for (int h = 1; h <= n; h = 3 * h + 1) {
                G.Insert(0, h);
            }

            foreach (var g in G) {
                cnt += InsertionSort(A, n, g);
            }

            Console.WriteLine(G.Count);
            Console.WriteLine(ListToString(G));
            Console.WriteLine(cnt);
        }

        static int InsertionSort(List<int> A, int n, int g) {
            int cnt = 0;
            for (int i = g; i < n; i++) {
                int v = A[i];
                int j = i - g;
                while (j >= 0 && A[j] > v) {
                    A[j + g] = A[j];
                    j -= g;
                    cnt++;
                }
                A[j + g] = v;
            }
            return cnt;
        }

        static string ListToString(List<int> nums) {
            StringBuilder sb = new StringBuilder();
            nums.ForEach(n => sb.Append(" " + n));
            return sb.ToString().TrimStart();
        }
    }
}

Measured memory_bytes: 94680
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  int s_water = 0, s_mass = 0;
  double n_max = 0.0;
  for (int i = 0; 100 * a * i <= f; i++) {
    int w1 = 100 * a * i;
    for (int j = 0; w1 + 100 * b * j <= f; j++) {
      int w = w1 + 100 * b * j;
      for (int k = 0; w + c * k <= f; k++) {
        int s1 = c * k;
        for (int l = 0; w + s1 + d * l <= f; l++) {
          int s = s1 + d * l;
          if (w * e < 100 * s) continue;

          double noudo = (double)(s) / (w + s) * 100;
          if (noudo >= n_max) {
            n_max = noudo;
            s_water = w + s;
            s_mass = s;
          }
        }
      }
    }
  }

  // 解答
  cout << s_water << " " << s_mass << endl;

  return 0;
}


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

int main() {
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  ll ans = 0;
  rep(i,t.size()){
    if(t[i]=='r') ans += p;
    if(t[i]== 's') ans += r;
    if(t[i]== 'p') ans += s;
  }
  for (int i = k; i < t.size(); i++){
    if (t[i] == t[i - k]){
      if(t[i]=='r') ans -= p;
      if(t[i]== 's') ans -= r;
      if(t[i]== 'p') ans -= s;
      t[i] = 'n';
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<cstdio>
using namespace std;
int main(){
    char ch,ci;
    while(1){
        scanf("%c",&ch);
        if(ch=='\n')break;
        if(islower(ch)){
            ci = toupper(ch);
            cout << ci;
        }
        else if(isupper(ch)){
            ci = tolower(ch);
            cout << ci;
        }
        else if(ch==','){
            cout << ',';
        }
        else if(ch==' '){
            cout << ' ';
        }
        else if(ch=='.'){
            cout << '.';
        }
        else{
            cout << ch;
        }
        
    }
    cout << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  if (a == b && b == c) cout << 1 << endl;
  else if (a != b && b != c && c != a) cout << 3 << endl;
  else cout << 2 << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input()
    # 後ろから貪欲に評価すればよい
    while True:
        if S[-5:] == "dream" or S[-5:] == "erase":
            S = S[:-5]
            continue
        elif S[-6:] == "eraser":
            S = S[:-6]
            continue
        elif S[-7:] == "dreamer":
            S = S[:-7]
            continue
        else:
            break
    if S == "":
        print("YES")
    else:
        print("NO")
    return


if __name__ == "__main__":
    main()


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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {

  
  string s;
  cin >> s;
  
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;

}

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

using namespace std;
using ll = long long;

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

	if (X > Y) { cout << ">" << endl; }
	if (X < Y) { cout << "<" << endl; }
	if (X == Y) { cout << "=" << endl; }

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int xx;
const ll N=1e7+7;
ll A[N];
vector<ll> v;
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

int main()
{
    sieve();
   ll a,b,cnt=0;
   cin>>a>>b;
   ll d=__gcd(max(a,b),min(a,b));
   for(ll i=0;v[i]<=sqrt(d);i++)
   {
       if(d%v[i]==0)
       {
           while(d%v[i]==0)
             {
                 d/=v[i];
             }
           cnt++;
       }
   }
   if(d!=1)
   {
       cnt++;
   }
   cout<<cnt+1<<endl;
return 0;
}











Measured memory_bytes: 38528
import math


def solve_c(c):
    res = c - 1
    d = math.floor(math.sqrt(c))
    for a in range(2, d + 1):
        if c % a == 0:
            res = (a - 1) + (c // a - 1)
    return res


def main():
    # input
    c = int(input())
    res = solve_c(c)
    print(res)


def test():
    assert solve_c(10) == 5
    assert solve_c(50) == 13
    assert solve_c(10000000019) == 10000000018


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TEST int t = 1; while(t--) solve()
 
void solve(){
    int n; cin>>n;
    bool flag = false;
    while(n){
        if(n%10 == 7)
            flag = true;
        n /= 10;
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
 
signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST; return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define F(i,n) for (int i=1; i<=n; i++)
#define FF(i,n) for (int i=0; i<n; i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define re(x) (int)x.size()
#define pi pair < int , int >
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int N = 3e5+228;
const int big = 2e9;
int n,pr[N],sf[N];
string a;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
    cin>>n;
    cin>>a;
    F(i,n) {
        pr[i]=pr[i-1];
        if (a[i-1]=='W') pr[i]++;
    }
    for (int i=n; i>=1; i--){
        sf[i]=sf[i+1];
        if (a[i-1]=='E') sf[i]++;
    }
    int ans=2e9;
    F(i,n) ans=min(ans,pr[i-1]+sf[i+1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2964
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), m = next();
  return n*(n-1)/2+m*(m-1)/2;
}

Measured memory_bytes: 21064
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;
int n  , k ;
vi a ;
bool f(int x){
    int cnt = 0 ;
    int sm = 0 ;
    vi v ;
    for(int i = 0 ; i < n ; i++){
        int y = a[i] % x ;
        sm += y ;
        if(y) v.pb(y) ;
    }
    if(sm == 0) return 1 ;
    sort(all(v)) ;
    deque<int> Q ;
    for(int z : v) Q.pb(z) ;
    int mov = 0 ;
    while(!Q.empty()){
        if(sz(Q) == 1) return false ;
        int f = Q.front() ;
        int b = Q.back() ;
        int extra = min(f,x-b) ;
        Q.front() -= extra ;
        Q.back() += extra ;
        if(Q.front() == 0) Q.pop_front() ;
        if(Q.back() == x) Q.pop_back() ;
        mov += extra ;
    }
    return mov <= k ;
}

void solve(){
    cin >> n >> k ;
    int sm = 0 ;
    a.resize(n) ;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i] ;sm += a[i] ;
    }
    vi divs ;
    for(int i = 1 ; i*i <= sm ; i++){
        if(sm%i == 0){
            divs.pb(i) ;
            if(i*i != sm){
                divs.pb(sm/i) ;
            }
        }
    }
    sort(all(divs)) ;
    for(int i = sz(divs) -1 ; i >= 0 ; i--){
        if(f(divs[i])){
            cout << divs[i] << endl ;
            return ;
        }
    }

}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 256
while gets
	a=$_.split.map(&:to_i)
	b=gets.split.map(&:to_i)
	c,d=0,0;
	4.times do |i|
		if a[i]==b[i] then
			c+=1
		else
			4.times do |j|
				if a[i]==b[j] then
					d+=1;break;
				end
			end
		end
	end
	print c," ",d,"\n"
end

Measured memory_bytes: 8636
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b >> c;
	if (a == 5 && b == 5 && c == 7) {
		cout << "YES" << "\n";
	}
	else if (a == 5 && b == 7 && c == 5) {
		cout << "YES" << "\n";
	}
	else if (a == 7 && b == 5 && c == 5) {
		cout << "YES" << "\n";
	}
	else {
		cout << "NO" << "\n";
	}
	
	std::cin >> e;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll x;
    cin>>x;
    ll now1=x/500;
    x%=500;
    ll now2=x/5;
    cout<< now1*1000+now2*5;
}



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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

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

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

// 素因数分解
map<int64_t, int> prime_factor(int64_t n) {
  map<int64_t, int> ret;
  for (int64_t i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

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

  ll N;
  cin >> N;

  ll ans = 0;
  REP(i, N + 1) {
    if (i % 2 == 0) {
      continue;
    }
    ll num_divisor = 1;
    auto factors = prime_factor(i);
    FORm(it, factors) { num_divisor *= (it->second + 1); }
    if (num_divisor == 8) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int comp_time(int x, int y)
{
  int c = 0;
  int t = 0;
  while ((x>0) || (y>0))
  {
    int xi = x % 10;
    int yi = y % 10;
    t += xi * yi + c;
    if (xi + yi + c >=10) c=1; else c=0;
    x = x / 10;
    y = y / 10;
  }
  return t + c;
}

int main()
{
  int n;
  int x[300];

  cin >> n;
  for (int i=0; i<n; i++) cin >> x[i];

  // table
  int sum[300][300];
  int time[300][300];

  for (int i=0;i<n;i++)
  {
    sum[i][1]=x[i];
    time[i][1]=0;
  }

  for (int k=2; k<=n; k++)
  {
    for (int i=0;i<=n-k;i++)
    {
      sum[i][k]=x[i] + sum[i+1][k-1];
      int min_time = comp_time(x[i], sum[i+1][k-1]) + time[i+1][k-1];
      for (int l=2; l<=k-1; l++)
      {
        int r=k-l;
        int t = time[i][l] + time[i+l][r] + comp_time(sum[i][l], sum[i+l][r]);
        if (t < min_time) min_time = t;
      }
      time[i][k] = min_time;
    }
  }
  cout << time[0][n] << endl;
  return 0;
}

Measured memory_bytes: 1864
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	ll n,m;
	cin>>n>>m;
	if(n>=2){
		n-=2;
	}
	ll egh;
	if(m>=2){
		m-=2;
	}
	cout<<n*m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct node {
  int parent,right,left;
};

struct node T[MAX];
int n;
int D[MAX],H[MAX];

int Depth(int u);
int bro(int u);
void print(int u);

int main(){
  int i,v,l,r;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=NIL;
  }


  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);

    T[v].left=l;
    T[v].right=r;

    if(l!=NIL){
      T[l].parent=v;
    }
    if(r!=NIL){
      T[r].parent=v;
    }
  }


  for(i=0;i<n;i++){
    D[i]=Depth(i);
    H[i]=0;
  }

  for(i=0;i<n;i++){
    if (T[i].left==NIL && T[i].right==NIL ) {
      H[i]=0;
      int p=T[i].parent;
      int c=1;
      while(1){
        if (p==NIL) {
          break;
        }
        if (H[p]<c){
          H[p]=c;
        }
        c++;
        p=T[p].parent;

      }
    }
  }
  for (i=0;i<n;i++){
    print(i);
  }
  return 0;
}
int Depth(int u){
  int d=0;
  while(1){
    u=T[u].parent;
    if(u==NIL) {
      break;
    }
    d++;
  }
  return d;
}


int bro(int u){

  if(T[u].parent==NIL) {
    return NIL;
  }
  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) {
    return T[T[u].parent].left;
  }
  if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) {
    return T[T[u].parent].right;
  }
  else  {
    return NIL;
  }
}

void print(int u){
  int deg=0;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", bro(u));

  if (T[u].left!=NIL ) {
    deg++;
  }
  if (T[u].right!=NIL) {
    deg++;
  }

  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);
  if (T[u].parent==NIL){
    printf("root\n");
  }
  else if (T[u].left==NIL && T[u].right==NIL){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}

Measured memory_bytes: 624
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

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

    if (N <= 999) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }

    return 0;
}


Measured memory_bytes: 3536
S = str(input())
    
result = False
    
    
if S[0] == 'A':
    
    check = S[2:len(S)-1]
    
    if check.count('C') == 1:
        index = check.find('C') + 2
        
        if S[1:index].islower() and S[index+1:].islower():
            result = True
            
if result:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t x, a, b;
	cin >> x >> a >> b;
	if (a >= b) cout << "delicious" << endl;
	else if (a < b && b <= a + x)cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <cstdio>

const int p = 1000000007;

int a[4000004];
int b[4000004];
int d[2002][2002];

int f(int x, int y) {
	return y ? y & 1 ? 1ll * f(x, y ^ 1) * x % p : f(1ll * x * x % p, y >> 1) : 1;
}

inline int nCr(int n, int r) {
	return n < r ? 0 : 1ll * a[n] * b[r] % p * b[n - r] % p;
}

int main() {
	int i, j, n, m;
	scanf("%d%d", &n, &m);
	if (m == 1) {
		puts("1");
		return 0;
	}
	a[0] = 1;
	for (i = 1; i <= n * m; i++) a[i] = 1ll * i * a[i - 1] % p;
	b[n * m] = f(a[n * m], p - 2);
	for (i = n * m; i >= 1; i--) b[i - 1] = 1ll * i * b[i] % p;
	d[0][0] = 1;
	for (i = 0; i <= n; i++) for (j = 0; j <= i; j++) {
		d[i + 1][j] = (d[i + 1][j] + d[i][j]) % p;
		if (j < i) d[i][j + 1] = (d[i][j + 1] + 1ll * d[i][j] * (n - j) % p * nCr((n - j) * m - i + j - 1, m - 2)) % p;
	}
	printf("%d", d[n][n]);
	return 0;
}


Measured memory_bytes: 46208
//118 B - Foods Loved by Everyone 2019/02/16
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> k(n);
    vector<int> a(100,0);
    int tmp;
    int counter=0;
    rep(i ,n) {
        cin >> k[i];
        rep(j ,k[i]) { cin >> tmp; ++a[tmp]; }
    }
    rep(i ,m+1) if(a[i]==n) ++counter;
    cout << counter << endl;
}

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

inline long long next(long long i) {return i + i/100;}

int main() {
  long long x, y = 0;
  cin >> x;
  
  for (long long i = 100;; i = next(i)) {
    if (i >= x) break;
    y++;
  }
  
  cout << y;
  
  return 0;
}

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

int main(){
    int X;
    int Nmax;
    int rem;
    cin >> X;
    Nmax = X / 100;
    rem = X % 100;

    if(Nmax * 5 >= rem){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return(0);
}

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

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

bool ok=true;
int c[60][60];
int w,h;
bool seen[60][60];
int dx[8]={1,-1,0,0,1,-1,1,-1};
int dy[8]={1,-1,1,-1,0,0,-1,1};

void dfs(int v,int u){
	if(!seen[v][u]){
		seen[v][u]=true;
		for(int i=0;i<8;i++){
			if(v+dx[i]>=0&&v+dx[i]<h&&u+dy[i]>=0&&u+dy[i]<w&&c[v+dx[i]][u+dy[i]]==1)dfs(v+dx[i],u+dy[i]);
		}
	}
	return;
}

int main(){
	while(ok){
		cin>>w>>h;
		if(w==0||h==0){
			ok=false;
			return 0;
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>c[i][j];
			}
		}
		for(int i=0;i<60;i++){
			for(int j=0;j<60;j++)seen[i][j]=false;
		}
		int ans=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(c[i][j]==1&&!seen[i][j]){
					ans++;
					dfs(i,j);
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3148
import heapq
X, Y, Z, K = map(int, input().split())
A = sorted(map(int, input().split()))[::-1]
B = sorted(map(int, input().split()))[::-1]
C = sorted(map(int, input().split()))[::-1]
h = []
s = set([(0, 0, 0)])
heapq.heappush(h, (-A[0]-B[0]-C[0], 0, 0, 0))
for _ in range(K):
    ans, i, j, k = heapq.heappop(h)
    print(-ans)
    if i+1 < X and (i+1, j, k) not in s:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k], i+1, j, k))
        s.add((i+1, j, k))
    if j+1 < Y and (i, j+1, k) not in s:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k], i, j+1, k))
        s.add((i, j+1, k))
    if k+1 < Z and (i, j, k+1) not in s:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1], i, j, k+1))
        s.add((i, j, k+1))

Measured memory_bytes: 4976