akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class31
    {
        static void Main()
        {
            //a97 Z90
            string S = Console.ReadLine();
            string part = S.Substring(2,S.Length-3);

            if (S[0] == 'A')
            {
                if (part.Count(x => x == 'C') == 1)
                {
                    for(int i = 1; i < S.Length; i++)
                    {
                        if (S[i] != 'C' & (int)S[i] <= 90)
                        {
                            Console.WriteLine("WA");
                            return;
                        }
                    }
                    Console.WriteLine("AC");
                    return;
                }
            }
            Console.WriteLine("WA");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++)

const int inf = 2e8;

int n, m, r;
int d1[205][205], d2[205][205];
int path[1005], dp[1005][205];

void init(int p[][205]) {
    inc(i, 1, n) inc(j, 1, n) p[i][j] = inf;
    inc(i, 1, n) p[i][i] = 0;
}

void floyd(int p[][205]) {
    inc(k, 1, n) inc(i, 1, n) inc(j, 1, n) p[i][j] =
        min(p[i][j], p[i][k] + p[k][j]);
}

int x, y, z;
char c;

int main() {
    while (scanf("%d %d", &n, &m) != EOF && n) {
        init(d1), init(d2);
        inc(i, 1, m) {
            scanf("%d %d %d %c", &x, &y, &z, &c);
            if (c == 'L')
                d1[x][y] = d1[y][x] = min(d1[x][y], z);
            else
                d2[x][y] = d2[y][x] = min(d2[x][y], z);
        }
        floyd(d1), floyd(d2);

        scanf("%d", &r);
        inc(i, 1, r) scanf("%d", &path[i]);

        inc(i, 1, n) dp[1][i] = inf;
        dp[1][path[1]] = 0;

        inc(i, 2, r) {
            inc(j, 1, n) {
                dp[i][j] = inf;
                inc(k, 1, n) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][k] + d1[path[i - 1]][k] +
                                                 d2[k][j] + d1[j][path[i]]);
                    if (k == j)
                        dp[i][j] = min(dp[i][j],
                                       dp[i - 1][k] + d1[path[i - 1]][path[i]]);
                }
            }
        }

        int res = inf;
        inc(i, 1, n) res = min(res, dp[r][i]);
        printf("%d\n", res);
    }
}


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

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

    vector<int> c(n), t(n);
    for(int i = 0; i < n; i++) cin >> c[i] >> t[i];

    int ans = -1;
    int mincost = 10000;
    for(int i = 0; i < n; i++){
        if(t[i] <= tlim && c[i] < mincost){
            ans = i;
            mincost = c[i];
        }
    }

    if(ans == -1) cout << "TLE" << endl;
    else cout << mincost << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

#define INF 2000000

int main(){
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A.at(i);

  int min_K=INF;
  int temp;
  for(int i=0;i<N;i++){
    //c
    int e=(i+N-1)%N;
    temp=(A.at(e)+K-A.at(i))%K;
    //cc
    e=(i+1)%N;
    temp=min(temp,(A.at(i)+K-A.at(e))%K);
    min_K=min(min_K,temp);
  }

  cout << min_K << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 50;
int A[MAXN];
int N, Q;
string S;
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> Q;
    cin >> S;
    vector<int> vec;
    for (int i=1; i<=N-1; i++){
        if (S[i-1] == 'A' && S[i] == 'C'){
            vec.push_back(i);
        }
    }
    for (int i=0; i<Q; i++){
        int l, r; cin >> l >> r;
        int ans = lower_bound(vec.begin(), vec.end(), r) - lower_bound(vec.begin(), vec.end(), l);
        cout << ans << "\n";
    }
}


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

using namespace std;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()

const int INF = 1000000000;

int main(){
    int K, S;

    cin >> K >> S;

    int count = 0;

    rep (i, K+1) {
        rep (j, K+1) {
            int sum = S - i - j;
            if (sum >= 0 && sum <= K) count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
    int m, d;
    cin >> m >> d;
    int count = 0;
    for(int i=2; i<=m; i++){
        for(int j=10; j<=d; j++){
            int d1 = j % 10;
            int d2 = j / 10;
            if( d1 < 2 || d2 < 2) continue;
            if(d1 * d2 == i){
//            cout << j << ":" << d1 << " " << d2 << endl;

                count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n;
    cin >> n;
    ll cnt2 = 0, cnt4 = 0;

    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
        if (a[i] % 2 == 0) cnt2++;
        if (a[i] % 4 == 0) cnt4++;
    }

    if (cnt2 == cnt4) {
        if (n-cnt2 <= cnt4+1) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if (n-cnt2 <= cnt4) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

signed main(){
  lint N, K; cin >> N >> K;
  string s; cin >> s;
  vector<lint> data;
  if(s[0] == '0') data.push_back(0);
  lint num = 1;
  for(int i = 0; i < s.size();) {
    int j = i;
    while (j < s.size() && s[j] == s[i]) ++j; 
    data.push_back(j - i);
    i = j;
  }
  if(s.back() == '0') data.push_back(0);
  lint ans1 = 0, ans;
  for(lint i = 0; i < 2 * K + 1 && i < data.size(); i++){
    ans1 += data[i];
  }
  ans = ans1;
  for(lint i = 2 * K + 2; i < data.size(); i += 2){
     ans1 = ans1 + data[i] + data[i - 1] - data[i - 2 * K - 1] - data[i - 2 * K - 2];
     ans = max(ans, ans1);
  }
  cout << ans << endl;
}


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

int main() {
	int n; cin >> n;
	vector<int>x(n), y(n);
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i];
	
	vector<int>g; for (int i = 0; i < n; i++)g.push_back(i);
	vector<vector<int>>inorder;
	do {
		inorder.push_back(g);
	} while (next_permutation(g.begin(), g.end()));

	double ans = 0;
	for (int i = 0; i < inorder.size(); i++) {
		for (int j = 0; j < n - 1; j++) {
			double xi, yi;
			xi = x[inorder[i][j]] - x[inorder[i][j + 1]];
			yi = y[inorder[i][j]] - y[inorder[i][j + 1]];
			ans += sqrt(xi * xi + yi * yi);
		}
	}
	printf("%.10f", ans/inorder.size());

	return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#define ll long long

using namespace std;


int main(void){
    ll a[3][3];
    ll b[3][3];
    bool c = false;
    for(ll i = 0; i < 3; i++){
        for(ll j = 0; j < 3; j++){
            cin >> a[i][j];
            b[i][j] = 0;
        }
    }
    ll n;
    cin >> n;
    ll check[n];
    for(ll i = 0; i < n; i++)
        cin >> check[i];
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < 3; j++){
            for(ll k = 0; k < 3; k++){
                if(check[i]==a[j][k])
                    b[j][k] = 1;
            }
        }
    }
    for(ll i = 0; i < 3; i++){
        ll w = 0, h = 0;
        for(ll j = 0; j < 3; j++){
            h+=b[i][j]; w += b[j][i];
        }
        if(h == 3 || w == 3)
            c = true;
    }
    if(b[0][0]+b[1][1]+b[2][2] == 3 || b[0][2]+b[1][1]+b[2][0]==3)
        c = true;
    if(c == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	long H, W;
	cin >> H >> W;

	long h, w;
	cin >> h >> w;

	long ans = h * w + (W - w) * h + (H - h) * w;
	ans = H * W - ans;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <random>
#include <chrono>

using namespace std;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define per(i, a, n) for (int i = n - 1; i >= a; --i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef int64_t i64;
typedef uint64_t ui64;
typedef pair<int, int> pi;

struct custom_hash {
    static ui64 splitmix64(ui64 x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(ui64 x) const {
        static const ui64 FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T, class U>
inline ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
template <class T, class U>
inline istream& operator>>(istream& os, pair<T, U>& p) {
    os >> p.first >> p.second;
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
    if (v.empty())
        return os;
    if (v.begin() != v.end())
        os << v.front();
    for (auto it = ++v.begin(); it != v.end(); ++it)
        os << ' ' << *it;
    return os;
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
    for (auto& i : v)
        is >> i;
    return is;
}

template <class T, size_t N>
inline istream& operator>>(istream& is, array<T, N>& a) {
    for (auto& i : a)
        is >> i;
    return is;
}

inline void Solve(istream& is, ostream& os) {
    ui64 a, b, x;
    is >> a >> b >> x;
    ui64 remainder = a % x;
    ui64 first_divisible = remainder ? a + x - remainder : a;

    if (b < first_divisible) {
        os << 0;
        return;
    }
    ui64 diff = b - first_divisible;
    os << diff / x + 1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << setprecision(20) << fixed;
    Solve(cin, cout);
    return 0;
}


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

int main(){
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    for(int i = 0;i < 2 * N;i++){
        if(i % 2 == 0){
            cout << S.at(i/2);
        }
        else{
            cout << T.at(i/2);
        }
    }
    cout << endl;
}

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

using namespace std;
using ll = long long;

const int MOD = 1000000007;

ll poww(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b & 1) {
		return (a * poww(a, b - 1)) % MOD;
	}
	return poww((a * a) % MOD, b >> 1);
}

int main() {
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<ll> cnt(k + 1);
	ll ans = 0;
	for (int g = k; g > 0; --g) {
		cnt[g] = poww(k / g, n);
		for (ll j = 2; g * j <= k; ++j) {
			cnt[g] -= cnt[g * j];
			if (cnt[g] < 0) {
				cnt[g] += MOD;
			}
		}
		ans += g * cnt[g];
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3964
n,k = map(int,input().split())
t = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if abs(t[i] - t[i+1]) < k:
    ans += abs(t[i] - t[i+1])
  else:
    ans += k
print(ans+k)

Measured memory_bytes: 104092
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b) cout << c << endl;
	else if(a == c) cout << b << endl;
	else cout << a << endl;
	return 0;
}

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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=1e5+10, M=(ll)1e9+1 ;
const int mod = 1e9+7 ;
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
// vl ed[N],g[N],in(N),vis(N,0),cost(N,0);
vl g[N],vis(N,0);

priority_queue<ll,vl,greater<ll>> pq;


int main(){
 ios_base::sync_with_stdio(0);
  ll n,i,j,k;
  cin >> n >> k;
  vector<unsigned long long int> a(n);
  for(i=0;i<n;i++)
    cin >> a[i];
  ll ans=0,co=0,ce=0;
  ans=0;
  for(i=40;i>=0;i--){
    co=0;
    ce=0;
      for(j=0;j<n;j++){
        // co+=(1ull<<i)&a[j];
         ce+=!((1ull<<i)&a[j]);
      }
      co=n-ce;
      // if(i<=3){
      //     cout << i << " " << co << " " << ce  << endl;
      // }
      if(co<ce ){
        ans|=1ull<<i;
        if(ans>k)
          ans^=(1ull<<i);
        // cout << (1<<i) << endl;
      }
  }
  // cout << ans;
  unsigned long long int re=0;
  for(i=0;i<n;i++){
      re+=(a[i]^ans);
  }
  cout << re ;
  return 0;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    int min_num = 0;
    int max_num = 100005;
    for (int i = 0; i < M; ++i) {
        int l, r;
        cin >> l >> r;
        min_num= max(min_num, l);
        max_num = min(max_num, r);
    }
    if (max_num - min_num >= 0){
        cout << max_num - min_num + 1 << endl;
    }else{
        cout << 0 << endl;
    }

}

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


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type Data struct {
	b, c int
}
type DataSlice struct {
	data []*Data
}

func (s DataSlice) Len() int           { return len(s.data) }
func (s DataSlice) Swap(i, j int)      { s.data[i], s.data[j] = s.data[j], s.data[i] }
func (s DataSlice) Less(i, j int) bool { return s.data[i].c > s.data[j].c }

func main() {
	n, m := oneInt(), oneInt()

	dataSlice := &DataSlice{[]*Data{}}

	input := scanNums(n)
	for _, a := range input {
		dataSlice.data = append(dataSlice.data, &Data{1, a})
	}

	for i := 0; i < m; i++ {
		b, c := oneInt(), oneInt()
		dataSlice.data = append(dataSlice.data, &Data{b, c})
	}

	ans := calc(dataSlice, n)

	fmt.Println(ans)

}

func calc(dataSlice *DataSlice, n int) int {

	sort.Sort(dataSlice)

	count := 0
	sum := 0
	for _, d := range dataSlice.data {
		for i := 0; i < d.b; i++ {
			if count == n {
				return sum
			}
			count++
			sum += d.c
		}
	}
	return sum
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 12416
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
double p[15],q[15],l,r,s;
inline double max(R double x,R double y){return x>y?x:y;}
inline double min(R double x,R double y){return x<y?x:y;}
int main(){
	s=1.0/100;
	fp(i,1,6)scanf("%lf",&p[i]),p[i]*=s;
	fp(i,1,6)scanf("%lf",&q[i]),q[i]*=s;
	l=0,r=1,s=1.0/3;
	for(R int T=233;T;--T){
		R double l1=l+(r-l)*s,r1=r-(r-l)*s;
		R double a1=0,a2=0;
		fp(i,1,6){
			a1+=max(l1*p[i],(1-l1)*q[i]);
			a2+=max(r1*p[i],(1-r1)*q[i]);
		}
		a1>a2?l=l1:r=r1;
	}
	R double res=0;
	fp(i,1,6)res+=max(r*p[i],(1-r)*q[i]);
	printf("%.10lf\n",res);
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m,R = LI()
    r = LI()
    for i in range(R):
        r[i] -= 1
    v = [[float("inf")]*n for i in range(n)]
    for i in range(m):
        a,b,c = LI()
        a -= 1
        b -= 1
        v[a][b] = c
        v[b][a] = c
    l = 1<<R
    for k in range(n):
        for i in range(n):
            for j in range(n):
                nv = v[i][k]+v[j][k]
                if nv < v[i][j]:
                    v[i][j] = nv
    dp = [[float("inf")]*R for i in range(l)]
    for i in range(R):
        dp[1<<i][i] = 0
    for b in range(l):
        for i in range(R):
            if not (1<<i)&b:
                continue
            x = r[i]
            for j in range(R):
                bj = 1<<j
                if bj&b:
                    continue
                y = r[j]
                nd = dp[b][i]+v[x][y]
                nb = b|bj
                if nd < dp[nb][j]:
                    dp[nb][j] = nd
    print(min(dp[-1]))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 51292
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int n, m;
int a[101010];
LL imos[101010];
LL ans;
LL add[101010];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; a[i]--;
		if (i) {
			ans += min((a[i] + m - a[i - 1]) % m, 1 + a[i] % m);
			add[a[i] + 1] += (a[i] + m - a[i - 1]) % m;
			imos[a[i - 1] + 1]++;
			imos[a[i] + 1]--;
			if (a[i] < a[i - 1])imos[0]++;
		}
	}
	for (int i = 1; i < 101010; i++) {
		imos[i] += imos[i - 1];
	}
	LL minl = ans;
	for (int i = 1; i < m; i++) {
		ans -= imos[i - 1];
		ans += add[i];
		minl = min(minl, ans);
	}
	cout << minl << endl;
}

Measured memory_bytes: 2176
import bisect

n,k = (int(i) for i in input().split())
v = [int(i) for i in input().split()]

res = -10**10
for x in range( min(k+1,n+1) ):
    for l in range(x+1):
        r = x-l
        tras = k-x
        get = sorted(v[:l] + (v[-r:] if r!=0 else []))
        
        idx_0 = bisect.bisect_left(get,0)
        if res < sum(get[ min(idx_0,tras) :]):
            res = sum(get[ min(idx_0,tras) :])

print(res)

Measured memory_bytes: 43624
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
//    String s=sc.next();
    int x=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    int d=sc.nextInt();
    System.out.println(Math.min(x,a)+Math.min(b,d));
  }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* RangeMinimumQuery(0-index) */

struct RMQ{
  typedef int Type;
  int segn2;
  Type inf;
  vector<Type> data;
  
  RMQ(int n){
    inf = 0; //init value
    for(segn2=1;segn2<n;segn2*=2);
    data.assign(segn2*2,inf);
  }
  
  //get minimum value [a,b]
  Type query(int a,int b,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(a<=l && r<=b) return data[k];
    if(r<a || b<l) return inf;
    return (query(a,b,l,(l+r)/2,k*2+1)+query(a,b,(l+r)/2+1,r,k*2+2));
  }
  
  //set kth number x
  void set(int k,Type x){
    k+=segn2-1;
    data[k]=x;
    while(k>0){
      k=(k-1)/2;
      data[k]=(data[k*2+1]+data[k*2+2]);
    }
    return;
  }
};




int main(){
  int n,k;
  int a[SIZE];
  ll sum[SIZE] = {};
  vector<ll> vec;
  vector<ll> vec2;
  map<ll,int> mm;
  
  scanf("%d%d",&n,&k);

  for(int i=1;i<=n;i++){
    scanf("%d",a+i);
    a[i] -= k;
    sum[i] = a[i];
  }

  for(int i=0;i<=n;i++){
    sum[i+1] += sum[i];
    vec.push_back(sum[i]);
  }
  
  vec2 = vec;
  
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());

  for(int i=0;i<vec.size();i++){
    mm[vec[i]] = i;
  }

  RMQ seg(n+1);
  int cc[SIZE] = {};
  
  for(int i=0;i<=n;i++){
    int p = mm[vec2[i]];
    cc[p]++;
    seg.set(p,cc[p]);
  }
  
  ll ans = 0;
  
  for(int i=0;i<n;i++){
    int p = mm[sum[i]];
    
    cc[p]--;
    seg.set(p,cc[p]);

    ans += seg.query(p,INF);
  }
  

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


Measured memory_bytes: 23152
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)


int N, a[112345];

int main() {

	scanf("%d", &N);

	rep(i, N) scanf("%d", &a[i]);

	//sort(a, a + N);

	rep(i, N) if (a[i] % 2) {
		printf("first\n");
		return 0;
	}


	printf("second\n");


	return 0;
}


Measured memory_bytes: 640
l, r = map(int,input().split())
ans = 2018
if r - l > 2019:
    print(0)
else:
    a = l % 2019
    b = r % 2019
    for i in range(a, b):
        for j in range(i + 1, b + 1):
            if ans > (i * j) % 2019:
                ans = (i * j) % 2019
    print(ans)

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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=n-1;i>=m;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> v(n,0);
	FOR(i, 1, n + 1) {
		int a = i;
		FOR(j, 2, i+1) {
			int cnt = 0;
			while (a%j == 0) {
				cnt++;
				a /= j;
			}
			v[j - 1] += cnt;
		}

	}
	long long res = 1;
	REP(i, n) {
		res = res*(v[i]+1) % MOD;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int i = 0;
    while(a>0 && c>0) {
        if(i==0) {
            c -= b;
        }
        else {
            a -= d;
        }
        i = 1 - i;
    }
    if(a>0) cout<<"Yes";
    else cout<<"No";
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#include <math.h>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;

typedef long long ll;

long long Mygcd(long long a, long long b)
{
	if (a % b == 0)return b;
	return Mygcd(b, a % b);
}

int Mygcd(int a, int b)
{
	if (a % b == 0)return b;
	return Mygcd(b, a % b);
}

long long Mylcm(long long a, long long b)
{
	return a * b / Mygcd(a, b);
}

int Mylcm(int a, int b)
{
	return a * b / Mygcd(a, b);
}

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

	double R;

	cin >> R;

	double PI = 3.14159265358979323846;

	cout << std::fixed << std::setprecision(20) << R * 2 * PI << endl;

	return 0;
}

Measured memory_bytes: 3796
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <unordered_set>
#include <unordered_map>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

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

    string co = "CODEFESTIVAL2016";

    int ans = 0;
    rep(i, S.size()) {
        if(S[i] != co[i])
            ans++;
    }
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
     
pi=3.1415
import sys
stdin = sys.stdin
     
pi=3.1415
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A,B,C,D=nm()

T=0
while(A>0 and C>0):
    if(T==0):
        C-=B
        T=1
    else:
        A-=D
        T=0

print('Yes' if T==1 else 'No')

Measured memory_bytes: 9204
#include <iostream>
#include <list>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))

using namespace std;

int main(){
	int D; cin >> D;
	int c[26],s[D][26],t[D];
	rep(i,0,26) cin >> c[i];
	rep(i,0,D) rep(j,0,26) cin >> s[i][j];
	rep(i,0,D){ cin >> t[i]; t[i]--; }
	
	int score = 0;
	
	list<int> day[26]; // �R���e�X�g���J�Â��ꂽ���t
	rep(i,0,26) day[i].push_back(0);
	rep(i,0,D){
		int num = t[i]; // �R���e�X�g�^�C�v
		score += s[i][num];
		score -= c[num]*(i-day[num].back())*(i+1-day[num].back())/2;
		day[num].push_back(i+1);
	}
	rep(i,0,26){
		score -= c[i]*(D-day[i].back())*(D+1-day[i].back())/2;
		day[i].push_back(D+1);
	}
	
	int M; cin >> M;
	
	rep(i,0,M){
		int d,q; cin >> d >> q; q--;
		int p = t[d-1]; // �ύX�����O�̃R���e�X�g�ԍ�
		// �R���e�X�g p ���J�Â���Ȃ����Ƃɂ��e��
		for(list<int>::iterator itr=day[p].begin();itr!=day[p].end();itr++){
			if( *itr == d ){	// �K���ǂ����Ɋ܂܂��
				list<int>::iterator back=itr,next=itr; back--; next++;
				// �K��0���擪�Ɋ܂܂�Ă���̂�itr!=begin
				// �K��D+1���I�[�Ɋ܂܂�Ă���̂�next!=end
				score -= c[p]*(d-*back)*(*next-d)+s[d-1][p];
				day[p].erase(itr);
				break;
			}
		}
		// �R���e�X�g q ���J�Â���邱�Ƃɂ��e��
		for(list<int>::iterator itr=day[q].begin();;itr++){
			if( *itr > d ){
				// �I�[��D+1�ŕK�������|���邱�Ƃ��ۏ؂����
				list<int>::iterator back=itr; back--;
				day[q].insert(itr,d);
				score += c[q]*(d-*back)*(*itr-d)+s[d-1][q];
				break;
			}
		}
		t[d-1] = q;
		cout << score << endl;
	}
	
	return 0;
}


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

int main(void){
    int dis[5];
    int k;
    rep(i,5){
        int x;
        cin >> x;
        dis[i] = x;
    }
    cin >> k;
    if(dis[4]-dis[0]<=k){
        cout << "Yay!";
    }
    else{
        cout << ":(";
    }
    
    return 0;
}


































Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = sc.nextInt();
		int[] data = new int[n];
		for (int i = 0; i < n; i++) {
			data[i] = sc.nextInt();
		}
		
		for (int i = n -1; i >= 0; i--) {
			System.out.print(data[i]);
			if (i != 0) {
				System.out.print(" ");
			}
		}
		System.out.println("");
		
		sc.close();
	}
}

Measured memory_bytes: 19628
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int r=0;
    int m=0;
    for(int i=0;i<s.length();i++){
      int d=s.charAt(i);
      if(d=='A'||d=='T'||d=='G'||d=='C'){
        r++;
        m=Math.max(r,m);
      }else{
        r=0;
      }
    }
    System.out.println(m);
  }
}

Measured memory_bytes: 21972
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  uint64_t N, t, a = 0;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> t;
    a |= t;
  }
  for (int i = 0;; i++)
  {
    if ((a & 1) == 1)
    {
      cout << i << endl;
      return 0;
    }
    else
    {
      a = (a >> 1);
    }
  }
}


Measured memory_bytes: 3184
$<.map{|i|a=i.split(?,).map(&:to_i).sort;b=a.map{|j|a.count(j)}.max;s=a.uniq.size;puts b>3?"four card":b>2?s>2?"three card":"full house":b>1?s>3?"one pair":"two pair":a[4]-a[0]<5||a[1]>9?:straight: :null}

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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};



int main() {
	fastio();

	double n; cin >> n;

	cout << fixed << setprecision(15) ;

	if ((ll)n % 2 == 0) {
		cout << ((double)1 / 2);
	}

	else cout << ((n + 1) / (2 * n));

	return 0;
}

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

int n,m,L = 0,R = 1010101;
int l[101010],r[101010];

int main(){
  cin >> n >> m;
  for(int i = 0; i <m; i++){
    cin >> l[i] >> r[i];
    L = max(l[i],L);
    R = min(r[i],R);
  }
  if(R>=L) cout << R - L + 1 <<endl;
  else cout << "0" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>

template< typename iterator >
iterator partition( iterator first, iterator last)
{
    auto x = *(last-1) ;
    int i = -1;
    for( iterator iter = first ; iter != last-1 ; ++iter )
    {
        if( *iter <= x )
        {
            ++i ;
            std::swap( *iter, *(first+i) ) ;
        }
    }
    std::swap( *(last-1), *(first+i+1) ) ;

    return first+i+1 ;
}

template< typename iterator >
void quick_sort( iterator first, iterator last )
{
    if( first < last )
    {
        iterator mid = partition( first, last ) ;
        quick_sort( first, mid ) ;
        quick_sort( mid+1, last ) ;
    }
}

struct Card
{
    char mark ;
    int num ;
    bool operator <=( Card & l )
    {
        if( num <= l.num )
        {
            return true ;
        }
        else
        {
            return false ;
        }
    }

    bool operator <( const Card & l ) const
    {
        if( num < l.num )
        {
            return true ;
        }
        else
        {
            return false ;
        }
    }
} ;

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

    std::vector<Card> A(n) ;
    for( int i = 0 ; i < n ; ++i )
    {
        std::cin >> A.at(i).mark >> A.at(i).num ;
    }
    std::vector<Card> B(n) ;
    for( int i = 0 ; i < n ; ++i )
    {
        B.at(i).mark = A.at(i).mark ;
        B.at(i).num = A.at(i).num ;
    }

    quick_sort( A.begin(), A.end() ) ;
    std::stable_sort( B.begin(), B.end() ) ;
    
    bool flag = 0 ; 
    for( int i = 0 ; i < n ; ++i )
    {
        if( A.at(i).mark != B.at(i).mark )
        {
            flag = 1 ;
        }
    }
    
    if(flag)
    {
        std::cout << "Not stable" << std::endl ;
    }
    else
    {
        std::cout << "Stable" << std::endl ;
    }

    for( int i = 0 ; i < n ; ++i )
    {
        std::cout << A.at(i).mark << " " << A.at(i).num << std::endl ;
    }
}



Measured memory_bytes: 4584
#include<stdio.h>
int a[100020];
int main ()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int i,k=0,m,t=0;
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		i=0;
		while(a[i]!=2)
		{
			if(a[i]==0)
			{
				printf("-1\n");
				t++;
				break;
			}
			m=i;
			i=a[i]-1;
			a[m]=0;
			k++;
		}
		if(t==0)
			printf("%d\n",k+1);
	}
} 

Measured memory_bytes: 512
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
  ld n,m;cin>>n>>m;
  vector<ld>a(n);
  rep(i,n)cin>>a[i];
  ld sum=0;
  rep(i,n)sum+=a[i];
  ld x=sum/(4*m);
  ll count=0;
  rep(i,n)if(a[i]>=x)count++;
  cout<<(count>=m ? "Yes" : "No")<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int gcd(int a,int b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  else return gcd(b,a%b);
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int fr[n],ba[n];
  fr[0]=a[0];
  ba[n-1]=a[n-1];
  repi(i,1,n){
    fr[i]=gcd(a[i],fr[i-1]);
  }
  repn(i,n-2){
    ba[i]=gcd(a[i],ba[i+1]);
  }
  int ans=0;
  repi(i,1,n-1){
    ans=max(ans,gcd(fr[i-1],ba[i+1]));
  }
  ans=max(ba[1],ans);
  ans=max(ans,fr[n-2]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int total3 (multiset <int, greater<int> > s )
{
	multiset <int, greater<int> >::iterator it = s.begin();
	int res = 0;
	int i;

	for (i = 0; i < 3; ++i, ++it){
		res += (*it);
	} // end for

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.contest2", "r", stdin );
	string str = "";

	int i;
	multiset <int, greater<int> > scoreW, scoreK;

	for (i = 0; i < 10; ++i){
		int score;
		getline (cin, str );

		stringstream ssw(str);
		ssw >> score;
		scoreW.insert (score );
//		cout << "scoreW: " << score << endl;
	} // end loop
	for (i = 10; i < 20; ++i){
		int score;
		getline (cin, str );

		stringstream ssk(str);
		ssk >> score;
		scoreK.insert (score );
//		cout << "scoreK: " << score << endl;
	} // end for

	int resW = total3 (scoreW );
	int resK = total3 (scoreK );

	cout << resW << ' ' << resK << endl;
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int red, green, blue, k;
  cin >> red >> green >> blue >> k;
 
  string result = "No";
  
  for (int i = 0; i < k; i++) {
  	
    if (green > red && blue > green) {
    	result = "Yes";
      	break;
    }
    
    if (red >= green) {
    	green *= 2;
      if (green > red && blue > green) {
          result = "Yes";
          break;
      	}
      continue;
    }
    
    if (green >= blue) {
      	blue *= 2;
        if (green > red && blue > green) {
        result = "Yes";
        break;
      	}
      continue;
    }
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>


using namespace std;

const long long int mod = 1e9+7;
const long long int MAXN = 1e5;

int main()
{
	long long int n,a[MAXN] = {0};

	cin >> n;

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

	if (n == 1)
	{
		if (a[0] == 0)
		{
			cout << 1 << endl;
		}else
		{
			cout << 0 << endl;
		}

		return 0;
	}

	long long int p[MAXN] = {0};

	for(int i = 0; i < n; i++)
	{
		p[a[i]]++;
	}

	int cnt = 0;

	for(int i = 0; i < n; i++)
	{
		if (p[i] == 2)
		{
			cnt++;
		}else if (p[i] != 2 && p[i] != 0 && i != 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	if (cnt != floor(n/2))
	{
		cout << 0 << endl;
		return 0;
	}

	long long int sol = 1;

	for(int i = 1; i <= cnt; i++)
	{
		sol *= 2;
		sol %= mod;
	}

	cout << sol << endl;

	return 0;
}
	

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

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin>>s;
    if(s =="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define mnx 1000001
#define pr pair<ll,ll>
using namespace std;

void masterstroke(){
ll n;
cin>>n;
ll a,b;
ll t=0;
vector <pair<ll,ll> > v;
for(ll i=0;i<n;i++){
	cin>>a>>b;
	v.PB(MP(b,a));
}
sort(all(v));
for(auto j:v){
	if(j.ff<(t+j.ss)){cout<<"No"<<endl;return;}
	t+=j.ss;
}
cout<<"Yes"<<endl;
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke();
}


Measured memory_bytes: 6600