akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
ld a,b,x,h,pi=acos(-1.);

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>a>>b>>x;
	h=x/(a*a);
	if (2*x<=a*a*b){
		cout<<(ld)180/pi*atan(a*b*b/(2*x));
	}
	else {
		cout<<(ld)180/pi*atan((2*b-2*x/(a*a))/a);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int f1(int a, int p) {
	if (p == 1)return a;
	if (p % 2)return f1(a, p - 1) * a % mod;
	else return f1(a * a % mod, p / 2) % mod;
}
int cbn(int n, int r) {
	int rt = 1;
	for (int i = 1; i <= n; i++) { rt *= i; rt %= mod; }
	for (int i = 1; i <= r; i++) { rt *= f1(i, mod - 2); rt %= mod; }
	for (int i = 1; i <= n - r; i++) { rt *= f1(i, mod - 2); rt %= mod; }
	return rt;
}
signed main() {
	int n, k; cin >> n >> k; cout << cbn(n + k - 1, n) << endl;
}


Measured memory_bytes: 3116
def resolve():
    N = int(input())
    ac = 0
    wa = 0
    tle = 0
    re = 0
    for i in range(N):
        S = input()
        if S == "AC":
            ac += 1
        elif S == "WA":
            wa += 1
        elif S == "TLE":
            tle += 1
        else:
            re += 1
    print("AC x", ac)
    print("WA x", wa)
    print("TLE x", tle)
    print("RE x", re)
resolve()

Measured memory_bytes: 9208
n = int(input())
an = list(map(int, input().split()))
n_list = [0]*n

for i in range(n):
  n_list[an[i]-1] += 1
n_sum = int(sum([x*(x-1)/2 for x in n_list]))

for j in range(n):
  n_remove = n_list[an[j]-1] - 1
  print(n_sum - n_remove)


Measured memory_bytes: 25004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll X, Y;
    cin >> X >> Y;
    ll cnt = LINF;
    rep(i, 2) rep(j, 2){
        ll x = X, y = Y;
        ll tmp = 0;
        if (i) x *= -1, tmp++;
        if (j) y *= -1, tmp++;
        if (x <= y) {
            tmp += y - x;
            cnt = min(cnt, tmp);
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3596
n = int(input())
v = [int(i) for i in input().split()]
c = [int(j) for j in input().split()]

x = []
 
for i in range(n):
    x.append(int(v[i]-c[i]))
 
x.sort()
 
y = 0
 
i = n-1
 
while x[i] >= 0 and i >= 0 :
    y += x[i]
    i += -1
 
print(y)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
			int[] height = new int[10];
			for (int i = 0; i < 10; i++) {
					try {
						
						height[i] = Integer.parseInt(reader.readLine());
					} catch (IOException e) {
						// TODO ????????????????????? catch ????????????
						e.printStackTrace();
					}
			}
			Arrays.sort(height);
			
			for(int i=9;i>6;i--){
				System.out.println(height[i]);
			}
		}
}

Measured memory_bytes: 24452
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e+7;

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

  int n, q;
  string s;
  cin >> n >> q >> s;

  vector<int> sums(n+1, 0);
  reps(i,1,n) {
    if(s[i-1] == 'A' && s[i] == 'C') sums[i+1] = sums[i]+1;
    else sums[i+1] = sums[i];
  }

  rep(i,q) {
    int l, r;
    cin >> l >> r;
    cout << sums[r] - sums[l] << endl;
  }
  return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;
typedef long double LD;

int main(){
  LD W,H,w,h,x,y;
  cin >> W >> H >> w >> h >> x >> y;
  x=(x-w/2+min(x+w/2,W/2))/2;
  y=(y-h/2+min(y+h/2,H/2))/2;
  cout << fixed << setprecision(10) << y/x << endl;
  return 0;
}



Measured memory_bytes: 3308
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    string S;
    cin >> S;
    if (S.size() % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    rep(i, 0, S.size()){
        if(S.substr(i, 2) != "hi"){
            cout << "No" << endl;
            return 0;
        }
        i++;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc134/tasks/abc134_d

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

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

inline int read() {
    int out = 0, fh = 1;
    char jp = getchar();
    while ((jp > '9' || jp < '0') && jp != '-')
        jp = getchar();
    if (jp == '-')
        fh = -1, jp = getchar();
    while (jp >= '0' && jp <= '9')
        out = out * 10 + jp - '0', jp = getchar();
    return out * fh;
}

int a[200001];
bool b[200001];
int main() {
    int n, ans = 0;
    n = read();
    for (int i = 1; i <= n; i++) {
        a[i] = read();
    }
    for (int i = n; i >= 1; i--) {
        int x = a[i];
        for (int j = i << 1; j <= n; j += i) {
            x ^= b[j];
        }
        b[i] = x;
        if (x)
            ans++;
    }
    cout << ans << "\n";
    for (int i = 1; i <= n; i++) {
        if (b[i]) {
            cout << i << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 1920
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, T = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

AB.sort()

ans = 0
dp = np.zeros(T, dtype=int)
for a, b in AB:
    ans = max(ans, dp.max() + b)
    np.maximum(dp[:-a] + b, dp[a:], out=dp[a:])
print(ans)


Measured memory_bytes: 12768
# frozen_string_literal: true

n = gets.to_i
f = Hash.new { 0 }
(1..100).each do |x|
  (1..100).each do |y|
    (1..100).each do |z|
      f[x*x + y*y + z*z + x*y + y*z + z*x] += 1
    end
  end
end

(1..n).each do |i|
  puts f[i]
end


Measured memory_bytes: 16664
from sys import setrecursionlimit
setrecursionlimit(2 * 10 ** 5 + 10)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, p):
    res = 1
    for v, c in E[u]:
        if p != c:
            res += dfs(v, c)
    X[p] = res
    return res

dfs(0, -1)

I = [1]
inv = pow(2, mod - 2, mod)
for i in range(N):
    I.append(I[-1] * inv % mod)

ans = - inv * N - I[N] + 1 + sum((1 - I[x]) * (1 - I[N - x]) for x in X)

print(ans % mod)

Measured memory_bytes: 214424
N = int(input())
A = list(map(int,input().split()))

x0=0
x=[]
for i in range(N):
    if i%2 == 0:
        x0+=A[i]
    else:
        x0-=A[i]

x.append(x0)
for i in range(1,N):
    x.append(2*A[i-1]-x[-1])

for i in range(N-1):
    print(x[i], end="")
    print(" ", end="")
print(x[N-1])


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

int main(){
  int A,B,cnt;
  cin >> A >> B;
  cnt=0;
  for(int i=A;i<=B;i++){
    int tmp=i;
    int a,b,c,d,e;
    a=tmp%10; tmp/=10;
    b=tmp%10; tmp/=10;
    c=tmp%10; tmp/=10;
    d=tmp%10; tmp/=10;
    e=tmp%10; tmp/=10;
    if(a==e&&b==d)cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>

using namespace std;

class RollingHash
{
    //must be 64bit
    using yuzuki = uint_fast64_t;

    static const yuzuki base = 10009;
    static const yuzuki mod = (1UL << 61) - 1;
    static const yuzuki MASK30 = (1UL << 30) - 1;
    static const yuzuki MASK31 = (1UL << 31) - 1;
    static const yuzuki SUP = mod * 3UL;

    vector<yuzuki> hashed, powmemo;

    inline yuzuki mul(yuzuki a, yuzuki b) const
    {
        yuzuki au = a >> 31;
        yuzuki ad = a & MASK31;
        yuzuki bu = b >> 31;
        yuzuki bd = b & MASK31;
        yuzuki mid = ad * bu + au * bd;
        yuzuki midu = mid >> 30;
        yuzuki midd = mid & MASK30;
        return applyMod(au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    inline yuzuki applyMod(yuzuki val) const
    {
        val = (val & mod) + (val >> 61);
        if (val > mod)
        {
            val -= mod;
        }
        return val;
    }

public:
    RollingHash(const string &s)
    {
        int n = (int)s.size();
        hashed.resize(n + 1);
        powmemo.resize(n + 1);
        powmemo[0] = 1;
        for (int i = 0; i < n; ++i)
        {
            hashed[i + 1] = applyMod(mul(hashed[i], base) + s[i]);
            powmemo[i + 1] = applyMod(mul(powmemo[i], base));
        }
    }

    //[l, r)
    inline yuzuki get(int l, int r) const
    {
        return applyMod(hashed[r] + SUP - mul(hashed[l], powmemo[r - l]));
    }

    //not verified
    inline yuzuki connect(const yuzuki &h1, const yuzuki &h2, int h2len) const
    {
        return applyMod(hashed[h2] + mul(hashed[h1], powmemo[h2len]));
    }

    inline int LCP(const RollingHash &b, int l1, int r1, int l2, int r2)
    {
        int ok = 0, ng = min(r2 - l2, r1 - l1) + 1;
        while (ok + 1 < ng)
        {
            int m = (ok + ng) / 2;
            (get(l1, r1) == b.get(l2, r2) ? ok : ng) = m;
        }
        return ok;
    }
};

// verified @ https://onlinejudge.u-aizu.ac.jp/status/users/sifi_border/submissions/1/ALDS1_14_B/judge/4050447/C++14

int main(void)
{
    string s, t;
    cin >> s >> t;
    RollingHash rh1(s), rh2(t);
    int n = s.size(), m = t.size();
    for (int i = 0; i + m <= n; i++)
    {
        if (rh1.get(i, i + m) == rh2.get(0, m))
        {
            cout << i << '\n';
        }
    }

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n+1),b(n);
	rep(i,n+1) cin >> a[i];
	rep(i,n) cin >> b[i];
	ll ans(0);
	rep(i,n){
		if(a[i] >= b[i]){
			ans += b[i];
		}else{
			ans += a[i];
			b[i] -= a[i];
			if(a[i+1] >= b[i]){
				ans += b[i];
				a[i+1] -= b[i];
			}else{
				ans += a[i+1];
				a[i+1] = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	ll max = a;
	int flag = 0;
	if(max < b) {max = b; flag = 1;}
	if(max < c) {max = c; flag = 2;}

	for (int i = 0; i < k; i++) {
		max = max * 2;
	}

	ll ans = 0;
	if(flag == 0) {
		ans = max + b + c;
	}
	if(flag == 1) {
		ans = max + a + c;
	}
	if(flag == 2) {
		ans = max + b + a;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int a,b;

int main(){
  cin >> a >> b;
  cout << (a+b)%24 << endl;
  
  return 0;
}



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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	string s;
	cin >> s;
	int ans = INF;
	for(int i = 0; i < s.size() - 2; ++i){
		int n = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		ans = min(ans, abs(n - 753));
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	u := readInt() - 1
	v := readInt() - 1
	nexts := make([][]int, n)
	for i := 0; i < n; i++ {
		nexts[i] = make([]int, 0)
	}

	for i := 0; i < n-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		nexts[a] = append(nexts[a], b)
		nexts[b] = append(nexts[b], a)
	}

	ans := 0
	d1 := f(n, u, nexts)
	d2 := f(n, v, nexts)
	for i := 0; i < n; i++ {
		if d1[i] < d2[i] && ans < d2[i] {
			ans = d2[i] - 1
		}
	}

	fmt.Println(ans)
}

func f(n int, x int, nexts [][]int) []int {
	d := make([]int, n)
	for i := 0; i < n; i++ {
		d[i] = 10000000
	}
	d[x] = 0
	q := []int{x}
	for len(q) > 0 {
		current := q[0]
		q = q[1:]
		for _, next := range nexts[current] {
			if d[current]+1 < d[next] {
				q = append(q, next)
				d[next] = d[current] + 1
			}
		}
	}
	return d
}

var stdin *bufio.Scanner

func read() string {
	if stdin == nil {
		stdin = bufio.NewScanner(os.Stdin)
		stdin.Split(bufio.ScanWords)
		stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	}
	stdin.Scan()
	return stdin.Text()
}

func readInt() int {
	n, _ := strconv.Atoi(read())
	return n
}

func readFloat64() float64 {
	n, _ := strconv.ParseFloat(read(), 64)
	return n
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

    int N;
    cin >> N;

    cout << N / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a,i,j,n,cnt,ren[100];
int main(void){
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        for(j=0;;j++){
            if(ren[j]==0){
                ren[j]=a;
                cnt++;
                break;
            }
            if(ren[j]==a) break;
        }
    }
    printf("%d",cnt);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int n,m,k,i,j;
short check()
{	for(i=0;i<=n;i++)
		for(j=0;j<=m;j++)
			if(i*m+j*n-i*j*2==k) return 1;
	return 0;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	if(check()) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
/* https://img.atcoder.jp/arc094/editorial.pdf */
#include <stdio.h>
#include <string.h>

#define N	200000
#define MD	998244353

int main() {
	static char cc[N + 1];
	static int dp[3][3][2], dq[3][3][2];
	int n, i, ka, kb, kc, s, a, eq, ans;

	scanf("%s", cc), n = strlen(cc);
	ka = kb = kc = 0;
	for (i = 0; i < n; i++)
		if (cc[i] == 'a')
			ka++;
		else if (cc[i] == 'b')
			kb++;
		else
			kc++;
	if (ka == n || kb == n || kc == n) {
		printf("1\n");
		return 0;
	}
	if (n == 2 && cc[0] != cc[1]) {
		printf("2\n");
		return 0;
	}
	if (n == 3 && cc[0] != cc[1] && cc[1] != cc[2] && cc[0] != cc[2]) {
		printf("3\n");
		return 0;
	}
	for (a = 0; a < 3; a++)
		dp[a][a][0] = 1;
	for (i = 1; i < n; i++) {
		memset(dq, 0, sizeof dq);
		for (s = 0; s < 3; s++)
			for (a = 0; a < 3; a++)
				for (eq = 0; eq < 2; eq++) {
					int x = dp[s][a][eq], a_;

					if (x == 0)
						continue;
					for (a_ = 0; a_ < 3; a_++) {
						int s_ = (s + a_) % 3, eq_ = eq || a == a_;

						dq[s_][a_][eq_] = (dq[s_][a_][eq_] + x) % MD;
					}
				}
		memcpy(dp, dq, sizeof dq);
	}
	ans = 1;
	for (i = 1; i < n; i++)
		if (cc[i] == cc[i - 1]) {
			ans = 0;
			break;
		}
	s = (kb + kc * 2) % 3;
	for (a = 0; a < 3; a++)
		ans = (ans + dp[s][a][1]) % MD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1900
//#include "pch.h" 
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
using namespace std;
int n, m, c;
int b[20];
signed main() {
	cin >> n >> m >> c;
	int ans = 0;
	rep(i, m) cin >> b[i];
	rep(i, n) {
		int cnt = c;
		rep(j, m) {
			int a;
			cin >> a;
			cnt += (a * b[j]);
		}
		if (cnt > 0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*

fun simple(a: Int, b: Int, x: List<Long>, L: Long): Int {
    var res = 0
    var v = a
    while (v < b) {
        v = x.indexOfLast { it <= x[v] + L }
        res++
    }

    return res
}

fun main(args: Array<String>) {
    val M = readLine()!!.toInt()
    var N = 1
    while (N <= M) N *= 2
    val x = readLine()!!.split(" ").map{it.toLong()}
    val L = readLine()!!.toLong()

    // solve
    val Q = readLine()!!.toInt()
    val a = Array(Q) { 0 }
    val b = Array(Q) { 0 }
    for (i in a.indices) {
        val (A, B) = readLine()!!.split(" ").map { it.toInt() }
        a[i] = Math.min(A, B) - 1
        b[i] = Math.max(A, B) - 1
    }


    // check
//    val A = ArrayList<Int>()
//    val B = ArrayList<Int>()
//    for (i in 0 until M) for (j in i + 1 until M) {
//        A.add(i)
//        B.add(j)
//    }
//    val a = A.toTypedArray()
//    val b = B.toTypedArray()

    solve(a, b, x, N, L)
}

private fun solve(
    a: Array<Int>,
    b: Array<Int>,
    x: List<Long>,
    N: Int,
    L: Long
) {
    val mp = TreeMap<Long, Int>()
    x.forEachIndexed { index, l -> mp[l] = index }

    val doubling = Array(N) { Array(20) { x.size } }

    for (i in x.indices) {
        var value = mp.floorEntry(x[i] + L).value
        if (value == i) {
            value = x.size
        }
        doubling[i][0] = value
    }

    for (k in 1 until 20) {
        for (i in doubling.indices) {
            doubling[i][k] = doubling[doubling[i][k - 1]][k - 1]
        }
    }

    fun findNext(s: Int, t: Int): Pair<Int, Int> {
        var k = doubling[s].indexOfFirst { it >= t }
        if (k > 0) k--

        return Pair(doubling[s][k], 1 shl k)
    }

    for (l in a.indices) {
        var res = 0

        var v = a[l]
        while (v < b[l]) {
            val p = findNext(v, b[l])
            v = p.first
            res += p.second
        }

        // solve
        println(res)

        // check
//        val res2 = simple(a[l], b[l], x, L)
//        if (res != res2) {
//            println("${a[l]} ${b[l]}, $res $res2")
//        }
    }
}


Measured memory_bytes: 156960
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, d; cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i,n) rep(j,d) {
        cin >> x[i][j];
    }
    int ans = 0;
    rep(i,n) repf(j,i+1,n) {
        int tmp = 0;
        rep(k,d) {
            tmp += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        int a = sqrt(tmp);
        if (a*a == tmp) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N,A,B;cin>>N>>A>>B;
    int ac,bc,cc;
    ac=bc=cc=0;
    REP(i,N){
        int a;cin>>a;
        if(a<=A)ac++;
        if(a>A&&a<=B)bc++;
        if(a>B)cc++;
    }
    cout<<min(ac,min(bc,cc))<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    string s;
    cin >> s;
    int n = s.length();
    forn(i, n - 1){
        if (s[i] == s[i + 1]){
            cout << i + 1 << ' ' << i + 2 << '\n';
            return;
        }
    }
    forn(i, n - 2){
        if (s[i] == s[i + 2]){
            cout << i + 1 << ' ' << i + 3 << '\n';
            return;
        }
    }
    cout << "-1 -1\n";
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  
  int k,x;
  
  cin>>k>>x;
  
  for(int i=x-k+1;i<=x+k-1;i++){
    if(i!=x+k-1)cout<<i<<' ';
    else cout<<i<<endl;
  }
  
  return 0;
}

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

int main() {
 int n;
    cin >> n;
    
    if( 400 <= n&&n <= 599) {
    cout << 8;
    } else if (600 <=n&&n<=799){
    cout << 7;} else if(800<=n&&n<=999) {
     cout << 6;} else if ( 1000<=n&&n<=1199) {
    cout << 5;} else if(1200<=n&&n<=1399){
     cout << 4;} else if (1400<=n&&n<=1599) {
     cout << 3;} else if(1600<=n&&n<=1799) {
     cout << 2;} else if (1800<=n&&n<=1999){
     cout << 1;} 
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b>c+d)
	{
   		printf("Left");
	}
	if(a+b==c+d)
	{
    		printf("Balanced");
	}
	if(a+b<c+d)
	{
    	printf("Right");
	}
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c=MI()
    if c>=a and c<=b:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
using namespace std;


int main() {

#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	int L, N;
	cin >> L >> N;
	cout << N << endl;
	for (int  i = 0; i < N; i++){
		int x,w;
		cin >> x >> w;
		cout << -x << " " << w << endl;

	}


	return 0;
}

Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] AB = sc.nextLine().split(" ");
        int A = Integer.parseInt(AB[0]);
        int B = Integer.parseInt(AB[1]);

        int plug = 0;
        int ans = 0;
        for (int i = 1; i < 30; i++) {
            if (i != 1) {
                plug--;
            }
            plug += A;
            if (plug >= B) {
                ans = i;
                break;
            }
        }

        System.err.println(plug);
        if (B == 1) {
            System.out.println(0);
        } else {
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1 << 29;
const double EPS = 1e-9;

void combi(vector<vector<lint>> &v) {
	for (int i = 0; i < (int)v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < (int)v.size(); j++) {
		for (int k = 1; k <= j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
}

int main() {

	cin.tie(0);

	vector<vector<lint>> combi_tb(51, vector<lint>(51));
	combi(combi_tb);

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

	vector<lint> v(N);
	FOR(i, 0, N) cin >> v[i];

	sort(v.begin(), v.end(), greater<lint>());

	long double ave = .0;
	
	FOR(i, 0, A) ave += v[i];
	cout.precision(10);
	cout << fixed << ave / A << "\n";

	int bk = 0, fw = 0, cnt = 0;
	lint ans = 0;
	
	if (v[0] != v[A - 1]) {

		while (v[A - 1] == v[A - 1 - bk]) {
			bk++;
		}
		while ((A - 1 + fw) < N && v[A - 1] == v[A - 1 + fw]) {
			fw++;
		}
		ans = combi_tb[bk + fw - 1][bk];
	}
	else {

		while (cnt < N && v[0] == v[cnt]) {
			cnt++;
		}
		FOR(i, A, min(B, cnt) + 1)	ans += combi_tb[cnt][i];
	}

	cout << ans;

	return 0;
}

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

struct Unionfind {
  // tree number
  vector<int> par;
  // constructor
  Unionfind(int n = 1) : par(n, -1) {}
  // search root
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  int uni(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return x;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return x;
  }
  int size(int x) { return -par[root(x)]; }
};

struct edge {
  int x, y;
  long long c;
  bool operator<(const edge& r) {
    if (c != r.c) return c < r.c;
    if (x != r.x) return x < r.x;
    return y < r.y;
  }
};

long long n, m;
vector<edge> edges;
vector<long long> a, sum, memo;
vector<vector<long long>> v;
Unionfind tmp, uf;

long long solve();

int main() {
  cin >> n >> m;
  a.resize(n);
  for (auto& p : a) cin >> p;
  edges.resize(m);
  for (int i = 0; i < m; ++i) {
    cin >> edges[i].x >> edges[i].y >> edges[i].c;
    --edges[i].x, --edges[i].y;
  }
  sort(edges.begin(), edges.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  uf = Unionfind(n);
  tmp = Unionfind(n);
  v.resize(n);
  memo.resize(n);
  for (int i = 0; i < n; ++i) memo[i] = i;
  sum = a;
  for (int i = 0; i < m; ++i)
    if (!tmp.issame(edges[i].x, edges[i].y)) {
      int x = memo[tmp.root(edges[i].x)], y = memo[tmp.root(edges[i].y)], r;
      v[x].push_back(i);
      if (v[y].size() > v[x].size()) swap(x, y);
      while (v[y].size()) {
        v[x].push_back(v[y].back());
        v[y].pop_back();
      }
      r = tmp.uni(x, y);
      memo[r] = x;
      sum[x] = sum[x] + sum[y];
      if (sum[x] >= edges[i].c)
        while (v[x].size()) {
          int id = v[x].back();
          uf.uni(edges[id].x, edges[id].y);
          v[x].pop_back();
        }
    }
  sum.assign(n, 0);
  for (int i = 0; i < n; ++i) sum[uf.root(i)] += a[i];
  long long res = m;
  for (int i = 0; i < m; ++i)
    if (uf.issame(edges[i].x, edges[i].y) &&
        sum[uf.root(edges[i].x)] >= edges[i].c)
      --res;
  return res;
}


Measured memory_bytes: 16228
#!/usr/bin/env python
# -*- coding: utf-8 -*-

input = raw_input()

result = ""
for i in range(0, 3):
    if input[i] == "1":
        result += "9"
    elif input[i] == "9":
        result += "1"
    else:
        result += input[i]

print int(result)

Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main(void){
    int a[3],res=0;
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    sort(begin(a),end(a));
    for(int i=0;i<2;i++){
        res += abs(a[i] - a[i+1]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
p_1 = [x1, y1]
p_2 = [x2, y2]
p_3 = [p_2[0]-(p_2[1]- p_1[1]), p_2[1]+ (p_2[0]-p_1[0])]
p_4 = [p_3[0]-(p_3[1]- p_2[1]), p_3[1]+ (p_3[0]-p_2[0])]
ans = list(p_3 + p_4)
ans = [str(i) for i in ans]
print(" ".join(ans))

Measured memory_bytes: 3064
N, K, *DS = $stdin.read.split.map(&:to_i)
#digits = ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - DS)

N.upto(Float::INFINITY) do |n|
  if (n.to_s.chars.map(&:to_i).uniq & DS).empty?
    p n
    exit
  end
end


Measured memory_bytes: 1916
#abc137 c
n=int(input())
table=dict()
for i in range(n):
    s=str(sorted(input()))
    if s not in table:
        table[s]=1
    else:
        table[s]+=1
ans=0

for x in table.values():
    kumi=(x*(x-1))/2
    ans+=int(kumi)
print(ans)

Measured memory_bytes: 21988
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
typedef pair <int, int> P;

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

    vector<P> order(n - 1);
    vector<vector<int>> edge(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        order[i] = {a, b};
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    queue<P> q;
    q.push({0, -1});

    map<P, int> mp;
    int k = 1;
    while (!q.empty()) {
        P p = q.front();
        q.pop();

        int cur = p.first;
        int par = p.second;

        int idx = 1;
        for (int ch : edge[cur]) {
            if (ch == par) continue;
            if (idx == mp[{cur, par}]) idx++;
            k = max(k, idx);
            mp[{cur, ch}] = idx;
            mp[{ch, cur}] = idx++;
            q.push({ch, cur});
        }
    }

    cout << k << '\n';
    for (int i = 0; i < n - 1; i++) {
        cout << mp[order[i]] << '\n';
    }

    return 0;
}

Measured memory_bytes: 19328
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

signed main() {
	int n, k;
	cin >> n >> k;
	int a[200005];
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	rep(i, (max((int)0, n - k))) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// #define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}

ll inverse(ll n)
{
	return exp(n,MOD-2);
}
int LIM=6010;
v64 factorial(LIM,1);

void solve()
{
//Read Comments below main
	string s;
	cin>>s;
	if (s[2]==s[3] && s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
}
 
int main() {
    fast_cin();
    ll t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
// BITMASK:
// 1)When some constraint is of the order of 15-20, think of bitmask DP.
// 2)When some constraint is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algo

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n, k;
    cin >> n >> k;
    vi a(n);
    ll mini = INF;
    rep(i, n){
        cin >> a[i];
        chmin(mini, a[i]);
    }
    ll ans = 0;
    ll tmp = 0;
    for(ll i=1;i<n;i++){
      if(a[i-1]==mini&&a[i]!=mini){
          a[i] = mini;
          tmp++;
          if(tmp==k-1){
              tmp = 0;
              ans++;
          }
      }
    }
    for (ll i = n - 2; i >= 0; i--)
    {
        if(a[i+1]==mini&&a[i]!=mini){
            a[i] = mini;
            tmp++;
            if(tmp==k-1){
              tmp = 0;
              ans++;
          }
        }
    }
    if (tmp > 0)ans++;
    print(ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc077/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    ll N; 
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    rep(i, N){
        ll k1 = N - (lower_bound(C.begin(), C.end(), B[i] + 1) - C.begin());
        ll k2 = (lower_bound(A.begin(), A.end(), B[i]) - A.begin());
        ans += k1 * k2;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1536
#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;

int x[100005];

int main()
{
	int n, a, b;
	LL ans = 0;
	scanf("%d %d %d", &n, &a, &b);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}

	for (int i = 1; i < n; i++) {
		ans += MIN(b, (x[i] - x[i - 1]) * 1LL * a);
	}

	printf("%lld\n", ans);


	return 0;
}


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

typedef long long ll;

int main()
{
    int N;
    ll ans = 1;

    cin >> N;
    
    for(int i = 0; i < N; i++) {
        ll T;
        cin >> T;
        (ans /= __gcd(ans, T)) *= T;
    }

    cout << ans << endl;

    return (0);
}


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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int A, B;
    cin >> A >> B;

    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        puts("Possible");
    } else {
        puts("Impossible");
    }
}

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


int main(){
    int64_t x1,x2,x3,x4,x5;
    cin >> x1 >>x2 >> x3 >> x4 >> x5;
    
    if(x1 == 0){
        cout << 1 << endl;
    }else if(x2 == 0){
        cout << 2 << endl;
    }else if(x3 == 0){
        cout << 3 << endl;
    }else if(x4 == 0){
        cout << 4 << endl;
    }else{
        cout << 5 << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int N, K;
    vector<int> p;

    cin >> N;
    cin >> K;
    p.reserve(N);
    for( int i = 0; i < N; ++i )
    {
        int input;
        cin >> input;
        p.push_back(input);
    }

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

    int ans = 0;
    for( int i = 0; i < K; ++i )
    {
        ans += p.at(i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1e9 + 5;

int main()
{
    ll n, w, wi, val;
    cin >> n >> w;
    ll dp[n + 1][w] = {};
    for(ll i = 1; i <= n; i++)
    {
        cin >> wi >> val;
        for(ll j = 0; j <= w; j++)
            dp[i][j] = dp[i - 1][j];
        for(ll j = w; j >= 0; j--)
        {
            if(j - wi >= 0)
                dp[i][j] = max(dp[i - 1][j], val + dp[i][j - wi]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    /*for(ll i = 0; i <= n; i++)
    {
        for(ll j = 0; j <= w; j++)
            cout << dp[i][j] << ' ';
        cout << '\n';
    }*/
    ll ans = 0;
    for(int i = 0; i <= w; i++) ans = max(ans, dp[n][i]);
    cout << ans;
}


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

using namespace std;

int main(){
    long long A=0,B=0,C=0,D=0,N=0,ans=1;
    string S;



    cin>>N;
    vector<long long> vec(N);

    for(auto& x : vec)
    {
            cin>>x;
    }
    

    for(int i=1;i<N;++i){
    bool check=true;
        for(int k=0;k<i;++k){ 
            if(vec[k]>vec[i]){
                check=false;
            }
        }

        if(check){
            ans++;
        }
    }


    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 6006
typedef long long ll;
const int mod=998244353;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,x,ans,fac[N],ifac[N];
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	ifac[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		ifac[i]=1LL*ifac[i+1]*(i+1)%mod;
	}
}
inline int C(int n,int m){
	if(n<0||m<0||n-m<0)return 0;
	return 1LL*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main(){
	n=read(),x=read();
	if(x==1){
		return !printf("%d\n",qpow(2,n));
	}
	init(max(n,x));
	for(int k=1;k<=n;++k){
		int tmp=0;
		for(int i=k;i<x;++i){
			tmp=(tmp+C(k,i-k))%mod;
		}
		for(int i=1;i<=k-1;++i){
			if(i<=k-i){
				tmp+=(x-1==2*i);
			}
			else{
				int p=x-1-2*(k-i);
				tmp=(tmp+C(2*i-k,p-(2*i-k)))%mod;
			}
		}
		ans=(ans+1LL*C(n,k)*tmp)%mod;
	}
	printf("%d\n",(ans+1)%mod);
	return 0;
}

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

int main(){
int n,k;
cin >> n>>k;
 int now =1;
 for(int i=0;i<n;i++){
     int a=0,b=0;
     a = now*2;
     b=now+k;
     now = min(a,b);
 }
 cout << now << endl;
}

Measured memory_bytes: 256
def c_exam_and_wizard(N, A, B):
    ans = 0
    sum_of_shortage_for_passing_mark = 0
    campensation_for_shortage = []
    for a, b in zip(A, B):
        if a < b:
            ans += 1
            sum_of_shortage_for_passing_mark += b - a
        elif a > b:
            campensation_for_shortage.append(a - b)

    if sum_of_shortage_for_passing_mark == 0:
        return 0  # 準備度を変更するまでもない

    campensation_for_shortage.sort(reverse=True)  # A_i-B_iが大きなiから分けていく
    for pts in campensation_for_shortage:
        sum_of_shortage_for_passing_mark -= pts
        ans += 1
        if sum_of_shortage_for_passing_mark < 0:
            break
    else:
        ans = -1
    return ans

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
print(c_exam_and_wizard(N, A, B))

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int ceil(int x, int y){
	return (x + y - 1) / y;
}

int main(void){

	int A, B, C, D; cin >> A >> B >> C >> D;
	
	
	while(1){
		C -= B;
		if(C <= 0){
			cout << "Yes" << endl;
			break;
		}
		A -= D;
		if(A <= 0){
			cout << "No" << endl;
			break;
		}
	}


	


	return 0;

}


Measured memory_bytes: 3632
n, k, q = map(int, input().split())
a = [input() for i in range(q)]

p = [k - q] * n

for i in range(q):
    p[int(a[i]) - 1] += 1

for i in range(n):
    if p[i] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 12840