akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int n,m,k;
int j[1100][1100],o[1100][1100],i[1100][1100];
int tj,to,ti;
string tmp;
int a,b,c,d;

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

  for(int y=0;y<m;y++){
    tj = to = ti = 0;
    cin >> tmp;
    j[y][0] = o[y][0] = i[y][0] = 0;
    for(int x=0;x<n;x++){
      if(tmp[x] == 'J')tj++;
      if(tmp[x] == 'O')to++;
      if(tmp[x] == 'I')ti++;
      j[y][x+1] = tj;
      o[y][x+1] = to;
      i[y][x+1] = ti;
    }
  }
 
  while(k--){
    cin >> a >> b >> c >> d;
    tj = to = ti = 0;
    for(int y=a-1;y<c;y++){
      tj += j[y][d] - j[y][b-1];
      to += o[y][d] - o[y][b-1]; 
      ti += i[y][d] - i[y][b-1];
    }
    cout << tj << " " << to << " " <<  ti << endl;
  }
}

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

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  string s;
  cin>>s;
  LL cnt = 0;
  REP(i, s.size())
  {
    if(s[i]=='x'){
      cnt++;
    }
  }
  if(cnt>=8){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n,m;
int x,y;
vector<int> ga[100100];
int dp[100100];//starting with x
int jisou(int u){
	if(dp[u]!=-1)
		return dp[u];
	dp[u]=0;
	for(int i=0;i<ga[u].size();i++){
		dp[u]=max(dp[u],jisou(ga[u][i])+1);
	}
	return dp[u];
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		ga[x].push_back(y);
	}
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)
		jisou(i);
	cout<<*max_element(dp+1,dp+n+1);
	return 0;
}


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

//abc063 d

const int N = 1e5 + 5;
int n, a, b;
int h[N];
lli hTemp[N]; //for checkSol() use

bool checkSol(int n, lli s) {
	if(s == 0) return false;
	int d = a - b;
	for(int i = 0; i < n; i++) hTemp[i] = max(h[i] - s*b, (lli)0);
	lli remaining = 0;
	for(int i = 0; i < n; i++) remaining += (hTemp[i]+d-1)/d;
	return (remaining <= s);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> a >> b;
	for(int i = 0; i < n; i++) cin >> h[i];

	lli lb = 0, ub = 1e9;
	while(ub - lb > 1) {
		lli mid = (lb + ub)/2;
		if(checkSol(n, mid)) ub = mid;
		else lb = mid;
	}

	if(checkSol(n, lb)) cout << lb << endl;
	else cout << ub << endl;

	return 0;
}

Measured memory_bytes: 1408
alp = ['a', 'b', 'c']
a = Array.new(3) do
    gets.split('').map do |v|
        alp.index(v)
    end
end

turn = 0
while true do
    next_turn = a[turn].shift
    if a[turn].length == 0 then
        break
    end
    turn = next_turn
end

puts alp[turn].upcase


Measured memory_bytes: 14280
n=int(input())

s=set()
command=[]

for i in range(n):
  c=input().split()
  command.append(c)


for i in range(n):

  if command[i][0]=="insert":
    s.add(command[i][1])
  else:
    if command[i][1] in s:
      print("yes")
    else:
      print("no")


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

vector<int> g[2010];
int n, k;

void dfs(int v, int p, int d, vector<bool>& visited)
{
    if (d>k/2) return;
    visited[v]=true;
    for(int u: g[v]) if (u!=p) dfs(u, v, d+1, visited);
}

int main()
{
    cin>>n>>k;
    for(int i=0; i+1<n; ++i) {
        int a, b; cin>>a>>b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int res=n;
    if (k%2==0) {
        for(int i=0; i<n; ++i) {
            vector<bool> visited(n);
            dfs(i, -1, 0, visited);
            res=min<int>(res, count(begin(visited), end(visited), false));
        }
    }
    else {
        for(int i=0; i<n; ++i) {
            vector<bool> visited(n);
            dfs(i, -1, 0, visited);
            for(int u: g[i]) {
                auto tmp=visited;
                dfs(g[i][0], -1, 0, visited);
                res=min<int>(res, count(begin(visited), end(visited), false));
                visited=tmp;
            }
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(i64, X, Y);
    vector<i64> ans;
    ans.push_back(X);
    while (ans.back() * 2 <= Y) {
        ans.push_back(ans.back() * 2);
    }

    print(ans.size());

    return 0;
}


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

const int MOD = 1e9 + 7;
const int N = 1001;
char grid[N][N];
int dp[N][N];
int n, m;

int solve (int i, int j) {
    if (i == n && j == m) {
        return 1;
    }
    int& ans = dp[i][j];
    if (ans != -1) {
        return ans;
    }
    ans = 0;
    if (i + 1 <= n && grid[i + 1][j] == '.') {
        ans += solve(i + 1, j);
        ans %= MOD;
    }
    if (j + 1 <= m && grid[i][j + 1] == '.') {
        ans += solve(i, j + 1);
        ans %= MOD;
    }
    return ans;
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> grid[i][j];
        }
    }
    memset(dp, -1, sizeof dp);
    cout << solve(1, 1);
    return 0;
}


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

typedef long long ll;

#define reg register 
#define rep(a,b,c) for(reg int a=b,a##end=c;a<=a##end;++a)
#define drep(a,b,c) for(reg int a=b,a##end=c;a>=a##end;--a)

char IO;
int rd(){
	int s=0,f=0;
	while(IO=getchar(),IO<'0'||IO>'9')if(IO=='-')f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(IO=getchar(),IO>='0'&&IO<='9');
	return f?-s:s;
}

const int N=10000;

ll l,r,a,b;

ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }

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


ll Solve(ll x){
	return x/a+x/b-x/lcm(a,b);
}


int main(){
	scanf("%lld %lld %lld %lld",&l,&r,&a,&b);
	ll ans=Solve(r)-Solve(l-1);
	ans=r-l+1-ans;
	printf("%lld\n",ans);
}







Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

int main() {
	long a, b, c;
	long count, ans;

	std::cin >> a >> b >> c;
	
	if (a + b < c) {
		ans = b * 2 + a + 1;
	}
	else if (a + b == c) {
		ans = a + b * 2;
	}
	else if (a + b > c) {
		if (b < c) ans = ans = b * 2 + c - b;
		else ans = b + c;
	}

	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
S = gets.chomp
if S == "SUN" then
  puts 7
end
if S == "MON" then
  puts 6
end
if S == "TUE" then
  puts 5
end
if S == "WED" then
  puts 4 
end
if S == "THU" then
  puts 3 
end
if S == "FRI" then
  puts 2
end
if S == "SAT" then
  puts 1
end

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

using namespace std;



int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    int max_length = 0;
    
    cin >> s;
    
    for (int i = 0; i < s.length(); i++) {
        for (int j = i; j < s.length(); j++) {
            string sub = s.substr(i, j - i + 1);
            istringstream iss(sub);
            char c;
            bool valid = true;
            while (iss >> c) {
                if (c != 'A' && c != 'C' && c != 'G' && c != 'T') {
                    valid = false;
                    break;
                }
            }
            if (!valid) {
                break;
            }
            max_length = max(max_length, (int) sub.length());
        }
    }
    
    cout << max_length << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i, 0, n)cin >> v[i];
	int score, M = 0;
	rep(g, 0, min(n, k) + 1) {
		rep(l, 0, g + 1) {
			vector<int> s;
			rep(i, 0, n) {
				if (i < l || i >= n - g + l)s.push_back(v[i]);
			}
			sort(all(s));
			int p = 0, m = min(k - g, (int)s.size());
			for (; p < m; p++)if (s[p] > 0)break;
			score = 0;
			for (; p < s.size(); p++)score += s[p];
			M = max(score, M);
			s.erase(all(s));
		}
	}
	printf("%d\n", M);
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(ll i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define NG cout <<"UNRESTORABLE" << endl;
#define INF 10101010

ll gcd(ll x,ll y){
    if (x%y == 0){
        return(y);
    }
    else{
        return(gcd(y, x%y));
    }
}
ld lcm(ll x, ll y) {
    return x / gcd(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
int main()
{
    ld A,B,C,D;
    cin >> A >> B >> C >> D;
    ld a_c=A/C;
    ld b_c=B/C;
    ld a_d=A/D;
    ld b_d=B/D;
    ll c_val=(ll)b_c-(ll)a_c;
    ld a_c_i=(ll)a_c;
    //cout << a_c-a_c_i << endl;
    if(ld(a_c-(ll)a_c)==0){
        c_val++;
    }
    
    ll d_val=(ll)b_d-(ll)a_d;
    if((ld)a_d-(ll)a_d==0){
        d_val++;
    }
    //cout << d_val << endl;
    ll ans=labs((ll)c_val+(ll)d_val);
    ld lcm_cd;
    if(C>D)
        lcm_cd=lcm(C,D);
    else{
        lcm_cd=lcm(D,C);
    }
    ld a_lcm=A/lcm_cd;
    ld b_lcm=B/lcm_cd;
    ll lcm_cd_val=(ll)b_lcm-(ll)a_lcm;
    //cout << lcm_cd_val << endl;
    if(a_lcm-(ll)a_lcm==0){
        lcm_cd_val++;
    }
    ans-=lcm_cd_val;

    ans=B-A+1-ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
while true
    n = gets.to_i
    break if n == 0
    m = gets.chomp.split.map(&:to_i)
    count, success = 0, false
    10000.times{
        if m == (1..m.length).to_a
            success = true
            break
        end
        m.map!{|x| x - 1}
        m << m.length
        m.delete(0)
        count += 1
    }
    puts success ? count : -1
end


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

template <uint32_t mod>
class modint{
    uint64_t value;
public:
    constexpr modint(const int64_t x=0) noexcept: value(x % mod + (x < 0 ? mod : 0)){ }
    constexpr explicit operator uint64_t() const noexcept{ return value; }
    constexpr modint inverse() const noexcept{ return pow(*this, mod-2); }
    constexpr bool operator==(const modint &rhs) const noexcept{ return value == rhs.value; }
    constexpr bool operator!=(const modint &rhs) const noexcept{ return value != rhs.value; }
    constexpr modint operator+() const noexcept{ return modint(*this); }
    constexpr modint operator-() const noexcept{ return modint(mod - value); }
    constexpr modint operator+(const modint &rhs) const noexcept{ return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept{ return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept{ return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept{ return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) noexcept{
        if((value += rhs.value) >= mod) value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) noexcept{ return *this += mod - rhs.value; }
    constexpr modint &operator*=(const modint &rhs) noexcept{
        if((value *= rhs.value) >= mod) value %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) noexcept{ return *this *= rhs.inverse(); }
    constexpr modint operator++(int) noexcept{
        modint ret(*this);
        if((++value) >= mod) value -= mod;
        return ret;
    }
    constexpr modint operator--(int) noexcept{
        modint ret(*this);
        if((value += mod - 1) >= mod) value -= mod;
        return ret;
    }
    constexpr modint &operator++() noexcept{ return *this += 1; }
    constexpr modint &operator--() noexcept{ return *this -= 1; }
    friend std::ostream &operator<<(std::ostream &os, const modint<mod> &x){ return os << x.value; }
    friend std::istream &operator>>(std::istream &is, modint<mod> &x){
        int64_t i;
        is >> i;
        x = modint<mod>(i);
        return is;
    }
    friend constexpr modint<mod> pow(const modint<mod> &x, uint64_t y){
        modint<mod> ret{1}, m{x};
        while(y > 0){
            if(y & 1) ret *= m;
            m *= m;
            y >>= 1;
        }
        return ret;
    }
};
constexpr int64_t mod = 1'000'000'007;
modint<mod> fact[400001], finv[400001];

modint<mod> comb(int n, int r){
    return fact[n] * finv[r] * finv[n-r];
}

int main(){
    fact[0] = 1;
    for(int i=1;i<=400000;++i) fact[i] = fact[i-1] * i;
    finv[400000] = fact[400000].inverse();
    for(int i=400000;i>0;--i) finv[i-1] = finv[i] * i;

    int n, k;
    cin >> n >> k;
    if(k >= n - 1){
        cout << comb(2*n-1, n) << endl;
    }else{
        modint<mod> ans = 0;
        for(int i=0;i<=k;++i){
            ans += comb(n, i) * comb(n-1, i);
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6528
while True:
    m, f, r = map(int, input().split())
    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1:
        print("F")
    elif m+f>=80:
        print("A")
    elif m+f>=65:
        print("B")
    elif m+f>=50:
        print("C")
    elif m+f>=30:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")            


Measured memory_bytes: 5596
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
str_list = SR(n)


for lower_letter in [chr(i) for i in range(97, 123)]:
    ret = INF
    for each_str in str_list:
        ret = min(ret, each_str.count(lower_letter))
    print(ret * lower_letter, end='')






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

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

    vector<int> av;
    vector<int> bv;
    av.reserve(n);
    bv.reserve(n);
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        av.push_back(a);
        bv.push_back(0);
    }

    for(int r=0; r<k; ++r){
        for(int i=0; i<n; ++i){
            int l = std::max(i - av[i],0);
            int r = i + av[i] + 1;
            ++bv[l];
            if(r<n) --bv[r];
        }

        for(int i=1; i<n; ++i){
            bv[i] += bv[i-1];
        }

        bool end = true;
        for(int i=0; i<n; ++i){
            if(av[i] != bv[i]) end = false;
            av[i] = bv[i];
            bv[i] = 0;
        }
        if(end) break;
    }

    for(int i=0; i<n-1; ++i) cout << av[i] << " ";
    cout << av[n-1] << endl;

    return 0;
}

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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mkf(n,MOD)  int fact[(n)+1]={}; mfac((n),fact,(MOD)) //enables to let x!=fact[x]

int mmul(int p,int q,int m){ //O(1)?
    ll lp=p,lq=q; return ((lp%m)*(lq%m))%m;
}

int mpow(int x,int n,int m){ //O(logN)
    ll res=x,ans=1;
    while(n!=0){
        if(n%2==0){ res = mmul(res,res,m);n>>=1;
        }else{      ans = mmul(ans,res,m);--n;}
    }
    return ans;
}

int mdiv(int p,int q,int m){ //O(logMOD)
    return mmul(p,mpow(q,m-2,m),m);
}

void mfac(int x,int *f,int m){//O(n)
    *f=1; for(int i=1;i<=x;++i)f[i]=mmul(f[i-1],i,m);
}

int mncr(int n,int r,int m,int* f){//O(logMOD)
    return mdiv(f[n],mmul(f[r],f[n-r],m),m);
}


int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int x,y;
    cin >>x>>y;

    mkf(1001001,MOD);

    if((x+y)% 3 != 0){
        puts("0");
        return 0;
    
    }else{
        if(y > 2*x){
            puts("0");
            return 0;
        }else if(y > 2*x){
            puts("0");
            return 0;
        }

        int n = (x+y)/3;

        //vector<int> fact = modfact(n,MOD);
        int r = 2*n - x;

        /*
        int nf=modfacts(n);
        int rf=modfacts(r);
        int nrf=modfacts(n-r);

        ans = moddiv(nf,modmul(rf,nrf,MOD),MOD);
        */

        ans = mncr(n,r,MOD,fact);

    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}


vector<ll> fact,inv;

ll f(ll a,ll b, ll p){  // a^b mod pを求める
	if (b == 0)return 1;
	else if (b % 2 == 0){
		ll d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else{
		return a * f(a,b-1,p) % mod;
	}
}

void init(ll n){
	fact.resize(n+1,1);
	inv.resize(n+1,1);
	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
		fact[i] = fact[i-1] * i % mod;
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
		inv[i] = f(fact[i],mod-2,mod) % mod;
}

ll comb(ll n,ll k){  //n_C_k
	if (n < k) return 0;
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}


int main()
{
	ll x,y;
	cin>>x>>y;

	if((x+y)%3!=0){
		cout<<0<<endl;
		return 0;
	}

	int n = (2*y-x)/3;
	int m = (2*x-y)/3;

	if(n<0||m<0){
		cout<<0<<endl;
		return 0;
	}

	init(n+m);

	cout<<comb(n+m,n)<<endl;

	return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a[5];
	for(ll i=0; i<5; i++)
		cin >> a[i];
	ll k;
	cin >> k;
	sort(a, a+5);
	if(a[4] -a[0] > k)
		cout << ":(";
	else
		cout << "Yay!";
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> H(n);
    rep(i, n) cin >> H[i];

    vector<ll> dp(10101010, INF);
    dp[0] = 0;
    rep(i, n)
    {
        for (int j = 1; j <= k; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]));
        }
    }

    cout << dp[n - 1] << endl;
}
//配るDPのが楽


Measured memory_bytes: 83000
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <=n; i++){
		if(i%3 == 0)
			printf(" %d", i);
		else if(i%10 == 3 || (i/10)%10 == 3 || (i/100)%10 == 3 ||(i/1000)%10 == 3)
			printf(" %d", i);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2136
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    int n;
    cin >> n;
    vi p(3,0);
    cin >> p[0] >> p[1];
    int ans=0;
    rep(i,n)
    {
        cin >> p[2];
        if((p[1]!=min(p[1],p[0])||p[1]!=min(p[1],p[2]))&&(p[1]!=max(p[1],p[0])||p[1]!=max(p[1],p[2])))
        {
            ans++;
        }
        p[0]=p[1];
        p[1]=p[2];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector <int> A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector <int> B(N);
  for(int i=0;i<N;i++)
    cin>>B.at(i);
  vector <int> C(N-1);
  for(int i=0;i<N-1;i++)
    cin>>C.at(i);
  int sum=0;
  for(int i=0;i<N;i++)
    sum+=B.at(i);
  
  for(int i=0;i<N-1;i++){
  if(A.at(i+1)-A.at(i)==1)
    sum+=C.at(A.at(i)-1);
  
  }cout<<sum<<endl;
  
  
  
  
  return 0;
}

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

using namespace std;

int arr[300000];

int main()
{
    int n, min, count = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    min = arr[0];
    for(int i = 0; i < n; i++)
    {
        if (min >= arr[i])
        {
            min = arr[i];
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4336
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

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

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool ans = false;
    if (abs(a - c) <= d)
        ans = true;
    if (abs(a - b) <= d && abs(b - c) <= d)
        ans = true;
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main() {
    string w;
    cin >> w;
    bool judge = true;

    for (char i = 'a'; i <= 'z'; i++) {
        int count = 0;
        for (int j = 0; j < w.size(); j++) {
            if (w[j] == i) count++;
        }
        if (count % 2 != 0) {
            judge = false;
            break;
        }
    }

    if (judge == true) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[]A = new int[M];
		int[]B = new int[M];
		List<int>[]C = new List<int>[M];
		List<int>[]D = new List<int>[N];
		for(var i=0;i<M;i++){
			string[] str2 = Console.ReadLine().Split();
			string[] str3 = Console.ReadLine().Split();
			A[i] = int.Parse(str2[0]);
			B[i] = int.Parse(str2[1]);
			C[i] = new List<int>();
			for(var j=0;j<B[i];j++){
				C[i].Add(int.Parse(str3[j]));
			}
		}
		int[] E = new int[N];
		for(var i=0;i<N;i++){
			D[i] = new List<int>();
			E[i] = 999999999;
		}
		int[]mi = new int[N];
		for(var i=0;i<M;i++){
			for(var j=0;j<C[i].Count;j++){
				D[C[i][j]-1].Add(i);
				if(E[C[i][j]-1] > A[i]){
					E[C[i][j]-1] = A[i];
					mi[C[i][j]-1] = i;
				}
			}
		}
		bool flag = true;
		for(var i=0;i<N;i++){
			if(D[i].Count==0){
				flag = false;
			}
		}
		if(!flag){
			Console.WriteLine("-1");
		} else {
			int ct = (int)Math.Pow(2,N);
			int[] DP = new int[ct];
			var listT = new List<int>();
			for(var i=0;i<ct;i++){
				DP[i] = 999999999;
			}
			DP[0] = 0;
			listT.Add(0);
			while(listT.Count>0){
				var listT2 = new List<int>(listT);
				listT.Clear();
				foreach(var i in listT2){
					for(var j=0;j<M;j++){
						int[]it = new int[N];
						int c = 1;
						for(var k=0;k<N;k++){
							if(i/c%2==1){
								it[k] = 1;
							}
							c *= 2;
						}
						for(var k=0;k<C[j].Count;k++){
							it[C[j][k]-1] = 1; 
						}
						int i2 = 0;
						c = 1;
						for(var k=0;k<N;k++){
							if(it[k]==1){
								i2 += c;
							}
							c *= 2;
						}
						int d2 = DP[i] + A[j];
						if(d2 < DP[i2]){
							DP[i2] = d2;
							listT.Add(i2);
						}
					}
				}
			}
			Console.WriteLine(DP[ct-1]);
		}
	}
}

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

#define ll long long
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define gg return 0;

using namespace std;

const int maxn = (int)2e5 + 7;
const int INF = (int)1e9;

ll a,b[maxn],c,d,cnt,e[(int)2e3 + 1][(int)2e3 + 1],cost[maxn],tout[maxn],mn = INF,p[maxn];

ll cntc;

vector < pair < ll, ll> > g[maxn];

vector <ll> ans;

bool u[40 * 40 + 7];

string s,t;

int main()
{
    //freopen("island2.in" , "r" , stdin);
    //freopen("island2.out" , "w" , stdout);
    cin >> a;
    int k = a;
    if(a != 0 && a % 4 == 0 || a % 7 == 0 && a != 0){
    	cout << "Yes" << '\n';
    	gg
    }
    u[4] = 1, u[7] = 1;
   	for(int i = 1; i <= 40; ++i){
   		for(int j = 1; j <= 40; ++j){
   			u[i * 4 + j * 7] = 1;
   		}
   	}
   	if(u[a]){
   		cout << "Yes" << '\n';
   		gg
   	}
   	cout << "No" << '\n';
    gg
}


Measured memory_bytes: 6400
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		String s=nextLine();
		if(s.equals("AAA") || s.equals("BBB"))
			out.println("No");
		else
			out.println("Yes");
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 21204
N,D = [int(i) for i in input().split()]
X = [0]*N
for i in range(N):
    X[i] = [int(i) for i in input().split()]
count = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans = 0
        for k in range(D):
            ans += (X[i][k] - X[j][k]) ** 2
        ans = ans ** (1/2)
        if ans.is_integer():
            count+=1
print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    cout << c*60+d-a*60-b-e << endl;
}

Measured memory_bytes: 3632
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
const string FILENAME = "input";



int h, w, a, b;



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//read(FILENAME);
 	cin >> h >> w >> a >> b;
 	for (int i = 0; i < h; i++) {
 		if (i < b) {
 			for (int j = 0; j < w; j++) {
 				if (j < a) {
 					cout << '0';
 				} else {
 					cout << '1';
 				}
 			}
 		} else {
 			for (int j = 0; j < w; j++) {
 				if (j < a) {
 					cout << '1';
 				} else {
 					cout << '0';
 				}
 			}
 		}
 		cout << '\n';
 	}
	return 0; 	
}

Measured memory_bytes: 1280
import sys
import bisect
input = sys.stdin.readline

def main():
    N = int(input())

    a = sorted([int(input()) for i in range(N)]) + [int(1e10)]

    ans = 0
    pre = a[0]
    count = 1
    for i in range(1, N+1):
        if pre != a[i] and count&1:
            ans += 1
            count = 0
        count += 1
        pre = a[i]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 8284
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N,A=map(int,input().split())
    X=list(map(int,input().split()))

    # https://qiita.com/drken/items/dc53c683d6de8aeacf5a#%E9%A1%9E%E9%A1%8C-3
    
    INF = 10**10  # INF+INFを計算してもオーバーフローしない範囲で大きく
    
    I ,J,K=N,N,A*N
    # dpテーブル dp[i][j][k]:=i番目までからj枚選んで合計kとなる通り数
    dp = [[[0]*(K+1) for _ in range(J+1)]for _ in range(I+1)]
    # 初期条件
    for i in range(I+1):
        dp[i][0][0] = 1
    # ループ
    for i in range(1, I+1):
        for j in range(1,J+1):
            for k in range(K+1):
                if k>=X[i-1]:
                    dp[i][j][k]=dp[i-1][j-1][k-X[i-1]]+dp[i-1][j][k]
                else:
                    dp[i][j][k]=dp[i-1][j][k]

    print(sum([dp[I][j][A*j] for j in range(1,N+1)]))
    

    
resolve()

Measured memory_bytes: 91740
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N, A;
    cin >> N >> A;
    ll ans = N*N - A;
    cout << ans;
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = IntArray(n)
    for(i in 0 until n){
        a[i] = readLine()!!.toInt()
    }
    val b = a.sorted()
    for(i in 0 until n){
        println(if(a[i] == b[n - 1]) b[n - 2] else b[n - 1])
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

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

	int n, m, c;
	cin >> n >> m >> c;

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

	int a[n][m];
	rep(i, n) rep(j, m) cin >> a[i][j];

	int ans = 0;
	rep(i, n){
		int tmp = c;
		rep(j, m) {
			tmp += a[i][j] * b[j];
		}
		if(tmp > 0) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i*i < n; ++i) {
    if (n%i == 0 && i < n/i-1) {
      ans += n/i-1;
    }
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
// #define int long long
#define mod (long long int)(998244353)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

long long int pow_mod(long long int a,long long int b){
  if(b==0) return 1;
  if(b%2==0){
    long long int c=pow_mod(a,b/2);
    return (c*c)%mod;
  }
  return (a*pow_mod(a,b-1))%mod;
}

int main(){

  int n;
  cin>>n;
  vector<int> d(n);
  int t;
  bool f=true;
  int max_d=0;
  for(int i=0;i<n;i++){
    cin>>t;
    max_d=max(max_d,t);
    if(i==0 && t!=0){
      f=false;
    }
    d[t]++;
  }
  if((!f) || (d[0]!=1)){
    cout<<0<<endl;
    return 0;
  }

  long long int r=1;
  for(int i=1;i<=max_d;i++){
    if(d[i]==0){
      cout<<0<<endl;
      return 0;
    }
    
    r*=pow_mod(d[i-1],d[i]);
    r%=mod;
  }
  cout<<r<<endl;
  
  return 0;
}


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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int a,b;
	char aa;
	cin>>a>>aa>>b;
	if(aa=='+'){
		cout<<a+b;
	}
	else{
		cout<<a-b;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std ;
typedef long long ll ;
const ll maxx = 1e5+5,mod=1e9+7 ;
ll fact[maxx];
ll power(ll b,ll p,ll m)
{
    if(p==0){return 1;}
    //if(p==1){return b;}
    ll half = power(b,p/2,m);
    ll ans,full=(half*half)%m;
    if(p%2==0)
    {
        return full;
    }
    else { return  (full*b)%m ;}
}
ll mulv(ll b,ll p)
{
    // since p is prime ;
    // b*x=1 mod p , p is prime so gcd(p,b)=1
    ll x  = power(b,p-2,p);
    return x ;
}
ll ncr(ll n,ll r)
{
    //cout << n << "  " << r << endl;
    if(n<r){return 0;}
    if(r==0 || n==r){return 1;}
    if(r==1 ){return n%mod;}
    ll a,b,c;
    a = fact[n];
    b = mulv(fact[n-r],mod);
    c = mulv(fact[r],mod);
    ll ans = (a*b)%mod;
    ans = (ans*c)%mod;
    return ans ;
}
int main()
{
    fact[0]=1;
    for(int i=1;i<=100002;i++)
    {
       fact[i]=(fact[i-1]*i)%mod;
    }
    ll n , k ;
    cin >> n >> k ;
    ll arr[n+5];
    for(int i=1;i<=n;i++)
    {
       ll  x ;
       cin >> x ;
       arr[i-1]=x;
    }
    sort(arr,arr+n,greater<ll>());
    ll sum=0,sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        sum1+= (arr[i]*ncr(n-i-1,k-1))%mod ;

        sum2+= (arr[i]*ncr(i,k-1))%mod ;
    }
    sum=sum1-sum2;
    cout << sum%mod << endl;
    return 0 ;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
char s[20];
 
int main() {
  scanf("%s", s);
  while (strlen(s) < 15) s[strlen(s)] = 'o';
 	int rlt = 0;
  for (int i = 0; i < 15; i ++) if (s[i] == 'o') rlt ++;
  puts(rlt > 7 ? "YES" : "NO");
 
    return 0;
}

Measured memory_bytes: 256
// 582 F Next Level DSU
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second     
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define mp make_pair
#define int long long
#define double float

using namespace std;
template <typename T>
void watch(vector<T> v)
{
    for(int i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    cout<<"Look above\n";
    cout<<"\n";
}
const int INF = 1e15;
const int MAX = 2e5+3;
int MOD = 998244353;
int32_t main()
{
      int n;
      cin>>n;
      vector<int> ord[n];
      for(int i=0;i<n;i++)
      {
         for(int j=0;j<n-1;j++)
         {
            int x;
            cin>>x;
            x--;
            ord[i].pb(x);
         }
      }

      vector<int> ptr(n, 0);
      set<int> count;
      for(int i=0;i<n;i++)
         count.insert(i);
      set<pair<int, int > > st;
      vector<int> changed;
      for(int i=0;i<n;i++){
         int x = i, y = ord[i][0];
         if(x > y)
            swap(x, y);
         if(st.find({x, y}) == st.end())
            st.insert({x, y});
         else
         {
            st.erase({x, y});
            changed.pb(x);
            changed.pb(y);
            ptr[x]++;
            ptr[y]++;
            if(ptr[x] == n-1)
               count.erase(x);
            if(ptr[y] == n-1)
               count.erase(y);
              
         }
         
      }
      if(changed.size() == 0)
      {
         cout<<-1;
         return 0;
      }
      int days = 1;
      while(!count.empty())
      {
         vector<int> temp;
         for(int i=0;i<changed.size();i++)
         {
            int ind = changed[i];
            int x = ind, y = ord[ind][ptr[ind]];
            if(x > y)
               swap(x, y);
            if(st.find({x, y}) == st.end())
               st.insert({x, y});
            else
            {
               st.erase({x, y});
               temp.pb(x);
               temp.pb(y);
               ptr[x]++;
               ptr[y]++;
               if(ptr[x] == n-1)
                  count.erase(x);
               if(ptr[y] == n-1)
                  count.erase(y);
            }
         }
         changed = temp;
         if(changed.size() == 0)
         {
            days = -1;
            break;
         }
         days++;
      }
      cout<<days;

}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string n;
    cin >> n;
    long sum = 0;

    for(int i = 0; i < (int)n.size(); ++i){
        sum += (int) n[i] - 48;
    }

    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int A1 = 0, A2 = 0, A3 = 0,result=0;
        A1 = input.nextInt();
        A2 = input.nextInt();
        A3 = input.nextInt();
        
        if (1 <= A1 && A1 <= 13 && 1 <= A2 && A2 <= 13 && 1 <= A3 && A3 <= 13 ) {   
            if(A1+A2+A3==22 || A1+A2+A3>22){
                System.out.println("bust");
            }
            else{
                System.out.println("win");
            }       

        }
        else{
           
        }

    }
}


Measured memory_bytes: 23380
#include <iostream>
using namespace std;
int main(void){
  long long  n;
  cin>>n;
  long long  *a=new long long [n];
  long long *a2=new long long[n];
  long long sum=0;
  for(int i=0;i<n;i++){
      cin>>a[i];
      if(i!=0)
      a2[i]+=a[i]+a2[i-1];
    else   a2[i]=a[i];
      sum+=a[i];
     // cout<<a2[i]<<" ";
  }//cout<<sum<<" ";
  long long mn=100000000000000000;
   for(int i=0;i<n-1;i++){
      if(abs((sum-a2[i])-a2[i])<mn){
          mn=abs((sum-a2[i])-a2[i]);
          //pos=i;
         // cout<<mn<<" ";
      }
  }

  cout<<mn;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];

	sort(all(v));
	reverse(all(v));
	int ans = 0;
	int ck = 1;
	rep(i, n)
	{
		ans += ck * v[i];
		ck *= -1;
	}

	cout << ans << endl;

	return (0);
}


Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  long long count=0;
  for(int i=1;i<=N;i++){
  	if(i%3!=0 && i%5!=0){
    	count=count+i;
    }
  }
 cout<<count<<endl;
}


Measured memory_bytes: 3548
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int nC2(int n) {
	return n * (n - 1) / 2;
}

int DP[502][502];	//DP[l][r]:[l,r]に含まれる
int L[200000], R[200000], p[100000], q[100000];

signed main() {
	int ans = 0;
	int N, M, Q;
	cin >> N >> M >> Q;
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
		DP[L[i]][R[i]]++;
	}
	for (int i = 0; i < Q; i++) {
		cin >> p[i] >> q[i];
	}
	//した->うえ
	for (int x = 0; x <= N; x++) {
		for (int i = N; i > 0; i--) {
			DP[i - 1][x] += DP[i][x];
		}
	}
	//みぎ->ひだり
	for (int y = 0; y <= N; y++) {
		for (int i = 1; i <= N; i++) {
			DP[y][i] += DP[y][i - 1];
		}
	}

	for (int i = 0; i < Q; i++) {
		cout << DP[p[i]][q[i]]<<"\n";
	}

	//cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 7552
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9+7;

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var a = o.r(h,1);
  var dp = Array(h).fill(0).map(a=>Array(w).fill(0));
  dp[0][0] = 1;
  for(var i = 0; i < h; i++){
    if(a[i][0] === "." && i)dp[i][0] = dp[i-1][0];
    for(var j = 1; j < w; j++){
      if(a[i][j] === "#")continue;
      if(i === 0)dp[0][j] = dp[0][j-1];
      else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
    }
  }
  return dp[h-1][w-1];
}

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

const int MAXN = 1e5 + 21;

int n, k;
long long a[MAXN];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];

    sort(a, a + n, greater <int>());

    for(int i = 1; i <= n; i++) {
        if(a[i] <= i) {
            k = 0;
            while(a[i + k] == i)
                k++;

            if (k & 1 || (a[i - 1] - i) & 1)
                cout << "First" << '\n';
            else
                cout << "Second" << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define unordered_map umap
typedef long long ll;
typedef long double ld;
ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}
bool isPrime(int n){if(n<2){return false;}for(int i=2;i<sqrt(n)+1;i++){if(n%i==0) return false;}return true;}


int main(){
  int N; cin >>N;
  ll r = 0;
  ll a;
  REP(i,N){
    cin >> a;
    r += a-1;
  }
  printf("%Ld",r);
}


Measured memory_bytes: 256