akhauriyash/Code-Regression huggingface dataset:
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Scanner;

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

		int dataSet = scan.nextInt();
		ArrayList<String> ansList = new ArrayList<String>();

		for (int i = 0; i < dataSet; i++) {
			Point2D.Double a = new Point2D.Double(scan.nextDouble(), scan.nextDouble());
			Point2D.Double b = new Point2D.Double(scan.nextDouble(), scan.nextDouble());
			Point2D.Double c = new Point2D.Double(scan.nextDouble(), scan.nextDouble());
			Point2D.Double d = new Point2D.Double(scan.nextDouble(), scan.nextDouble());

			double  ab = (a.getX() > b.getX() ? Math.atan2(a.getY() - b.getY(), a.getX() - b.getX())
					: Math.atan2(b.getY() - a.getY(), b.getX() - a.getX()));

			double  cd = (c.getX() > d.getX() ? Math.atan2(c.getY() - d.getY(), c.getX() - d.getX())
					: Math.atan2(d.getY() - c.getY(), d.getX() - c.getX()));

			ansList.add(ab == cd ? "YES" :"NO");
		}

		for(String ans :ansList){
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
h, w = map(int, input().split())
n = 10
cost = []
for i in range(n):
    cost.append(list(map(int, input().split())))

for k in range(n):
    for i in range(n):
        for j in range(n):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

res = 0
for i in range(h):
    for j in map(int, input().split()):
        if j == -1:
            continue
        else:
            res += cost[j][1]
print(res)


Measured memory_bytes: 3064
#include <cstdio>
#include <queue>
#include <cstring>
#include <algorithm>

using namespace std;

int h, w;
int c[2222];
char g[22][22];

int* solve(int p) {
  queue<int> q; q.push(p);
  memset(c, -1, sizeof(c));
  c[p] = 0;
  int dx[] = {0,1,0,-1};
  int dy[] = {1,0,-1,0};
  while(!q.empty()) {
    p = q.front(); q.pop();
    for (int i = 0; i < 4; i++) {
      int x = p % 100 + dx[i], y = p / 100 + dy[i];
      if (x >= 0 && x < w && y >= 0 && y < h && g[y][x] == '.' && c[y*100+x] < 0) {
	c[y*100+x] = c[p] + 1;
	q.push(y*100+x);
      }
    }
  }
  return c;
}

int main(void) {
  scanf("%d%d", &h, &w);
  int x, y;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf(" %c", g[i] + j);
      if (g[i][j] == '.') {
	x = j;
	y = i;
      }
    }
  }

  int res = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (g[i][j] == '.') {
	res = max(res, *max_element(solve(i*100+j), c+2222));
      }
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
  k = 0
  while b != 0:
    r = a % b
    a, b = b, r
    k += 1
  return[a, k]
while True:
  x, y = list(map(int, input().split()))
  if x == 0: break
  if x < y:
    x, y = y, x
  ans = gcd(x, y)
  print(*ans)


Measured memory_bytes: 5612
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i;
  string s;
  cin >> s;
  n=s.size();
  for(i=0;i<n;i++)
    if(s[i]=='?'){
      cout << 'D';
    }else{
      cout << s[i];
    }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3376
#include <stdio.h>
#include <ctype.h>
int main(){
	char a[11],b[11],c[11];
	scanf("%s %s %s",a,b,c);
	printf("%c%c%c\n",toupper(a[0]),toupper(b[0]),toupper(c[0]));

	return 0;
}

Measured memory_bytes: 128
N, K, Q = gets.split(' ').map(&:to_i)
r = []
N.times {r << K - Q}
Q.times {
	ans_num = gets.to_i
  	r[ans_num - 1] += 1
}
r.each do |num|
	puts num > 0 ? "Yes" : 'No'
end

Measured memory_bytes: 3196
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

LL n, s;

vector<LL> find(LL x) {
	vector<LL> ret;
	for (LL i = 1; i * i <= x; i++) {
		if (x % i) continue;
		if (x % i == 0) {
			ret.push_back(i + 1);
			if (i == x / i) continue;
			ret.push_back(x / i + 1);
		}
	}
	sort(ret.begin(), ret.end());
	return ret;
}

LL calc(LL b, LL n)  {
	LL ret = 0;
	while (n) {
		ret += n % b;
		n /= b;
	}
	return ret;
}
int main()
{
	scanf("%lld %lld", &n, &s);
	if (n == s) {
		printf("%lld\n", n + 1);
		return 0;
	}
	vector<LL> Bs = find(ABS(n - s));
	for (LL b : Bs) {
		LL now = calc(b, n);
		if (now == s) {
			printf("%lld\n", b);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,d;
  cin>>n>>d;
  int count=1;
  while(true) {
    if(n>(d*2+1)*count) {
      count++;
    }
    else{
      break;
    }
  }
  cout<<count<<endl;
  return 0;
}


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

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

int m,n;

int imos[100010];

int main(){
    int i,j,k;
    int a,b;
    
    cin >> n;
    k=0;
    for (i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        imos[(a+k)%86400]++;
        k=(k+a+b)%86400;
    }
    copy(imos,imos+10800,imos+86400);
    
    for (i=1;i<=86400+10800;i++){
        imos[i]=imos[i-1]+imos[i];
    }
    int result=0;
    for (i=0;i<86400;i++){
        result = max(result,imos[i+10801]-imos[i]);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int A,B;
	cin>>A>>B;
	cout<<max(0, A-2*B)<<endl;
}

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

int main(){
  string S;
  cin >> S;
  const string sub= S.substr(2, S.size()-3);
  
  bool head= S.at(0)=='A';
  bool second_n_tail= islower(S.at(1)) && islower(S.back());
  int midlower= 0;
  int midC= 0;
  for(auto c:sub){
    if(islower(c)) { midlower++; }
    else if(c=='C'){ midC++; }
    else{ continue; }
  }
  bool mid= (midC==1 && midlower+ midC== sub.size());

  string ans= (head && second_n_tail && mid) ? "AC"
                                             : "WA";
  cout << ans << endl;
}

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

struct dice {
	int eye[6];
};

void rightroll(struct dice *a){
	int s = a->eye[0];
	a->eye[0] = a->eye[3];
	a->eye[3] = a->eye[5];
	a->eye[5] = a->eye[2];
	a->eye[2] = s;
}
void beyoroll(struct dice *a){
	int s = a->eye[0];
	a->eye[0] = a->eye[1];
	a->eye[1] = a->eye[5];
	a->eye[5] = a->eye[4];
	a->eye[4] = s;
}
void thisroll(struct dice *a){
	int s = a->eye[0];
	a->eye[0] = a->eye[4];
	a->eye[4] = a->eye[5];
	a->eye[5] = a->eye[1];
	a->eye[1] = s;
}
void leftroll(struct dice *a){
	int s = a->eye[0];
	a->eye[0] = a->eye[2];
	a->eye[2] = a->eye[5];
	a->eye[5] = a->eye[3];
	a->eye[3] = s;
}
void rsideroll(struct dice *a){
	int s = a->eye[1];
	a->eye[1] = a->eye[2];
	a->eye[2] = a->eye[4];
	a->eye[4] = a->eye[3];
	a->eye[3] = s;
}
void lsideroll(struct dice *a){
	int s = a->eye[1];
	a->eye[1] = a->eye[3];
	a->eye[3] = a->eye[4];
	a->eye[4] = a->eye[2];
	a->eye[2] = s;
}

void roll(struct dice *a,int upf[2]){
	int i;
	for (i = 0; i < 6; i++){
		if (a->eye[i] == upf[0])
			break;
	}
	switch (i){
	case 0:
		break;
	case 1:
		beyoroll(a);
		break;
	case 2:
		leftroll(a);
		break;
	case 3:
		rightroll(a);
		break;
	case 4:
		thisroll(a);
		break;
	case 5:
		leftroll(a);
		leftroll(a);
		break;
	}
	for (i = 0; i < 6; i++){
		if (a->eye[i] == upf[1])
			break;
	}
	switch (i){
	case 0:
		break;
	case 1:
		break;
	case 2:
		rsideroll(a);
		break;
	case 3:
		lsideroll(a);
		break;
	case 4:
		rsideroll(a);
		rsideroll(a);
		break;
	case 5:
		break;
	}
}

int main(void){
	struct dice a;
	int upf[100][2];
	int n=0;
	int i = 0;
	for (; i < 6; i++){
		scanf("%d", &a.eye[i]);
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d",&upf[i][0],&upf[i][1]);
	}

	for (i = 0; i < n; i++){
		roll(&a, upf[i]);
		printf("%d\n", a.eye[2]);
	}


	return 0;
}


Measured memory_bytes: 2072
# B - Frog 2
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float("inf")]*n
dp[0]=0
for i in range(n-1):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[n-1])

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

using namespace std;

int main() {
	vector<int> x(5);
	int c = 1;
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
		if (x[i] == 0) {
			cout << c;
		}
		c++;
	}
}

Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
using namespace std;

char s[11111];
int x, y;
int d1[32006][2], d2[32006][2];
vector<pair<int, int> > v;

int main() {
    scanf("%s", s+1);
    scanf("%d %d", &x, &y);

    int n;
    for (n = 1; s[n]; n++);
    n--;

    s[0] = s[1];
    int cnt = 0;
    int fuck = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == s[i-1]) {
            cnt++;
        }
        else {
            if (v.size() == 0 && s[i-1] == 'F') {
                fuck = 1;
            }
            v.push_back({ cnt,s[i-1] == 'F'} );
            cnt = 1;
        }
    }
    if (cnt) {
        if (v.size() == 0 && s[n] == 'F') {
            fuck = 1;
        }
        v.push_back({ cnt,s[n] == 'F' });
    }



    int flag = 0;
    vector<int> a, b;
    for (auto it : v) {
        if (it.second == 0) {
            flag = (flag+it.first)%2;
        }
        else {
            if (flag) b.push_back(it.first);
            else a.push_back(it.first);
        }
    }
    


    d1[16000][0] = 1;
    d2[16000][0] = 1;
    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j <= 32000; j++) {
            int aa = j-a[i] >= 0 ? d1[j-a[i]][i%2] : 0;
            int bb = j+a[i] <= 32000 ? d1[j+a[i]][i%2] : 0;
            if (fuck && i == 0) {
                bb = 0;
            }
            d1[j][(i+1)%2] = (aa | bb);
        }
    }
    for (int i = 0; i < b.size(); i++) {
        for (int j = 0; j <= 32000; j++) {
            int aa = j-b[i] >= 0 ? d2[j-b[i]][i%2] : 0;
            int bb = j+b[i] <= 32000 ? d2[j+b[i]][i%2] : 0;
            d2[j][(i+1)%2] = (aa | bb);
        }
    }

/*
    for (int it : a) printf("%d ", it);
    puts("");
    for (int it : b) printf("%d ", it);
    puts("");


    for (int i = 7990; i <= 8010; i++) {
        printf("%d ", i);
    }
    puts("");
    for (int i = 7990; i <= 8010; i++) {
        printf("%4d ", d2[i][0]);
    }
    puts("");
    for (int i = 7990; i <= 8010; i++) {
        printf("%4d ", d2[i][1]);
    }

    printf("\n%d %d\n", d1[x+8000][a.size()%2], d2[y+8000][b.size()%2]);
    */

    if (d1[x+16000][a.size()%2] && d2[y+16000][b.size()%2]) {
        puts("Yes");
    }
    else {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 896
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn main() {
    input! { n, s: [i64; n] };
    let mut ans = 0;
    for d in 1..n - 1 {
        let mut used = vec![false; n];
        used[0] = true;
        used[n - 1] = true;
        let mut acc = 0;
        let mut i = 1;
        while i * d < n
            && !used[i * d]
            && !used[n - 1 - i * d]
            && i * d != n - 1 - i * d
            && d < n - 1 - i * d
        {
            used[i * d] = true;
            used[n - 1 - i * d] = true;
            acc += s[i * d] + s[n - 1 - i * d];
            ans = max(ans, acc);
            i += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,ans=0;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(ll i=0;i<k;i++)
    {
        ans+=a[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3636
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

func main() {
	var sum int
	nk := scanIntNums()
	ms := scanIntNums()

	N := nk[0]
	K := nk[1]

	if K >= N {
		fmt.Println(0)
	} else {
		sort.Sort(sort.IntSlice(ms))
		for i := N - K - 1; i >= 0; i-- {
			sum += ms[i]
		}
		fmt.Println(sum)
	}
}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

Measured memory_bytes: 10368
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	int MAX = 1000000;
	int prime[];

	void eratosthenes(int max) {
		prime = new int[max + 1];
		Arrays.fill(prime, 1);
		prime[0] = prime[1] = 0;
		for (int i = 2; i * i <= max; i++) {
			if (prime[i] == 1) {
				for (int j = i * i; j <= max; j += i) {
					prime[j] = 0;
				}
			}
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		eratosthenes(MAX);

		L: while (true) {
			int a = sc.nextInt();
			int d = sc.nextInt();
			int n = sc.nextInt();
			if ((a | d | n) == 0) {
				break;
			}
			int cnt = 0;
			for (int i = a; ; i += d) {
				if (prime[i] == 1) {
					cnt++;
					if (cnt == n) {
						System.out.println(i);
						continue L;
					}
				}
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 25552
n=int(input())
a=input().split()
for i in range(0,n):
  a[i]=int(a[i])
answer=0
for j in range(1,n-1):
  if a[j]>a[j-1] and a[j]<a[j+1]:
    answer=answer+1
  elif a[j]<a[j-1] and a[j]>a[j+1]:
    answer=answer+1
print(answer)

Measured memory_bytes: 3064
#include <cstdio>

unsigned int n, a, t, f, u, i, v, j = 2;
constexpr unsigned int b[10] = {0, 0, 0, 1, 0, 2, 0, 3, 0, 0};
constexpr unsigned int c[3] = {2, 2, 6};

int main(){
	scanf("%d", &n);
	for(i=3; i<=n; i+=c[j]){
		++j;
		if(j == 3) j = 0;
		t = i;
		f = 0;
		for(;t!=0;){
			u = t / 10;
			v = b[t - u * 10];
			f |= 1 << v;
			if(!v) break;
			t = u;
		}
		if(f == 14) ++a;
	}
	printf("%d\n", a);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> num(N, 0);
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        num[a - 1]++;
    }
    sort(num.begin(), num.end(), greater<int>());
    int ans = 0;
    for(int i = K; i < N; ++i) {
        if(num[i] == 0)
            continue;
        ans += num[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int n, val; cin>>n;
    unordered_map<int, int> hmap;
    for(int i = 1; i < n; ++i){
    	cin>>val;
    	hmap[val-1]++;
    }
    for(int i = 0; i < n; ++i) cout<<hmap[i]<<'\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 11408
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;



int main(void) {
	long long int N, Q, cou, ans;
	cou = 0;
	ans = 0;
	string S;
	cin >> N >> Q >> S;
	vector<long long int> AC, l(Q), r(Q);
	for (long long int i = 0; i < Q; ++i) cin >> l[i] >> r[i];
	AC.push_back(0);
	for (long long int i = 1; i < N; i++) {
		if (S[i] == 'C'&&S[i - 1] == 'A')cou++;
		AC.push_back(cou);
		
	}
	for (int i = 0; i < Q; i++) {
		cout << AC[r[i] - 1] - AC[l[i] - 1] << endl;
	}

}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ll long long int
#define db long double
#define ull unsigned long long int
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
#define MAXN 1000005
 
using namespace std;

ll mod=1e9+7;
ll dp[3001][3001],pre[3001][3001];

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    int tests=1;
    // cin>>tests;
    while(tests--)
    {
    	ll i,j,n;
    	cin>>n;
    	string s;
    	cin>>s;
    	// dp[i][j] tells us the no of ways to construct the permutation using first
    	// i elements and the permutation ends with j
    	dp[1][1]=1;
    	rep(len,2,n)
    	{
    		rep(i,1,len-1)
    		{
    			pre[len-1][i]=(pre[len-1][i-1] + dp[len-1][i])%mod;
    			// pre[len-1][i]%=mod;
    		}
    		rep(end,1,len)
    		{
    			ll left,right;
    			if(s[len-2]=='<')
    			{
    				left=1;
    				right=end-1;
    			}
    			else
    			{
    				left=end;
    				right=len-1;
    			}
    			if(left<=right)
    			{
    				dp[len][end]+=(pre[len-1][right]-pre[len-1][left-1]+mod)%mod;
    				// dp[len][end]%=mod;
    			}
    		}
    	}

    	ll ans=0;
    	rep(i,1,n)
    	{
    		ans+=dp[n][i];
    		ans%=mod;
    	}
    	cout<<ans;


    }
    	return 0;
    
}

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

int main(void){
  int n,m,cnt=0;
  cin>>n>>m;
  string a[n],b[m];
  r(i,n)cin>>a[i];
  r(i,m)cin>>b[i];

  string answer="No";
  r(i,n-m+1){
    r(j,n-m+1){
      r(k,m){
        string tmp=a[i+k].substr(j,m);
        if(tmp!=b[k])break;
        if(k==m-1)answer="Yes";
      }
      if(answer=="Yes")break;
    }
    if(answer=="Yes")break;
  }

cout<<answer<<endl;





  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  static const double pi = 3.141592653589793;
  
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  
  double t,t1,t2;
  
  t1 = 30 * h + 0.5 * m;
  t2 = 6 * m;
  
  
  if(abs(t1-t2) > 180) t = 360 - (t1-t2);
  else t = (t1-t2);
  
  t /= 180; 
  
  double y = cos( M_PI * t );
  //cout << y << endl;
  
  double c = a*a + b*b - 2*a*b*y;
  
  c = sqrt(c); 
  
  cout << fixed << setprecision(20) << c;
}

Measured memory_bytes: 4160
<?php



fscanf(STDIN,"%d %d",$A,$B);



$sum_port = $A;
for($i=0;$i<$B;$i++){
    if($B == 1){
        echo "0\n";
    }else{
    if($sum_port >= $B){
        echo ($i+1)."\n";
    break;
    }
    $sum_port += $A-1;
    }
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#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 repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; 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; }

int main()
{
	string day[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string in;

	cin >> in;

	rep(i, 7) {
		if (day[i] == in)
			cout << 7 - i << endl;
	}

	return 0;
}

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

int main(void){
    ll n;
    cin >> n;
    string res;
    rep(i,32) {
        ll sign = (i%2==0 ? +1 : -1);
        if (n%(1LL<<(i+1))==0){
            res += "0";
        } else {
            res += "1";
            n -= sign * (1LL<<i);
        }
        if (n == 0) break;
    }
    reverse(all(res));
    cout << res << endl;
    return 0;
}


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

#define ll long long int
ll mod=1e9+7;

// vector<ll> g[200005];
// ll vis[200005];
// queue<ll> q;
// ll level[200005];

// void dfs(ll i)
// {
//     vis[i] = 1;
//     for(ll j=0;j<g[i].size();j++)
//     {
//         ll child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(ll i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         ll top = q.front();
//         ll len_adj = g[top].size();
//         ll j;
//         for(j=0;j<len_adj;j++)
//         {
//             ll v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

vector<ll> DecToBinary(ll num,ll trailing_zero, ll nbits)
{
    vector<ll> bits;
    while(num > 0)
    {
        bits.push_back(num%2);
        num /= 2;
    }

    if(trailing_zero == 1)
    {
        while(bits.size() < nbits)
        {
            bits.push_back(0);
        }
    }

    return bits;
}

long long int BinaryToDec(vector<ll> bits)
{
    ll number = 0;
    ll i;
    for(i=bits.size()-1;i>=0;i--)
    {
        number += (bits[i] * (long long)pow((ll)2 , i));
    }
    return number;
}



ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}



int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        
        ll arr[5];

        for(i=0;i<5;i++)
        {
            cin >> arr[i];
        }

        for(i=0;i<5;i++)
        {
            if(arr[i] == 0)
            {
                cout << i+1 << '\n';
                return 0;
            }
        }
    }

    
    
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve(long long N, long long K, std::vector<long long> X) {
  vector<int> xs[2];

  for( auto x : X){
    if( x == 0 ) K --;
    else if( x < 0 ) xs[0].push_back(-x);
    else if( x > 0 ) xs[1].push_back(x);
  }

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

  for( auto &x : xs ) x.push_back(0);

  for( auto &x : xs ) {
    sort(x.begin(), x.end());
  }
  ll ans = 1e18;
  for( int i = 0 ; i < xs[0].size() ; i++){
    int a = xs[0][i];
    if( K - i >= 0 && xs[1].size() > K - i ) {
      int b = xs[1][K - i];
      ans = min(ans, 1ll * a + b + min(a, b));
    }
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> x(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
  }
  solve(N, K, std::move(x));
  return 0;
}


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		//入力
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();
		int c = stdin.nextInt();

		//処理
		if ((a == b) && (b == c))
		{
			System.out.println("1");
		} else if ((a == b) || (a == c) || (b == c))
		{
			System.out.println("2");
		} else
		{
			System.out.println("3");
		}
	}
}


Measured memory_bytes: 20820
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		int num[] = new int[6];
		int answer = 0;
		int decTime = 0;
		int frontAddress = 0;
		diceClass dice =new diceClass();
		for (int i=0;i<6;i++){
			num[i] = scan.nextInt();
			dice.pos[i] = num[i];
		}
		decTime = scan.nextInt();
		int upSide[] = new int[decTime];
		int frontSide[] = new int[decTime];
		for(int i=0;i<decTime;i++){
			upSide[i] = scan.nextInt();
			frontSide[i] = scan.nextInt();
			for(int ii=0;ii<6;ii++){
				if(frontSide[i] == num[ii]){
					frontAddress = ii;
				}
			}
			for(int ii=0;ii<6;ii++){
				if(upSide[i] == num[ii]){
					answer = dice.rightNumber(ii,frontAddress);
					System.out.println(num[answer]);
				}
			}
		}
	}
}
class diceClass{	
	int pos[] = new int[6];
	int up0[] = {1,2,4,3};
	int up1[] = {0,3,5,2};
	int up2[] = {0,1,5,4};
	int up3[] = {0,4,5,1};
	int up4[] = {0,2,5,3};
	int up5[] = {1,3,4,2};
	public diceClass(){

	}

	public int rightNumber(int up,int ri){
		int[] temp = new int[4];
		int front = 0;
		if(up == 0){
			temp = (int[])up0.clone();
		}
		else if(up == 1){
			temp = (int[])up1.clone();
		}
		else if(up == 2){
			temp = (int[])up2.clone();
		}
		else if(up == 3){
			temp = (int[])up3.clone();
		}
		else if(up == 4){
			temp = (int[])up4.clone();
		}
		else if(up == 5){
			temp = (int[])up5.clone();
		}
		for(int i =0;i<4;i++){
			if(temp[i] == ri){
				front = i+1;
				if(front == 4){
					front = 0;
				}
				break;
			}
		}
		return temp[front];
	}
}

Measured memory_bytes: 26256
N=int(input())
S = [input() for i in range(N)]

m, a, r, c, h, zero = 0,0,0,0,0,0
for l in range(N):
	if S[l][0] == 'M':
		m += 1
	elif S[l][0] == 'A':
		a += 1
	elif S[l][0] == 'R':
		r += 1
	elif S[l][0] == 'C':
		c += 1
	elif S[l][0] == 'H':
		h += 1
P = [0,0,0,0,0,0,1,1,1,2]
Q = [1,1,1,2,2,3,2,2,3,3]
R = [2,3,4,3,4,4,3,4,4,4]
D = [m,a,r,c,h]
ans = 0
for i in range(10):
	ans += D[P[i]] * D[Q[i]] * D[R[i]]
print(ans)



Measured memory_bytes: 9772
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int m;
    cin >> m;
    cout << 48-m;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    char name[n];
    cin>>name;
    int sum=0;
    for(i=0;i<n;i++)
    {
        sum=sum+name[i];
    }
    //cout<<"sum = "<<sum<<endl;
    int sum2=0;
    for(i=0;i<(n/2);i++)
    {
        sum2=sum2+name[i];
    }
    if((2*sum2)==sum)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int x[] = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = sc.nextInt();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        }
    }

}

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

struct Card {
  int h, w, s = 0;
  Card(){};
  Card(int _h, int _w) {

    h = _h;
    w = _w;
  };
};

int main() {
  int h, w, d;
  cin >> h >> w >> d;
  int n = h * w;
  vector<Card> v(n + 1);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x;
      cin >> x;
      v[x] = Card(i, j);
    }
  }
  int q;
  cin >> q;
  vector<int> l(q), r(q);
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  for (int j = d + 1; j <= n; j++) {
    v[j].s = v[j - d].s + abs(v[j].h - v[j - d].h) + abs(v[j].w - v[j - d].w);
  }

  for (int i = 0; i < q; i++) {

    cout << v[r[i]].s - v[l[i]].s << endl;
  }

  // for (int i = 1; i <= n; i++) {
  //   cout << i << " " << v[i].h << " " << v[i].w << " " << v[i].s << endl;
  // }
}


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

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


int main(void){
  ll h, n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  if (accumulate(a.begin(), a.end(), 0) < h) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 700;
		String S = sc.next();
		String[] s2 = S.split("");

		if (s2[0].equals("o"))
			m += 100;
		if (s2[1].equals("o"))
			m += 100;
		if (s2[2].equals("o"))
				m += 100;
		System.out.println(m);
	}
}

Measured memory_bytes: 21844
use std::io::Read;
use std::cmp::max;

fn calc(p: &[(usize, usize)], dp: &mut Vec<usize>) -> usize {
    if p.len() == 0 {
        return 0;
    }
    if p.len() == 1 {
        return *dp.last().unwrap() + p[0].1;
    }
    let n = p.len();
    let m = n / 2;
    let save = dp.clone();
    for &(a, b) in &p[..m] {
        for i in (a..dp.len()).rev() {
            dp[i] = max(dp[i], dp[i - a] + b);
        }
    }
    let x = calc(&p[m..], dp);
    let mut dp = save;
    for &(a, b) in &p[m..] {
        for i in (a..dp.len()).rev() {
            dp[i] = max(dp[i], dp[i - a] + b);
        }
    }
    let y = calc(&p[..m], &mut dp);
    max(x, y)
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let w: usize = it.next().unwrap().parse().unwrap();
    let mut p = vec![];
    for _ in 0..n {
        let a: usize = it.next().unwrap().parse().unwrap();
        let b: usize = it.next().unwrap().parse().unwrap();
        p.push((a, b));
    }
    let ans = calc(&p, &mut vec![0; w]);
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {
	
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		new Main().run();
	}
	
	public void run() throws NumberFormatException, IOException
	{
		BufferedReader file = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(file.readLine());
		char[][] strs = new char[N][];
		int b = 0;
		int ba = 0;
		int a = 0;
		int cnt = 0;
		for(int i = 0;i<N;i++)
		{
			strs[i] = file.readLine().trim().toCharArray();
			if(strs[i][0] == 'B'){
				if(strs[i][strs[i].length-1]=='A')
					ba++;
				else
					b++;
			}
			else if(strs[i][strs[i].length-1]=='A')
				a++;
			for(int j = 0;j<strs[i].length-1;j++)
			{
				if(strs[i][j]=='A' &&strs[i][j+1] == 'B')
					cnt++;
			}
		}
		if(a!=0)
		{
			a--;
			cnt+=ba;//now ends with a
			if(b!=0)
			{
				b--;
				cnt++;
			}
			cnt+=Math.min(a,b);
		}else if(ba!=0){
			cnt+=ba-1;
			if(b!=0)
				cnt++;
		}
		System.out.println(cnt);
	}
	
}


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

int main(){
  int _w,_d, w[10], d[10];
  while(cin >> _w >> _d, _w){
    for( int i = 0 ; i < _w; ++i ) cin >> w[i];
    for( int i = 0 ; i < _d; ++i ) cin >> d[i];

    sort(w, w + _w, greater<>());
    sort(d, d + _d, greater<>());

    int i = 0, j = 0, sum = 0;;
    for(;;){
      if(i >= _w){
        if(j >= _d) break;
        else{
          sum += d[j++];
        }
      }else if(j >= _d){
        if(i >= _w) break;
        else{
          sum += w[i++];
        }
      }else{
        if(w[i] == d[j]){
          ++i;
          sum += d[j++];
        }else if(w[i] > d[j]){
          sum += w[i++];
        }else{
          sum += d[j++];
        }
      }
    }
    cout << sum << endl;
  }

  return 0;
}


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

int main() {

    int N, A, B;
    cin >> N >> A >> B;
    int sum = 0;

    for (int i = 0; i <= N; i++) {
        //cout << "case: i = " << i << endl;
        string str_i = to_string(i);
        int sum_i = 0;
        for (int j = 0; j < str_i.size(); j++)
            sum_i += str_i.at(j) - '0';
        
        if (A <= sum_i && sum_i <= B) {
            sum += i;
            //cout << "+" << i << endl;
        }
    }
    cout << sum << endl;
}

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

int dp[41][45]; //?§??????°,??????->?????????
typedef tuple<int,int,int> T;
vector<T> V;

int main(){
    int N,M,L;
    cin>>N>>M>>L;
    for(int i=0;i<M;i++){
        int d,a,k,t;
        cin>>d>>a>>k>>t;
        V.emplace_back(a+d*(N+1),k,t);
    }
    sort(V.begin(),V.end());
    int c=0;
    for(auto &v:V){
        int a=get<0>(v),k=get<1>(v),t=get<2>(v);
        c++;
        for(int l=1;l<=L&&l<=c;l++){
            dp[l][a+k-1]=max(dp[l][a+k-1],dp[l-1][a-1]+t);
            for(int aa=a+k-1;aa<5*(N+1);aa++){
                dp[l][aa]=max(dp[l][aa],dp[l][aa-1]);
            }
        }
    }
    int ans=0;
    for(int l=0;l<=L;l++) ans=max(ans,dp[l][5*(N+1)-1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
#define mod             1000000007
#define rep(i,n)        for (int i = 0; i < n; ++i)
#define REP(i,k,n)      for (int i = k; i < n; ++i)
#define REPR(i,k,n)     for (int i = k; i >= n; --i)
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define pii             pair<int,int>
#define mp              make_pair
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll              long long
#define w(x)            int x; cin>>x; while(x--)
#define mem(a, b)       memset(a, (b), sizeof(a))
#define setbits(x)      __builtin_popcountll(x)
  
void solve() {
    long long a[1001],m,n,an=0,su=0,i;
	cin>>n>>m;
	for(i=0;i<n;i++){
        cin>>a[i];
        su+=a[i];
    }
	while(i--){
		if(a[i]*4*m>=su) an++;
	}
	cout<<(an>=m?"Yes":"No")<<endl;
}
 
 
int main() {
    fast
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,g,b;
    cin>>r>>g>>b;
    int x=r*100;
    int y=g*10;
    if((x+y+b)%4==0)
        cout<<"YES";
    else
        cout<<"NO";
}



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

int main(){
  int a,b,c,d,e,f,i,j,k,l,s=0,w=100;
  cin>>a>>b>>c>>d>>e>>f;a*=100;b*=100;
  for(i=0;i<=f;i+=a)
  for(j=0;i+j<=f;j+=b)
  for(k=0;i+j+k<=f;k+=c)
  for(l=0;i+j+k+l<=f;l+=d)
  if((k+l)*(100+e)<=e*(i+j+k+l)&&s*(i+j+k+l)<=(k+l)*(w+s)) w=i+j,s=k+l;
  cout<<w+s<<" "<<s;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream> 
using namespace std; 
int main(){ 
char a; 
while(1){ 
scanf("%c",&a);
 if(isalpha(a)){ 
if(islower(a))cout<<(char)toupper(a);
 else if(isupper(a))cout<<(char)tolower(a);
 } else {
cout<<a;
} 
if(a=='\n')break; 
} 
return 0;
 } 

 



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(ll, n, a, b);
  ll ans;
  if ((b - a) % 2 == 0)
    ans = (b - a) / 2;
  else
    ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
  cout << ans << endl;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, m;
    cin >> n >> m;
    ll a[n];
    std::vector<ll> v;
    rep(i, n) {
        cin >> a[i];
        v.push_back(a[i]);
    }
    Sort_rev(v);
    ll all = accumulate(ALL(v), 0LL);
    ll ans = 0;
    rep(i, n) {
        if ( v[i]*4*m >= all ) {
            ans++;
        } else {
            break;
        }
    }

    cout << ( (ans >= m) ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  char c[2][3];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++)
      cin >> c[i][j];
  }
  if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}


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

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x; }
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  int x;
  cin >> x;
  Sieve sieve(1e6);
  for (int i = x; i < 1e6; ++i) {
    if (sieve.isPrime(i)) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4732
#include<stdio.h>
#define MN 2000005
int N,A[MN],B[MN],C[10005],i,j,k=-1;
void cs()
{
	for(i=0;i<N;i++)C[A[i]]++;
	for(i=1;i<=k;i++)
		C[i]+=C[i-1];
	for(j=N-1;j>=0;j--)
	{
		B[C[A[j]]-1]=A[j];
		C[A[j]]--;
	}
}
int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
		k=k>A[i]?k:A[i];
	}
	cs();
	for(i=0;i<N;i++)
		printf("%d%c",B[i],i==N-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 16264
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define asort(array) sort(array.begin(), array.end())
#define vunique(v) unique(v.begin(), v.end());
#define MAX_V 1000
#define INF 1e18
long long d[MAX_V];
struct edge {
	long long from, to, cost;
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M;
	cin >> N >> M;
	fill(d, d + N, INF);
	d[0] = 0; // start

	edge E[M];

	for(int i = 0; i < M; i++) {
		long long a, b, c;
		cin >> a >> b >> c;
		E[i].from = a - 1;
		E[i].to = b - 1;
		E[i].cost = -c;
	}

	for(int i = 0; i < 2 * N; i++) {
		for(int j = 0; j < M; j++) {
			edge e = E[j];
			if(d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if(i >= N - 1 && e.to == N - 1) {
					cout << "inf" << endl;
					return 0;
				}
			}
		}
	}
	cout << -d[N - 1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int N;
    double T, A;
    cin >> N >> T >> A;
    vector<double> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    double ans = 1e10;
    int ind = -1;
    for(int i = 0; i < N; i++){
        double temp = T - 0.006 * H[i];
        if(ans > abs(A - temp)){
            ans = abs(A - temp);
            ind = i;
        }
    }
    cout << ind + 1 << endl;
}

Measured memory_bytes: 3768
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		
		int a;
		int min=1000000;
		int max=-1000000;
		long sum=0;
		int f=sc.nextInt();
		for(;sc.hasNext();){
			a=sc.nextInt();
			sum+=a;
			if(a<=min)min=a;
			if(a>=max)max=a;
			
		}
		System.out.printf("%d %d %d%n",min,max,sum);
		
	}
}

Measured memory_bytes: 33520
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    vector<vector<int>> v(3, vector<int>(3, 0));
    REP(i, 3){
        int c1, c2, c3;
        cin >> c1 >> c2 >> c3;
        v[i][0] = c1;
        v[i][1] = c2;
        v[i][2] = c3;
    }

    int b1 = v[0][0], b2 = v[0][1], b3 = v[0][2];
    bool flag = true;
    int a2 = v[1][0] - b1, a3 = v[2][0] - b1;
    if(a2 != v[1][1] - b2 || a2 != v[1][2] - b3) flag = false;
    if(a3 != v[2][1] - b2 || a3 != v[2][2] - b3) flag = false;

    if(flag) Yes();
    else No();
}

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

Measured memory_bytes: 256