akhauriyash/Code-Regression huggingface dataset:
import operator
class SegmentTree:
    def __init__(self, size, default, op = operator.add):
        self.size = 1
        while self.size < size:
            self.size *= 2
        self.dat = [default]*(self.size*2-1)
        self.op = op

    def update(self, i, x):
        i += self.size - 1
        self.dat[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.dat[i] = self.op(self.dat[i*2+1], self.dat[i*2+2])

    def add(self, i, x):
        i += self.size - 1
        self.dat[i] = self.op(self.dat[i], x)
        while i > 0:
            i = (i - 1) // 2
            self.dat[i] = self.op(self.dat[i], x)

    def get(self, a, b, k = None, l = None, r = None):
        if k is None:
            k = 0
            l = 0
            r = self.size

        if r <= a or b <= l:
            return None

        if a <= l and r <= b:
            return self.dat[k]

        res_l = self.get(a, b, k*2+1, l, (l+r)//2)
        res_r = self.get(a, b, k*2+2, (l+r)//2, r)
        if res_l is None:
            return res_r
        if res_r is None:
            return res_l
        return self.op(res_l, res_r)
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    return gcd(b%a, a)

n = int(input())
a = list(map(int, input().split()))
seg = SegmentTree(n,0,gcd)
for i in range(n):
    seg.update(i,a[i])
ans = 1
for i in range(n):
    seg.update(i,0)
    ans = max(ans, seg.get(0,n))
    seg.update(i,a[i])
print(ans)


Measured memory_bytes: 123996
import sys

X, N = map(int, input().split(" "))
if N == 0:
    print(X)
    sys.exit(0)

P = list(map(int, input().split(" ")))

l = list(range(0, 102))
for p in P:
    l.pop(l.index(p))

dis_min = 1000
n = 1000
for i in l:
    dis = abs(i - X)
    if dis_min > dis:
        dis_min = dis
        n = i
    elif dis_min == dis:
        if n > i:
            n = i

print(n)


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

using namespace std;
int main(void){
    long long  a,n;
    long long max=0,ans=0;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>n;
        if(max<n){
            max=n;
        }
        if(max>n){
            ans=ans+(max-n);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 10000000
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[100010];
multiset<int> st;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		auto ite = st.lower_bound(a[i]);
		if (ite == st.begin())st.insert(a[i]);
		else {
			ite--;
			st.erase(ite);
			st.insert(a[i]);
		}
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+10;
bitset<2*N*N>jl;
int n,a[N];
int main()
{
	scanf("%d",&n);int sum=0;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	jl[0]=1;
	for(int i=1;i<=n;i++){
		jl|=(jl<<(a[i]));sum+=a[i];
	}
	for(int i=(sum+1)/2;;i++){
		if(jl[i]){
			cout<<i<<endl;return 0;
		}
	}
}

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

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

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 1) {
            cnt++;
        }
    }
    if (cnt == 0) {
        cout << 1 << endl;
    } else {
        cout << double(cnt) / double(n) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

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

	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;


}


Measured memory_bytes: 3604
import math
N = int(input())
n = int(math.sqrt(N))
ans = float('inf')
for i in range(1,n+1):
  if(N%i == 0):
    a,b = i,N//i
    a,b = str(a),str(b)
    tmp = max(len(a),len(b))
    ans = min(ans,tmp)
print(ans)

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

int main() {
	double a, b;
	while(cin >> a >> b) {
		if(a < 35.50 && b < 71.00)
			cout << "AAA" << endl;
		else if(a < 37.50 && b < 77.00)
			cout << "AA" << endl;
		else if(a < 40.00 && b < 83.00)
			cout << "A" << endl;
		else if(a < 43.00 && b < 89.00)
			cout << "B" << endl;
		else if(a < 50.00 && b < 105.00)
			cout << "C" << endl;
		else if(a < 55.00 && b < 116.00)
			cout << "D" << endl;
		else if(a < 70.00 && b < 148.00)
			cout << "E" << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
vector<int>v[100001];
int dp[100001]={0};
bool vis[100001]={0};
int n,m;
vector<int>ans;
void dfs(int x){  
    if(vis[x])return ;
    vis[x]=1;
    for(int i=0;i<v[x].size();i++){
      if(!vis[v[x][i]])dfs(v[x][i]);
    dp[x]=max(dp[x],1+dp[v[x][i]]);
    }
}
int main(){
  cin>>n>>m;
  int x,y;
  for(int i=0;i<m;i++){
  cin>>x>>y;
    v[x].push_back(y);
  }
  for(int i=1;i<=n;i++){
  if(!vis[i])dfs(i);}
  cout<<*max_element(dp+1,dp+n+1);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	S[5]=S[13]=' ';
	cout<<S<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 764
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
//#define i_7 998244353
//#define i_5 i_7-2
ll i_7=(ll)(1E9+7);
ll i_5=i_7-2;
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

#define N 100
ll n;
dd x[N],y[N];
struct pai{
    dd xp,yp,r;
};

dd dis(dd x1,dd x2,dd y1,dd y2){
    return sqrt(powl(x1-x2,2)+powl(y1-y2,2));
}
pai cal(ll i,ll j){
    pai p;
    p.xp=(x[i]+x[j])/2.0;
    p.yp=(y[i]+y[j])/2.0;
    p.r=dis(x[i],p.xp,y[i],p.yp);
    return p;
}
pai cal(ll i,ll j,ll k){
    pai p;
    dd a=x[i],b=y[i],c=x[j],d=y[j],e=x[k],f=y[k];
    p.yp=((e-a)*(a*a+b*b-c*c-d*d)-(c-a)*(a*a+b*b-e*e-f*f))/(2*(e-a)*(b-d)-2*(c-a)*(b-f));
    if((abs)(a-c)<EPS){
        p.xp=(2*(b-f)*p.yp-a*a-b*b+e*e+f*f)/(2*(e-a));
    }else{
        p.xp=(2*(b-d)*p.yp-a*a-b*b+c*c+d*d)/(2*(c-a));
    }
    p.r=dis(p.xp,a,p.yp,b);
    return p;
}
bool check(pai p){
    
    rep(i,0,n-1){
        if(dis(x[i],p.xp,y[i],p.yp)>p.r+EPS)return false;
    }
    return true;
}


int main(){fastio
    cin>>n;
    rep(i,0,n-1)cin>>x[i]>>y[i];
    dd ans=inf;
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            pai p=cal(i,j);
            if(check(p)){
                ans=min(ans,p.r);
            }
        }
    }
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            rep(k,j+1,n-1){
                pai p=cal(i,j,k);
                if(check(p)){
                    ans=min(ans,p.r);
                }
            }
        }
    }
    cout<<setprecision(20)<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
h={15:2244,12:1870,10:1520,5:850,3:550,2:380}
m={0:0}

for i in range(50):
  if i in m:
    for k,v in h.items():
      m[i+k] = min(m.get(i+k,1e9),m[i]+v)

while True:
  n = input()
  if n == 0 : break
  print(m[n/100])

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

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  int maxcnt = 0;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    mp[s]++;
    maxcnt = max(maxcnt,mp[s]);
  }

  vector<string> anss;
  for(auto x:mp){
    if(x.second==maxcnt){
      anss.push_back(x.first);
    }
  }
  sort(anss.begin(),anss.end());
  for(string ans:anss){
    cout << ans << endl;
  }
}

Measured memory_bytes: 26868
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

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

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}
 
int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
 
const int N=500002;

void solve(){
  int A,B,M;
  cin>>A>>B>>M;
  vi a(A);
  cin>>a;
  vi b(B);
  cin>>b;
  int ans=1e9;
  for(int i=0;i<M;i++){
    int x,y,z;
    cin>>x>>y>>z;
    x--;y--;
    ans=min(ans,max(0,a[x]+b[y]-z));
  }
  sort(all(a));
  sort(all(b));
  ans=min(ans,a[0]+b[0]);
  cout<<ans;
}
 
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int add(int x, int y) {return (x + y >= MOD ? x + y - MOD : x + y);}
int sub(int x, int y) {return (x < y ? x - y + MOD : x - y);}

int main()
{
	boost;
	int n, k, x, i;
	cin >> n >> k;
	int dp[k + 2], val[k + 1];
	memset(val, 0, sizeof val);
	
	val[0] = 1;
	fo(i, 0, n) {
		memset(dp, 0, sizeof dp);
		cin >> x;
		for(int j = 0; j <= k; j++) {
			int y = min(k, j + x);
			dp[j] = add(dp[j], val[j]);
			dp[y + 1] = sub(dp[y + 1], val[j]);
		}
		val[0] = dp[0];
		for(int j = 1; j <= k; j++)
		val[j] = add(dp[j], val[j - 1]);
	}
	cout << val[k];
}


Measured memory_bytes: 4424
A, B, X = gets.split.map(&:to_i)

S = A * A * B

def calc(deg)
  rad = (deg * Math::PI / 180.0)

  if S / 2.0 > X
    c = Rational(B, Math.tan(rad))
    area = (c * B / 2.0) * A

    area > X
  else
    c = Rational(A, Math.cos(rad))
    h = A * Math.sin(rad)
    area = (c * h / 2.0) * A

    area <= S - X
  end
end

ok = 0
ng = 1_000_000_000_000
unit = 90 / ng.to_f

while (ok - ng).abs > 1
  mid = (ok + ng) / 2
  deg = unit * mid

  check = calc(deg)

  # p [deg, S - X, area, check, ok, ng]

  if check
    ok = mid
  else
    ng = mid
  end
end

puts ok * unit


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using V = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

/* ----------- ANSWER ----------- */
/* ------------------------------ */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        V<P> xy(n);
        rep(i, n) xy[i].F = inl(), xy[i].S = inl();
        sort(all(xy));


        ll ans = n;
        rep(i, n - 1) {
            ll tmp = n;
            for (ll j = i + 1; j < n; ++j) {
                ll p = xy[j].F - xy[i].F, q = xy[j].S - xy[i].S;

                ll pass = 0;
                for (ll k = 0; k < n - 1; ++k) {
                    for (ll l = k + 1; l < n; ++l) {
                        if (xy[l].F - xy[k].F == p && xy[l].S - xy[k].S == q) pass++;
                    }
                }
                tmp = min(tmp, n - pass);
            }
            ans = min(tmp, ans);
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

typedef long long ll;

int main(){
  ll N;
  std::cin >> N;
  std::vector<ll> A(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> A[i];
  }
  std::vector<ll> B(1000010);
  for(auto r : A){
    if(B[r] != 0){
      B[r] = 2;
      continue;
    }
    for(int x = r ; x < 1000010 ; x += r){
      B[x]++;
    }
  }
  ll resa = 0;
  for(auto it = A.begin() ; it != A.end() ; it++){
    if(B[*it] == 1) resa++;
  }
  std::cout << resa << std::endl;
  return 0;
}


Measured memory_bytes: 12772
import math
import sys
input = sys.stdin.readline

def lcm(a, b):
    return (a * b) // math.gcd(a, b)

N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7
# A全体の最小公倍数
a_lcm = 1
for a in A:
    a_lcm = lcm(a_lcm, a)

# Bの総和
b_sum = 0
for i in range(N):
    b_sum += a_lcm // A[i]

print(b_sum % mod)


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

int main(){
    int n,m,k,a,c=0;
    cin>>n>>m;
    vector<int>v(m,0);
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>a;
            v[a-1]++;
        }
    }
    for(int i=0;i<m;i++) if(v[i]==n) c++;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, i; cin >> N >> i;
    cout << N - i + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<int> to[100010];
vector<bool> kn(100010);

void bfs(int i,int p){
    for(auto u : to[i]){
        if(kn[u]==0 && u!=p){
            kn[u] = 1;
            bfs(u,i);
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int x,y;
        int dummy;
        cin >> x >> y >> dummy;
        x--; y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    int ans = 0;
    rep(i,n){
        if(kn[i]==0){
            ans++;
            kn[i] = 0;
            bfs(i,-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define ld long double
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
#define pi 2*acos(0.0)
const int INF = 1e7;
const int mod = 1e9 + 7;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
 
ll nCr(ll n, ll k) { 
   ll C[n + 1][k + 1]; 
   
   REP(i,0,n+1){ 
      REP(j,0,min(i,k)+1) {
         if(j==0 || j==i) {
            C[i][j] = 1;  
         } else {
            C[i][j] = C[i-1][j-1] + C[i-1][j]; 
         }
      } 
   }
   return C[n][k]; 
}

bool compare(pair<int, int>&i, pair<int, int>&j) {
    return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);

   int a, b;
   cin >> a >> b;

   cout << a*b;
}

Measured memory_bytes: 3632
// https://atcoder.jp/contests/abc115/tasks/abc115_c

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

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

    cin >> n >> k;
    int h[n], df[n];

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

    // 小さい順に並び替えた後、k個の高さの差を計算する
    for (int i = 0; i < n - k + 1; i++) {
        df[i] = h[i + k - 1] - h[i];
    }
    // 差分を並び替える
    sort(df, df + n - k + 1);

    cout << df[0] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int twos[205];
int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        while(x % 2 == 0)
            twos[i]++,x /= 2;
    }
    int mine = 1e5;
    for(int i = 0;i < n;i++)
        mine = min(mine,twos[i]);
    cout << mine;
}


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

int main(void)
{
    int X;
    cin >> X;

    //int mod = N % 1000;
    //if ((a * b) % 2 == 0) cout << "Even" << endl;
    //else cout << "Odd" << endl;    
    if(X >= 30){
        cout<< "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def C(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

N, M = MAP()
L = [LIST() for i in range(M)]

tree = UnionFind(N)

# print(C(N, 2))
ans = [0] * (M+1)
ans[M] = C(N,2)
for i in range(M-1, -1, -1):
    #     if len(l) >= 2:
    #         ans[i] -= C(len(l), 2)
    a, b = L[i]
    ans[i] = ans[i+1]
    if not tree.same(a-1, b-1):
        ans[i] -= tree.size(a-1) * tree.size(b-1)
    tree.union(a-1, b-1)
for a in ans[1:]:
    print(a)
    

Measured memory_bytes: 37528
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }      
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
signed main()
{   jaldi
    string str;
    cin>>str;
    bool x=true;
    for(int i=0;i<str.length();i++)
    {   if(i%2==0)
        {   if(str[i]=='L')
            x=false;
        }
        else
        {   if(str[i]=='R')
            x=false;
        }
    }
    if(x)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i= 0; i<n; i++)

int main(){
    vector<int> min(3,0); //i行目の最小値
    vector<vector<int>> c(3,vector<int>(3));
    bool flag = true;
    rep(i,3){
        rep(j,3){
            cin >>  c[i][j];
            if(c[i][j] < min[i]) min[i] = c[i][j];
        }
    }
    int thr1 = c[0][0]-c[0][1];
    int thr2 = c[0][1]-c[0][2];
    rep(i,2){
        if(c[i+1][0]-c[i+1][1] != thr1 || c[i+1][1]-c[i+1][2] != thr2) flag = false;
    }
    int thr3 = c[0][0]-c[1][0];
    int thr4 = c[1][0]-c[2][0];
    rep(i,2){
        if(c[0][i+1]-c[1][i+1] != thr3 || c[1][i+1]-c[2][i+1] != thr4) flag = false;
        
    }

    cout << (flag?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int N,Y;
    cin >> N >> Y;
    for(int i = N; i >= 0; --i){
        for(int j = 0; j <= N-i; ++j){
            for(int k = N-j-i; k <= N-j-i; ++k){
                if(10000*i+5000*j+1000*k == Y){
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int A,B;
	scan(A>>B);
	rep1(i,10000){
		if(i*108/100-i==A&&i*110/100-i==B){
			prin(i);
			return 0;
		}
	}
	prin(-1);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int n = 100;
int swapped;

void print_ans(vvi & ans) {
  printf("100 100\n");
  rep (i, n) {
    rep (j, n) {
      char c;
      if ((ans[i][j] + swapped) % 2 == 0) {
        c = '.';
      } else {
        c = '#';
      }
      printf("%c", c);
    }
    printf("\n");
  }
}

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  a -= 1; b -= 1;
  vvi ans(n, vi(n, -1));
  swapped = 0;
  FOR (i, 0, n/2) {
    rep (j, n) {
      ans[i][j] = 1;
    }
  }
  FOR (i, n/2, n) {
    rep (j, n) {
      ans[i][j] = 0;
    }
  }
  for (int i = 0; i < n/2; i += 2) {
    for (int j = 0; j < n; j += 2) {
      if (a == 0) { break; }
      if (a > 0) {
        ans[i][j] = 0;
        a -= 1;
      }
    }
  }
  for (int i = n-1; i >= n/2; i -= 2) {
    for (int j = 0; j < n; j += 2) {
      if (b == 0) { break; }
      if (b > 0) {
        ans[i][j] = 1;
        b -= 1;
      }
    }
  }

  print_ans(ans);

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

  auto f = [&](int n) {
    int res;
    if (n%2 == 0) res = n/2;
    else res = 3*n + 1;
    return res;
  };

  set<int> st;
  int a = s;
  st.insert(a);
  rrep(i,(int)1e6) {
    a = f(a);
    if (st.count(a)) {
      cout << i+1 << endl;
      return 0;
    }
    st.insert(a);
  }

  return 0;
}

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

const int maxn=103;
const int mo=1e9+7;

int n;
long long dp[maxn][256],res;

int go(int stat,int k){
	return (stat*4)%256+k;
}

bool check(int stat){
	if(stat%64==44||stat%64==56||stat%64==50) return false;
	if(stat==200||stat==216||stat==232||stat==248) return false;
	if(stat==224||stat==228||stat==232||stat==236) return false;
	return true;
}

int main(){
	scanf("%d",&n);
	dp[0][0]=1;
	for(int i=0;i<n;++i){
		for(int j=0;j<256;++j){
			if(dp[i][j]!=0&&check(j)){
//				printf("%d %d : %lld\n",i,j,dp[i][j]);
				for(int k=0;k<4;++k)
					(dp[i+1][go(j,k)]+=dp[i][j])%=mo;
			}
		}
	}
	for(int j=0;j<256;++j)
		if(check(j))
			(res+=dp[n][j])%=mo;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 512
n=int(input())
a=[int(i) for i in input().split()]

ans=0
t=0
while t<n:
    if a[t]==t+1:
        if t+1<n and a[t+1]==t+2:
            ans+=1
            t+=2
        else:
            ans+=1
            t+=2
    else:
        t+=1
print(ans)

Measured memory_bytes: 52908
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	
	int x1,x2,x3,x4,x5;
	
	
	//vector<int> res = {};
	cin >> x1>>x2>>x3>>x4>>x5;
	vector<int> res = {x1,x2,x3,x4,x5};
	//cout<<res[0]<<" "<<res[1]<<" "<<res[2]<<" "<<res[3];
	vector<int>::iterator it = std::find(res.begin(), res.end(), 0);
	cout << std::distance(res.begin(), it)+1;
	
	return 0;
	
	
	
}

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

A,B=[int(i) for i in input().rstrip().split()]
S = input().strip()

if S.count("-") == 1:
  s1,s2=S.rstrip().split("-")
  print( "Yes" if len(s1)==A and len(s2)==B else "No" )
else:
  print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  string S;
  cin>>S;

  int ans=0;
  rep(i,3) if(S[i]=='7') ans=1;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

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

    int count = 0;
    for(size_t i = 1; i < S.size(); ++i){
        if(S[i] != S[i - 1]){
            ++count;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 512
st = input()
length = len(st)
pat1 = ['0' if i % 2 else '1' for i in range(length)]
pat2 = ['0'] + pat1[:-1] 
len1 = len([s for s, ss in zip(st, pat1) if s != ss])
len2 = len([s for s, ss in zip(st, pat2) if s != ss])
print(min(len1, len2))

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

using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	int c=0;
	if(x>0)
	{
		if(y>0)
		{
			if(x<=y)
			{
				cout << y-x;
			}
			else
			{
				cout << x-y+2;
			}
		}
		else
		{
			if(-y>=x)
			{
				cout << -x-y+1;
			}
			else
			{
				cout << x+y+1;
			}
		}
	}
	if(x<0)
	{
		if(y>0)
		{
			if(-x>y)
			{
				cout << -y-x+1;
			}
			else
			{
				cout << y+x+1;
			}
		}
		else
		{
			if(x<=y)
			{
				cout << y-x;
			}
			else
			{
				cout << x-y+2;
			}
		}
	}
	if(x==0)
	{
		if(y>=0)
		{
			cout << y;
		}
		else
		{
			cout << 1-y;
		}
	}
}


Measured memory_bytes: 256
function Main(input) {
  	var inputArray = input.split(' ');
    var appleN = inputArray[0];
    var lookD = inputArray[1] * 2 + 1;
    var ans = appleN / lookD;
    if (appleN % lookD != 0) {
       console.log(Math.floor(ans + 1));
        } else {
  		 console.log(ans);
        }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int H,W;
char t[50][50];
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
bool visited[50][50][4][16];

bool dfs(int py,int px,int dir,int mem){
  py=(py+H)%H;
  px=(px+W)%W;
  char ch=t[py][px];
  if(visited[py][px][dir][mem])return false;
  visited[py][px][dir][mem]=true;
  
  if(ch=='@'){
    return true;
  }else if(ch=='<' || (ch=='_'&&mem!=0) ){
    dir=3;
  }else if(ch=='>' || (ch=='_'&&mem==0)){
    dir=1;
  }else if(ch=='^' || (ch=='|'&&mem!=0)){
    dir=0;
  }else if(ch=='v' || (ch=='|'&&mem==0)){
    dir=2;
  }else if(ch=='?'){
    for(int i=0;i<4;i++){
      int ny=py+dy[i];
      int nx=px+dx[i];
      if( dfs(ny,nx,i,mem) )return true;
    }
    return false;
  }else if('0'<=ch&&ch<='9'){
    mem=(ch-'0');
  }else if(ch=='+'){
    mem=(mem+1)%16;
  }else if(ch=='-'){
    mem=(mem+15)%16;
  }
  py+=dy[dir];
  px+=dx[dir];
  if(dfs(py,px,dir,mem))return true;
  else return false;
}

int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>t[i][j];
  cout<< (dfs(0,0,1,0)?"YES":"NO") <<endl;
  return 0;
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char str[3];
	cin>>str;
	int max=0;
	int c=0;
	
	for(int i=0;i<3;i++)
	{
		if(str[i]=='R')
		{
			while(str[i]=='R')
			{
				c++;
				i++;
			}
			
			if(c>max)
			{
				max=c;
			}
			c=0;
		}
	}
	cout<<max<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int n,m;
    cin >> n >> m;
    int a[n];
    int sum=0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    int pop=(sum-1)/4/m;
    int cnt=0;
    rep(i,n){
        if(a[i]>pop)cnt++;
    }
    if(cnt>=m)cout << "Yes";
    else cout << "No";


    
}

/*
*/



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> u,v;
    int m = 0;
    REP(i,n-1){
        u.push_back(i+1);
        v.push_back(n);
        m++;
    }
    int dif = (n-1)*(n-2)/2-k;
    if(dif<0){
        put(-1);
        return 0;
    }
    vector<bool> c(n,0);
    REP(i,2){
        c[n-1-i]=1;
    }
    do{
        if(dif--<=0)break;
        int fir=-1,sec;
        REP(i,n){
            if(c[i]){
                if(fir<0){
                    fir = i;
                }else{
                    sec = i;
                }
            }
        }
        u.push_back(fir);
        v.push_back(sec);
        m++;
    }while(next_permutation(all(c)));
    put(m);
    REP(i,m){
        cout << u[i] << " " << v[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[200000];
signed main(){
	int n,k;scanf("%d",&n);
	cin>>k;
	map<int,int>mp;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	if(mp.size()<=k){
		puts("0");
		return 0;
	}
	vector<int>v;
	for(auto p:mp)v.push_back(p.second);
	sort(v.begin(),v.end());
	int cnt=0;
	rep(i,v.size()-k){
		cnt+=v[i];
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 11516
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, x;
	scanf("%d%d", &n, &x);
	if (x == 1 || x == 2 * n - 1) printf("No\n");
	else {
		printf("Yes\n");
		vector<int> ans(2 * n);
		vector<bool> used(2 * n);
		ans[n] = x;
		ans[n - 1] = 1;
		ans[n + 1] = 2 * n - 1;
		used[1] = used[2 * n - 1] = used[x] = true;
		if (n > 2) {
			if (x == 2) ans[n - 2] = 2 * n - 2;
			else ans[n + 2] = 2;
			used[ans[n - 2]] = used[ans[n + 2]] = true;
		}
		int c = 1;
		for (int i = 1; i <= 2 * n - 1; ++i) {
			if (ans[i]) printf("%d\n", ans[i]);
			else {
				while (used[c]) ++c;
				printf("%d\n", c);
				++c;
			}
		}
	}
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string ans = "";
  int x = sx, y = sy;
  while(y < ty) y++, ans += "U";
  while(x < tx+1) x++, ans += "R";
  while(y > sy-1) y--, ans += "D";
  while(x > sx) x--, ans += "L";
  y++, ans += "U";
  x--, ans += "L";
  while(y < ty+1) y++, ans += "U";
  while(x < tx) x++, ans += "R";
  while(y > sy) y--, ans += "D";
  while(x > sx) x--, ans += "L";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>


int main(void){
  int n;
  scanf("%d",&n );

  int half,tmp=0;
  char s[101];
  char half1[51],half2[51];

  scanf("%s",s);

  if(n%2!=0){
    printf("No\n");
  }else{
    half=n/2;
    for (int i = 0; i < half; i++) {
      half1[i]=s[i];
      //printf("%c",half1[i] );
    }
    int j=0;
    for (int i = half; i < n; i++) {
      half2[j]=s[i];
      j++;
    }

///////
    for (size_t i = 0; i < half; i++) {
      if(half1[i]!=half2[i]){
        printf("No\n");
        tmp=1;
        break;
      }
    }
    if (tmp==0) {
      printf("Yes\n");
    }

  }

  return 0;
}


Measured memory_bytes: 128
def main():
    n = int(input())
    a_list = list(map(int,input().split()))
    a = 0
    end = 0
    for i in range(n):
        if i%2 == 0:
            a += a_list[i]*0.5
        else:
            a -= a_list[i]*0.5

    out = str(int(a*2))
    point = a
    for i in range(n-1):
        point = a_list[i]-point
        out += " "+str(int(point*2))
    print(out)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14028
N=int(input())
check=[0]*(N+1)

DIV=10**9+7
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for i in range(2,N+1):
  facts=factorization(i)
  for fact in facts:
    check[fact[0]]+=fact[1]
    
ans=1
for c in check:
  if c==0:
    continue
  ans=((ans%DIV)*((c+1)%DIV))%DIV

print(ans)

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

int main(){
    double H, W, x, y; cin >> W >> H >> x >> y;
    if( H == 2 * y && W == 2 * x ){
        cout << (H / 2.0000000000) * W << " " << 1 << endl;
    } else {
        cout << (H / 2.0000000000) * W << " " << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;
typedef long long int ll;

int main(void){
  int pre = 0;
  int cur = 0;
  ll ans = 0;
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> cur;
    if(cur >= pre){
      pre = cur;
    }else{
      ans += pre - cur;
      //pre = cur;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  for(int i=0; i<N; i++){
      cin >> x.at(i);
      cin >> y.at(i);
  }
  double sum=0;
  for(int i=0; i<N; i++){
      for(int j=i+1; j<N; j++){
          if(i!=j){
              double d=sqrt(pow((x.at(i)-x.at(j)),2)+pow((y.at(i)-y.at(j)),2));
              
              sum+=d;
          }
      }
  }
  double ave;
  int t=0;
  for(int i=1; i<N; i++){
      t+=i;
  }
  ave=sum/t;
  
  printf("%f\n",ave*(N-1)); 
}

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

using namespace std;

int main() {

    int n;
    string s;
    cin >> n >> s;

    int maximum = 0, curr = 0;

    int left[256] = {0}, right[256] = {0};
    left[s[0]] = 1;

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

    maximum = curr = (right[s[0]] > 0 ? 1 : 0);

    for (int i = 1; i < n; i++) {
        left[s[i]]++;
        right[s[i]]--;

        if (left[s[i]] > 1 and right[s[i]] == 0) {
            curr--;
        } else if (left[s[i]] == 1 and right[s[i]] > 0) {
            curr++;
        }

        maximum = max(maximum, curr);
    }

    cout << maximum << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
$input = trim(fgets(STDIN));
list($w,$h,$x,$y,$r)= explode(" ", $input);
if(($x - $r) >= 0 && ($x + $r) <= $w && ($y - $r) >= 0 && ($y + $r) <= $h){
    echo "Yes\n";
}else{
    echo "No\n";
}

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

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

  std::vector<int> x_array(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> x_array[i];
  }

  const long long mod = 1000000000 + 7;

  int zone = 0;
  long long ans = 1;
  long long zanki = 0;
  long long vacant = 0;

  for (const int x : x_array) {
    zanki += 1;

    int cur_zone = x / 2;
    if (x % 2 == 1) {
      cur_zone += 1;
    }

    if (zone < cur_zone) {
      vacant += (cur_zone - zone) - 1;
      zone = cur_zone;
    } else {
      if (vacant > 0) {
        vacant -= 1;
      } else {
        ans = (ans * zanki) % mod;
        zanki -= 1;
      }
    }
  }

  for (long long i = zanki; i >= 2; --i) {
    ans = (ans * i) % mod;
  }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    double v[n], tt = 0.0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        tt += v[i];
    }
    int cnt = 0;
    double aux = (tt * (1 / (4.0 * (m + 0.0))));
    for(int i = 0; i < n; i++){
        if(v[i] >= aux)
            cnt++;
    }
    cnt >= m? cout << "Yes\n" : cout << "No\n";
    return 0;
}


Measured memory_bytes: 256