akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int N;
    vector<int> P;
    void input() {
        cin >> N;
        P.resize(N);
        cin >> P;
    }
    void solve() {
        int ans = 0;
        for (int i = 0; i < P.size(); i++) {
            auto p = P[i];
            if (p == i + 1) {
                ans++;
                swap(P[i], P[i + 1]);
            }
        }
        cout << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}


Measured memory_bytes: 768
use itertools::Itertools as _;
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcds: [(Usize1, Usize1, usize, u64); q],
    }

    let ans = (0..m)
        .combinations_with_replacement(n)
        .map(|array| {
            abcds
                .iter()
                .filter(|&&(a, b, c, _)| array[b] - array[a] == c)
                .map(|(_, _, _, d)| d)
                .sum::<u64>()
        })
        .max()
        .unwrap();
    println!("{}", ans);
}


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

int main(int argc, char const *argv[]) {
    int N,x;
    cin >> N >> x;
    vector<int> a(N);
    for(int i=0;i<N;i++)cin >> a[i];
    sort(a.begin(),a.end());
    int sum = 0;
    for(int i=0;i<N;i++){
        sum += a[i];
        if(sum <= x)continue;
        else{
           cout << i << endl;
           return 0;
       }
    }
    sum -= a[N];
    if(x - sum == a[N])
        cout << N << endl;
    else
        cout << N-1 << endl;
    // for(int i=0;i<N;i++)cout << a[i] << " ";
    // cout << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
k = [int(i) for i in input().split()]
ans1 = max(k)
k.remove(ans1)
c = ans1
ans2 = 0
for i in k:
  if abs(i-ans1/2) <= c:
    ans2 = i
    c = abs(i-ans1/2)
print(ans1,ans2)


Measured memory_bytes: 14052
#include<stdio.h>
int main()
{
    unsigned long long int n,sum=0,i;
    scanf("%llu",&n);
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            sum=sum;
        else
            sum=sum+i;
    }
    printf("%llu",sum);
    return 0;
}


Measured memory_bytes: 1736
int main(void){ 
  int H,N; 
  scanf("%d%d",&H,&N); 
  for(int i=0;i<N;i++){ 
  int A; 
  scanf("%d",&A); 
       H-=A; 
  } 
  if(H<=0)puts("Yes"); 
  else puts("No");
  return 0;
}


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

using namespace std;

int N;
vector<int> d;
int in[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> in[i];
	}
	int ct = 1;
	for (int i = 1; i < N; i++) {
		if (in[i] == !in[i - 1])ct++;
		else d.push_back(ct), ct = 1;
	}
	d.push_back(ct);
	int ans = 0;
	if (d.size() <= 3) {
		for (int i = 0; i < d.size(); i++)ans += d[i];
		cout << ans << endl;
	}
	else {
		for (int i = 0; i < d.size() - 2; i++) {
			ans = max(ans, d[i] + d[i + 1] + d[i + 2]);
		}
		cout << ans << endl;
	}
	//for (int i = 0; i < d.size(); i++)cout << d[i] << " ";
	return 0;
}

Measured memory_bytes: 3668
X=int(input())

def is_prime2(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
if X==2:
  print(X)
  exit()
if X%2==0:
  X+=1
while not is_prime2(X):
  X+=2
print(X)

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

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

const long long INF = 1LL << 60;


int main(void){
	string s;cin >> s;
	deque<char> str_list; 
	for(int i=0;i<s.size();i++){
		str_list.push_back(s[i]);
	}
	int q;cin >> q;
	bool flip = true;
	for(int i=0;i<q;i++){
		int a,b;
		char c;
		cin >> a;
		if(a == 1){
			flip = !flip;
			continue;
		}
		cin >> b >> c;
		if(flip == false) b = 3-b; 
		if(b==1){
			str_list.push_front(c);
		}else{
			str_list.push_back(c);
		}
	}
	if(!flip) reverse(str_list.begin(),str_list.end());
	auto it = str_list.begin();
	while(it != str_list.end()){
		cout << *it;
		it++;
	}	
	cout << endl;	
	return 0; 
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<set>
#include<map>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    string s, ans = "";
    cin >> s;
   
    for(char c : s){
        if(c == 'B' && ans.size()) ans.pop_back();
        else if(c != 'B')ans.pb(c);
    }
   
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X,Y,Z;
    cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			long N = long.Parse(Console.ReadLine());
			long min = long.MaxValue;
			for (int i = 0; i < 5; i++) {
				min = Math.Min(min, long.Parse(Console.ReadLine()));
			}

			long ans = 4;
			ans += N / min;
			if (N % min != 0) {
				ans++;
			}
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 11092
# code-festival-2017-qualaC - Palindromic Matrix
from collections import Counter


def main():
    H, W, *A = open(0).read().split()
    H, W, C = int(H), int(W), Counter("".join(A)).values()
    single = H & W & 1
    double = (H >> 1 if W & 1 else 0) + (W >> 1 if H & 1 else 0)
    C_mod4 = [i % 4 for i in C]
    flg = C_mod4.count(1) + C_mod4.count(3) <= single and C_mod4.count(2) <= double
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> times(5, 0);
  vector<int> rests(5, 0);
  int ans = 0;
  REP(i, 5) {
    cin >> times[i];
    ans += times[i];
    if (times[i] % 10 != 0) {
      rests[i] = 10 - times[i] % 10;
      ans += rests[i];
    }
  }
  ans -= *max_element(rests.begin(), rests.end());
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

struct UnionFind {
  vector< int > par;
  UnionFind(int n = 1) {
    init(n);
  }

  void init(int n) {
    par.resize(n);
    for(int i = 0; i < n; i++)
      par[i] = -1;
  }
  
  int root(int n) {
    if (par[n] < 0) return n;
    return par[n] = root(par[n]);
  }

  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;

    return true;
  }
};

int N;

int kruskal(vector< tuple< ll, int, int > > e)
{
  ll res = 0ll;
  UnionFind uf(N);
  EACH(ei, e) {
    ll cost;
    int e1, e2;
    tie(cost, e1, e2) = ei;
    if (uf.root(e1) != uf.root(e2)) {
      uf.unite(e1, e2);
      res += cost;
    }
  }
  return res;
}

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

  cin >> N;
  vector< pair< int, ll > > x, y;
  REP(i, N) {
    CIN(p, q);
    x.emplace_back(make_pair(p, i));
    y.emplace_back(make_pair(q, i));
  }

  sort(ALL(x));
  sort(ALL(y));

  vector< tuple< ll, int, int > > e;
  REP(i, N) {
    e.emplace_back(make_tuple(abs(x[i + 1].first - x[i].first), x[i].second, x[i + 1].second));
    e.emplace_back(make_tuple(abs(y[i + 1].first - y[i].first), y[i].second, y[i + 1].second));
  }

  sort(ALL(e));

  ll ans = kruskal(e);

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 10848
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
 int n;cin>>n;
 int ans=0;
 for(int i=1;i<=n;i++)
 {
     int temp=n/i;
     int sum=(temp+1)*temp/2;
     ans+=i*sum;
 }
 cout<<ans<<endl;
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
      t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 3620
#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; 
//order_of_key(k)= # of items strictly smaller than 'k'  //find_by_order(x)= iterator to x'th largest element (counting from ZERO) //erase("iterator") [log(n)] //end(<name>)
//os.find_by_order(os.order_of_key(x)=iterator to 'x' in the rb tree
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("O3")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef priority_queue<ll> pq;                                        //min-heap-> multiply the values by '-1'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define test ll t;cin>>t;while(t--)
#define summ(a,n) accumulate(a,a+n,0)
#define bsrch(v,n) lower_bound(v.begin(), v.end(), n)
#define minindex(v) distance(v.begin(),min_element(v.begin(),v.end()))         //returns index of minimum(/max) element in the vector
#define bp(x) _builtin_popcount(x)
#define inf 1000000000000
#define PI = 3.1415926535897932384626
#define mod 1000000007

ll dp[22][1<<21];

int main()
{
    ll n; cin>>n;
    ll a[n][n];
    forr(i,0,n)
        forr(j,0,n)
            cin>>a[i][j];
            
    dp[0][0]=1;
    forr(i,0,n)
        forr(mask,0,1<<n)
        {
            if(i==__builtin_popcount(mask))
                forr(j,0,n)
                    if(a[i][j] && !(mask & (1<<j)))
                    {
                        dp[i+1][mask|(1<<j)] += dp[i][mask];
                        dp[i+1][mask|(1<<j)]%=mod;
                    }
        }
/*forr(i,0,n+1)
{
    forr(j,0,1<<n) cout<<dp[i][j]<<" ";
    cout<<endl;
}*/
    cout<<dp[n][(1<<n)-1];
}

Measured memory_bytes: 167272
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int n;
	char c;
	cin >> n;
	rep(i, n) {
		cin >> c;
		if (c == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

    const int CAKE_PRICE = 4;
    const int DONUT_PRICE = 7;
    
    int sum = 0;
    for (int i = 0; i <= 25; i++)
    {
        sum = i * CAKE_PRICE;
        if (sum == n)
        {
            cout << "Yes" << endl;
            return 0;
        }

        if (sum > n)
        {
            continue;
        }
        
        for (int j = 0; j <= 20; j++)
        {
            sum += DONUT_PRICE;
            if (sum == n)
            {
                cout << "Yes" << endl;
                return 0;
            }

            if (sum > n)
            {
                continue;
            }
        }   
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String srgs[]) {
		Scanner sc = new Scanner(System.in);
		int prime[] = new int[10001];
		int n;

		prime[0] = -1;
		prime[1] = -1;
		for (int i = 2; i < 10001; i++) {
			for (int j = i; i * j < 10001; j++) {
				prime[i * j] = -1;
			}
		}

		while (sc.hasNext()) {
			n = sc.nextInt();
			for (int i = n; 0 <= i; i--) {
				if (0 <= i - 2 && prime[i] == 0 && prime[i - 2] == 0) {
					System.out.println((i - 2) + " " + i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
n = gets.to_i
a = n.times.map{gets.to_i}.sort

if n==2
  p (a[0]-a[1]).abs
  exit
end



def f n,a
  ans = 0
  l = 1
  r = n-3
  #
  x = [a[-1],a[-2]]
  ans += (a[-1]-a[0]).abs + (a[-2]-a[0]).abs 
  #
  (n-3).times.map{|i|
    x.sort!
    if (x[1]-a[l]).abs > (x[0]-a[r]).abs
      ans += (x[1]-a[l]).abs
      x[1] = a[l]
      l += 1
    else
      ans += (x[0]-a[r]).abs
      x[0] = a[r]
      r -= 1
    end
  }
  ans
end

p [f(n,a),f(n,a.reverse)].max

Measured memory_bytes: 8736
# 0人になる部屋の数
# ・最小0 (k = 1　ないしは　N = 2 and k = 3が制約外なので必ず0になる)
# ・最大 min(k,N-1) (k人が部屋を空に出来るが、1部屋は必ず空でない部屋が残る)
# min(k,N-1)部屋が空になるということは、N-min(k,N-1)部屋には必ず人がいる
# 空でない部屋の最大数はN - K
# N - K - 1部屋に割り振るパターンはあり得ない
# つまりN-min(k,N-1)-1部屋に人がいるケースはあり得ない
# N人をN部屋に割り振る場合の数から、
# N人をN-min(k,N-1)-1部屋に割り振る場合の数を引く
# いずれも0の場合を含む
# N個をK箱に割り振る場合の数は、N+K-1 C N

DIV = 10 ** 9 + 7
n = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % DIV )
    inverse.append( ( -inverse[DIV % i] * (DIV//i) ) % DIV )
    g2.append( (g2[-1] * inverse[-1]) % DIV )

def nCr(n, r, DIV):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % DIV

N,K = map(int,input().split())

# N人をN部屋に割り振る場合の数から、
# N人をN-min(k,N-1)-1部屋に割り振る場合の数を引く
# いずれも0の場合を含む
# N個をK箱に割り振る場合の数は、N+K-1 C N

ans = 0
for i in range(min(K,N-1) + 1):
  a = nCr(N,i,DIV)
  
  # N-i個の部屋にN個のボールを詰める
  # N個のうちのN-i個をまず1個ずつ詰める
  # 残りはN - (N - i) = i個
  # i個のボールをN-i個に詰める。i個と(N-i-1)個の仕切りの並び替え
  # (i + N - i - 1) C i = (N-1) C i
  b = nCr(N-1,i,DIV)
  
  ans += (a * b) % DIV
  ans %= DIV
  
print(ans)

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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "No War"
#define FALSE__ "War"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
}

vector<int> x;
vector<int> y;
int N, M, X, Y;

void solve()
{
	cin >> N >> M >> X >> Y;
	x.resize(N);
	y.resize(M);
	rep(i, N) cin >> x[i];
	rep(i, M) cin >> y[i];
	sort(all(x));
	sort(all(y));
	int Z = x.back() + 1;
	PRINT(X < Z && Z <= Y && Z <= y[0]);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
const long long MOD = 1000000007;
int N, K;
long long O, fc[4000001], fi[4000001], f[2001], g[2001];
inline long long C(int x, int y)
{
	return fc[x] * fi[y] % MOD * fi[x - y] % MOD;
}
int main()
{
	scanf("%d%d", &N, &K);
	if (K == 1)
	{
		puts("1");
		return 0;
	}
	fc[0] = fi[0] = fi[1] = 1;
	for (int i = 2; i <= N * K; i++)
		fi[i] = (MOD - MOD / i) * fi[MOD % i] % MOD;
	for (int i = 1; i <= N * K; i++)
	{
		fc[i] = fc[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * fi[i] % MOD;
	}
	f[0] = 1;
	for (int i = 1; i <= N + N; i++)
	{
		for (int j = 0; j < (i + 1) >> 1; j++)
			g[j] = 0;
		for (int j = (i + 1) >> 1; j <= N; j++)
			g[j] = (f[j - 1] * C(i + j * (K - 2) - 1, K - 2) + f[j]) % MOD;
		std::copy(g, g + N + 1, f);
	}
	printf("%lld\n", f[N] * fc[N] % MOD);
	return 0;
}

Measured memory_bytes: 62720
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	string str;
	cin >>str;
	if((str.at(0)==str.at(1))&&(str.at(2)==str.at(3))&&(str.at(1)==str.at(2))){
		cout<<"No";
	}else if((str.at(0)==str.at(1))&&(str.at(2)==str.at(3))){
		cout<<"Yes";
	}else if((str.at(0)==str.at(2))&&(str.at(3)==str.at(1))){
		cout<<"Yes";
	}else if((str.at(0)==str.at(3))&&(str.at(2)==str.at(1))){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;

/**
 * ZAKIREN第5章 4-6.データ構造の応用
 * 
 * @author tdi5277
 *
 */
public class Main {
	/** 入力用 */
	private static Scanner scan = new Scanner(System.in);

	/** 出力用 */
	private static StringBuilder stringBuilder = new StringBuilder();

	/**
	 * メイン。
	 * 
	 * @param args 未使用
	 */
	public static void main(String[] args) {
		// 読み込み
		String terrain = scan.nextLine();

		// 読み込み終了
		scan.close();
		scan = null;

		// 計算用スタックの宣言
		Stack<Integer> s1 = new Stack<>();
		Stack<Map<Integer, Integer>> s2 = new Stack<>();

		// 文字数分ループ
		int sum = 0;
		for (int i = 0; i < terrain.length(); i++) {
			char target = terrain.charAt(i);
			if (target == '\\') {
				s1.push(i);
			} else if (target == '/' && s1.size() > 0) {
				int j = s1.pop();
				sum += i - j;
				int a = i - j;
				if (s2.size() > 0) {
					Map<Integer, Integer> s2Map = s2.peek();
					Set<Integer> temp = s2Map.keySet();
					Object[] keys = temp.toArray();
					Integer key = (Integer) keys[0];
					while (s2.size() > 0 && key > j) {
						a += s2Map.get(key);
						s2.pop();

						if (s2.size() > 0) {
							s2Map = s2.peek();
							temp = s2Map.keySet();
							keys = temp.toArray();
							key = (Integer) keys[0];
						}
					}
				}
				Map<Integer, Integer> pushS2Map = new HashMap<>();
				pushS2Map.put(j, a);
				s2.push(pushS2Map);
			}
		}

		// 結果出力 合計
		stringBuilder.append(sum + "\n");

		// 結果出力 水たまりの数
		int size = s2.size();
		stringBuilder.append(size);
		
		// 各面積を逆順に並び替える
		Stack<Integer> reverse = new Stack<>();
		while (s2.size() > 0) {
			Map<Integer, Integer> map = s2.pop();
			Set<Integer> temp = map.keySet();
			Object[] keys = temp.toArray();
			Integer key = (Integer) keys[0];
			reverse.push(map.get(key));
		}
		Collections.reverse(new ArrayList<>(reverse));
		
		// 結果出力 各面積
		while (reverse.size() > 0) {
			stringBuilder.append(" " + reverse.pop());
		}

		System.out.println(stringBuilder.toString());

	}

}



Measured memory_bytes: 33100
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int h,w,k;
	cin >> h >> w >> k;

	vector<string> grid(h);
	for(int i = 0;i < h;i++)cin >> grid[i];

	int ans = 0;

	for(int i = 0;i < (1 << h);i++){
		for(int j = 0;j < (1 << w);j++){
			map<int,bool> col;
			for(int k = 0;k < h;k++){
				if((i >> k) & 1)col[k] = true;
			}
			map<int,bool> row;
			for(int k = 0;k < w;k++){
				if((j >> k) & 1)row[k] = true;
			}

			int cnt = 0;

			for(int k = 0;k < h;k++){
				for(int l = 0;l < w;l++){
					if(grid[k][l] == '#' && col[k] == false && row[l] == false){
						cnt++;
					}
				}
			}

			if(cnt == k)ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=3e5+5;
int n,m,x[N],l[N],r[N];
long long ans;
int main(){
	scanf("%d%d",&n,&m);m<<=1;
	for(int i=1;i<=n;++i)scanf("%d",&x[i]);
	for(int i=1,t;i<=n;++i){
		scanf("%d",&t);
		if(t%m==0)ans+=t;
		else{
			ans+=(0ll+t+m-1)/m*m;t%=m;
			if(t<=(x[i]<<1))l[i]=1;
			if(t<=m-(x[i]<<1))r[i]=1;
		}
	}
	for(int i=1,x=0,y=0;i<n;++i){
		if(x&&r[i])
			y+=l[i],--x,ans-=m;
		else if(r[i]&&!l[i])
			y?(--y,++x):0;
		else
			x+=l[i];
	}
	if(!r[n])ans+=m;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) std::cin >> a[i];
    std::vector<int> l(n + 2), r(n + 2);
    for (int i = 1; i <= n; i++) {
        l[i] = std::max(l[i - 1], a[i]);
        r[n - i + 1] = std::max(r[n - i + 2], a[n - i + 1]);
    }
    for (int i = 1; i <= n; i++) {
        std::cout << std::max(l[i - 1], r[i + 1]) << std::endl;
    }

    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}
long long powm(long long a, long long b, long long mod=1000000007){
    if(b<0) b+=mod-1;
    if(b>0){
        if(b%2==1) return a*powm(a*a%mod,b/2)%mod;
        else return powm(a*a%mod,b/2)%mod;
    }else{
        return 1;
    }
}


ll mod = 1e9+7;
int main(){
    ll n,m;
    cin>>n>>m;

    vector<ll> ptb(n+1,1);
    rep(i,n){
        ptb[0]*=m-i;
        ptb[0]%=mod;
    }
    rep(i,n){
        ptb[i+1]=ptb[i]*(n-i)%mod*powm(m-i,-1)%mod*powm(i+1,-1)%mod;
    }
    ll ans=ptb[0],tmp=0;
    rep(i,n+1){
        tmp+=(ptb[i]*(i%2 ? -1:1)+mod);
        if(tmp<0) tmp+=mod;
        tmp%=mod;
    }
  //  cout<<ptb<<tmp<<endl;
    cout<<ans*tmp%mod<<endl;
    return 0;
}

Measured memory_bytes: 7140
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

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

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

  for (int i = k; i < n; i++) {
    if (scores[i] <= scores[i - k]) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  for(int i = 0; i <= A; i++) {
    for(int j = 0; j <= B; j++) {
      for(int k = 0; k <= C; k++) {
        if(500 * i + 100 * j + 50 * k == X) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll N; cin >> N;
    ll out=0;
    ll c=1;
    ll a=1;
    while(a*10<=N){
        out += (N/a)%10;
        a*=10;
        c++;
    }
    out += (N/a)%10;
    cerr << out << endl;
    out = max(out,9*(c-1)+N/a-1);
    
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  V<> h(n); for (int i = 0; i < n; ++i) cin >> h[i];
  V<> dp(n, 2e9);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = i - 1; j >= max(i - k, 0); --j) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



int main(){
int n; cin>>n;
int d[110000];

for(int i=0;i<n;i++)
cin>>d[i];

sort(d,d+n);

cout<<d[n/2]-d[n/2-1]<<endl;
}


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

using namespace std;

int main(){
  string s,t,u;
  while(cin>>s>>t){
    u=(s.size()>t.size())?t:s;
    if(s==u) s=t;
    int c=u.size();
    int a=0,b=0;
    for(int i=0;i<c;++i){
      for(int j=0;j<s.size();++j){
	if(u[(j+i)%c]==s[j]){
	  ++b;
	  if(i+j==c-1){
	    a=max(a,b);b=0;
	  }
	}
	else{
	  a=max(a,b);b=0;
	}
      }
      a=max(a,b);b=0;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <functional>
#include <algorithm>

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

const function<int(int,int)>
(&fs)[]={plus<int>(),
         minus<int>(),
         multiplies<int>()};
char op[]="+-*";
int fidx[]={0,1,2};

int a[4];

int main(){
    while(1){
        rep(i,4)cin>>a[i];
        if(accumulate(a,a+4,0)==0) break;
        bool ok=false;
        sort(a,a+4);
        rep(i,3)rep(j,3)rep(k,3){
            do{
                int ans=fs[k](fs[j](fs[i](a[0],a[1]),a[2]),a[3]);
                if(ans==10){
                    cout<<"((("
                        <<a[0]<<op[i]
                        <<a[1]<<")"<<op[j]
                        <<a[2]<<")"<<op[k]
                        <<a[3]<<")"
                        <<endl;
                    ok=1;
                    goto end;
                }
                ans=fs[k](fs[i](a[0],a[1]),fs[j](a[2],a[3]));
                if(ans==10){
                    cout<<"("
                        <<a[0]<<op[i]<<a[1]
                        <<")"<<op[k]<<"("
                        <<a[2]<<op[j]<<a[3]
                        <<")"
                        <<endl;
                    ok=1;
                    goto end;
                }
            }while(next_permutation(a,a+4));
        }
    end:;
        if(!ok) cout<<0<<endl;
    }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        string S; cin >> S;
        if (S == "ABC") cout << "ARC" << endl;
        else cout << "ABC" << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3628
# coding: utf-8

import sys
input = sys.stdin.readline

bit = lambda s, j: (s >> j) & 1

def f(n, a):
    mod = int(1e9 + 7)
    sn = 1 << n
    dp = [[0] * sn for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(n):
        dpi = dp[i]
        dpi1 = dp[i + 1]
        ai = a[i]
        for s in range(0, sn):
            if dpi[s]:
                for j in range(n):
                    if bit(s, j) == 0 and ai[j]:
                        s_ = s | 1 << j
                        dpi1[s_] += dpi[s]
                        if dpi1[s_] > mod:
                            dpi1[s_] -= mod
    return(dp[-1][-1])

n = int(input()) # 1 <= n <= 21
a = [list(map(int, input().split())) for _ in range(n)]
print(f(n, a))


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string color_1, color_2;
    cin >> color_1 >> color_2;
    int num_1, num_2;
    cin >> num_1 >> num_2;
    string temp;
    cin >> temp;
    if (temp == color_1)
        --num_1;
    else
        --num_2;
    cout << num_1 << " " << num_2 << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  int dp[n];
  for(int i = 0;i < n;i++) cin >> a[i];
  dp[0] = 0;
  dp[1] = abs(a[1]-a[0]);
  for(int i = 2;i < n;i++){
    dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),
    dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

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

  if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D){
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}



Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000009;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 5;
int n, m;
int a[N];
string s;
main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	for(ld i = 0 ; i <= n ; i++){
		ld x = i * 1.08;
		if((int)x == n)ret(i);
	}
	ret(":(");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N, M, r = 0;
    vector<int> f;
    cin >> N >> M;
    
    for (int i = 0; i < M; ++i) f.push_back(0);
    
    for (int i = 0; i < N; ++i) {
        int K;
        cin >> K;
        
        for (int j = 0; j < K; ++j) {
            int Ki;
            cin >> Ki;
            f[Ki - 1]++;
            if (f[Ki - 1] == N) r++;
        }
    }
    
    cout << r << endl;
    
    return 0;
}


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

void testCase(){
    int n, m, a, b, count = 0;
    cin>>n>>m;
    vector<int> hei(n);
    for(int i = 0; i < n; i++) cin>>hei[i];
    vector<vector<int> > adj(n);
    for(int i = 0; i < m; i++){
        cin>>a>>b;
        adj[--a].push_back(--b);
        adj[b].push_back(a);
    }
    for(int i = 0; i < n; i++){
        if(adj[i].size() == 0) count++;
        else{
            bool flag = true;
            for(auto j : adj[i]){
                if(hei[j] >= hei[i]) flag = false;
            }
            if(flag) count++;
        }
    }
    cout<<count<<endl;
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 8780
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#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 FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;
#define INF 1000000000000
#define NOD 1000000007
#define PI 3.141592653589793238462643

int main() {
    double r;
    cin >> r;
    cout << 2*r*PI << endl;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

ll n;
string ans;


int main() {
   cin>>n;
   while(n>26) {
      ll k1 = n/26, k2 = n%26;
      if(k2) ans += (char)('a'-1+k2);
      else ans += 'z', k1--;
      n = k1;
   }
   if(n) ans += (char)('a'+n-1);
   int len = ans.size();
   for(int i=len-1; i>=0; --i) cout<<ans[i];
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;



int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=(n-1)/i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] player = new int[n];
        for (int i = 0; i < q; i++) {
            int a = sc.nextInt();
            player[a - 1]++;
        }
        for (int i = 0; i < n; i++) {
            if (player[i] > q - k) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

        sc.close();
    }

}


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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a<=k) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int d;
  scanf("%d", &d);
  if (d == 22) 
    printf("Christmas Eve Eve Eve\n");
  if (d == 23) 
    printf("Christmas Eve Eve\n");
  if (d == 24)
    printf("Christmas Eve\n");
  if (d == 25)
    printf("Christmas\n");
  return 0;
}


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

int main(){

  int n;
  cin >> n;

  int num;
  vector<int> v;

  for(int i; i<n; ++i){
    cin >> num;
    v.push_back(num);
  }

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

  int ans = v.back() - *v.begin();
  cout << ans <<endl;

  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    string s;
    cin >> s;
    if(s.size() == 3) reverse(WHOLE(s));
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k, a[105], dp[100005];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k; 
for (int i=0; i<n; i++) cin >> a[i];
for (int i=1; i<=k; i++){
	int mini=1;
	for (int j=0; j<n; j++)
		if (i>=a[j]) mini=min(mini, dp[i-a[j]]);
	dp[i]=(mini+1)%2;
}
if (dp[k]==1) cout << "First";
else cout << "Second";
return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

struct UnionFind{
    vector<long long> par;
    vector<long long> size;

    UnionFind(long long n) : par(n){
        //initialization
        for(long long i = 0; i < n; i++){
            par[i] = i;
        }
        size.resize(n, 1);
    }

    long long root(long long x){
        if(par[x] == x){
            return x;
        }
        return par[x] = root(par[x]);
    }

    void unite(long long x, long long y){
        long long rx = root(x);
        long long ry = root(y);
        if(rx == ry){
            return;
        }

        par[rx] = ry;
        size[ry] += size[rx]; 
    }

    bool same(long long x, long long y){
        long long rx = root(x);
        long long ry = root(y);
        return rx == ry;
    }

    long long treeSize(long long x){
        //group size
        return size[root(x)];
    }
};

int main(){
    long long n, m, k;
    cin >> n >> m >> k;

    UnionFind tree(n);
    vector<set<long long> > list(n);
    for(long long i = 0; i < m; i++){
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        tree.unite(a, b);
        list[a].insert(b);
        list[b].insert(a);
    }
    
    for(long long i = 0; i < k; i++){
        long long c, d;
        cin >> c >> d;
        c--;
        d--;
        if(tree.same(c, d) == true){
            list[c].insert(d);
            list[d].insert(c);
        }
    }

    
    for(long long i = 0; i < n; i++){
        printf("%lld ", tree.treeSize(i)- list[i].size()- 1);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 29312
//DP Contest
//K-Stones
  #include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
//Ques I
  //for an Odd N (small number<=3000)
  //what is the prob that more heads show up

  //what is important rn
  //order of heads-tails showing up till now? No
  //So a dp state just describing number of head states till now

  //dp[heads][tails], but #of tails= i - heads;
  //so dp[heads] is enough


  int32_t main()
  {
  	/*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
    IOS
    int n;
    cin>>n;
    vector<double> v(n);
    for(auto& x: v)
    	cin>>x;
    vector<double> dp(n+1);
     dp[0]=1;
    //dp[i]= i heads till now
    
  for(int coin=0;coin<n;coin++)
  {

  	for(int i=coin+1;i>=0;i--)
  	{  
  		//this inner loop goes reverse
  		//prob of i-1 heads + prob of tails into dp[i]th coz only i heads needed
  		dp[i]=((i==0)?0:v[coin]*dp[i-1]) + (1-v[coin])*dp[i];
  	}
  }

  double ans=0.0;
  for(int heads=0;heads<=n;heads++)
  {
  	int tails=n-heads;
  	if(heads> tails)
  		ans+=dp[heads];
  }
 cout << fixed << setprecision(10)<<ans;
 return 0;
}

Measured memory_bytes: 384