akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> v[31];
    rep(i, N) {
        int K; cin >> K;
        while(K--) {
            int A; cin >> A;
            A--;
            v[i].push_back(A);
        }
    }
    int ans = 0;
    rep(i, M) {
        bool ok = true;
        rep(j, N) {
            bool exist = false;
            for(auto& e: v[j]) {
                if(e == i) exist = true;
            }
            if(!exist) ok = false;
        }
        ans += ok;
    }
    cout << ans << endl;

    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

struct edge { int to, cost; };

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	string a;
	cin >> a;
	int ans = 0;
	for(int i = 0; i < a.size(); i++){
		int cnt = 0;
		for(int j = i; j < a.size() && (a[j] == 'A' || a[j] == 'C' || a[j] == 'G' || a[j] == 'T'); j++){
			cnt++;
		}
		ans = max(ans,cnt);
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> numbers = new ArrayList<Integer>();
	
		String num_size = in.next();
		String input;

		int size = Integer.parseInt(num_size);
		int i = 0;

		for(i = 0; i < size; i++){
			input = in.next();
			numbers.add(Integer.parseInt(input));
		}
		int v,j,k;
		String str;
		for(i = 0; i < size; i++){
			v = numbers.get(i);
			j = i - 1;
			while( (j >= 0) && (numbers.get(j) > v)){
				numbers.set(j+1, numbers.get(j));
				j--;
			}
		 numbers.set(j+1, v);
		 for(k = 0 ;k < size ;k++){
			 if(k != size - 1)
				 System.out.print(numbers.get(k) + " ");
			 else 
				 System.out.print(numbers.get(k));				 
		 }
			 System.out.print("\n");
		}
	}
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int Q;
int dp[64][64][32];

int dfs(int c, int a, int n){
  if(dp[c][a][n] >= 0) return dp[c][a][n];
  int res = 0;
  if(c > 0 && a > 0 && n > 0) res = max(res, dfs(c-1, a-1, n-1)+1);
  if(c > 1 && a > 0) res = max(res, dfs(c-2, a-1, n)+1);
  if(c > 2) res = max(res, dfs(c-3, a, n)+1);
  return dp[c][a][n] = res;
}

int main(){
  cin >> Q;
  rep(i, Q){
    memset(dp, -1, sizeof(dp));
    int c, a, n;
    cin >> c >> a >> n;
    int res = 0;
    while(c > 8 && a > 4 && n > 0){
      res++;
      c--;
      a--;
      n--;
    }

    while(c > 8 && a > 4){
      res++;
      c-=2;
      a--;
    }

    while(c > 8){
      res++;
      c-=3;
    }
    res += dfs(c, a, n);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1668
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr int INF = 1000000000;

int main()
{
  int a, b, c, x, y;
  cin>>a>>b>>c>>x>>y;
  int mn = INF;
  REP(i,max(x,y)+1) {
    int ab = 2*i;
    int needa = max(0, x - i);
    int needb = max(0, y - i);
    int cost = ab*c + needa * a + needb * b;
    mn = min(mn, cost);
  }
  cout << mn << endl;
  return 0;
}


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

using namespace std;

#define Speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define MOD 998244353
#define fi first
#define se second

const int NR = 2e5 + 10;

ifstream in ("date.in");
ofstream out ("date.out");

int a[NR] , n , m , sum , cnt;
int main()	{
    Speed;
    int i;
    cin >> n >> m ;
    for ( i = 1 ; i <= n ; ++ i )   {
        cin >> a[i];
        sum += a[i];
    }
    for ( i = 1;  i <= n ; ++ i )    {
        if ( a[i]* 4 * m >= sum )   cnt ++ ;
    }
    if ( cnt >= m ) cout << "Yes\n";
    else            cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 1e5; // CAMBIAR ESTE

// GJNM

int main(){
	int a,b,c,k;
	riii(a,b,c);
	ri(k);

	int ans = 0;
	ans += min(a,k);
	k = max(k-a,0);
	if ( k>0 )
		k -= b;
	if ( k>0 )
		ans -= k;
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
	long long int K,i,j,k,l,m;
	char S[101];
	cin >> S >> K;
	m = strlen(S);
	for (i = 0; i < m; i++) {
		if (S[i] != '1') {
			break;
		}
	}

	if (K <= i)
		cout << "1" << endl;
	else
		cout << S[i] << endl;
	
    return 0;
}



Measured memory_bytes: 256
n, m, x = map(int, input().split())
c, a = [], []
for _ in range(n):
    tmp = [int(i) for i in input().split() ]
    c.append(tmp[0])
    a.append(tmp[1:])

ans = 10**8
for s in range(2**n):
    cost = 0
    d = [0] * m
    for i in range(n):
        if (s >> i & 1):
            cost += c[i]
            for j in range(m):
                d[j] += a[i][j]
    ok = True
    for j in range(m):
        if (d[j] < x):
            ok = False
    if (ok):
        ans = min(ans, cost)

if (ans == 10**8):
    print("-1")
else:
    print(ans)

Measured memory_bytes: 9192
n, k = map(int, input().split())
X = list(map(int, input().split()))
T = []

for i in range(n - k + 1):
    l = X[i]
    r = X[i + k - 1]
    route1 = abs(l) - l + r
    route2 = abs(r) - l + r
    temp = min(route1, route2)
    T.append(temp)
    
print(min(T))

Measured memory_bytes: 14224
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    let m=read::<usize>();
    let mut a=vec![0;m];
    for _ in 0..n{
        let k=read::<usize>();
        for _ in 0..k{
            let s=read::<usize>()-1;
            a[s]+=1
        }
    }
    let mut c=0;
    for i in 0..m{
        if a[i]==n{c+=1}
    }
    println!("{}",c)
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>

int main()
{
    // input
    std::string S;
    std::cin >> S;

    int N = S.size();
    std::vector<int> L(N), R(N);
    for(int i=0; i<N; i++){
        if(S[i] == 'L') L[i] = L[i-1] + 1;
        else L[i] = -1;
    }
    for(int i=N-1; i>=0; i--){
        if(S[i] == 'R') R[i] = R[i+1] + 1;
        else R[i] = -1;
    }

    std::vector<int> count(N);
    for(int i=0; i<N; i++){
        if(L[i] != -1) count[i - L[i] - (L[i]%2)]++;
        if(R[i] != -1) count[i + R[i] + (R[i]%2)]++;
    }

    // output
    for(int i=0; i<N; i++) printf("%d ", count[i]);
    printf("\n");
}

Measured memory_bytes: 1792
// Created by Nandu Vinodan
#include "bits/stdc++.h"

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;


ll getCount(ll n) {
	if (n <= 1) return 0LL;
	return (n * (n-1))/2;
}

void testcase() {
    int n; cin >> n;

    vector<int> v(n+1, 0);
    set<int> s;
    vi in(n);
    rep (i, 0, n-1) {
    	int x; cin >> x;
    	in[i]  = x;
    	v[x]++;
    	s.insert(x);
    }

    ll tot = 0;
    unordered_map<int, ll> mp;
    for (auto it = s.begin(); it!=s.end(); it++) {
    	ll val =  getCount((ll)v[*it]);
    	mp[*it] = val;
    	tot += val;
    	//db2(*it, val);
    }


    rep (i, 0, n-1) {
    	int val = in[i];
    	//db3(val, tot, mp[val]);
    	cout << tot - mp[val] + getCount((ll)v[val]-1) << "\n";
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 15048
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int a,p;
int main(){
	cin>>a>>p;
	p+=a*3;
	cout<<p/2<<endl;
	return 0;
}


Measured memory_bytes: 256
out_grade = ""

while True:
    m, f, r = map(int, input().split(" "))

    if m==f==r==-1:
        #EOF
        break
    
    if m==-1 or f==-1:
        out_grade = "F"
    elif m + f >= 80:
        out_grade = "A"
    elif m + f >= 65:
        out_grade = "B"
    elif m + f >= 50:
        out_grade = "C"
    elif m + f >= 30:
        if r >= 50:
            out_grade = "C"
        else:
            out_grade = "D"
    else:
        out_grade = "F"
    
    print(out_grade)

Measured memory_bytes: 7624
#include<stdio.h>

int main(){
int a[3],b[3];
int s,t,c,d,i,j,k;
s =t=c=d=0;
for(i=0;i<3;i++)
scanf("%d %d",&a[i],&b[i]);

for(i = 0;i<3;i++){
if(a[i]==1)
s++;
if(a[i]==2)
t++;
if(a[i]==3)
c++;
if(a[i]==4)
d++;
}

for(i = 0;i<3;i++){
if(b[i]==1)
s++;
if(b[i]==2)
t++;
if(b[i]==3)
c++;
if(b[i]==4)
d++;
}

if(s >=3 || t >= 3 || c >= 3 || d >= 3)
puts("NO");
else
puts("YES");

return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a[5],b,c;
int main()
{
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[2]-a[1]==a[3]-a[2])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(){
  int x1, x2, x3, x4, y1, y2, y3, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3 = x2 - ( y2 - y1 );
  y3 = y2 + ( x2 - x1 );
  x4 = x3 - ( y3 - y2 );
  y4 = y3 + ( x3 - x2 );
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
int a[100005];
int b[100005];
int c[100005];

int dp[3][100005];
//a-0. b-1. c-2

int main()
{
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];

	for (int i = 1;i < n;i++) {
		dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
		dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i];
		dp[2][i] = max(dp[1][i - 1], dp[0][i - 1]) + c[i];
	}

	cout << max(max(dp[0][n - 1], dp[1][n - 1]), dp[2][n - 1]) << endl;

	return 0;
}


Measured memory_bytes: 2560
#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> PI;
typedef pair<ll, ll> PL;

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, d; cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	rep(i,n){
		rep(j,d){
			cin >> x.at(i).at(j);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			int sum = 0;
			for(int k = 0; k < d; k++){
				sum += (x.at(i).at(k) - x.at(j).at(k))*(x.at(i).at(k) - x.at(j).at(k));
			}
			for(int p = 1; p * p <= sum; p++){
				if(p * p == sum) ans++;
			}
		}
	}
	cout << ans << endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
int a[2000001], h;
void maxHeapify(int i){
    int largest, r, l, tmp;
    r=2*i+1;
    l=2*i;
    if(l<=h&&a[l]>a[i])largest=l;
    else largest=i;
    if(r<=h&&a[r]>a[largest])largest=r;
    if(largest!=i){
        tmp=a[i];
        a[i]=a[largest];
        a[largest]=tmp;
        maxHeapify(largest);
    }
}
int main(){
    int i;
    scanf("%d", &h);
    for(i=1; i<=h; i++)scanf("%d", &a[i]);
    for(i=h/2; i>0; i--)maxHeapify(i);
    for(i=1; i<=h; i++)printf(" %d", a[i]);
    printf("\n");
    return 0;
}


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

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

    string a = S.substr(0, N/2);
    string b = S.substr(N/2, N/2);

    if (N % 2 != 0) {
        cout << "No" << endl;
    } else {
        if (a == b) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power_mod(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define outaa(a, m, n) rep(i, m) {rep(j, n) cout << a[i][j] << " "; cout << endl;} cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl

//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always


map<int, int> mp;
void prime_factorize(int x) {
    int tmp = x;
    rep3(i, 2, sqrt(x) + 1) {
        while (tmp % i == 0) {
            mp[i]++;
            tmp /= i;
        }
    }
    if (tmp != 1) mp[tmp] = 1;
}


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    
    
    COMinit();
    
    int n, m; cin >> n >> m;
    prime_factorize(m);
    
    
    ll ans = 1;
    for (auto e : mp) {
        //out(e.F << " " << e.S);
        (ans *= COM(e.S + n - 1, n - 1)) %= mod;
    }
    (ans += mod) %= mod;
    out(ans);
    
    
}


Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,s;
    map<ll,ll>mp;
    cin>>n;
    c=0;
    s=0;
    while(c<2)
    {
        s++;
        mp[n]++;
        if(mp[n]==2)
        {
            break;
        }
        if(n%2==0)
        {
            n=n/2;
        }
        else if(n%2==1)
        {
            n=3*n+1;

        }
    }
    cout<<s<<endl;
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool unite(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool same(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll getsize(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	int a[m], b[m];
	UnionFind ut(n);

	rep(i, m) cin >> a[i] >> b[i], a[i]--, b[i]--;

	int ans[m+1] = {};
	for(int i = m-1; i >= 0; i--) {
		if(ut.same(a[i], b[i])) ans[i] = ans[i+1];
		else ans[i] = ans[i+1] + ut.getsize(a[i]) * ut.getsize(b[i]);
		ut.unite(a[i], b[i]);
	}

	rrep(i, m) cout << n*(n-1)/2 - ans[i] << endl;
	return 0;
}

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

int n, q;

const int MOD = 1e9 + 7;

int a[3055];
long long dp[3055][3055];

int mod_pow(int n, int k) {
	if (k == 0) return 1;
	
	int res = mod_pow(n, k >> 1);
	res = (1ll * res * res) % MOD;
	
	if (k & 1) res = (1ll * res * n) % MOD;
	return res;
}
int main() {
	cin >> n >> q;
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) {
		if (a[i] > a[j]) {
			dp[i][j] = 1;
		}
	}
	
	int p5 = mod_pow(2, MOD - 2);
	
	for (int _ = 0; _ < q; _++) {
		int x, y;
		scanf("%d %d", &x, &y);
		
		if (x == y) continue;
		
		if (x > y) swap(x, y);
		
		for (int i = 1; i <= n; i++) if (i < x || i > y) {
			{
				int l = dp[i][x];
				int r = dp[i][y];
				
				dp[i][x] = (1ll * l * p5 + 1ll * r * p5) % MOD;
				dp[i][y] = (1ll * l * p5 + 1ll * r * p5) % MOD;
			}
			
			{
				int l = dp[x][i];
				int r = dp[y][i];
				
				dp[x][i] = (1ll * l * p5 + 1ll * r * p5) % MOD;
				dp[y][i] = (1ll * l * p5 + 1ll * r * p5) % MOD;
			}
		}
		
		for (int i = x + 1; i < y; i++) {
			{
				int l = dp[i][x];
				int r = dp[i][y];
				
				dp[i][x] = (1ll * l * p5 + 1ll * r * p5) % MOD;
				dp[i][y] = (1ll * l * p5 + 1ll * r * p5) % MOD;
			}
			
			{
				int l = dp[x][i];
				int r = dp[y][i];
				
				dp[x][i] = (1ll * l * p5 + 1ll * r * p5) % MOD;
				dp[y][i] = (1ll * l * p5 + 1ll * r * p5) % MOD;
			}
		}
		
		{
			int l = dp[x][y];
			int r = dp[y][x];
			
			dp[x][y] = (1ll * l * p5 + 1ll * r * p5) % MOD;
			dp[y][x] = (1ll * l * p5 + 1ll * r * p5) % MOD;
		}
	}
	
	int p = 1;
	long long res = 0;
	
	for (int i = 1; i <= q; i++) {
		p = (p + p) % MOD;
	}
	
	for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) {
		res = (1ll * res + 1ll * p * dp[i][j] % MOD) % MOD;
	}
	
	cout << res << endl;
}


Measured memory_bytes: 71936
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	inp(n) inp(k)
	inpa(a,n)
	int ans=0;
	fo(i,n)
		ans+=(a[i]>=k);
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 

using namespace std;

const int mod = 924844033,g=5,maxn = 2e5+10;
struct node{int to,next;} e[1010010];
int N,K,cnt[1010100],tot,h[1010000],sz[1010100];
ll tmp1[1010100],tmp2[1010000];
inline ll ksm(ll x,ll y){
	ll res=1;
	
	while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;y>>=1;
		//cout<<y<<endl;
	}//cout<<x<<" "<<y<<endl;
	return res;
}
inline void add(int from,int to){e[++tot].next=h[from];h[from]=tot;e[tot].to=to;}
inline void DFS(int now,int ffa){
	sz[now]=1;
	//cout<<now<<" "<<ffa<<endl; 
	for(rint i=h[now];i;i=e[i].next) {
		int to=e[i].to;if(to==ffa) continue;
		DFS(to,now);sz[now]+=sz[to];
		cnt[sz[to]]++;
	}
	if(now!=1)
	cnt[N-sz[now]]++;
}
int fac[1010000],Ifac[1010000];
inline ll C(int a,int b){
	return 1ll*fac[a]*Ifac[b]%mod*Ifac[a-b]%mod; 
} 
inline void NTT(ll *A,int len,int ca){
	for(rint j=0,i=1;i<len;++i) {
		for(rint s=len;j^=s>>=1,~j&s;);
		if(i>j) swap(A[i],A[j]);
	}
	for(rint i=2;i<=len;i<<=1) {
		ll gi=g;if(ca==-1) gi=ksm(gi,mod-2);
		ll wn=ksm(gi,(mod-1)/i);
		for(rint j=0;j<len;j+=i) 
		{
			ll w=1;
			for(rint k=0;k<i/2;++k) {
				ll x=A[j+k],y=w*A[j+k+i/2]%mod;
				A[j+k]=(x+y)%mod,A[j+k+i/2]=(x-y+mod)%mod;
				w=w*wn%mod; 
			}
		}
	}
	if(ca==-1) {ll Inv=ksm(len,mod-2);for(rint i=0;i<len;++i) A[i]=A[i]*Inv%mod;}
}
inline void Init(){
	fac[0]=Ifac[0]=1;
	for(rint i=1;i<=maxn;++i) fac[i]=1ll*fac[i-1]*i%mod;
	
	Ifac[maxn]=ksm(fac[maxn],mod-2);
	//return ;
	for(rint i=maxn-1;i;--i) Ifac[i]=1ll*Ifac[i+1]*(i+1)%mod;//return ;
	int len=1;
	
	while(len<=N*2) len<<=1;
	for(rint i=0;i<len;++i) tmp1[i]=1ll*fac[i]*cnt[i]%mod;
	for(rint i=0;i<=N;++i) tmp2[N-i]=ksm(fac[i],mod-2);
	NTT(tmp1,len,1);NTT(tmp2,len,1);
	for(rint i=0;i<len;++i) tmp1[i]=tmp1[i]*tmp2[i]%mod;
	NTT(tmp1,len,-1);
}
int main(){
	cin>>N;
	for(rint i=1;i<N;++i) {
		int a,b;cin>>a>>b;
		add(a,b);add(b,a);
	}
	DFS(1,0);
	
	Init();
	for(rint i=1;i<=N;++i) {
		cout<<(1ll*N*C(N,i)%mod-1ll*ksm(fac[i],mod-2)*tmp1[i+N]%mod+mod)%mod<<"\n";
	}
	return 0;
} 

Measured memory_bytes: 32112
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
const int N = 205, mod = 1000000007;
int n, a[N], f[N][N][N];
int movk[5] = { -1, 0, 1, 0, 1 };
int movj[5] = { 0, 0, 0, 1, 1 };
int main()
{
	scanf ("%d", &n);
	Rep(i, 1, n * 2 - 1) scanf ("%d", &a[i]);
	sort(a + 1, a + n * 2);
	f[1][1][1] = 1;
	Rep(i, 1, n - 1) {
		Rep(j, 1, n) {
			Rep(k, 1, j) {
				Rep(x, 0, 4) {
					int _k = k + movk[x], _j = j + movj[x];
					if (!_k || _k > _j) continue ;
					bool f0, f1;
					f0 = (a[i] != a[i + 1]);
					f1 = (a[2 * n - i] != a[2 * n - i - 1]);
					Rep(y, 0, f0) Rep(z, 0, f1) {
						int tj = _j, tk = _k;
						if (y) tj --, tk --;
						if (z) tj --;
						if (!tk || tk > tj) continue ;
						(f[i + 1][tj][tk] += f[i][j][k]) %= mod;
					}
				}
			}
		}
	}
	printf("%d\n", f[n][1][1]);

	return 0;
}

Measured memory_bytes: 8960
#[warn(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
   input! {
      n: usize,
      a: [usize; n]
   }
   let mut ans = 0;
   let mut dp = vec![0usize; n + 1];
   for i in 0..n {
      if i >= a[i] {
         ans += dp[i - a[i]];
      }
      if a[i] + i < n {
         dp[a[i] + i] += 1;
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 6588
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

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

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int x;
    int y;
    cin>>x>>y;
    if (x>=13){
    cout<<y;
    }
    else if (x>=6 && x<=12){
    y=0.5*y;
    cout<<y;
    }
    else if (x<=5){
        y=0;
        cout<<y;
        }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "
#define F           first
#define S           second
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
//ll hell=1000000007;
ll hell=998244353 ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
// mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());  after namespace std
// srand(chrono::high_resolution_clock::now().time_since_epoch().count()); after ios:base
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

ll modPow(ll base, ll ex, ll m) {
	ll ret = 1;
	while(ex){
		if(ex & 1){
			ret = ret * base % m;
		}
		ex >>= 1;
		base = base * base % m;
	}
	return ret;
}
vector<ll> mFacts, mInvFacts;
ll modFact(int n){ return mFacts[n]; }
ll modInvFact(int n){ return mInvFacts[n]; }
ll modInv(int n, ll m){ return modPow(n, m - 2, m); }
ll modC(int n, int k, ll m){ return modFact(n) * modInvFact(k) % m * modInvFact(n - k) % m; }
void init(int n, ll m){
    mFacts.resize(n + 1);
    mInvFacts.resize(n + 1);
    mFacts[0] = 1;
    for(int i = 1; i <= n; i++){
        mFacts[i] = mFacts[i - 1] * i % m;
    }
    mInvFacts[n] = modInv(mFacts[n], m);
    for(int i = n - 1; i >= 0; i--){
        mInvFacts[i] = mInvFacts[i + 1] * (i + 1) % m;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    init(1e6, M);
    int n, m;
    cin >> n >> m;
    map<int, int> fs;
    for(int i = 2; i <= sqrt(m); i++){
        while(m % i == 0){
            fs[i]++;
            m /= i;
        }
    }
    if(m > 1){
        fs[m]++;
    }
    printde(fs);
    ll ans = 1;
    for(auto& p : fs){
        ans = ans * modC(n - 1 + p.second, p.second, M) % M;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 15872
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int N;
int x[30], y[30], r[30], c[30];
int overlap[30];
char dp[(1<<24)+1];

int rec(int S) {
  if (dp[S] >= 0) return dp[S];
  int ret = 0;
  // select lhs
  for (int i = 0; i < N - 1; ++i) {
    if (S >> i & 1) continue;
    if ((overlap[i] | S) != S) continue;
    // select rhs
    for (int j = i+1; j < N; ++j) {
      if ((S >> j & 1) || c[i] != c[j]) continue;
      if ((overlap[j] | S) != S) continue;
      // printf("%d : %d %d : %d %d : %d %d\n", S, i, j, overlap[i], overlap[j]);
      // remove
      ret = max(ret, rec(S|(1<<i)|(1<<j)) + 2);
    }
  }
  return dp[S] = ret;
}

int solve() {
  // check overlap
  memset(overlap, 0, sizeof overlap);
  for (int i = 1; i < N; ++i) {
    int lapped = 0;
    for (int j = 0; j < i; ++j) {
      int dx = x[i] - x[j], dy = y[i] - y[j], dc = r[i] + r[j];
      if (dx * dx + dy * dy < dc * dc) lapped |= (1 << j);
    }
    overlap[i] = lapped;
  }
  memset(dp, -1, sizeof dp);
  return rec(0);
}

int main() {
  while (scanf("%d", &N), N) {
    rep(i,N) scanf("%d%d%d%d", x+i, y+i, r+i, c+i);
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 16000
#include<stdio.h>


int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b&&a<c&&b<c){
		printf("%d %d %d\n",a,b,c);
	}else if(a<c&&a<b&&c<b){
		printf("%d %d %d\n",a,c,b);
	}else if(b<a&&b<c&&a<c){
		printf("%d %d %d\n",b,a,c);
	}else if(b<c&&b<a&&c<a){
		printf("%d %d %d\n",b,c,a);
	}else if(c<a&&c<b&&a<b){
		printf("%d %d %d\n",c,a,b);
	}else if(c<b&&c<a&&b<a){
		printf("%d %d %d\n",c,b,a);
	}else if(a<b&&a<c&&b==c){
		printf("%d %d %d\n",a,b,c);
	}else if(a>b&&a>c&&b==c){
		printf("%d %d %d\n",b,c,a);
	}else if(b<a&&b<c&&a==c){
		printf("%d %d %d\n",b,a,c);
	}else if(b>a&&b>c&&a==c){
		printf("%d %d %d\n",a,c,b);
	}else if(c<a&&c<b&&a==b){
		printf("%d %d %d\n",c,a,b);
	}else if(c>a&&c>b&&a==b){
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

struct Node {
	int	parent=0;
	vector<int> child;
	int	child_num=0;;
	int	h=-1;
};

int	main() {
	int N;
	cin >>N;
	vector<Node> a(N+1);
	for (int i=2; i<=N; i++) {
		int aa;
		cin >>aa;
		a.at(aa).child.push_back(i);
		a.at(aa).child_num++;
		a.at(i).parent=aa;
	}
	list<int> q;
	Rep1(i, N)
		if (0==a.at(i).child_num) {
			a.at(i).h=0;
			int p=a.at(i).parent;
			a.at(p).child_num--;
			if (0==a.at(p).child_num)
				q.push_back(p);
		}
	while(!q.empty()) {
		int n=q.front();
		q.pop_front();
		vector<int> D;
		Rep0(i, a.at(n).child.size()) {
			int child=a.at(n).child.at(i);
			D.push_back(a.at(child).h);
		}
		Sort(D);
		Rev(D);
		int H=0;
		Rep0(i, D.size())
			H=max(H, D.at(i)+i);
		a.at(n).h=H+1;
		int p=a.at(n).parent;
		a.at(p).child_num--;
		if (0==a.at(p).child_num)
			q.push_back(p);
	}
	cout <<a.at(1).h <<endl;
	return 0;
}



Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
  int N, K; cin >> N >> K;
  ll H[200010];
  ll attack_cnt = 0;

  for(int i=0; i<N; ++i) cin >> H[i];

  stable_sort(H, H+N);

  for(int i=0; i<N-K; ++i) {
    attack_cnt += H[i];
  }

  cout << attack_cnt << endl;
}


Measured memory_bytes: 2560
n, k = map(int, input().split())

if k == 0:
    print(n**2)
    exit()

ans = 0
for i in range(1, n+1):
    if i <= k:
        continue
    q, r = divmod(n, i)
    if r < k:
        ans += (i-k)*q
    else:
        ans += (i-k)*q + (r-k+1)
print(ans)


Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
int x,y,z,l,r,m;
signed main(){
  cin>>x>>y>>z;
  r=x/y+1;
  while(l+1<r){
    m=(l+r)/2;
    (m*(y+z)+z<=x?l:r)=m;
  }
  cout<<l;
}

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

int main() {
    long long s;
    cin >> s;

    long long result = 1000, tmp;
    while (s >= 100) {
        tmp = 753 - (s % 1000);
        tmp = (tmp < 0 ? tmp * -1 : tmp);
        if (tmp < result) result = tmp;
        s /= 10;
    }

    cout << result << endl;

    return 0;
}


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

using namespace std;

void check(string s, int till)
{
    int n=s.length();
    for(int i=0;i<till;i++)
    {
        if(s[i]==s[(n-3)/2 - i] && s[i]==s[(n+1)/2 + i] && s[i]==s[(n-1) - i])
        {
            continue;
        }
        else
        {
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
    return ;
}

int main()
{
    string s;
    cin>>s;
    int till=0;
    if((s.length()/2)%2==0)
    {
        till=s.length()/4;
    }
    else
    {
        till=s.length()/4 + 1;
    }
    check(s,till);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int x;
  cin >>x;
  int y=x/2;
 
  if (x%2 ==0) {
std::cout << (double)y / x << std::endl;
  }
  else {
std::cout << (double)(y+1) / x << std::endl;
  }
  
    
  
  
 }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long N,M;
	cin >> N >> M;
	long long A=0;
	for(int i=0;i<M;i++){
		int tmp;
		cin >> tmp;
		A+= tmp;
	}
	long tmp = N-A;
	if(N-A < 0){
		cout << -1 << endl;
	}else{
		cout << tmp << endl;
	}
	return 0;
}



Measured memory_bytes: 3592
/* 
  Krishnakant Tiwari
  Problem Link:
  
 */
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mll map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#define eb	emplace_back
#define ppb	pop_back
#define pf	push_front
#define ppf	pop_front
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define precise(x)	cout<<fixed<<setprecision(x)
const ll MAX=1000004;
const ll INF = 1e18L + 5;
template <typename Arg1>
void pn(Arg1&& arg1) {
    cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) {
    cout << arg1 << "\n";
    pn(args...);
}
template <typename Arg1>
void ps(Arg1&& arg1) {
    cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) {
    cout << arg1 << " ";
    ps(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
    cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
    cin >> arg1;
    read(args...);
}

ll g[MAX];
ll a[MAX];

void solve(){
    ll x,k,d;
    read(x,k,d);
    x=abs(x);
    ll n_s=x/d;
    if(n_s>k){
        pn(x-k*d);
        return ;
    }

    x-=(n_s*d);
    k-=n_s;
    if(k%2==0){
        pn(x);
    }else pn(d-x);
}


int main(){

    _cin
    // ll tc;
    // cin>>tc;
    // while(tc--){
            solve();
    // }

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int
main()
{
  int K; cin >> K;
  ll cnt = 1;
  ll seven = 7;
  rep(i, 0, 90000000){
    if(seven % K == 0){
      cout << cnt << endl;
      return 0;
    }
    seven = (seven * 10 + 7) % K;
    ++cnt;
  }

  cout << -1 << endl;

}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll mod=1e9+7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(ll n, ll k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main(){
    ll n,m;
    cin >> n >> m;
    mint ans=0;
    rep(i,n+1){
        mint del=c.p(m-i,n-i)*c(n,i);
        if(i%2==0){
            ans+=del;
        }
        else{
            ans-=del;
        }
    }
    ans*=c.p(m,n);
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<pair<int, int>> ans;
    for(int i=2; i<=N; i++) ans.push_back({1, i});
    int now = (N-1)*(N-2)/2;
    if(now < K){
        cout << -1 << endl;
        return 0;
    }

    for(int i=2; i<=N; i++) for(int j=i+1; j<=N; j++){
        if(now > K){
            ans.push_back({i, j});
            now--;
        }
    }

    cout << ans.size() << endl;
    for(auto& p : ans) cout << p.first << " " << p.second << endl;
    return 0;
}


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	REP(i, n)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	if (SIZE(mp) <= k)
	{
		print(0);
		return 0;
	}

	vector<int> v;
	REPIT(mp) v.push_back((*it).second);
	ALL(sort, v);

	int ans = 0;
	FOR(i, 0, SIZE(v) - k) ans += v[i];

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 10744
S0 = input()
S0_n = len(S0)
T = input()
T_n = len(T)

T_kouho = []

for i in range(S0_n-T_n, -1, -1):
  for j,k in enumerate(range(i,i+T_n)):
    if T[j] != S0[k] and S0[k] != '?':
      break
  else:
    T_kouho.append(i)
    break

if len(T_kouho) == 0:
  print('UNRESTORABLE')
else:
  i = 0
  for _ in range(S0_n):
    if i >= S0_n:
      break
    if i == T_kouho[0]:
      print(T, end='')
      i += T_n
    elif S0[i] == '?':
      print('a', end='')
      i+=1
    else:
      print(S0[i], end='')
      i+=1

Measured memory_bytes: 3064