akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


void solv() {
	int n, ma, mb;
	cin >> n >> ma >> mb;
	ll a[105], b[105], c[105];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}

	ll dp[41][500][500];
	for (size_t p = 0; p <= n; p++)
	{

		for (size_t i = 0; i < 500; i++)
		{
			for (size_t j = 0; j < 500; j++)
			{
				dp[p][i][j] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	ll res = INF;
	for (int i = 1; i <= n; i++)
	{
		for (size_t j = 0; j < 500; j++)
		{
			for (size_t k = 0; k < 500; k++)
			{
				dp[i][j][k] = dp[i - 1][j][k];
			}
		}
		int aa = a[i - 1];
		int bb = b[i - 1];
		for (int j = 1; j < 500; j++)
		{
			for (int k = 1; k < 500; k++)
			{
				if (j - aa >= 0 && k - bb >= 0 && dp[i - 1][j - aa][k - bb] < INF) {
					dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - aa][k - bb] + c[i - 1]);
					if (mb * j == ma * k) { 
						res = min(dp[i][j][k], res); 
					}
				}

			}
		}
	}
	cout << (res == INF ? -1 : res) << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 80384
# -*- coding: utf-8 -*-

n,m,c = map(int, input().split())
b = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

#print(a)

count = 0
for i in range(n):
    sum = 0
    for j in range(m):
        sum += a[i][j]*b[j]
#    print("sum: "+str(sum))
    if sum + c > 0:
        count += 1
print(count)


Measured memory_bytes: 3060
// https://atcoder.jp/contests/agc040/tasks/agc040_b

#include "algorithm"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll N;
  cin >> N;

  ll max_l = 0;
  ll min_r = 1e18;

  VPL originals(N);
  rep(i, N) {
    ll l, r;
    cin >> l >> r;
    // [l, r)
    r++;
    originals[i] = {l, r};
    chmax(max_l, l);
    chmin(min_r, r);
  }

  ll res = 0;

  // max_l, min_r を与えるものを同一グループにするケース
  {
    for (auto p : originals) {
      chmax(res, max(min_r - max_l, 0ll) + p.se - p.fi);
    }
  }

  // max_l, min_r を与えるものを同一グループにしないケース
  {
    VPL ps(N);  // f: max(r_i - max_l, 0), s: max(min_r - l_i, 0)

    // s, t の 2 グループに分ける
    // s には max_l を与えるものを、t には min_r を与えるものを入れる
    // s グループの値は min(max(p.second - max_l, 0))
    // t グループの値は min(max(min_r - p.first, 0))
    // となる。
    // 上記２つの値を持った pair N 個を 2 グループに分け、 s については first, t
    // については second の min を取る
    rep(i, N) {
      ps[i] = {
          max(originals[i].se - max_l, 0ll),
          max(min_r - originals[i].fi, 0ll),
      };
    }

    // s について fi の min が x だったとすると、
    // t について se の min を最大化するには fi が x 以上のもの全てを s
    // に入れるのが最善。
    // よって fi で昇順に並び替えた時、 s
    // には後ろの連続した要素を入れることを考えれば良い。

    // fi の昇順、 fi が同一のものは se で降順に並び替えると、
    // 先頭を t に、残りを s に入れる形で最小値の和が網羅できる。
    sort(all(ps), [](auto& a, auto& b) {
      // if (a.fi == b.fi) return a.se > b.se;
      return a < b;
    });

    ll min_t = 1e18;

    rep(i, N - 1) {
      PL new_t = ps[i];

      chmin(min_t, new_t.se);
      ll min_s = ps[i + 1].fi;

      chmax(res, min_t + min_s);
    }
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main(){
    int n;
    cin >> n;
    int f = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a % 2) f = 1;
    }
    cout << (f ? "first" : "second") << endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<60);

int main() {
  int n, ans = 0; cin >> n;
  vl P(n), Q(n);
  ina(P,n); ina(Q,n);
  if (P > Q) swap(P, Q);
  do {
    if (P == Q) break;
    ans++;
  } while (next_permutation(all(P)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(i = p;i < q;i++)
#define ll long long

using namespace std;


//34 A
int main(void) {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	string s;
	cin >> s;
	a--;
	b--;
	c--;
	d--;

	if (d < c) {
		string dots = "...";
		size_t t,p;
		bool can = false;
		int index = b-1;
		while (index < s.size() && ( t = s.substr(index,s.length() - index).find(dots)) != string::npos) {
			int realIndex = t + index;
			if (b-1 <= realIndex && realIndex <= d-1)can = true;
			if (can || d < realIndex)break;
			index = realIndex+1;
		}
		string sharps = "##";
		index = a;
		while (index < s.size() && (p = s.substr(index,s.length() - index).find(sharps)) != string::npos) {
			int realIndex = p + index;
			if ((a < realIndex && realIndex < c)) can = false;
			if (!can)break;
			index = realIndex + 1;
		}
		
		if (can)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		bool can = true;
		string sharps = "##";
		size_t p;
		int index = a;
		while (index < s.size() && (p = s.substr(index,s.size() - index).find(sharps)) != string::npos) {
			int realIndex = p + index;
			if (((a < realIndex && realIndex < c)) || (b < realIndex && realIndex < d)) {
				can = false;
				break;
			}
			index = realIndex + 1;
		}
		if (can)cout << "Yes" << endl;
		else cout << "No" << endl;
	}


}


Measured memory_bytes: 772
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int m,f,r,point;
		while(true){
			point=0;
			m=scan.nextInt();
			f=scan.nextInt();
			r=scan.nextInt();
			if(m==-1&&f==-1&&r==-1) break;
			if(m==-1||f==-1){
				System.out.println("F");
			}else{
				point+=(m+f);
				if(80<=point){
					System.out.println("A");
				}else if(65<=point&&point<80){
					System.out.println("B");
				}else if(50<=point&&point<65){
					System.out.println("C");
				}else if(30<=point&&point<50){
					if(50<=r){
						System.out.println("C");
					}else{
						System.out.println("D");
					}
				}else{
					System.out.println("F");
				}
			}
		}
		scan.close();
	}
}

Measured memory_bytes: 19116
a=int(input())
even_num = 0
odd_num = 0
if a %2==0:
    even_num += a/2
    odd_num +=a/2
else:
    even_num +=(a+1)/2 - 1
    odd_num +=(a+1)/2
print(int(even_num*odd_num))

Measured memory_bytes: 2940
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
a = list(map(int, input().split()))

count = 0
while(1):
    if sum(a) == 0:
        break
    b = False
    for i in range(n):
        if a[i] == 0:
            if b == True:
                break
            continue
        else:
            a[i] -= 1
            b = True
    count += 1
print(count)

    

Measured memory_bytes: 7752
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
typedef std::vector<int> vi;
typedef std::pair<int,int> pi;
typedef std::vector<pi> vp;
typedef long long ll;
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
template<class A,class B>
std::ostream& operator << (std::ostream& st,const std::pair<A,B> p) {
	st << "(" << p.first << ", " << p.second << ")";
	return st;
}
#define tc() int T; scanf("%d",&T); for(int t = 1;t <= T;t++)
using namespace std;


int A[1 << 20],n;

bool solve(){
	ll sum = 0;
	loop(i,n) sum += A[i];
	ll S = n*(n + 1LL)/2;
	if(sum%S) return 0;
	ll k = sum/S,tot = 0;
	int prv = A[n - 1];
	loop(i,n) {
		ll d = A[i] - prv; prv = A[i];
		d = k - d;
		if(d < 0 || d%n) return 0;
		tot += d/n;
	}
	return k == tot;
}

int main(){
#ifdef HOME
	freopen("in.in", "r", stdin);
#endif
	scanf("%d",&n);
	loop(i,n) scanf("%d",A + i);
	puts(solve() ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int r; cin >> r;
    if(r < 1200) cout << "ABC" << endl;
    else if(r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');
let i = 0;
let n = 2, max = 2;
while (line = lines.shift()) {
	if (i % 2 === 0) {
		[n, max] = line.split(' ');
		if (n === 0 && max === 0) { break; }
	}
	else {
		const prices = line.split(' ').map(Number);
		let temp = 0;
		for (let i = 0; i <= n; i++) {
			for (let j = 0; j <= n; j++) {
				if (!prices[i] || !prices[j] || i === j) {
					continue;
				}
				const tempCalc = prices[i] + prices[j];

				if (tempCalc <= max && tempCalc > temp) {
					temp = tempCalc;
				}
			}
		}

		console.log(`${temp ? temp : 'NONE'}`);
	}
	i++;
} 



Measured memory_bytes: 18288
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    long sum=0;
    cin>>a>>b;
    vector<long> c(a);
    for(int i=0;i<a;i++){
        cin>>c.at(i);
    }
    sort(c.begin(),c.end());
    for(int i=0;i<a-b;i++){
        sum+=c.at(i);
    }
    cout<<sum;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
  int k, t;
  cin >> k >> t;
  int maxa = 0, tota = 0;
  for(int i=0; i<t; ++i){
    int a;
    cin >> a;
    maxa = max(maxa, a);
    tota += a;
  }
  if(tota%2){
    maxa = max(0, maxa -(tota+1)/2);
    cout << maxa *2 << endl;
    return 0;
  }
  maxa = max(0, maxa -tota/2);
  if(maxa) maxa = maxa *2 -1;
  cout << maxa << endl;  
}

Measured memory_bytes: 3564
#include<stdio.h>
#define MAX 100005
#define NOT   -1

struct Node{int p, l, r;};
struct Node T[MAX];
int n,H,A[MAX];

int getDepth(int);
void Print(int);

int main( ){
  int i,j,k,l,v,c;
  scanf("%d",&n);
  for(i = 0; i<n; i++){
    T[i].p = T[i].l = T[i].r = NOT;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d",&v, &k);
    for(j = 0; j < k; j++){
      scanf("%d",&c);
      if(j == 0){
	T[v].l = c;
      }
      else T[l].r =c;
	l = c;
	T[c].p = v;
      
      }
    }
  

    H = 0;
    for(i = 0; i < n; i++){
      A[i] = getDepth(i);
      if(A[i] > H) H = A[i];
    }
    for(i = 0; i < n; i++) Print(i);
    return 0;
  }

int getDepth(int u){
  int k = 0;
  for(;T[u].p != NOT;k++){
    u = T[u].p;
  }
  return k;
}

void Print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",A[u]);

  if(T[u].p == NOT) printf("root, ");
  else if(T[u].l == NOT) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0,c = T[u].l; c != NOT; i++,c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}



Measured memory_bytes: 3324
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    string S;
    cin >> S;
    const int N = S.size();
    vector<int> cnt(N,0), R(N,0), L(N,0);
    R[0] = 0; L[N-1] = N-1;
    for (int i=1;i<N;i++) 
        if (S[i] == 'R') R[i] = i;
        else R[i] = R[i-1];
    for (int i=N-2;i>=0;i--) 
        if (S[i] == 'L') L[i] = i;
        else L[i] = L[i+1];

    for (int i=0;i<N;i++) {
        if (S[i] == 'R') {
            int D = L[i]-i;
            cnt[L[i] - D%2]++;
        } else {
            int D = i-R[i];
            cnt[R[i] + D%2]++;
        }
    }

    for (int i=0;i<N;i++) {
        cout << cnt[i];
        if (i < N-1) cout << " ";
        else cout << endl;
    }
    return 0;
}


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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, begin, end) for(int (i) = (begin); (i) < (end); (i)++)

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    int n;
    vector<int> a;
    cin >> n;
    a.resize(n);
    rep(i,0,n) {
        cin >> a[i];
    }
    int minval = INF;
    rep(i,-100,101) {
        int sum = 0;
        rep(j,0,n) {
            sum += (a[j]-i)*(a[j]-i);
        }
        if(sum < minval) {
            minval = sum;
        }
    }

    cout << minval << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    int old = a[0];
    int cnt = 1;
    int ans = 0;
    rep(i,n-1){
        if(a[i+1]==old)cnt++;
        else{
            if(cnt%2==1)ans++;
            cnt = 1;
            old = a[i+1];
        }
    }
    if(cnt%2==1)ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
use std;
use std::collections::VecDeque;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

/*
ここまでテンプレ
*/
fn ord(a: (i32, i32), b: (i32, i32)) -> bool {
    if (a.0 < b.0) {
        true
    } else {
        false
    }
}
fn main() {
    let N = read::<i128>();
    if N % 2 == 1 {
        println!("0");
        return;
    }
    let mut ans: i128 = 0;
    let mut tmp: i128 = 10;
    loop {
        if (N / tmp) == 0 {
            break;
        }
        ans += N / tmp;
        tmp *= 5;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
N = len(S)

for i in range(-(-N//2)):
  if S[i*2] == "L":
    print("No")
    exit()
    
for i in range(N//2):
  if S[i*2+1] == "R":
    print("No")
    exit()
    
if N%2 == 1:
  if S[N-1] == "L":
    print("No")
    exit()
    
print("Yes")

Measured memory_bytes: 5656
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    s = a[i] + b[i] + c[i]
    ta = s.count(a[i])
    tb = s.count(b[i])
    tc = s.count(c[i])

    if ta == 3:
        continue
    elif ta == 1 and tb == 1 and tc == 1:
        ans += 2
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<cstdio>

#define Fast register
const int MaxL=300000;

inline void chkMin(int&x,const int&y){(x>y)&&(x=y);}

char s[MaxL+1];
int cnt[MaxL+1];


int main(){
	Fast int n;
	scanf(" %d %s",&n,s+1);
	for(Fast int i=1,v=0;i<=n;++i){
		if(s[i]=='W')
			++v;
		cnt[i]=v;
	}Fast int Ans=n;
	for(Fast int i=1;i<=n;++i)
		chkMin(Ans,(cnt[i]-(s[i]=='W'))+(n-i)-(cnt[n]-cnt[i]));
	printf("%d",Ans);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(std::vector<long long> H, std::vector<long long> M, long long K) {
  int a = H[0] * 60 + M[0];
  int b = H[1] * 60 + M[1];
  cout << max(0ll, (b - K) - a) << endl;
}

signed main() {
  std::vector<long long> H(2);
  std::vector<long long> M(2);
  for (int i = 0; i < 2; i++) {
    scanf("%lld", &H[i]);
    scanf("%lld", &M[i]);
  }
  long long K;
  scanf("%lld", &K);
  solve(std::move(H), std::move(M), K);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3696
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b){
        if(b != c)
            cout <<"Yes"<<endl;
        else
            cout << "No" << endl;
    }
    else{
        if(a == c || b == c)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second

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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll t1 = b - a + 1;

    ll t2 = b/c - (a-1)/c;

    ll t3 = b/d - (a-1)/d;

    ll lcm = ((c*d)/__gcd(c,d));

    ll t4 = b/lcm - (a-1)/lcm;

    ll t5 = t2 + t3 - t4;

    cout<<t1 - t5<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
using namespace std;
int N;
long ans;
int X[500][500];
bool vis[500][500];
int d[4]={1,0,-1,0};
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)X[i][j]=min(min(i,N-1-i),min(j,N-1-j));
	}
	for(int i=0;i<N*N;i++)
	{
		int P;cin>>P;P--;
		int x=P/N,y=P%N;
		ans+=X[x][y];
		vis[x][y]=true;
		deque<pair<int,int> >Q;
		Q.push_back(make_pair(x,y));
		while(!Q.empty())
		{
			int nx=Q.front().first,ny=Q.front().second;
			Q.pop_front();
			int c=X[nx][ny];
			if(!vis[nx][ny])c++;
			for(int r=0;r<4;r++)
			{
				int tx=nx+d[r],ty=ny+d[r^1];
				if(0<=tx&&tx<N&&0<=ty&&ty<N&&X[tx][ty]>c)
				{
					X[tx][ty]=c;
					if(c>X[nx][ny])Q.push_back(make_pair(tx,ty));
					else Q.push_front(make_pair(tx,ty));
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	string s; cin >> s;
	if(n%2){ out("No"); return 0; }
	else{
		bool flg = true;
		rep(i,n/2){
			if(s[i]!=s[i+n/2]){
				out("No"); return 0;
			}
		}
	}
	out("Yes");
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef vector<vector<int> > Graph;
typedef pair<int, int> P; 
// MOD
//const int mod = 1000000007;
typedef long long ll;
long long INF = 1<<30;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
//int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}
 
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];

bool memo[110];
bool flag;

int dist[100][100];

bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}


struct Unionfind{
    vector<int> par;

    Unionfind(int n) : par(n, -1){}

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    } 

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x]>par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

P s(int x){
    int a = x%10;
    int b = 0;
    while(x){
        b = x;
        b/=10;
    }
    return P(a, b);
}


int main() {
  int a; cin >> a;
  cout << a+a*a + a*a*a << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

typedef struct edge{ll s,g;}E;
int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

ll n,m;
ll a[100010];
E data[100010];
int main(){
	scanf("%lld%lld",&n,&m);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,m){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		data[i].s=y;
		data[i].g=x;
	}
	sortup(a,n);
	qsort(data,m,sizeof(E),esort);
	ll crr=0;
	for(int i=m-1;i>=0;i--){
		int flag=1;
		rep(j,0,data[i].g){
			if(a[crr]>=data[i].s){
				flag=0;
				break;
			}else{
				a[crr++]=data[i].s;
				if(crr==n){
					flag=0;
					break;
				}
			}
		}
		if(!flag)break;
	}
	ll ans=0;
	rep(i,0,n)ans+=a[i];
	printf("%lld",ans);
}



Measured memory_bytes: 4084
import math

N = int(input())


def is_prime(x):
    
    if x == 2:
       
        return True
    if x > 2 and x % 2 == 0:
        return False
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i = i+ 2
    
    return True
    
  
ans =0
for i in range(N):
    n =int(input())
    is_prime(n)
    if is_prime(n):
        ans += 1

print(ans)



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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  int n;
  cin >> n;
  cout << 180 * (n-2) << endl;

  return 0;
}


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

using namespace std;
int main(){
    long long int X, counter = 0, C=100;

    cin>>X;

    while(true){
        if(C>=X){
            break;
        }
        else{
            C=C*(1.01);
            counter++;
        }
    }

    cout<<counter<<"\n";

    return 0;
}



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

int main()
{
  int n, l;
  cin >> n >> l;
  
  vector <string> s(n);
  for (int i = 0; i < n; i++){
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  
  string ans;
  for (int i = 0; i < n; i++){
    ans += s.at(i);
  }
  cout << ans;
}

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

typedef long long ll;

ll N;
string S;

int main() {
    cin >> N >> S;
    ll ans = 0;
    for (ll i = 0; i <= S.size() - 3; i++) {
        // cout << i << endl;
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import math
def main():
    n = int(input())
    s1 = input()
    s2 = input()
    s = ""
    i=0
    while(i<n):
        if(s1[i]==s2[i]):
            s+="|"
            i+=1
        else:
            s+="="
            i+=2
        if(i>=n):
            break
    res = 0
    if(s[0]=="|"):
        res = 3
    else:
        res = 6
    MOD = 10**9 + 7
    for i in range(1,len(s)):
        if(s[i-1]=="|" and s[i]=="|"):
            res *= 2
        elif(s[i-1]=="|" and s[i]=="="):
            res *= 2
        elif(s[i-1]=="=" and s[i]=="|"):
            res *= 1
        else:
            res *= 3

        res%=MOD
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
ll pro(ll A[], ll n)
{

    ll array_sum = 0;
    for (ll i = 0; i < n; i++)
        array_sum = (array_sum%mod + A[i]%mod)%mod;
    ll array_sum_square = ((array_sum%mod) * (array_sum%mod))%mod;
    ll individual_square_sum = 0;
    for (ll i = 0; i < n; i++)
        individual_square_sum = ((individual_square_sum%mod)+((A[i]%mod)*(A[i]%mod))%mod)%mod;
    return (array_sum_square - individual_square_sum)/2;
}
ll po(ll x,ll y)
{
    ll ans=1;
    while(y>0)
    {

        if(y%2)
            ans=(ans*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return ans%mod;
}
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+1],i,sum=0;
        for(i=0;i<n;i++)
            {cin>>a[i];
              sum=(sum%mod+a[i]%mod)%mod;
            }
            sum=((sum)*(sum))%mod;
            ll k=0;
            for(i=0;i<n;i++)
            {
                ll m=(a[i]*a[i])%mod;
                k=(k%mod+m%mod)%mod;
            }
            sum+=mod;
            sum-=k;
            ll ans=((sum%mod)*(po(2,mod-2)%mod))%mod;
          cout<<ans<<endl;
         // else
           // cout<<(sum-k)/2<<endl;
    }

}


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

int main(){
  int W,H;
  while(cin >> H >> W){
    if(H==0&&W==0)
      break;
    for(int h=0; h<H; h++){
      for(int w=0; w<W; w++){
        if(h%2 == 0){
           if(w%2 == 0)
             cout<< '#';
           else
             cout << '.';
        }else{
           if(w%2 == 0)
             cout << '.';
           else
             cout << '#';
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3076
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[] vitalArray = new int[N];
        for(int i = 0; i < N; i++){
            vitalArray[i] = sc.nextInt();
        }
        int[] vitalAfterBattle = Arrays.copyOf(vitalArray, vitalArray.length);
        int[] vitalBeforeBattle = new int[N];
        
        while(isNotEnough(vitalBeforeBattle, vitalAfterBattle)){
            vitalBeforeBattle = Arrays.copyOf(vitalAfterBattle, vitalAfterBattle.length);
            vitalAfterBattle = attackByWeakest(vitalAfterBattle);
        }
        
        System.out.println(minButNotZero(vitalAfterBattle));
    }
    private static int[] attackByWeakest(int[] vitalArray){
        int min = minButNotZero(vitalArray);
        for(int i = 0; i < vitalArray.length; i++){
            if(min != vitalArray[i]) vitalArray[i] = vitalArray[i] % min;
        }
        return vitalArray;
    }
    private static boolean isNotEnough(int[] vitalArray, int[] vitalAfterBattle){
        for(int i = 0; i < vitalArray.length; i++){
            if(vitalArray[i] != vitalAfterBattle[i]) return true;
        }
        return false;
    }
    private static int minButNotZero(int[] vitalArray){
        int min = 1000000000;
        for(int i = 0; i < vitalArray.length; i++){
            if(vitalArray[i] != 0 && min > vitalArray[i]) min = vitalArray[i];
        }
        return min;
    }
}


Measured memory_bytes: 48728
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    long A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    long f = A[0];
    long sum = 0;
    for (int i = 1; i < N; i++)
    {
        long h = (f <= A[i]) ? 0 : f-A[i] ;
        sum += h;
        f = A[i] + h;
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];


int main(void) {
  ll i, j, k;
  
  ll N, M, K;
  ll a[MAX*2], b[MAX*2];
  ll sa[MAX*2], sb[MAX*2];
  
  cin >> N >> M >> K;
  for(i=1; i<=N; i++) {
    cin >> a[i];
    sa[i]=sa[i-1]+a[i];
  }
  for(i=1; i<=M; i++) {
    cin >> b[i];
    sb[i]=sb[i-1]+b[i];
  }
  
  ll ans=0;
  for(i=0; i<=N; i++) {
    ll rem=K-sa[i];
    if(rem<0) continue;
    
    ll p=upper_bound(sb, sb+M+1, rem)-1-sb;
    chmax(ans, i+p);
  }
  
  pt(ans);
  
}
 
 




Measured memory_bytes: 9860
#include<stdio.h>
#define n 100

struct Node{
  int l,r,p;
};
struct Node t[n];
int m;
int d[n],h[n];

int depth(int u){
  int a=0;
  while(1){
    u=t[u].p;
    if(u==-1)break;
    a++;
  }
  return a;
}
int sibling(int u){
  if(t[u].p==-1) return -1;
    if(t[t[u].p].l!=u && t[t[u].p].l!=-1) return t[t[u].p].l;
  if(t[t[u].p].r!=u && t[t[u].p].r!=-1) return t[t[u].p].r;
  return -1;
}

void print(int i){
  int a=0;
  printf("node %d: ",i);
  printf("parent = %d, ",t[i].p);
  printf("sibling = %d, ",sibling(i));
  if(t[i].l!=-1)a++;
  if(t[i].r!=-1)a++;
    printf("degree = %d, ",a);
  printf("depth = %d, ",d[i]);
  printf("height = %d, ",h[i]);
  if(t[i].p==-1){
    printf("root\n");
  }
  else if(t[i].l==-1 && t[i].r==-1){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}

int main(){
  int i,r,l,x,p;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    t[i].p=-1;
  }

  for(i=0;i<m;i++){
          scanf("%d%d%d",&x,&l,&r);
    t[x].l=l;
    t[x].r=r;
    if(l!=-1)t[l].p=x;
    if(r!=-1)t[r].p=x;
  }

  for(i=0;i<m;i++){
    d[i]=depth(i);
    h[i]=0;
  }
  
  for(i=0;i<m;i++){
    if(t[i].l==-1 && t[i].r==-1){
      h[i]=0;
      p=t[i].p;
      int a=1;
      while(1){
        if(p==-1)break;
        if(h[p]<a)h[p]=a;
        a++;
        p=t[p].p;
      }
    }
  }
  for(i=0;i<m;i++){
    print(i);
  }
  return 0;
}


Measured memory_bytes: 2100
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	f := map[int]bool{}

	for i := 0; i < n; i++ {
		a := nextInt()
		if f[a] {
			_, _ = fmt.Fprintf(writer, "NO")
			return
		}
		f[a] = true
	}

	_, _ = fmt.Fprintf(writer, "YES")
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 8704
/* AUTHOR : UTKARSH CHAUHAN */

#include<bits/stdc++.h>
using namespace std;
       
#define ff              first
#define ss              second                            
#define int             long long
#define rep(i,j,k)      for(int i=(j); i<(int)k; ++i)
#define rrep(i,k,j)     for(int i=(int)k-1; i>=(j); --i)
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define endl            "\n"
#define vi              vector<int>
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x, y)        fixed << setprecision(y) << x
#define mk(arr, n, type)type *arr = new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define PI              3.14159265358979323846264338327950L
#define span(a)         begin(a), end(a)
#define parent(i)       (i >> 1)
#define left(i)         (i << 1)
#define right(i)        (left(i) | 1)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
       
       
       
       
void c_p_c() {
  ios_base::sync_with_stdio(0); 
  cin.tie(0); 
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif  
}      


double pi = 3.141592653589;

// int gcd (int a, int b) {
//   if (b == 0) return a;
//   else return gcd (b, a % b);
// }    
// int gcd(int a, int b, int& x, int& y) {
//   if (b == 0) {
//     x = 1;
//     y = 0;
//     return a;
//   }  
//   int x1, y1;
  
//   int d = gcd(b, a % b, x1, y1);
//   x = y1;
//   y = x1 - y1 * (a / b);
//   return d;
// }   
// int lcm (int a, int b)  {
//   return a / gcd(a, b) * b;
// }   
// int fact (int n){
//   if (n == 0) return 1 ;
//   else return n * fact(n - 1); 
// }   
 
// bool isPrime(int x) {
//   for (int d = 2; d * d <= x; d++) if (x % d == 0) return false;
//   return true;
// }
 
// int divisor(int number)
// {
//         int i;
//         for (i = 2; i <= sqrt(number); i++)
//         {
//                 if (number % i == 0)
//                 {
//                        return number/i;
//                 }
//         }
//         return 1;
// }  
inline void solve() 
{
	int n; cin >> n;
	n >= 30 ? cout << "Yes" : cout << "No";
}    
int32_t main() 
{
      //c_p_c();
      //w(x)
      solve();
      return 0;
} 

Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
 #define MAX_V 5010
struct Edge{ll to,cap,rev;};
typedef vector<Edge> Edges;
Edges G[MAX_V];
bool used[MAX_V];//for DFS
 
void add_Edge(int from,int to,int cap){
  G[from].pb((Edge){to,cap,(int)G[to].size()});
  G[to].pb((Edge){from,0,(int)G[from].size()-1});
}
 
ll dfs(ll v,ll t,ll f){
  if(v == t) return f;
  used[v] = true;
  rep(i,G[v].size()){
    Edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      ll d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
 
ll Ford_Fulkerson(ll s,ll t){
  ll flow = 0;
  while(1){
    memset(used,0,sizeof(used));
    ll f = dfs(s,t,INF);
    if(f == 0) return flow; //max flow
    flow += f;
  }
}

int main(){
  int n; cin >> n;
  ll sum = 0;
  for(int i = 1; i <= n; i++){
    int a; cin >> a;
    if(a > 0)
      sum+=a,add_Edge(i,n+1,a);
    else
      add_Edge(0,i,-a);
    for(int k = i; k <= n; k+=i)
      add_Edge(i,k,INF);
  }
  cout << sum - Ford_Fulkerson(0,n+1) << endl;
}

Measured memory_bytes: 384
#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 mod =1'000'000'007;
    int N;
    cin >> N;
    
    //vector<vector<vector<vector<int>>>> dp(N+2,vector(4,vector(4,vector<int>(4,0))));
    vector<vector<vector<vector<int>>>> dp(N+2, vector<vector<vector<int>>>(4,vector<vector<int>>(4,vector<int>(4,0))));
    
    dp[0][3][3][3] = 1;
    
    for(int len=0; len < N; len++){
        for(int c1=0; c1<4; c1++){
            for(int c2=0; c2<4; c2++){
                for(int c3=0; c3<4; c3++){
                    if(dp[len][c1][c2][c3]==0) continue;
                    
                    //１文字追加する
                    for(int a=0; a<4; a++){
                        if(a==2 && c1==1 && c2==0) continue;
                        if(a==1 && c1==2 && c2==0) continue;
                        if(a==2 && c1==0 && c2==1) continue;
                        if(a==2 && c1==1 && c3==0) continue;
                        if(a==2 && c2==1 && c3==0) continue;
                        
                        dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len + 1][a][c1][c2] %= mod;
                    }
                
                }
                
            }
        }
    }
    
    int ans=0;
    for(int c1=0; c1<4; c1++){
        for(int c2=0; c2<4; c2++){
            for(int c3=0; c3<4; c3++){
                ans += dp[N][c1][c2][c3];
                ans %= mod;
            
            }
            
        }
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
priority_queue<int> q;
int a;
for(int i=0;i<3;i++){
cin>>a;
q.push(a);
}
int k;
cin>>k;
int ans=0;
int t;
for(int i=0;i<k;i++){
t=q.top();
t*=2;
q.pop();
q.push(t);
}
while(!q.empty()){
ans+=q.top();
q.pop();

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		int W = in.nextInt();
		int H = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		int r = in.nextInt();

		if(x >= r && (x + r) <= W && y >= r && (y + r) <= H){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 26328