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

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int get_random(int l, int r) {
  int k = r - l + 1;
  return l + rng() % k;
}

const int N = 365 + 7;
const int K = 26 + 7;
int n;
int c[K], s[N][K], t[N], last[K], sol[N], best = -(int) 2e9, univ;
set<int> pos[K];

void reset_univ() {
  univ = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      univ -= c[j] * i;
    }
  }
  /**for (int i = 1; i <= m; i++) {
    univ += s[i][t[i]];
    last[t[i]] = i;
    for (int j = 1; j <= 26; j++) {
      univ += c[j] * last[j];
    }
  }**/
}

int get() {
  for (int j = 1; j <= 26; j++) {
    last[j] = 0;
  }
  int sol = 0, grow = 0;
  for (int i = 1; i <= n; i++) {
    sol += s[i][t[i]];
    grow += c[t[i]] * (i - last[t[i]]);
    last[t[i]] = i;
    sol += grow;
  }
  return sol;
}

void upd() {
  int cur = get();
  if (cur > best) {
    best = cur;
    for (int i = 1; i <= n; i++) {
      sol[i] = t[i];
    }
  }
}

void make_better(double seconds) {
  time_t bg = clock();
  int c = 0;
  int cur = get();
  while (1) {
    c++;
    if (c % 10 == 0) {
      time_t nd = clock();
      if ((double) (nd - bg) / CLOCKS_PER_SEC > seconds) {
        break;
      }
    }
    int i = get_random(1, n), x = get_random(1, 26);
    while (x == t[i]) {
      x = get_random(1, 26);
    }
    int init = t[i];
    t[i] = x;
    int after = get();
    if (after > cur) {
      cur = after;
    } else {
      t[i] = init;
    }
  }
  upd();
}

void generate_max() {
  for (int i = 1; i <= n; i++) {
    t[i] = 1;
    for (int j = 1; j <= 26; j++) {
      if (s[i][j] > s[i][t[i]]) {
        t[i] = j;
      }
    }
  }
}

void generate_random() {
  generate_max();
  int modif = get_random(1, 20);
  while (modif--) {
    int i = get_random(1, n), x = get_random(1, 26);
    while (t[i] == x) {
      x = get_random(1, 26);
    }
    t[i] = x;
  }
}

void generate_random2() {
  t[1] = 1;
  for (int j = 1; j <= 26; j++) {
    if (c[j] > c[t[1]]) {
      t[1] = j;
    }
  }
  for (int i = 2; i <= n; i++) {
    t[i] = t[1];
  }
  int modif = get_random(1, 100);
  while (modif--) {
    int i = get_random(1, n), x = get_random(1, 26);
    while (t[i] == x) {
      x = get_random(1, 26);
    }
    t[i] = x;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= 26; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      cin >> s[i][j];
    }
  }
  /**for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  int m;
  cin >> m;
  while (m--) {
    int i, x;
    cin >> i >> x;
    upd(i, x);

  }**/
  for (int i = 1; i <= 150; i++) {
    generate_random();
    make_better(0.01);
    upd();
  }
  for (int i = 1; i <= 15; i++) {
    generate_random2();
    make_better(0.01);
    upd();
  }
  generate_max();
  make_better(0.2);
  upd();
  for (int i = 1; i <= n; i++) {
    cout << sol[i] << "\n";
  }
  return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) {
        cin >> S.at(i);
    }

    bool can1 = true, can2;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S.at(i).at(j) == '#') {
                can2 = false;
                if (i - 1 >= 0) {
                    if (S.at(i - 1).at(j) == '#') {
                        can2 = true;
                    }
                }
                if (j - 1 >= 0) {
                    if (S.at(i).at(j - 1) == '#') {
                        can2 = true;
                    }
                }
                if (j + 1 < W) {
                    if (S.at(i).at(j + 1) == '#') {
                        can2 = true;
                    }
                }
                if (i + 1 < H) {
                    if (S.at(i + 1).at(j) == '#') {
                        can2 = true;
                    }
                }
                if (!can2) {
                    can1 = false;
                }
            }
            if (!can1) {
                break;
            }
        }
        if (!can1) {
            break;
        }
    }
    if (can1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
abc="abcdefghijklmnopqrstuvwxyz"

A=str(input())
n=len(A)
#make matrix (a-z)*(n characters)
#次にchrが出てくるindex
word_pos=[]
ct=[n]*26
orda=ord("a")

for i in range(n-1,-1,-1):
    ct[ord(A[i])-orda]=i
    word_pos.append(ct.copy())

word_pos.reverse()

dp=[0]*n+[1,0]
j=n
sep=[]
#区切れめをマーク
for i in range(n-1,-1,-1):
    ct=word_pos[i]
    if(max(ct)<j):
        #remove last chunk
        sep.append(i)
        j=min(ct)
        
if(j==n):
    for i in abc:
        if(i not in A):
            print(i+"\n")
            break

else:
    sep.reverse()
    ans=""
    for i in abc:
        if(i not in A[:sep[0]]):
            ans+=i
            break

    for i in range(0,len(sep)):
        start=sep[i]
        try:
            end=sep[i+1]
        except:
            end=n
        #ans[-1]が出現するタイミング
        next=word_pos[start][ord(ans[-1])-orda]
        for i in range(0,26):
            if(word_pos[next+1][i]>end-1):
                ans+=chr(orda+i)
                break
    ans+="\n"
    print(ans)

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

int main(){
  
  int N; cin >> N;
  
  vector<int> C(N);
  
  for(int i = 0; i < N; i++){
    cin >> C[i];
  }
  
  int max = *max_element(C.begin(),C.end());
  
  int sum = 0;
  for(int i = 0 ; i < N; i++){
    sum += C[i];
  }
  
  cout << (max/2) + (sum - max) << endl;
  
  return 0;
}
  
  

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include<set>
using namespace std;
typedef long long ll;
const int maxn=int(1e5 + 5);
int arr[maxn];
set<int>S;
int main()
{
	S.clear(); int sizes = 0;
	int n; cin >> n;
	for (int i = 1; i <= n; i++)scanf("%d", &arr[i]);
	int tmp = 1;
	int ans = 0,k=1;
	while (1) {
		 tmp = arr[tmp];
		 if (tmp == 2) { ans = k; break; }
		 S.insert(tmp); sizes++;
		 if (S.size() < sizes) { ans = -1; break; }
		 k++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    if (x >= y) {
        cout << "War";
        return 0;
    }

    vector<int> xp;
    xp.PB(x);
    vector<int> yp;
    yp.PB(y);

    int num;
    REP(_,n){
        cin >> num;
        xp.PB(num);
    }
    REP(_,m){
        cin >> num;
        yp.PB(num);
    }

    SORT(xp);
    SORT(yp);

    if (xp[n] >= yp[0])
        cout << "War";
    else
        cout << "No War";
}

Measured memory_bytes: 256
/*GRATITUDE*/
//Arise Awake and Stop Not Till the Goal is reached. You are the greatest of all. Hare Krishna
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ff              first
#define ss              second
#define uint            unsigned long long
#define int             long long
#define double           long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define vpii            vector<pii>
#define umpii           unordered_map<int,int>
#define ustii           unordered_set<int>   
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             10000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define all(x)             x.begin(), x.end()
#define all_r(x)           x.rbegin(), x.rend()
#define sortall(x)         sort(all(x))
#define sortall_r(x)       sort(all_r(x))  
#define tr(it, a)          for(auto it = a.begin(); it != a.end(); it++)
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);
#endif
}
/*************************************************************************************************/
//Write your functions here..............................


/***************************************************************************************************/
void solve() {
/*Write your code here*/
int x,y; cin>>x>>y;
if((y-2*x)%2||(4*x-y)%2||(y-2*x)<0||(4*x-y)<0) cout<<"No";
else cout<<"Yes";
}
int32_t main()
{
ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 



Measured memory_bytes: 3636
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int a, b, c;
		Boolean t = true;
		a = in.nextInt();
		b = in.nextInt();
		c = in.nextInt();

		if (a >= b)
			t = false;	
		if (b >= c)
			t = false;

		if (t)
			System.out.println("Yes");
		else
		{
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 26316
import itertools
import math

def ceiler(list):
    a, b, c, d, e = list
    a = math.ceil(a/10)
    b = math.ceil(b/10)
    c = math.ceil(c/10)
    d = math.ceil(d/10)
    return a, b, c, d, e
    
l = [int(input()) for _ in range(5)]

a, b, c, d, e = ceiler(l)
time = (a + b + c + d)*10 + e

for i in itertools.permutations(l):
    a, b, c, d, e = ceiler(i)
    if time > (a + b + c + d)*10 + e:
        time = (a + b + c + d)*10 + e
print(time)


Measured memory_bytes: 3064
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.trim();
    var N = input.split('\n')[0].split(' ')[0];
    var K = input.split('\n')[0].split(' ')[1];
    var ans = [];
    var array = input.split('\n');
    array.shift();
    for (var i = 1; i < array.length; i = i + 2) {
        var num = array[i].split(' ');
        var abc = num.map(Number);
        abc.map(Number);
        var array2 = ans.concat(abc);
        ans = array2;
    }
    var result = ans.filter(function (x, i, self) {
        return self.indexOf(x) === i;
    });
    var answer = N - result.length;
    console.log(answer);
    
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 31712
let sl = Str.split (Str.regexp " ") @@ read_line ()
let il = List.map int_of_string sl

(* let ar = Array.of_list il *)

let il' = List.sort (-) il

let rec func = function
    h :: [] -> print_endline @@ string_of_int h
  | h :: l' -> print_string @@ string_of_int h; print_string " "; func l'
  | [] -> ()

let () = func il'

Measured memory_bytes: 2220
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;

typedef long long ll;

const ll MAX_N = 2e5 + 10;
ll n, ans, tmp;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	n = s.size();
	tmp = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'A') {
			tmp++;
			continue;
		}

		if (s[i] == 'C') {
			tmp = 0;
			continue;
		}

		if (s[i] == 'B') {
			if (i + 1 < n && s[i + 1] == 'C') {
				i++;
				ans += tmp;
				continue;
			}

			tmp = 0;
		}
	}

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

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int A, B, M;
  cin >> A >> B >> M;

  vector<int> a(A), b(B);
  for (int i = 0; i < A; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < B; ++i) {
    cin >> b[i];
  }
  int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());

  for (int i = 0; i < M; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    ans = min(ans, (a[x - 1] + b[y - 1] - z));
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 1024
# Keyence 2020 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
h=ni()
t=int(math.log2(h))
# print(t)
# print(2**t)
ans=0
for i in range(t+1):
    ans+=2**i
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 1e5 + 5;
const int M = 21;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

void solve() {
    LL s, t, d;
    cin >> d >> t >> s;
    cout << (s * t >= d ? "Yes\n" : "No\n");
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1;t<=T;++t) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 3612
#include <iostream>

using namespace std;
#define NIL -1;

struct Node{int parent, left, right;};
Node T[600000];
int D[600000];

int getDepth(int u){
    int d=0;
    while(T[u].parent!=-1){
        u=T[u].parent;
        d++;
    }
    return d;
}

void setDepth(int u, int p){
    D[u]=p;
    if(T[u].right!=-1)setDepth(T[u].right,p);
    if(T[u].left!=-1)setDepth(T[u].left,p+1);
}

void print(int u){
    int i,c;
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].parent<<", ";
    cout<<"depth = "<<D[u]<<", ";

    if(T[u].parent==-1)cout<<"root, ";
    else if(T[u].left==-1)cout<<"leaf, ";
    else cout<<"internal node, ";

    cout<<"[";

    for(i=0,c=T[u].left;c!=-1;i++,c=T[c].right){
        if (i) cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;

}

int main()
{
    int n,i,v,d,c,l,r;
    cin>>n;
    for(i=0;i<n;i++)T[i].parent=T[i].left=T[i].right=-1;
    for(i=0;i<n;i++){
        cin>>v>>d;
        for(int j=0;j<d;j++){
            cin>>c;
            if (j==0)T[v].left=c;
            else T[l].right=c;
            l=c;
            T[c].parent=v;
        }
    }

    for(i=0;i<n;i++){
        if(T[i].parent==-1) r=i;
    }
    setDepth(r,0);

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

    return 0;
}


Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#define mp make_pair
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

vector<vector<LL>> adj;
vector<bool> visited;
vector<LL> cnt;
LL tin = 0;
LL base = -1;
LL cycle_size = -1;

void dfs(LL s)
{
    if (!visited[s])
    {
        visited[s] = true;
        cnt[s] = ++tin;
        for (auto x : adj[s])
        {
            dfs(x);
        }
    }
    else
    {
        base = s;
        cycle_size = 1 + tin - cnt[s];
    }
}

int main()
{
    fastinput;
    LL n, i, j, k, t, temp;
    cin >> n >> k;
    LL num_visits = k + 1;
    adj.resize(n + 1);
    cnt.resize(n + 1);
    visited.resize(n + 1);
    for (i = 1; i <= n; i++)
    {
        cin >> j;
        adj[i].pb(j);
        visited[i] = false;
        cnt[i] = -1;
    }

    dfs(1);

    LL left = num_visits - cnt[base];
    //debug(num_visits);
    //debug(cnt[base]);
    if (left < 0)
    {
        LL search=num_visits;;
        for (i = 1; i <= n; i++)
        {
            if (cnt[i] == search)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
    //debug(base);
    //debug(cycle_size);
    //debug(left);
    LL search = cnt[base] + left % cycle_size;
    //debug(search);
    for (i = 1; i <= n; i++)
    {
        if (cnt[i] == search)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 21776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, l;

    cin >> n >> l;

    vector<string> s(n);

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

    sort(s.begin(), s.end());

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

    return 0;
}


Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
# a = 100 * a(g)の水を入れる
# b = 100 * b(g)の水を入れる
# c = c(g)の砂糖を入れる
# d = d(g)の砂糖を入れる
# e = 100(g)あたりの水に溶ける砂糖
# f = 水の質量と砂糖の質量の合計
# 砂糖水の濃度 = 100 * b / (a + b) (%)
# 答え = 1つ目は求める砂糖水の質量、2つ目はそれに溶けている砂糖の質量

xs = set()
ys = set()

a_limit = f // (100 * a)
for i in range(a_limit + 1):
    b_limit = (f - (100 * a * i)) // (100 * b)
    for j in range(b_limit + 1):
        if i == 0 and j == 0:
            continue
        x = 100 * a * i + 100 * b * j
        xs.add(x)

c_limit = f // c
for i in range(c_limit + 1):
    d_limit = (f - c * i) // d
    for j in range(d_limit + 1):
        y = c * i + d * j
        ys.add(y)

density_limit = e / (100 + e)
max_density = 0.0
w = 0
s = 0
for x in xs:
    for y in ys:
        density = y / (x + y)
        if f >= x + y and density_limit >= density and density >= max_density:
            max_density = density
            w = x + y
            s = y

print(w, s)


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

inline int read(){
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	x=c-48;
	while((c=getchar())>='0'&&c<='9')x=x*10+c-48;
	return x;
}

const int maxn=2e5+10;
int n,a,b,uu[maxn],vv[maxn],dep[maxn],fa[20][maxn],dist[maxn],ans;
int ecnt,ebeg[maxn],enxt[maxn<<1],eto[maxn<<1];
int eecnt,eebeg[maxn],eenxt[maxn<<1],eeto[maxn<<1];
bool safe[maxn];

inline void ae(int u,int v){
	++ecnt;
	enxt[ecnt]=ebeg[u];
	ebeg[u]=ecnt;
	eto[ecnt]=v;
}
inline void aee(int u,int v){
	++eecnt;
	eenxt[eecnt]=eebeg[u];
	eebeg[u]=eecnt;
	eeto[eecnt]=v;
}
inline void chkmax(int&a,int b){
	if(a<b)a=b;
}
void dfs(int pos){
	for(int i=ebeg[pos],v;i;i=enxt[i])
		if((v=eto[i])!=fa[0][pos]){
			fa[0][v]=pos;
			dep[v]=dep[pos]+1;
			dfs(v);
		}
}
int lca(int u,int v){
	if(dep[u]<dep[v])u^=v,v^=u,u^=v;
	for(int i=19;~i;--i)
		if(dep[fa[i][u]]>dep[v])
			u=fa[i][u];
	if(dep[u]>dep[v])
		u=fa[0][u];
	for(int i=19;~i;--i)
		if(fa[i][u]!=fa[i][v])
			u=fa[i][u],v=fa[i][v];
	if(u!=v)
		u=fa[0][u],v=fa[0][v];
	return u;
}
void dfss(int pos,int last){
	chkmax(ans,dep[pos]);
	if(dist[pos]>=dep[pos])
		return;
	if(safe[pos]){
		puts("-1");
		exit(0);
	}
	for(int i=eebeg[pos];i;i=eenxt[i])
		if(eeto[i]!=last){
			dist[eeto[i]]=dist[pos]+1;
			dfss(eeto[i],pos);
		}
}

int main(){
	n=read();a=read();b=read();
	for(int i=1;i<n;++i)
		uu[i]=read(),vv[i]=read();
	for(int i=1,u,v;i<n;++i){
		u=read();v=read();
		ae(u,v);
		ae(v,u);
	}
	dfs(b);
	for(int i=1;i<20;++i)
		for(int j=1;j<=n;++j)
			fa[i][j]=fa[i-1][fa[i-1][j]];
	for(int i=1,u,v;i<n;++i){
		u=uu[i];v=vv[i];
		aee(u,v);aee(v,u);
		if(dep[u]+dep[v]-dep[lca(u,v)]*2>=3)
			safe[u]=safe[v]=true;
	}
	dfss(a,0);
	printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 32896
#include <iostream>
using namespace std;
int main(){
  int x, y = 0;
  while(true){
    cin >> x >> y;
    if(!x){
      break;
    }
    for(int i = 0; x > i; i++){
      for(int j = 0; y > j; j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3100
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt");
    if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll M; cin >> M;
    ll D = 0, S = 0;
    rep(i, M){
        ll d, c; cin >> d >> c;
        D += c; S += d*c;
    }
    cout << D-1 + (S-1)/9 << endstr;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

// ABC 85-D
// https://beta.atcoder.jp/contests/abc085/tasks/abc085_d

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		
		int diff = Math.abs(A - B);
		System.out.println(diff % 2 == 0 ? "Alice" : "Borys");
	}
}


Measured memory_bytes: 21972
n, s = map(int, input().split())
*A, = map(int, input().split())
p = 998244353
DP = [[0 for j in range(s + 1)] for i in range(n + 1)]
for i in range(1, n + 1):
    for j in range(s + 1):
        DP[i][j] += DP[i - 1][j]
        if j >= A[i - 1]:
            DP[i][j] += DP[i - 1][j - A[i - 1]]
        if j == A[i - 1] or j == 0:
            DP[i][j] += 1
        DP[i][j] %= p
ans = 0
for i in range(1, n + 1):
    ans += DP[i][s]
    ans %= p
print(ans)


Measured memory_bytes: 120284
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 1000000007;
#define int ll
int n, a, b;
 
ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}
 
int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
   	cin>>n>>a>>b;
   	if((a-b)%2==0) cout<<(b-a)/2;
   	else cout<<min((a+b-1)/2, n-b+1+(b-a-1)/2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
#define inf 0x3f3f3f3f
int a[100050];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	sort(a,a+n);
	int maxn=1e9;
	int ans;
	for(int i=0;i<n-1;i++)
	{
		int x=abs(a[i]-(a[n-1]+1)/2); 
		if(x<maxn)
		{
			maxn=abs(a[i]-(a[n-1]+1)/2);
			ans=a[i];
		}
	}
	cout<<a[n-1]<<" "<<ans;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A+B+C>=22){
    cout<<"bust"<<endl;
  }
  else{
    cout<<"win"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e6+5;
const dd eps = 1e-8;
const ll mod = 1e9+7;
ll x,y,m,n;
ll fac[N];

inline ll qpow(ll a,ll b){
  ll ans = 1;
  a = (a%mod + mod)%mod;
  for(;b;b >>= 1){
    if(b&1) ans = (a*ans)%mod;
    a = (a*a)%mod;
  }
  return ans;
}

ll comb(ll n,ll m){
  ll up = fac[n];
  ll down = ((qpow(fac[n-m],mod-2)%mod)*(qpow(fac[m],mod-2)%mod))%mod;
  return ((up%mod)*(down%mod))%mod;
}

int main(){
  // freopen("input.txt","r",stdin);
  ios::sync_with_stdio(false);
  cin>>x>>y;
  if((x+y)%3 != 0){
    cout<<"0"<<endl;
    return 0;
  }
  m = (2*x-y)/3;n = (2*y-x)/3;
  if(m < 0 || n < 0){
    cout<<"0"<<endl;
    return 0;
  }
  fac[0] = 1;
  for(int i = 1;i <= 2e6;i++){
    fac[i] = (fac[i-1]*i*1ll)%mod;
  }
  cout<<comb(m+n,n)<<endl;
  return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    int x,t;
    cin>>x>>t;
    cout<<max(0, x-t)<<endl;
}


Measured memory_bytes: 256
N = int(input())
C = [list(map(int,input().split())) for _ in range(N-1)]

for i in range(N-1):
    now = 0
    for j in range(i,N-1):
        now = max(C[j][1], -(-now//C[j][2])*C[j][2])
        now += C[j][0]
    print(now)
print(0)

Measured memory_bytes: 9124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 
import static java.lang.Integer.parseInt;
 
/**
 * Cyclic Sugoroku
 */
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
 
        int N = parseInt(br.readLine());
        int[] a = new int[N];
 
        StringTokenizer st = new StringTokenizer(br.readLine());
 
        for (int i = 0; i < N; i++) {
            a[i] = parseInt(st.nextToken());
        }
 
        //
        int[] indeg = new int[N];
        boolean[] used = new boolean[N];
 
        for (int i = 0; i < N; i++) {
            indeg[(i + a[i]) % N]++;
        }
 
 
        for (int i = 0; i < N; i++) {
            int j = i;
            while (!used[j] && indeg[j] == 0) {
                used[j] = true;
                j = (j + a[j]) % N;
                indeg[j]--;
            }
        }
 
//      System.out.println(Arrays.stream(indeg).filter(x -> x != 0).count());
 
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (indeg[i] != 0) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 45368
#include <iostream>

using namespace std;

int N;

#define MAX_N 10000005
int F[MAX_N];

void build_f() {
  F[1] = 0;
  for (int i = 1; i < MAX_N; i++) {
    for (int j = 1; i * j < MAX_N; j++) {
      F[i*j]++;
    }
  }
  // for (int i = 0; i < 100; i++) {
  //   printf("F[%d] = %d\n", i, F[i]);
  // }
}

int main() {
  cin >> N;
  build_f();
  long long ans = 0;
  for (long long i = 1; i <= N; i++) {
    ans += i * F[i];
  }
  cout << ans << endl;
}

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

int main()
{
    int a;
    int b;

    cin >> a;
    cin >> b;

    if (a < 10 && b < 10)
    {
        cout << a*b << endl;
    }
    else
    {
        cout << "-1" << endl;
    }

    return 0;
}


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

bool isStable(string in[], string out[], int N){
    int values[N];
    for(int i = 0; i <= N-1; i++){
        values[i] = atoi(in[i].substr(1, 1).c_str());
    }
    for(int i = 0; i <= N-1; i++){
        for(int j = i+1; j <= N-1; j++){
            for(int a = 0; a <= N-1; a++){
                for(int b = a+1; b <= N-1; b++){
                    if(values[i] == values[j] && in[i] == out[b] && in[j] == out[a]){
                        return false;
                    }
                }
            }
        }
    }
    
    return true;
}

void BubbleSort(string C[], int N){
    int values[N];
    string C_original[N];
    
    //数値だけ取り出す、Cのコピー
    for(int i = 0; i < N; i++){
        values[i] = atoi(C[i].substr(1, 1).c_str());
        C_original[i] = C[i];
    }
    
    for(int i = 0; i < N; i++){
        for(int j = N-1; j > 0; j--){
            if(values[j] < values[j-1]){
                int tmp = values[j];
                values[j] = values[j-1];
                values[j-1] = tmp;
                
                string str = C[j];
                C[j] = C[j-1];
                C[j-1] = str;
                
            }
        }
    }
    
    //出力
    for(int i = 0; i < N; i++){
        if(i == 0){
            cout << C[i];
        }else{
            cout << " " << C[i];
        }
    }
    
    cout << endl;
    
    if(isStable(C, C_original, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    
}

void SelectionSort(string C[], int N){
     int values[N];
     string C_original[N];
    
    //数値だけ取り出す、Cのコピー
    for(int i = 0; i < N; i++){
        values[i] = atoi(C[i].substr(1, 1).c_str());
        C_original[i] = C[i];
    }
    
    int minj;
    for(int i = 0; i < N; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(values[j] < values[minj]){
                minj = j;
            }
        }
        
        int tmp = values[i];
        values[i] = values[minj];
        values[minj] = tmp;
        
        string str = C[i];
        C[i] = C[minj];
        C[minj] = str;
        
    }
    
    for(int i = 0; i < N; i++){
        if(i == 0){
            cout << C[i];
        }else{
            cout << " " << C[i];
        }
    }
    
    cout << endl;
    
    if(isStable(C, C_original, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    
}

int main(void){
    int N;
    
    cin >> N;
    
    string cards[N];
    string cards_copy1[N], cards_copy2[N];
    
    for(int i = 0; i < N; i++){
        cin >> cards[i];
        cards_copy1[i] = cards[i];
        cards_copy2[i] = cards[i];
    }
    
    BubbleSort(cards_copy1, N);
    SelectionSort(cards_copy2, N);
    
}



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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> C(N-1), S(N-1), F(N-1);
    for(int i=0;i<N-1;i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i=0;i<N-1;i++){
        int T = S[i] + C[i];
        for(int j=i+1;j<N-1;j++){
            while(true){
                if(T%F[j] == 0 && T >= S[j]) break;
                T++;
            }
            T += C[j];
        }
        cout << T << endl;
    }
    cout << 0 << endl; // for N-th station

    return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;


int32_t main(){
    boost;

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt" , "r" , stdin); 
    // freopen("output.txt" , "w", stdout);
    // #endif
    
    int n;
    cin >> n;
    pair<int,int> a[n];
    for(int i = 0 ; i < n ; ++i){
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a,a+n);

    for(int i = 0 ; i < n ; ++i){
        if(a[n-1].second != i){
            cout << a[n-1].first << "\n";
        }
        else{
            cout << a[n-2].first << "\n";  
        }
    }
    return 0;
}

Measured memory_bytes: 4736
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  ll X, Y;
  cin >> X >> Y;
  if(X < Y) {
    swap(X, Y);
  }
  if(X - Y >= 2) {
    cout << "Alice" << endl;
  } else {
    cout << "Brown" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int h,n,t,sum=0,i;
    cin>>h>>n;
    for(i=0;i<n;++i)
    {
        cin>>t;
        sum += t;
    }
    if(sum >= h)    cout<<"Yes";
    else    cout<<"No";
	return 0;
}

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


class Dice{
	int dn[6];
	int ori[6];
	int up, front;
	string qu;

public:
	Dice(int d1, int d2, int d3, int d4, int d5, int d6){
		dn[0] = d1;
		dn[1] = d2;
		dn[2] = d3;
		dn[3] = d4;
		dn[4] = d5;
		dn[5] = d6;

		ori[0] = d1;
		ori[1] = d2;
		ori[2] = d3;
		ori[3] = d4;
		ori[4] = d5;
		ori[5] = d6;
	}

	void Result(string m){
		int w;
		qu = m;
		for (int i = 0; i < 6; i++){
			dn[i] = ori[i];
		}

		for (int i = 0; i < qu.size(); i++){
			switch (qu[i]){
			case 'E':
				w = dn[0];
				dn[0] = dn[3];
				dn[3] = dn[5];
				dn[5] = dn[2];
				dn[2] = w;
				break;

			case 'N':
				w = dn[5];
				dn[5] = dn[4];
				dn[4] = dn[0];
				dn[0] = dn[1];
				dn[1] = w;
				break;

			case 'S':
				w = dn[0];
				dn[0] = dn[4];
				dn[4] = dn[5];
				dn[5] = dn[1];
				dn[1] = w;
				break;

			case 'W':
				w = dn[0];
				dn[0] = dn[2];
				dn[2] = dn[5];
				dn[5] = dn[3];
				dn[3] = w;
				break;
			}
		}
	}

	int get0(){
		return dn[0];
	}
	int get1(){
		return dn[1];
	}
	int get2(){
		return dn[2];
	}
	int get3(){
		return dn[3];
	}
	int get4(){
		return dn[4];
	}
	int get5(){
		return dn[5];
	}
};

int main()
{
	int d1[6];
	int d2[6];
	string quu[23] = { "WSE", "ESW", "WSSE", "SWW", "EN", "WN", "N", "SW", "W", "SSW",
		"NW", "SE", "E", "SSE", "NE", "S", "WS", "ES", "WWS", "WW", "SWS", "SES", "SS" };
	string q;
	string flag = "No";
	int count = 0;

	for (int i = 0; i < 6; i++){
		cin >> d1[i];
	}
	for (int i = 0; i < 6; i++){
		cin >> d2[i];
	}

	Dice dice2(d2[0], d2[1], d2[2], d2[3], d2[4], d2[5]);

	for (int i = 0; i < 6; i++){
		if (d1[i] == d2[i]){
			count = count + 1;
		}
	}
	if (count == 6){
		flag = "Yes";
	}
	count = 0;

	for (int i = 0; i < 23; i++){
		dice2.Result(quu[i]);

		d2[0] = dice2.get0();
		d2[1] = dice2.get1();
		d2[2] = dice2.get2();
		d2[3] = dice2.get3();
		d2[4] = dice2.get4();
		d2[5] = dice2.get5();

		for (int j = 0; j < 6; j++){
			if (d1[j] == d2[j]){
				count = count + 1;
			}
		}
		if (count == 6){
			flag = "Yes";
		}
		count = 0;
	}

	cout << flag << endl;
	
	return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double l;
    cin >> l;
    double m = l / 3;
    cout << fixed << setprecision(10);
    cout << m * m * m << endl;
    return 0;
}


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



using namespace std;



int main(){



	char s[11];

	cin >> s;



	int i=0, mi=800;

	while(s[i+2]!='\0'){

		int a = (int)s[i] - 48;

		int b = (int)s[i+1] - 48;

		int c = (int)s[i+2] - 48;

		

		int cur = a*100+b*10+c;

		cur = abs(cur - 753);

		mi = min(mi, cur);

		i++;

	}

	cout << mi << endl;

	return 0;

}

Measured memory_bytes: 256
def main():
  from collections import Counter
  from collections import defaultdict
  from collections import deque
  from itertools import accumulate
  from itertools import combinations
  from itertools import permutations
  from itertools import product
  import sys
  sys.setrecursionlimit(10**6)
  readline = sys.stdin.readline
  ints = lambda: map(int, readline().split())
  floats = lambda: map(float, readline().split())
  lli = lambda I, J: [[0] * J for _ in range(I)]
  mod = 10**9+7

  h, w, k = ints()
  ans = h + w
  s = [list(map(int, input())) for _ in range(h)]
  for comb in product([False, True], repeat=h - 1):
    divs = 0
    a = [s[0][:]]
    for row, isd in zip(s[1:], comb):
      if isd:
        a += [row[:]]
        divs += 1
      else:
        for i in range(w):
          a[divs][i] += row[i]
    dh = divs + 1
    ta = [list(i) for i in zip(*a)]
    currow = ta[0]
    imp = False
    for row in ta[1:]:
      if any([i > k for i in currow]):
        imp = True
        break
      else:
        temp = [i + j for i, j in zip(currow, row)]
        if any([i > k for i in temp]):
          currow = row
          divs += 1
        else:
          currow = temp
    if not imp:
      ans = min(ans, divs)
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 86364
def main():
    k = int(input())
    A, B = map(int, input().split(" "))

    m = A % k
    
    if m==0:
        print("OK")
    else:
        if (k-m) <= (B-A):
            print("OK")
        else:
            print("NG")
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 61632
N=int(input())
a=list(map(int,input().split()))

cnt=0
counterarr=[0 for _ in range(N)]
others=[]
for i in range(N):
    if a[i]-1<N:
        counterarr[a[i]-1]+=1
    else:
        others.append(a[i])
for i in range(N):
    shoudbe=i+1
    now=counterarr[i]
    if shoudbe>now:
        cnt+=now
    elif shoudbe<now:
        cnt+=now-shoudbe
cnt+=len(others)
print(cnt)

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

#define pii					pair<int,int>
#define vi                  vector<int>
#define vii					vector<std::vector<int>> v;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define sonic               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define itr(it,c)           for(auto const &it : c)
#define all(c)              c.begin(), c.end()
#define ff                  first
#define ss                  second
#define INF                 INT_MAX
#define REPl(i,a,b)         for (ll i=a;i<b;i++)
#define REPi(i,a,b)			for (ll i=a;i<b;i++)
//*******Uer-Defined Functions*********//

//*******Functions end here************//
//*******Main func starts**************//
int main()
{
/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    */
    sonic;
	char c;
	cin >> c;
	if (c >= 'A' && c <= 'Z')
		cout << 'A' << endl;
	else if (c >= 'a' && c <= 'z')
		cout << 'a' << endl;
}
//******Main Ends here****************//

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  cout << (N + 1'000 - 1) / 1'000 * 1'000 - N << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    set<string> cand;
    rep(i, s.size())
    {
        for (int j = 1; j <= K && i + j <= s.size(); j++) {
            //cout << i << " " << j;
            string sub = s.substr(i, j);
            cand.insert(sub);
            if (cand.size() > K) {
                cand.erase(prev(cand.end(), 1));
            }
        }
    }
    cout << *prev(cand.end(), 1) << endl;

    return 0;
}

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

int main(void) {
    int T, A, B, fee;
    cin >> T >> A >> B;

    fee = A*T;
    if (B < fee) {
        cout << B << endl;
    } else {
        cout << fee << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

int32_t main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();
    int n;
    cin >> n;
    int w;
    cin >> w;
    int dp[n + 1][w + 1];
    memset(dp, 0, sizeof(dp));
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (j < v[i - 1].first)
            {
                dp[i][j] = dp[i - 1][j];
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], (v[i - 1].second + dp[i - 1][j - v[i - 1].first]));
            }
        }
    }
    cout<<dp[n][w];
    return 0;
}

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

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

ll cal(int w,int h,int k) {
	ll ret=0;
	for(int d=0;d<h;d++)
		for(int j=1;j<w&&1ll*d*j<=k+k+w-2;j++) {
			int val=k+k+__gcd(w,d)-2-d*j;
			if(val<0) continue;
			int lim=min(h-1-d,val/w),cnt=lim;
			if(lim+1<=h-1-d&&1ll*(lim+1)*w-__gcd(lim+1,j)-__gcd(w-j,lim+1+d)<=val) ++cnt;
			ret+=cnt*(d==0?1:2);
		}
	return ret;
}

int main() {
	int w,h,k;cin>>w>>h>>k;
	cout<<(cal(w,h,k)+cal(h,w,k))*2;
	return 0;
}


Measured memory_bytes: 3640
A,B,C=map(int,input().split())
a,b,c = 0,0,0
total = A+B+C
count = 0
while 1:
    a = max(A,B,C)
    c = min(A,B,C)
    b = total - (a+c)
    if a == b and b==c:
        break
    elif a == b and b > c:
        c += 2
    elif a > b and b == c:
        b += 1
        c += 1
    else:
        b += 1
        c += 1
    count += 1
    A = a
    B = b
    C = c
    total = A+B+C
print(count)

Measured memory_bytes: 3064