akhauriyash/Code-Regression huggingface dataset:
#define  REP(i, s, e) for(register int i = s; i <= e ;i++)
#define DREP(i, s, e) for(register int i = s; i >= e ;i--)

#define DEBUG fprintf(stderr, "Passing [%s] in LINE %d\n", __FUNCTION__, __LINE__)
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

#include <bits/stdc++.h>

using namespace std;
const int maxn = 200, maxm = 200;

template <typename T> T read()
{
	T ans(0), p(1);
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-') p = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * p;
}

int m, n, ans;

string a[maxn], b[maxm];

int main()
{
#ifdef CraZYali
	freopen("b.in", "r", stdin);
	freopen("b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin >> n;
	REP(i, 1, n) cin >> a[i];
	cin >> m;
	REP(i, 1, m) cin >> b[i];
	REP(i, 1, n)
	{
		int temp = 0;
		REP(j, 1, n) temp += a[i] == a[j];
		REP(j, 1, m) temp -= a[i] == b[j];
		chkmax(ans, temp);
	}

	REP(i, 1, m)
	{
		int temp = 0;
		REP(j, 1, m) temp -= b[i] == b[j];
		REP(j, 1, n) temp += b[i] == a[j];
		chkmax(ans, temp);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const string num[10] ={
  "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101",
  "0100111", "1111111", "1101111"};

int main() {
  int N, n;
  
  while(cin >> n){
    if(n == -1) break;
    string now, after;
    
    for(int cs = 0 ; cs < n ; cs++){
      cin >> N;
      
      if(cs == 0){
	cout << num[N] << endl;
	now = num[N];
      }
      else{
	after = num[N];
	for(int i = 0 ; i < 7 ; i++){
	  if(now[i] == after[i]) cout << '0';
	  else cout << '1';
	}
	cout << endl;
	now = after;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll n, k, a[109], dp[109][100009], p[100009];
ll get(int ind) {
    if(ind == -1)
        return 0;
    return p[ind];
}
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    dp[0][0] = 1;
    for(int i=1;i<=n;i++) {
        p[0] = 1;
        for(ll candies=1;candies<=k;candies++)
            p[candies] = (p[candies - 1] + dp[i - 1][candies]) % mod;
        for(ll candies=0;candies<=k;candies++) {
            //cout<<i<<" "<<candies<<" "<<p[candies]<<" "<<a[i]<<" "<<get(max(0ll, candies-a[i]) - 1)<<endl;
            dp[i][candies] += (p[candies] - get(max(0ll, candies-a[i]) - 1));
            if(dp[i][candies] < 0)
                dp[i][candies] += mod;
            //for(int l=max(0ll, candies-a[i]);l<=candies;l++)
            //    dp[i][candies] += dp[i - 1][l];
            //for(int last = 0;last <= min(a[i], candies); last++) {
            //    dp[i][candies] += dp[i - 1][candies - last];
            //}
            //cout<<dp[i][candies]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n][k];
}


Measured memory_bytes: 82516
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N, X;
    std::cin >> N >> X;
    std::vector<int64_t> C;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        C.push_back(std::abs(t - X));
    }

    if (N > 1) {
        int64_t ans = boost::math::gcd(C[0], C[1]);
        for (size_t i = 2; i < N; ++i) {
            ans = boost::math::gcd(ans, C[i]);
        }
        std::cout << ans << std::endl;
    }
    else {
        std::cout << C[0] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, min = 10000000, kaunto = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> A;
    while (A % 2 == 0) {
      kaunto++;
      A = A / 2;
    }
    if (min > kaunto) {min = kaunto;}
    kaunto = 0;
  }
  cout << min << endl;
}

Measured memory_bytes: 3576
n, q = [int(i) for i in input().split()]
S = input()
counter = [0] * len(S)
for i in range(len(S)):
    if i == 0:
        counter[i] == 0
    elif S[i-1:i+1] == 'AC':
        counter[i] = counter[i-1] + 1
    else:
        counter[i] = counter[i-1]

counter = [0] + counter
# print(counter)


for _ in range(q):
    l, r = [int(i) for i in input().split()]
    print(counter[r] - counter[l])

Measured memory_bytes: 53820
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	if(n == m)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 3648
//
//  trick_or_treat.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define PI 3.14159265
void dfs(vector<int> A, int n, int m)  {
  if  (A.size() > n) {
    for (int i = 1; i <= n; i++) {
      std::cout << A[i];
    }
    std::cout << std::endl;
    return;
  }
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A, n, m);
    A.back()++;
  }
}

int main(int argc, const char* argv[]) {

  int n, k;
  std::cin >> n >> k;
  std::map<int, int> m;

  for (int i = 0; i < k; i++) {
    int d;
    std::cin >> d;
    for (int j = 0; j < d; j++) {
      int snuck;
      std::cin >> snuck;
      m[snuck] = 1;
    }
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if(m.count(i)==0) {
      sum++;
    }
  }
  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <map>
#include <queue>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

using P = pair<string, int>;

char getLast(char c1, char c2) {
    if (c1 > c2) swap(c1, c2);
    if (c1 == 'b' && c2 == 'g') return 'r';
    if (c1 == 'b' && c2 == 'r') return 'g';
    return 'b';
}

#include <set>
bool check(string s) {
    set<int> st;
    for(auto &c: s) {
        st.insert(c);
    }
    return st.size() == 1;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    while (cin >> s, s != "0") {
        map<string, int> mp;
        int n = s.size();
        queue<P> q;
        q.emplace(s, 0);
        int ans = -1;
        while (q.size()) {
            string e = q.front().first;
            int cnt = q.front().second;
            q.pop();
            if (check(e)) {
                ans = cnt;
                break;
            }
            mp[e] = cnt;
            REP (i, 0, n - 1) {
                if (e[i] != e[i + 1]) {
                    string tmp = e;
                    tmp[i] = tmp[i + 1] = getLast(e[i], e[i + 1]);
                    if (mp.count(tmp) == 0) {
                        q.emplace(tmp, cnt + 1);
                        mp[tmp] = cnt + 1;
                    }
                }
            }
        }
        if (ans == -1) {
            cout << "NA" << endl;
        } else {
            cout << ans << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;
// セグメント木
template<class T>
struct SegmentTree {
private:
    int n;
    vector<T> node;
	T ininum; // 初期値。区間sumなら0、区間minならINFなど
	function<T(T,T)> f; // sum,minなどの演算を設定

public:
    SegmentTree(vector<T> v, T ininum, function<T(T,T)> f) {
    	this->ininum = ininum;
    	this->f = f;
    	
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void update(int x, T val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = f(node[2*x+1], node[2*x+2]);
        }
    }

    ll get(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return ininum;
        if(a <= l && r <= b) return node[k];

        ll vl = get(a, b, 2*k+1, l, (l+r)/2);
        ll vr = get(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};




void mainsolve(){


	ll n;
	cin >> n;
	string s;
	cin >> s;
	vector<bool> dp(n,false);
	vector<SegmentTree<bool>> vseg(26, SegmentTree<bool>(dp, 0, [&](bool a, bool b){return a|b;}));

	rep(i,n){
		vseg[s[i]-'a'].update(i,true);
	}

	ll q;
	cin >> q;
	rep(i,q){
		ll j;
		cin >> j;
		if(j==1){
			ll k;
			cin >> k;
			--k;
			char c;
			cin >> c;

			vseg[s[k]-'a'].update(k,false);
			vseg[c-'a'].update(k,true);
			s[k] = c;


		}
		else{
			ll l,r;
			cin >> l >> r;
			--l; --r;
			ll res = 0;
			rep(k,26){
				if(vseg[k].get(l,r+1)) res++;
			}

			cout << res << endl;

		}
	}

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 4356
#include <stdio.h>

int main(){
    char a,b;
    scanf("%c %c",&a,&b);
    if(a == 'H'){
        if(b == 'H'){
            printf("H");
        }
        else if(b == 'D'){
            printf("D");
        }
    }
    else if(a == 'D'){
        if(b == 'H'){
            printf("D");
        }
        else if(b == 'D'){
            printf("H");
        }
    }
    return 0;
}

Measured memory_bytes: 128
year, month, day = gets.split('/').map(&:to_i)
if year > 2019
  puts 'TBD'
elsif year < 2019
  puts 'Heisei'
else
  if month > 4
    puts 'TBD'
  elsif month < 4
    puts 'Heisei'
  else
    if day > 30
      puts 'TBD'
    else
      puts 'Heisei'
    end
  end
end

Measured memory_bytes: 1788
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func main() {
	sc.Split(bufio.ScanWords)
	var tmp string
	n := nextInt()
	m := make(map[string]struct{})
	for i := 0; i < n; i++ {
		tmp = nextString()
		m[tmp] = struct{}{}
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 13932
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
 
template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}
 
//~ ifstream f(".in");
//~ ofstream g(".out");
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif
 
  int n;
  cin >> n;
  vector<int> v(n + 2);
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  
  const ll INF = 1e18L + 5;
  vector<vector<ll>> dp(n + 2, vector<ll>(n + 2, INF));
  vector<vector<ll>> a(n + 2, vector<ll>(n + 2));
  for (int i = 1; i <= n; ++i) {
    a[i][i] = v[i];
    for (int j = i + 1; j <= n; ++j) {
      a[i][j] = a[i][j - 1] + v[j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    dp[i][i] = 0;
  }
  for (int l = n; l >= 1; --l) {
    for (int r = l + 1; r <= n; ++r) {
      for (int m = l; m <= r - 1; ++m) {
        uin(dp[l][r], dp[l][m] + dp[m + 1][r] + a[l][m] + a[m + 1][r]);
      }
    }
  }
  
  cout << dp[1][n] << '\n';
  
 
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		double value = Math.log(N) / Math.log(K);

		System.out.println((int) Math.floor(value) + 1);

		sc.close();
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S; cin >> S;
    int trouts[S.size()][2];
    for (int i = 0; i < S.size(); i++) {
        if ('R' == S[i]) {
            trouts[i][0] = 0;
            trouts[i][1] = 0;
        } else {
            trouts[i][0] = 1;
            trouts[i][1] = 0;
        }
    }

    int i; i = 0;
    int sign;
    int zero_num, one_num;
    while (i < S.size()) {
        zero_num = 0;
        one_num = 0;

        sign = 0;
        while (sign == trouts[i][0]) {
            zero_num += 1;
            i++;
        }
        int zero_idx; zero_idx = i - 1;

        int one_idx; one_idx = i;
        sign = 1;
        while (sign == trouts[i][0]) {
            one_num += 1;
            if (i == S.size()) break;
            i++;
        }

        int total_num = zero_num + one_num;
        if (total_num % 2 == 0) {
            trouts[zero_idx][1] = trouts[one_idx][1] = total_num / 2;
        } else if (zero_num < one_num) {
            trouts[zero_idx][1] = total_num / 2;
            trouts[one_idx][1] = total_num / 2 + 1;
            if (zero_num % 2 != 0) swap(trouts[zero_idx][1], trouts[one_idx][1]);
        } else {
            trouts[zero_idx][1] = total_num / 2 + 1;
            trouts[one_idx][1] = total_num / 2;
            if (one_num % 2 != 0) swap(trouts[zero_idx][1], trouts[one_idx][1]);
        }
    }

    for (int i = 0; i < S.size(); i++) {
        cout << trouts[i][1] << (i < S.size() - 1 ? " " : "\n");
    }

    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

const ll MOD = 1000000007;

int main(){

    ll N;
    cin >> N;
    vector<ll>vec(N);
    for(ll i = 0; i < N; i++)cin >> vec[i];
    sort(all(vec));
    cout << vec[N - 1] - vec[0] << endl;

    return 0;
}

Measured memory_bytes: 256
import random

def func(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

x = int(input())
while x == x:
  if func(x) == True:
    print(x)
    break
  x += 1

Measured memory_bytes: 3444
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            //入力
            int n = int.Parse(Console.ReadLine());
            long sum = 0;

            //RかBかでそれぞれリストを作る
            for(int i = 1;i <= n;i++)
            {
                if(i % 3 != 0 && i % 5 != 0)
                    sum += i;
            }
            
            
            Console.WriteLine(sum);
            

        }
    }

Measured memory_bytes: 27540
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#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(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	int d[13] = {};
	cin >> N;
	REP(i, N){
		int D;
		cin >> D;
		if(D == 0){
			cout << 0 << endl;
			return 0;
		}
		d[D]++;
		if((D == 12 && d[D] > 1) || d[D] > 2){
			cout << 0 << endl;
			return 0;
		}
	}
	
	int res = 0;
	int D[51] = {};
	int ok = 1;
	vector<int> a;
	REP(i, 13){
		if(d[i] == 2){
			D[ok] = i;
			D[ok+1] = 24-i;
			ok+=2;
		}else if(d[i] == 1){
			a.push_back(i);
		}
	}
	REP(i, 1 << a.size()){
		int DD[51] = {};
		REP(j, ok){
			DD[j] = D[j];
		}
		int ret = INF;
		REP(j, a.size()){
			DD[j+ok] = (i >> j) & 1 ? a[j] : 24-a[j];
		}
		sort(DD, DD+N+1);
		REP(j, N+1){
			ret = min(ret, abs(DD[j]-(DD[(j+1)%(N+1)] == 0 ? 24 : DD[(j+1)%(N+1)])));
		}
		res = max(ret, res);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] A) {
    auto t = SegmentTree!(long, gcd, 0L)(A);
    return iota(N).map!(i => gcd(t[0 .. i], t[i + 1 .. $])).reduce!max;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](N);
    foreach (i; 0 .. N) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A);
    else
        solve(N, A).writeln;
}


struct SegmentTree(M, alias f, alias e) if (
    is(typeof(e) == M)
) {
private:
    alias _f = binaryFun!f;

    long _size;
    long leaves;
    M[] data;

public:
    // constructor___________________________________________________
    this(long n) {
        _size = n;
        leaves = 1;
        while (leaves < n) leaves <<= 1;
        data.length = leaves << 1;
        data.fill(e);
    }

    this(R)(R range) if (
        isInputRange!R &&
        hasLength!R &&
        is(ElementType!R == M)
    ) {
        this(range.length);
        foreach (i; 0 .. range.length)
            data[leaves + i] = range[i];
        foreach_reverse(i; 1 .. leaves)
            data[i] = _f(data[i << 1], data[(i << 1) + 1]);
    }

    // query_________________________________________________________
    M opIndexAssign(M x, long i)
    in {
        assert(0 <= i && i < size, "Access Violation");
    }
    body {
        i += leaves;
        data[i] = x;
        while ((i >>= 1) != 0)
            data[i] = _f(data[i << 1], data[(i << 1) + 1]);
        
        return x;
    }

    M opIndex(long[2] range)
    in {
        // assert(0 <= range[0] && range[0] < size, "Access Violation");
        // assert(0 < range[1] && range[1] <= size, "Access Violation");
        // assert(range[0] < range[1], "Query Violation");
    }
    body {
        long l = range[0] + leaves;
        long r = range[1] + leaves;
        M vl = e;
        M vr = e;
        while (l < r) {
            if (l & 1)
                vl = _f(vl, data[l++]);
            if (r & 1)
                vr = _f(data[--r], vr);
            l >>= 1;
            r >>= 1;
        }

        return _f(vl, vr);
    }

    // utility_______________________________________________________
    M opIndex(long i)
    in {
        assert(0 <= i && i < size, "Access Violation");
    }
    body {
        return this[i .. i + 1];
    }
    
    M opIndexOpAssign(string op)(M x, long i) {
        mixin("this[i] = (this[i] %s x);".format(op));
        return this[i];
    }

    @property long size() {
        return _size;
    }

    long opDollar(long dim : 0)() {
        return size;
    }

    long[2] opSlice(long dim : 0)(long i, long j) {
        return [i, j];
    }
}


Measured memory_bytes: 10792
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		int N = readInt();
		
		int crntX = 0, crntY = 0, crntTime = 0;
		for(int i = 1; i<=N; i++) {
			int time = readInt(), X = readInt(), Y= readInt();
			if(Math.abs(crntX-X) + Math.abs(crntY-Y) + crntTime <= time && 
					(Math.abs(crntX-X) + Math.abs(crntY-Y) + crntTime)%2 == time%2) {
				crntTime = time;
				crntX = X; crntY = Y;
			}
			else {println("No"); exit();}
		}
		println("Yes");
		exit();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBoolean() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readCharacter() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int left = -1, right = 1001001, L, R;
    for (int i = 0; i < M; i++) {
        cin >> L >> R;
        left = max(left, L);
        right = min(right, R);
    }
    cout << max(0, right - left + 1) << endl;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) out("Yes");
    else out("No");
}

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

int main()
{
       ll a;
       cin>>a;
       if(a<1200)
       {
           cout<<"ABC"<<endl;
       }
       else if(a<2800)
       {
           cout<<"ARC"<<endl;
       }
       else 
       {
           cout<<"AGC"<<endl;
       }


    return 0;
}


Measured memory_bytes: 256
// 1600_EntranceExamination.cpp
//
#include <bits/stdc++.h>
using namespace std;
int m, nmin, nmax, res, dif;
int p[10010];
int main() {
  while(cin >> m >> nmin >> nmax && m && nmin && nmax) {
    dif = 0;
    for(int i = 0; i < m; ++i) {
      cin >> p[i];
      if(nmin <= i && i <= nmax && dif <= p[i-1] - p[i]) {
        res = i;
        dif = p[i-1] - p[i];
      }
    }
    cout << res << endl;
  }

  return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int a,b;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>a>>b;
	if(a%2==0 || b%2==0) cout<<"Even";
	else cout<<"Odd";
}


Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap());
    let x = it.next().unwrap();
    let a = it.next().unwrap();
    let b = it.next().unwrap();
    if b <= a {
        println!("delicious");
    } else if b - a <= x {
        println!("safe");
    } else {
        println!("dangerous");
    }
}


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

int main(){
  int n,a,b;
  cin>>n>>a>>b;

  int ans=0;
  for(int i=1;i<=n;i++){
      int sum=0;
      if(i<10) sum+=i;
      if(i>=10&&i<100) sum+=i/10%10+i%10;
      if(i>=100&&i<1000) sum+=i/100%10+i/10%10+i%10;
      if(i>=1000&&i<10000) sum+=i/1000%10+i/100%10+i/10%10+i%10;
      if(i==10000) sum+=i/10000%10+i/1000%10+i/100%10+i/10%10+i%10;
      if(a<=sum&&sum<=b) ans+=i; 
  }
  printf("%d\n",ans);

}

Measured memory_bytes: 256
n = int(input())
B = []

for i in range(n):
    A = int(input())
    B.append([])
    for j in range(A):
        B[i].append(list(map(int,input().split())))

maxCnt = 0
for i in range(2 ** n):
    bin_str = format(i, 'b').zfill(n)
    trueFlg = 1
    for j in range(n):
        for k in B[j]:
            if bin_str[j] == '1':
                if int(bin_str[k[0] -1]) != k[1]:
                    trueFlg = 0
                    break
#            if bin_str[j] == '0':
#                if int(bin_str[k[0] - 1]) == k[1]:
#                    trueFlg = 0
#                    break
    if trueFlg == 1:
        maxCnt = max(maxCnt, bin_str.count('1'))

print(maxCnt)

Measured memory_bytes: 3064
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v)/len(u)/len(v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        len (a,b) = sqrt(a^2+b^2)
        eps=1e-13 

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll ans=(n/500)*1000+(n%500)/5*5;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var nx = ReadInts();
            var ans = nx[0];
            var list = new List<int>();
            for (int i = 0; i < nx[0]; i++)
            {
                var m = ReadInt();
                list.Add(m);
            }
            var aa = nx[1] - list.Sum();
            ans += aa / list.Min();
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> v(2000001);
  rep(i,n){
    int x;
    cin >> x;
    v[x]++;
  }
  sort(all(v));
  reverse(all(v));
  rep(i,k){
    n-=v[i];
  }
  cout << n << endl;
}


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

#define PI 3.1415926535

int main(void){
  double x = 0.0, y = 0.0;
  int d, a, angle = 90;

  do{
    scanf("%d,%d", &d, &a);
    x += cos(angle*PI/180) * d;
    y += sin(angle*PI/180) * d;
    angle -= a;
  }while(d != 0 || a != 0);
  printf("%d\n%d\n", (int)x, (int)y);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	for (auto &x : L) {
		cin >> x;
	}

	int d = 0;
	int ans = 1;
	for (auto x : L) {
		d += x;
		if (d <= X) {
			++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    N = int(input())
    L = list(map(int, input().split()))
    if max(L) < sum(L) - max(L):
        print("Yes")
    else:
        print("No")

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}


Measured memory_bytes: 104940
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define rev(a) a.rbegin(),a.rend()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

void solve(){
	ll m = 0, n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
	cin>>n;
    vl v(n), temp(n, 0);
    for(auto &i : v) cin>>i;
    temp[1] = abs(v[1] - v[0]);
    f(i, 2, n){
        temp[i] = min(temp[i - 2] + abs(v[i] - v[i - 2]), temp[i - 1] + abs(v[i] - v[i - 1]));
    }
    cout<<temp[n - 1]<<"\n";
}

int main(){

	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

/* 	ll t;
	cin>>t;
	while(t--){ */
		solve();
/* 	} */

}

Measured memory_bytes: 1792
/**
   * @Author:Monk78
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second;
#define F first;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()
vpshVar(){
    string str;
    cin>>str;
    int frst,scnd;
    int val1=str[0]-'0';
     int val2=str[1]-'0';
      int val3=str[2]-'0';
     int val4=str[3]-'0';
     frst=val1*10+val2;
     scnd=val3*10+val4;
       if(frst<=12 && frst>=1 && scnd>=1 && scnd<=12){
            cout<<"AMBIGUOUS"<<endl;
            return 0;
       }
       else if(frst<=12 && frst>=1 && scnd>=0){
            cout<<"MMYY"<<endl;
            return 0;
       }
       else if(frst>=0 && scnd>=1 && scnd<=12){
            cout<<"YYMM"<<endl;
            return 0;
       }
       else{
            cout<<"NA"<<endl;
       }
return 0;
}


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

int main()
{
  string S, T, U;
  int A, B;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(S==U) cout << A-1 << " " << B << endl;
  else if(T==U) cout << A << " " << B-1 << endl;
}

Measured memory_bytes: 3532
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int d[10][10];
int num[10];
int a[205][205];

int main(){
	int h, w;
	scanf("%d %d ", &h, &w);
	FORI(0, 10) {
		FORJ(0, 10) {
			scanf("%d ", &d[i][j]);
		}
	}
	FORI(0, h) {
		FORJ(0, w) {
			scanf("%d ", &a[i][j]);
		}
	}
	FORK(0, 10) {
		FORI(0, 10) {
			FORJ(0, 10) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	FORI(0, h) {
		FORJ(0, w) {
			if(a[i][j]!=-1)
				num[a[i][j]]++;
		}
	}
	int ans = 0;
	FORI(0, 10) {
		ans += d[i][1]*num[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>

auto main () -> int
{
    int a [4][3][10] = {};
    int n;
    std::cin >> n;
    for (auto i = 0; i < n; ++ i)
    {
        int b , f , r , v;
        std::cin >> b >> f >> r >> v;
        a [b - 1] [f - 1] [r - 1] += v;
    }
    for (auto && tower : a)
    {
        for (auto && floor : tower)
        {
            for (auto && elem : floor)
            {
                std::cout << ' ' << elem;
            }
            std::cout << std::endl;
        }
        if (tower != a [3])
            std::cout << "####################" << std::endl;
    }
}

Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main (){
  for(int h,w;cin>>h>>w,h;){
    int a[21]={},b[21]={},r=0;
    for(int i=0,t;i<h&&cin>>t;i++) a[t]++;
    for(int i=0,t;i<w&&cin>>t;i++) b[t]++;
    for(int i=0;i<21;i++){
      int t=min(a[i],b[i]);
      r+=t*i;
      a[i]-=t;
      b[i]-=t;
    }
    for(int i=0;i<21;i++) r+=a[i]*i;
    for(int i=0;i<21;i++) r+=b[i]*i;
    cout<<r<<endl;
  }
  return 0;
}



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


int main()
{
  int n;
  cin >> n;
  int a[100];
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  cout << (a[n - 1] - a[0]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e18
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

double culc(int xi, int xj, int yi, int yj){
    int bs = (xi - xj) * (xi - xj) + (yi - yj) * (yi - yj);
    double distance = sqrt(bs);
    return distance;
}

int factorial(int n){
    if(n == 1)
        return 1;
    else
        return n * factorial(n - 1);
}

int main(){
    ll n;
    cin >> n;
    ll m = sqrt(n) + 2;
    ll min = INF;
    repk(i, 1, m) {
        if (n % i)
            continue;
        else
            chmin(min, i + n / i - 2);
    }
    cout << min << endl;
}

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


template<class Abel>
struct wUnionFind {
    vector<int> par;
    vector<Abel> diff_weight;
    wUnionFind(int n):par(n, -1), diff_weight(n) {}
    int root(int x) {
        if(par[x] < 0) return x;
        int r = root(par[x]);
        diff_weight[x] += diff_weight[par[x]];
        return par[x] = r;
    }
    bool unite(int x, int y, Abel w) { //weight(y) - weight(x) = w となるようにする
        w += weight(x)-weight(y);
        x = root(x); y = root(y);
        if(x == y) {
            assert(diff(x, y) == w);
            return false;
        }
        if(par[x] > par[y]) swap(x, y), w = -w;
        par[x] += par[y];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);}
    bool size(int x) {return -par[root(x)];}
    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }
    Abel diff(int x, int y) {
        assert(same(x, y));
        return weight(y)-weight(x);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    wUnionFind<int> wuft(n);
    while(q--) {
        int t;
        cin >> t;
        if(t) {
            int x, y;
            cin >> x >> y;
            if(wuft.same(x, y)) {
                cout << wuft.diff(x, y) << '\n';
            } else {
                cout << '?' << '\n';
            }
        } else {
            int x, y, z;
            cin >> x >> y >> z;
            wuft.unite(x, y, z);
        }
    }
}


Measured memory_bytes: 3628
N = int(input())
A = input().split()
A = [int(a) for a in A]
sum_ = sum(A)
sum_2 = sum_/2

X = 0
s = 0
for i in range(N):
    s += A[i]
    X += A[i]
    if(s>=sum_2):
        break

l1 = X-A[i]
l2 = sum_-X

data = [abs(l1+A[i]-l2),abs(l2+A[i]-l1)]
print(min(data))

Measured memory_bytes: 26220
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
int main() {
    int e,y,ans;
    cin>>e>>y;
    switch(e){
        case 0 :
            if(1868<=y && y<=1911){
                ans=y-1867;
                cout<<"M"<<ans<<endl;
                
            }
            else if(y<=1925){
                ans=y-1911;
                cout<<"T"<<ans<<endl;
            }
            else if(y<=1988){
                ans=y-1925;
                cout<<"S"<<ans<<endl;
            }
            else {
                ans=y-1988;
                cout<<"H"<<ans<<endl;
            }
            break;
        case 1: ans=1867+y;cout<<ans<<endl;break;
        case 2: ans=1911+y;cout<<ans<<endl;break;
        case 3: ans=1925+y;cout<<ans<<endl;break;
        case 4: ans=1988+y;cout<<ans<<endl;break;
    }
    return 0;
}

Measured memory_bytes: 3100
s=input().split()
n=int(s[0])
x=int(s[1])
s=input().split()
l=[int(c) for c in s]
l.sort()
i=0
cnt=0
while True:
    if x>=l[i]:
        x-=l[i]
        cnt+=1
    else:
        x-=l[i]
        break
    i+=1
    if i==len(l):
        break
if x>0:
    cnt-=1
print(cnt)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>

using namespace std;

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

	int a, b, sum = 0, sum_min = 100000;

	for(int i = 1; i < N; i++) {
		a = i;
		b = N - i;
		while(a != 0 || b != 0) {
			if(a != 0) {
				sum += a % 10;
				a /= 10;
			}
			if(b != 0) {
				sum += b % 10;
				b /= 10;
			}
		}
		if(sum_min > sum) sum_min = sum;
		sum = 0;
	}
	cout << sum_min << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define FIO "sample"
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

template<typename T> inline void Max(T &x,T y){if(x<y) x=y;}
template<typename T> inline void Min(T &x,T y){if(x>y) x=y;}

const int maxn=55;

int n,a[maxn],b[maxn];
ll to[maxn],ans=0;
bool vis[maxn];

inline bool check()
{
	for(int i=0;i<=50;i++)
		to[i]=1LL<<i;
	
	for(int i=1;i<=50;i++)
	{
		for(int j=1;j<=50;j++)
			if(vis[j])
				to[i]|=to[i%j];
	}

	for(int i=1;i<=n;i++)
		if(!((to[a[i]]>>b[i])&1))
			return 0;
			
	return 1;
}

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

	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=read();
	for(int i=0;i<=50;i++) vis[i]=1;
	
	if(!check()) return puts("-1"),0;
	for(int i=50;i>=0;i--)
	{
		vis[i]=0;
		if(!check())
		{
			vis[i]=1;
			ans+=1LL<<i;
		}
	}
	printf("%lld\n",ans);

#ifdef dxymaster
	cerr<< " Time: " << (double) clock() / CLOCKS_PER_SEC << "s			It Runs So Fast!" << endl;
#endif

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char x;
	int i;
	for (i=1;i<=19;i++)
	{
		cin>>x;
		if(i!=6&&i!=14) cout<<x;
		else cout<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
char s[55]; int n;
int main()
{
	scanf("%s",s+1), n = strlen(s+1);
	s[n-7] = '\0'; printf("%s\n",s+1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int A,B,K;
    cin >> A >> B >> K;
    if(A<K){
        K-=A;A=0;
    }else{
        A-=K;K=0;
    }
    
    if(B<K){
        K-=B;B=0;
    }else{
        B-=K;K=0;
    }
    cout << A MM B << endl;
    return 0;
}



Measured memory_bytes: 256