akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n;
  cin>>n;
  int ans;
  if(n<2)ans=1;
  else if(n<4)ans=2;
  else if(n<8)ans=4;
  else if(n<16)ans=8;
  else if(n<32)ans=16;
  else if(n<64)ans=32;
  else ans=64;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define SZ(x) ((int)(x).size())

const ll MOD = 1e9 + 7;

using namespace std;


int main() {

	int K, X;
	cin >> K >> X;

	int s = X - (K - 1);
	int e = X + (K - 1);

	for (int i = s; i <= e; i++)
	{
		cout << i << " ";
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 384
import sys

n, m = map(int, input().split())

array = [[int(x) for x in input().split()] for x in range(m)]

if m == 0:
    print(0)
    sys.exit()

adj_array = [[] for x in range(n + 1)]
res_array = [True] + [False for x in range(n)]
for item in array:
    adj_array[item[0]].append(item[1])
    adj_array[item[1]].append(item[0])


def dfs(n, res_array, res):
    res_array[n] = True
    if False not in res_array:
        return res+1
    else:
        for next in adj_array[n]:
            if not res_array[next]:
                res = dfs(next, list(res_array), res)
    return res


res = 0
res_array[1] = True
print(dfs(1, res_array, res))


Measured memory_bytes: 3064
#include <cstdio>
#define maxn 200010
#define ll long long

int n,a[maxn];
ll m;
ll check(int x)
{
	ll re=0;
	for(int i=1; i<=n; i++)re+=a[i]/x+(a[i]%x>0)-1;
	return re;
}

int main()
{
	scanf("%d %lld",&n,&m);
	for(int i=1; i<=n; i++)scanf("%d",&a[i]);
	int l=1,r=1e9,mid,ans;
	while(l<r)
	{
		mid=l+r>>1;
		if(check(mid)<=m)
			r=mid;
		else 
			l=mid+1;
	}
	printf("%d",l);
}


Measured memory_bytes: 2516
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t n, k;
    std::string s;
    std::cin >> n >> k >> s;

    s.at(k-1) = s.at(k-1) - 'A' + 'a';

    std::cout << s << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char Char[110];
int In,Now,M;
int main(){
    cin>>In;
    cin>>Char+1;
    for(int i=1;i<=In;i++){
        if(Char[i]=='I') Now=Now+1;
        else Now=Now-1;
        M=max(M,Now);
    }
    cout<<M<<endl;
}

Measured memory_bytes: 256
/*
  ->->->->->-> Vora Mahammadasim <-<-<-<-<-<-
*/
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;

int k,n;

void solve(){
    cin>>k>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(all(a));
    int p = -1;
    for(int i=1;i<n;i++){
        p = max(p,a[i]-a[i-1]);
    }
    p = max(p,k-a[n-1]+a[0]);
    cout<<k-p;
}

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int ans;
	int m,x;
	scanf("%d%d",&ans,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&x);
		ans-=x;
	}
	if(ans<0) printf("-1");
	else printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1736
import itertools

N = list(map(int, input().split()))
permutation_P = tuple(map(int, input().split()))
permutation_Q = tuple(map(int, input().split()))

data = list()
for i in range(1, N[0] + 1):
    data.append(i)

dictionaly = list(itertools.permutations(data))
dic_size = len(dictionaly)

for j in range(0, dic_size):
    if permutation_P == dictionaly[j] and permutation_Q == dictionaly[j]:
        a = j + 1
        b = j + 1
    elif permutation_P == dictionaly[j]:
        a = j + 1
    elif permutation_Q == dictionaly[j]:
        b = j + 1

if (a - b) >=  0:
    print(a - b)
elif (a - b) < 0:
    print(-1 * (a - b))

Measured memory_bytes: 8052
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, w, weight[100100], value[100100];
ll dp[110][100100];

int main() {
    cin >> n >> w;
    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 100100; j++){
            if(j - weight[i] >= 0) dp[i+1][j] = max(dp[i+1][j], dp[i][j - weight[i]] + value[i]);
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;
}

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

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

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

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 time = 0;
        time += s[i];
        time += c[i];
        for (int j = i + 1; j < n - 1; j++) {            
            if (time % f[j] != 0) {
                int diff = time % f[j];
                time += f[j] - diff;
            }
            if (s[j] < time) {}
            else { // time <= s[j]
                time = s[j];
            }        
            time += c[j];
        }
        cout << time << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3556
a = list(input())
n = len(a)
def dfs(i, s, sum_):
  if i == n-1:
    if sum_ == 7:
      print(s+"=7")
      exit()
  else:
    dfs(i+1, s+"+"+a[i+1], sum_+int(a[i+1]))
    dfs(i+1, s+"-"+a[i+1], sum_-int(a[i+1]))

print(dfs(0,a[0],int(a[0])))

Measured memory_bytes: 3064
n = int(input())
s = input()
rgb = s.count("R") * s.count("G") * s.count("B")
for i in range(n-2):
  for j in range(i+1, n-1):
    d = j - i
    k = j + d
    if n <= k: break
    if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
      rgb -= 1
print(rgb)      


Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define rdll(x) scanf("%lld",&x);

string a,b;
ll f[35];
int main(){
    cin>>a>>b;
    int n=a.size(), m = b.size();
    f[0] = 1;
    for(int i=1;i<35;i++) f[i] = f[i-1]*1000007%mod;
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(i && j) continue;
            map<array<int,26>,int>S;
            array<int,26>aa;
            rep(i,26) aa[i] = 0;
            int cx = i, cy = j;
            S[aa] = cx-1;
            while(cx<n&&cy<m){
                aa[a[cx]-'a']++;
                aa[b[cy]-'a']--;
                if(S.find(aa)!=S.end()) ans = max(ans,cx-S[aa]);
                else S[aa] = cx;
                cx++; cy++;
            }
        }
    }
    cout<<ans<<endl;
}


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

int main ()
{
  int n;
  vector<int> v;
  int length = 0;
  cin >> n;
  
  int temp;
  cin >> temp;  
  v.push_back(temp);
  
  for (int i = 1; i < n; i++)
  {
    int x;
    cin >> x;
    auto itr = lower_bound(v.begin(),v.end(),x); 
    if (*itr == x)
    {
      cout << "NO";
      return 0;
    }
    
    v.insert(itr,x);    
  }
  
  cout << "YES";
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
    int n;
    cin>>n;
    int s=0,max=0,x;
    while (n--)
        {
        cin>>x;
        s+=x;
        if(x>max)
            max=x;
        }
if(s-max>max)
    cout<<"Yes";
else
    cout<<"No";
    return 0;
}

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

int main(){
  int w, h, x, y, r;
  cin>>w>>h>>x>>y>>r;
  if(x-r<0||x+r>w||y-r<0||y+r>h) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3092
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc173_d.cpp"

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

  int n;
  cin >> n;
  vl a(n);
  cin >> a;

  priority_queue<ll> q;
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  q.push(a[0]);
  FOR(i, 1, n) {
    ans += q.top();
    q.pop();
    q.push(a[i]);
    q.push(a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6848
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cassert>

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;
vector<ll> factors;
vector<ll> anti_factors;

ll pow(ll a, int pow) {
    ll res = 1;
    while (pow > 0) {
        if (pow % 2 == 1) {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        pow /= 2;
    }
    return res;
}

ll nck(ll n, ll k) {
    if (n < k || n < 0 || k < 0) {
        return 0;
    }
    ll res = factors[n];
    res *= anti_factors[k];
    res %= MOD;
    res *= anti_factors[n - k];
    res %= MOD;
    return res;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int &v : a) cin >> v;
    factors.resize(n + 1, 1);
    anti_factors.resize(n + 1, 1);
    for (int i = 2; i <= n; ++i) {
        factors[i] = (factors[i - 1] * i) % MOD;
        anti_factors[i] = (anti_factors[i - 1] * pow(i, MOD - 2)) % MOD;
    }
    ll res = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i) {
        ll inc = ((-a[i] * nck(n - 1 - i, k - 1)) % MOD + MOD) % MOD;
        inc += (a[i] * nck(i, k - 1));
        inc %= MOD;
        res += inc;
        res %= MOD;
    }
    cout << res << "\n";

    return 0;
}


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

int main() {
    //
    int a, b, k;
    vector<int> vecA;
    vector<int> vecB;

    cin >> a >> b >> k;

    for (int i = 1; i <= a; i++) {
        if (a % i == 0) vecA.push_back(i);
    }

    for (int i = 1; i <= b; i++) {
        if (b % i == 0) vecB.push_back(i);
    }

    vector<int> kekka;
    for (int i = 0; i < vecA.size(); i++) {
        auto exists = find(vecB.begin(), vecB.end(), vecA.at(i)) != vecB.end();
        if (exists == true) kekka.push_back(vecA.at(i));
    }

    sort(kekka.rbegin(), kekka.rend());

    cout << kekka.at(k - 1);
    //
}


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

using namespace std;

/* Template file for Online Algorithmic Competitions */
/* Typedefs */
	/* Basic types */
	typedef long long ll;
	typedef unsigned long long ull;
	/* STL containers */
	typedef vector <int> vi;
	typedef vector <ll> vll;
	typedef pair <int,int> pii;
	typedef pair <ll,ll> pll;
	typedef vector < pii > vpii;
	typedef vector < pll > vpll;
/* Macros */
	/* Loops */
	#define fl(i,a,b) for(int i(a);i<(b);i++)
	#define rep(i,n) fl(i,0,n)
	#define rep1(i,n) fl(i,1,n)
	#define rfl(i,a,b) for(int i(a);i>=(b);i--)
	/* Algorithmic functions */
	#define srt(v) sort((v).begin(),(v).end())
	/* STL container methods */
	#define pb push_back
	#define mp make_pair
	/* String methods */
	#define slen(s) s.length()
	/* Shorthand notations */
	#define F first
	#define S second
	#define MOD 1000000007
	#define MAX 100010

int main(){	

        int n;
	cin >> n;

	if(n <= 999){
		cout << "ABC";
	}
	else{
		cout <<"ABD";
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL N = 2005;
const LL M = 400005;

vector <LL> G[N];
LL vis[2][N][N],p[2][N],vi[N];
LL eu[M],ev[M],n,m;

void dfs_vis(LL u,LL rt){
	vis[0][rt][u] = 1;
	vi[u] = 1;
	for(LL i = 0;i < G[u].size();i ++){
		LL v = G[u][i];
		if(vis[0][rt][v]) continue;
		dfs_vis(v,rt);
	}
}

void get_vis(){
	for(LL i = 1;i <= n;i ++){
		memset(vi,0,sizeof(vi));
		dfs_vis(i,i);
	}
}

void dfs_sol(LL u,LL col,LL pid,LL rt){
	p[pid][u] = col;
	vi[u] = 1;
	for(LL i = 0;i < G[u].size();i ++){
		LL v = G[u][i];
		if(p[pid][v]) continue;
		dfs_sol(v,col,pid,rt);
	}
}

void solve(LL u){
	memset(p,0,sizeof(p)); p[0][u] = 1; p[1][u] = 1;
	memset(vi,0,sizeof(vi)); vi[u] = 1;
	for(LL i = 0;i < G[u].size();i ++) if(!vi[G[u][i]]) dfs_sol(G[u][i],i + 1,0,u);
	memset(vi,0,sizeof(vi)); vi[u] = 1;
	for(LL i = (LL)(G[u].size()) - 1;i >= 0;i --) if(!vi[G[u][i]]) dfs_sol(G[u][i],i + 1,1,u);
	for(LL i = 1;i <= n;i ++) if(vi[i] && p[0][i] != p[1][i]) vis[1][u][i] = 1;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(LL i = 1;i <= m;i ++){
		cin >> eu[i] >> ev[i];
		G[eu[i]].push_back(ev[i]);
	}
	get_vis();
	for(LL i = 1;i <= n;i ++) solve(i);
	for(LL i = 1;i <= m;i ++) cout << ((vis[0][ev[i]][eu[i]] ^ vis[1][eu[i]][ev[i]]) ? "diff" : "same") << '\n';
	return 0;
}

Measured memory_bytes: 44800
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long x;
	cin >> x;
	x *= 2;
	long long top = 1000000;
	long long bot = 0;
	while (top - bot > 1) {
		long long mid = top + bot;
		mid /= 2;
		if (mid * (mid + 1) >= x) {
			top = mid;
		}
		else bot = mid;
	}
	cout << top << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a_list = list(map(int, input().split()))

dp = [[0]*(N+10) for _ in range(N+10)]
dp[0][0] = 0
for width in range(1, N+1):
    for l in range(1, N+1):
        r = l + width
        if r >= N+2:
            break
        if width % 2 == N % 2:
            dp[l][r] = max(dp[l][r-1]+a_list[r-2], dp[l+1][r]+a_list[l-1])
        else:
            dp[l][r] = min(dp[l][r-1]-a_list[r-2], dp[l+1][r]-a_list[l-1])

print(dp[1][N+1])

Measured memory_bytes: 145224
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <time.h>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;

int main() 
{
	int L; cin >> L;
	double d = (double)L / 3;
	d = pow(d, 3);
	cout << setprecision(8)<<d << endl;
}

Measured memory_bytes: 3524
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

int prim[101];
using namespace std;
int main()
{
	int a, b, k;
	int ct = 0;
	cin >> a >> b >> k;
	if (a < b)
	{
		int t = b;
		b = a;
		a = t;
	}
	for (int i = b; i >=1 ; i--)
	{
		if (b % i == 0)
			prim[ct++] = i;
	}
	int m = 0;
	for (int i = 0; i < ct; i++)
	{
		if (a%prim[i]==0)
		{
			m++;
		}
		if (m==k)
		{
			cout << prim[i];
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i

nums = gets.chomp.split(" ").map(&:to_i)

change_count = 0
n.times do |i|
  a = n - 1
  i += 1
  while true do
    if a < i
      break
    end
    if nums[a] < nums[a - 1]
      tmp = nums[a]
      nums[a] = nums[a - 1]
      nums[a- 1] = tmp
      change_count += 1
      a -= 1
    else
      a -= 1
    end
  end
end

puts nums.join(" ")
puts change_count


Measured memory_bytes: 6872
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX 150

using namespace std;

struct DATA{
  int time;
  int log;
};

bool IsSafety(vector<DATA>);
bool Compare(const DATA&, const DATA&);

int main(){
  int i, n, m, a, b;
  DATA _data;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> m >> a >> b;
      _data.time = a;
      _data.log = m;
      data.push_back(_data);
      _data.time = b;
      _data.log = -m;
      data.push_back(_data);
    }

    sort(data.begin(), data.end(), Compare);

    if(IsSafety(data)) cout << "OK" << endl;
    else cout << "NG" << endl;

    data.clear();
  }
  return 0;
}

bool IsSafety(vector<DATA> data){
  int i, sum;
  for(i=0, sum=0; i<data.size(); ++i){
    sum += data[i].log;
    if(sum > MAX) return false;
  }
  return true;
}

bool Compare(const DATA& x, const DATA& y){
  if(x.time == y.time)
    return x.log < y.log; 
  else
    return x.time < y.time;
}

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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N,K; cin>>N>>K;
    vector<ll> x(N),y(N);
    vector<pair<ll,int>> X;
    rep(i,N){
        cin>>x[i]>>y[i];
        X.push_back({x[i],i});
    }
    ll res = 4e18;
    sort(X.begin(),X.end());
    for(int l = 0; l < N - K + 1; l++){
        for(int r = l + K - 1; r < N; r++){
            ll lx = X[r].first - X[l].first, ly = INF;
            vector<pair<ll,int>> Y;
            for(int k = l; k <= r; k++){
                int i = X[k].second;
                Y.push_back({y[i],i});
            }
            if(Y.size()<K)continue;
            sort(Y.begin(),Y.end());
            
            int ysize = Y.size();
            for(int s = 0; s <= ysize - K; s++){
                ly = min(ly,y[Y[s+K-1].second] - y[Y[s].second]);
            }
            res = min(res,lx*ly);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	string S;
	cin >> S;

	string ans = "keyence";



	int remove = S.length() - 7;

	for (int i = 0; i + remove < S.length(); i++) {
		
		string now = S;
		for (int j = 0; j < remove; j++) {
			now.erase(now.begin() + i);
		}
		if (now == ans) {
			cout << "YES";
			return 0;
		}
		//cout << now << endl;

	}


	cout << "NO";






}


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

int main(){
  int N,cnt=0;
  cin >> N;
  string S;
  cin >> S;
  int ans1=0,ans2=0;
  vector<int> vec(200000);
  
  for(int i=0;i<N;i++){
    if(i==0 && S[i]=='R'){
      ans1++;
      vec[cnt]=-1;
      cnt++;
    }
    else{
      if(S[i]=='R'){
        ans1++;
        
        if(ans1==i+1){
          vec[cnt]=-1;
          cnt++;
          
          continue;
        }
        else{
          ans2++;
          vec[cnt]=i;
          cnt++;
        }
      }
    }
  }
  
  for(int i=0;i<ans1;i++){
    if(ans1>=vec[i]+1 && vec[i]!=-1){
      ans2--;
    }
  }
  
  
  cout << ans2 <<endl;
}


Measured memory_bytes: 4444
import java.util.Arrays;
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	long[] L=new long[3];

    	for(int i=0;i<3;i++) {
    		L[i]=sc.nextLong();
    	}

    	Arrays.sort(L);

    	long base=L[0]*L[1];

    	if(L[2]%2==0) {
    		System.out.println("0");
    	}else {
    		System.out.println(base);
    	}
    }


}



Measured memory_bytes: 25044
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string S;

int main() {
  cin >> S;
  rep(i, 0, 3) { cout << S[i]; }
}

Measured memory_bytes: 3616
#include <iostream>
#include <climits>
#include <cmath>
using namespace std;
int main()
{
  double N, T, A, ans=0;
  double tdiff=INT_MAX;
  cin >> N >> T >> A;
  for(int n=1; n<=N; ++n)
  {
    double H;
    cin >> H;
    if(abs(A-(T-H*0.006))<tdiff)
    {
      tdiff = (double)abs(A-(T-H*0.006));
      ans = n;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int S, h, s;
	cin >> S;
	h = S/3600;
	s = S%60%60;
	
	cout << h << ":" << (S-3600*h-s)/60 << ":" << s << '\n';
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 3056
putout = ->(ar) {puts ar.join(" ")}

gets
ar = gets.split.map(&:to_i)
n = ar.size

putout.(ar)
1.upto(n - 1) do |i|
  v = ar[i]
  j = i - 1
  while j >= 0 and ar[j] > v
    ar[j + 1] = ar[j]
    j -= 1
  end
  ar[j + 1] = v
  putout.(ar)
end



Measured memory_bytes: 6884
#include<iostream>
using namespace std;
int main(){
	string s[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string str;
	cin>>str;
	for(int i=0;i<8;i++){
		if(str==s[i]){
			cout<<7-i<<endl;
			return 0;
		}
	}

}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	while (1){
		int n, m, count = 1, turn = 0, x = 0;
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0)break;
		int N[n+1], M[m];
		for (int i = 1; i <= n; i++){
			scanf("%d", &N[i]);
		}
		for (int i = 0; i < m; i++){
			scanf("%d", &M[i]);
		}
		while (1){
			if (count>=n)break;
			count += M[x++];
			count += N[count];
			turn++;
		}
		printf("%d\n", turn);
	}
	return 0;
}

Measured memory_bytes: 3204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        int k = in.nextInt();
        int count = 0;
        String[] tokens = in.nextLine().split(" ");
        for (int i = 0; i < n; i++) {
            if (Integer.parseInt(tokens[i]) >= k) {
                count++;
            }
        }
        out.println(count);
    }
}


Measured memory_bytes: 29652
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗を求めるらしい！！！
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
	//dominoに借りたやつです
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[n])

  int i = sqrt (n) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;
string s = "";

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	int n, k;
	cin >> n >> k;
	int now = 1;
	rep(i, n) {
		now = min(now * 2, now + k);
	}
	cout << now << rt;

	please AC;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, m, l, r, x=0, y=1e5;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> l >> r;
        x=max(x, l);
        y=min(y, r);
    }
    cout << max(0, y-x+1) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

def solve():
    n, y = map(int, input().split())
    y //= 1000 # 下三桁は考慮しないので簡単にします

    for nogu in range(n + 1):
        for higu in range(n + 1 - nogu):
            yuki = n - nogu - higu
            if nogu + higu * 5 + yuki * 10 == y:
                print(yuki, higu, nogu)
                return
    
    print("-1 -1 -1")

if __name__=="__main__":
    solve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007

int main()
{
	fast;
	ll A,P;
	cin>>A>>P;
	ll ans=(3*A+P)/2;
	cout<<ans<<"\n";
	return 0;
}

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

int main() {
    long long int A[101][101],B[101][101];
    int n, m, l;
    cin >> n >> m >> l;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> A[i][j];
    
    for(int i = 0; i < m; i++)
        for(int j = 0; j < l; j++)
            cin >> B[i][j];
        
    long long int ans;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            ans = 0;
            for(int k = 0; k < m; k++){
                ans += A[i][k] * B[k][j];
            }
            if(j > 0) cout << " ";
            cout << ans;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

int main()
{

        int N;
        cin >> N;

        cout << ((1 + N) * N) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[5], b[5];
long long dp[75000005];
int main() {
	scanf("%d",&n);
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	scanf("%d%d%d",&b[1],&b[2],&b[3]);
	for(int x=0;x<=75000000;x++) dp[x] = x;
	for(int now=3;now>=1;now--) {
		for(int x=0;x<=75000000;x++) {
			if(x-a[now]>=0) dp[x] = max(dp[x], dp[x-a[now]] + b[now]);
		}
	}
	int ans = (int)dp[n];
	for(int x=0;x<=75000000;x++) dp[x] = x;
	for(int now=3;now>=1;now--) {
		for(int x=0;x<=75000000;x++) {
			if(x-b[now]>=0) dp[x] = max(dp[x], dp[x-b[now]] + a[now]);
		}
	}
	printf("%lld",dp[ans]);
}

Measured memory_bytes: 586240
#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 LP = pair<ll,int>;

const ll INF = 1e18;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  int si, sj, ti, tj;
  cin >> si >> sj >> ti >> tj;
  --si; --sj; --ti; --tj;
  vector<string> g(h);
  rep(i,h) cin >> g[i];

  auto toId = [&](int i, int j, int v) {
    return (i*w+j)*4+v;
  };
  auto modCeilK = [&](ll x) {
    return (x+k-1)/k*k;
  };

  vector<ll> dist(h*w*4, INF);
  priority_queue<LP, vector<LP>, greater<LP>> q;
  auto push = [&](int i, int j, int v, ll x) {
    int id = toId(i,j,v);
    if (dist[id] <= x) return;
    dist[id] = x;
    q.emplace(x,id);
  };
  rep(v,4) push(si, sj, v, 0);
  while (!q.empty()) {
    ll d = q.top().first;
    int id = q.top().second;
    q.pop();
    if (dist[id] != d) continue;
    int i = id/w/4;
    int j = id/4%w;
    int v = id%4;
    rep(nv,4) push(i,j,nv,modCeilK(d));
    {
      int ni = i+di[v], nj = j+dj[v];
      if (0 <= ni && ni < h && 0 <= nj && nj < w) {
        if (g[ni][nj] == '.') {
          push(ni,nj,v,d+1);
        }
      }
    }
  }

  ll ans = INF;
  rep(v,4) ans = min(ans, dist[toId(ti,tj,v)]);
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    ans = modCeilK(ans)/k;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 44044
import math
n, h = map(int, input().split())
lis =[list(map(int, input().split())) for _ in range(n)]

a_sort = sorted(lis, reverse=True)

b_sort = sorted(lis, key=lambda x:x[1], reverse=True)

cnt = 0
furu = a_sort[0][0]

for nage in b_sort:
    if nage[1] > furu:
        h -= nage[1]
        cnt += 1
    else:
        break

    if h <= 0:
        break

if h <= 0:
    print(cnt)
else:
    plus = int(math.ceil(h/furu))
    cnt += plus
    print(cnt)

Measured memory_bytes: 30360
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 03/08/2020

from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007

x = ii1()
if x >= 30:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 65512
INF = 2**31-1
class segtree():
    def __init__(self, N):
        self.N0 = 2**(N-1).bit_length()
        self.data = [INF]*((2*self.N0)+1)

    # a_k の値を x に更新
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])

    # 区間[l, r)の最小値
    def get(self, l, r):
        L = l + self.N0; R = r + self.N0
        s = INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])

            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s
    
N, x = map(int,input().split())

s_tree = segtree(2*N) #N⇒1になるので二倍の配列を準備
arr = list(map(int,input().split()))

for i in range(N):
    s_tree.update(i, arr[i])
    s_tree.update(i+N, arr[i])

ans = float("inf")
for i in range(N):#i = 魔法をかける回数
    tmp = i * x
    for k in range(N,2*N):#i回魔法をかけてスライムkに変更できうる区間の中で、最小コストのスライムを選ぶ 
        tmp += s_tree.get(k-i,k+1)
    ans = min(ans,tmp) #合計コストが答のものが答
    
print(ans)

Measured memory_bytes: 55484
def m(g, ps):
    res = 0
    i = len(ps) - 1
    while g > 0 and i >= 0:
        if ps[i] > 0:
            g -= 100 * (i + 1)
            ps[i] -= 1
            res += 1
        else:
            i -= 1
    return res if g <= 0 else 1 << 30


def main():
    d, g = map(int, input().split())
    ps = [0] * d
    cs = [0] * d
    for i in range(d):
        ps[i], cs[i] = map(int, input().split())
    qs = [p - 1 for p in ps]
    res = m(g, qs)
    for i in range(1, 1 << d):
        qs = [p - 1 for p in ps]
        g0 = 0
        m0 = 0
        for j in range(d):
            if (i >> j) & 1:
                g0 += 100 * (j + 1) * ps[j] + cs[j]
                m0 += ps[j]
                qs[j] = 0
        if g0 < g:
            res = min(res, m0 + m(g - g0, qs))
        else:
            res = min(res, m0)
    print(res)


if __name__ == '__main__':
    main()


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

using i64 = int64_t;

int main(){
    int n, m;
    cin >> n >> m;
    int left = 1, right = n;
    for(int i=0;i<m;++i){
        int l, r;
        cin >> l >> r;
        left = max(left, l);
        right = min(right, r);
    }
    cout << max(0, right-left+1) << endl;

    return 0;
}


Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

string binary(int x, int y)
{
    string bin = "";

    while (x > 0) {
        char res = (x % 2) + '0';
        bin = res + bin;
        x /= 2;
    }

    y = y - bin.length();
    for (int i = 0; i < y; i++)
        bin = '0' + bin;

    return bin;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    vector<vector<int>> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            int X, Y;
            cin >> X >> Y;
            x[i].push_back(X);
            y[i].push_back(Y);
        }
    }

    int ans = 0;
    for (int k = 1; k < pow(2, N); k++) {
        string bin = binary(k, N);
        int hon = 0; //正直な人の数(bitの立っている数)
        for (int i = 0; i < N; i++)
            if (bin[i] - '0' > 0) hon++;

        int ok = 1;
        for (int i = 0; i < N; i++) {
            if (bin[i] - '0' > 0) {
                for (int j = 0; j < A[i]; j++) {
                    int t = y[i][j]; //人iのj番目の証言
                    int u = bin[x[i][j] - 1] - '0'; //仮定
                    if (t != u) {
                        //証言が仮定と食い違った
                        ok = 0;
                    }
                }
            }
        }

        if (ok > 0 && hon > ans) ans = hon;
    }

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


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair< int, int > pii;
typedef vector< int > vi;


int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    cout.tie(0);
    ll X, Y;
    cin >> X >> Y;
    cout << (abs(X - Y) > 1 ? "Alice" : "Brown") << endl;
}


Measured memory_bytes: 256
"use strict"
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
let stdout = [];
function input(){return stdin.pop()};
function maput(){return input().split(" ").map(n=>parseInt(n))};
function print(x){stdout.push(x)};
function exist(x, xs){return xs.indexOf(x) > -1}
function max(x){return x.reduce(function(a,b){ return Math.max(a,b) }) }
function min(x){return x.reduce(function(a,b){ return Math.min(a,b) }) }
function sum(x){return x.reduce(function(a,b){ return a+b }) }
function sorting(x, index){x.sort((a, b) => a[index] - b[index])}
function all(x){return x.reduce(function(a,b){ return a && b }) }
function any(x){return x.reduce(function(a,b){ return a || b }) }
function list(iterable){return Array.from(iterable)}
function vint(iterable){return Array.from(iterable, x => parseInt(x))}
function tile(val, len){return Array(len).fill(val)}
const range = (start, stop, step) => Array.from(
    { length: (stop - start) / step }, (_, i) => start + (i * step));
/*START*/

function diff(setA, setB) {
    var _difference = new Set(setA);
    for (var elem of setB) {
        _difference.delete(elem);
    }
    return _difference;
}


let tmp = maput()
let n = tmp[0]
let m = tmp[1]
let s = new Set(range(1, m+1, 1))
let t = new Set(range(1, m+1, 1)) 
for (let i = 0; i < n; i++){
    let tmp = new Set(maput().slice(1))
    s = diff(s, diff(t, tmp))
}

print(list(s).length)



/*END*/
stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 11948
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N,M;
vector<ll> A,B(200010),C(100010);

bool f(ll x){
    ll cnt = 0;
    rep(i,N){
        cnt += B[max(x-A[i],(ll)0)];
    }
    if(cnt >= M) return true;
    else return false;
}

int main(){
    cin >> N >> M;
    rep(i,N){
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(ALL(A));
    rep(i,N){
        B[A[i]]++;
    }
    rep(i,100010){
        C[i+1] += C[i] + A[min(i,N)];
    }
    rrep(i,100009){
        B[i] += B[i+1];
    }
    ll l = 0,r = 200001;
    while(r - l > 1){
        ll mid = (l+r) / 2;
        if(f(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    ll ans = 0,cnt = 0;
    rep(i,N){
        ans += A[i] * B[max(l-A[i],(ll)0)] + C[100009] - C[N-B[max(l-A[i],(ll)0)]];
        cnt += B[max(l-A[i],(ll)0)];
    }
    cout << ans - (cnt - M) * l << endl;
}



Measured memory_bytes: 3704
#include<stdio.h>

int n;       // 数列 A の長さ(最大 50)
int A[50];   // 数列 A 

int solve(int i, int m)
{
  //printf("%d %d\n", i, m);
  if (m == 0)
    return 1;
  if (i >= n || m < 0)
    return 0;

  if (solve(i+1, m) == 1 || solve(i+1, m - A[i]) == 1)
    return 1;
  return 0;
}


int main(void)
{
  int q, M, i;

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &M);
    if (solve(0, M) == 1)
      printf("yes\n");
    else
      printf("no\n");
  }
    
  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}

bool bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; }

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

    // solution comes here

    string S;
    cin >> S;

    
    ll ALL = 1<<3;
    rep(sub, ALL) {
        string ans="";
        ans += S[0];
        ll cnt=S[0]-'0';
        rep(i, 3) {
            if(bit(sub, i)) {
                cnt += S[i+1]-'0';
                ans += '+';
            }
            else {
                cnt -= S[i+1]-'0';
                ans += '-';
            }
            ans += S[i+1];
        }
    if(7==cnt){
        cout << ans  << "=7" << nl;
        return 0;
    }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,k;
string s;

void solve(){
  cin >> n >> k;
  cin >> s;
  vector<int> d;
  if(s[0]=='0'){
    d.push_back(0);
  }
  int l=1;
  rep(i,n-1){
    if(s[i]!=s[i+1]){
      d.push_back(l);
      l=1;
    }
    else{
      l+=1;
    }
  }
  d.push_back(l);
  if(s[n-1]=='0')d.push_back(0);
  int m=d.size();
  // for(int t:d){
  //   cout << t << " ";
  // }
  // cout << "" << endl;
  if(2*k+1>m){
    int ans=0;
    for(int t:d){
      ans+=t;
    }
    cout << ans << endl;
    return;
  }
  int ans=0,S=0;
  rep(i,2*k+1){
    S+=d[i];
  }
  ans=max(ans,S);
  Rep(i,1,1+(m-1-2*k)/2){
    S+=-d[2*i-1]-d[2*i-2]+d[2*i+2*k-1]+d[2*i+2*k];
    ans=max(ans,S);
  }
  cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 1020