akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    for i in sorted(
            set(range(A, min(B + 1, A + K))) |
            set(range(max(A, B + 1 - K), B + 1))):
        print(i)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
bool solve(vector<int> &a,int num,int x){
	int size=a.size();
	if(x==0) return true;
	if(num>=size) return false;
	int ans1 = solve(a,num+1,x);
	int ans2 = solve(a,num+1,x-a[num]);
	if(ans1==1) return true;
	if(ans2==1) return true;
	return false;
}

int main(){
	int n,m,i;
	cin>>n;
	vector<int> a(n);
	for(i=0; i<n; i++){
		cin>>a[i];
	}
	cin>>m;
	int b[m];
	for(i=0; i<m; i++){
		cin>>b[i];
	}
	for(i=0; i<m; i++){
		if(solve(a,0,b[i])){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector <int> a(n + 1);
  for (int i = 1; i <= n; i++) {
	  cin >> a[i];
	}
  vector <int> b(n + 1, 0);
  vector <int> ans;
  int count = 0;
  for (int i = n; i >= 1; i--) {
	  int j = 2 * i;
	  int c = 0;
	  while (j <= n) {
		  if (b[j]) {
			  c = (c + 1) & 1;
			}
		  j += i;
		}
	  if (c != a[i]) {
		  b[i] = 1;
		  ans.push_back(i);
		  count++;
		}
	}
  cout << count << endl;
  for (int i = 0; i < count - 1; i++) {
	  cout << ans[i] << " ";
	}
  if (count > 0) {
	  cout << ans[count - 1] << endl;
	}
  return 0;
}


Measured memory_bytes: 3064
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");

typedef long long ll;
typedef long double ld;

void solve(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int res = min(a, k);
    k -= min(a, k);
    if(k <= 0){
        cout << res << "\n";
        return;
    }
    k -= min(b, k);
    if(k <= 0){
        cout << res << "\n";
        return;
    }
    res -= (min(c, k));
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}


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

#define ll_inf 1000000000000;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll>s(A+2);
    s[0] = 0 - ll_inf;
    s[A+1] = ll_inf;
    for (int i = 1; i <= A; ++i) {
      cin >> s[i];
    }
    vector<ll>t(B+2);
    t[0] = 1 - ll_inf;
    t[B+1] = 1 + ll_inf;
    for (int i = 1; i <= B; ++i) {
      cin >> t[i];
    }
    vector<ll>x(Q);
    for (int i = 0; i < Q; ++i) {
      cin >> x[i];
    }

    // s, t, q は全て異なるので upper_bound で二分探索
    // ll_inf を最初と最後に加えてあるので配列外には飛ばない
    for (int i = 0; i < Q; ++i) {
        ll sL, sR, tL, tR;
        auto iter1 = upper_bound(s.begin(), s.end(), x[i]);
        sR = *iter1;
        sL = *--iter1;
        auto iter2 = upper_bound(t.begin(), t.end(), x[i]);
        tR = *iter2;
        tL = *--iter2;

        ll ans = ll_inf;
        if(sL < tL){
            ll temp = min(tL - sL, sR - tL) + x[i] - tL;
            ans = min(ans, temp);
        } else{
            ll temp = min(sL - tL, tR - sL) + x[i] - sL;
            ans = min(ans, temp);
        }
        if(sR < tR){
            ll temp = min(sR - tL, tR - sR) + sR - x[i];
            ans = min(ans, temp);
        } else{
            ll temp = min(tR - sL, sR - tR) + tR - x[i];
            ans = min(ans, temp);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
# coding: utf-8
# Your code here!

class Dice:
    def __init__(self,lst):
        self.face=lst
        self.order="NNNNWNNNWNNNENNNENNNWNNN"
    
    def roll(self,x):
        tmp=self.face
        if x=="E":
            self.face=[tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2]]
        if x=="W":
            self.face=[tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3]]
        if x=="N":
            self.face=[tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4]]
        if x=="S":
            self.face=[tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1]]
    
    def showDown(self):
        return self.face[0]
    
    def query(self,lst):
        tmp=self.face
        ans=-1
        for i in self.order:
            self.roll(i)
            if self.face[0]==lst[0] and self.face[1]==lst[1]:
                ans=self.face[2]
                break
        self.face=tmp
        return ans
    
    def isEqual(self,another):
        tmp=self.face
        ans=False
        for i in self.order:
            self.roll(i)
            flg=True
            for j in range(6):
                if self.face[j]!=another.face[j]:
                    flg=False
                    break
            if flg==True:
                return True
        return ans

num=int(input())
dices=[Dice(list(map(int,input().split()))) for i in range(num)]
flg=True
for i in range(num):
    for j in range(i+1,num):
        if dices[i].isEqual(dices[j])==True:
            flg=False
            break
if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5620
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

bool test = true;
#define log(x) cout << "#x" << " : " << x << "\n";

int main()
{
    FIO;
    char ch;
    cin >> ch;
    if(ch >= 'a' && ch <= 'z') {
        cout << 'a' << "\n";
    } else {
        cout << "A\n";
    }
    return 0;

}



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

int main()
{
	int n, m = 800000001;

	cin >> n;

	vector<pair<int, int> > p;

	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		p.push_back(make_pair(x, y));
	}

	sort(p.begin(), p.end());
	
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int xi = p[i].first, xj = p[j].first;
			if (xj - xi > m)
				break;
			else {
				int yi = p[i].second, yj = p[j].second;
				int r = (xi - xj) * (xi - xj) + (yi - yj) * (yi - yj);
				m = min(m, r);
			}
		}
	}

	cout << m << endl;

	return 0;
}



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

int six[7] = {1, 6, 36, 216, 1296, 7776, 46656};
int nine[6] = {1, 9, 81, 729, 6561, 59049};

int func(int num, int ans){
    if(num < 6) return ans + num;
    int i6, i9;
    i6 = upper_bound(six, six + 7, num) - six;
    i6 = max(0, i6 - 1);
    i9 = upper_bound(nine, nine + 6, num) - nine;
    i9 = max(0, i9 - 1);
    ans++;
    return min(func(num - six[i6], ans), func(num - nine[i9], ans));
} 

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

    int n;
    cin >> n;

    cout << func(n, 0) << endl;

    return 0;
}

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

using namespace std;

int main()
{
	int H, W, max_ = 0;

	scanf("%d", &H);
	scanf("%d", &W);

	vector<vector<int> > c(H, vector<int>(W));

	vector<vector<int> > dp(H, vector<int>(W, 0));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			scanf("%d", &c[i][j]);

			if (c[i][j] == 0)
			{
				if (i == 0 || j == 0)
				{
					dp[i][j] = 1;
				}

				max_ = 1;
			}
		}
	}

	for (int i = 1; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			if (c[i][j] == 0)
			{
				dp[i][j] = min({ dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1] }) + 1;

				max_ = (dp[i][j] > max_ ? dp[i][j] : max_);
			}
		}
	}

	printf("%d\n", max_ * max_);

	return 0;
}

Measured memory_bytes: 17676
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 101

int n, H[N][N], Lim[N][N];

int main()
{
	scanf("%d", &n);
	memset(Lim, 0x3f, sizeof(Lim));
	for (int t = 1, x, y, h; t <= n; t ++)
	{
		scanf("%d%d%d", &x, &y, &h);
		for (int i = 0; i < N; i ++)
			for (int j = 0; j < N; j ++)
			{
				int t = h + abs(i - x) + abs(j - y);
				if (h == 0)
					Lim[i][j] = min(Lim[i][j], t);
				else
				{
					if (!H[i][j] || H[i][j] == t)
						H[i][j] = t;
					else H[i][j] = -1;
				}
			}
	}
	for (int i = 0; i < N; i ++)
		for (int j = 0; j < N; j ++)
			if (H[i][j] > 0 && H[i][j] <= Lim[i][j])
				printf("%d %d %d\n", i, j, H[i][j]);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;
}
ll h,w;
vvl field(h,vl(w));
void dfs(ll y,ll x){
    field[y][x]=0;
    rep(i,8){
        ll ny=y+dy[i],nx=x+dx[i];
        if(ny<0||nx<0||ny>=h||nx>=w)continue;
        if(field[ny][nx]==1){
            dfs(ny,nx);
        }
    }
}
int main(){
    while(true){
        ll ans=0;
        cin >> w >>h;
        if(w==0&&h==0)break;
        field.assign(h,vl(w));
        rep(i,h){
            rep(j,w)cin >> field[i][j];
        }
        rep(i,h){
            rep(j,w){
                if(field[i][j]==1){
                    dfs(i,j);
                    ans++;
                }
            }
        }
        cout <<ans <<endl;
    }
}


Measured memory_bytes: 3268
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int white = 0;
    int black = 0;
    rep(i, N) {
        if (S[i] == '.') white++;
        else black++;
    }
    int ans = INF;
    int W = 0, B = 0;
    rep(i, N) {
        if (S[i] == '.') W++;
        else B++;
        int remainW = white - W;
        int remainB = black - B;
        ans = min(ans, B + remainW);
        ans = min(ans, white);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 848
a = input()
listA=["a","b","c","d","e","f","g","h","i",'j',"k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
flag = 0
for i in range(len(listA)):
    if a == listA[i]:
        print("a")
        flag = 1
        break
if flag == 0:
    print("A")

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
string s;
bool used[26];
int main(){
	cin >> s;
	if(s == "zyxwvutsrqponmlkjihgfedcba") return 0*puts("-1");
	else if(s.size() != 26){
		rep(i, s.size()) used[s[i]-'a'] = true;
		cout << s;
		rep(i,26) if(!used[i]) return 0*printf("%c\n", 'a'+i);
	}else{
		int t = 26, u;
		for(; s[t-1] > s[t]; t--) used[s[t]-'a'] = true;
		used[s[t--]-'a'] = true;
		for(u = s[t]-'a'; !used[u]; u++);
		rep(i,t) printf("%c", s[i]);
		printf("%c\n", 'a'+u);
	}
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> x(n, vector<int>(n - 1)), y(n, vector<int>(n - 1));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }
  int ans = 0;
  for (int bit = 0; bit < 1 << n; bit++) {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      if (bit >> i & 1) {
        for (int j = 0; j < a[i]; j++) {
          if ((bit >> x[i][j] & 1) ^ y[i][j]) {
            ok = false;
            break;
          }
        }
        if (!ok) break;
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(bit));
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

void bobalicecard(int a, int b) {
	if (a == 1)
	{
		a += 13;
	}
	if (b == 1)
	{
		b += 13;
	}
	if (a > b) {
		printf("Alice\n");
	}
	if (a < b) {
		printf("Bob\n");
	}
	if (a == b) {
		printf("Draw\n");
	}
}

int main()
{
	char str[30];
	int hantei;
	int hantei2;
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &hantei, &hantei2);
	bobalicecard(hantei, hantei2);




	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int r,D,x,i;
  
  scanf("%d %d %d",&r,&D,&x);
  
  for(i=1;i<=10;i++){
    x=r*x-D;
    printf("%d\n",x);
  }
  
  return 0;
}

Measured memory_bytes: 128
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

string s;

void solve(){
	Int ans = 0;
	for(int i = 0;i < s.size();){
		vector<int> v;
		int j;
		for(j = i;j < s.size();){
			if(s[j]=='A'){
				v.push_back(0);
				j++;
			}else if(s[j]=='B'){//expect BC
				if(j + 1 >= s.size() or s[j+1] != 'C'){
					j++;
					break;
				}
				v.push_back(1);
				j+=2;
			}else{
				j++;
				break;
			}
		}
		i = j;
		int zero_ct = 0;
		REP(i,v.size()){
			if(v[i]==0)zero_ct++;
			else ans += zero_ct;
		}
	}
	cout<<ans<<endl;
}

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

	cin >> s;
	solve();
	return 0;
}

//}}}



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

int N, M;
vector<int> even;
vector<int> odd;
vector<int> a;
vector<int> b;

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int t;
    cin >> t;
    if (t & 1) {
      odd.push_back(t);
    } else {
      even.push_back(t);
    }
  }

  if (odd.size() > 2) {
    cout << "Impossible" << endl;
    return 0;
  }

  if (odd.size() == 0) {
    a.push_back(even[0]);
    b.push_back(even[0] - 1);
  } else {
    a.push_back(odd[0]);
    if (odd[0] != 1) {
      b.push_back(odd[0] - 1);
    }
  }

  for (int i=(odd.empty() ? 1 : 0); i < even.size(); ++i) {
    a.push_back(even[i]);
    b.push_back(even[i]);
  }

  if (odd.size() < 2) {
    b.push_back(1);
  } else {
    a.push_back(odd[1]);
    b.push_back(2);
    if (odd[1] != 1) {
      b.push_back(odd[1] - 1);
    }
  }

  for (int i = 0; i < a.size(); ++i) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << b.size() << endl;
  for (int i = 0; i < b.size(); ++i) {
    if (i) cout << " ";
    cout << b[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.rstrip

l = Hash.new(0)
r = Hash.new(0)
1.upto(n-1) do |i|
  r[s[i]] += 1
end

d = Array.new(1000, 0)

1.upto(n-2) do |i|
  l[s[i-1]] += 1
  r[s[i]] -= 1

  b = s[i]
  l.each do |a, va|
    r.each do |c, vc|
      if va > 0 && vc > 0
        d[(a + b + c).to_i] = 1
      end
    end
  end
end

p d.reduce(&:+)


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

typedef int i32;
typedef long long i64;
typedef unsigned int u32;
typedef unsigned long long u64;


template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};


#define debug(x)  cerr<<x<<"\n";
#define loop(i,n) for(i32 i = 0; i < n; ++i)
#define pi  pair<int,int>
#define ti  tuple<int,int,int>
#define mt  make_tuple
#define mk  make_pair
#define vi  vector<int>
#define vll vector<i64>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
using namespace std;

int main() 
{ 
	i32 n,k;
    cin>>n;
    vector<int> v(n);
    //vector<int> temp(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
	//temp=v;
    sort(v.begin(), v.end());
	int mn=v[0];
    for (int i = 1; i < n; i++) {
        if (abs(1.0* mn - v[v.size()-1] / 2.0) > abs(1.0*v[i]-v[v.size()-1] / 2.0)) {
            mn = v[i];
        }
    }
    cout<<(int)v[v.size()-1]<<" "<<mn;
	
    return 0; 
} 



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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int N;
    string s;
    cin >> N >> s;
    int ans = 0;
    rep(i,N-2)
    {
        if(s[i] == 'A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct lca_finder{
    int size, lg;
    vector<vector<int> > lca;
    vector<int> depths;
    lca_finder(vector<int> & parents, vector<int> & dep){
        // root should have -1 as parent
        size = parents.size();
        depths = dep;
        lg = log2(size) + 2;
        lca.assign(lg, vector<int>(size));
        for(int e = 0; e < size; e++)
            lca[0][e] = parents[e];
        build();
    }
    void build(){
        for(int e = 1; e < lg; e++)
            for(int f = 0; f < size; f++)
                if(lca[e-1][f] != -1)
                    lca[e][f] = lca[e-1][lca[e-1][f]];
    }
    int get_lca(int u, int v){
        if(depths[u] < depths[v]) swap(u, v);
        for(int e = lg - 1; e >= 0; e--)
            if((depths[u] - depths[v]) & (1 << e))
                u = lca[e][u];
        if(u == v) return u;
        for(int e = lg - 1; e >= 0; e--)
            if(lca[e][u] != lca[e][v]){
                u = lca[e][u];
                v = lca[e][v];
            }
        return lca[0][u];
    }
};
const int maxn = 200200;
vector<int> red[maxn], blue[maxn];
int dist_blue[maxn], good[maxn], parent[maxn];
void dfs(int cur, int par){
	parent[cur] = par;
	for(int nxt : blue[cur]){
		if(nxt == par) continue;
		dist_blue[nxt] = dist_blue[cur] + 1;
		dfs(nxt, cur);
	}
}
int mx;
void loop(){
	cout << -1 << endl;
	exit(0);
}
void run(int cur, int par, int i){
	if(dist_blue[cur] <= i) return;
	mx = max(mx, (dist_blue[cur] - 1) * 2);
	if(good[cur]) loop();
	for(int nxt : red[cur]){
		if(nxt == par) continue;
		run(nxt, cur, i + 1);
	}
}
int main(){
	int n, X, Y; cin >> n >> X >> Y; X--; Y--;
	for(int i = 0; i < n - 1; i++){
		int a, b; cin >> a >> b; a--; b--;
		red[a].push_back(b);
		red[b].push_back(a);
	}
	for(int i = 0; i < n - 1; i ++){
		int a, b; cin >> a >> b; a--; b--;
		blue[a].push_back(b);
		blue[b].push_back(a);
	}
	dfs(Y, -1);
	vector<int> _parent(n), _depth(n);
	for(int i = 0; i < n; i++){
		_parent[i] = parent[i];
		_depth[i] = dist_blue[i];
	}
	lca_finder lc(_parent, _depth);
	auto get_blue_distance = [&](int u, int v){
		return dist_blue[u] + dist_blue[v] - 2 * dist_blue[lc.get_lca(u, v)];
	};
	for(int i = 0; i < n; i++){
		for(int j : red[i]){
			if(get_blue_distance(i, j) >= 3){
				good[i] = 1;
				good[j] = 1;
			}
		}
	}
	run(X, -1, 0);
	cout << mx + 2 << endl;
	return 0;
}


Measured memory_bytes: 50172
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7


int main(){
    int a, b, c;
    int k;
    cin >> a >> b >> c >> k;
    int ans = a + b + c;
    int max_ = max({a, b, c});
    ans -= max_;
    REP(i, k){
        max_ *= 2;
    }
    ans += max_;
    print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

int calcLv(const string& s){
	rep(i, s.size()) if(s[i] != '.') return i;
	return -1;
}

bool f[110];


int calc(int p, const vector<string> &s){
	int lv = calcLv(s[p]);
	f[p] = true;
	if(s[p][lv] >= '0' && s[p][lv] <= '9') return s[p][lv] - '0';
	if(s[p][lv] == '+'){
		int np = p, ret = 0;
		while(calcLv(s[++np]) > lv){
			if(!f[np]) ret += calc(np, s);
		}
		//printf(" (%d, %d)\n", lv, ret);
		return ret;
	}
	else{
		int np = p, ret = 1;
		while(calcLv(s[++np]) > lv){
			if(!f[np]) ret *= calc(np, s);
		}
		//printf(" (%d, %d)\n", lv, ret);
		return ret;
	}
}

int main(){
	while(1){
		int n = in.nextInt();
		if(n == 0) break;
		vector<string> s(n + 1);
		rep(i, n) s[i] = in.next();
		if(n == 1){
			cout<<s[0]<<endl;
			continue;
		}
		rep(i ,110) f[i] = false;
		
		cout<<calc(0, s)<<endl;
	}
}

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

typedef long long ll;
using ll = long long;

bool between(ll x, ll y1, ll y2){
    if(y1 > y2) swap(y1, y2);
    y1++; y2--;
    if(!(y1 <= y2)) return false;

    while(x > 0){
        if(x % 3 == 1){
            if(y2 - y1 > 3) return true;
            for(ll y=y1;y<=y2;y++) if(y % 3 == 1) return true;
        }
        x /= 3;
        y1 /= 3;
        y2 /= 3;
    }

    return false;
}

ll get_extra(ll x1, ll y1, ll x2, ll y2) {
    ll ans = 0;
    ll three = 1;
    for (int i = 0; i < 35; ++i) {
        if(x1 / three == x2 / three && between(x1 / three, y1 / three, y2 / three)) {
            ll tmp = min(min(x1 % three, x2 % three) + 1, three - max(x1 % three, x2 % three));
            ans = max(ans, tmp);
        }
        three *= 3;
    }

    return ans;
}

ll get_dist(ll x1, ll y1, ll x2, ll y2){
    return abs(x1 - x2) + abs(y1 - y2) + 2 * max(get_extra(x1, y1, x2, y2), get_extra(y1, x1, y2, x2));
}

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

    while (Q--) {
        long long a;
        long long b;
        long long c;
        long long d;

        cin >> a >> b >> c >> d;
        cout << get_dist(a-1, b-1, c-1, d-1) << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  
  string n;
  cin >> n;
  string ans="Yes";
  char one = n.at(0),two=0;
  for (int i = 1; i < 4; ++i) {
    if(n.at(i)!=one){
      two=n.at(i);
      break;
    }
  }
  for (int i = 1; i < 4; ++i) {
    char m = n.at(i);
    if (m!=one&&m!=two) {
      ans="No";
    }
  }

  if(two==0){
    ans="No";
  }


  cout << ans << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1356>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */
ll solve(){
    ll res = 0;
    ll n; cin >> n;
    string s;
    for(int i = 0; i < n;i++){ char c; cin >> c; s += c; }
    for(int i = 0; i < 114514;i++){
        if(s.find(to_string(i)) == string::npos){
            return res = i;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



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

int main() {
  int x, y, A, B, N;
  
  cin >> N;
  cin >> A;
  cin >> B;
  
  x = A * N;
  y = B;
  
  if (x < y) {
    cout << x << endl;
  } else if (x == y){
    cout << x << endl;
  } else if (x > y){
    cout << y << endl;
  }
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> a(n+1);
    for1(i,n) cin>>a[i];
    unordered_map<int,int> cnt;
    ll ans=0;
    for1(i,n){
        ans+=cnt[-(a[i]-i)];
        cnt[a[i]+i]++;
    }
    cout<<ans;
    return 0;
}



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

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

  int ans;

  bool flag = false;
  int count, maxCount = 0;

  for (char c : s) {
    if (
        c == 'A' ||
        c == 'T' ||
        c == 'C' ||
        c == 'G'
    ) {
      flag=true;

      ++count;
    } else {
      flag=false;

      if (maxCount < count) {
        maxCount = count;
      }
      count=0;
    }
  }

  if (maxCount < count) {
    maxCount = count;
  }

  cout << maxCount << endl;
}


Measured memory_bytes: 256
#include <iostream>
    using namespace std;
    int N;
    int A[210];
    int main(){
    cin >> N;
    for (int i=0;i<N;++i)cin >> A[i];
    int res=0;
    while(true){
    	bool exist_odd = false;
        for (int i = 0; i < N; ++i){
    	if (A[i]%2 !=0) exist_odd =true;
        }
        if (exist_odd) break;
        for(int  i = 0; i < N; ++i){
        	A[i] /= 2;
            }
            ++res;
            }
            cout << res << endl;
            }

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;//2^60
constexpr double kEPS = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

string s1,s2;
int dp[1010][1010];

int main(void) {
  cin >> s1 >> s2;
  int m = s1.length();
  int n = s2.length();

  rep (i,m+1) dp[i][0] = i;
  rep (j,n+1) dp[0][j] = j;

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = min(
        dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1]),
        min(dp[i - 1][j] + 1, dp[i][j - 1] + 1)
      );
    }
  }

  cout << dp[m][n] << endl;

  return 0;
}


Measured memory_bytes: 7104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Node{
  int key;
  struct Node *right,*left,*parent;
};
//typedef struct Node;

struct Node *root,*NIL;

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int n,i,x;
  char str1[]="insert";
  char str2[]="print";
  char com[1000];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,str1)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,str2)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

	

Measured memory_bytes: 24048
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        
        long w = d * b;
        long x = c * b;
        long y = a * c;
        long z = a * d;
        
        long ans = Math.max(Math.max(w, x), Math.max(y, z));
        System.out.println(ans);

    }
}

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

int main(){
  
  string S;
  cin >> S;
  int Num = 0, i;
  
  for(i = 0; i < 4; i++){

    if(S[i] == '+'){
      Num++;
    }else{
      Num--;
    }
  }
  cout << Num << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>  
using namespace std;
 int main(){  long long a, b, k;  cin >> a >> b >> k;
 if(k <= a){ 
      cout<< a - k <<" "<< b <<endl; }
 else if(k <= a+b){  cout << 0 << " "<< b - (k-a) <<endl; }
 else{ cout<< 0 << " "<< 0 <<endl;  } 
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int N; cin >> N;
    vector <int> A(N+2);
    A[0]=0;
    A[N+1]=0;
    for (int i=1; i<=N; i++) cin >> A[i];
    
    ll sum=0;
    rep(i,N+2) sum+=abs(A[i+1]-A[i]);
    
    for (int i=1; i<=N; i++){
        cout << sum -( abs(A[i]-A[i-1]) + abs(A[i+1]-A[i]) )+ abs(A[i+1]-A[i-1]) << endl;
    }
}

Measured memory_bytes: 1664
// 5/10 リアルタイム参加
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

    int ichi = N % 10;

    // if (N % 10 == '2')
    if (ichi == 2 || ichi == 4 || ichi == 5 || ichi == 7 || ichi == 9) {
        cout << "hon" << endl;
    } else if (ichi == 0 || ichi == 1 || ichi == 6 || ichi == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    int a,b,c,d,e,f,w1,w2,s1,s2,ans1=0,ans2=0;
    double temp1=0.0,temp2;
    cin >>a>>b>>c>>d>>e>>f;
    vector<int>x,y;
    for(int i=0;100*a*i<=f;i++){
        w1 = 100*a*i;
        for(int j=0;100*b*j+w1<=f;j++){
            w2 = 100*b*j;
            if(w1+w2<=f) x.push_back(w1+w2);
        }
    }
    for(int i=0;c*i<=f;i++){
        s1 = c*i;
        for(int j=0;d*j+s1<=f;j++){
            s2 = d*j;
            if (s1+s2<=f) y.push_back(s1+s2);
        }
    }
    int n=x.size(),m=y.size();
    fol(i,n){
        w1 = x[i];
        fol(j,m){
            s1=y[j];
            temp2 = w1+s1==0 ? 0.0 :(double)s1/(double)(w1+s1);
            if (w1+s1<=f&&temp2>=temp1&&s1<=w1/100*e){
                temp1 = temp2;
                ans1 = w1 + s1,ans2 = s1;
            }
        }
    }
    cout << ans1 << " " <<ans2 <<endl;

}

int main(){
/*/Debug by file input
    ifstream fin("input");
    cin.rdbuf(fin.rdbuf());// */
    solve();
    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int M = max({a, b, c});
    int sum = a + b + c;

    int ans = 0;
    if (M % 2 == sum % 2) {
        ans = (3 * M - sum) / 2;
    } else {
        ans = (3 * (M + 1) - sum) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {

	int a, b = 1, c = 0, d = 2, n = 3, m;
	string str,str2,str3;

	cin >> str;


	cout << str.front() <<  str.size() -2 << str.back() << endl;






	return 0;
}

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

long long int n, ans;
bool flag = true;

int main() {
    cin >> n;

    while(n/10) {
        flag = (n%10 == 9) && flag;
        ans += 9;
        n /= 10;
    }

    ans += n;

    if (!flag)
    {
        ans --;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    int n;rd(n);
    int ans =  1;
    if(n>=1800)ans=1;
    else if(n>=1600)ans=2;
    else if(n>=1400)ans=3;
    else if(n>=1200)ans=4;
    else if(n>=1000)ans=5;   
    else if(n>=800)ans=6;   
    else if(n>=600)ans=7;   
    else if(n>=400)ans=8;   
    pp(ans);
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3648
import math

def divisor_generator(n):
    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            large_divisors.append(n // i)
    for divisor in reversed(large_divisors):
        yield divisor

n = int(input())


divs = list(divisor_generator(n))
l = len(divs) - 1
best = 2 if n == 1 else min([divs[i] + divs[l-i] for i in range(len(divs)>>1)] )

print(best-2)

Measured memory_bytes: 3384
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

ll in(){
	ll x;
	scanf("%lld",&x);
	return x;
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int n;
ll d;
vector<int> D;
int q;
vector<int> Q;
vector<int> memo;

void input(){
    n = in();
    d = in();
    D.resize(n);
    foreach(i,D){
        i = in();
    }
    q = in();
    Q.resize(q);
    foreach(i,Q){
        i = in() - 1;
    }
}

vector<int> solve(){
	memo.resize(n+1);
	memo[0] = d;
	repa(i,n+1){
		memo[i] = min(memo[i-1],abs(memo[i-1]-D[i-1]));
	}
	vector<int> ans(n,false);
	ll num = 0;
	per(i,n){
		if(memo[i]<=num){
			ans[i] = false;
		}else{
			ans[i] = true;
		}
		if(D[i]<=num*2+1){
			num += D[i];
		}
	}
	return ans;
}

int main(){
	input();
	vector<int> ans = solve();
	foreach(i,Q){
		cout << (ans[i]?"YES":"NO") << endl;
	}
	return 0;
}


Measured memory_bytes: 9728
import math

n = input()
l = list(map(int,input().split()))

a = [0]*9
for x in l:
 if math.floor(x/400)>8:
  a[8] += 1
 else:
  a[math.floor(x/400)] += 1
c = 0
for i in range(len(a)):
 if i==8:
  if c==0:
   min=1
  else:
   min = c
  c += a[i]
 elif a[i] >0:
  c+=1

print("%d %d"% (min, c))

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

int main(void)
{
  double x, y, r;
  double d, a;

  x = y = 0.0;
  r = 90.0;
  while (1){
    scanf("%lf,%lf", &d, &a);
    if (d == 0.0 && a == 0.0){
      break;
    }

    x += cos(r / 180 * M_PI) * d;
    y += sin(r / 180 * M_PI) * d;
    r -= a;
  }

  printf("%d\n%d\n", (int)x, (int)y);

  return (0);
}

Measured memory_bytes: 632
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	double[] GR => Strs.Select(double.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	const long INFL = 4011686018427387913L;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var p = GR;
		// dp[i,j]=i枚投げて表がj枚
		var dp = new double[N + 1, N + 1];
		dp[0, 0] = 1;
		for (var n = 0; n < N; n++)
		{
			dp[n + 1, 0] = dp[n, 0] * (1 - p[n]);
			dp[n + 1, n + 1] = dp[n, n] * p[n];
			for (var m = 1; m <= n; m++) dp[n + 1, m] = dp[n, m] * (1 - p[n]) + dp[n, m - 1] * p[n];
		}
		var ans = 0.0;
		for (var i = (N + 1) / 2; i <= N; i++) ans += dp[N, i];
		WriteLine(ans);
	}
}


Measured memory_bytes: 83040
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	var h []int
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		h = append(h, tmp)
	}

	sort.Ints(h)
	min := h[k-1] - h[0]
	for i := 1; i < n-k+1; i++ {
		diff := h[i+k-1] - h[i]
		if diff < min {
			min = diff
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 5504
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    ll n;
    ll ans=1;
    ll mod = INF;
    
    ll r=0;
    bool d[2*maxn]={0};
    string s;
    cin >> n;
    cin >> s;
    
    if(s[0]=='W'||s[2*n-1]=='W'){
        cout << 0<<endl;
    }else{
        //L=false,R=true
        d[0]=false;
        d[2*n-1]=true;
        rep(i,2*n-1){
            if(s[i]==s[i-1]){
                if(d[i-1])d[i]=false;
                else d[i]=true;
            }else{
                if(d[i-1])d[i]=true;
                else d[i]=false;
            }
        }
        rep(i,2*n){
            if(d[i])r++;
        }
        if(r!=n){
            cout << 0<<endl;
        }else{
            ll pl=0;
            ll pr=0;
            ll rr=r;
            rep(i,s.size()){
                if(d[i]){
                    ans=(ans*(pl-pr))%mod;
                    rr--;
                    pr++;
                }else{
                    pl++;
                }
            }
            for(ll i=1;i<=n;i++){
                ans=(ans*i)%mod;
            }
            cout << ans<<endl;
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 772
N = int(input())
H = list(map(int, input().split()))

cnt = 0
ans = 0
for i in range(N-1):
  if H[i+1] <= H[i]:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
ans = max(ans, cnt)    
print(ans)      

Measured memory_bytes: 14252