akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define MAXN 100005
using namespace std;
int dis1[MAXN], disn[MAXN];
bool vst1[MAXN], vst2[MAXN];
vector<int> g[MAXN];
int n, fennec, snuke;
void dfs1(int v, int cost) {
	dis1[v] = cost;
	vst1[v] = 1;
	for(int i = 0; i < g[v].size(); i++) {
		if(!vst1[g[v][i]]) {
			dfs1(g[v][i], cost+1);
			vst1[g[v][i]] = 0;
		}
	}
}

void dfs2(int v, int cost) {
	disn[v] = cost;
	vst2[v] = 1;
	for(int i = 0; i < g[v].size(); i++) {
		if(!vst2[g[v][i]]) {
			dfs2(g[v][i], cost+1);
			vst2[g[v][i]] = 0;
		}
	}
} 

int main () {
	int u, v;
	scanf("%d", &n);
	for(int i = 1; i < n; i++) {
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs1(1, 0);
	dfs2(n, 0);
	for(int i = 1; i <= n; i++) {
		if(dis1[i] <= disn[i]) fennec++;
		else snuke++;
	}
	if(fennec > snuke) printf("Fennec\n");
	else printf("Snuke\n");
	return 0;
}

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

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

const int N = 210;

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int ans = 0;
  while (ans * a - ans + 1 < b) ++ans;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
    int K = sc.nextInt();
    double[] d = new double[N];
    for (int i = 0; i < N; i++) {
       d[i] = 1.0 + 0.5*(sc.nextInt()-1);
    }
    double max = 0;
    for (int i = 0; i < K; i++) {
      max += d[i]; 
    }
    double total = max;
    for (int i = 0; i < N-K; i++) {
      total = total -d[i] + d[i+K];
      max = Math.max(max, total);
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 72700
#include <iostream>
#include <string>

using namespace std;

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

  int taro = 0, hanako = 0;
  for (int i = 0; i < n; i++) {
    string t_str, h_str;
    cin >> t_str >> h_str;

    if (t_str > h_str) {
      taro += 3;
    } else if (t_str < h_str) {
      hanako += 3;
    } else {
      taro++;
      hanako++;
    }
  }

  cout << taro << " " << hanako << endl;

  return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define IO ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
using namespace std;

int n;
string str[55];
int mat[55][30];

int main()
{
	IO
	cin>>n;
	for(int i = 0; i < n; ++i){
		cin>>str[i];
		for(int j = 0; j < int(str[i].size()); ++j){
			mat[i][int(str[i][j]-'a')]++;
		}
	}
	
	for(int i = 0; i < 26; ++i){
		int mini = INT_MAX;
		for(int j = 0; j < n; ++j){
			mini = min(mini,mat[j][i]);
		}
		while(mini--){
			cout<<char(i+'a');
		}
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import math
import bisect


def main():
    n = int(input())
    s = input()
    ans = 0
    for i in range(n):
        if i + 3 <= n:
            if s[i:i+3] == 'ABC':
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()


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

int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        if(mp.find(x)!=mp.end()){
            cout << "NO" << endl;
            return 0;
        }
        mp[x]++;
    }
    cout << "YES" <<endl;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<string, int> mp;
  REP(i, n){
    string s;
    cin >> s;
    mp[s]++;
  }
  // get max value
  int mv = 0;
  for (auto v : mp){
    mv = max(v.second, mv);
  }
  vector<string> ans;
  for (auto v : mp){
    if (v.second == mv) ans.push_back(v.first);
  }
  sort(ans.begin(), ans.end());
  for (auto v : ans) cout << v << endl;
  return 0;
}



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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int turn = 0;
    while(a > 0 && c > 0) {
        if(turn == 0) {
            c -= b;
        } else {
            a -= d;
        }
        turn++;
        turn %= 2;
    }
    if(a <= 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

#define M 1000000007


unsigned long long power(int m, int n) {
    unsigned long long x;
    if (n == 0) return 1;
    if (n % 2) {
        x = power(m, n-1);
        return (x * m) % M;
    }
    else {
        x = power(m, n/2);
        return (x * x) % M;
    }
}

int main() {
    int m, n, i;
    unsigned long long x;

    scanf("%d %d", &m, &n);

    printf("%llu\n", power(m, n));

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	vi a(N), b(N), c(N);
	rep(i, N) cin >> a[i] >> b[i] >> c[i]; // i(0-ind)日目に海で泳ぐなどしたときに得る幸福度
	vi A(N + 1), B(N + 1), C(N + 1); // i(0-ind)日目に海で泳ぐなどしたときのi日目までの幸福度の合計の最大値
	A[0] = a[0]; B[0] = b[0]; C[0] = c[0];
	rep2(i, 1, N) {
		A[i] = max(B[i - 1], C[i - 1]) + a[i];
		B[i] = max(C[i - 1], A[i - 1]) + b[i];
		C[i] = max(A[i - 1], B[i - 1]) + c[i];
	}
	cout << max(max(A[N - 1], B[N - 1]), C[N - 1]);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

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

	int flg = 0;
	int res = 1;
	for (int i = 0; i < N - 1; i++) {
		if (flg == 0) {
			if (a[i] < a[i + 1]) {
				flg = 1;
			}
			if (a[i] > a[i + 1]) {
				flg = -1;
			}
		} else if (flg == 1) {
			if (a[i] > a[i + 1]) {
				res++;
				flg = 0;
			}
		} else if (flg == -1) {
			if (a[i] < a[i + 1]) {
				res++;
				flg = 0;
			}
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_rpw_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    s = s_input()
    t = s_input()

    len_s = len(s)

    for i in range(len_s-1):
        if s[i] != t[i]:
            No()
            exit()

    Yes()

if __name__ == '__main__':
    main()


Measured memory_bytes: 68348
#include <iostream>
#include <string>


using namespace std;


int main()
{
	string s, p;
	int mem;
	int i, j;

	cin >> s >> p;

	// 処理
	i = j = 0;
/*	while(j < p.length()){
		if(s[i % s.length()] == p[j]){
			i++;	j++;
			if(j == 1)
				mem = i;
		}else{
			if(s.length() <= i){
				cout << "No" << endl;
				return 0;
			}
			if(!j)
				i++;
			else
				i = mem;
			j = 0;
		}
	}
	cout << "Yes" << endl;
*/

	do{
		if(s[i % s.length()] == p[j]){
			i++;	j++;
			if(j == 1)
				mem = i;
		}else{
			if(!j)
				i++;
			else
				i = mem;
			j = 0;
		}
	}while((j || i < s.length()) && j < p.length());

	if(j)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3216
import java.io.*;
import java.util.StringTokenizer;

import static java.lang.Math.*;

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

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      final int n = in.nextInt();
      final int l = in.nextInt();

      int total = 0;
      for (int i = 0; i < n; i++) {
        total += l + i;
      }

      int res = 0;
      for (int i = 0; i < n; i++) {
        int t = 0;
        for (int j = 0; j < n; j++) {
          if(j != i) {
            t += l + j;
          }
        }
        if(abs(total - res) > abs(total - t)) res = t;
      }

      final int ans = res;
      out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  static class InputReader implements AutoCloseable {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }
    public String next() {
      if (st == null || !st.hasMoreTokens()) {
        try { st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return st.nextToken();
    }
    public int nextInt() { return Integer.parseInt(next()); }
    public long nextLong() { return Long.parseLong(next()); }
    int[] mapInt(int len) {
      int[] ret = new int[len];
      for (int i = 0; i < len; i++) ret[i] = Integer.parseInt(next());
      return ret;
    }
    long[] mapLong(int len) {
      long[] ret = new long[len];
      for (int i = 0; i < len; i++) ret[i] = Long.parseLong(next());
      return ret;
    }
    @Override public void close() throws IOException { br.close(); }
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n,x;cin>>n>>x;
  vector<ll> m(n);
  ll minn=INF;
  ll ans=n;
  rep(i,n){
    cin>>m[i];
    x-=m[i];
    minn=min(minn,m[i]);
  }

  cout<<ans+x/minn<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N;
  long long x;
  cin>>N>>x;
  long long a[N+1];
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  sort(a,a+N);
  if(a[0]>x){
    cout<<0<<endl;
    return 0;
  }
  int sum=0,ans=0;
  for(int i = 0;i<N;i++){
    sum+=a[i];
    if(sum>x){
      break;
    }
    if(sum==x){
      ans++;
      break;
    }
    ans++;
  }
  if(sum<x){
    ans--;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
 int N;
 cin >> N;
 
 if (N % 1000 > 0){
     cout << 1000 - (N % 1000) << endl;
 }
 else {
     cout << 0 << endl;
 }
}


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

int main() {
  long long k,n;
  cin >> k >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  long long ans = 0;
  vector<long long> kyori(n);
  for(long long i = 0; i < n; i++){
    if(i == n - 1){
      kyori[i] = k - a[i] + a[0];
    }else{
      kyori[i] = a[i + 1] - a[i];
    }
  }
  sort(kyori.begin(), kyori.end());
  for(long long i = 0; i < n - 1; i++){
    ans += kyori[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                int A = int.Parse(Console.ReadLine());
                int B = int.Parse(Console.ReadLine());
                Console.WriteLine(A + B);
            }
        }
    }
}

Measured memory_bytes: 13140
package main

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

func main() {
	sc = initScanner(os.Stdin)
	a, b := scanInt(sc), scanInt(sc)
	fmt.Println(resolve(a, b))
}

func resolve(a, b int) int {
	count := 0
	for i := a; i <= b; i++ {
		s := strconv.Itoa(i)
		if isPalindrome(s) {
			count++
		}
	}
	return count
}

func isPalindrome(s string) bool {
	ss := strings.Split(s, "")
	for i := 0; i < len(ss)/2; i++ {
		if ss[i] != ss[len(s)-i-1] {
			return false
		}
	}
	return true
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


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

using namespace std;

int main() {
  int n;
  string s;
  int ans = 0;

  cin >> s;
  int len = s.length();

  cout << s.substr(0,4) << " " <<s.substr(4,8)  << endl;

  return 0;
}


Measured memory_bytes: 256
class Tree():
    def __init__(self, n, edge):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - 1].append(e[1] - 1)
            self.tree[e[1] - 1].append(e[0] - 1)

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.order = []
        self.order.append(root)
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj]

    def diam(self):
        u = self.depth.index(max(self.depth))
        dist_u = [None for _ in range(N)]
        dist_u[u] = 0
        stack = [u]
        while stack:
            node = stack.pop()
            for adj in self.tree[node]:
                if dist_u[adj] is None:
                    dist_u[adj] = dist_u[node] + 1
                    stack.append(adj)
        d = max(dist_u)
        v = dist_u.index(d)
        return d, u, v

import sys
input = sys.stdin.readline

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]
T = Tree(N, E)
T.setroot(0)
d, _, _ = T.diam()

print('First' if d % 3 != 1 else 'Second')

Measured memory_bytes: 93044
N, M = map(int, input().split())
H = list(map(int, input().split()))
P = [1] * (N+1)
P[0] = 0
for m in range(M):
    A, B = map(int, input().split())
    Ha, Hb = H[A-1], H[B-1]
    if Ha > Hb:
        P[B] = 0
    elif Ha < Hb:
        P[A] = 0
    elif Ha == Hb:
        P[A] = 0
        P[B] = 0

print(sum(P))

Measured memory_bytes: 84988
#include<stdio.h>

int main(void){
	
	int n;
	while(scanf("%d", &n) && n){
		int s = 5,go = 0;
		while(1){
			if(s>n)break;
			go += n/s;
			s *= 5;
		}
		
		printf("%d\n",go);
		
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_H = 200, MAX_W = 200;

int H, W;
int c[10][10];
int A[MAX_H][MAX_W];

int main() {
    cin >> H >> W;
    REP(i, 10) {
        REP(j, 10) cin >> c[i][j];
    }
    REP(i, H) {
        REP(j, W) cin >> A[i][j];
    }
    
    REP(k, 10) {
        REP(i, 10) {
            REP(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
        }
    }

    int min_mp = 0;
    REP(i, H) {
        REP(j, W) {
            if (A[i][j] != -1) min_mp += c[A[i][j]][1];
        }
    }
    PRINT(min_mp);
    return 0;
}

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

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

Measured memory_bytes: 1792
N, K = map(int, input().split())
mod = 998244353
D = []
dp = [0] * (N+1)
for i in range(K):
    L, R = map(int, input().split())
    D.append([L, R])

dp[0] = 1
a = 0
for i in range(N):
    a += dp[i]
    a %= mod
    for d in D:
        if i + d[0] > N:
            continue
        dp[i + d[0]] += a
        dp[i + d[0]] %= mod
        if i + d[1] + 1 > N:
            continue

        dp[i + d[1] + 1] -= a
        dp[i + d[1] + 1] %= mod


print(dp[N-1])



Measured memory_bytes: 16852
#include "bits/stdc++.h"
using namespace std;

const int N=200;

int n,m,q,arr[N],a[N],b[N],c[N],d[N],ans;

void f(int i,int pv)
{
	if(i==n+1)
	{
		int cost=0;
		for(int i=0;i<q;i++)
		{
			if(arr[b[i]]-arr[a[i]]==c[i]) cost+=d[i];
		}
		ans=max(ans,cost);
		return;
	}
	for(int j=pv;j<=m;j++)
	{
		arr[i]=j;
		f(i+1,j);
	}
}

int main()
{
	cin>>n>>m>>q;
	for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	f(1,1);
	cout<<ans;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int A,B,C,d=0;
	cin >> A >> B >> C;
	for(int i=1;i<1000000;i++){
		d=d+A;
		if(d%B==C){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

using namespace std;





int main(){
    
    int N, H;
    cin >> N >> H;
    vector<int> a(N);
    vector<int> b(N);
    int amax = 0;
    priority_queue<int> pq;
    
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        pq.push(b[i]);
        amax = max(amax, a[i]);
    }
    
    
    int ans = 0;

    while (H > 0) {
        if (pq.top() > amax && !pq.empty()) {
            ans += 1;
            H -= pq.top();
            pq.pop();
        }else{
            if (amax == 1) {
                ans += H;
                H = 0;
            }else{
                if (H%amax == 0) {
                    ans += H/amax;
                }else{
                    ans += H/amax;
                    ans += 1;
                }
                H = 0;
            }
        }
            
    }
    
    cout << ans << endl;
    
    
    
}





Measured memory_bytes: 1660
#include <iostream>

int main(){
  int S = 0;
  int W = 0;
  
  std::cin >> S >> W;
  
  if( S <= W ){
    std::cout << "unsafe" << std::endl;
  }
  else{
    std::cout << "safe" << std::endl;
  }
  
  return 0;
}

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

int main(){
  string str;
while(cin >> str){
 
  int JOI_counter=0;
  int IOI_counter=0;
  for(int i =0; i < str.size()-2; i++){
   
    if(str.at(i) == 'J'&&str.at(i+1) == 'O'&&str.at(i+2)=='I'){
      JOI_counter++;
    }
    else if(str.at(i) == 'I'&&str.at(i+1) == 'O'&&str.at(i+2)=='I'){
      IOI_counter++;
    }
  
}
	cout << JOI_counter << endl;
    cout << IOI_counter << endl;
}
}
  





Measured memory_bytes: 3212
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val s = sc.next()
  val t = sc.next()
  
  val ans = (0 to s.length-1).find(i => s == turn(t, i))
  ans match {
    case Some(_) => println("Yes") 
    case None => println("No") 
  }
  
  def turn(origin: String, cnt: Int): String = {
    var s = origin
    for(i <- 1 to cnt) {
      s = (s.last + s).dropRight(1)
    }
    s
  }
}

Measured memory_bytes: 56748
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

ans = 0
s = 0
for i in range(n):
    s += a[i]
    if x < s:
        break
    elif i < n - 1 or s == x:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int m,n,ans;
int ma[10003];
int ha[503][2];
int dp[503][10003];
int main(){
	scanf("%d%d",&m,&n);
	for(int i = 0;i < m;i++){
		scanf("%d",&ma[i]);
	}
	sort(ma,ma + m,greater<int>());
	for(int i = 1;i < m;i++)ma[i] += ma[i-1];
	for(int i = 0;i < n;i++){
		scanf("%d%d",&ha[i][0],&ha[i][1]);
	}
	for(int i = 0;i <= n;i++){
		for(int j = 1;j <= m;j++){
			dp[i][j] = INF;
		}
	}
	for(int i = 1;i <= ha[0][0];i++){
		dp[1][i] = ha[0][1];
		ans = max(ans,ma[i-1]-dp[1][i]);
	}
	for(int i = 2;i <= n;i++){
		for(int j = 1;j <= m;j++){
			dp[i][j] = min(dp[i-1][j],ha[i-1][1]+dp[i-1][max(0,j-ha[i-1][0])]);
			ans = max(ans,ma[j-1]-dp[i][j]);
		}
	}
	printf("%d\n",ans);
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
		//	printf("%d ",dp[i][j]);
		}
		//printf("\n");
	}
	return 0;
}


Measured memory_bytes: 20828
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    std::cout << std::fixed << std::setprecision(10);

    int T, X;
    cin >> T >> X;
    double ans = 0.0;

    ans = (double)T / (double)X;
    cout << ans << endl;
    return (0);
}

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

int n;

int32_t main() {
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
    {
        cout<<"hon";
        return 0;
    }
    else if(n==0 || n==1 || n==6 || n==8)
    {
        cout<<"pon";
        return 0;
    }
    else{
        cout<<"bon";
    }
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int A[2000001],H=0;
void maxHeapify(int *A,int i){
  int largest,l,r,tmp;
  l = 2*i;
  if(2*i+1 <= H)r = 2*i+1;
  else r = NULL;
  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest] && r != NULL)largest = r;

  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i=H/2;i>0;i--)maxHeapify(A,i);
}

void insert(int *A,int k){
  int i,tmp;
  H++;
  i = H;
  A[i] = k;
  while(A[i] > A[i/2] && i/2 > 0){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i/2;
  }
}

int extractMax(int *A){
  int a;
  if(H<1)exit(2);
  a = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(A,1);
  return a;
}

int main(){
  int i,x;
  char c[20];
  while(1){
    scanf("%s",c);
    if(c[0]=='i'){
      scanf("%d",&x);
      insert(A,x);
    }
    else if(c[0]=='e'){
      if(c[1]=='x')
	printf("%d\n",extractMax(A));
      else if(c[1]=='n')
	break;
    }
  }

  return 0;
}



Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>b){
		cout<<"a > b"<<endl;
	}
	else if(a<b){
		cout<<"a < b"<<endl;
	}
	else{
		cout<<"a == b"<<endl;
	}
	return 0;
}




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

int main(){
  char c;
  cin>>c;
  if(c!='A'){cout<<"WA"<<endl;return 0;}
  cin>>c;
  if(c<'a'||c>'z'){cout<<"WA"<<endl;return 0;}
  for(;cin>>c;) if(c=='C') break;
  if(!(cin>>c)){cout<<"WA"<<endl;return 0;}
  if(c<'a'||c>'z'){cout<<"WA"<<endl;return 0;}
  for(;cin>>c;) if(c<'a'||c>'z'){cout<<"WA"<<endl;return 0;}
  cout<<"AC"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
#include <random>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){

	int N;
	cin >> N;

	map <int, int> mp[N];

	rep(N, i)
	{
		string s;
		cin >> s;
		for (char c : s)
		{
			mp[i][c-'a']++;
		}
	}

	string ans = "";

	rep(26, i)
	{
		int m = INF;
		rep(N, n)
		{
			m = min(m, mp[n][i]);
		}

		rep(m, mm)
		{
			put(char('a'+i));
		}
	}

	putln("");


}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int in , blue, red, ans = 0;
    cin >> in >> blue >> red;
    if (blue == 0)
    {
        cout << 0 << endl;
        return (0);
    }
    ans = in / (blue + red) * blue;
    ans += in % (blue + red) > blue ? blue : in % (blue + red);
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define int long long int 

void solve(int arr[],int n){

    unordered_map<int,int> mp;
    for(int i=0;i<n;i++){
        mp[arr[i]]++;
    }

    int all=0;
    for(auto x:mp){
        all+=((x.second)*(x.second-1)/2);
    }
    
    int ans[n];
    for(int i=0;i<n;i++){

        ans[i]=all-(mp[arr[i]]-1);
    }

    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}

int32_t main(){
    int n;
    cin >> n;
    int arr[n];

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

    solve(arr,n);
    return 0;
}


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




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

    vector<bool> visit(n+1, false);
    bool ans = false;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        if(a == 1){
            if(visit[b]){
                ans = true;
            }
            visit[b] = true;
        }else if(b == n){
            if(visit[a]){
                ans = true;
            }
            visit[a] = true;
        }
    }

    if(!ans) cout << "IM";
    cout << "POSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 256
while True:
    a,b,c=input().split()
    a_num=int(a)
    c_num=int(c)
    if b=="?":
        break
    if b=="+":
        print(a_num+c_num)
    if b=="-":
        print(a_num-c_num)
    if b=="*":
        print(a_num*c_num)
    if b=="/":
        print(int(a_num/c_num))



Measured memory_bytes: 5596
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val n, m = Scanner.nextInt
	val k = Scanner.nextLong

	val a = Array.fill(n)(Scanner.nextLong).scanLeft(0L)(_ + _)
	val b = Array.fill(m)(Scanner.nextLong).scanLeft(0L)(_ + _)

	pw.println(
		(0 to n).foldLeft((0, m)){ case ((max, j), i) =>
			if (a(i) > k) (max, j)
			else {
				val next = (j to 0 by -1).find(a(i) + b(_) <= k).getOrElse(0)
				(Math.max(max, i + next), next)
			}
		}._1
	)
	
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 63028
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    string s; cin >> s;
    sort(s.begin(), s.end());
    
    string t; cin >> t;
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	bool edge[10][10];
	for (int i = 0;i < 10;i++) {
		for (int j = 0;j < 10;j++) {
			edge[i][j] = false;
		}
	}
	for (int i = 0;i < m;i++) {
		int a, b;
		cin >> a >> b;
		edge[a][b] = true;
		edge[b][a] = true;
	}
	vector<int>v(n);
	v[0] = 1;
	iota(v.begin() + 1, v.end(), 2);
	int ans = 0;
	do {
		bool b = true;
		for (int i = 0;i < n - 1;i++) {
			if (!edge[v[i]][v[i + 1]]) {
				b = false;
			}
		}
		if (b) {
			ans++;
		}
	} while (next_permutation(v.begin() + 1, v.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Created by Sharat Sachin
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0ll,(a+b)-n);
    return 0;
}

Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline
n = int(input())
edges = [[]for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((c, b))
    edges[b].append((c, a))
INF = float('inf')


def dijkstra(init_v):
    dist = [INF]*n
    dist[init_v] = 0
    tasks = [(0, init_v)]
    while tasks:
        d, v = heapq.heappop(tasks)
        if dist[v] < d:
            continue
        for d2, v2 in edges[v]:
            if dist[v2] <= dist[v]+d2:
                continue
            dist[v2] = dist[v]+d2
            heapq.heappush(tasks, ((dist[v2], v2)))
    return dist


q, k = map(int, input().split())
dist = dijkstra(k-1)
for _ in range(q):
    x, y = map(lambda x: int(x)-1, input().split())
    print(dist[x]+dist[y])

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

using namespace std;

int main(void){
    int n, ans = 0;
    cin >> n;
    
    vector<int> a(n+1);
    
    for (int i = 0; i < n; i++) cin >> a[i];
    
    a[n] = -1;
    
    for (int i = 0; i <= n; i++){
        
        for(; a[i] > 0;){
            for (int j = 0; a[i+j] > 0; j++){
                a[i+j] -= 1;
            }
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
def bubbleSort(arr, n)
    flag = 1 
    cnt = 0
    
    while flag == 1
        flag = 0
        j = n - 1
        while j > 0
            if arr[j] < arr[j-1]
                v = arr[j-1]
                arr[j-1] = arr[j]
                arr[j] = v
                flag = 1
                cnt += 1
            end
            j -= 1
        end
    end 
    return arr, cnt
end

n = ARGF.gets.to_i
arr = ARGF.gets.split
arr = arr.map{|i| i.to_i} 
arr, c = bubbleSort(arr,n)

print arr.shift.to_s
arr.each{|i| print " " + i.to_s}
print "\n"
puts c



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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

template<class T, class... Args>
auto create(size_t n, Args&&... args) {
	if constexpr(sizeof...(args) == 1)
		return vector<T>(n, args...);
	else
		return vector(n, create<T>(args...));
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef OJ
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define sz(x) ((int)x.size())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const char en = '\n';
const int MOD = 0;
const int MAXN = 0;
const int INF = 1e9+1;

int solve() {
    int n; cin >> n;
    int ans = 0;
    fore(c,1,n-1) {
        int d = n-c;
        for(int x = 1; x*x <= d; x++) {
            if(d%x == 0) {
                ans++;
                if(x*x != d) ans++;
            }
        }
    }
    cout << ans << en;
    return 0;
} 

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int ntest = 1;
    //cin >> ntest;
    fori(test, ntest) {
        //cout << "Case #" << test+1 << ": ";
        solve();
    }

    return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    int count = 0, sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }
    for (int i = 0; i < N; ++i) {
        if (A[i]*4*M >= sum) count++;
    }
    cout << (count>=M ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long bigMod(long long b, long long p, long long m){
	if (p == 1) return b%m;
	else if (p & 1){
		return ((b%m) * bigMod(b, p-1, m))%m;
	} else {
		return ((bigMod(b,p>>1,m))*(bigMod(b,p>>1,m)))%m;
	}
}
int main(){
	long long m,n;
	cin >> m >> n;
	cout << bigMod(m, n, 1000000007) << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
using namespace std;
int main() {
 
	string str;
	cin >> str;
 
	str.insert(str.begin() + 6, ' ');
	str.insert(str.begin() + 15, ' ');
	str.erase(str.begin() + 5);
	str.erase(str.begin() + 13);
 
	cout << str << endl;
  
	return 0;
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

	int a,b;
	cin>>a>>b;
	loop(i,b-a+1,b+a)cout<<i<<" ";cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int N;
    int Q;

    cin >> N;
    long long sum = 0;
    unordered_map <long long, int> valMap;

    for (int i = 0; i < N; ++i) {
        long long v;
        cin >> v;
        ++valMap[v];
        sum += v;
    }

    cin >> Q;

    for (int i = 0; i < Q; ++i) {
        long long B;
        long long C;
        cin >> B >> C;

        long long tot = valMap[B];
        sum -= B * tot;

        valMap[B] = 0;
        valMap[C] += tot;
        sum += C * tot;

        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 6948
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    string S;
    cin >> S;
    std::vector<std::string> v;

    std::stringstream ss{S};
    std::string buf;
    while (std::getline(ss, buf, '/')) {
        v.push_back(buf);
    }

    if (stoi(v[0]) < 2018 || (stoi(v[0]) == 2019 && stoi(v[1]) < 4)
        || (stoi(v[0]) == 2019 && stoi(v[1]) == 4 && stoi(v[2]) <= 30)) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include<stack>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#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) for(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 pc() pop_back()
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
#define ll long long
#define endl '\n'
#define st stack<int>
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first> 
#define vpii vector<pii>
#define vvi vector<vi>
#define vs vector<string>
#define mii map<int,int>

int power(int a, int b) {
    int res = 1;
    while (b != 0) {
        if (b & 1) {
            res *= a;
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
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;
}
bool comp(int n) {
    vi v(4);
    int i = 0;
    while (n) {
        v[i] = n % 10;
        n /= 10;
        i++;


    }
    set<int> s(all(v));
    if (s.size() != 4) return false;
    else return true;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vvi v(n, vi(3));
    rep(i, n) {
        rep(j, 3) cin >> v[i][j];

    }
    vvi dp(n, vi(3, 0));
    rep(i, 3) {
        dp[0][i] = v[0][i];
    }
    reu(i, 1, n) {
        rep(j, 3) {
            dp[i][j] = v[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
        }
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));


}

Measured memory_bytes: 11264