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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t h;
  std::cin >> h;

  int64_t ans = 0;
  int64_t n = 0;

  while (0 < h) {
    h /= 2;
    ans += (static_cast<int64_t>(1) << n);
    n++;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;
int a, b, c, x, cnt;

int main() {
	while (cin >> a >> b >> c >> x) {
		cnt = 0;
		for (int i = 0; i <= a; ++i) {
			for (int j = 0; j <= b; ++j) {
				for (int k = 0; k <= c; ++k) {
					if (500*i + 100*j + 50*k == x)
						++cnt;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#from time import time
#t = time()
nvm = input().split(' ')
if abs(int(nvm[0]) - int(nvm[1])) < abs(int(nvm[0]) - int(nvm[2])):
    print('A')
else:
    print('B')

#print(mn[0] * mm[1])
#tt= time()
#print(tt-t)
    

Measured memory_bytes: 2940
//--- pE ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}


class Solution {
	Scanner scanner;



	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}


	private void run_case() {
		// scanner.nextLine();
		String line = scanner.nextLine();
		// int N = Integer.parseInt(line);
		char[] num = line.toCharArray();
		line = scanner.nextLine();
		int K = Integer.parseInt(line);
		this.K = K;

		long res = countInRange(num);

		this.K = K-1;
		long res2 = countInRange(num);

		System.out.println(res - res2);
		return;
	}

	List<Integer> num;
	int K;
	int M = 101;
	long[][][] dp;
	private long countInRangeUtil(int pos, int cnt, int tight ) {
	    if (pos == num.size()) {
	        // If count of non zero digits
	        // is less than or equal to K
	        if (cnt <= K)
	            return 1;
	        return 0;
	    }

	    // If this result is already computed
	    // simply return it
	    if (dp[pos][cnt][tight] != -1)
	        return dp[pos][cnt][tight];

	    int ans = 0;

	    // Maximum limit upto which we can place
	    // digit. If tight is 1, means number has
	    // already become smaller so we can place
	    // any digit, otherwise num[pos]
	    int limit = (tight!=0 ? 9 : num.get(pos));

	    for (int dig = 0; dig <= limit; dig++) {
	        int currCnt = cnt;

	        // If the current digit is nonzero
	        // increment currCnt
	        if (dig != 0)
	            currCnt++;

	        int currTight = tight;

	        // At this position, number becomes
	        // smaller
	        if (dig < num.get(pos))
	            currTight = 1;

	        // Next recursive call
	        ans += countInRangeUtil(pos + 1, currCnt, currTight);
	    }
	    return dp[pos][cnt][tight] = ans;
	}

	private long countInRange (char[] x) {
	    num = new ArrayList<Integer>();
		int sz = x.length;
		for (int i=sz-1; i>=0; i--) {
			num.add(x[i] - '0');
		}
	    // while (x!=0) {
	    //     num.add(x % 10);
	    //     x /= 10;
	    // }
	    Collections.reverse(num);

	    // Initialize dp
		dp = new long[M][M][2];
	    for(int i=0;i<M;i++)
	        for(int j=0;j<M;j++)
	            for(int k=0;k<2;k++)
	            	dp[i][j][k]=-1;
	    return countInRangeUtil(0, 0, 0);
	}


	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}


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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"

int n, m;
char a[111][111];
char b[111][111];

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

	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i)
		scanf("%s", a[i]);
	for (int i = 0; i < m; ++i)
		scanf("%s", b[i]);

	for (int i = 0; i + m - 1 < n; ++i)
		for (int j = 0; j + m - 1 < n; ++j) {
			bool ok = 1;
			for (int ii = 0; ii < m; ++ii)
				for (int jj = 0; jj < m; ++jj) {
					ok &= (a[i + ii][j + jj] == b[ii][jj]);
				}
			if (ok) {
				puts("Yes");
				return 0;
			}
		}
	puts("No");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,top=2,now=1;
    string s;
    cin>>n;
    n+=now;
    while(n>top){
        now*=3;
        top+=now*2;
        n+=now;
    }
    while(n){
        if(n>=now*2){
            s+='+';
            n-=now*2;
        }
        else if(n>=now){
            s+='0';
            n-=now;
        }
        else s+='-';
        now/=3;
    }
    while(now>0){
        s+='-';
        now/=3;
    }
    //reverse(s.begin(),s.end());
    cout<<s<<endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int n;
double ans,d,x;
int main() {
  scanf("%d%lf%lf",&n,&d,&x);
  for ( ; n ; ans += (2 * d + (2 * n - 1) * x) / 2.0, d += (2 * d + 5 * x) / (2.0 * n), x += (2.0 * x) / n, n --);
  printf("%.14lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, b, c, k5, k7;

	scanf("%d%d%d", &a, &b, &c);
	k5 = k7 = 0;
	if (a == 5)
		k5++;
	else if (a == 7)
		k7++;
	if (b == 5)
		k5++;
	else if (b == 7)
		k7++;
	if (c == 5)
		k5++;
	else if (c == 7)
		k7++;
	printf(k5 == 2 && k7 == 1 ? "YES\n" : "NO\n");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


void solve() {
	string s; cin >> s;
	if (s == "AAA" || s == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
		a[i]--;
	}
	vector<int> d(n);
	for(int i=0;i<n;i++){
		d[a[i]]++;
	}
	vector<int> ans(n,-1);
	int ban=-1;
	set<int> st;
	for(int i=0;i<n;i++){
		st.insert(i);
	}
	for(int i=0;i<n;i++){
		if(n-i<=8){
			vector<int> v;
			for(int vv:st){
				v.push_back(vv);
			}
			do{
				bool ok=1;
				if(v[0]==ban)ok=0;
				for(int j=0;j<v.size()-1;j++){
					if(a[v[j]]==v[j+1])ok=0;
				}
				if(ok){
					for(int j=0;j<v.size();j++){
						ans[i+j]=v[j];
					}
					for(int j=0;j<n;j++){
						cout << ans[j]+1 << " ";
					}
					cout << endl;
					return 0;
				}
			}while(next_permutation(v.begin(),v.end()));
			cout << -1 << endl;
			return 0;
		}
		else{
			int k=n-i;
			for(int v:st){
				if(v==ban)continue;
				if(st.count(a[v])&&d[a[v]]==k-1)continue;
				ans[i]=v;
				st.erase(v);
				ban=a[v];
				d[a[v]]--;
				break;
			}
		}
	}
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x,y;cin >> x >> y;
	int ans = 0;
	while(x <= y){
		ans++;
		x *= 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

ans = 'YES'

x = sc - 1
for i in range(N):
    if S[i] == 'L': x -= 1
    # print("# L", i, x)
    if x < 0: ans = 'NO'
    if T[i] == 'R': x = min(x + 1, W - 1)

x = sc - 1
for i in range(N):
    if S[i] == 'R': x += 1
    # print("# R", i, x)
    if x >= W: ans = 'NO'
    if T[i] == 'L': x = max(x - 1, 0) 
    
y = sr - 1
for i in range(N):
    if S[i] == 'U': y -= 1
    # print("# U", i, y)
    if y < 0: ans = 'NO'
    if T[i] == 'D': y = min(y + 1, H - 1)
    
y = sr - 1
for i in range(N):
    if S[i] == 'D': y += 1
    # print("# D", i, y)
    if y >= H: ans = 'NO'
    if T[i] == 'U': y = max(y - 1, 0)

print(ans)


Measured memory_bytes: 3888
using System;

namespace Atcoder
{
    class Program
        //AtCoder Beginner Contest 130 B - Bounding
    {
        private static void Main(string[] args)
        {
            var nx = Console.ReadLine().Split(' ');
            int n = int.Parse(nx[0]);
            int x = int.Parse(nx[1]);
            var l = Console.ReadLine().Split(' ');
            var sums = 0;
            var ans = 1;
            for (var i = 0; i < l.Length; i++)
            {
                ans++;
                sums += int.Parse(l[i]);
                if (sums == x)
                {
                    break;
                }

                if (sums > x)
                {
                    ans--;
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
import itertools
n, d = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for a, b in itertools.combinations(X, r=2):
    s = (sum(map(lambda x, y: (x - y)**2, a, b)))**0.5
    if s.is_integer():
        ans += 1
print(ans)

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

int main() {
  int H, W;
  cin >> H >> W;
  char s[H][W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> s[i][j];
    }
  }

  int t[2] = {-1, 1};
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(s[i][j] == '.') continue;
      bool ok = false;
      for(int ver : t){
        if(i+ver >= 0 && i+ver < H){
          if(s[i+ver][j] == '#'){
            ok = true;
            break;
          }
        }
      }
      for(int hori : t){
        if(j+hori >= 0 && j+hori < W){
          if(s[i][j+hori] == '#'){
            ok = true;
            break;
          }
        }
      }
      if(!ok){
        cout << "No" << endl;
        return 0; 
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
const ll mod = (ll)1e9 + 7;
const ll INF = (ll)2e18;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}

class EVirusTree2 {
    int N, K;
    vector<int> next[110000];
    ll ans = 1;
public:
    void dfs(int cur, int pre, int num) {
        ans = ans * num % mod;
        num = K - 1;
        if (pre != - 1) --num;
        for (int ch : next[cur]) {
            if (ch == pre) continue;
            dfs(ch, cur, num);
            --num;
        }
    }

	void solve(std::istream& in, std::ostream& out) {
        in >> N >> K;
        rep(i, N - 1) {
            int a, b;
            in >> a >> b;
            --a; --b;
            next[a].push_back(b);
            next[b].push_back(a);
        }
        dfs(0, -1, K);
        out << ans << endl;
	}
};


int main() {
	EVirusTree2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 2019
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}


int32_t main()
{
  io
 int a,b,k;
 cin>>a>>b>>k;
 int kk=a;
  a=max(a-k,(int)0);
  k-=min(k,kk);
  b=max(b-k,(int)0);
  cout<<a<<" "<<b<<endl;

}

Measured memory_bytes: 3664
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
#define BUF_SIZE 1024
#define ARRAY_SIZE 100
 
 
void selectionSort(int array[],int n,int& change_count)
{
    int min;
    for(int i = 0; i < n-1; i++){
        min = i;    //?????????
        for(int j = i+1; j < n; j++){
            if(array[j] < array[min]){
                min = j;
            }
        }
        if(i != min){
            swap(array[i],array[min]);
            change_count++;
        }
    }
 
}
 
int main(){
 
    char buf[BUF_SIZE];
    int n = atoi(fgets(buf,BUF_SIZE,stdin));
    int array[ARRAY_SIZE];
    int change_count = 0;
 
    for(int i = 0; i < n; i++){
        cin >> array[i];
    }
 
    selectionSort(array,n,change_count);
 
    for(int i = 0; i < n; i++){
        if(i != n-1){
            printf("%d ",array[i]);
        }else{
            printf("%d\n",array[i]);
        }
    }
    printf("%d\n",change_count);
}


Measured memory_bytes: 3196
h,w=map(int, input().split()) 
n=int(input())
a=list(map(int, input().split())) 
ans=[[0]*w for i in range(h)] 
count=0
x=1
for i in range(h):
    for j in range(w):
        if i%2==0:
            if a[x-1]==0:
                x+=1
            ans[i][j]=x
            a[x-1]-=1
        else:
            if a[x-1]==0:
                x+=1
            ans[i][w-1-j]=x
            a[x-1]-=1

for i in range(h):
    print(*ans[i])
    




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

void solve_A() {
	int S, W;
	std::cin >> S >> W;
	//std::string result = (S <= W ? "unsafe" : "safe");
	std::cout << (S <= W ? "unsafe" : "safe") << std::endl;
}

void solve_B() {
	int A, B, C, D;
	std::cin >> A >> B >> C >> D;
	while (!( A <= 0 || C <= 0)) {
		C -= B;
		if (C <= 0) break;
		A -= D;
	}
	std::cout << (A <= 0 ? "No" : "Yes") << std::endl;
}

#include<vector>
#include<algorithm>

void solve_C() {
	int N;
	std::vector<std::string> v;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::string tmp;
		std::cin >> tmp;
		v.push_back(tmp);
	}
	std::sort(v.begin(), v.end());
	auto last = std::unique(v.begin(), v.end());
	v.erase(last, v.end());
	std::cout << v.size() << std::endl;

}

int main()
{
	//solve_A();
	//solve_B();
	solve_C();
    return 0;
}

Measured memory_bytes: 11640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b; cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
struct Kruskal{
  
  struct edge{
    Int from,to;
    T cost;
    Int used;
    edge(){}
    edge(Int from,Int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  Int n;
  vector<Int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(Int n):n(n){}

  void init(Int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(Int x,Int y){
    return find(x)==find(y);
  }

  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(Int u,Int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,d;
  cin>>n>>d;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Kruskal<Int> ks(n);
  using P = pair<Int, Int>;

  const Int INF = 1e18;
  vector<P> ls(n,P(INF,-1)),rs(n,P(INF,-1)),dp(n);
  function<void(Int, Int)> dfs=
    [&](Int l,Int r)->void{
      if(l+1==r){
        dp[l]=P(a[l],l);
        return;
      }
      Int m=(l+r)>>1;      
      dfs(l,m);
      dfs(m,r);
      P x(INF,-1),y(INF,-1);
      for(Int i=l,j=m;i<m||j<r;){
        if(i==m){
          chmin(ls[dp[j++].second],x);
          continue;
        }
        if(j==r){
          chmin(rs[dp[i++].second],y);
          continue;
        }
        if(dp[i].first<=dp[j].first){
          Int k=dp[i++].second;
          chmin(rs[k],y);
          chmin(x,P(a[k]-k*d,k));
        }else{
          Int k=dp[j++].second;
          chmin(ls[k],x);
          chmin(y,P(a[k]+k*d,k));
        }
      }
      
      inplace_merge(dp.begin()+l,dp.begin()+m,dp.begin()+r);
    };  
  dfs(0,n);
  
  auto add_edge=
    [&](Int x,Int y){
      if(x<0||y<0) return;
      Int c=abs(x-y)*d+a[x]+a[y];
      ks.add_edge(x,y,c);
    };
  for(Int i=0;i<n;i++) add_edge(ls[i].second,i);
  for(Int i=0;i<n;i++) add_edge(i,rs[i].second);

  cout<<ks.build()<<endl;
  return 0;
}


Measured memory_bytes: 33640
#include<bits/stdc++.h>
using namespace std;
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;}
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(int i=b;i<n;i++)
#define loopv(b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}

#define trace2(x, y)               cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
ll fib(vector<ll> f,ll n,ll a,ll b)
{
    trace2(n,f[n]);
  if(n<a)
    return 0;
    if (n == a )
        return 1;
    if(n>a)
    {
        if(n<b)
        {
            if(n%a==0)
                return 1;
            else
                return 0;
        }
        else
        {    if(n==b)
    {if(n%a==0)
            {
                f[n]=2;
                return f[n];
     }    else
    return 1;
  }



        }
    }
    if (f[n])
        return f[n];
    int k = (n & 1)? (n+1)/2 : n/2;
    f[n] = (n & 1)? modA(modM(fib(f,k,a,b),fib(f,k,a,b)) , modM(fib(f,k-1,a,b),fib(f,k-1,a,b))):
        modA(2*fib(f,k-1,a,b) ,modM( fib(f,k,a,b),fib(f,k,a,b)));
      trace2(n,f[n]);
    return f[n];
}
int main()
{
// freopen("input.txt","r",stdin);
ll t;
t=1;
while(t--)
{
    ll n;
    cin>>n;
ll ans=1;
string s;
cin>>s;
map<char,ll> cnt;
loop(i,0,n)
cnt[s[i]-'a']++;
for(auto i:cnt)
    if(i.ss&1)
{
    ans=0;
    break;
}
if(ans)
cout<<"Yes"<<"\n";
else

cout<<"No"<<"\n";
}
return 0;
}



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

using namespace std;

char s[20];

int main(){
	int n,k;
	scanf("%d",&n);
	scanf("%s",s + 1);
	int i;
	scanf("%d",&k);
	for(i = 1;i <= n;i++)if(s[i] != s[k]) s[i] = '*';
	for(i = 1;i <= n;i++)cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,b,c,d;
long long a[100005],dp[100005];

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
            cin>>a[i];

    }
    dp[1]=abs(a[0]-a[1]);

    for(int i=2;i<n;i++){
            b=abs(a[i-1]-a[i]);
            c=abs(a[i-2]-a[i]);
            dp[i]=min(dp[i-1]+b,dp[i-2]+c);
    }
    if(n==2)cout<<dp[1];
    else{

     cout<<dp[n-1];
     }
        return 0;
}


Measured memory_bytes: 5204
#include<stdlib.h>
int main(){
      int N,x=0,i,y=0;
      char S[110];
    scanf("%d%s",&N,S);
    for(i=0;i<N;i++){
        if(S[i]=='I') x++;
        else if(S[i]=='D') x--;
        if(x>y) y=x;
    }
    printf("%d\n",y);
return 0; 
}

Measured memory_bytes: 128
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n = ni()
s = input()
dp = [[0] * 5005 for _ in range(5005)]
for i in range(n)[::-1]:
    for j in range(n)[::-1]:
        if s[i] != s[j]:
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(n):
    for j in range(n):
        if i >= j: continue
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)


Measured memory_bytes: 231688
#include <iostream>
#include <ctype.h>
using namespace std;
int main(void){
    char data[1200];
    cin.getline(data, sizeof(data));
    for (int i = 0; i < 1200; i++)
    {
        // ?°???????
        if (islower(data[i]) != 0)
        {
            data[i] = toupper(data[i]);
        }
        // ??§??????
        else
        {
            data[i] = tolower(data[i]);
        }
    }
    cout << data << endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)*/

//ここから書き始める
int main(){
	int n, k ; cin >> n>>k;//選ぶことができるのは、1,3,...って感じで切り上げ処理を施したn-1)/2 
	int pos = (n+1)/2;
	if(k<=pos) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A,B,C,X;
    int c=0;
    scanf("%d%d%d%d",&A,&B,&C,&X);
    for(int x=0;x<=A;x++){
        for(int y=0;y<=B;y++){
            for(int z=0;z<=C;z++){
                if(500*x+100*y+50*z==X){
                    c++;
                    //printf("x = %d,y = %d,z = %d\n",x,y,z);
                }
            }
        }
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
int main(void) {
  long long n;
  cin>>n;
  for(long long i=n; i>=0; i--) {
    double x=sqrt(i);
    if(ceil(x)==floor(x)) {
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
priority_queue<double, vector<double>, greater<double> > q; 
	double a,b,c;
	double h;
	cin>>a;
	
	for(int i=1;i<=a;i++){
		cin>>b;
		q.push(b);
	}

	for(int i=1;i<a;i++){
		b=q.top();
		q.pop();
		c=q.top();
	    q.pop();
		h=(b+c)/2.0;
		q.push(h);
	
		
	}
	q.pop() ;
	cout<<h<<endl;

	return 0;
	}	

Measured memory_bytes: 256
def main():
    nk = [int(_x) for _x in input().split()]
    N = nk[0]
    K = nk[1]

    snuke = [True]*N

    for i in range(K):
        input()
        aa = [int(_x) for _x in input().split()]
        for a in aa:
            snuke[a-1] = False
    print(sum(snuke))


main()


Measured memory_bytes: 9108
from math import inf
from random import randint,random
import time
START=time.time()
PROB=0.99

def f(a,d,T):
    try:
        return T[d:].index(a)+d
    except ValueError:
        return len(T)

from random import randint
A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))
 
def g(d,q,S,C,T):
    p=T[d]

    a=f(p,d+1,T)
    b=f(q,d+1,T)
    
    Y=0
    h=L[d-1][p]
    for i in range(d,a):
        h+=1
        Y+=h-L[i][p]
        
    m=0
    Z=0
    for j in range(d,b):
        Z-=m-L[j][q]
        m+=1
        
    return (S[d][q]-S[d][p])+Z*C[q]-Y*C[p]

T=[0]
L=[[0]*(A+1) for _ in range(D+1)]
for d in range(1,D+1):
    M=-inf
    E=0

    for j in range(1,A+1):
        X=0
        for k in range(1,A+1):
            if j!=k:
                X-=C[k]*L[d][k]
                
        if M<=X+S[d][j]:
            M=X+S[d][j]
            E=j

    T.append(E)
    for j in range(1,A+1):
        if j!=E:
            L[d][j]=L[d-1][j]+1
        else:
            L[d][j]=0

while time.time()-START<=1.70:
    e=randint(1,D)
    q=randint(1,A)

    V=g(e,q,S,C,T)
    if V>0 or random()>PROB:
        p=T[d]

        a=f(p,d+1,T)
        b=f(q,d+1,T)
        
        h=L[d-1][p]
        for i in range(d,a):
            h+=1
            L[i][p]=h

        m=0
        for j in range(d,b):
            L[j][q]=m
            m+=1
        T[d]=q

for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 89456
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, l;
int x[65], y[65], z[65];
void addedge(int u, int v, int c) {
	m++, x[m] = u+1, y[m] = v+1, z[m] = c;
}
int main() {
	read(l);
	for (; (1<<n) <= l; n++) ; n--;
	for (int i = 0; i < n; i++)
		addedge(i, i+1, 0), addedge(i, i+1, 1<<i);
	int base = 1<<n;
	for (int i = n-1; ~i; i--) if (l>>i&1)
		addedge(i, n, base), base += 1<<i;
	printf("%d %d\n", n+1, m);
	for (int i = 1; i <= m; i++)
		printf("%d %d %d\n", x[i], y[i], z[i]);
	return 0;
}

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

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int m = n % 1000 != 0 ? n / 1000 + 1 : n / 1000;
        Console.WriteLine(1000 * m - n);
    }
}

Measured memory_bytes: 27472
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi  3.14159265358979323846
 
int main(){
    ll m,f,r;
    ll roop = 0;
    char result[52];
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r==-1){
            break;
        }else if(m == -1 || f == -1 || m+f < 30){
            result[roop] = 'F';
        }else if(m+f>=80){
            result[roop] = 'A';
        }else if(m+f>=65){
            result[roop] = 'B';
        }else if(m+f>=50 || (m+f>=30&&r>=50)){
            result[roop] = 'C';
        }else{
            result[roop] = 'D';
        }
        roop++;
    }
    REP(i,roop){
        cout << result[i] << endl;
        }
    return 0;
}


Measured memory_bytes: 3052
# coding: utf-8

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

N = int(input())
L = [[int(x) for x in input().split()] for _ in range(N)]

L.sort(key=lambda x : x[1])

flag = True
time = 0
for l in L:
    time += l[0]

    if time > l[1]:
        flag = False
        break

print("Yes" if flag else "No")


Measured memory_bytes: 83804
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);

    int fl = 0;
    for(int i=1; i<10; i++){
        if(N%i == 0 && N/i < 10){
            fl = 1;
            break;
        }
    }

    if(fl){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;

}

Measured memory_bytes: 128
use std::cmp::max;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let h: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut ans = h[0];

    for i in 0..n - 1 {
        ans += max(0, h[i + 1] - h[i]);
    }

    print!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

typedef struct{
    int top,front,right,left,back,bottom;
}Dice;

void roll(char c,Dice* d){
    int tmp;
    switch(c){
        case 'N':
        tmp=d->top;
        d->top=d->front;
        d->front=d->bottom;
        d->bottom=d->back;
        d->back=tmp;
        break;
        case 'S':
        tmp=d->top;
        d->top=d->back;
        d->back=d->bottom;
        d->bottom=d->front;
        d->front=tmp;
        break;
        case 'E':
        tmp=d->top;
        d->top=d->left;
        d->left=d->bottom;
        d->bottom=d->right;
        d->right=tmp;
        break;
        case 'W':
        tmp=d->top;
        d->top=d->right;
        d->right=d->bottom;
        d->bottom=d->left;
        d->left=tmp;
        break;
    }
    return;
}

int main(void){
    int i,l;
    char d[101];
    Dice dice;
    scanf("%d%d%d%d%d%d",&dice.top,&dice.front,&dice.right,&dice.left,&dice.back,&dice.bottom);
    getchar();
    scanf("%s",d);
    l=strlen(d);
    for(i=0;i<l;i++){
        roll(d[i],&dice);
    }
    printf("%d\n",dice.top);
    return 0;
}

Measured memory_bytes: 600
N,K = map(int,input().split())
A = list(map(int,input().split()))

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

if K > max(A):
    print("IMPOSSIBLE")
else:
    now = A[0]
    for i in range(1,N):
        now = euclid(now,A[i])

    if now == 1:
        print("POSSIBLE")
    elif K % now == 0:
        print("POSSIBLE")
    elif K in A:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 85236
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

    int water = 0, sugar = 0;
    double nodoMax = -1;
    for(int i=0; 100*a*i<=f; i++){
        int wa = 100*a*i;
        for(int j=0; wa + (100*b*j) <= f; j++){
            int wb = 100*b*j;

            // waterなしはありえない
            if (wa+wb == 0) continue;

            for(int k=0; wa+wb+(c*k) <= f; k++){
                int sc = k*c;

                if (e*(wa+wb) < sc*100) break;
                for(int l=0; wa+wb+sc+(d*l) <= f; l++){
                    int sd = l*d;

                    if(wa+wb+sc+sd==0) continue;

                    if (e*(wa+wb) < 100*(sc+sd)) break;

                    double nodo = (sc+sd)*1000000/(wa+wb+sc+sd);
                    if(nodoMax < nodo){
                        nodoMax = nodo;
                        water = wa+wb;
                        sugar = sc+sd;
                    }
                }
            }
        }
    }

    cout << water+sugar << ' ' << sugar << endl;
    return 0;
}


Measured memory_bytes: 256
def ARC082D():
    N = int(input())
    p = list(map(int, input().split()))
    cnt = 0
    if p[N - 1] == N:
        #print(p[N - 1], N)
        p[-2], p[-1] = p[-1], p[-2]
        cnt += 1

    for i in range(N - 1):
        if p[i] == i + 1:
            p[i], p[i + 1] = p[i + 1], p[i]
            cnt += 1
    print(cnt)
ARC082D()

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; 
  string s;
  cin >> n >> s;

  if(n >= s.size()) {
    cout << s;
  }else {
    rep(i, n) {
      cout << s[i];
    }
    cout << "...";
  }
}

  


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

    ll n,r;
    cin>>n>>r;

    if(n >= 10) cout<<r<<endl;
    else{
        // d = i-100*(10-n)
        cout<< r + 100 * (10-n) <<endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 256
[n, m, l] = [int(x) for x in raw_input().split()]

A = []
B = []
counter = 0
while counter < n:
    A.append([int(x) for x in raw_input().split()])
    counter += 1

counter = 0
while counter < m:
    B.append([int(x) for x in raw_input().split()])
    counter += 1

B = list(zip(*B))

for i in range(n):
        print(' '.join([str(x) for x in [sum([x[0] * x[1] for x in zip(A[i], B[j])]) for j in range(l)]]))

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

int main(){
  int x;
  cin>>x;
  vector<bool>expo(x+1);
  expo[1]=1;
  for(int b=2;b<x;b++){
    int v=b*b;
    while(v<=x){
      expo[v]=1;
      v*=b;
    }
  }
  for(int i=x;i>=1;i--){
    if(expo[i]){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int K, X;

int main() {
	cin >> K >> X;
	if (K * 500 >= X)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 200000

/*typedef struct node {
  int pa;
  int left;
  int right;
  int key;
} Tree;
*/
int pa(int x) {return x/2;}
int le(int x) {return x*2;}
int ri(int x) {return x*2+1;}

int main()
{
  int H,i,n[N];
  
  
  scanf("%d",&H);

  for(i=1; i<=H; i++)
    {
      scanf("%d",&n[i]);
    }

  for(i=1; i<=H; i++)
    {
      printf("node %d: key = %d, ",i,n[i]);

      if(pa(i) >= 1) printf("parent key = %d, ",n[pa(i)]);

      if(le(i) <= H) printf("left key = %d, ",n[le(i)]);

      if(ri(i) <= H) printf("right key = %d, ",n[ri(i)]);

      printf("\n");
    }

  return 0;
}

  
	   




Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] d = S.toCharArray();
        int[] red = new int[N];
        int[] green = new int[N];
        int[] blue = new int[N];
        for (int i = 0; i < N; i++) {
            if (d[i] == 'R') {
                red[i] = 1;
            }
            if (d[i] == 'G') {
                green[i] = 1;
            }
            if (d[i] == 'B') {
                blue[i] = 1;
            }
        }
        int[] sum_red = new int[N+1];
        for (int i = 1; i <= N; i++) {
            sum_red[i] = sum_red[i-1] + red[i-1];
        }
        int[] sum_green = new int[N+1];
        for (int i = 1; i <= N; i++) {
            sum_green[i] = sum_green[i-1] + green[i-1];
        }
        int[] sum_blue = new int[N+1];
        for (int i = 1; i <= N; i++) {
            sum_blue[i] = sum_blue[i-1] + blue[i-1];
        }
        long ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (d[i] == d[j]) {
                    continue;
                }
                int k = j + (j - i);
                if (d[i] != 'R' && d[j] != 'R') {
                    ans += sum_red[N] - sum_red[j+1];
                }
                if (d[i] != 'G' && d[j] != 'G') {
                    ans += sum_green[N] - sum_green[j+1];
                }
                if (d[i] != 'B' && d[j] != 'B') {
                    ans += sum_blue[N] - sum_blue[j+1];
                }
                if (N <= k) {
                    continue;
                }
                if (d[i] != d[k] && d[j] != d[k]) {
                    ans -= 1;
                }
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 28696
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n, a2, a4, a1 int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		t := nextInt(sc)
		if t%4 == 0 {
			a4++
		} else if t%2 == 0 {
			a2++
		} else {
			a1++
		}
	}
	if a2 > 0 {
		a1++
	}
	// fmt.Println("a4", a4, "a2", a2, "a1", a1)
	if a4+1 >= a1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2176
x, k, d = map(int, input().split())
if x < 0:
    x *= (-1)
if (x - (k * d)) > 0:
    ans = x - (k * d)
else:
    if k % 2 == 1:
        x -= d
        k -= 1
    if (x - (k * (d * 2))) > 0:
        ans = x - (k * (d * 2))
    else:
        ans = min(abs(2 * d - (x % (d * 2))), x % (d * 2))
print(ans)    

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int a[1010101],n;
inline void doit(){
	int G=a[1];
	for (int i=2;i<=n;i++) G=__gcd(G,a[i]);
	for (int i=1;i<=n;i++) a[i]/=G;
}
signed main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (bool cur=0;;cur^=1){
		int flag1=0,cnt_e=0,cnt_o=0,pos1=0;
		for (int i=1;i<=n;i++){
			cnt_e+=!(a[i]%2),cnt_o+=a[i]%2,flag1|=(a[i]==1);
			if (a[i]&1) pos1=i;
		}
		if (flag1){
			puts((cnt_e&1)^cur?"First":"Second");return 0;
		}
		if (cnt_e&1){
			puts(cur?"Second":"First");return 0;
		}else{
			if (cnt_o==1) a[pos1]--,doit();
			else{
				puts(cur?"First":"Second");return 0;
			}
		}
	}
    return 0;
}


Measured memory_bytes: 4024
/**
  *    █████╗  ██████╗       ██████╗ ██╗     ███████╗
  *   ██╔══██╗██╔════╝       ██╔══██╗██║     ╚══███╔╝
  *   ███████║██║            ██████╔╝██║       ███╔╝
  *   ██╔══██║██║            ██╔═══╝ ██║      ███╔╝
  *   ██║  ██║╚██████╗▄█╗    ██║     ███████╗███████╗
  *   ╚═╝  ╚═╝ ╚═════╝╚═╝    ╚═╝     ╚══════╝╚══════╝
  *
  *  @Author: TieWay59
  *  @Created: 2020/8/15 21:20
  *  @Link: https://atcoder.jp/contests/agc047/tasks/agc047_a
  *  @Tags:
  *
  *******************************************************/

#include <bits/stdc++.h>

#ifdef DEBUG

#   include "libs59/debugers.h"
//  #define debug(x)  cerr <<#x << " = "<<x<<endl;
#else
#   define endl '\n'
#   define debug(...)
#   define max(x,y) ((x)>(y)?(x):(y))
#   define min(x,y) ((x)>(y)?(y):(x))
#endif

#define STOPSYNC ios::sync_with_stdio(false);cin.tie(nullptr)
#define MULTIKASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
typedef long long ll;
const int MAXN = 2e5 + 59;
const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll llINF = 0x3F3F3F3F3F3F3F3F;
using namespace std;
using pii = pair<int, int>;
using vint = vector<int>;

ll fpow(ll a, ll b, ll mod = MOD) {
    if (a % mod == 0) return 0;
    ll ret = 1;
    a %= mod;
    while (b) {
        if (b & 1)ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}


void solve(int kaseId = -1) {
    int n;
    cin >> n;
    map<pair<ll, ll>, ll> cnt;
    for (int i = 1; i <= n; ++i) {
        long double ai;
        cin >> ai;
        ll val = (ll) round(ai * 1000000000.0);
        ll cnt2 = 0;
        ll cnt5 = 0;
        while (val % 2 == 0) {
            cnt2++;
            val /= 2;
        }
        while (val % 5 == 0) {
            cnt5++;
            val /= 5;
        }
        cnt[make_pair(cnt2, cnt5)]++;
    }

    ll ans = 0;
    for (const auto &pi: cnt) {
        for (const auto &pj: cnt) {
            if (pi.first.first + pj.first.first >= 18 &&
                pi.first.second + pj.first.second >= 18) {
                if (pi == pj) {
                    ans += pi.second * (pi.second - 1ll);
                } else {
                    ans += pi.second * 1ll * pj.second;
                }
            }
        }
    }
    debug(cnt);

    cout << ans / 2 << endl;
}

void solves() {
    MULTIKASE {
        solve(kase);
    }
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r+", stdin);
#endif
    STOPSYNC;
    solve();
    return 0;
}
/*

 */

Measured memory_bytes: 3748