akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  string a,b,c;
  cin>>a>>b>>c;
  char tern='a';
  int num1=a.size(),num2=b.size(),num3=c.size();
  while(1){
    if(tern=='a'){
      tern=a[a.size()-num1];
      num1=num1-1;
    }else if(tern=='b'){
      tern=b[b.size()-num2];
      num2=num2-1;
    }else{
      tern=c[c.size()-num3];
      num3=num3-1;
    }

    if(tern=='a'&&num1==0){
      cout<<"A"<<endl;
      break;
    }
    if(tern=='b'&&num2==0){
      cout<<"B"<<endl;
      break;
    }
    if(tern=='c'&&num3==0){
      cout<<"C"<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<u64>();
    let mut tmp = a[0];
    for i in 1..n {
        tmp ^= a[i];
    }
    for i in 0..n {
        a[i] ^= tmp;
        print!("{} ", a[i]);
    }
    println!("");
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 5808
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,ans=1;
  std::cin>>n;

  ll pool[2]={0,0};

  std::vector<P> a(2*n);

  rep(i,0,n){
    ll temp;
    std::cin>>temp;
    a[i]=P(temp,0);
  }
  rep(i, 0, n) {
    ll temp;
    std::cin >> temp;
    a[n+i] = P(temp, 1);
  }

  std::sort(all(a));

  rep(i,0,2*n){
    ll type=a[i].second;
    if(pool[type^1]==0){
      pool[type]++;
    }else{
      ans=(ans*pool[type^1])%MOD;
      pool[type^1]--;
    }
  }

  std::cout<<ans;

  return 0;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a>c&&c>b){
    cout<<"Yes"<<endl;
  }
  else if(a<c&&c<b){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]
result = "No"
if c[2][0]-c[1][0] == c[2][1]-c[1][1] == c[2][2]-c[1][2]:
    if c[1][0]-c[0][0] == c[1][1]-c[0][1] == c[1][2]-c[0][2]:
        if c[0][2]-c[0][1]==c[1][2]-c[1][1]==c[2][2]-c[2][1]:
            if c[0][1]-c[0][0]==c[1][1]-c[1][0]==c[2][1]-c[2][0]:
                result = "Yes"
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int mod = 1000000007;

long long pw(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1ll) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

const int N = 111111;
int sz[N];
vector<int> a[N];

void dfs(int v, int p = -1) {
	sz[v] = 1;
	for (int x : a[v]) {
		if (x == p) {
			continue;
		}
		dfs(x, v);
		sz[v] += sz[x];
	}
}

int main() {
	int n = nxt();
	vector<vector<int>> ed(n - 1);
	for (int i = 0; i < n - 1; ++i) {
		int x = nxt() - 1, y = nxt() - 1, z = nxt();
		ed[i] = {x, y, z};
	}
	for (auto v : ed) {
		a[v[0]].push_back(v[1]);
		a[v[1]].push_back(v[0]);
	}

	dfs(0);
	long long ans = 0;
	for (auto v : ed) {
		int cn = min(sz[v[0]], sz[v[1]]);
		ans += 2ll * v[2] * min(cn, (n - cn));
	}

	int v = 0;
	int p = -1;
	while (true) {
		bool ok = false;
		for (int x : a[v]) {
			if (x == p) {
				continue;
			}
			if (2 * sz[x] == n) {
				int i = 0;
				while ((ed[i][0] != v || ed[i][1] != x) && (ed[i][0] != x || ed[i][1] != v)) {
					++i;
				}
				ans -= ed[i][2];
				cout << ans << "\n";
				return 0;
			}
			if (2 * sz[x] > n) {
				p = v;
				v = x;
				ok = true;
				break;
			}
		}
		if (!ok) {
			break;
		}
	}

	long long mn = LLONG_MAX;
	for (auto w : ed) {
		if (w[0] == v || w[1] == v) {
			mn = min(mn, 1ll * w[2]);
		}
	}

	ans -= mn;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 17152
//
// Created by MengHaitao on 2019/11/27 0027.
//

#include <iostream>
using namespace std;
int n,t,count;
bool isPrime (int number) {
    if(number<2)return false;
    for (int i = 2; i*i <= number; ++i) {
        if(number%i==0)return false;
    }
    return true;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin>>t;
        if(isPrime(t)) count++;
    }
    cout<<count<<endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3096
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inline flip f a b = f b a  

// memoization
let inline memo size f =
  let dp = Array.create size None
  let rec g x =
    match dp.[x] with
    | None ->
      let v = f g x
      dp.[x] <- Some v
      v
    | Some v -> v
  g

let inline memo2 size1 size2 f =
  let dp = Array2D.create size1 size2 None
  let rec g x y =
    match Array2D.get dp x y with
    | None ->
      let v = f g x y
      Array2D.set dp x y (Some v)
      v
    | Some v -> v
  g

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

let (N, M) = readInts () |> pair

let count n = 
  seq {
    for i in 1..n do
      for j in (i+1)..n do
        yield ()
  }
  |> Seq.length

count N + count M
|> printfn "%d"



Measured memory_bytes: 14044
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APoor solver = new APoor();
        solver.solve(1, in, out);
        out.close();
    }

    static class APoor {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a[] = new int[3];
            for (int i = 0; i < 3; i++) a[i] = in.nextInt();
            Arrays.sort(a);
            if (a[0] == a[1] && a[0] != a[2]) {
                out.println("Yes");
                return;
            }
            if (a[1] == a[2] && a[1] != a[0]) {
                out.println("Yes");
                return;
            }
            out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21332
import itertools

N,M,R = map(int,input().split())
r = list(map(lambda x:int(x)-1,input().split()))
ABC = [list(map(int,input().split())) for _ in range(M)]
INF = 10**7
d = [[INF]*N for _ in range(N)]

for A,B,C in ABC:
    d[A-1][B-1] = C
    d[B-1][A-1] = C
for k in range(N):
    for i in range(N):
        for j in range(i+1,N):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])
            d[j][i] = d[i][j]
ans = INF * M
for r in itertools.permutations(r):
    S = 0
    for i,ri in enumerate(r[:-1]):
        S += d[ri][r[i+1]]
    ans = min(ans,S)
print(ans)


Measured memory_bytes: 49624
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	final int LEN = 0;

	void doIt() {
		double n = sc.nextDouble();
		for(int i = 1; i < 50000; i++) {
			int x = (int)Math.floor((double)i * 1.08);
			if(x == n) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(":(");
	}

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


Measured memory_bytes: 24016
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const ll MAX = 510000;
ll 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 COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void solve(){
    ll n, k; cin >> n >> k;
    COMinit();
    ll res = 0;
    ll lim = min(k, n-1);
    for(ll z=0; z<=lim; z++){
        res += (COM(n, z) * COM(n-1, n-z-1))%MOD;
        res = res%MOD;
    }
    cout << res << endl;
}

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

Measured memory_bytes: 12160
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

K = I()
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[K-1])

Measured memory_bytes: 38384
#include <stdio.h>


int main(void)
{
  int a[6] = {};
  int i = 0;
  double x,y;
  
  while (scanf("%d", &a[0])!= EOF){
    for(i = 1; i < 6; i++)
      scanf("%d", &a[i]);
    y = 1.0 *( a[3]*a[2] - a[0]*a[5] )/( a[3] * a[1]- a[0] * a[4]);
    x = 1.0 *( a[2] - a[1]*y ) / a[0];
    
    printf("%.3f %.3f\n",x ,y);
  }
    
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define _GLIBCXX_DEBUG
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  int n,m;cin >> n >> m;
  int Ans = 0;
  Ans += n*(n-1)/2;
  Ans += m*(m-1)/2;
  cout << Ans << endl;
}


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

string to_s(int n) {
	ostringstream os;
	os << n;
	return os.str();
}

string square(string fst, int remain, int lim) {
//	cout << "square: ";
//	cout << fst << ' ' << remain << ' ' << lim << endl;
	ostringstream os;
	if (remain == 0) {
		os << fst << endl;
		return os.str();
	}
	for (int i = min(remain, lim); 1 <= i; i--) {
		os << square(fst+" "+to_s(i), remain-i, min(i, lim));
	}
	return os.str();
}

int main() {
	int n;
	while (cin >> n, n) {
		for (int i = n; 1 <= i; i--) {
			cout << square(to_s(i), n-i, i);
		}
	}
	return 0;
}

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

#define ll long long int

int main() {
    ll x, s=0; cin >> x;

    for (int i = 1; i <=x; i++)
        for (int j = 1; j <=x; j++)
            for (int k = 1; k <=x; k++)
                s+= __gcd(__gcd(i,j), k);
    cout << s;
    
}

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

using namespace std;

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

    long n;
    cin >> n;
    char s[n];
    cin >> s;
    // scanf("%s", &s);
    long right_e = 0;
    for (long i = 1; i < n; i++) right_e += (s[i] == 'E');
    long min_count = right_e;
    // long left_w = 0;
    for (long i = 1; i < n; i++) {
        if (!min_count) break;
        right_e -= s[i] == 'E';
        right_e += s[i - 1] == 'W';
        min_count = min(min_count, right_e);
    }
    // cout << min_count << endl;
    cout << min_count << '\n';

    return 0;
}

Measured memory_bytes: 512
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n >> k;
  rep(i, k) {
    cin >> a;
    mp[a]++;
  }
  rrep(i, n, n + ohara) {
    s = to_string(i);
    int ok = 1;
    rep(j, Size(s)) {
      if (mp[(s[j] - '0')]) ok = 0;
    }
    if (!ok) continue;
    Cout(s);
    return 0;
  }
  return 0;
}

Measured memory_bytes: 384
def main():
    N = int(input())
    assert N % 2 == 1
    M = (N + 1) // 2
    P = list(map(float, input().split(' ')))
    dp = [[0 for _ in range(M + 1)] for _ in range(N)]
    dp[0][0] = 1 - P[0]
    dp[0][1] = P[0]
    for n in range(1, N):
        p = P[n]
        for m in range(min([n + 1, M]) + 1):
            if 1 <= m < M:
                dp[n][m] = dp[n - 1][m] * (1 - p) + dp[n - 1][m - 1] * p
            elif m == M:
                dp[n][m] = dp[n - 1][m] + dp[n - 1][m - 1] * p
            else:
                # m == 0
                dp[n][m] = dp[n - 1][m] * (1 - p)
    print(dp[-1][-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 121716
#include<iostream>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    int ara[n];
    for(int i=0;i<n;i++) cin>>ara[i];
    for(int i=0;i<n;i++){
        sum+=(ara[i]-1);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
n,x,m = map(int,input().split())
mod = m
ans = 0
bit = [-1 for i in range(m)]
cycle = False
for i in range(n):
    if i == 0 :
        a = x
        bit[a] = i
        ans += a
    else:
        a = (a**2)% mod
        if bit[a] != -1:
            cy_st = bit[a]
            cy_fi = i -1
            cycle = True
            break
        else:
            bit[a] = i
            ans += a

if cycle:
    ans2 = 0
    b =  -1
    for j in range(cy_st):
        if j == 0 :
            b = x
            ans2 += b
        else:
            b = (b**2)% mod
            ans2 += b
    cy_num = ans - ans2
    cy_repe = (n-cy_st) // (cy_fi - cy_st + 1)
    ans3 = cy_num * cy_repe
    cy_amari = (n-cy_st) % (cy_fi - cy_st + 1)
    
    if b == -1:
        for j in range(cy_amari):
            if j == 0 :
                b = x
                ans3 += b
            else:
                b = (b**2)% mod
                ans3 += b
        
    else:
        for i in range(cy_amari):
            b = (b**2)% mod
            ans3 += b

    print(ans2+ans3)
else:
    print(ans)


Measured memory_bytes: 11396
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define MAXCHAR 255

using namespace std;

vector<long> Height;
map<long, long> IndexHeightDif;

int main()
{
	int input = 0;
	cin >> input;
	long output = 0;
	for (int i = 0; i < input; i++)
	{
		long heightInput = 0;
		cin >> heightInput;
		Height.push_back(heightInput);

		output += IndexHeightDif[i - heightInput];
		IndexHeightDif[i + heightInput] += 1;
	}

	cout << output << endl;

	return 0;
}

Measured memory_bytes: 27400
#include <cstdio>
#include <algorithm>
using namespace std;

int w[10],k[10];

int main(){
	for(int i = 0; i < 10; i++){
		scanf("%d",&w[i]);
	}
	for(int i = 0; i < 10; i++){
		scanf("%d",&k[i]);
	}
	sort(w,w+10);
	sort(k,k+10);
	printf("%d %d\n",w[9]+w[8]+w[7],k[9]+k[8]+k[7]);
	return 0;
}

Measured memory_bytes: 2648
import itertools
S = input()
plus_list = list(itertools.product([0, 1], repeat=len(S) - 1)) #0:+を入れない, 1:+を入れる

res = 0

for plus in plus_list:
    res_list = []
    tmp = 0
    for i in range(len(S) - 1):
        if plus[i] == 1:
            res += int(S[tmp:i+1])
            tmp = i + 1
    res += int(S[tmp:])
            
print(res)

Measured memory_bytes: 3060
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
	if (u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}
int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
	if (T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}
int getSibling(int u) {
	if (T[u].parent == NIL) return NIL;
	if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
	if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
	return NIL;
}
void print(int u) {
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if (T[u].left != NIL) deg++;
	if (T[u].right != NIL) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);
	if (T[u].parent == NIL) printf("root\n");
	else if (T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
	else printf("internal node\n");
}

int main() {
	int v, l, r, root = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) T[i].parent = NIL;
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if (l != NIL)T[l].parent = v;
		if (r != NIL)T[r].parent = v;
	}
	for (int i = 0; i < n; i++) if (T[i].parent == NIL) root = i;
	setDepth(root, 0);
	setHeight(root);
	for (int i = 0; i < n; i++) print(i);
	return 0;
}


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

vector<vector<int> > G(2e5 + 1);
vector<int> res(2e5 + 1);

void dfs(int i, int p) {
	for (int x : G[i]) {
		if (x == p) continue ;
		res[x] += res[i];
		dfs(x, i);
	}
}

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n, q; cin >> n >> q;
	REP(i, n - 1) {
		int a, b; cin >> a >> b;
		G[--a].push_back(--b);
		G[b].push_back(a);
	}
	REP(i, q) {
		int p, x; cin >> p >> x;
		res[--p] += x;
	}
	dfs(0, 0);
	REP(i, n) cout << res[i] << " ";
	return 0;
}

Measured memory_bytes: 24304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    while(cin >> s){
        int ans = count(ALL(s), 'x') < 8;
        cout << (ans ? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	cin >> str;
	long long sum = 0;
	long long x = 0;
	for(int i = 0;i < str.size();i++)
	    {
	    	sum = sum + (str[i] - '0');
		}
	for(int i = 0;i < str.size();i++)
	    {
	    	x = x * 10 + (str[i] - '0');
		}
	if(x % sum == 0)
	    {
	    	cout << "Yes" << endl;
		}
		else
		    {
		    	cout << "No" << endl;
			}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = [int(i) for i in input().split()]

ans = 0

    
for i in range(N-2):
    L1 = L[i]
    for j in range(i+1,N-1):
        L2 = L[j]
        for k in range(j+1,N):
            L3 = L[k]
            if L1==L2 or L2==L3 or L3==L1:
                continue
            if(L1+L2>L3) and (L2+L3>L1) and (L3+L1>L2):
                ans+=1
print(ans)
            

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

vector<int> h;
int dp[100002];

int main() {
	int n; cin >> n; h.resize(n);
	for (auto &x : h) { cin >> x; }
	h.resize(n + 2, 1 << 30);
	fill(dp, dp + n + 2, 1 << 30);
	dp[0] = 0; for (int i = 0; i < n; i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
	}
	cout << dp[n - 1] << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 3928
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr double DINF =100000000000000000.0;
constexpr long long INF = 100000000000000000;
const double PI = acos(-1);
 
int main() {
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.emplace_back(a);
	}
	sort(v.begin(), v.end());
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		if (*lower_bound(v.begin(), v.end(), a) != a) {
			cout << "NO" << endl;
			return 0;
		}
		else {
			v.erase(lower_bound(v.begin(), v.end(), a));
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1400
#include<iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    string s;
    cin >> s;
    int Counter = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            Counter += 1;
        }
    } 

    cout << Counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define rep(i, b) for (__typeof(b) i = 0; i < b; i++)
#define repo(i, a, b) for (__typeof(a) i = a; i <= b; i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
ll v[200005];
int main()
{
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    ll m = 1e9, l = k - 1;
    rep(i, n - k + 1)
    {
        m = min(m, abs(a[i] - a[l]));
        l++;
    }
    cout << m;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 1e9+7;


void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
///--//
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */
    int n; cin>>n;
    vector<int> cnt(1e5+10,0);
    vector<int> sq;
    for(int i=1 ; i<=100; i++){
        sq.push_back(i);
    }
    for(int x : sq) {
        for(int y : sq){
            for(int z : sq){
                cnt[x*x+y*y+z*z+x*y+x*z+y*z]++;
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout<<cnt[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,l;
	while(cin>>n>>l,n,l){
		bool f=false;
		int s1,s2;
		vector<int> data;
		data.push_back(n);
		for(int times=0;times<20;times++){
			int num=data[times];
			vector<int> a;
			for(int i=0;i<l;i++){
				a.push_back(num%10);
				num/=10;
			}
			sort(a.begin(),a.end());
			num=0;
			int k=1;
			for(int i=0;i<l;i++){
				num+=(a[i]-a[l-i-1])*k;
				k*=10;
			}
			for(int i=0;i<data.size();i++){
				if(num==data[i]){
					cout<<i<<" "<<num<<" "<<data.size()-i<<endl;
					f=true;
					break;
				}
			}
			if(f)break;
			data.push_back(num);
		}
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
const int MAX_NUM = 36+7;
struct card{
	char suit;
	int value;
};
struct card cards1[MAX_NUM];
struct card cards2[MAX_NUM];
int N;
void BubbleSort(){
	int i;
	for(i = 0;i<N;i++){
		int j;
		for(j = N-1;j>=i+1;j--){
			if(cards1[j].value < cards1[j-1].value){
				swap(cards1[j],cards1[j-1]);
			}
		}
	}
} 
void SelectionSort(){
	int i;
	for(i = 0; i <N-1;i++){
		int min_i = i;
		int j;
		for(j = i+1;j<N;j++){
			if(cards2[j].value<cards2[min_i].value){
				min_i = j;
			}
		}
		swap(cards2[min_i],cards2[i]);
	}
}
int main(){
	cin >> N;
	scanf("\n");
	
	int i;
	for(i = 0; i<N;i++){
		scanf("%c%d", &cards1[i].suit,&cards1[i].value);
		cards2[i].suit = cards1[i].suit;
		cards2[i].value = cards1[i].value;
		if(i<N-1) scanf(" ");
	}
	
	BubbleSort();
	SelectionSort();
	for(i = 0; i<N;i++){
		if(i!=0) cout << " ";
		cout <<  cards1[i].suit << cards1[i].value;
	}
	cout << endl;
	cout << "Stable" << endl;
	int flag = 0;
	for(i = 0; i<N;i++){
		if(cards1[i].suit!=cards2[i].suit){
			flag = 1;
			break;
		}
	}
	for(i = 0; i<N;i++){
		if(i!=0) cout << " ";
		cout <<  cards2[i].suit << cards2[i].value;
	}
	cout << endl;
	if(flag==0){
		cout << "Stable" << endl;
	} else{
		cout << "Not stable" << endl;
	}
	
	return 0;
	
} 


Measured memory_bytes: 3240
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    u64 T;
    cin >> T;

    //vector<u64> ans(T);

    for(u64 t=0; t<T; t++) {
        u64 N;
        cin >> N;

        priority_queue<pair<u64, u64>> lside;
        priority_queue<pair<u64, u64>> rside;
        u64 t_ans = 0;

        for(uint n=0; n<N; n++) {
            u64 K, L, R;
            cin >> K >> L >> R;
            t_ans += min(L, R);

            if(L > R) {
                lside.push(make_pair(K, L-R));
            } else {
                // HACK : sort order defalut is N to M (N > M)
                rside.push(make_pair(N-K, R-L));
            }
        }
    
        priority_queue<u64> lcdt;
        for(u64 l=lside.size(); l>0; l--) {
            while(!lside.empty() && l <= lside.top().first) {
                lcdt.push(lside.top().second);
                lside.pop();
            }
            if(!lcdt.empty()) {
                t_ans += lcdt.top();
                lcdt.pop();
            }   
        }
        
        priority_queue<u64> rcdt;
        for(u64 r=rside.size(); r>0; r--) {
            while(!rside.empty() && r <= rside.top().first) {
                rcdt.push(rside.top().second);
                rside.pop();
            }
            if(!rcdt.empty()) {
                t_ans += rcdt.top();
                rcdt.pop();
            }   
        }

        //ans[t] = t_ans;
        cout << t_ans << endl;
    }


    //for(const auto a : ans) cout << a << endl;
    return 0;
}

Measured memory_bytes: 8276
#include <iostream>

using namespace std;

int main(){
    long long X,Y;
    cin >> X >> Y;
    long long  count = 1;
    long long tmp = X;
    while(true){
        tmp *= 2;
        if(tmp>Y)break;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int,input().split())

x3 = x2 - (y2 - y1)
y3 = y2 - (x1 - x2)
x4 = x3 + (x1 - x2)
y4 = y3 - (y2 - y1)

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

#define PI 3.141592653589793


int main(int argc, const char * argv[]) {
    int a,b,c;
    double s,l,h;
    
    scanf("%d%d%d",&a,&b,&c);
    
    s = sin(c * PI / 180.0)*a*b/2;
    l = a + b + sqrt(a*a + b*b - 2*a*b * cos(c * PI / 180.0));
    h = s/a*2;
    
    printf("%lf %lf %lf\n" ,s,l,h);
    
    return 0;
    
}


Measured memory_bytes: 2128
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define num_points_max 100000

typedef struct
{
	int time;
	int rcdx;
	int rcdy;
} coordinate;

typedef struct
{
	int        num_points;
	coordinate way_point[num_points_max + 1];
} abc086c_t;

bool IsPossible (const abc086c_t * const given_data)
{
	// local variables for this function
	coordinate displacement;
	int        distance;

	for (int iter = 1; iter <= (*given_data).num_points; ++iter)
	{
		displacement.time = (*given_data).way_point[iter].time - (*given_data).way_point[iter - 1].time;
		displacement.rcdx = (*given_data).way_point[iter].rcdx - (*given_data).way_point[iter - 1].rcdx;
		displacement.rcdy = (*given_data).way_point[iter].rcdy - (*given_data).way_point[iter - 1].rcdy;

		distance = abs(displacement.rcdx) + abs(displacement.rcdy);

		if (distance > displacement.time)
		{
			return false;
		}
		else if (distance % 2 != displacement.time % 2)
		{
			return false;
		}
		else
		{
			continue;
		}
	}

	return true;
}

void ABC086C (const abc086c_t * const given_data)
{
	if   ( IsPossible(given_data) ) printf( "Yes\n" );
	else                            printf(  "No\n" );
}

int main (void)
{
	// variables for `main`
	abc086c_t given_data;
	int       retval_scanf;

	// STEP.01
	// read out the given data
	retval_scanf = scanf("%d", &given_data.num_points);

	given_data.way_point[0].time = 0;
	given_data.way_point[0].rcdx = 0;
	given_data.way_point[0].rcdy = 0;

	for (int iter = 1; iter <= num_points_max; ++iter)
	{
		retval_scanf =
			scanf(
				"%d %d %d",
				&given_data.way_point[iter].time,
				&given_data.way_point[iter].rcdx,
				&given_data.way_point[iter].rcdy
			);
	}

	// STEP.02
	// calculate & output the answer
	ABC086C(& given_data);

	// STEP.END
	return EXIT_SUCCESS;
}

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

using namespace std;

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

  string s;
  cin >> s;
  if ((s.size() % 2 == 0) ^ (s[0] == s[s.size() - 1])) {
    cout << "Second\n";
  } else {
    cout << "First\n";
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n;
struct a{
    int x,y,t;
}m[100005];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x,y,t;
        cin>>t>>x>>y;
        m[i].x=x,m[i].y=y,m[i].t=t;
    }
    m[0].x=0,m[0].y=0,m[0].t=0;
    for(int i=1;i<=n;i++)
    {
        int s,t;
        s=abs(m[i].x-m[i-1].x)+abs(m[i].y-m[i-1].y);
        t=abs(m[i].t-m[i-1].t);
        if(s>t||s%2!=t%2)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll h,a;
	cin>>h>>a;
	cout<<(h+a-1)/a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll N;
    INX(N);

    vll c(4, 0);
    for (ll i = 0; i < N; i++)
    {
        string tmp;
        INX(tmp);

        if(tmp == "AC")
        {
            c[0]++;
        }
        else if(tmp == "WA")
        {
            c[1]++;
        }
        else if(tmp == "TLE")
        {
            c[2]++;
        }
        else
        {
            c[3]++;
        }
    }
    
    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;
    


    return 0;
}


Measured memory_bytes: 3628
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s,t string
    fmt.Scan(&s,&t)
    ans := "No"
    s = sortString(s)
    t = reverseString(sortString(t))
    if s < t{
        ans = "Yes"
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PR pair<int, int>
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
//constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//
int a[100010];
int b[100010];
signed main()
{
  ios();
  int N,H;
  cin >> N >> H;
  rep(i,N) cin >> a[i] >> b[i]; 
  int max = 0;
  rep(i,N){
    chmax(max,a[i]);
  }  
  sort(b,b+N,greater<int>());
  int cnt = 0;
  rep(i,N)
  {
    if(b[i] <= max) break;
    H -= b[i];
    cnt ++ ;
    if(H <= 0) 
    {
      cout << cnt <<endl;
      return 0;
    }
  }
  cout << (H-1) / max + 1  + cnt << endl;
}

//N縺薙・荳ｭ縺九ｉ騾｣邯壹☆繧橘蛟九ｒ驕ｸ縺ｶ縺ｨ縺阪・驕ｸ縺ｳ譁ｹ縺ｯ髯舌ｌ繧峨ｌ繧九・ S T L

//驛ｨ蛻・・譛蟆丞､
//譖ｴ譁ｰ縺励↑縺・ｴ蜷遺・邏ｯ遨阪ｏ REP(i,N) ruiseki[i+1] += ruiseki[i];
//莠梧ｬ｡蜈・↓縺励◆縺・・縺・ｂ縺呎ｳ・
//荳邂・園繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Segment Tree(縺溘□縺怜叙蠕涌(logN))
//遽・峇繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Lazy Segment Tree


Measured memory_bytes: 1792
require 'prime'

N = gets.to_i
A = gets.split.map(&:to_i)

gcd = A[0]
listLR = [gcd]

(1...N).each do |i|
  gcd = gcd.gcd(A[i])
  listLR << gcd
end

gcd = A[-1]
listRL = []

(N - 1).downto(0) do |i|
  gcd = gcd.gcd(A[i])
  listRL.unshift(gcd)
end

v1 = listLR[-2]
v2 = listRL[1]

v3 = -1

1.upto(N - 2) do |i|
  gcd = listLR[i - 1].gcd(listRL[i + 1])
  v3 = gcd if v3 < gcd
end

puts [v1, v2, v3].max


Measured memory_bytes: 10920
#include <iostream>

using namespace std;

typedef long long int lli;

int mth1[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int mth2[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool check(int t)
{
	bool f = false;
	if(t%4 == 0){
		if(t%100 == 0){
			if(t%400 == 0){
				f = true;
			}
		} else {
			f = true;
		}
	}
	
	return f;
}

lli func(int y1, int m1, int d1, int y2, int m2, int d2)
{
	lli r = 0;
	int t;
	
	for(int i = y1+1; i < y2; i++){
		r += (check(i)? 366 : 365);
	}
	if(check(y1)){
		t = 366;
		for(int i = 1; i < m1; i++){
			t -= mth2[i];
		}
	} else {
		t = 365;
		for(int i = 1; i < m1; i++){
			t -= mth1[i];
		}
	}
	t -= d1;
	r += t;
	t = 0;
	if(check(y2)){
		for(int i = 1; i < m2; i++){
			t += mth2[i];
		}
	} else {
		for(int i = 1; i < m2; i++){
			t += mth1[i];
		}
	}
	t += d2;
	r += t;
	if(y1 == y2){
		r -= (check(y1)? 366 : 365);
	}
	
	return r;
}

int main()
{
	int y1, y2, d1, d2, m1, m2;
	
	while(cin>>y1>>m1>>d1>>y2>>m2>>d2 && y1 != -1){
		cout << func(y1, m1, d1, y2, m2, d2) << endl;
	}
	
	return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e9;
const int N = (int)1e5+5;
const int K = 105;
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n;
int k;
int dp[N];
int a[N];
int solve(int idx){
    if(idx>n)return OO;
    if(idx==n-1)
        return 0;
    int &ret = dp[idx];
    if(~ret)
        return ret;
    ret =OO;
    for (int i = 1; i <= k; i++){
        ret = min(ret, solve(idx + i) + abs(a[idx + i] - a[idx]));
    }
    return ret;
}
int dp2[N][K];
int solve_rec(int idx,int k_so_far){
    if(idx==n-1)
        return abs(a[idx]-a[idx-k_so_far]);
    if(k_so_far==k)
        return solve_rec(idx,0)+abs(a[idx]-a[idx-k_so_far]);
    int &ret = dp2[idx][k_so_far];
    if(~ret)
        return ret;
    ret = solve_rec(idx+1,k_so_far+1);
    if(k_so_far>0)
    ret = min(ret,solve_rec(idx,0)+abs(a[idx]-a[idx-k_so_far]));
    return ret ;

}  
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    scanf("%d",&n);
    scanf("%d",&k);
    memset(dp,-1,sizeof(dp));
    memset(dp2,-1,sizeof(dp2));
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
   // printf("%d\n",solve(0));    
    printf("%d\n",solve_rec(0,0));
    return 0;
}

Measured memory_bytes: 51456
<?php
fscanf(STDIN, "%d", $n);
$as = explode(' ', trim(fgets(STDIN)));

$member = array();
for ($i=1; $i <= $n; $i++) {
  $member[$i] = 0;
}

foreach ($as as $a) {
  $member[$a]++;
}

for ($i=1; $i <= $n; $i++) {
  echo $member[$i] . PHP_EOL;
}


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

int gcd( int a, int b) {

   return b ? gcd(b, a % b) : a;

} 

int main() {

    int n;
    cin >> n;

    vector<int> a(n);

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

    int GCD = a[0];

    for (int i = 1; i < n; i++) {

        GCD = gcd(GCD , a[i]); 
    }

    cout << GCD << endl;

    return 0;


    
}

Measured memory_bytes: 640
open System
open System.Collections.Generic
open System.Linq
open System

// Following contents are my library. The Main processes are on the bottom of this code.

let putn = Console.WriteLine : 'a -> unit
let put = Console.Write : 'a -> unit
let Read() = Console.ReadLine()
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])
let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)
let ReadIntTriple () = ReadTriple () |> FuncTriple int int int
let ReadIntDouble () = ReadDouble () |> FuncDouble int int
let ensmallen l = l % 1000000007L
let manhattan x y = abs (fst x - fst y) + abs (snd x - snd y)
let sayYESNO b = if b then putn "YES" else putn "NO"


// The main contents of this submission are below this line.

let s = Read()
(s |> Seq.filter ((=) '+') |> Seq.length) - (s |> Seq.filter ((=) '-') |> Seq.length) |> putn


Measured memory_bytes: 13268
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3924
#include <iostream>
#include <algorithm>

int main()
{
	int k, n;
	std::cin >> k >> n;

	int price[1000];
	int sum_price = 0;

	for (int i = 0; i < k; i++) {
		std::cin >> price[i];
	}

	std::sort(price, price + k);

	for (int i = 0; i < n; i++) {
		sum_price += price[i];
	}

	std::cout << sum_price;
}

Measured memory_bytes: 3164