akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=3e5+5;
int n,m;
int ans[maxn];
void add(int l,int r){
	ans[l]++;ans[r+1]--;
}
void calc(){
	rep(i,1,m)ans[i]+=ans[i-1];
}
int main(){
	read(n);read(m);
	rep(i,1,n){
		int l,r;read(l);read(r);
		l--;
		for(int j=1,nxtj;j<=l;j=nxtj+1){
			nxtj=min(l/(l/j),r/(r/j));
			if((l/j)!=(r/j))add(j,nxtj);
		}
		add(l+1,r);
	}
	calc();
	rep(i,1,m)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 1280
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000000
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}



//=============================================ASIFAZAD==============================================//
const int N = 500050;
set<char> sub[4*N];
string s;


void calc(int cur, set<char>& a, set<char>& b)
{
    sub[cur].clear();
    for(auto c: a)
        sub[cur].insert(c);
    for(auto c: b)
        sub[cur].insert(c);
}

void build(int cur, int strt, int en)
{
    if(strt == en)
        sub[cur].insert(s[strt]);
    else
    {
        int mid = (strt + en)/2;
        build(2*cur, strt , mid);
        build(2*cur + 1, mid + 1, en);
        calc(cur, sub[2*cur], sub[2*cur+1]);
    }
}

void upd(int cur, int strt, int en, int ind, char v)
{
    if(strt == en)
    {
        sub[cur].clear();
        sub[cur].insert(v);
    }
    else
    {
        int mid = (strt + en)/2;
        if(ind <= mid)
            upd(2*cur, strt, mid, ind, v);
        else
            upd(2*cur + 1, mid + 1, en, ind, v);
        calc(cur, sub[2*cur], sub[2*cur+1]);
    }
}

set<char> dif(int cur, int strt, int en, int l, int r)
{
    if(en < l || strt > r)
    {
        set<char> ret;
        return ret;
    }
    if(strt >= l && en <= r)
        return sub[cur];
    int mid = (strt + en)/2;
    set<char> a, b, ret;
    a = dif(2*cur , strt, mid, l, r);
    b = dif(2*cur + 1, mid + 1, en, l, r);
    for(auto x: a)
        ret.insert(x);
    for(auto x: b)
        ret.insert(x);
    return ret;
}

int32_t main()
{
    io;
    int n;
    cin>>n;
    s += "0";
    for(int i = 1; i <= n;i++)
    {
        char c;
        cin>>c;
        s += c;
    }

    //dbg(s);

    build(1, 1, n);

    int q;
    cin>>q;
    while(q--)
    {
        int ck;
        cin>>ck;
        if(ck == 1)
        {
            int ind;
            char v;
            cin>>ind>>v;
            upd(1,1, n, ind, v);
        }
        else
        {
            int l, r;
            cin>>l>>r;
            cout<<dif(1,1, n, l, r).size()<<"\n";
        }
    }
    return 0;
}

Measured memory_bytes: 236576
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    result = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
    for s in S:
        result[s] += 1
    print('AC x %d' % result['AC'])
    print('WA x %d' % result['WA'])
    print('TLE x %d' % result['TLE'])
    print('RE x %d' % result['RE'])
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16292
import collections

N = int(input())
S = [input() for i in range(N)]

setted_S = set(S)
counted_S = collections.Counter(S)
sorted_S = sorted(counted_S.items(), key=lambda x: x[1], reverse=True)

ans_ls = []
for s in sorted_S:
    a = sorted_S[0][1]
    if s[1] == a:
        ans_ls.append(s[0])
    else:
        break

ans_ls.sort()

for i in ans_ls:
    print(i)

Measured memory_bytes: 58096
N = int(input())

ans = ["" for _ in range(11)]
count = 0
while N > 0:

    remainder = N % 26
    if remainder ==0:
        remainder = 26
    ans[count] = chr(remainder + 96)
    N = (N-remainder)//26
    count += 1
print("".join(list(reversed(ans))))

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    ll k; cin >> k;
    ll now = 7;
    
    rep(i, k+5){
        if(now % k == 0) {
            cout << i+1 << endl;
            return;
        }
        now = (now*10 + 7) % k;
    }
    cout << -1 << endl;
    return;
}

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

Measured memory_bytes: 3648
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>

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

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

    vector<int> a(N);

    rep(i, N)
    {
        cin >> a.at(i);
    }

    rep(i, N)
    {
        if (a.at(i) % 2 == 0)
        {
            if (!(a.at(i) % 3 == 0 || a.at(i) % 5 == 0))
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
line = gets.chomp
line = line.split(" ")
ary = Array.new(n){Array.new(21)}
for i in 0..20
  ary[0][i] = 0
end
ary[0][line[0].to_i] = 1;
for i in 1..n-1
  for j in 0..20
    if j-line[i].to_i >= 0 
      ary[i][j] = ary[i-1][j-line[i].to_i]
    else 
      ary[i][j] = 0
    end
    if j+line[i].to_i <= 20 
      ary[i][j] += ary[i-1][j+line[i].to_i]
    else 
      ary[i][j] += 0
    end
  end
end
puts ary[n-2][line[n-1].to_i]

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

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

    int n;
    cin >> n;

    vector<double> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];

    vector<double> dp(n + 1, 0.0);
    dp[0] = 1 - p[0];
    dp[1] = p[0];
    for (int i = 1; i < n; i++){
        for (int j = i; j >= 0; j--){
            dp[j + 1] = dp[j] * p[i] + dp[j + 1] * (1 - p[i]);
        }
        dp[0] = dp[0] * (1 - p[i]);
    }

    double ans = 0.0;
    for (int i = n; i > n / 2; i--)
        ans += dp[i];

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

void set_bipartite_graph(int a_from, int a_until, int b_from, int b_until, const int level, std::vector<std::vector<int>>& result) {
	if (a_until - a_from <= 0 || b_until - b_from <= 0) return;
	for (auto a = a_from; a < a_until; ++a) {
		for (auto b = b_from; b < b_until; ++b) {
			result[a][b] = level;
			result[b][a] = level;
		}
	}
	set_bipartite_graph(a_from, (a_from + a_until) / 2, (a_from + a_until) / 2, a_until, level + 1, result);
	set_bipartite_graph(b_from, (b_from + b_until) / 2, (b_from + b_until) / 2, b_until, level + 1, result);
}
int main() {
	constexpr long long int mod = 1000000007LL;
	int n; std::cin >> n;
	std::vector<std::vector<int>> result(n, std::vector<int>(n, 0));
	set_bipartite_graph(0, n / 2, n / 2, n, 1, result);
	for (auto i = 0; i + 1 < n; ++i) {
		for (auto j = i + 1; j < n; ++j) {
			std::cout << result[i][j];
			if (j != n - 1) std::cout << ' ';
		}
		std::cout << '\n';
	}
}

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

int *dp, *hrr, n;

int main(){
    cin>>n;
    hrr = new int[n], dp = new int[n];
    for(int i=0;i<n;i++){
        cin>>hrr[i];
    }

    dp[0] = 0;
    dp[1] = abs(hrr[1]-hrr[0]) + dp[0];
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(hrr[i]-hrr[i-1]), dp[i-2]+abs(hrr[i]-hrr[i-2]));
    }
    int ans = dp[n-1];
    delete[] hrr;
    delete[] dp;
    cout << ans;

    return 0;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m;
bool vis[N];
int main()
{
    scanf("%d%d",&n,&m);
    if(n&1)
    {
        for(int i=1,l=1,r=n;i<=m;i++)
        {
            printf("%d %d\n",l,r);
            l++;r--;
        }
    }
    else
    {
        int k=(n-1)/2;
        k=k/2+k%2;
        int l=1,r=n;
        while(k&&(m--))
        {
            printf("%d %d\n",l,r);
            l++;r--;
            k--;
        }
        r--;
        if(m<0) m=0;
        while(m--)
        {
            printf("%d %d\n",l,r);
            l++;r--;
        }
    }
}


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

typedef long long ll;
const int SIZE = 1<<17;
int n,m,s,e;
ll l;

ll dp[SIZE],tmp[SIZE];

int make_mask(int s,int e) {
    int ret = 0;
    for(int i=s; i<e; ++i) ret |= (1<<(i-5));
    return ret;
}

int main() {
    while(cin>>n, n) {
        memset(dp, -1, sizeof(dp));
        memset(tmp, -1, sizeof(tmp));
        dp[0] = 0;

        for(int i=0; i<n; ++i) {
            dp[0] = 0;
            cin>>m>>l;
            int mask = 0;
            for(int j=0; j<m; ++j) {
                cin>>s>>e;
                mask |= make_mask(s,e);
            }

            for(int k=0; k<SIZE; ++k) {
                if(dp[k] == -1) continue;
                if((k&mask) != 0) continue;
                tmp[k|mask] = max(tmp[k|mask], dp[k]+l);
            }
            for(int k=0; k<SIZE; ++k) dp[k] = tmp[k];
        }

        ll ans = 0;
        for(int i=0; i<SIZE; ++i) ans = max(ans, dp[i]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2912
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
  int p[3], j[2];

  while(cin >> p[0] >> p[1] >> p[2] >> j[0] >> j[1]) {
    sort(p, p+3);
    sort(j, j+2);
    int ans = p[0] + j[0];
    cout << ans - 50 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int m, n;

int books[100];

bool Check(int breadth){
  int stage = 0;
  int remaining = breadth;
  for(int i=0; i<n; i++){
	if(remaining - books[i] < 0){
	  stage++;
	  remaining = breadth;
	  if(stage >= m){
		return false;
	  }
	}
	remaining -= books[i];
  }
  return true;
}

void Solve(int max_book){
  int left = max_book-1;
  int right = 1500000;
  while(right - left > 1){
	int mid = (right + left)/2;
	if(Check(mid)){
	  right = mid;
	}else{
	  left = mid;
	}
  }
  cout << right << endl;
}

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

  while(1){
	cin >> m >> n;
	if(m == 0){
	  return 0;
	}
	int max_book = -1;
	for(int i=0; i<n; i++){
	  cin >> books[i];
	  if(books[i] > max_book){
		max_book = books[i];
	  }
	}
	Solve(max_book);
  }
  
  
  return 0;
}

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string getindex(string s, char tg){
  
}

bool find(string s, int tg){
  int d1 = tg /100;
  
}

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for(int i=0;i<1000;i++){
    int c[3] = {i/100,(i/10)%10, i%10};
    int f = 0;
    for(int j=0;j<N;j++){
      if(S[j] == ('0' + c[f])){
        f++;
      }
      if(f == 3) break;
    }
    if(f==3){
      ans++;
    }
  }
    printl(ans);
  
}


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

using namespace std;

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

    long long n;
    cin >> n;

    long long m = sqrt(n);
    for (int i = m; i >= 1; i--) {
        if (n % i == 0) {
            long long x = i;
            long long y = n / i;
            cout << x + y - 2;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n= scan.nextLong();
		scan.close();
		long x = 0,y = 0;
		for (long i = (long) Math.sqrt(n);i > 0;i--){
            if (n % i == 0){
              x = n / i;
              y = i;
              break;
            }
        }
		System.out.println(x+y-2);
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s.substr(i,2)=="AC"){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, p) = get!(usize, usize);
    if p == 1 {
        println!("1");
        return;
    } else if n == 1 {
        println!("{}", p);
        return;
    }
    let mut ans = 1;
    for i in 2..p {
        if p < i * i {
            break;
        }
        let mut tp = p;
        let mut count = 0;
        while tp % i == 0 {
            tp /= i;
            count += 1;
            if n <= count {
                ans = i;
                break;
            }
        }
    }
    println!("{}", ans);
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

string s;
int cur, n;

void dfs(int i) {
	if(i == n) {
		pstr(s.c_str()); pc('\n');
		return;
	}
	rep(v, cur+2) {
		s += (v+'a');
		if(v == cur+1) {
			cur = v;
			dfs(i+1);
			cur = v-1;
		} else {
			dfs(i+1);
		}
		s.pop_back();
	}
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    gi(n);
	cur = -1;
	dfs(0);
}


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

int main(){
    string s;
    cin >> s;
    vector<int> a;
    for(int i=0;i<s.size();i++){
        a.push_back(s[i]-'0');
    }
    int res;
    int ans=1e5;
    for(int i=0;i<s.size()-2;i++){
        res=100*a[i]+10*a[i+1]+a[i+2];
        res=abs(res-753);
        ans=min(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = INF;
	for (char c = 'a'; c <= 'z'; c++) {
		string t = s;
		int tmp = 0;
		while (true) {
			if (count(t.begin(),t.end(), c) == t.size())break;
			string u;
			for (int i = 0; i < t.size() - 1; i++) {
				if (t[i] == c || t[i + 1] == c)u += c;
				else u += ".";
			}
			t = u;
			tmp++;
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string O,E;
  cin>>O>>E;
  if(O.size()==E.size()){
    for(int i=0;i<E.size();i++){
      cout<<O[i]<<E[i];
    }
  }else{
    for(int i=0;i<E.size();i++){
      cout<<O[i]<<E[i];
    }
    cout<<O[O.size()-1]<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/rope>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define mp make_pair
#define lowbit(x) (x&(-x))
#define X first
#define Y second
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
const int N = 1e6 + 5;
const int mod = 1e9 + 21;
const int maxn = 1e7 + 5;
ll a[N];
ll dp[N];
ll pre[N];
ll suf[N];
ll sdp[N];
ll dp1[N];
ll sdp1[N];
int main() {
#ifdef local
    freopen("input", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
    }
    ll ans = INF;
    mst(dp,0);mst(sdp,0);mst(pre,0);mst(suf,0);
    for(int i = 1; i <= n; i++){
        pre[i] = pre[i - 1] + a[i];
    }
    for(int i = n; i >= 1; i--)suf[i] = suf[i + 1] + a[i];
    for(int i = 1; i <= n; i++){
        ll tmp = min(pre[i - 1],dp[i - 1]);
        if(a[i] == 0){
            dp[i] = tmp + 2;
        }
        else if(a[i] % 2 == 1){
            dp[i] = tmp + 1;
        }
        else dp[i] = tmp;
        dp1[i] = pre[i - 1] + (a[i] % 2 == 0);
        dp1[i] = min(dp1[i],min(dp1[i - 1],dp[i - 1]) + (a[i] % 2 == 0));
    }
    for(int i = n; i >= 1; i--){
        ll tmp = min(sdp[i + 1],suf[i + 1]);
        if(a[i] == 0){
            sdp[i] = tmp + 2;
        }
        else if(a[i] % 2 == 1){
            sdp[i] = tmp + 1;
        }
        else sdp[i] = tmp;
        sdp1[i] = suf[i + 1] + (a[i] % 2 == 0);
        sdp1[i] = min(sdp1[i],min(sdp1[i + 1],sdp[i + 1]) + (a[i] % 2 == 0));
    }
    for(int i = 1; i <= n; i++){
        ans = min(ans,dp1[i] + sdp1[i] - (a[i] % 2 == 0));
        int c = 0;
        if(a[i] == 0)c = 2;
        else if(a[i] % 2 == 1)c = 1;
        ans = min(ans,dp[i] + sdp[i] - c);
    }
    ans = min(ans,suf[1]);
    for(int i = 1; i <= n; i++){
        ans = min(ans,dp1[i] + suf[i + 1] - (a[i] % 2 == 0));
        ans = min(ans,dp[i] + suf[i + 1]);
        ans = min(ans,pre[i - 1] + sdp1[i] - (a[i] % 2 == 0));
        ans = min(ans,pre[i - 1] + sdp[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 40704
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int k,x;
int main() {
	scanf("%d%d",&k,&x);
	int l=x-k+1,r=x+k-1;
	for (int i=l;i<=r;++i)
		printf("%d ",i);
	return 0;
}

Measured memory_bytes: 256
//*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    mint a,b;
    cin>>a>>b;
    if(a>b) cout<<"GREATER\n";
    if(a==b)cout<<"EQUAL\n";
    if(a<b) cout<<"LESS\n";
    
    return 0;
}


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

int n, k;
double ex[200000], pre[200001];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		double val;
		cin >> val;
		ex[i] = (val * (val + 1)) / (2 * val);
	}
	double mx = 0;
	for(int i = 1; i <= n; i++){
		pre[i] = pre[i - 1] + ex[i - 1];
		mx = max(mx, pre[i] - pre[max(0, i - k)]);
	}
	cout << fixed << setprecision(6) << mx << "\n";
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<int>>A(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>A[i][j];
    }
  }

  vector<tuple<int,int,int,int>>p;

  int cnt=0;
  int i=0,j=0;
  for(int r=0;r<H*W-1;r++){
    int a=i,b=j;
    if(i%2!=0){
      if(j>0){j--;}
      else{i++;}
    }
    else{
      if(j<W-1){j++;}
      else{i++;}
    }
    int c=i,d=j;
    if(A[a][b]%2!=0){
      cnt++;A[a][b]--;A[c][d]++;
      p.push_back(make_tuple(a+1,b+1,c+1,d+1));
    }
  }
  cout<<cnt<<endl;
  for(auto k:p){
    int a,b,c,d;
    tie(a,b,c,d)=k;
    cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl; 
  }
  return 0;  
}

Measured memory_bytes: 6324
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    vector<string> S(N);
    rep( i, N ) cin >> S[i];

    int M = in;
    vector<string> T(M);
    rep( i, M ) cin >> T[i];

    int ans = 0;
    for( string s : S ) {
        int tmp = 0;
        rep( i, N ) tmp += S[i] == s;
        rep( i, M ) tmp -= T[i] == s;
        ans = max( ans, tmp );
    }

    cout << ans << "\n";
}


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

using namespace std;

#define ll       long long

#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)

#define  pfi(x)   printf("%d", x)
#define  pfl(x)   printf("%lld", x)
#define  pfd(x)   printf("%lf", x)
#define  pfc(x)   printf("Case %d: ", x++)
#define  ps       printf(" ")
#define  pn       printf("\n")

#define  pb       push_back
#define  ppb      pop_back
#define  pf       push_front
#define  ppf      pop_front
#define  In       insert
#define  All(a)   a.begin(), a.end()

std::vector<int> edges[100005];
int dp[100005];

int solve(int u)
{
	if(dp[u] != -1)
		return dp[u];

	int p = 0;
	for(int i = 0; i < edges[u].size(); i++)
		p = max(solve(edges[u][i]), p);

	return dp[u] = p + 1;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n, m;
    sci(n), sci(m);

    memset(dp, -1, sizeof dp);

    int x, y, i;

    for(i = 0; i < m; i++)
    {
    	sci(x), sci(y);
    	edges[x].pb(y);
    }

    int ans = 0;

    for(i = 1; i <= n; i++)
    	ans = max(ans, solve(i));

    cout << ans - 1;

    return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>
#include<algorithm>
using namespace std;
int a,b,c;
int main(){
  scanf("%d%d%d",&a,&b,&c);
  if(a<c && c<b){
    printf("Yes\n");
  }else if(b<c && c<a){
    printf("Yes\n");
    
  }else{
    printf("No\n");
  }
  
}

Measured memory_bytes: 128
U = 2*10**6+1
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z *= fact_inv[n-k]
    z %= MOD
    return z

k = int(input())
S = input()
n = len(S)
ans = 0
for i in range(n-1, n+k):
  temp = comb(i, n-1)*pow(25, i-(n-1), MOD)*pow(26, n+k-1-i, MOD)
  temp %= MOD
  ans += temp
ans %= MOD
print(ans)

Measured memory_bytes: 117088
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 2000005
  #define INF 1000000000000
  #define eps 1e-6
  #define int long long


string brute(int n)
{
  if(n == 0)
  {

    return "P";
  }
  else return ("B" + brute(n-1) + "P" + brute(n-1)+ "B");
}


int b[N],p[N];



int32_t main()
{



    int n,x;
    cin >> n >> x;

    b[0] = 1;
    p[0] = 1;

    for(int i = 1; i <= n; i++)
    {
      b[i] = b[i-1]*2 + 3;
      p[i] = p[i-1]*2 + 1;
    }

    int ans = 0;

    x--;

    for(int i = n; i >= 0; i--)
    {
      if(x == 0)
        {
          if(i == 0)
            {
              ans++;
              
            }
            break;
        }
        else if(x == (b[i] -1)/2)
        {
          ans += p[i-1] + 1;
          break;
        }
        else if(x == b[i] - 1)
        { 
          ans += p[i];
          break;
        }
        else if(x <(b[i] -1)/2 )
        {
          x--;
        }
        else
        {
          x-= b[i-1] + 2;
          ans += p[i-1] + 1;
         }
    }



    cout << ans;




    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
int ans[MAXN];

int main() {
    ans[0] = 1;
    for (int i = 1; i <= 100000; i++) {
        int tmp = i;
        vector<int> a, b;
        while (tmp) {
            a.push_back(tmp % 10);
            tmp /= 10;
        }
        b = a;
        reverse(a.begin(), a.end());
        if (a == b)
            ans[i] = ans[i - 1] + 1;
        else
            ans[i] = ans[i - 1];
    }
    int n, m;
    cin >> n >> m;
    cout << ans[m] - ans[n - 1];
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
	int n, a;
	scanf("%d", &n);
	bool any = false;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a & 1)
			any = true;
	}
	if (any)
		printf("first\n");
	else
		printf("second\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int N = 100005;
using namespace std;
typedef long long ll;
int a[N];
int n;
bitset<4000010> f;
int main()
{
	int i,j,k=0;
	scanf("%d",&n);
	f[0]=1;
	for(i=1;i<=n;i++)
	  {
       scanf("%d",&j);
       f|=f<<j;
       k+=j;
      }
    for(i=(k+1)/2;!f[i];i++);
    printf("%d\n",i);
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)



int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n, 0);
    rep(i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a; --b;
        cnt[a]++; cnt[b]++;
    }

    for(auto&& i : cnt) {
        if(i & 1) {
            puts("NO");
            return 0;
        }
    }

    puts("YES");

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	while (A >= B) {
		B *= 2;
		K--;
	}
	while (B >= C) {
		C *= 2;
		K--;
	}
	if (K < 0)cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  int N,M,ans=0;
  cin >> N >> M;
  int A[N+10][M+10],B[M+10]={};
  for(int i=0; i<N; i++){
    int K; cin >> K;
    for(int j=0; j<K; j++){
      cin >> A[i][j];
      B[A[i][j]]+=1;
    }
  }
  for(int i=0; i<=M; i++){
    if(B[i]==N) ans+=1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t a,b,k;
  cin >> a >> b >> k;
  if(a>=k){
    cout << a-k << " " << b << endl;
  }
  else{
    if(a+b-k<=0){
      cout << 0 << " " << 0 << endl;
    }
    else{
      cout << 0 << " " << a+b-k << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdio.h>
using namespace std;
int main()
{
    int N,M;
    scanf("%d%d",&N,&M);
    double result=0;
    for(int i=1;i<=2000;i++)
    {
        result+=(1900*M+100*(N-M))*i*(pow((pow(2,M)-1)/(pow(2,M)*1.0),i-1)/(pow(2,M)*1.0));
    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
 
unsigned int getCost(int changeNum, vector<int> &a){
  unsigned int cost = 0;
  const size_t aSize = a.size();
  for(int i = 0; i < aSize; i++){
    cost += pow(a[i] - changeNum, 2.0);
  }
  return cost;
}
 
unsigned int getResult(vector<int> &a){
  unsigned int minCost = 1e9;
  for(int i = -100; i <= 100; i++){
    unsigned int cost = getCost(i, a);
    minCost = min(cost, minCost);
  }
  return minCost;
}
 
int main(){
  int N;
  cin >> N;
  vector<int> a;
  for(int i = 0; i < N; i++){
    int ai;
    cin >> ai;
    a.push_back(ai);
  }
  unsigned int result = getResult(a);
  cout << result << endl;
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // cin >> T;
    while(T--){
        cin >> n;
        ll ans = 0;
        for(ll i=1;i<=n;i++){
            ll d = n/i;
            if(n%i==0)
                d--;
            if(d<0)
                d = 0;
            ans += d;
        }
        cout << ans << "\n";
        
    }

    return 0;
}


Measured memory_bytes: 3664
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int N;
    cin >> N;

    cout << "Christmas";

    int n = 25;
    while(n > N) {
        cout << " Eve";
        --n;
    }

    cout << endl;
}


Measured memory_bytes: 892
antennas = [int(input()) for _ in range(5)]
k = int(input())

flgs = [abs(antennas[i] - antennas[j]) <= k
             for i in range(len(antennas)-1) 
             for j in range(i+1,len(antennas))
            ]

print("Yay!" if all(flgs) else ":(")

Measured memory_bytes: 3188
#include <stdio.h>
 
int main(void){
 
    int m, f, r;
    char result;
 
 
    for (;;){
        scanf("%d %d %d", &m, &f, &r);
 
        if (m == -1 && f == -1 && r == -1){
            break;
        }
        else if (m == -1 || f == -1){
            result = 'F';
        }
        else if (m + f >= 80)
        {
            result = 'A';
        }
        else if (m + f >= 65 && m + f < 80)
        {
            result = 'B';
        }
        else if (m + f >= 50 && m + f < 65)
        {
            result = 'C';
        }
        else if (m + f >= 30 && m + f < 50)
        {
            if (r >= 50){
                result = 'C';
            }
            else
            {
                result = 'D';
            }
        }
        else if (m + f < 30)
        {
            result = 'F';
        }
        printf("%c\n", result);
    }
 
    return 0;
}

Measured memory_bytes: 600
N = int(input())

d = [ list(map(int,input().split())) for i in range(N)]

for i in range(N-2):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        print("Yes")
        break
else:
    print("No")

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

signed main() {
    string ss, ts;
    cin >> ss >> ts;
    vector<string> ans;
    rep(i, ss.size() - ts.size() + 1) {
        if (ss[i] != '?' && ss[i] != ts[0]) continue;
        bool f = true;
        inc(j, 1, ts.size()) {
            if (ss[i+j] != '?' && ss[i+j] != ts[j]) f = false;
        }
        if (f) {
            string a(ss);
            copy(begin(ts), end(ts), begin(a) + i);
            ans.emplace_back(a);
        }
    }
    if (ans.empty()) { cout << "UNRESTORABLE" << nl; return 0; }

    sort(begin(ans), end(ans));
    string& a = ans[0];
    rep(i, a.size()) {
        if (a[i] == '?')
            cout << 'a';
        else
            cout << a[i];
    }
    cout << nl;
}


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

int main(){
  double w,h,x,y;cin >> w >> h >> x >> y;
  double ans = w*h/2;int spl;
  if(x*2 == w && y*2 == h)spl = 1;
  else spl = 0; 
  printf("%.6lf %d\n",ans,spl);
  return 0;
}

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

typedef
tree<ll, null_type, less<ll>, 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 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("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vi cnt(26);
    forn(i, n){
        string s;
        cin >> s;
        cnt[s[0] - 'A']++;
    }
    int ans = 0;
    while (true){
        vpii l;
        forn(i, 26){
            if (cnt[i] > 0) l.pb({cnt[i], i});
        }
        Sort(l), Reverse(l);
        if (l.size() < k) break;
        ans++;
        forn(i, k) cnt[l[i].S]--;
    }
    cout << ans << '\n';
}

bool multitest = false;

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

Measured memory_bytes: 3656
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	s := oneStr()

	l := len(s)
	strs := []string{"dream", "dreamer", "erase", "eraser"}
	for i := l - 1; i >= 0; i-- {
		for j := 0; j < len(strs); j++ {
			if s[i:len(s)] == strs[j] {
				s = s[:i]
				break
			}
		}
	}
	if len(s) == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums []int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums []int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func sum(nums []int) int {
	sum := 0
	for i := 0; i < len(nums); i++ {
		sum += nums[i]
	}
	return sum
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}

func sumOfEachDigit(num int) int {
	sum := 0
	for num > 0 {
		sum += num % 10
		num /= 10
	}
	return sum
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

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

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

  cin >> q;
  int v;
  int cnt = 0;
  for (int i = 0; i < q; i++) {
    cin >> v;
    for (int j = 0; j < n; j++) {
      if (S[j] == v) {
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
  
  return 0;
}

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

#define inf 1e9+1
vector<long long >v;
vector<long long>w;
vector<vector<long long >>dp;

long long minwt(long long n,long long val){

        if(dp[n][val]!=-1){
            return dp[n][val];
        }
        long long mn = minwt(n-1,val);
        if(val>=v[n]){
            long long b = minwt(n-1,val-v[n])+w[n];
            mn = min(mn,b);
        }
        return mn;
}
void solve(){
    int n,wt;cin>>n>>wt;
    v.resize(n);
    w.resize(n);
    int mxval = n*1000;
    dp.resize(2,vector<long long>(mxval+1,inf));

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

    dp[0][0]=0;
    dp[0][v[0]]=w[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<=mxval;j++){
            dp[i&1][j]= dp[(i-1)&1][j];
            if(j>=v[i]){

                dp[i&1][j]= min(dp[i&1][j],dp[(i-1)&1][j-v[i]]+w[i]);
            }

        }
        //cout<<i<<"\n";
    }

    long long ans = 0;
    int idx=1;
    if(n&1){
        idx =0;
    }
    for(int i=mxval;i>=0;i--){
        if(dp[idx][i]<=wt){
            ans = i;
            break;
        }
    }
    cout<<ans<<"\n";
}

int main(){

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


Measured memory_bytes: 2560
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""043-b"""


import sys


def main():
    """Main function."""
    s = input()

    res = ""
    for c in s:
        if c == 'B':
            res = res[:-1]
        else:
            res += c

    print(res)


if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int ans=0;
    for (int i=0; i<n; i++){
        int a;
        cin >> a;
        int s = d / a;
        if (d % a != 0) s++;
        ans += s;
    }
    out(ans + x);
}

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

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  string s; cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) cout<< "Yes" <<endl;
  else cout<< "No" <<endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int,x)

function main()
  (N,L) = map(parseInt,split(readline()))
  a = zeros(Int64, N)
  for i = 1:N
    a[i] = L+i-1
  end
  b = zeros(Int64, N)
  c = sum(a)
  for i = 1:N
    b[i] = c-a[i]
  end
  S = b[1]
  for i = 1:(N-1)
    if abs(c-b[i+1]) < abs(c-b[i])
      S = b[i+1]
    end
  end
  println(S)
end

main()

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

using namespace std;

typedef pair<int,int> pi;

int main()
{
    string a,b;
    cin>>a>>b;
    int n = a.length();
    int m = b.length();

    vector<vector<int> > ans(n+1,vector<int>(m+1,0));
    vector<vector< pi > > prev(n+1,vector<pi>(m+1,make_pair(-1,-1)));

    for(int i=n-1; i>=0; i--)
    {
        for(int j=m-1; j>=0; j--)
        {
            if(a[i]==b[j])
            {
                ans[i][j] = 1 + ans[i+1][j+1];
                prev[i][j] = make_pair(i+1,j+1);
            }
            else
            {
                if(ans[i][j+1]>ans[i+1][j])
                {
                    ans[i][j] = ans[i][j+1];
                    prev[i][j] = prev[i][j+1];
                }
                else
                {
                    ans[i][j] = ans[i+1][j];
                    prev[i][j] = prev[i+1][j];
                }
            }
        }
    }
    string final;
    pi p = prev[0][0], last=make_pair(-1,-1);
    // if(a[0]!=b[0])
    //     p = prev[p.first][p.second];
    while(p!=last)
    {
        int i = p.first-1;
        final.push_back(a[i]);

        p = prev[p.first][p.second];
    }
    cout<<final;
    return 0;
}

Measured memory_bytes: 105984