akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
}

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,h,w;
 
ll x[500005],y[500005],z[500005];
char s[100005],t[100005];
bool ok=false;
bool check[100005];
 
int main(){
    cin>>h>>w;
    for(i=0;i<h;i++){
        cin>>s;
        for(j=0;j<w;j++){
            t[i*w+j]=s[j];
            
        }
    }
    num=0;
    a=1;
    sort(t,t+h*w);
	
    while(1+1==2){
        if(t[num]==t[num+1]){
            num++;
            a++;
        }else{
            num++;
            b += (a/4);
            c += (a/2);
            a=1;
        }
        if(num==h*w)break;
    }
    b += (a/4);
    c += (a/2);
    if(b>=(h/2)*(w/2)){
        c -= (h/2)*(w/2)*2;
    }else{
        p("No");
        return 0;
    }
    if((h*w)%2==1){
        if(c>=h/2+w/2){
            p("Yes");
        }else{
            p("No");
            
        }
        return 0;
    }
    if((h+w)%2==1){
        if(h%2==0)swap(h,w);
        if(c>=w/2){
            p("Yes");
        }else{
            p("No");
            
        }
        return 0;
    }
    p("Yes");
    
 
   
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>

using namespace std;

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

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

    cout << (h <= a_sum ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int a;
string s;
signed main(){
    cin>>a>>s;
    if(a>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
    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 next=0;
        int i=0;
        while ((next=sc.nextInt()) != 0) {
            i++;
            System.out.println("Case " + i + ": " + next);
        }
    }
}


Measured memory_bytes: 41440
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func rs() string {
	sc.Scan()
	return sc.Text()
}

type sortRunes []rune
func (s sortRunes) Less(i, j int) bool { return s[i] < s[j] }
func (s sortRunes) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortRunes) Len() int           { return len(s) }

func sortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func sigma(x int) int { return x * (x + 1) / 2 }

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	keys := make(map[string]int)
	for i := 0; i < n; i++ {
		s := rs()
		sSorted := sortString(s)
		keys[sSorted]++
	}
	ans := 0
	for _, v := range keys {
		if v == 0 || v == 1 {
			continue
		}
		ans += sigma(v - 1)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 11520
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));


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

	int N, A, B;
	cin >> N >> A >> B;

	if (A > B)
		cout << 0 << endl;
	else if (N == 1) {
		if (A != B)
			cout << 0 << endl;
		else
			cout << 1 << endl;
	}
	else
		cout << (B - A)*(N - 2) + 1 << endl;
	

	return 0;
}



Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#define mp make_pair
#define pb push_back
using namespace std;

namespace Header_Template {
  typedef long long li;
  template<class T>inline void read(T &x) {
    x = 0;
    T tmp = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') tmp = -1, c = getchar();
    while (c >= '0' && c <= '9')
      x = (x << 1) + (x << 3) + c - '0', c = getchar();
    x *= tmp;
  }
  template<class T>inline void Max(T &x, T y) {
    if (y > x) x = y;
  }
  template<class T>inline void Min(T &x, T y) {
    if (y < x) x = y;
  }
}
using namespace Header_Template;

const int N = 710;
int n, m, a[N][N];
int cnt, fa[N], id[N], col[N], f[N], ans;
vector<int> g[N], sub[N];

int Find(int x) {
  if (fa[x] != x) fa[x] = Find(fa[x]);
  return fa[x];
}
void Color(int x, int cur) {
  col[x] = cur;
  for (int y : g[x]) {
    if (~col[y]) {
      if (col[y] == col[x]) {
        ans = -1;
        return;
      } else continue;
    }
    Color(y, cur ^ 1);
  }
}
void Solve(int x, int y) {
  for (int i = n; ~i; --i) {
    int cur = 0;
    if (i >= x) cur |= f[i - x];
    if (i >= y) cur |= f[i - y];
    f[i] = cur;
  }
}
int main(void) {
  read(n), read(m);
  for (int i = 1, x, y; i <= m; ++i) {
    read(x), read(y);
    a[x][y] = a[y][x] = 1;
  }
  
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (!a[i][j]) {
        g[i].pb(j);
        g[j].pb(i);
        int x = Find(i), y = Find(j);
        if (x != y) fa[x] = y;
      }
  for (int i = 1; i <= n; ++i)
    if (Find(i) == i) id[i] = ++cnt;
  for (int i = 1; i <= n; ++i)
    sub[id[Find(i)]].pb(i);

  f[0] = 1;
  fill(col + 1, col + 1 + n, -1);
  for (int i = 1; i <= cnt; ++i) {
    Color(sub[i][0], 0);
    if (ans == -1) {
      puts("-1");
      return 0;
    }
    int x = 0, y = 0;
    for (int u : sub[i])
      if (col[u]) ++x;
      else ++y;
    Solve(x, y);
  }
  ans = n >> 1;
  while (!f[ans]) --ans;
  ans = ans * (ans - 1) / 2 + (n - ans) * (n - ans - 1) / 2;
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(void)
{
	char S[3];
	char T[3];
	int cnt=0;

	scanf("%s",S);
	scanf("%s",T);

	for(int i=0;i<3;i++){
		if(S[i]==T[i]){
			cnt++;
		}
	}
	printf("%d\n",cnt);

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		System.out.print(a.charAt(0));
		System.out.print(b.charAt(1));
		System.out.print(c.charAt(2));
	}
}

Measured memory_bytes: 21588
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        p: i32,
        q: i32,
        r: i32,
    }
    let mut a = vec![p + q, q + r, p + r];
    a.sort();

    println!("{}", a[0]);
}


Measured memory_bytes: 4352
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def factorials(n):
    facts = []
    for k in range(2, n+1):
        done = False
        max_f = int(math.sqrt(k))
        for f in facts:
            if f > max_f:break
            if not k % f:
                done = True
                break
        if not done:
            facts.append(k)
    return facts

def prime_factorization(val, facts = None, divisors = None):
    if facts == None:
        max_n = int(math.sqrt(val))
        facts = factorials(max_n)
    if divisors == None:
        divisors = defaultdict(lambda:0)
    for f in facts:
        if f > val:break
        while True:
            if not val % f:
                divisors[f] += 1
                val //= f
            else:
                break
    if val > 1:
        divisors[val] += 1

    return divisors

def run():
    N = int(input())

    max_n = int(math.sqrt(N))
    facts = factorials(max_n)
    divisors = defaultdict(lambda: 0)
    for n in range(2, N+1):
        divisors = prime_factorization(n, facts, divisors)
    #print(divisors)
    mod = 10 ** 9 + 7
    ans = 1
    for key, value in divisors.items():
        ans *= value+1
        ans %= mod
    print(ans)

if __name__ == "__main__":
    run()

Measured memory_bytes: 9420
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(n - k + 1):
    left = x[i]
    right = x[i + k - 1]
    if abs(left) > abs(right):
        ans.append(abs(right) + abs(left - right))
    else:
        ans.append(abs(left) + abs(right - left))

print(min(ans))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
	char str[3];
	int frg[3]={0};
	cin >>str[0]>>str[1]>>str[2];
	for(int i=0;i<3;i++){
		if(str[i] == 'a'){frg[0] = 1;}
		else if(str[i] == 'b'){frg[1] = 1;}
	else if(str[i] == 'c'){frg[2] = 1;}
	}
	if(frg[0] == 1 && frg[1] == 1 && frg[2]==1){
		cout <<"Yes"<<endl;
	}
	else {
		cout <<"No"<<endl;
	}
	return 0;
	
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  vector<int> a(3);
  cin >> a;
  sort(all(a));
  if (a[0] == a[1] && a[1] != a[2]) {
    cout << "Yes" << endl;
    return;
  } else if (a[0] != a[1] && a[1] == a[2]) {
    cout << "Yes" << endl;
    return;
  }
  cout << "No" << endl;
  return;
}


Measured memory_bytes: 256
from numba import njit
import numpy as np

d = int(input())
cs = list(map(int, input().split()))
cs = np.array(cs, dtype=np.int64)
sm = [list(map(int, input().split())) for _ in range(d)]
sm = np.array(sm, dtype=np.int64)

@njit('i8(i8[:], i8)', cache=True)
def total_satisfaction(ts, d):
    ls = np.zeros(26, dtype=np.int64)
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dv = cs * ((i+1) - ls)
        s -= dv.sum()
    return s

@njit('i8(i8, i8, i8, i8, i8[:])', cache=True)
def differential(s, i, t, d, ls):
    t -= 1
    bk = ls[t]
    s += sm[i][t]
    ls[t] = i + 1

    dv = cs * ((i+1) - ls)
    s -= dv.sum()

    ls[t] = bk
    return s

ts = np.array([], dtype=np.int64)
for i in range(d):
    sc = 0
    if len(ts) > 0:
        tt = np.array(ts, dtype=np.int64)
        sc = total_satisfaction(tt, i)

    ls = np.zeros(26, np.int64)
    for i, t in enumerate(ts, 1):
        ls[t-1] = i

    mx = -99999999
    mxt = -1
    for t in range(1, 26+1):
        df = differential(sc, len(ts), t, i + 1, ls)
        s = sc + df
        if s > mx:
            mx = s
            mxt = t
    ts = np.append(ts, [mxt])
    print(mxt)


Measured memory_bytes: 116608
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int N,M;
vi g[SIZE];
bool used[SIZE];
int guki[SIZE]={0};
ll cntX=0,cntY=0;
bool flag;
void dfs(int a){
	used[a]=true;
	for(int i=0;i<g[a].size();i++){
		int next=g[a][i];
		if(guki[next]==guki[a])flag=false;
		if(!used[next]){
			guki[next]=guki[a]*-1;
			dfs(next);
		}
		
	}
}
int main(){
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int u,v;
		cin>>u>>v;u--;v--;
		g[u].pb(v);g[v].pb(u);
	}
	ll ans=0;
	int cnt=0;
	rep(i,N)used[i]=false;
	for(int i=0;i<N;i++){
		if(g[i].size()==0)cnt++,used[i]=true;
	}
	ans+=(ll)N*(ll)N-(ll)(N-cnt)*(ll)(N-cnt);
	for(int i=0;i<N;i++){
		if(!used[i]){
			guki[i]=1;
			flag=true;
			dfs(i);
			if(flag){
				cntY++;
			}else{
				cntX++;
			}
		}
	}
	ans+=(cntX+cntY)*(cntX+cntY)+cntY*cntY;
	cout<<ans<<endl;
}

Measured memory_bytes: 10112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long ans =0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        a[i]=x-i-1;
    }
    sort(a.begin(),a.end());
    int p;
    if(n%2==0){
       p = (a[n/2]+a[n/2-1])/2;
    }else{
       p = a[n/2];
    }
    for(int j=0;j<n;j++){
        ans = ans+ abs(a[j]-p);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
  char s[4]={};
  int i,ans=0;
  scanf("%s",s);
  for(i=0;i<4;i++)
  {
    if(s[i]=='+')
    {
      ans++;
    }
    else if(s[i]=='-')
    {
      ans--;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
sw=[[] for _ in range(m)]
for _ in range(m):
    temp=list(map(int,input().split()))
    sw[_]=temp[1:temp[0]+1]
p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    temp=[0]*n
    for j in range(n):
        if i&1: temp[j]=1
        i>>=1
    flag=1
    for l,s in enumerate(sw):
        cnt=0
        for k in s:
            if temp[k-1]==1: cnt+=1
        if p[l]!=cnt%2:
            flag=0
            break
    if flag: ans+=1
print(ans)

Measured memory_bytes: 9168
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int64_t i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, X, M;
  cin >> N >> X >> M;

  unordered_map<int64_t, pair<int64_t, int64_t>> hist;
  int64_t answer = 0;
  int64_t A = X;
  rep(i, N) {
    if (hist.count(A)) {
      auto prev = hist[A];
      int64_t loop_size = i - prev.first;
      int64_t loop_sum = answer - prev.second;
      int64_t loop_cnt = (N - i) / loop_size;
      answer += loop_sum * loop_cnt;

      int64_t last = N - i - loop_cnt * loop_size;
      rep(j, last) {
        answer += A;
        A = (A * A) % M;
      }
      break;
    } else {
      hist[A] = {i, answer};
      answer += A;
      A = (A * A) % M;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 5984
#include "bits/stdc++.h"
    using namespace std;
    
    #define nl '\n'
    #define ll long long 
    #define ull unsigned long long
    #define debug(x)       { cerr << #x << " = " << x << endl; } 
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    
    const int Max = (int)2e5+5;
    
    //functions
    ll lcm(ll a,ll b) {if(a==0 || b==0){return 0;}else{return (a*b)/__gcd(a,b);}}
    
    //direction arry
    int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
    int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
    int dx4[] = {0, 0, 1, -1};
    int dy4[] = {1, -1, 0, 0};
    
    //____________________________________________________________________________________________________
    void solve()
    {
        int n,m;
        cin>>n>>m;
        vector<int>v(n);
        ll sum = 0;
        for(int i=0;i<n;i++)
        {
            cin>>v[i];
            sum+=v[i];
        }
        ll cnt = 0;
        for(int i=0;i<n;i++)
        {
            if(sum<=v[i]*4*m)
            {
                cnt++;
            }
        }
        if(cnt>=m)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    int main()
    {
        fastread;
        int tc=1;
        // cin>>tc;
        while(tc--){
            solve();
        }
        return 0;
    }

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 998244353;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int n, k;
    cin >> n >> k;
    vi l(k), r(k);
    rep(i,k) cin >> l[i] >> r[i];
    vi dp(n+1, 0);
    
    int tmp = 0;
    dp[1] = 1;
    reps(i, 2, n){
        rep(j,k){
            tmp = mod(tmp - dp[max(0LL, i - r[j] - 1)]);
            tmp = mod(tmp + dp[max(0LL, i - l[j])]);
        }
        dp[i] = mod(dp[i] + tmp);
    }
    
    cout << dp[n] % MOD << endl;
}

Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
int W,H,N,a,x,y,b1,b2,b3,b4,i;
int main()
{
	cin>>W>>H>>N;
	b2=W;b4=H; 
	for(i=1;i<=N;i++)
	{
		cin>>x>>y>>a;
		if(a==1&&x>b1)b1=x;
		if(a==2&&x<b2)b2=x;
		if(a==3&&y>b3)b3=y;
		if(a==4&&y<b4)b4=y;
	}
	if(b2<=b1||b4<=b3)cout<<0;
	else cout<<(b2-b1)*(b4-b3);
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    string S;
    cin >> S;
    std::reverse(S.begin(), S.end());
    string rd = "maerd", rder = "remaerd", re = "esare", rer = "resare";
    int i = 0;
    int n = S.size();
    while (i < n)
    {
        if (i + 6 < n && S.substr(i, 7).compare(rder) == 0)
        {
            i += 7;
        }
        else if (i + 5 < n && S.substr(i, 6).compare(rer) == 0)
        {
            i += 6;
        }
        else if (i + 4 < n && (S.substr(i, 5).compare(rd) == 0 || S.substr(i, 5).compare(re) == 0))
        {
             i += 5;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3748
from heapq import *

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

# 0 <= i <= N
# left_Nth_max_sum[i] == sum( sorted(As[:N+i], reverse=True)[:N] )
# right_Nth_min_sum[i] == sum( sorted(As[N+i:])[:N] )

left_Nth_max_sum = [0] * (N+1)
lpq = As[:N] # left priority queue
heapify(lpq)
left_Nth_max_sum[0] = sum(lpq)
for i in range(N):
    popped_A = heappushpop(lpq, As[N+i])
    left_Nth_max_sum[i+1] = left_Nth_max_sum[i] + As[N+i] - popped_A

right_Nth_min_sum = [0] * (N+1)
rpq = [-A for A in As[2*N:]]
heapify(rpq)
right_Nth_min_sum[N] = -sum(rpq)
for i in range(N-1, -1, -1):
    popped_A = -heappushpop(rpq, -As[N+i])
    right_Nth_min_sum[i] = right_Nth_min_sum[i+1] + As[N+i] - popped_A

"""
for i in range(N+1):
    assert left_Nth_max_sum[i] == sum( sorted(As[:N+i], reverse=True)[:N] )
    assert right_Nth_min_sum[i] == sum( sorted(As[N+i:])[:N] )
"""

print(max( (left_Nth_max_sum[i] - right_Nth_min_sum[i] for i in range(N+1)) ))

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

int main() {
    string S;
    cin >> S;
    if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3) ) {
        cout << "Bad" << endl;
    }
    else {
        cout << "Good" << endl;
    }
    
}

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

int main() {
    int n;
    cin >> n;
    int a[9] = {0};
    rep(i,n) {
        int rate;
        cin >> rate;
        int color = rate / 400;
        if (rate >= 3200) color = 8;
        a[color]++;
    }
    int min_types = 0;
    rep(i,8) {
        if (a[i] > 0) {
            min_types++;
        }
    }
    int max_types = min_types + a[8];
    min_types = max(min_types, 1);
    printf("%d %d\n", min_types, max_types);
}

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

int gcd(int x, int y){
    int r;
    if(x<y){
        swap(x,y);
    }

    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    int n,x;
    cin >> n >> x;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = abs(x-a[0]);
    for(int i = 0; i < n; i++){
        ans = gcd(ans,abs(x - a[i]));
    }
    cout << ans;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut acc = vec![0; n + 1];
    for i in 0..n {
        acc[i + 1] = acc[i] + a[i];
    }
    let mut mi: i64 = 1 << 50;
    for i in 1..n {
        mi = min(mi, (acc[n] - 2 * acc[i]).abs());
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 12540
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int sum = 0;
    for (int i=1;i<=n;i++){
      for (int j=1;j<=n;j++){
        for (int k=1;k<=n;k++){
          sum += find(i,j,k);
        }
      }
    }
    System.out.println(sum);
  }

  public static int find(int a,int b,int c){
    int min = a;
    if (a>b){
      min = b;
    }
    if (min>c){
      min = c;
    }

    int l = min;
    while (l>1){
      if ((a%l == 0) && (b%l == 0) && (c%l == 0)){
        return l;
      }
      l -= 1;
    }
    return l;
  }

}


Measured memory_bytes: 35660
program V1502;
 var
  a:array[0..101] of int64;
  i,n:longint;
 function haha(x,y:int64):int64;
  begin
   if x<y then exit(haha(y,x));
   if y=0 then exit(x);
   exit(haha(y,x mod y));
  end;
 begin
  readln(n);
  for i:=1 to n do
   readln(a[i]);
  for i:=2 to n do
   a[i]:=a[i] div haha(a[i],a[i-1])*a[i-1];
  writeln(a[n]);
 end.


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

int main() {
	int n,ans=0;
	cin>>n;
	
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a.at(i);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	for(int i=0;i<n;i++){
		if(i%2==0)ans+=a.at(i);
		else ans-=a.at(i);
	}
	cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

using vd=vector<double>;
using vvd=vector<vd>;


int main(){
    string s;
    while(cin>>s,s!="#"){
        vs ans;
        rep(c, (1<<s.size())){//2^20
            vector<bool> cng(26,false);
            cng[25]=true;
            vector<bool> n(26,true);
            string as=s,cs=s;
            rep(a,s.size()){//20
                if(c&(1<<a)){
                    if(cng[cs[a]-'a']) goto end;
                    cng[cs[a]-'a']=true;
                    cs[a]++;
                }
                as[a]=cs[a];
                if(n[as[a]-'a'] && as[a]!='a'){
                    n[as[a]-'a']=false;
                    as[a]--;
                    if(s[a]!=as[a]){
                        goto end;
                    }
                }
            }
            ans.pb(cs);
            end:;
        }
        sort(all(ans));
        cout<<ans.size()<<endl;
        if(ans.size()<=10){
            for(auto a:ans)cout<<a<<endl;
        }else{
            rep(i,5)cout<<ans[i]<<endl;
            range(i,ans.size()-5,ans.size())cout<<ans[i]<<endl;
        }
    }
	return 0;
}



Measured memory_bytes: 4180
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  string s; cin>>s;
	rep(i,3){
		rep(j,3){
			if(s[i]!=s[j]) return cout<<"Yes"<<endl,0;
		}
	}
	cout << "No"<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
PY = []

for i in range(M):
    p, y = map(int, input().split())
    PY.append([p, y, i])

nums = [0] * N
ans = [''] * M

PY.sort(key=lambda x:x[1])

for p, y, i in PY:
    nums[p - 1] += 1
    ans[i] = str(p).zfill(6) + str(nums[p - 1]).zfill(6)

for a in ans:
    print(a)


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

int main(){
    int a, b;
    string op;
    for(;;){
        cin >> a >> op >> b;
        if(op == "+"){
            cout << a + b << endl;
        }
        else if(op == "-"){
            cout << a - b << endl;
        }
        else if(op == "*"){
            cout << a * b << endl;
        }
        else if(op == "/" && b != 0){
            cout << a / b << endl;
        }
        else{
            break;
        }
    }
    
}


Measured memory_bytes: 3148
// Aizu Vol-2 0286: Computation of Salary
// 2017.8.20 bal4u@uu
// 2017.11.5 retry

#include <stdio.h>

#define MAX 10000
#define MAX2 500000

typedef struct { int n, nxt, end; } WAK;
typedef struct { int nxt, t, e; } LNK;

WAK wak[MAX+5];
LNK lnk[MAX2+5]; int used;
int b[MAX+5];

char buf[100002], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}


void pr(int n)
{
	char *q;
	static char tmp[13] = { 0, ' ' };
	q = tmp+1; while (n >= 10) {
		*++q = '0' + (n % 10);
		n /= 10;
	}
	*p++ = n + '0';
	while (*q) *p++ = *q--;
}

int main()
{
	int N, M, L, i, j, k, ans;
	WAK *w;

	fgets(p=buf, 20, stdin), N = getint(), p++, M = getint();
	while (fgets(p=buf, 30, stdin) && *p != '0') {
		w = wak + getint(), p++, lnk[used].t = getint(), p++, lnk[used].e = getint();
		if (w->n == 0) w->nxt = used;
		else lnk[w->end].nxt = used;
		w->end = used++, w->n++;
	}
	fgets(p=buf, 10, stdin), L = getint();
	while (L--) {
		fgets(p=buf, 70000, stdin);
		for (i = 1; i <= M; i++) b[i] = getint(), p++;
		for (p = buf, w = wak+1, i = N; i--; w++) {
			if (w->n == 0) { *p++ = '0', *p++ = ' '; continue; }
			for (ans = 0, k = w->nxt, j = w->n; j--; k = lnk[k].nxt)
				ans += lnk[k].e * b[lnk[k].t];
			pr(ans);
		}
		*--p = 0, puts(buf);
	}
	return 0;
}

Measured memory_bytes: 2404
N = int(input())
s = []
mozi = set()
for i in range(N):
  S =input()
  s.append(S)
  mozi.add(S)
M = int(input())
t = []
for i in range(M):
  t.append(input())
ans = 0
for elem in mozi:
    cur = 0
    for i in range(N):
        if elem == s[i]:
            cur += 1
    for j in range(M):
        if elem == t[j]:
            cur -=1
    ans = max(ans,cur)

print(ans)


Measured memory_bytes: 3064
S = input()
c = 0
i = 0
ac = 0
while i < len(S):
    if S[i] == "A":
        ac += 1
    elif S[i:i+2] == "BC":
        c += ac
        i += 1
    else:
        ac = 0
    i += 1
print(c)


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

using namespace std;
typedef long long ll;
ll t , k,n,x , y , a, b,c , d ,sum;
string s;
const int N=1e5+1;
char ch;
int occ[N],arr[N];
int main()
{
    cin >> n;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> arr[i];
        occ[arr[i]]++;
        sum+=arr[i];
    }
    cin >> k;
    for(int i = 0 ; i  < k ; i++)
    {
        cin >> b >> c;
        sum=sum-(occ[b]*b)+(occ[b]*c);
        occ[c]+=occ[b];
        occ[b]=0;
        cout << sum << "\n";
    }
    return 0;
}


Measured memory_bytes: 4348
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, j;
	int sum, max;
	int n, k;
	int *ary;
	int tmp;

	while(1)
	{
		scanf("%d %d", &n, &k);
		if(n==0 && k==0)
			break;

		if( (ary = (int*)calloc(n, sizeof(int))) == NULL )
			return 1;

		for(i=0; i<n; i++) {
			scanf("%d", ary + i);
		}

		sum = 0;
		for(i=0; i<k; i++) {
			sum += ary[i];
		}
		max = sum;
		tmp = ary[i-k];

		for(; i<n; i++) {
			sum += ary[i] - tmp;
			tmp = ary[i-k+1];
			if(sum > max)
				max = sum;
		}

		printf("%d\n", max);
	}

	return 0;
}

Measured memory_bytes: 1004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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; }

inline bool OddCheck( vector<ll> v ){
    bool isOdd = false;
    for (int i = 0; i < (int)v.size(); i++) {
        if( v[i] % 2 ) isOdd = true;
    }
    return isOdd;
}


int main(int argc, const char * argv[]) {
    
    
    
    int n; cin >> n;
    vector<ll> A(n);
    rep(i,n) cin >> A[i];
    
    ll Ans = 0;
    while(!OddCheck(A)){
        for (int i = 0; i < n; i++) {
            A[i] /= 2;
        }
        Ans++;
    }
    
    cout << Ans << endl;
    
    
    
    
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include<set>
const int maxn = 100010;
using namespace std;
int a[maxn];
int main()
{
       string ss;
       int n;
       scanf("%d",&n);
       set<string> s;
       while(n--)
       {
           cin>>ss;
           s.insert(ss);
       }
       printf("%d",s.size());

}


Measured memory_bytes: 19280
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int[] x = new int[N];
    for(int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }
    // dp[i][j][k]はインデックスiまでのカードからj枚選んで和をkにする場合の数を表す
    long[][][] dp = new long[N][N + 1][2501];
    dp[0][0][0] = 1;
    dp[0][1][x[0]] = 1;
    for(int i = 1; i < N; i++) {
      for(int j = 0; j < N + 1; j++) {
        for(int k = 0; k < 2501; k++) {
          if(j == 0) {
            if(k == 0) dp[i][j][k] = 1;
          } else {
            if(x[i] <= k) {
              dp[i][j][k] = dp[i - 1][j - 1][k - x[i]] + dp[i - 1][j][k];
            } else {
              dp[i][j][k] = dp[i - 1][j][k];
            }
          }
        }
      }
    }
    long ans = 0;
    for(int j = 1; j < N + 1; j++) {
      ans += dp[N - 1][j][A * j];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 82356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

ll dp[51][6000];

void solve() {
    ll N, A;
    cin >> N >> A;
    vll x(N);
    for(auto &a:x) {cin >> a; a-=A;};
    dp[0][3000] = 1;
    for(int i = 1; i <= N; i++) {
        for(int j = -2600;j < 2600; j++) {
            dp[i][j+3000] = dp[i-1][j+3000];
            dp[i][j+3000] += dp[i-1][j-x[i-1]+3000];
        }
    }
    out(dp[N][3000] - 1);
}

int main() {
    fast_io;
    solve();
    return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int k,n;
    cin>>n>>k;
    cout<<(n-k+1)<<endl;
    return 0;
}


Measured memory_bytes: 256
function main(input) {
  const inputs =input.split('\n')
  const [X, N] = inputs[0].split(' ').map(Number)
  const P = inputs[1].split(' ').map(Number)
  let min = 101
  let n = -1
  for (let i = 0; i <= 101; i++) {
    // console.log('i:', i)
    if (P.includes(i)) continue
    const d = Math.abs(X - i)
    // console.log('i:', i, 'd:', d)
    if (min <= d) break
    min = d
    n = i
  }
  console.log(n)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int a , b ;

int main() {
    cin >> a >> b ;
    map < int , int > v ;
    forn( int , i , 1 , 19 ){
       v[ i ] = i ;
    }
    v[ 1 ] = 14 ;
    if( v[ a ] > v[ b ] ){
        cout << "Alice" ;
    } else if( v[ b ] > v[ a ] ){
        cout << "Bob" ;
    } else cout << "Draw" ;
    return 0 ;
}



Measured memory_bytes: 256
import java.util.*;

class ManipulationException extends RuntimeException {}

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int n;
        while((n = scn.nextInt()) > 0) {
            String[] prm = scn.nextLine().trim().split(" ");
            String[] ary = scn.nextLine().split(" ");
            Memory mem = new Memory(
              Integer.parseInt(prm[0]), Integer.parseInt(prm[1]),
              Integer.parseInt(prm[2]), Integer.parseInt(prm[3])
            );
            try {
                for(int i = 0; i < n; i++) {
                    int y = Integer.parseInt(ary[i]);
                    while(mem.isDiff(y)) {
                        mem.nextFrame();
                    }
                    mem.nextFrame();
                }
                System.out.println(mem.showFrame());
            } catch(ManipulationException e) {
                System.out.println("-1");
            }
        }
    }
}

class Memory {
    private int frame_, x_;
    private final int a_, b_, c_;
    
    public Memory(int a, int b, int c, int x) {
        frame_ = -1;
        a_ = a;
        b_ = b;
        c_ = c;
        x_ = x;
    }
    
    public void nextFrame() throws ManipulationException {
        if(++frame_ > 10000) {
            throw new ManipulationException();
        }
        x_ = (a_ * x_ + b_) % c_;
    }
    
    public int showFrame() {
        return frame_;
    }
    
    public boolean isDiff(int y) {
        return x_ != y;
    }
}

Measured memory_bytes: 32028
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		sc = null;
		int m = Math.min(a, b);
		int i;
		int c = 0;
		for(i = m; i > 0; i--) {
			if((a % i == 0) && (b % i == 0)) {
				c++;
				if(c == k) break;
			}
		}
		System.out.println(i);
	}
}


Measured memory_bytes: 22868
#pragma region Header
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    string s;
    cin >> s;
    int m = 0;
    for (auto c : s)
    {
        int x = c - '0';
        (m += x) %= 9;
    }
    cout << (m == 0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3736
#include<cstdio>
#define f(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;i=-(~i))
#define rf(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;i=~(-i))
const int neko=100010,mod=1e9+7;
int n,a[neko],fac[neko],ifac[neko],ht[neko];
int spow(int m,int n)
{
	int b=1;
	for(;n;n>>=1,m=1ll*m*m%mod)if(n&1)b=1ll*b*m%mod;
	return b;
}
int ADD(int x,int y){return (x+=y)>=mod?x-mod:x;}
int C(int n,int m){if(n<m)return 0;return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
void initM(int n)
{
	fac[0]=ifac[0]=1;
	f(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=spow(fac[n],mod-2);
	rf(i,n-1,1)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
int main()
{
	int x,X,Y;
	scanf("%d",&n);
	initM(n+5);
	f(i,1,n+1){scanf("%d",&x);if(ht[x])X=ht[x],Y=i;ht[x]=i;}
	printf("%d\n",n);
	f(k,2,n+1)printf("%d\n",ADD(mod,ADD(C(n+1,k),mod-C(X+n-Y,k-1))));
	return 0;
}


Measured memory_bytes: 2304
a, b, c = map(int, input().split())
d = [a, b, c]
d.sort()

count = 0

while d[2] > d[1]:
    d[1] += 1
    d[0] += 1
    count += 1

while d[0] < d[1]-1:
    d[0] += 2
    count += 1

if d[0] == d[1]:
    print(count)
else:
    print(count+2)

Measured memory_bytes: 3188