akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using v = vector<ll>;
void dpA(){
    int n;
    cin >> n;
    auto h = vector<ll>(n,0);
    for(ll i =0;i<n;i++) cin >> h[i];

    auto dp = vector<ll>(n+2,1e9);
    
    dp[0] = 0;
    dp[1] = 0;
    for(ll i=1;i<n;i++){
        if(i>=2) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])); 
        else if(i>=1) dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
    }
    cout << dp[n-1];
}

void dpB(){
    ll n,k;
    cin >> n >> k;
    auto h = vector<ll>(n+1,0);
    for(ll i=0;i<n;i++) cin >> h[i];

    auto dp = vector<ll>(100000,1e9);
    dp[0] = 0;
    for(ll i=0;i<n;i++){
        for(ll j=1;j<=k;j++){
           if(i+j<=n) dp[i+j] = min(dp[i+j],dp[i] + abs(h[i+j]-h[i]));
        }
    }
    cout << dp[n-1];
}

void dpC(){
    ll n; cin >> n;
    vector<v> a(n,v(3,0));
    for(ll i=0;i<n;i++) cin >> a[i][0] >> a[i][1] >> a[i][2];

    auto dp = vector<v>(n+1,v(3,0));

    for(ll i=0;i<n;i++)
        for(ll today=0;today<3;today++)
            for(ll oday=0;oday<3;oday++)
                if(today!=oday) 
                    dp[i+1][today] = max(dp[i+1][today],dp[i][oday] + a[i][today]);
    
    cout << max(dp[n][0],max(dp[n][1],dp[n][2]));
   
    
}

void dpD(){
    ll N,W;
  	cin >> N >> W;
    auto ww = v(N,0);
    auto vv = v(N,0);
    for(ll i=0;i<N;i++) cin >> ww[i] >> vv[i];

    auto dp = vector<v>(N+1,v(W+1,0));
    
    for (ll i = 0; i < N; i++)
    {
        for (ll j = 0; j <= W; j++)
        {

            if(j-ww[i]>=0) dp[i+1][j] = max(dp[i][j],dp[i][j-ww[i]]+vv[i]);
            else dp[i+1][j] = dp[i][j];
        }    
    }
    cout << dp[N][W];
}

void dpE(){
    ll N,W;
  	cin >> N >> W;
    auto ww = v(N,0);
    auto vv = v(N,0);
    for(ll i=0;i<N;i++) cin >> ww[i] >> vv[i];

    auto dp = vector<v>(N+1,v(1e5+100,1LL<<60));
    dp[0][0] = 0;
  
    for (ll i = 0; i < N; i++)
    {
        for (ll j = 0; j <=1e5; j++)
        {
            if(j+vv[i]<=1e5) dp[i+1][j+vv[i]] = min(dp[i+1][j+vv[i]],dp[i][j]+ww[i]);  
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        }    
    }
  
    ll ans = 0;
    for(auto i=0;i<=1e5;i++){
        if(dp[N][i] <=W){
            ans = i;
        }
    }
    cout << ans;
}

int main(){
    dpE();
    return 0;
}

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

#define INF 2147483647
#define MAX_N 131072

int tree[MAX_N*2];
int L[MAX_N*2];
int R[MAX_N*2];

int dfs(int a, int b, int k){
  if(R[k]<=a || b<=L[k])return INF;
  if(a<=L[k] && R[k]<=b)return tree[k];
  return min(dfs(a,b,k*2+1),dfs(a,b,k*2+2));
}

int getmin(int a, int b){
  return dfs(a,b,0);
}

void update(int i, int x){
  int k=i;
  k += (MAX_N-1);
  tree[k]=x;
  L[k]=i;
  R[k]=i+1;
  while(k){
    k=(k-1)/2;
    tree[k]=min(tree[k*2+1],tree[k*2+2]);
    L[k]=min(L[k*2+1],L[k*2+2]);
    R[k]=max(R[k*2+1],R[k*2+2]);
  }
}

int n,q;
int a,b,c;
int main(){
  for(int i=0;i<MAX_N;i++)
    update(i,INF);

  cin>>n>>q;

  for(int i=0;i<q;i++){
    cin>>a>>b>>c;
    if(a==1)cout<<getmin(b,c+1)<<endl;
    else update(b,c);
  }
  return 0;
}

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

int main() {
  std::vector<int> c(9, 0);

  int n;
  std::cin >> n;

  for (int i = 0; i < n; i++) {
    int r;
    std::cin >> r;
    c[std::min(8, r / 400)]++;
  }

  int s = 0;
  for (int i = 0; i < 8; i++) {
    if (c[i] != 0) {
      s++;
    }
  }

  std::cout << std::max(1, s) << " " << s + c.back() << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  
  if (X-A >= 0 && X-A <= B) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
   string s; cin>>s;
   int n=s.size();
   int ans=1010;
   for(int i=0;i<n-2;i++){
      int num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
      ans=min(ans,abs(num-753));
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  v(ll) sum(N+1,0);
  rep(i,N) {
    sum[i+1] = sum[i] + (ll)A[i];
  }
  ll ans = LINF;
  rep(i,N-1) {
    ans = min(ans, abs(sum[N] -  2 * sum[i+1]));
  }
  cout << ans << endl;
  return 0;
}

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;

 long double pi=3.14159;

 string N;

signed main(){
	
	cin>>a>>b>>c;

	swap(a,b);

	swap(a,c);

	cout<<a<<" "<<b<<" "<<c;



 return 0;
}


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

int main(){
   int n,k;
    cin>>n>>k;
    
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    
    sort(p.begin(),p.end());
    
    int ans=0;
    rep(i,k) ans +=p[i];
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cctype>
#include <cstring>
#include <string>

#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )
#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )

using namespace std;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  char buf[ 256 ];
  int n;

  fgets ( buf, sizeof ( buf ), stdin );
  sscanf ( buf, "%d", &n );
  while ( n-- )
  {
    string res;
    int m;
    int p = 0;

    fgets ( buf, sizeof ( buf ), stdin );
    *( strchr ( buf, '\n' ) ) = '\0';
    res.assign ( buf );

    fgets ( buf, sizeof ( buf ), stdin );
    sscanf ( buf, "%d", &m );

    while ( m-- )
    {
      fgets ( buf, sizeof ( buf ), stdin );

      if ( !strncmp ( buf, "forward char", 12 ) )
      {
        ++p;
        p = MIN( p, res.size ( ) );
        continue ;
      }
      if ( !strncmp ( buf, "backward char", 13 ) )
      {
        --p;
        p = MAX( p, 0 );
        continue ;
      }
      if ( !strncmp ( buf, "forward word", 12 ) )
      {
        while ( p < res.size ( ) && isspace ( res[ p ] ) ) ++p;
        while ( p < res.size ( ) && !isspace ( res[ p ] ) ) ++p;
        continue ;
      }
      if ( !strncmp ( buf, "backward word", 13 ) )
      {
        while ( p > 0 && isspace ( res[ p - 1 ] ) ) --p;
        while ( p > 0 && !isspace ( res[ p - 1 ] ) ) --p;
        continue ;
      }
      if ( !strncmp ( buf, "insert", 6 ) )
      {
        *( strrchr ( buf, '\"' ) ) = '\0';
        res.insert ( p, strchr ( buf, '\"' ) + 1 );
        p += strlen ( strchr ( buf, '\"' ) + 1 );
        continue ;
      }
      if ( !strncmp ( buf, "delete char", 11 ) )
      {
        if ( p < res.size ( ) ) res.erase ( p, 1 );
        continue ;
      }
      if ( !strncmp ( buf, "delete word", 11 ) )
      {
        int q = p;

        while ( q < res.size ( ) && isspace ( res[ q ] ) ) ++q;
        while ( q < res.size ( ) && !isspace ( res[ q ] ) ) ++q;
        if ( !isspace ( res[ q - 1 ] ) ) res.erase ( p, q - p );
        continue ;
      }
    }

    printf ( "%s^%s"
           , res.substr ( 0, p ).c_str ( )
           , res.substr ( p, res.size ( ) - p ).c_str ( ) );
    puts ( "" );
  }

  return ( 0 );
}

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

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> a;
  rep(i, n) {
    int x;
    cin >> x;
    a.push(x);
  }
  while (m) {
    int t = a.top();
    a.pop();
    a.push(t/2);
    --m;
  }
  ll ans = 0;
  rep(i, n) {
    ans += a.top();
    a.pop();
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3936
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    int h, w, k;
    cin>>h>>w>>k;

    vector<mint> com {1, 1, 2, 3, 5, 8, 13, 21, 34};
    vector<vector<mint>> dp(h + 1, vector<mint>(w));
    dp[0][0] += 1;
    rep(i, h) {
        rep(j, w) {
            dp[i + 1][j] += dp[i][j] * com[j] * com[w - j - 1];
            if (j > 0) dp[i + 1][j] += dp[i][j - 1] * com[j - 1] * com[w - j - 1];
            if (j < w - 1) dp[i + 1][j] += dp[i][j + 1] * com[j] * com[w - j - 2];
        }
    }
    cout<<dp[h][k - 1]<<endl;
}

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

long long int gcd(long int a, long int b) { return b ? gcd(b, a%b) : a;}
long long int lcm(long long int a, long long int b) { return a / gcd(a,   b) * b;}
int main(){
    long long int a,b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;    
}

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

int N, M, Ans;
char a[MaxN][MaxN];
int l[MaxN][MaxN], r[MaxN][MaxN], u[MaxN][MaxN], d[MaxN][MaxN];
inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}
inline void ChkMax(int &aa, int bb) {
	if(aa < bb) aa = bb;
	return;
}

int main() {
	register int i, j;
	N = Rd(), M = Rd();
	for(i = 1; i <= N; ++i)
		scanf("%s", a[i] + 1);
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j)
			l[i][j] = (a[i][j] == '#') ? 0 : 1 + l[i][j - 1];
	for(i = 1; i <= N; ++i)
		for(j = M; j >= 1 ; --j)
			r[i][j] = (a[i][j] == '#') ? 0 : 1 + r[i][j + 1];
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j)
			u[i][j] = (a[i][j] == '#') ? 0 : 1 + u[i - 1][j];
	for(i = N; i >= 1; --i)
		for(j = 1; j <= M; ++j)
			d[i][j] = (a[i][j] == '#') ? 0 : 1 + d[i + 1][j];
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j)
			ChkMax(Ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);	
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 66816
#include<bits/stdc++.h>
using namespace std ; 
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;ll k;cin>>k;
  ll dp[n+1]={0};
  ll a[n+1]={0};
  ll i;
  for(i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  dp[1]=0;
  dp[2]=abs(a[1]-a[2]);
  i=3;
  while(i<=n)
  {
      dp[i]=1e18;
    ll j = 1 ; 
    while(j<=k && i-j>=1)
    {
        dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        
        j++;
    }
    
    
    i++;
  }
  cout<<dp[n];
  
  
  return 0;
}

Measured memory_bytes: 5156
def main():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    ans = float("INF")
    b = [float("INF")]*N
    for k in range(N):
        temp_ans = k*x
        for i in range(N):
            b[i] = min(b[i],a[i-k])
            temp_ans += b[i]
        ans = min(ans,temp_ans)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <functional>
#include <bitset>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using string_view = boost::string_ref;

#include <boost/function_output_iterator.hpp>


using namespace std;

template<class T, size_t N, class F>
struct compare_n
{
    F f;
    bool operator() (const T& t1, const T& t2)
    {
        return f(get<N>(t1), get<N>(t2));
    }
};
 
template<size_t N, class T>
auto make_less_n(const T&)
{
    using t = typename T::value_type;
    using less = std::less<typename tuple_element<N, t>::type>;
    return compare_n<t, N, less>();
}

template<class T>
T digit(T x)
{
    return static_cast<T>(floor(log10(x)+1));
}

int64_t ipow(int64_t x, int64_t y)
{
    return static_cast<int64_t>(pow(x, y));
}

struct point_t
{
    int64_t x,y;
};

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

    size_t n, m;
    cin >> n >> m;
    
    if(n > m)
    {
        cout << "0\n";
        return 0;
    }
    
    vector<int> xs(m);
    for(auto& x : xs) cin >> x;
    sort(begin(xs), end(xs));
    
    vector<int> ds(m-1);
    for(size_t i : irange(0UL, ds.size()))
    {
        ds[i] = xs[i+1]-xs[i];
    }
    sort(begin(ds), end(ds), greater<int>());
    
    int ans = xs.back() - xs.front();
    for(size_t i : irange(0UL, n-1))
    {
        ans -= ds[i];
    }
    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#define N 10000

int main(void){
  int i,num;
  int h,m,s;
  int sums[N],trsums[N];

  for(i=0;;i++){
    scanf("%d%d%d",&h,&m,&s);
    if(h==-1)
      break;
    sums[i]=s+60*m+3600*h;
    sums[i]=7200-sums[i];
    trsums[i]=3*sums[i];
  }
  num=i;
  for(i=0;i<num;i++){
    h=sums[i]/3600;
    sums[i]%=3600;
    m=sums[i]/60;
    sums[i]%=60;
    s=sums[i];
    if(h/10==0)
      printf("0");
    printf("%d:",h);
    if(m/10==0)
      printf("0");
    printf("%d:",m);
    if(s/10==0)
      printf("0");
    printf("%d\n",s);
    h=trsums[i]/3600;
    trsums[i]%=3600;
    m=trsums[i]/60;
    trsums[i]%=60;
    s=trsums[i];
    if(h/10==0)
      printf("0");
    printf("%d:",h);
    if(m/10==0)
      printf("0");
    printf("%d:",m);
    if(s/10==0)
      printf("0");
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	char x[10];
	int i;
	int max;
	int count;
	
	scanf("%s", x);
	
	for (i = 0;i < 10; i++){
		if(x[i] == 'A'||x[i] == 'T'||x[i] == 'C'||x[i] == 'G'){
			count++;
			if (max < count){max = count;}
		}
		else if (count != 0){
			count = 0;
		}
	}
	
	printf("%d", max);
	
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;

vector<string> selection_sort(vector<string> s){
    int n = s.size();
    vector<int> a;
    REP(i, n)
        a.push_back(atoi(s[i].substr(1, 1).c_str()));

    REP(i, n){
        int mini = i;
        for(int j = i; j < n ; j++){
            if(a[j] < a[mini])
                mini = j;
        }
        if(i != mini){
            swap(a[i], a[mini]);
            swap(s[i], s[mini]);
        }
    }
    return s;
}

vector<string> bubble_sort(vector<string> s) {
    int n = s.size();
    vector<int> a;
    REP(i, n)
        a.push_back(atoi(s[i].substr(1, 1).c_str()));

    REP(i, n)
        for(int j = n - 1; j > i; j--)
            if(a[j] < a[j-1]){
                swap(a[j], a[j-1]);
                swap(s[j], s[j-1]);
            }

    return s;
}

int find(vector<string> target, string query){
    int i = 0;
    vector<string>::iterator iter = target.begin();
    while(iter != target.end()){
        if (*iter == query)
            break;
        i++;
        iter++;
    }

    return i;
}

int main() {
    int n;
    cin >> n;
    vector<string> a;
    string str;
    REP(i, n) {
        cin >> str;
        a.push_back(str);
    }
    vector<string> b, s;
    b = bubble_sort(a);
    s = selection_sort(a);

    REP(i, n-1) {
        cout << b[i] << " ";
    }

    cout << b[n-1] << endl << "Stable" << endl;
    REP(i, n-1) {
        cout << s[i] << " ";
    }

    cout << s[n-1] << endl;
    bool stable = true;
    REP(i, n){
        REP(j, i){
            if((s[j].substr(1,1) == s[i].substr(1,1)) && ((find(a, s[j]) - find(a, s[i])) > 0)){
                stable = false;
                break;
            }
        }
    }

    if(stable)
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;


    return 0;
}

Measured memory_bytes: 1240
# https://atcoder.jp/contests/abc176/tasks/abc176_e

h,w,m=gets.split.map(&:to_i)
# h,w,m=300000,300000,300000
lh=[0]*h
lw=[0]*w
# s=[]
# h.times do
#   s << [0]*w
# end
sl=[]
m.times do
# m.times do |i|
  hh,ww=gets.split.map(&:to_i)
  # hh,ww=i+1,i+1
  lh[hh-1]+=1
  lw[ww-1]+=1
  # s[hh-1][ww-1]=1
  sl << [hh-1,ww-1]
end
mh=lh.max
mw=lw.max
# lhh=[]
# lh.each.with_index do |llh,i|
#   if llh==mh
#     lhh << i
#   end
# end
# lww=[]
# lw.each.with_index do |llw,i|
#   if llw==mw
#     lww << i
#   end
# end
# ans=mh+mw
# lhh.each do |i|
#   lww.each do |j|
#     if s[i][j]==0
#       puts ans
#       exit
#     end
#   end
# end
ans=mh+mw
ch=lh.count(mh)
cw=lw.count(mw)
cnt=ch*cw
sl.each do |i,j|
  if lh[i]==mh&&lw[j]==mw
    cnt-=1
  end
end
puts cnt==0 ? ans-1 : ans


Measured memory_bytes: 39612
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

void g(int a){
	if(a/1000){
		if(a/1000>=2){
			cout<<a/1000;
		}
		cout<<"m";
	}
	a%=1000;
	if(a/100){
		if(a/100>=2){
			cout<<a/100;
		}
		cout<<"c";
	}
	a%=100;
	if(a/10){
		if(a/10>=2){
			cout<<a/10;
		}
		cout<<"x";
	}
	a%=10;
	if(a){
		if(a>=2){
			cout<<a;
		}
		cout<<"i";
	}
	cout<<endl;
}

int f(){
	string str;
	cin>>str;
	int i,res=0;
	int a=1;
	for(i=0;i<str.size();i++){
		if(str[i]=='m'){
			res+=a*1000;
			a=1;
		}else if(str[i]=='c'){
			res+=a*100;
			a=1;
		}else if(str[i]=='x'){
			res+=a*10;
			a=1;
		}else if(str[i]=='i'){
			res+=a;
			a=1;
		}else{
			a=str[i]-'0';
		}
	}
	return res;
}

int main() {
	int n=in();
	while(n--){
		int a,b;
		a=f();
		b=f();
		g(a+b);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 500000
 
int H;
int A[N+1];
 
void MaxHeapify(int i){
  int l,r,largest,temp;

  l=i*2;
  r=i*2+1;
  temp=0;
 
  if(l<=H && A[l]>A[i]){
    largest=l;
  }else{
    largest=i;
  }
 
  if(r<=H && A[r]>A[largest]){
    largest=r;
  }
 
  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    MaxHeapify(largest);
  }
}
 
void buildMaxHeap(){
  int i=0;
 
  for(i=H/2;i>=1;i--){
    MaxHeapify(i);
  }
}
 
int main(){
  int i,j;
 
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
 
  buildMaxHeap();
 
  for(i=1;i<=H;i++){
    printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
 
  return 0;
}

Measured memory_bytes: 2552
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#define eps 1e-5
using namespace std;
const int MAXN=10;
int a[MAXN+5][MAXN+5];
int n,d,tmp1,ans;
double tmp2;
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			tmp1=0;
			for(int k=1;k<=d;k++)
				tmp1+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			tmp2=sqrt(tmp1);
			if(tmp2-(int)tmp2<eps)
				ans++;
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
void Iswap(int *a,int *b){
  int t=*a;
  *a=*b;
  *b=t;
}
void Fswap(double *a,double *b){
  double t=*a;
  *a=*b;
  *b=t;
}
void Lswap(ll *a,ll *b){
  ll t=*a;
  *a=*b;
  *b=t;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

int main(void){
  int n;
  scanf("%d",&n);
  ll ans=0;
  FOR(i,n+1)if(i%3&&i%5)ans+=i;
  PRL(ans);
  return 0;
}

Measured memory_bytes: 1732
/*
 * Author: Utkal Sinha
 * Created on: 2020-08-22, Sat, 18:9
 * Problem:
 * Platfrom: General
 * */
#if USE_BOOST2
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; //int512_t or //int128_t
typedef bst::cpp_bin_float_100 vdouble;
#endif

#include <bits/stdc++.h>
using namespace std;
#define GETTIME std::chrono::system_clock::now()
#define DURATION std::chrono::duration<double>
#ifdef MY_DEV_ENV2
#define LOCALDEV
#endif
typedef long long ll;
typedef std::chrono::system_clock::time_point TPT;
static TPT starttime, endtime, timelimit;
static double problem_tle = 1.5;
static inline void calc_problem_end_time() {timelimit = starttime + std::chrono::milliseconds(int (problem_tle * 1000));}
// template end



void love() {
    int n;
    cin >> n;
    ll arr[n];
    for(int i = 0; i<n; i++) cin >> arr[i];
    ll ans = 0;
    ll mx = arr[0];
    for(int i = 1; i<n; i++) {
        if(arr[i] < mx) {
            ans += arr[i-1] - arr[i];
            arr[i] = arr[i-1];
        }
        mx = arr[i];
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    srand(time(0));
#ifdef LOCALDEV
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
#ifdef LOCALDEV
    starttime = GETTIME;
    calc_problem_end_time();
#endif
    while(t--) love();
#ifdef LOCALDEV
    endtime = GETTIME;
    DURATION elapsed_seconds = endtime - starttime;
    DURATION time_limit_seconds = timelimit - starttime;
    clog << "Elapsed time: " << elapsed_seconds.count() << "s\n";
    clog << "Time limit: " << time_limit_seconds.count() << "s\n";
#endif
    return 0;
}

Measured memory_bytes: 5216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

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

using ll = long long;

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

	if (N * 2 <= K)
	{
		cout << N << endl;
		return 0;
	}

	if (N % K == 0)
	{
		cout << 0 << endl;
		return 0;
	}

	if (N / 2.0 < K)
	{
		ll ans = N;

		rep(i, 3)
		{
			ans = min(abs(ans - K), ans);
		}

		cout << ans << endl;
	}
	else if(K == 2)
	{
		cout << 1 << endl;
	}
	else
	{
		ll ans = N % K;

		rep(i, pow(10, 6))
		{
			ans = min(abs(ans - K), ans);
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, m, a, b;
    cin >> n >> m;
    unordered_set<int> x1;
    unordered_set<int> x2;
    while(m--) {
        cin >> a >> b;
        if (a == 1)
            x1.insert(b);
        if (b == n)
            x2.insert(a);
    }
    for(int e: x1) {
        if (x2.count(e) > 0) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}



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

int main(int argc, char const* argv[]) {

    std::string w;
    char        c = 'a';
    int         count;
    std::cin >> w;

    for (size_t i = 0; i < 26; i++) {
        count = 0;
        for (size_t j = 0; j < w.size(); j++) {
            if (w.at(j) == c) {
                count++;
            }
        }
        if (count % 2 == 1) {
            std::cout << "No" << '\n';
            return 0;
        }
        c++;
    }

    std::cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 256
from collections import deque
from sys import stdin
input = stdin.readline

H,W = map(int, input().split())
mapmatrix = [None]*H
before_black_cnt = 0
for i in range(H):
    st = input()
    before_black_cnt += st.count('#')
    mapmatrix[i] = list(st)


queue = deque()
queue.append((0,0))
distancelist = [[-1]*W for _ in range(H)]
distancelist[0][0] = 1

move = ((-1,0),(1,0),(0,-1),(0,1))

while queue:
    x,y = queue.popleft()
    
    distance = distancelist[y][x]
    for dx,dy in move:
        X = x + dx; Y = y + dy
        if X >= 0 and X < W and Y >= 0 and Y < H:
            if distancelist[Y][X] == -1 and mapmatrix[Y][X] == '.':
                distancelist[Y][X] = distance + 1
                queue.append((X,Y))
if distancelist[H-1][W-1] == -1:
    print(-1)
else:
    after_black_cnt = W*H - distancelist[H-1][W-1]
    print(after_black_cnt - before_black_cnt)

Measured memory_bytes: 9500
// AOJ 0251: Magic Square
// 2017.12.16 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 100002

/* UNION-FIND library */
int p[MAX], rank[MAX];
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

char f[MAX];
char buf[20], *bp;

int in()
{
	int n = 0;
	while (*bp >= '0') n = 10*n + (*bp++ & 0xf);
	bp++;
	return n;
}

int main()
{
	int n, m, a, b, ans;

	while (fgets(bp=buf, 20, stdin) && *bp != '0') {
		n = in(), m = in();

		memset(rank, 0, sizeof(rank));
		for (a = 1; a <= n; a++) p[a] = a;
		memset(f, 0, sizeof(f));

		ans = 1;
		while (m--) {
			fgets(bp=buf, 20, stdin);
			if (ans) {
				a = in(), b = in();
				if      (f[a] > 1) ans = 0;
				else if (f[b] > 1) ans = 0;
				else if (find_set(a) == find_set(b)) ans = 0;
				if (ans) union_set(a, b), f[a]++, f[b]++;
			}
		}
		puts(ans ? "yes" : "no");
	}
	return 0;
}

Measured memory_bytes: 2412
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    int m;
    cin >> m;
    cout << (48 - m ) << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    vector<int> v(5);
    for (int i = 0; i < 5; i++)
        cin >> v[i];
    int ret = INF;
    for (int i = 0; i < 5; i++)
    {
        int sum = 0;
        for (int j = 0; j < 5; j++)
        {
            if (i == j)
                continue;
            sum += ((v[j] - 1) / 10 + 1) * 10;
        }
        sum += v[i];
        ret = min(ret, sum);
    }
    cout << ret << endl;
}


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

int main()
{
    const int MAX = 300000 + 700;
    int num, i, j;
    vector<int> msday;
    for (i = 2; i < MAX; ++i) {
        if (i % 7 == 1 || i % 7 == 6)
            msday.push_back(i);
    }
    while (cin >> num, num != 1) {
        vector<int> res;
        for (i = 0; ; ++i) {
            int ms = msday[i];
            if (ms > num)
                break;
            if (num % ms == 0) {
                for (j = 0; j < i; ++j) {
                    if (ms % msday[j] == 0)
                        break;
                }
                if (j == i)
                    res.push_back(ms);
            }
        }
        cout << num << ':';
        for (int i = 0; i < res.size(); ++i)
            cout << ' ' << res[i];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1592
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    double num;
    cin >> num;
    cout << setprecision(20) << (num*num*num)/27 << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
long long int i;
string s, ans;
int main()
{
    cin>>s;
    ans="";
    for(i=0;i<s.length();i++){
        if(s[i]=='0'){
            ans=ans+"0";
        }
        else if(s[i]=='1'){
            ans=ans+"1";
        }
        else if(s[i]=='B' && ans.length()>0){
            ans.erase(ans.end()-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        String T = scanner.nextLine();
        int min = Integer.MAX_VALUE;
        for(int i = 0; i<=S.length()-T.length(); i++){
            min = Math.min(min, find(S.substring(i, i+T.length()), T));
        }
        if(min!=Integer.MAX_VALUE){
            System.out.println(min);
        }else{
            System.out.println(T.length());
        }

    }

    public static int find(String a, String b){
        int calc = 0;
        for(int x = 0; x<a.length(); x++){
            if(a.charAt(x) != b.charAt(x)){
                calc++;
            }
        }
        return calc;
    }
}


Measured memory_bytes: 35864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,k;
	cin>>n>>k;
	long double ans=0.0;
	for(int i=1;i<=n;i++){
			long double a=1.0/n;
			ll num=i;
			ll cnt=0;
			for(cnt=0;cnt>=0;cnt++){
				if(num>=k)break;
				num*=2;
				a*=0.5;
			}
			ans+=a;
	}
	cout<<fixed<<setprecision(20)<<ans<<endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 

#define MOD 1000000007

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

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

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

	ll N;
	string S;

	cin >> N >> S;

	vector<ull> dp(N+1, 0);
	vector<ll> Acount(256, 0);
	bool flg = false;

	dp[0] = 0;
	int count = 0;
	//int dup = 0;

	rep(i, N) {
		Acount[S[i]]++;
	}
	ll out = 1;

	rep(i, 256) {
		if (Acount[i] != 0) {
			out = (out * (Acount[i] + 1)) % MOD;
		}
	}

	cout << dec << out - 1;
	

	return 0;
}

Measured memory_bytes: 1232
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
 
import java.util.*;
import java.lang.*;
import java.io.*;

@SuppressWarnings("unchecked")
public class Main implements Runnable {

  static BufferedReader in;
  static PrintWriter out;
 
  public static void main(String[] args) {
      new Thread(null, new Main(), "whatever", 1<<29).start();
  }


  public int findDigitsInBase(long n, int base) 
  { 
      return (int)(Math.floor(Math.log(n)/Math.log(base)) + 1);  
  } 
 
  public void run() {
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out, false);
 
    try
    {
      // in = new BufferedReader(new FileReader("class_treasurer.txt"));
      // out = new PrintWriter("output.txt");

      int t,x1,n,b;
      String str;
      String[] token;

      str=in.readLine().trim();
      token=str.split(" ");
      n=Integer.parseInt(token[0]);
      b=Integer.parseInt(token[1]);

      out.println(findDigitsInBase(n,b));


      out.flush();
      out.close();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 22740
#include <stdio.h>
int main(){
  int x,y;
  scanf("%d %d",&x,&y);
  int a=2*x;
  int b=4*x;
  if(y%2==0 && y<=b && y>=a){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1728
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define all(x) x.begin(),x.end() 
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int INF = 1e15;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int cnt,m,sum;
    int a[MAX];
    void solve()
    {
        cin>>n>>m;
        fo(i,0,n)
        {
            cin>>a[i];
            sum+=a[i];
        }
        fo(i,0,n)
        {
            if(a[i]*4*m>=sum)
                cnt++;
        }
        if(cnt>=m)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int h,a,i,total;
	scanf ("%d",&h);
	scanf ("%d",&a);
	if (h%a==0){
		i=h/a;
		printf ("%d",i);
	}
	else{
		total = (h/a)+1;
		printf ("%d",total);
	}
	return 0;
}

Measured memory_bytes: 1688
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
-- end of templete



main = replicateM 5 getInt >>= print . (`div` 5) . sum . map (max 40)


Measured memory_bytes: 3652
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>
 
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
 
#define pb(x) push_back(x)  
#define rep(i,n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define len(p) (sizeof(p)/sizeof(*p))
#define debug(x) cerr << #x << ": " << x << '\n'; 
// #define int long long
 
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
template <class T> void print(T x){ cout << x << '\n'; }
template <class T> void print(T *x, size_t l){ rep(i,l){cout << *(x+i) << ' ';} cout << '\n'; }
 
signed main(void){
    int n, z, w;
    cin >> n >> z >> w;
    int a[n];
    rep(i,n) cin >> a[i];
    if(n==1){
        print(abs(a[0] - w));
        return 0;
    }
    print(max(abs(a[n-1] - w), abs(a[n-1] - a[n-2])));
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static Deque<String> list = new ArrayDeque<>();

    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] sp = new String[2];
        try {
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                sp = br.readLine().split(" ");
                if (sp[0].equals("insert")) {
                    list.addFirst(sp[1]);
                } else if (sp[0].equals("delete")) {
                    list.remove(sp[1]);
                } else if (sp[0].equals("deleteFirst")) {
                    list.removeFirst();
                } else if (sp[0].equals("deleteLast")) {
                    list.removeLast();
                }
            }
            if (!list.isEmpty()) {
                ans.append(list.getFirst());
                list.removeFirst();
            }
            while (!list.isEmpty()) {
                ans.append(" ").append(list.getFirst());
                list.removeFirst();
            }
            System.out.println(ans.toString());
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
}



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

int main()
{
	string str;
	while(cin>>str)
	{
		int len=str.length();
		int f=0;
		for(int i=0;i<=len-1;i++)
		{
			if(str[i]==str[i+1]&&i+1<len)
			{
				f=1;
				cout<<i+1<<" "<<i+2<<endl;
				break;
			}
			else if(str[i]==str[i+2]&&i+2<len)
			{
				cout<<i+1<<" "<<i+3<<endl;
				f=1;
				break;
			}
		}
		if(f==0)cout<<-1<<" "<<-1<<endl;
	}
}

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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	if (a < b)
	{
		for (int i = 0; i < b; i++)
		{
			cout << a;
		}
	}
	else
	{
		for (int i = 0; i < a; i++)
		{
			cout << b;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

int factM(int n){
    static vector<int> t = {1};

    if((int)t.size() > n){
        return t[n];
    }

    for(int i = t.size(); i <= n; i++){
        t.push_back(t[i-1] * i % MOD);
    }
    return t[n];
}

class Combination{
    private:
        vector<int> t;

    public:
        Combination(int n): t(n+1){
            t[n] = powM(factM(n), MOD-2);

            for(int i = n-1; i >= 0; i--){
                t[i] = t[i+1] * (i+1) % MOD;
            }
        }

        int comb(int n, int k){
            if(n < k || n < 0 || k < 0){
                return 0;
            }
            return factM(n) * t[k] % MOD * t[n-k] % MOD;
        }

        int getInv(int n){
            return t[n];
        }
};

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

    int n, k;
    cin >> n >> k;

    int m = n - k;
    Combination c(4000);

    for(int i = 1; i <= k; i++){
        cout << c.comb(m + 1, i) * c.comb(k - 1, i - 1) % MOD << endl;
    }

    return 0;
}


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;

bool inRange(int x, int l, int r)
{
	return x >= l and x <= r;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, x;
	cin >> n;

	vector<bool> color(8, false);
	int diff = 0, legends = 0;

	for(int i = 0; i < n; i++)
	{
		cin >> x;

		if(inRange(x, 1, 399) and !color[0])
		{
			color[0] = true;
			diff++;
		}

		if(inRange(x, 400, 799) and !color[1])
		{
			color[1] = true;
			diff++;
		}

		if(inRange(x, 800, 1199) and !color[2])
		{
			color[2] = true;
			diff++;
		}

		if(inRange(x, 1200, 1599) and !color[3])
		{
			color[3] = true;
			diff++;
		}

		if(inRange(x, 1600, 1999) and !color[4])
		{
			color[4] = true;
			diff++;
		}

		if(inRange(x, 2000, 2399) and !color[5])
		{
			color[5] = true;
			diff++;
		}

		if(inRange(x, 2400, 2799) and !color[6])
		{
			color[6] = true;
			diff++;
		}

		if(inRange(x, 2800, 3199) and !color[7])
		{
			color[7] = true;
			diff++;
		}

		if(x >= 3200)
			legends++;
	}

	if(diff!=0)
	{
    	cout<<diff<<" "<<diff+legends<<endl;
    }
    else
    {
        cout<<1<<" "<<legends<<endl;
    }
    
	return 0;	
}

Measured memory_bytes: 256