akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
int A,B,C,D;

int main(){
    

    cin >> A >> B >> C >> D ;
    for(int i = 0; i <= 100; i++){
        if (A-i*D <= 0) {
            cout<<"No"<<endl;
            break;
        }else if (C - (i+1)*B <= 0 ){
            cout<<"Yes"<<endl;
            break;
        }
       
    }
    return 0;
}



Measured memory_bytes: 3592
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
string reversed(string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n, k; cin >> n >> k;
    string s; cin >> s;
    FOR(i, 0, min(k, 13)) {
        string u = s + reversed(s);
        FOR(j, 0, n + 1)chmin(s, u.substr(j, n));
        reverse(all(s));
    }
    print(reversed(s));
}


Measured memory_bytes: 384
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        int curMaxLength = 0;
        var hash = new RollingHash(s);
        for (int i = 0; i < s.Length; i++)
            for (int j = i; j < s.Length; j++)
                while (curMaxLength < j - i && j + curMaxLength < n && hash.Slice(i, curMaxLength + 1) == hash.Slice(j, curMaxLength + 1)) curMaxLength++;
        Console.WriteLine(curMaxLength);
    }
}

class RollingHash
{
    const ulong MASK30 = (1UL << 30) - 1;
    const ulong MASK31 = (1UL << 31) - 1;
    const ulong MOD = (1UL << 61) - 1;
    const ulong POSITIVIZER = MOD * ((1UL << 3) - 1);
    static uint Base;
    static ulong[] powMemo = new ulong[5000 + 1];
    static RollingHash()
    {
        Base = (uint)new Random().Next(129, int.MaxValue);
        powMemo[0] = 1;
        for (int i = 1; i < powMemo.Length; i++)
            powMemo[i] = CalcMod(Mul(powMemo[i - 1], Base));
    }

    ulong[] hash;

    public RollingHash(string s)
    {
        hash = new ulong[s.Length + 1];
        for (int i = 0; i < s.Length; i++)
            hash[i + 1] = CalcMod(Mul(hash[i], Base) + s[i]);
    }

    public ulong Slice(int begin, int length)
    {
        return CalcMod(hash[begin + length] + POSITIVIZER - Mul(hash[begin], powMemo[length]));
    }

    private static ulong Mul(ulong l, ulong r)
    {
        var lu = l >> 31;
        var ld = l & MASK31;
        var ru = r >> 31;
        var rd = r & MASK31;
        var middleBit = ld * ru + lu * rd;
        return ((lu * ru) << 1) + ld * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
    }

    private static ulong Mul(ulong l, uint r)
    {
        var lu = l >> 31;
        var ld = l & MASK31;
        var rd = r & MASK31;
        var middleBit = lu * rd;
        return  ld * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
    }

    private static ulong CalcMod(ulong val)
    {
        val = (val & MOD) + (val >> 61);
        if (val > MOD) val -= MOD;
        return val;
    }
}


Measured memory_bytes: 13264
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    string h[5];
    h[0] = "hi";
    h[1] = "hihi"; 
    h[2] = "hihihi"; 
    h[3] = "hihihihi"; 
    h[4] = "hihihihihi"; 

    for(int i=0;i<5;i++){
        if(S == h[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    

}

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

import sys
import os
import math

for i, s in enumerate(sys.stdin):
    n = int(s)
    if n == 0:
        break
    elif i != 0:
        print()

    A = []

    for i in range(n):
        lst = input().split()
        name = lst[0]
        w = int(lst[1])
        l = int(lst[2])
        d = int(lst[3])
        score = 3 * w + d
        A.append((score, -i, name))
    A.sort(reverse=True)

    for a in A:
        score = a[0]
        name = a[2]
        print('{},{}'.format(name, score))

Measured memory_bytes: 7520
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  # L <= 2019n <= R
        print(0)
    else:  # max: 2018 * 2017 patterns
        L, R = L % MOD, R % MOD
        if L <= 3 and R >= 673:  # 2019 = 3 * 673
            print(0)
            return
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                tmp = (i * j) % MOD
                if tmp < ans:
                    ans = tmp
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int h, w, n, i, j, a[10005], b = 0, c;
  scanf("%d%d%d", &h, &w, &n);
  
  for(i = 0; i < n; i++){
    scanf("%d", &c);
    for(j = b; j < b + c; j++) a[j] = i+1;
    b += c;
  }
  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      if(j) printf(" ");
      printf("%d", a[i*w + (i%2 ? w-1-j : j)]);
    }
    printf("\n");
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){

	int n,l;
	int i,j;

	cin >> n >> l;

	string str;
	string strsum;
	vector<string> strbox;

	for(i = 0; i < n; i++){
		cin >> str;
		strbox.push_back(str);
	}

	for(i = 0; i < n; i++){

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

			if(strbox[i] > strbox[j]){

			 strbox[i].swap( strbox[j] );

			}
		}
		
		strsum = strsum + strbox[i];
	}


	cout << strsum << endl;


}

Measured memory_bytes: 256
group = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
x, y = map(int, input().split())
for i in range(3):
    if x in group[i] and y in group[i]:
        print("Yes")
        exit()
    
print("No")

Measured memory_bytes: 3060
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, A, B;
    cin >> N >> A >> B;

    string s;
    cin >> s;

    ll pass_num = 0;
    ll oversea_rank = 0;
    for(char c : s){
        if(c=='a'){
            if(pass_num < A+B){
                pass_num++;
                p_yes();
            }else{
                p_no();
            }
        }
        else if(c=='b'){
            oversea_rank++;
            if(pass_num < A+B && oversea_rank <=B){
                pass_num++;
                p_yes();
            }else{
                p_no();
            }
        }
        else{
            p_no();
        }
    }
    
    return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
string s[214514];
map<string,ll>mp;
int main(){
	cin>>n;
	ll ma=0;
	for(int i=0;i<n;i++){
		cin>>s[i];
		mp[s[i]]++;
		ma=max(ma,mp[s[i]]);
	}
	sort(s,s+n);
	vector<string>v;
	for(int i=1;i<n;i++){
		if(s[i-1]!=s[i]){
			if(mp[s[i-1]]==ma)v.push_back(s[i-1]);
		}
	}
	if(mp[s[n-1]]==ma)v.push_back(s[n-1]);
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)cout<<v[i]<<endl;
	return 0;
}


Measured memory_bytes: 28532
n,T =map(int,input().split())
ans = 10**3+1
for i in range(n):
    c,t=map(int,input().split())
    if t > T:
        continue
    else:
        ans = min(ans,c)
if ans == 10**3+1:
    print('TLE')
else:
    print(ans)


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
bool cmp(long long int r,long long int t)
{
    return r>t;
}
int main()
{
    long long int a[60];
    int n;
    scanf("%d",&n);

    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }

    long long int ss=0;
    for(int j=0;; j++)
    {
        long long int s=0;
        sort(a,a+n,cmp);
        if(a[0]<n)
        {
            printf("%lld\n",ss);
            break;
        }
        else
        {
            s+=a[0]/n;
            ss+=s;
            a[0]=a[0]%n;

            for(int i=1; i<n; i++)
            {
                a[i]+=s;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#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;
typedef long long int ll;
#define int long long 
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef double f80;
#ifndef LOCAL
#define endl '\n'
#endif

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
ll pwr(ll a,ll b){
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
const int N = 1e5 + 5;
int p[N][26];
int f[26];
void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    fr(i, 0, n - 1){
        f[s[i] - 'a']++;
    }
    int ans = 1;
    fr(i, 0, 25){
        ans = (ans * (f[i] + 1)) % mod;
    }
    cout << (ans + mod - 1) % mod;
 }
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}

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

int main() {
  long long a, b, x; cin >> a >> b >> x;
  long long answer = 0;
  
  int start = 0;
  
  if (a % x == 0 && a != 0) {
    start = a / x;
  } else if (a == 0) {
    start = 1;
    answer++;
  } else {
    start = a / x + 1;
  }
  
  for (int i = start; i <= b / x; i++) answer++;
  
  cout << answer << endl;
}

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

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

using namespace std;

using ll = long long;

int main() {
    int N, M, L;
    cin >> N >> M >> L;
    vector<vector<ll>> dist(N, vector<ll>(N, LLONG_MAX / 2));
    REP(i, N) dist[i][i] = 0;
    REP(_, M) {
        int A, B, C;
        cin >> A >> B >> C;
        --A;
        --B;
        dist[A][B] = C;
        dist[B][A] = C;
    }
    REP(k, N) REP(i, N) REP(j, N) {
        if (dist[i][j] > dist[i][k] + dist[k][j])
            dist[i][j] = dist[i][k] + dist[k][j];
    }
    vector<vector<int>> times(N, vector<int>(N, N));
    REP(s, N) {
        queue<int> q;
        times[s][s] = -1;
        q.push(s);
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            REP(v, N) {
                if (dist[u][v] <= L && times[s][v] > times[s][u] + 1) {
                    times[s][v] = times[s][u] + 1;
                    q.push(v);
                }
            }
        }
    }
    int Q;
    cin >> Q;
    REP(_, Q) {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        cout << (times[s][t] != N ? times[s][t] : -1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = 0;
    int xa = min(A, K);
    K = K - xa;
    int xb = min(B, K);
    K = K - xb;
    int xc = K;
    ans = xa - xc;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>

int main(void){
	char str[1200];     // input; string, size<1200 char.
	char* p = str;      // pointer; 

	gets(str);

	while(*p != '\0'){
		if(*p >= 'A' && *p <= 'Z'){
			*p += 0x20;
		}else if(*p >= 'a' && *p <= 'z'){
			*p -= 0x20;
		}
		p++;
	}

	puts(str);

	return 0;
}

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

struct edge{
    int to;
    ll cost;
};

bool visit[100005];
bool ans[100005];
vector<vector<edge>> G(100005);

void dfs(int v, ll w){
    if(w%2 == 0) ans[v] = true;
    visit[v] = true;
    for(int i=0; i<G[v].size(); i++){
        auto v_to = G[v][i];
        if(visit[v_to.to] == false){
            dfs(v_to.to, w + v_to.cost);
        }
    }
    return;
}



int main(){
    int n;
    cin >> n;
    
    for(int i=0; i<n-1; i++){
        int u, v;
        ll w;
        cin >> u >> v >> w;
        G[u].push_back(edge{v, w});
        G[v].push_back(edge{u, w});
    }

    
    dfs(1, 0);
    for(int i=1; i<=n; i++) cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <string.h>
using namespace std;

int n, k, q;
int p[100000];

int main()
{
	cin >> n >> k >> q;

	memset(p, 0, sizeof(p));

	for (int i = 0; i < q; i++) {
		int a;
		cin >> a;

		p[a - 1]++;
	}

	for (int i = 0; i < n; i++) {
		if (p[i] + k > q)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	string ans = "";
	while (N > 0) {
		ans += (char)((N - 1) % 26 + 'a');
		N = (N - 1) / 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;

	return 0;
}


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

int main() {
 
   	long long int n;
  	cin>>n;  	

    long long int cnt = 1, ans = 1;
    while(n > 1) {
        n /= 2;
      	cnt = cnt * 2;
      	ans += cnt;
    }
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}
bool cmp(pii& a, pii& b) {
  return a.second > b.second;
}
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  mii odd, even;
  int x;
  fi(0, n) {
    cin >> x;
    if(i % 2 == 0) {
      odd[x]++;
    }
    else {
      even[x]++;
    }
  }
  vii oddv, evenv;
  for(pii p: odd)
    oddv.push_back(p);
  for(pii p: even)
    evenv.push_back(p);

  sort(all(oddv), cmp);
  sort(all(evenv), cmp);
  if(oddv[0].first == evenv[0].first) {
    ans = n - max(oddv[0].second + (evenv.size() > 1 ? evenv[1].second : 0), (oddv.size() > 1 ? oddv[1].second : 0) + evenv[0].second);
  }
  else {
    ans = n - oddv[0].second - evenv[0].second;
  }
  cout << ans << endl;
  return 0;
}



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

int main()
{
    char s[11000];
    int l;
    while(scanf("%s",s)!=EOF){

        l=strlen(s);
        if(l<4) printf("No\n");
        else{

            if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
                printf("Yes\n");
            }
            else printf("No\n");


        }

    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int const N = 2e3 + 41;
vector<int> e[N];
int n, k;

int dfs(int u, int p, int l){
	if(l < 0) return 0;
	int ret = 1;
	for(int to : e[u]){
		if(to == p) continue;
		ret += dfs(to, u, l-1);
	}
	return ret;
}

void solve(){
	cin >> n >> k;
	for(int i=0;i<n-1;++i){
		int u, v;
		cin >> u >> v;
		--u;--v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	int ans = 0;
	for(int i=0;i<n;++i){
		vector<pair<int, int>> a;
		for(int j : e[i]){
			a.push_back(make_pair(dfs(j, i, k/2 - 1), dfs(j, i, (k + 1) / 2 - 1)));
		}
		int sum = 0;
		for(int j=0;j<a.size();++j) sum += a[j].first;
		for(int j=0;j<a.size();++j) ans = max(ans, sum - a[j].first + a[j].second);
	}
	cout << n - (ans + 1) << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
#endif
	solve();

	return 0;
}

Measured memory_bytes: 384
def di(n):
    count=0
    while True:
        if n%2==0:
            n=n//2
            count+=1
        else:
            return count

        
n=int(input())
a=[int(i) for i in input().split()]

anslist=[]
for i in a:
    anslist.append(di(i))
print(min(anslist))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC163
{
    class Program
    {
        static void Main(string[] args)
        {
            c();
        }

        public static void c()
        {
            long n = long.Parse(Console.ReadLine()); 
            long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long[] ans = new long[n];
            for(long i = 0; i < n - 1; i++)
            {
                ans[a[i] - 1]++;
            }
            foreach(var x in ans)
            {
                Console.WriteLine(x);
            }
        }
    }
}


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

int main() 
{
	cout <<std::fixed<<setprecision(10);
	long double ans = 0,temp;
	int n; cin >> n;
	for(int i=0;i<n;i++)
		cin>>temp,ans+=1/temp;
	cout << 1/ans;	
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String S = sc.next();
		
		int cnt = 0;
		int ans = 0;
		int c = 0;
		ArrayList<Integer> ary = new ArrayList<Integer>();
		ary.add(0);
		cnt++;
		
		for(int i = 0; i < N - 1; i++) {
			if(!S.substring(i, i + 1).equals(S.substring(i + 1, i + 2))) {
				if(S.substring(i, i + 1).equals("1")) {
					if(cnt > K) {
						cnt--;
						ans = Math.max(ans, i + 1 - ary.get(c));
						c++;
					}
				} else {
					ary.add(i + 1);
					cnt++;
				}
			}
		}
		ans = Math.max(ans, N - ary.get(c));
		System.out.println(ans);
	}
}


Measured memory_bytes: 44508
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>

#define MAX(a, b) ((a > b) ? a : b)

char S[300001];

static void countDirectionChange(const uint32_t N, const char * S, uint32_t * turnCount) {
	*turnCount = 0;
	for (uint32_t idx = 0; idx < N; idx++) {
		if (S[idx] == 'E') {
			(*turnCount)++;
		}
	}
}

int main(void) {
	uint32_t N;
	uint32_t min = UINT32_MAX;

	scanf("%"PRIu32"\n%s", &N, &S);

	uint32_t turnToWCount = 0;
	uint32_t turnToECount = 0;

	countDirectionChange(N, S, &turnToWCount);

	for (uint32_t idx = 0; idx < N; idx++) {
		if (S[idx] == 'E') {
			turnToWCount--;
		}
		if (idx != 0 && S[idx - 1] == 'W') {
			turnToECount++;
		}

		if (turnToECount + turnToWCount < min) {
			min = turnToECount + turnToWCount;
		}
	}

	printf("%"PRIu32, min);

	return 0;
}

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

string s;

// i番目まで決まっている状況で、i+1番目を決める
template <typename T>
void func(int i, T& v) {
	if (i >= v.size() - 1) { return; }

	if (v[i] == 0) {
		if (s[i] == 'o') { 
			v[i + 1] = v[i - 1];
		} else { 
			v[i + 1] = 1 - v[i - 1];
		}
	} else if (v[i] == 1) {
		if (s[i] == 'o') {
			v[i + 1] = 1 - v[i - 1];
		} else {
			v[i + 1] = v[i - 1];
		}
	}
	func(i + 1, v);
}

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

	for (int i = 0; i < 2; ++i) {
		// 0 := 羊, 1 := 狼
		vector<int> v(N);

		v[0] = i;
		int pre;
		// 初期配置を決める
		for (int j = 0; j < 2; ++j) {
			if (i == 0) {
				if (s[0] == 'o') {
					pre = v[1] = j;
				} else {
					pre = j;
					v[1] = 1 - j;
				}
			} else {
				if (s[0] == 'o') {
					pre = j;
					v[1] = 1 - j;
				} else {
					pre = v[1] = j;
				}
			}

			// N番目まで埋めていく
			func(1, v);

			// 埋めていって決めたN番目と最初に決めたN番目が一致する場合
			if (pre == v[N - 1]) {
				bool can = false;

				if (pre == 0) {
					if (s[N - 1] == 'o') {
						if (v[N - 2] == v[0]) { can = true; }
					} else {
						if (v[N - 2] != v[0]) { can = true; }
					}
				} else {
					if (s[N - 1] == 'o') {
						if (v[N - 2] != v[0]) { can = true; }
					} else {
						if (v[N - 2] == v[0]) { can = true; }
					}
				}

				if (can) {
					for (int i = 0; i < v.size(); ++i) {
						if (v[i] == 0) { cout << 'S'; }
						else { cout << 'W'; }
					}
					cout << endl;
					return 0;
				}
			}
		}
	}

	cout << -1 << endl;
	return 0;
}


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

int main(){
    long long INF = 100000;
    queue<long long> que; // 整数の組はx*1000+yで保存
    long long table[1010][1010]; //ここに黒点からの距離を書いてやる
    long long H, W;
    cin >> H >> W;
    char A;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> A;
            if(A=='#'){
                table[i][j] = 0;
            que.push(i*1000+j);
            }
            else{
                table[i][j] = INF;
            }
        }
    }

    long long cnt = 0;
    long long a;

    int dx[4], dy[4];
    dx[0]=0; dx[1]=1; dx[2]=0; dx[3]=-1;
    dy[0]=1; dy[1]=0; dy[2]=-1; dy[3]=0;

    while(!que.empty()){
        a = que.front();
        long long x = a/1000;
        long long y = a%1000;
        for(int i=0; i<4; i++){
            long long nx= x+dx[i];
            long long ny= y+dy[i];
            if(0<=nx &&nx<H && 0<=ny && ny<W && table[nx][ny] > 50000){
                table[nx][ny] = table[x][y] +1;
                cnt = max(cnt, table[nx][ny]);
                long long t = nx*1000+ny;
                que.push(t);
//                cout << nx <<  ny << " ";
            }
        }
        que.pop();
    }

    cout << cnt << endl;
}

Measured memory_bytes: 16272
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

const int N = 1e5 + 7, INF = 1e15;

int p[N], q[N], r[N];

void solve() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    loop(i, a)
        cin >> p[i];
    loop(i, b)
        cin >> q[i];
    loop(i, c)
        cin >> r[i];
    sort(p, p + a, greater<int>());
    sort(q, q + b, greater<int>());
    sort(r, r + c, greater<int>());
    int good[x + y];
    loop(i, x)
        good[i] = p[i];
    loop(j, y)
        good[x + j] = q[j];
    sort(good, good + x + y);
    queue<int> ask;
    loop(i, x + y)
        ask.push(good[i]);
    loop(i, c) {
        if (r[i] < ask.front())
            break;
        ask.push(r[i]);
        ask.pop();
    }
    int ans = 0;
    while (!ask.empty()) {
        ans += ask.front();
        ask.pop();
    }
    cout << ans;
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 5504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) throws IOException {
    	Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input;
		int n = Integer.parseInt(reader.readLine());
		input = reader.readLine().split(" ");
//		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		long[] arr = new long[n];
		long total = 0;
		for(int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(input[i]);
			total ^= arr[i];
		}
		for(int i = 0; i < n; i++) {
			out.print((total ^ arr[i]) + " ");
		}
		out.flush();
		out.close();
    }
}


Measured memory_bytes: 66836
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())

let bsearch_ge arr a =
  let l = Array.length arr in
  match Array.bsearch Int.ord arr a with
  | `All_lower -> l
  | `All_bigger -> 0
  | `Just_after n -> l - n -1
  | `At n -> l - n
  | `Empty -> 0

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let square x = x * x

let n = scan "%d" identity
let xs = scan_list Int.of_string

let () =
  let half = (List.sum xs) / n in
  let half2 = (List.sum xs) / n + 1 in
  let n = List.sum @@ List.map (fun n -> square @@ n - half) xs in
  let m = List.sum @@ List.map (fun n -> square @@ n - half2) xs in
  printf "%d" @@ min n m


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<int> vec[n];
    for(int i = 0; i < q; i++)
    {
        int v;
        cin >> v;
        if(v == 0)
        {
            int t, x;
            cin >> t >> x;
            vec[t].push_back(x);
        }
        else if(v == 1)
        {
            int t;
            cin >> t;
            for(int i = 0; i < vec[t].size(); i++)
            {
                if(i > 0) cout << " " << vec[t][i];
                else cout << vec[t][i];
            }
            cout << endl;
        }
        else if(v == 2) 
        {
            int t;
            cin >> t;
            vec[t].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5972
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

set<pair<ll, int> > ss;
int n;
const int MAXN = 210000;

int m;
int s, t;

vector<pair<int, ll> > eds[MAXN];

void solve(int s, pair<ll, ll> *dd) {
	for (int i = 0; i < n; ++i)
		dd[i] = make_pair(INF, 0);
	dd[s] = make_pair(0, 1);
	ss.clear();
	ss.insert(make_pair(dd[s].first, s));
	while (!ss.empty()) {
		int x = ss.begin()->second;
		ss.erase(ss.begin());
		for (auto e: eds[x]) {
			int u = e.first;
			if (dd[u].first > dd[x].first + e.second) {
				ss.erase(make_pair(dd[u].first, u));
				dd[u].first = dd[x].first + e.second;
				ss.insert(make_pair(dd[u].first, u));
				dd[u].second = 0;
			}
			if (dd[u].first == dd[x].first + e.second)
				dd[u].second = (dd[u].second + dd[x].second) % MOD;
		}
	}
}


pair<ll, ll> ds[MAXN];
pair<ll, ll> dt[MAXN];

vector<tuple<int, int, ll> > ed;


int main() {
	scanf("%d%d", &n, &m);
	scanf("%d%d", &s, &t);
	--s, --t;
	for (int i = 0; i < m; ++i) {
		int a, b;
		ll c;
		scanf("%d%d%lld", &a, &b, &c);
		--a, --b;
		eds[a].push_back(make_pair(b, c));
		eds[b].push_back(make_pair(a, c));
		ed.push_back(make_tuple(a, b, c));
		ed.push_back(make_tuple(b, a, c));
	}
	solve(s, ds);
	solve(t, dt);
	ll ans = ds[t].second * ds[t].second % MOD;
	for (int i = 0; i < n; ++i) {
		if (ds[i].first == dt[i].first && ds[i].first * 2 == ds[t].first) {
			ll go = ds[i].second * dt[i].second % MOD;
			ans = (ans - go * go % MOD + MOD) % MOD;
		}
	}
	for (int i = 0; i < ed.size(); ++i) {
		int a, b;
		ll c;
		tie(a, b, c) = ed[i];
		if (c + ds[a].first + dt[b].first == ds[t].first) {
			if (ds[a].first * 2 < ds[t].first && dt[b].first * 2 < ds[t].first) {
				ll go = ds[a].second * dt[b].second % MOD;
				ans = (ans - go * go % MOD + MOD) % MOD;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 34280
#include <stdio.h>

char s[3][15];

int main(){

	scanf("%s %s %s",s[0],s[1],s[2]);

	printf("%c%c%c\n",(s[0][0]-'a')+'A',(s[1][0]-'a')+'A',(s[2][0]-'a')+'A');

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll A,ll B) {if(!B)return A;return gcd(B,A%B);}
int main()
{
	ll n,m;
	cin>>n>>m;
	vii v(m+1);
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(a <= m)v[a].pb(b);
	}
	ll ans = 0;
	priority_queue<int>pq;
	for(auto x : v){
		for(auto y:x)pq.push(y);
		if(!pq.empty()){
			ans+=pq.top();
			pq.pop();
		}
	}
	cout<<ans;
}

Measured memory_bytes: 8456
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
# from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
import math
# from itertools import product, accumulate, combinations, product
#import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 998244353


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())



def run():
    N, *A = mapread()
    LEFT = [0] * (N+2)
    RIGHT = [0] * (N+2)
    for i, a in enumerate(A, 1):
        LEFT[i] = math.gcd(LEFT[i-1], a)
    for i in range(N-1, -1, -1):
        k = i+1# for RIGHT
        RIGHT[k] = math.gcd(RIGHT[k+1], A[i])
    #print(LEFT)
    #print(RIGHT)
    ans = 0
    for i in range(N):
        k = i + 1# for LEFT and RIGHT
        v = math.gcd(LEFT[k-1], RIGHT[k+1])
        #print(v)
        ans = max(ans, v)

    print(ans)



if __name__ == "__main__":
    #print(math.gcd(0, 10))
    run()


Measured memory_bytes: 21292
// https://atcoder.jp/contests/abc145/tasks/abc145_e

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 3000;
const int T_MAX = 3000;
const int A_I_MAX = 3000;
const int B_I_MAX = 3000;

int N, T;
// int A[N_MAX];
// int B[N_MAX];

pair<int, int> vs[N_MAX];
int dp[N_MAX][T_MAX];

void solve() {
  sort(vs, vs + N);
  REP(i, N - 1) {
    int A = vs[i].first;
    int B = vs[i].second;
    REP(j, T) {
      if (j < A) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - A] + B);
      }
    }
  }
  // DUMP2D(dp, N, T);
  int ans = 0;
  REP(i, N) ans = max(ans, dp[i][T - 1] + vs[i].second);
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &T);
  REP(i, N) {
    int A, B;
    scanf("%d%d", &A, &B);
    vs[i] = {A, B};
  }
}

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


Measured memory_bytes: 35456
# Problem C - Colorful Leaderboard

# input process
N = int(input())
a_list = list(map(int, input().split()))

# initialization
kanmuri_count = {
    "king": 0
}

# count process
for a in a_list:
    if a<400 and not "gray" in kanmuri_count:
        kanmuri_count["gray"] = 1
    elif a>=400 and a<800 and not "brown" in kanmuri_count:
        kanmuri_count["brown"] = 1
    elif a>=800 and a<1200 and not "green" in kanmuri_count:
        kanmuri_count["green"] = 1
    elif a>=1200 and a<1600 and not "cyan" in kanmuri_count:
        kanmuri_count["cyan"] = 1
    elif a>=1600 and a<2000 and not "blue" in kanmuri_count:
        kanmuri_count["blue"] = 1
    elif a>=2000 and a<2400 and not "yellow" in kanmuri_count:
        kanmuri_count["yellow"] = 1
    elif a>=2400 and a<2800 and not "orange" in kanmuri_count:
        kanmuri_count["orange"] = 1
    elif a>=2800 and a<3200 and not "red" in kanmuri_count:
        kanmuri_count["red"] = 1
    elif a>=3200:
        kanmuri_count["king"] += 1

# output process
cur_clount = len(kanmuri_count) - 1
ans = cur_clount + kanmuri_count["king"]
print("%d %d"%(max(cur_clount,1), ans))


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

//ABC171D
//ABC171C
//ABC171B
int compare_int(const void *a, const void *b) { //sort
  return *(int*) a-*(int*) b;
}
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf("%d %d", &n, &k);
  int p[n];
  for(i=0; i<n; i++){
    scanf(" %d", &p[i]);
  }
  qsort(p, n, sizeof(int), compare_int); //sort
  for(i=0; i<k; i++){
    cou+=p[i];
  }
  printf("%d", cou);
}


Measured memory_bytes: 1744
#include<stdio.h>
int main(){
  int k,n,i,max;
  scanf("%d %d",&k,&n);
  int a[n];
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=1,max=a[1]-a[0];i<n-1;i++){
    if(max<a[i+1]-a[i])max=a[i+1]-a[i];
  }
  if(max<k-a[n-1]+a[0])max=k-a[n-1]+a[0];
  printf("%d",k-max);
  return 0;
}

Measured memory_bytes: 2512
// g++ -std=gnu++1y -O2 main.cpp

#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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; }

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

	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		int Ai;
		cin >> Ai;

		A[i] = Ai;
	}

	int maxDiff = 0;
	for (int i = 0; i < N - 1; i++) {
		// cout << "A[i + 1]: " << A[i + 1] << endl;
		// cout << "A[i]: " << A[i] << endl;
		int diff = A[i + 1] - A[i];
		// cout << "diff: " << diff << endl;
		if (diff > maxDiff)
		{
			maxDiff = diff;
		}
	}
	int diff = A[0] + (K - A[N - 1]);
	// cout << "diff: " << diff << endl;
	if (diff > maxDiff) {
		maxDiff = diff;
	}

	cout << (K - maxDiff) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s;
    cin >> s;

    int res = -1;
    FOR(i, 0, s.size()-3) {
        if (abs(res - 753) > abs(stoi(s.substr(i, 3)) - 753)) {
            res = stoi(s.substr(i, 3));
        }
    }
    cout << abs(res - 753) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll v[500500];
int main() {
	int n;
	scanf("%d ",&n);
	for(int i=0;i<n;i++) {
		scanf("%d ",&v[i]);
	}
	ll tot = 0;
	ll lf = 0,rt = 0;
	ll a = 0;
	while(lf < n) {
		while(rt < n && ((a+v[rt]) == (a^v[rt]))) {
			a += v[rt];
			rt++;
		}
		tot += rt-lf;
		a -= v[lf];
		lf++;
	}
	printf("%lld\n",tot);
}


Measured memory_bytes: 1792
// AtCoder_145C. Average Length
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ALL(v)      v.begin(), v.end()
#define PB          push_back
#define MP          make_pair
#define UB          upper_bound
#define LB          lower_bound
#define PI          2*acos(0.0)
#define MOD         1000000007
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   ((a)*(b)) / GCD(a, b)
#define INPUT       freopen("input.txt", "r", stdin);
#define OUTPUT      freopen("output.txt", "w", stdout);
#define PRINT(a)    for(auto i : a) cout << i << " "; cout << endl;
#define PRINTS(s)   for(auto i=s.begin(); i!=s.end(); i++) cout << *i << " "; cout << endl;
#define PRINTM(m)   for(auto i=m.begin(); i!=m.end(); i++) cout << i->first << " " << i->second << endl;

int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
string lowerCase = "abcdefghijklmnopqrstuvwxyz";
string upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// Graph moves
const int fxKing[] = {+1,+1,+0,-1,-1,-1,+0,+1}; /// King's move
const int fyKing[] = {+0,+1,+1,+1,+0,-1,-1,-1}; /// King's move
const int fxKnight[] = {+2,+1,-1,-2,-2,-1,+1,+2}; /// Knight's move
const int fyKnight[] = {+1,+2,+2,+1,-1,-2,-2,-1}; /// Knight's move

int x[10], y[10];
vector <int> v;

double dist(int i, int j)
{
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx*dx + dy*dy, 0.5);
}

int main()
{
    FIO;
    int n, t = 1;
    while(t--)
    {
        cin >> n ;
        for(int i=1; i<=n; i++){
            cin >> x[i] >> y[i];
        }
        for(int i=1; i<=n; i++){
            v.push_back(i);
        }

        double sum = 0.0;
        do{
            for(int i=1; i<n; i++){
                sum += dist(v[i-1], v[i]);
//                cout << v[i-1] << " " << v[i] << " " << sum << endl;
            }
        } while(next_permutation(v.begin(), v.end()));

        int fact = 1;
        for(int i=2; i<=n; i++){
            fact *= i;
        }
        cout << fixed << setprecision(10);
        cout << sum / fact << endl;
    }

    return 0;
}


Measured memory_bytes: 640
////////////////////////////////////////////////
//                                            //
//  Author: Muhammad Faishol Amirul Mukminin  //
//                                            //
////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef pair<ll,ll> pl;
typedef pair<pl,ll> pll;
typedef pair<double,double> pd;
typedef pair<pd,double> pdd;
typedef pair<string, int> psi;
 
#define FOR(i,x,y) for(int i=(x);i<(y);i++)
#define FORN(i,x,y) for(int i=(x);i<=(y);i++)
#define REV(i,a,b) for(int i=(a);i>(b);i--)
#define REVN(i,a,b) for(int i=(a);i>=(b);i--)
#define BTW(i,a,b) a <= i && i <= b
 
#define DB(x) cerr << #x << ": " << x << endl;
 
#define fi first
#define se second
#define PUB push_back
#define POB pop_back
#define PUF push_front
#define POF pop_front
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
 
const double EPS = 1e-9;
const double PI = acos(-1);
const ll MOD = 1e9+7;
const int INF = 0x7FFFFFFF;
const ll LINF = 0x7FFFFFFFFFFFFFFFLL;
const ull UINF = 0xFFFFFFFFFFFFFFFFLL;
const int dCol[] = {0,+1,0,-1,+1,+1,-1,-1};
const int dRow[] = {-1,0,+1,0,-1,+1,+1,-1};
 
template <typename T>
inline void VIN(vector<T> &i){ T x; cin >> x; i.PUB(x); }
inline void FIO(string i){ freopen((i+".in").c_str(), "r", stdin); freopen((i+".out").c_str(), "w", stdout);}
 
 
int N, ans = 0;
int data[100005];
int frek[2][100005];
vector<pi> gtw[2];
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> N;
	FOR(i,0,N) cin >> data[i];
	FOR(i,0,2) for(int j=i;j<N;j+=2){
		frek[i][data[j]]++;
	}

	for(int i=1;i<=100000;i++){
		if(frek[0][i] > 0) gtw[0].PUB({frek[0][i], i});
		if(frek[1][i] > 0) gtw[1].PUB({frek[1][i], i});
	}
	
	FOR(i,0,2) sort(gtw[i].begin(), gtw[i].end(), greater<pi>());
	//for(auto elm:gtw[0]) cout << elm.fi << " " << elm.se << endl;

	if(gtw[0][0].se == gtw[1][0].se){
		ans = max(gtw[0].front().fi, gtw[1].front().fi);
		if(gtw[1].size() > 1) ans = max(ans, gtw[0][0].fi+gtw[1][1].fi);
		if(gtw[0].size() > 1) ans = max(ans, gtw[0][1].fi+gtw[1][0].fi);
	}else{
		ans = gtw[0][0].fi+gtw[1][0].fi;
	}

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

Measured memory_bytes: 2428
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


int main()
{
	ll n, k;
	
	cin >> n >> k;

	if (k == 0)
	{
		cout << n * n << endl;
		return 0;
	}

	ll ans = 0;

	for(ll i = 1; i < n+1; i++)
	{
		/*
		if (i-1 >= k)
		{
			ans += (n / i) * (i - k);
			ans += max((n % i)- k + 1, 0ll);
		}
		*/
		if(i-1 >= k) {
	      ans += n/i*(i-k);
	      ans += max(0LL, (n%i) - k + 1);
	    }
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256