akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cctype>
#include<cstring>
#include<list>
#include<map>
#include<sstream>
#include<set>
#include<string>
#include<vector>
typedef long long ll;
using namespace std;
#define MN 300005
#define MM 600005
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define RF(i,a,b) for(int i=a;i>=(b);--i)
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define int long long
signed main()
{
   int t;
   while(cin>>t){
       int sum=(t+1)*t/2;
       for(int i=3;i<=t;i+=3){
           sum-=i;
       }
        for(int i=5;i<=t;i+=5){
           sum-=i;
       }
       for(int i=15;i<=t;i+=15){
           sum+=i;
       }
       cout<<sum<<endl;
   }
   return 0;
}


Measured memory_bytes: 3592
n, x = map(int, input().split())
a = [0]*(n+1)
p = [0]*(n+1)
a[0] = 1
p[0] = 1
for i in range(n):
    a[i+1] = 2*a[i]+3
    p[i+1] = 2*p[i]+1


def paty(n, x):
    if n == 0:
        return 1
    elif x == 1:
        return 0
    elif 1 < x <= 1+a[n-1]:
        return paty(n-1, x-1)
    elif x == 2+a[n-1]:
        return p[n-1]+1
    elif 2+a[n-1] < x <= 2+2*a[n-1]:
        return p[n-1]+1+paty(n-1, x-2-a[n-1])
    elif x == 3+2*a[n-1]:
        return 2*p[n-1]+1


print(paty(n, x))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
const int mod=1e9+7;
int t,n,m,k;
ll arr[maxn];
ll sum[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+i;
	}
	ll l=1;ll r=n+1-k;
	ll fin=1;
	for(ll i=l;i<=r;i++)
	{
		ll mi=sum[i-1];
		ll mx=sum[n]-sum[n-i];
		fin+=(mx-mi+1);
		fin=fin%mod;
	}
	cout<<fin<<endl;
	return 0;
}

Measured memory_bytes: 5100
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

  using i8 = std::int_fast8_t;
  using i32 = std::int_fast32_t;
  using i64 = std::int_fast64_t;
  using u8 = std::uint_fast8_t;
  using u32 = std::uint_fast32_t;
  using u64 = std::uint_fast64_t;
  using isize = std::ptrdiff_t;
  using usize = std::size_t;

  struct rep {
    struct itr {
      usize i;
      constexpr itr(const usize i) noexcept : i(i) {}
      void operator++() noexcept { ++i; }
      constexpr usize operator*() const noexcept { return i; }
      constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
    };
    const itr f, l;
    constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
    constexpr auto begin() const noexcept { return f; }
    constexpr auto end() const noexcept { return l; }
  };
  struct revrep {
    struct itr {
      usize i;
      constexpr itr(const usize i) noexcept : i(i) {}
      void operator++() noexcept { --i; }
      constexpr usize operator*() const noexcept { return i; }
      constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
    };
    const itr f, l;
    constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
    constexpr auto begin() const noexcept { return f; }
    constexpr auto end() const noexcept { return l; }
  };
  template <class T> auto md_vec(const usize n, const T& value) {
    return std::vector<T>(n, value);
  }
  template <class... Args> auto md_vec(const usize n, Args... args) {
    return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
  }
  template <class T> constexpr T difference(const T& a, const T& b) noexcept {
    return a < b ? b - a : a - b;
  }
  template <class T> void chmin(T& a, const T& b) noexcept {
    if (b < a)
      a = b;
  }
  template <class T> void chmax(T& a, const T& b) noexcept {
    if (a < b)
      a = b;
  }
  template <class F> class rec_lambda {
    F f;

  public:
    rec_lambda(F&& f) : f(std::move(f)) {}
    template <class... Args> auto operator()(Args&&... args) const {
      return f(*this, std::forward<Args>(args)...);
    }
  };
  template <class F> auto make_rec(F&& f) { return rec_lambda<F>(std::move(f)); }
  template <class T> T scan() {
    T ret;
    std::cin >> ret;
    return ret;
  }

} // namespace n91

#include <string>

namespace n91 {

  void main_() {
    /*
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    //*/
    std::string s = scan<std::string>();
    while (s.size() >= 2) {
      if (s.substr(s.size() - 2, 2) == "hi") {
        s.pop_back();
        s.pop_back();
      }
      else {
        std::cout << "No" << std::endl;
        return;
      }
    }
    if (!s.empty()) {
      std::cout << "No" << std::endl;
      return;
    }
    std::cout << "Yes" << std::endl;
    return;
  }

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

using namespace std;

int H, W;
unsigned char field[55][55];

int main()
{
    cin >> H >> W;
    
    string s;
    for (int i = 0; i < H; i++) {
        cin >> s;
        for (int j = 0; j < W; j++) {
            if (s[j] == '#') field[i + 1][j + 1] = 0b0000'0001;
            else if (s[j] == '.') field[i + 1][j + 1] = 0b0000'0000;
        }
    }
    for (int i = 1; i < 51; i++) {
        for (int j = 1; j < 51; j++) {
            field[i][j] |= (
                field[i - 1][j - 1] + field[i - 1][j] + field[i - 1][j + 1]
                + field[i][j - 1] + field[i][j + 1]
                + field[i + 1][j - 1] + field[i + 1][j] + field[i + 1][j + 1]
                ) << 4;
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (field[i + 1][j + 1] % 2) cout << '#';
            else cout << (char)((field[i + 1][j + 1] >> 4) + 0x30);
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ofstream cout ("fileName.out");
	//ifstream cin ("fileName.in");
	
	int H, W, K, black=0;
	cin>>H>>W>>K;
	
	vector<vector<char>> v(H, vector<char>(W));
	
	for(int j=0; j<H; ++j) {
		string row;
		cin>>row;
		for(int i=0; i<W; ++i) {
			v[j][i]=row[i];
			if(row[i]=='#') ++black;
		}
	}
	
	if(black<K) cout<<"0\n";
	else {
		
		int ans=0;
		
		for(int j=0; j<(1<<H); ++j) {
			for(int i=0; i<(1<<W); ++i) {
				
				int cnt=0;
				
				for(int r=0; r<H; ++r) {
					for(int c=0; c<W; ++c) {
						if(j&(1<<r) || i&(1<<c)) continue;
						else if(v[r][c]=='#') ++cnt;
					}
				}
				
				if(cnt==K) ++ans;
			} 
		}
		
		cout<<ans<<"\n";
	}
	
	return 0;
}


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

long long D,N,Dt,X,Y,cnt;

int main() {
	cin>>N;
	cin>>D;
	
	for(int i = 0; i<N; i++){
		cin>>X;
		cin>>Y;
		
		if((X*X + Y*Y) <=(D*D)){
			cnt++;
		}
	}
	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints


if A <= 5
  puts '0'
elsif A <= 12
  puts B / 2
else
  puts B
end


Measured memory_bytes: 14364
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            long x = long.Parse(ReadLine());
            for (long a = -200; a < 200; a++)
            {
                for (long b = -200; b < 200; b++)
                {
                    try
                    {
                        checked
                        {
                            if (a * a * a * a * a - b * b * b * b * b == x)
                            {
                                WriteLine(a + " " + b);
                                return;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 27476
#include <bits/stdc++.h>
using namespace std;
int main(){
	char a[9];
	cin>>a;
	if((a[0]==89) && (a[1]==65) && (a[2]==75) && (a[3]==73))
		cout<<"Yes";		    
	else
		cout<<"No";
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

//素因数分解をしたvecotrを返す。pair<素因数,その素因数の何乗か>  sizeは、素因数の個数
vector<pair<ll,ll>> factorize(ll n){
	vector<pair<ll,ll>> res;
	for( ll i = 2; i*i <= n; ++i){
		if(n%i) continue ; 
		res.emplace_back(i,0);
		while(n%i == 0){
			n /= i ;
			res.back().second++;
		}
	}
	if ( n != 1) res.emplace_back(n,1);
	return res;
}
int main()
{
	cout <<setprecision(10);
	ll a, b;
	cin >> a >> b;
	vector<pair<ll,ll>> fact_a = factorize(a);
	vector<pair<ll,ll>> fact_b = factorize(b);

	ll count = 0;
	ll k = fact_a.size();
	ll m = fact_b.size();
	for(ll i = 0 ; i < k ; i++){
		for(ll j = 0 ; j < m ; j ++){
			if(fact_a[i].first == fact_b[j].first){
				count ++;
			}
		}
	}
	if(count == 0) cout << 1 << endl;
	else{
		cout << count+1  << endl;
	}

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

// xのn乗をmodで割った余りをO(log n)で計算
int64_t ModPow(int64_t x, uint64_t n, int64_t mod) {
  if (n == 0) return 1;
  return (n & 1) == 0 ? ModPow(x * x % mod, n / 2, mod) : x * ModPow(x, n - 1, mod) % mod;
}

/**
 * @brief  組み合わせを高速に計算するためのクラス
 * @note   上限となるNをコンストラクタに与える．組み合わせはget()で得られる．
 * @retval None
 */
class comb {  // n C k (n <= N)までなら求められる．
  const uint64_t mod;
  std::vector<uint64_t> factorial;

 public:
  comb(size_t N, uint64_t m);                          // コンストラクタ
  uint64_t get(uint64_t n, uint64_t k);                // n C k を計算する
  uint64_t fact(size_t n) { return factorial.at(n); }  // n!を返す
};
comb::comb(size_t N, uint64_t m) : factorial(N + 1, 0), mod(m) {
  factorial[0] = 1;
  for (int i = 1; i <= N; i++) {
    factorial[i] = factorial[i - 1] * i % mod;
  }
}
uint64_t comb::get(uint64_t n, uint64_t k) {
  auto numerator = factorial[n];
  auto denominator = (factorial[k] * factorial[n - k]) % mod;
  return numerator * ModPow(denominator, mod - 2, mod) % mod;
}

int main() {
  constexpr int64_t mod = 1e9 + 7;
  int64_t N, K;
  cin >> N >> K;
  comb c(2001, mod);
  for (int i = 1; i <= K; i++) {
    int64_t ans = 0;
    if (N - K + 2 - 1 >= i) {
      ans = c.get(K - 1, i - 1) * c.get(N - K + 2 - 1, i) % mod;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define long ll
#define all(x) begin(x), end(x)
using namespace std;
 
mt19937 rnd;
 
const long SQRT  = 110000;
const long CBRT  = 2200;
const long MAXN = 1e10;
bool prime[SQRT];
vector<long> primes;
vector<long> squares;
long answer = 0;

long up(long a, long b) {
	assert(a >= 0 && b > 0);
	return (a + b - 1) / b;
}

pair<long, long> func(long x) {
	assert(x > 0);
	long a = 1, b = 1;
	for (long d : primes) {
		if (d * d * d > x) {
			break;
		}
		long cnt = 0;
		while (x % d == 0) {
			x /= d;
			++cnt;
		}
		cnt %= 3;
		
		if (cnt == 1) {
			if (a > up(MAXN, d) || b > up(MAXN, d * d)) {
				++answer;
				return {0, 0};
			}
			a *= d;
			b *= d * d;
		} else if (cnt == 2) {
			if (a > up(MAXN, d * d) || b > up(MAXN, d)) {
				++answer;
				return {0, 0};
			}
			a *= d * d;
			b *= d;
		}
		if (max(a, b) > MAXN) {
			++answer;
			return {0, 0};
		}
	}
	if (!binary_search(all(squares), x)) {
		if (a > up(MAXN, x) || b > up(MAXN, x * x)) {
			++answer;
			return {0, 0};
		}
		a *= x;
		b *= x * x;
	} else {
		if (a > up(MAXN, x) || b > up(MAXN, sqrt(x))) {
			++answer;
			return {0, 0};
		}
		a *= x;
		b *= sqrt(x);
	}
	if (max(a, b) > MAXN) {
		++answer;
		return {0, 0};
	}
	assert(1 <= a && 1 <= b);
	assert(a <= MAXN && b <= MAXN);
	return {a, b};
}
 
 
map<long, long> a, b;
 
int main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	fill(prime + 2, prime + SQRT, true);
	for (long i = 2; i < SQRT; ++i) {
		if (prime[i]) {
			primes.push_back(i);
			squares.push_back(long(i) * i);
		}
		for (long j = 2 * i; j < SQRT; j += i) {
			prime[j] = false;
		}
	}
	long n;
	cin >> n;
	while (n--) {
		long x;
		cin >> x;
		long aa, bb;
		tie(aa, bb) = func(x);
		if (aa == 0) {
			continue;
		}
		if (aa < bb) {
			++a[aa];
		} else {
			++b[bb];
			a[bb];
		}
	}
	for (auto e : a) {
		long x = e.first;
		if (x > 1) {
			answer += max(a[x], b[x]);
		} else {
			answer += a[x] > 0 || b[x] > 0;
		}
	}
	cout << answer << "\n";
	cerr << 1000 * clock() / CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,d;double rs;
  cin>>n>>d;
  int x= (2*d)+1;
  if(x>n)
    rs=1;
  else
  rs=ceil(n/(double)x);
  
  cout<<rs;
}
  
  
  

  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define out(a,n) REP(i,n) cout << a[i] << " "; cout << endl;
using namespace std;

int main(){
  ll x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<ll> p(a),q(b),r(c);
  REP(i,a) cin>>p[i];
  REP(i,b) cin>>q[i];
  REP(i,c) cin>>r[i];
  sort(p.begin(),p.end(),greater<>());
  sort(q.begin(),q.end(),greater<>());
  sort(r.begin(),r.end(),greater<>());
  
  if(x != a) p.erase(p.begin()+x,p.end());
  if(y != b) q.erase(q.begin()+y,q.end());
  p.insert(p.end(),q.begin(),q.end());
  p.insert(p.end(),r.begin(),r.end());
  //out(p,p.size());
  sort(p.begin(),p.end(),greater<>());
  ll ans = 0;
  REP(i,x+y) ans += p[i];
  cout<<ans;
}

Measured memory_bytes: 5872
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
	return a * b / my_gcd(a, b);	
}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong N, M;
    string S, T;
    cin >> N >> M >> S >> T;

    llong L = my_lcm(N, M), G = my_gcd(N, M);
    N /= G;
    M /= G;
    for (int k = 0; k < G; ++k) {
        if (S[k * N] != T[k * M]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << L << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
set_ans = {n}
for x in range(2, int(n ** 0.5) + 1):
    if n % x == 0:
        tmp = n
        while tmp % x == 0:
            tmp //= x
        if tmp % x == 1:
            set_ans.add(x)
for x in range(1, int((n-1) ** 0.5) + 1):
    if (n - 1) % x == 0:
        if x > 1:
            set_ans.add(x)
        if (n - 1) // x != x:
            set_ans.add((n - 1) // x)
print(len(set_ans))

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    //final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if(a >= 13){
        System.out.println(b);
    }else if(6 <= a && a<= 12){
        System.out.println(b/2);
    }else{
        System.out.println(0);
    }



    



   
    





}
}

Measured memory_bytes: 35644
loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  points = 3.times.map{ [] }
  k.times do
    c, a, b = gets.split
    a = a.to_i; b = b.to_i
    case c
    when 'yz'
      points[0] << [0, a, b]
    when 'xz'
      points[1] << [a, 0, b]
    when 'xy'
      points[2] << [a, b, 0]
    end
  end
  ans = n * n * n - k * n
  cross = []
  points.combination(2) do |ps1, ps2|
    ps1.each do |a|
      ps2.each do |b|
        if a.zip(b).any?{ |p, q| p == q }
          cross << a.zip(b).map{ |p, q| [p, q].max}
          ans += 1
        end
      end
    end
  end
  puts ans - cross.uniq.count{ |c| cross.count(c) >= 2 }
end

Measured memory_bytes: 8688
#include <iostream>

using namespace std;

int main(void){

  int N, K;
  int p[1000];
  int m;
  int sum = 0;

  cin >> N >> K;

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

  for(int i=0; i<N-1; i++){
    for(int j=0; j<N-1; j++){
      m = p[j];
      if(p[j+1]<m){
        p[j] = p[j+1];
        p[j+1] = m;
      }
    }
  }

//  for(int i=0; i<N; i++) cout << p[i];
//  cout << endl;
  for(int i=0; i<K; i++) sum+=p[i];

  cout << sum << endl;

  return 0;
}


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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n, k;
	cin >> n >> k;
	
	vcL num(n);
	for (auto &x : num) cin >> x;
	
	vcL dp(n, 0);
	for (int i = 1; i < n; ++i) {
		dp[i] = I_MAX;
		for (int j = 1; i-j >= 0 and j <= k; ++j) {
			dp[i] = min(dp[i], dp[i - j] + abs(num[i] - num[i - j]));
		}
	}
	
	cout << dp[n - 1] << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}




Measured memory_bytes: 4992
s = input()

cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3060
n = int(input())

edge = [[] for _ in range(n)]

for _ in range(n-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

visited = [0] * n
visited[0] = 1
ans = [0] * n
stack = [0]

while stack:
    v = stack.pop()
    for next, distance in edge[v]:
        if visited[next]: continue
        ans[next] = (ans[v] + distance) % 2
        visited[next] = 1
        stack.append(next)

print(*ans, sep="\n")

Measured memory_bytes: 41136
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		
		long arr[] = new long[100001];
		Arrays.fill(arr,0);
		
		for(long i=1; i<N+1; i++){
			int a = sc.nextInt();
			long b = sc.nextLong();
			arr[a]= arr[a]+b;
		}
		
		for(int i=1; i<100001; i++){
			if(K<=arr[i]){
				System.out.println(i);
				break;
			}
			else K=K-arr[i];
		}

	}
}

Measured memory_bytes: 85764
/**
 *      ABC 78 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-03 02:00:34
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    char X, Y; cin >> X >> Y;
    if (X > Y){
        cout << '>' << endl;
    }
    else if (X < Y){
        cout << '<' << endl;
    }
    else {
        cout << '=' << endl;
    }
    return 0;
}


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

using namespace std;

int main(){

  int n;
  cin>>n;

  vector<long long> a(n);

  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }

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

  long long c2 = a.at(n-1)/2;
  long long c = a.at(n-1);

long long min = 99999999999;
long long r = 0;
  for(int i=0;i<(n-1);i++){
    if(min>=abs(c2-a.at(i))){
      r = a.at(i);
      min=abs(c2-a.at(i));
    }
  }

  cout<<c<<' '<<r;


}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int x1, x2, x4, x5, tmp, count = 0;
  for (int i=A; i<=B; i++) {
    tmp = i;
    x5 = tmp % 10; tmp /= 10;
    x4 = tmp % 10; tmp /= 100;
    x2 = tmp % 10; tmp /= 10;
    x1 = tmp % 10;
    
    if ((x1 == x5) && (x2 == x4)) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1 << 30;
ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}
int main() {
	int S;
	cin >> S;
	int l = 1, r = 1;
	ll sum = 1;
	ll nxtL = 10, nxtR = 10, dL = 1, dR = 1;
	ll ans = 0;
	while (l < 1e8) {
		while (sum < S) {
			r++;
			if (r == nxtR) dR++, nxtR *= 10;
			sum += dR;
		}
		if (sum == S) ans++;
		sum -= dL;
		l++;
		if (l == nxtL) dL++, nxtL *= 10;
	}
	for (int len = 1; len <= S; len++) {
		int k = S / len;
		if (k <= 8) break;
		if (S%len == 0) {
			(ans += 9 * mod_pow(10, k - 1) - len + 1 + MOD) %= MOD;
		}
		else {
			(ans += 1) %= MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
<?php

$d = trim(fgets(STDIN));

if (strpos($d, 'RRR') !== false) {
    echo 3;
    exit;
} elseif (strpos($d, 'RR') !== false) {
    echo 2;
    exit;
} elseif (strpos($d, 'R') !== false) {
    echo 1;
    exit;
} else {
    echo 0;
}

Measured memory_bytes: 16124
#include "bits/stdc++.h"
#define ll long long
using namespace std;
int main(){
ll L,R;
cin>>L>>R;

ll rangeN  =  R/2019 - L/2019;

if(rangeN>=1){
cout<<0<<endl;
return 0;
}

ll min=3000;

for(ll i=L;i<R;i++){
  for(ll j=i+1;j<R+1;j++){
      if(((i*j)%2019)<min)
      min =(i*j)%2019;
  }
}

cout<<min<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main() {
    int h, w;
    
    cin >> h >> w;
    for(int j = 0 ; j < w + 2 ; j++) cout << "#" ;
    cout << endl;
    for(int i = 0 ; i < h ; i++){
        string s;
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    for(int j = 0 ; j < w + 2 ; j++) cout << "#";
    cout << endl;
}



Measured memory_bytes: 256
n, k = map(int,input().split())
ans = 0
a = 0

def need(x, y): # xを何乗したらy以上になるか
  for i in range(30):
    if x*(2**i) >= y:
      return i

for i in range(n):
  ned = need(i+1, k)
  for j in range(ned):
    a += (1/2)**(j+1)
  ans = 1 / n * a
  
print(1-ans)

Measured memory_bytes: 3060
#include <iostream>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define YES(i) cout<<(i?"YES":"NO")<<endl
using namespace std;
int main(void){
    int n,m; cin>>n>>m;
    int v[100001]={};
    FOR(i,0,m*2){
        int a; cin>>a;
        v[a]++;
    }
    bool fl=true;
    FOR(i,0,100001){
        if(v[i]%2!=0) fl=false;
    }
    YES(fl);
}


Measured memory_bytes: 640
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger

readString = map BS.unpack . BS.words

getInt = readInt <$> BS.getLine

getString = readString <$> BS.getLine

calc :: String -> Int
calc [] = 0
calc [c'] = 0
calc s
  | c' == c'' = 1 + calc s''
  | otherwise = calc s'
  where
    c' = head s
    s' = tail s
    c'' = head s'
    s'' = tail s'

main = do
  [s] <- getString
  k <- getInt
  if all (== head s) s
    then print $ (length s) * k `div` 2
    else do
      if last s /= head s
        then print $ (calc s) * k
        else do
          let d1 = calc s
          let d2 = calc (s ++ s)
          let diff = d2 - d1
          print $ d1 + (k - 1) * diff


Measured memory_bytes: 3728
def isRTri(a, b, c):
    return a * a + b * b == c * c

a = [0, 0, 0]
n = input()
for k in range(n):
    a = map(int, raw_input().split())
    a.sort()
    r = isRTri(a[0], a[1], a[2])
    print "YES" if r else "NO"

Measured memory_bytes: 6268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = (s.size() - 1) / 2;
	string t = s;
	reverse(all(s));
	string s1 = s.substr(0, n);
	string s2 = s.substr(n + 1);
	if (s == t && s1 == s2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N=1e5+5;
int n,a[N],cnt[N],cnt2=0;
signed main() {
	#ifdef aome
	in("aome.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n;
	memset(cnt,0,sizeof(cnt));
	fw (i,0,n) cin>>a[i], cnt[a[i]]++;
	//If a type of card exceeds 3, we can always remove 2 of its kind. So after a few operations
	//every type can go down to 1 or 2.
	//Consider all types with 2 cards. If there are an even number of them, we can all reduce
	//them to just 1. Else, the last one requires another removal involving another card.
	fw (i,1,N) if (cnt[i]) {
		cnt[i]=cnt[i]%2;
		if (!cnt[i]) cnt[i]=2, cnt2++;
	}
	int active=0;
	fw (i,1,N) {
		if (cnt[i]) active++;
	}
	if (cnt2%2==0) cout<<active;
	else cout<<active-1;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
const int N=2e5+1;
int n, max[N], c[N];
std::vector<int> e[N];
std::unordered_map<int, int> hash[N];
int q(int u, int fa, int x) {
	int res=0;
	auto it=hash[u].find(x);
	if(it!=hash[u].end()) return it->second;
	for(int v: e[u]) if(v!=fa&&v<=x) res+=q(v, u, x)+1;
	hash[u].emplace(x, res);
	return res;
}
void dfs(int u, int fa) {
	max[u]=std::max(fa, max[fa]);
	for(int v: e[u]) if(v!=fa) dfs(v, u);
	c[u]=q(u, fa, max[u])+(u>max[fa]?1:-q(u, fa, max[fa]));
}
void sum(int u, int fa) {
	c[u]+=c[fa];
	for(int v: e[u]) if(v!=fa) sum(v, u);
}
int main() {
	assert(scanf("%d", &n)==1);
	for(int i=1; i<n; ++i) {
		int a, b;
		assert(scanf("%d%d", &a, &b)==2);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	dfs(1, 0);
	sum(1, 0);
	for(int i=2; i<=n; ++i) printf("%d%c", c[i]-1, " \n"[i==n]);
	return 0;
}


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

int main() {
 int N; scanf("%d",&N);
 int L[100]; rep(i,N) scanf("%d",&L[i]);
 sort(L,L+N);
 int ans=0;
 for(int i=0; i<N; i++){
  for(int j=i+1; j<N; j++){
   for(int k=j+1; k<N; k++){
    if(L[i]==L[j]) continue;
    if(L[j]==L[k]) continue;
    if(L[i]+L[j]<=L[k]) continue;
    ans += 1;
 }}}

 cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (ll (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pp printf("Case %d: \n",t)
const unsigned int mod = 1e9+7;
const int mx=10000005;
const int maxInt = 2147483647;
ll a[105][2],n,m,dp[10000005];
ll maxx=0;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n >> m;
    rep(i,n){
    	cin >> a[i][0] >> a[i][1];
    }
    rep(i,mx)dp[i]=-(INF);
    dp[0]=0;
    for(int i=0;i<n;++i){
    	for(int j=m;j>=0;--j){
    		dp[j+a[i][0]]=max(dp[j+a[i][0]],a[i][1]+dp[j]);
    	}
    }
    ll ans=0;
    rep(i,m+1)ans=max(ans,dp[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define M 200006
#define ll long long int
using namespace std;
int c[M][66];
int n,goal=1,t;
ll m;
void bz(){
	int len=log(m)/log(2)+1;
	for(int i=1;i<=len;++i)
	for(int j=1;j<=n;++j)
	{
		c[j][i]=c[c[j][i-1]][i-1];
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		cin>>c[i][0];
	}
	bz();
	while(m){
		if(m&1){
			goal=c[goal][t];
		}
		m/=2;
		++t;
	}
	cout<<goal;
}

Measured memory_bytes: 55400
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans


'''
p = 10 ** 9 + 7
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
'''


#a = list(map(int, input().split()))


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

gr = [i for i in range(n)]
es = []

for i in range(m):
    y,z = list(map(int, input().split()))
    es.append([min(y-1,z-1),max(y-1,z-1)])

es.sort(key=lambda x:x[0])
#print(es)

neigh = [[] for i in range(n)]
blocks = [[] for i in range(n)]

for i in range(m):
    neigh[es[i][0]].append(es[i][1])
    neigh[es[i][1]].append(es[i][0])

    
    
#print(neigh)


checked = [0 for i in range(n)]
nums = [1 for i in range(n)]

for i in range(n):
    if(checked[i]!=0):
        continue
    else:
        queue = [i]
        seen = [i]
        now=0
        checked[i]=1
        while(True):
            if(len(queue)==now):
                for j in range(len(seen)):
                    checked[seen[j]] = i
                    nums[seen[j]] = len(seen)
                break
            seeing = queue[now]
            
            now+=1
            for j in range(len(neigh[seeing])):
                if(checked[neigh[seeing][j]]==0):
                    queue.append(neigh[seeing][j])
                    checked[neigh[seeing][j]]=1
                    seen.append(neigh[seeing][j])


#print()
#print(checked)
#print(nums)

for i in range(k):
    y,z = list(map(int, input().split()))
    if(checked[y-1]==checked[z-1]):
        blocks[y-1].append(z-1)
        blocks[z-1].append(y-1)

ans = []
for i in range(n):
    ans.append( nums[i] - len(blocks[i]) - len(neigh[i]) - 1 )
print(' '.join(map(str,ans)))


Measured memory_bytes: 128744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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

  cout << (a+b+c+d==21 && a*b*c*d==252?"YES":"NO") <<endl;
  
}

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

using namespace std;

const int MAX_N = 3005;
const int MAX_BN = 200005;
const int MOD = 1000000007;

typedef long long ll;

int h,w,n,dp[MAX_N];
ll fac[MAX_BN],faci[MAX_BN];
struct p {
	int r,c;
} b[MAX_N];

ll fpow(ll a, ll b)
{
	ll r=1;
	for (;b;b/=2,a=(a*a)%MOD)
		if (b&1)
			r=(r*a)%MOD;
	return r;
}

int bnk(int n, int k)
{
	return (((fac[n]*faci[k])%MOD)*faci[n-k])%MOD;
}

int main()
{
	fac[0]=faci[0]=1;
	for (int i=1; i<MAX_BN; i++)
	{
		fac[i]=(fac[i-1]*i)%MOD;
		faci[i]=fpow(fac[i],MOD-2);
	}
	scanf("%d %d %d",&h,&w,&n);
	for (int i=1; i<=n; i++)
		scanf("%d %d",&b[i].r,&b[i].c);
	sort(b+1,b+1+n,[](const p &a, const p &b) {
		if (a.r==b.r)
			return a.c<b.c;
		return a.r<b.r;
	});
	n++;
	b[n].r=h,b[n].c=w;
	for (int i=1; i<=n; i++)
		dp[i]=bnk(b[i].r+b[i].c-2,b[i].r-1);
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++)
			if (b[i].r<=b[j].r&&b[i].c<=b[j].c)
				dp[j]=(dp[j]-
					((dp[i]*1LL*bnk(b[j].r-b[i].r+b[j].c-b[i].c,
						b[j].r-b[i].r))%MOD)+MOD)%MOD;
	printf("%d\n",dp[n]);
	return 0;
}


Measured memory_bytes: 3328
n,a,b = map(int,input().split())
def place_of_1(num):
    return num%10

def place_of_10(num):
    return (num%100 - num%10)/10

def place_of_100(num):
    return (num%1000 - num%100)/100

def place_of_1000(num):
    return (num%10000 - num%1000)/1000

def place_of_10000(num):
    return (num%100000 - num%10000)/10000

ans = 0
Sum = 0 
for i in range(n+1):
    Sum = place_of_1(i)+place_of_10(i)+place_of_100(i)+place_of_1000(i)+place_of_10000(i)
    if a <= Sum <= b:
        ans += i
    Sum = 0

print(ans)

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

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node*)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

Node* search(int key) {
    Node* cur = nil->next;
    while(cur != nil && cur->key != key) {
        cur = cur->next;
    }
    
    return cur;
}

// insert
void insert(int key) {
    Node *n = (Node*)malloc(sizeof(Node));
    n->key = key;
    n->next = nil->next;
    nil->next->prev = n;
    nil->next = n;
    n->prev = nil;
}

// delete common logic
void deleteNode(Node *n) {
    Node *prev = n->prev;
    Node *next = n->next;
    prev->next = next;
    next->prev = prev;
    free(n);
}

// delete
void deleteByKey(int key) {
    Node *cur = search(key);
    
    if (cur != nil) {
        deleteNode(cur);
    }
}

// deleteFirst
void deleteFirst() {
    deleteNode(nil->next);
}
// deleteLast
void deleteLast() {
    deleteNode(nil->prev);
}

int main() {
    init();
    int n;
    scanf("%d", &n);
    
    char com[30];
    int key = 0;
    for(int i = 0; i < n; i++) {
        scanf("%s", com);

        if (strcmp(com, "deleteFirst") == 0) {
            deleteFirst();
            continue;
        } else if (strcmp(com, "deleteLast") == 0) {
            deleteLast();
            continue;
        } else if (strcmp(com, "delete") == 0) {
            scanf("%d", &key);
            deleteByKey(key);
            continue;
        } else if (strcmp(com, "insert") == 0) {
            scanf("%d", &key);
            insert(key);
            continue;
        }
    }
    
    Node *cur = nil->next;
    while(cur != nil) {
        if (cur->prev != nil) cout << " ";
        cout << cur->key;
        cur = cur->next;
    }
    
    cout << endl;
    
    return 0;
}




Measured memory_bytes: 34380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,ans=0;
  float Asum=0.0;
  cin>>N>>M;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    Asum+=A.at(i);
  }

  for(int i=0;i<N;i++){
    if(A.at(i)>=Asum/M/4)ans++;
    //cout<<A.at(i)<<" "<<Asum/M/4<<endl;
  }
  
  //cout<<ans<<endl;
  
  if(ans>=M)cout<<"Yes";
  else cout<<"No";
  
}

Measured memory_bytes: 3628
N = int(input())

if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(N - 90)
elif N < 10000:
    print(909)
elif N < 100000:
    print(N - 90 - 9000)
else:
    print(90909)

Measured memory_bytes: 2940
#include<iostream>
#define ll long long
using namespace std;
double pi= 3.14159265358979323846;
int main(){
	double R;
	cin>>R;
	printf("%.20lf\n",2*pi*R);
	return 0;
} 
//458.67252742410977361942
//458.67252742410977361942

//6.28318530717958623200
//6.28318530717958623200

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
bool cmp (pair<int, int>a, pair<int, int>b) {
  if (a.second < b.second) return true;
  if (a.second > b.second) return false;
  if (a.first < b.first) return true;
  return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> qry(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    qry[i] = {a, b};
  }
  sort(qry.begin(), qry.end(), cmp);
  int ret = 0;
  int prv = 0;
  for (int i = 0; i < m; i++) {
    int a, b;
    tie(a, b) = qry[i];
    if (a > prv) {
      prv = b - 1;
      ret++;
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int A,B,C,D,k;

inline bool check(int mid)
{
	int a=A-mid/(k+1)*k-mid%(k+1);
	int b=B-mid/(k+1);
	return b<=1LL*a*k;
}

int main()
{
	int T;
  scanf("%d",&T);
	while (T--)
	{
    scanf("%d%d%d%d",&A,&B,&C,&D);
		k=max(ceil(1.0*A/(B+1)),ceil(1.0*B/(A+1)));
		int left=0,right=A+B+1;
		while (left<right)
		{
			int mid=(left+right)>>1;
			if (check(mid)) left=mid+1;
			else right=mid;
		}
		int a=A-left/(k+1)*k-left%(k+1);
		int b=B-left/(k+1);
		right=left+b-a*k+1;
		for (int i=C;i<=min(D,left);i++)
		{
			if (i%(k+1)) cout << 'A';
			else cout << 'B';
		}
		for (int i=max(C,left+1);i<=D;i++)
		{
			if ((i-right)%(k+1)) cout << 'B';
			else cout << 'A';
		}
		puts("");
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int t;
    cin >> t;
    vector<int> N(t), D(t);
    rep(i, 0, t){
        cin >> N[i] >> D[i];
        int tmp = 127 - D[i];
        int ans = 127 * (N[i] - 1);
        if(N[i] % 2 == 0) ans += tmp;
        else ans += D[i];
        cout << ans << endl;
    }
}

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

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

  if (a > b) {
    cout << 0 << endl;
    return 0;
  }

  if (n == 1) {
    if (a != b) {
      cout << 0 << endl;
      return 0;
    } else {
      cout << 1 << endl;
      return 0;
    }
  }

  cout << (n-2) * (b-a) + 1 << endl;
  return 0;
}

Measured memory_bytes: 3592
// https://atcoder.jp/contests/abc156/tasks/abc156_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

ll div_ceil(ll a, ll b) { return (a + b - 1) / b; }

void solve() {
  ll K, Q;
  cin >> K >> Q;

  VL ds(K);
  rep(i, K) cin >> ds[i];

  auto query = [&](ll n, ll x, ll m) -> ll {
    ll last = x;
    ll zero_ct = 0;

    rep(i, K) {
      // 要素が N -> ds で足されるのは先頭 N-1 個
      ll added_count = div_ceil(n - 1 - i, K);
      last += (ds[i] % m) * added_count;

      if (ds[i] % m == 0) zero_ct += added_count;
    }

    // 商が増えた数 = あまりが減った数
    ll less_ct = last / m - x / m;

    return n - 1 - less_ct - zero_ct;
  };

  rep(i, Q) {
    ll n, x, m;
    cin >> n >> x >> m;
    cout << query(n, x, m) << endl;
  }
}

void solve2() {
  ll K, Q;
  cin >> K >> Q;

  VL ds(K);
  rep(i, K) cin >> ds[i];

  auto query = [&](ll n, ll x, ll m) -> ll {
    ll last = 0;
    ll zero_ct = 0;

    rep(i, K) {
      last += ds[i] % m;
      if (ds[i] % m == 0) zero_ct++;
    }

    // 要素が N -> ds で足されるのは先頭 N-1 個

    last *= (n - 1) / K;
    zero_ct *= (n - 1) / K;

    rep(i, (n - 1) % K) {
      last += ds[i] % m;
      if (ds[i] % m == 0) zero_ct++;
    }

    last += x;

    // 商が増えた数 = あまりが減った数
    ll less_ct = last / m - x / m;

    return n - 1 - less_ct - zero_ct;
  };

  rep(i, Q) {
    ll n, x, m;
    cin >> n >> x >> m;
    cout << query(n, x, m) << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct O{int p, c;};
int main()
{
	int n, r;
	while(cin >> n >> r && (n || r))
	{
		stack<O> order;
		rep(i, r)
		{
			O o;
			cin >> o.p >> o.c;
			order.push(o);
		}

		int res = 1;

		for(; !order.empty(); order.pop())
		{
			O o = order.top();

			if(res <= o.c)
				res += o.p - 1;
			else if(res <= o.c + o.p - 1)
				res -= o.c;
		}

		cout << n - res + 1 << endl;
	}
}

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

using namespace std;

int main(void)
{
    string s, t, td;
    int n;

    cin >> s;
    cin >> t;

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

    sort(t.begin(), t.end());
    
    reverse(t.begin(), t.end());

    n = t.size();

    if(s<t){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	string s[n];
	int p[n];
	int a[n];
	REP(i, n) cin >> s[i] >> p[i];
	REP(i, n){
		int ans = 0;
		REP(j, n){
			if (i == j) continue;
			if (s[i] == s[j]){
				if (p[i] < p[j]) ans++;
			}
			else if (s[i] > s[j]) ans++;
		}

		a[ans] = i + 1;
	}

	REP(i, n) cout << a[i] << endl;

}


Measured memory_bytes: 256
from functools import lru_cache
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353

div = pow(2, MOD-2, MOD)

DP = [0] * (S+1)
DP[0] = pow(2, N, MOD)
for a in A:
	for i in range(S-a, -1, -1):
		if DP[i] == 0: continue
		DP[i+a] = (DP[i+a] + DP[i] * div) % MOD

print(DP[S])


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

using ll = long long;

int main() {
    int n;
    cin >> n;
    cout << n << ":";
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            cout << " " << i;
            n /= i;
        }
    }
    if (n != 1) cout << " " << n;
    cout << "\n";
}


Measured memory_bytes: 3080