akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N;
	cin >> N;
	vector<int> H(N);
	REP(i, N) cin >> H[i];
	int res = 1;
	FOR(i, 1, N) {
		bool flag = true;
		REP(j, i) {
			if (H[j] > H[i]) flag = false;
		}
		if (flag) res++;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import math

t = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

c = [t[0]*a[0],t[1]*a[1]]
d = [t[0]*b[0],t[1]*b[1]]

if sum(c)==sum(d):
    print('infinity')
    exit()
elif c[0]==d[0]:
    print('infinity')
    exit()

if sum(d)>sum(c) and d[0]>c[0]:
    print(0)
    exit()
elif sum(c)>sum(d) and c[0]>d[0]:
    print(0)
    exit()



if sum(d)>sum(c):
    if d[0]>c[0]:
        print(0)
        exit()
    elif d[0]<c[0]:
        n = (c[0]-d[0])/(sum(d)-sum(c))
        if n==int(n):
            print(2*int(n))
        else:
            print(2*math.ceil(n)-1)
elif sum(c)>sum(d):
    if c[0]>d[0]:
        print(0)
        exit()
    elif c[0]<d[0]:
        n = (c[0]-d[0])/(sum(d)-sum(c))
        if n==int(n):
            print(2*int(n))
        else:
            print(2*math.ceil(n)-1)


Measured memory_bytes: 38384
#ifndef _WIN32
#include<iostream>
#endif

#include <complex>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <iomanip>
using namespace std;


#define FOR(i,bg,ed) for(int i = (bg);<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back

#define IL inline
namespace geo{
	typedef double D;
	typedef bool B;
	typedef complex<D> P;
#define X real()
#define Y imag()
	B comp(const P& l, const P& r)
	{
		return (l.X == r.X) ? l.Y < r.Y : l.X < r.X;
	}
	typedef pair<P, P> L;
	typedef pair<P, P> LS;
	typedef pair<P, D> C;
	typedef vector<P> Poly;
	const D EPS = 1e-8;

	//Decomposition Macro
#define DCI(a,b,l) P(a),(b);tie(a,b)=l;
#define DCc(a,b,c) P(a);D(b);tie(a,b)=c;

	//A dot B
	IL D dot(P a, P b)
	{
		return a.X*b.X + a.Y*b.Y;
	}
	IL D cross(P a, P b)
	{
		return a.X*b.Y - a.Y*b.X;
	}
	IL D ccw(P a, P b, P c)
	{
		return cross(b - a, c - a);
	}

	IL int sgn(P a, P b, P c){
		if (cross(b - a, c - a) > EPS)return 1;
		if (cross(b - a, c - a) < -EPS)return -1;
		if (dot(b - a, c - a) < -EPS)return 2;
		if (dot(a - b, c - b) < -EPS)return -2;
		return 0;
	}
	IL D signed_distance_P_L(P p, L l){
		DCI(a, b, l);
		return cross(b - a, p - a) / abs(b - a);
	}
	IL D dinstance_P_L(P p, L l){
		return abs(signed_distance_P_L(p, l));
	}
	IL D distance_P_LS(P p, LS ls){
		DCI(a, b, ls);
		if (dot(b - a, p - a) < EPS)return abs(p - a);
		if (dot(a - b, p - b) < EPS)return abs(p - b);
		return abs(cross(b - a, p - a)) / abs(b - a);
	}

	IL B is_L_L(L p, L q){
		DCI(a, b, p);
		DCI(c, d, q);
		return abs(cross(a - b, c - d))>EPS ||
			abs(cross(a - b, d - b)) < EPS; 
	}
	IL B is_LS_LS(LS p, LS q){
		DCI(a, b, p);
		DCI(c, d, q);
		return sgn(a, b, c) * sgn(a, b, d) <= 0 &&
			sgn(c, d, a) * sgn(c, d, b) <= 0;
	}
	IL D distance_LS_LS(LS p, LS q){
		if (is_LS_LS(p, q))
			return 0;
		return
			min({ distance_P_LS(p.fi, q) ,
			 distance_P_LS(p.se, q) ,
			 distance_P_LS(q.fi, q) ,
			 distance_P_LS(q.se, q) });
	}
	IL P cross_point_L_L(L p, L q){
		DCI(a, b, p);
		D d1 = signed_distance_P_L(a, q);
		D d2 = signed_distance_P_L(b, q);
		return (a*d2 - b*d1) / (d2 - d1);
	}
}

using namespace geo;


int main()
{
	int n;

	cin >> n;
	while (n--){
		D x1, x2, x3, y1, y2, y3, x4, y4;

		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		P a(x1 - x2, y1 - y2), b(x3 - x4, y3 - y4);

		P p(x1,y1),q(x2,y2),r(x3,y3),s(x4,y4);

		cout << setprecision(11);

		auto ans = cross_point_L_L({ p, q }, { r, s });
		cout << ans.X << " " << ans.Y  << endl;
	}
	return 0;
}

Measured memory_bytes: 3352
(defun calc-a (x y)
  (if (> x y)
      y
      x))

(defun gen-a (n b)
  (append (list (aref b 0))
          (loop :for i :from 0 :to (- n 3)
             :collect (calc-a (aref b i) (aref b (1+ i))))
          (list (aref b (- n 2)))))

(defun main ()
  (let* ((n (read))
         (b (coerce (loop :repeat (1- n) :for i = (read) :collect i)
                    'vector)))
    (format t "~A~%" (reduce #'+ (gen-a n b)))))

(main)

Measured memory_bytes: 16480
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int ab, bc, ca,s,S;
    cin >>ab>>bc>>ca;
    s = (ab + bc + ca) / 2.0;
    S  = sqrt(s*(s-ab)*(s-bc)*(s-ca));
    cout << S << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <ctype.h>
const int bufSize = 1e6;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++;
}
inline void read(char *s)
{
    static char c;
    for (; !isalpha(c); c = nc());
    for (; isalpha(c); c = nc()) *s++ = c;
    *s = '\0';
}
template<typename T>
inline T read(T &r)
{
    static char c;
    static int flag;
    flag = 1, r = 0;
    for (c = nc(); !isdigit(c); c = nc()) if (c == '-') flag = -1;
    for (; isdigit(c); c = nc()) r = r * 10 + c - 48;
    return r *= flag;
}
#define int long long
const int maxn = 1e5;
int n;
int a[maxn],f[maxn];
signed main()
{
    read(n);
    for (int i = 1; i <= n; ++i) read(a[i]);
    f[1] = 1000;
    for(int i = 2;i<=n;++i)
    {
        f[i] = f[i-1];
        for(int j = 1;j<i;++j)
        {
            if(a[i] <= a[j]) continue;
            int num = f[j] / a[j];
            f[i] = std::max(f[i],f[j] - num * a[j] + num * a[i]);
        }
    }
    printf("%lld\n",f[n]);
    return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "<" << #__VA_ARGS__ << ">:", debug_out(__VA_ARGS__)
#define INF LLONG_MAX


int main()
{
  ll n, m, c, a, b;
  cin >> n >> m;

  map <ll, vecll> mym;
  vecll ans(n, 0);

  forll(i, 0, m){
	cin >> a >> b;
	mym[a].push_back(b);
	mym[b].push_back(a);
  }
  
  queue <ll> s;
  s.push(1);
  while (not s.empty()){
	ll next = s.front();
	s.pop();
	forll(i, 0, (ll)mym[next].size()){
	  if (ans[mym[next][i] - 1] == 0){
		ans[mym[next][i] - 1] = next;
		s.push(mym[next][i]);
	  }
	}
  }
  cout << "Yes" << endl;
  forll(i, 1, n){
	cout << ans[i] << endl;
  }
}


Measured memory_bytes: 22508
#pragma region header
#include <bits/stdc++.h>
#define int long long
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define mp make_pair
#define mt make_tuple
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i > static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1) (__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1) (__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
using namespace std;

using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using vp = vector<pii>;
using vvp = vector<vp>;
using mii = map<int, int>;
using vm = vector<mii>;
using vvm = vector<vm>;
template <class T>
using less_queue = priority_queue<T>;
template <class T>
using greater_queue = priority_queue<T, vector<T>, greater<T>>;

constexpr int INF = 1e18;

template <class T>
void SORT(T &a) { stable_sort(all(a)); }
template <class T>
void RSORT(T &a) { stable_sort(rall(a)); }
template <class T>
void rev(T &a) { reverse(rall(a)); }
template <class T>
void uniq(T &a) { a.erase(unique(all(a)), end(a)); }
template <class T>
auto min_of(T a) { return *min_element(all(a)); }
template <class T>
auto max_of(T a) { return *max_element(all(a)); }
template <class T>
int sum_of(T a) { return accumulate(all(a), 0ll); }
template <class T, class U>
auto sum_of(T a, U init) { return accumulate(all(a), init); }
template <class T, class U>
int count_of(T a, U i) { return count(all(a), i); }
template <class T, class U>
bool has(T a, U i) { return find(all(a), i) != end(a); }
template <class T>
int sz(T a) { return a.size(); };

template <class T>
void COUT(T x) { cout << x << endl; }
template <class T, class U>
void COUT(T x, U y) { cout << x << ' ' << y << endl; }
template <class T, class U, class V>
void COUT(T x, U y, V z) { cout << x << ' ' << y << ' ' << z << endl; }
template <class T>
void CSP(T x) { cout << x << ' '; }
template <class T>
void CVEC(T v) {
  int c = v.size() - 1;
  for (size_t i = 0; i < c; i++) cout << v[i] << ' ';
  if (c > -1) cout << v[c];
  cout << endl;
}

template <class T>
bool amin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool amax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

#pragma endregion header

// no MOD


void solve(string s) {
  COUT(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]?"Bad":"Good");
}


#pragma region main
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;
  solve(s);
}
#pragma endregion main


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


vector<string> split(string& s,char c){
  int n=s.size();
  vector<string> res;
  for(int i=0;i<n;i++){
    if(s[i]==c) continue;
    string t;
    while(i<n&&s[i]!=c) t.push_back(s[i++]);
    res.push_back(t);
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  vector<string> ss;
  {
    string s;
    while(cin>>s) ss.emplace_back(s);
  }
  int n=ss.size();
  vector< vector<int> > vs(n);
  for(int i=0;i<n;i++)
    for(auto s:split(ss[i],','))
      vs[i].emplace_back(stoi(s));

  vector< vector<int> > dp(vs);
  for(int i=0;i+1<n;i++){
    for(int j=0;j<n;j++){
      for(int k=-1;k<=1;k++){
        if(j+k<0) continue;

        if(i<n/2 && k<0) continue;
        if(i>=n/2 && k>0) continue;

        if(j>=(int)dp[i].size()) continue;
        if(j+k>=(int)dp[i+1].size()) continue;

        chmax(dp[i+1][j+k],dp[i][j]+vs[i+1][j+k]);
      }
    }
  }

  cout<<dp[n-1][0]<<endl;
  return 0;
}



Measured memory_bytes: 3216
N = int(input())
INT_LIST_SORETED = sorted([int(s) for s in input().split()], reverse=True)
SECOND_INT_LIST_MAX = [val for idx, val in enumerate(INT_LIST_SORETED)
                       if idx <= 2 * N and idx % 2 == 1]
print(sum(SECOND_INT_LIST_MAX))


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

int P, Q, A, N;
int P_, Q_;

int gcd(int a, int b) {
	return a % b ? gcd(b, a % b) : b;
}

int solve(int a, int n, int sum, int b) {
	int res = 0;

	/*
	int div = gcd(sum , a);
	if(P_ == sum / div && Q_ == a / div)
		return 1;	
	// */
	if(sum / P_ == a / Q_ && sum % P_ + a % Q_ == 0)
		return 1;
	if(P_ * a < Q_ * sum)
		return 0;
	if(n >= N)
		return res;

	for(int i = b; a*i <= A; i++)
		res += solve(a * i, n + 1, sum * i + a, i);
	return res;
}

int main() {
	while(cin >> P >> Q >> A >> N, P | Q | A | N) {
//		cout << P << " " << Q << " " << A << " " << N << endl;
		int div = gcd(P, Q);
		//cout << div << endl;
		P_ = P / div;
		Q_ = Q / div;
		
		int res = 0;
		for(int i = 1; i <= A; i++) {
			int tmp;
			tmp = solve(i, 1, 1, i);
			if(tmp > 0)
				res += tmp;
		}
		cout << res << endl;
	}
}

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

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

  int L = A + B;
  int R = C + D;

  string LEFT = "Left";
  string BALANCED = "Balanced";
  string RIGHT = "Right";

  if (L < R) {
    cout << RIGHT << endl;
  }else if (L > R){
    cout << LEFT << endl;
  }else{
    cout << BALANCED << endl;
  }

}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, m, k = i_map()
    a_list = i_list()
    b_list = i_list()

    a_ruisekiwa = list(accumulate(a_list))
    b_ruisekiwa = list(accumulate(b_list))

    # print(a_ruisekiwa)
    # print(b_ruisekiwa)

    max_count = 0

    for i in range(n):
        if k < a_ruisekiwa[i]:
            break
        insert_num = k - a_ruisekiwa[i]
        insert_index = bisect_right(b_ruisekiwa, insert_num)
        max_count = max(max_count, i + insert_index +1)

    for i in range(m):
        if k < b_ruisekiwa[i]:
            break
        insert_num = k - b_ruisekiwa[i]
        insert_index = bisect_right(a_ruisekiwa, insert_num)
        max_count = max(max_count, i + insert_index +1)

    print(max_count)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 133504
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,n) for(int i=1;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
int n;
int s[11]={0};
int d[11][11]={0};
void warshall_floyd(){
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
				}
					
			
		}
	}
	
}
int main(){
	
	int a,b,c;
	while(cin>>n,n!=0){
	
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(i!=j)
				d[i][j]=999999;
			else
				d[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		d[a][b]=c;
		d[b][a]=c;
	}
	
	warshall_floyd();
	
	int it=0;
	int min=999999;
	rep(i,10){
		int sum=0;
		bool f=false;
	rep(j,10){
		if(i!=j&&d[i][j]!=999999){
			f=true;
		sum+=d[i][j];
		}
		
	}
		
		if(f&&sum<min){
			it=i;
			min=sum;
		}
	}
	
	cout<<it<<" "<<min<<endl;
	}
}

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

#define ll long long

const ll mod=1e9+7;
const int N = 2e5 + 20;

ll f[N];

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

ll C(ll n,ll k)
{
    ll a=f[n];
    ll b=(f[k]*f[n-k])%mod;
    return (a*pw(b,mod-2))%mod;
}

int main()
{
    f[0]=1;
    for(int i=1;i<N;i++)
    {
        f[i]=(i*f[i-1])%mod;
    }
    ll h,w,a,b;
    cin>>h>>w>>a>>b;

    ll ans=0;
    for(ll i=b+1;i<=w;i++)
    {
//        cout<<"B";
        ll tmp=(C(i-1+h-a-1,h-a-1)*C(w-i+a-1,w-i))%mod;
//        cout<<C(i-1+h-a-1,h-a-1)<<" "<<C(w-i+a-1,w-i)<<" ";
//        cout<<tmp<<endl;
//cout<<"A";
        ans=(ans+tmp) %mod;
    }
    cout<<ans%mod;
}


Measured memory_bytes: 1792
import java.util.*;
/**
 * Created by 卢嘉昊 on 2017/8/12.
 */
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        int Alice = B-A;
        int Bob = D-C;
        int res = 0;
        if(A<C){
            if(B<C) res = 0;
            else if(B>D) res = Bob;
            else res = B-C;
        }else if(A == C){
            res = Alice < Bob ? Alice : Bob;
        }else{
            if(A>=D) res = 0;
            else if(B>D) res = D-A;
            else res = B-A;
        }
        System.out.println(res);
    }
}

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

bool IsPrime(int num){
   if (num < 2) return false;
   else if (num == 2) return true;
   else if (num % 2 == 0) return false;
 
   double sqrtNum = sqrt(num);
   for (int i = 3; i <= sqrtNum; i += 2) {
     if (num % i == 0) {
       return false;
     }
   }
   return true;
 }

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

	int n;
	cin >> n;
	rep(i, n) {
		if(IsPrime(n + i)) {
			cout << n + i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i=0; i<m; i++) cin >> b[i];
    
    int result = 0;
    for(int i=0; i<n; i++) {
        int sum = c;
        for(int j=0; j<m; j++) {
            int temp;
            cin >> temp;
            sum += b[j]*temp;
        }

        if(sum >0) result++;
    }


    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
  int N;
  cin >> N;
  int max=0,i,p,ans=0;
  for(i=0;i<N;i++){
    cin >>p;
    ans+=p;
    if(p>max)max=p;
  }
  cout << ans-max/2;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

vector<ll> T,P;

//dp
map<pair<ll,ll>,ll> table;

ll dp(ll i,ll x){
  if(x<=0) return 0;
  if(i<=0) return 1;
  if(table.count({i,x})) return table[{i,x}];
  
  if(x==1) return 0; x-=1;
  if(x<=T[i-1]) return dp(i-1,x); x-=T[i-1];
  if(x==1) return P[i-1]+1; x-=1;
  if(x<=T[i-1]) return dp(i-1,x)+P[i-1]+1;
  return P[i];
}


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,X; cin>>N>>X;
  
  T=vector<ll>(N+1,1); rep(i,N) T[i+1]=2*T[i]+3;
  P=vector<ll>(N+1,1); rep(i,N) P[i+1]=2*P[i]+1;
  
  //dp
  cout<<dp(N,X)<<endl;
  
  //rep(i,T[N]) cout<<dp(2,i+1)<<endl;
  return 0;
}

Measured memory_bytes: 3616
N,X=map(int,input().split())
a,p=[1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
    if n==0:return 0 if x<=0 else 1
    elif x<=1+a[n-1]:return f(n-1,x-1)
    else:return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))

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

int main(void){

	int a, b, n;
	while (cin >> a >> b, a, b){
		cin >> n;
		int dp[20][20] = { 0 };
		for (int i = 0; i < n; i++){
			int x, y;
			cin >> x >> y;
			dp[x][y] = -1;
		}
		dp[1][1] = 1;
		for (int i = 1; i <= a; i++){
			for (int j = 1; j <= b; j++){
				if (i == 1 && j == 1) continue;
				dp[i][j] = (dp[i][j] + 1) * (dp[i - 1][j] + dp[i][j - 1]);
			}
		}

		cout << dp[a][b] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(k==1) printf("YES\n");
    else
    {
        if(k<=(n+1)/2) printf("YES\n");
        else printf("NO\n");
    }
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    string str;
    cin >> str;
    for(auto&& i : str){
        cout << static_cast<char>((i - 'A' + n) % 26 + 'A');
    }
    cout << "\n";
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int k;
string s;

void process()
{
    vector<string> a;
    for (int i=0;i<s.length();++i)
    {
        for (int j=i;j<=i+k;++j)
        {
            string ss=s.substr(i,j-i+1);
            a.push_back(ss);

        }
    }
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    cout<<a[k-1];
}

int main()
{
    cin>>s>>k;
    process();
    return 0;
}


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

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = sum(B)

for i in range(N-1):

    if A[i] + 1 == A[i+1]:

        ans += C[A[i]-1]

print (ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
	int n;cin>>n;
	int ans=0,ctr;
	for (int i=1; i<=n; i+=2){
		ctr=0;
		for (int j=1; j<=i; ++j)if(i%j==0)++ctr;
		if(ctr==8)++ans;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int h,w;
    cin >> h >> w;
    vector<vector<int>> c(10,vector<int>(10,0));
    rep(i,10) rep(j,10) cin >> c[i][j];
    int cnt[10] = {0};
    rep(i,h) 
        rep(j,w)
        {
            int a; cin >> a;
            if(a>=0) cnt[a]++;
        }

    int dp[10][10][10]; //[from][to][cnt]
    rep(i,10) rep(j,10) rep(k,10) dp[i][j][k] = i==j ? 0 : 1e9;
    rep(i,10) rep(j,10) dp[i][j][1] = c[i][j];
    
    rep2(k,2,10)
        rep(i,10)
            rep(j,10)
            {
                int min_cost = 1e9;
                rep(l,10)
                    min_cost = min(min_cost,dp[i][l][k-1] + c[l][j]);                
                dp[i][j][k] = min_cost;
            }
    
    int mp = 0;
    rep(i,10) mp += cnt[i] * dp[i][1][9];

    cout << mp << endl;
    return 0;
}

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

int main() {
  int a, b, seki;
  cin >> a >> b;
  seki =  (a * b) % 2;
  
  if ( seki == 0 ) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
  
}

Measured memory_bytes: 256
while line = gets
  a, op, b = line.split
  a, b = a.to_i, b.to_i

  case op
  when '+'
    puts a + b
  when '-'
    puts a - b
  when '*'
    puts a * b
  when '/'
    puts a / b
  when '?'
    break
  end
end

Measured memory_bytes: 8596
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
int main()
{
  ll n,k,d,i,j,x,c=0;
  cin>>n>>k;
  bool arr[n];
  memset(arr,0,n);
  for(i=0;i<k;i++)
  {
    cin>>d;
    for(j=0;j<d;j++)
    {
       cin>>x;
       if(arr[x-1]==0)
            {
             arr[x-1]=1;
             c++;
            }
    }

  }
  
  
   cout<<n-c<<endl;
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <bitset>
#include <cmath>

using namespace std;
typedef long long unsigned int ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main() {
    int n,m,ans=0,t,tf =0;
    scanf("%d %d", &n,&m);
    int s[m][n],k[m],p[m];
  bitset<10> b;
    REP(i,m){
        scanf("%d",&k[i]);
     	REP(i2,k[i]) scanf("%d",&s[i][i2]);
    }
  	REP(i,m) scanf("%d",&p[i]);
  	REP(i,pow(2,n)){
    	b = static_cast<bitset<10> >(i);
    	REP(i2,m){
          t=0;
        	REP(i3,k[i2]){
            	t += b[s[i2][i3]-1];
             
            }
          if(t%2 == p[i2]) tf=1;
          else{ tf = 0; break;}
        }
      	if(tf) ans +=1;
    }
    printf( "%d\n", ans );
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	vll a(n), b(n), c(n-1);
	ll ans=0;
	rep(i, n) cin>>a[i];
	rep(i, n){
		cin>>b[i];
		ans+=b[i];
	}
	rep(i, n-1) cin>>c[i];

	rep(i, n-1){
		if (a[i]+1==a[i+1]){
			ans+=c[a[i]-1];
		}
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> v[100000];
vector<pair<int,int> > ans;
int S[100000],D[100000];

void dfs(int p,int d,int pr){
  D[p]=d;
  for(int i=0;i<v[p].size();i++){
    int np=v[p][i];
    if(pr==np)continue;
    if(!D[np]){
      dfs(np,d+1,p);
      if(!S[np])ans.push_back(make_pair(min(p,np),max(p,np)));
      S[p]+=S[np];
    }
    else if(D[p]>D[np])S[np]--,S[p]++;
  }
}

int main(){
  int V,E;
  cin>>V>>E;
  for(int s,t,i=0;i<E;i++)
    cin>>s>>t,v[s].push_back(t),v[t].push_back(s);
  dfs(0,1,-1);
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)cout<<ans[i].first<<" "<<ans[i].second<<endl;
  return 0;
}

Measured memory_bytes: 7156
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int a,b;
  cin >> a >> b;
  cout << max({a+b,a-b,a*b}) << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{

    ll x,y,i,j,n,m,mid,p,q,z,t,k,b,c,a,d;
    cin>>a>>b>>c>>d;
    x=b*d;
    y=b*c;
    p=a*c;
    q=a*d;

    x=max(x,y);
    p=max(p,x);
    q=max(p,q);
    cout<<q;



}


Measured memory_bytes: 3632
class Node
  attr_accessor :id, :parent, :left, :right

  def initialize(id)
    @id = id
    @parent = -1
    @left = nil
    @right = nil
  end

  def add_left(left)
    @left = left
    @left.parent = self
  end

  def add_right(right)
    @right = right
    @right.parent = self
  end

end

class BinaryTree
  attr_accessor :root, :list

  def initialize(root)
    @root = root
  end

  def pre
    # 行きがけ順探索(左上から順に)
    @list = []
    traverse(@root, :pre)
    @list
  end

  def in
    # 通りがけ順探索
    @list = []
    traverse(@root, :in)
    @list
  end

  def post
    # 帰りがけ順探索(左下から順に)
    @list = []
    traverse(@root, :post)
    @list
  end

  private
  def traverse(node, type)
    @list << node.id if type == :pre
    traverse(node.left, type) if node.left
    @list << node.id if type == :in
    traverse(node.right, type) if node.right
    @list << node.id if type == :post
  end
end

n = gets.to_i
tree = Array.new(n){ | i | Node.new(i) }
n.times do
  id, l, r = gets.split.map(&:to_i)
  tree[id].add_left(tree[l])  if l != -1
  tree[id].add_right(tree[r]) if r != -1
end

root = nil
tree.each{ | n | root = n if n.parent == -1 }

bt = BinaryTree.new(root)
puts 'Preorder'
puts " #{bt.pre.join(' ')}"
puts 'Inorder'
puts " #{bt.in.join(' ')}"
puts 'Postorder'
puts " #{bt.post.join(' ')}"


Measured memory_bytes: 8888
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FIntervalRunning solver = new FIntervalRunning();
        solver.solve(1, in, out);
        out.close();
    }

    static class FIntervalRunning {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long[] t = in.readLongArray(2);
            long[] a = in.readLongArray(2);
            long[] b = in.readLongArray(2);

            long A = 0, B = 0;
            for (int i = 0; i < 2; i++) {
                A += a[i] * t[i];
                B += b[i] * t[i];
            }

            if (A == B) {
                out.println("infinity");
                return;
            }

            if (A < B) {
                long tmp = A;
                A = B;
                B = tmp;
                long[] tmp2 = a;
                a = b;
                b = tmp2;
            }
            // now A eventually leaves B completely

            long X = t[0] * a[0];
            long Y = t[0] * b[0];

            if (X > Y) {
                out.println(0);
                return;
            }

            long D1 = Math.abs(X - Y);
            long D2 = Math.abs(A - B);
            long answer = (D1 + D2 - 1) / D2;
            answer *= 2;
            if (D1 % D2 != 0)
                answer--;
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] x = new long[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextLong();
            }
            return x;
        }

    }
}



Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int A[101010];

signed main(void){ 
  int n,m; cin >> n >> m;
  int sum = 0;
  for(int i = 0; i < m; i++){ 
    cin >> A[i]; sum += A[i];
  }
  if( sum > n ) { cout << "-1" << endl; return 0;} 
  
  cout << n-sum << endl;
  
  return 0;
} 

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>

int main(){
    ll a,b;
    cin >> a >> b;
    vector<ll> A(a);
    vint B(a);
    rep(i,b){
        int c;
        cin >> c;
        B[c-1] = 1;
    }//Bのi番目が1の時i+1段目の床が抜けている
  //Aのi番目がi+1段目までの総数を示している
    for(int i = 0;i<a;i++){
      if(i == 0){
        if(B[i] == 0) A[i] = 1; 
        else A[i] = 0;
      }
      else if(i == 1){
        if(B[i] == 0) A[i] = A[i-1] + 1; 
        else A[i] = 0;
      }
      else{
        if(B[i] == 0) A[i] = (A[i-1] + A[i-2])%1000000007;
        else A[i] = 0;
      }
    }
    cout << A[a-1]%1000000007 << endl;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    auto fail = [](){ cout << "No\n"; exit(0); };

    int N;
    cin >> N;

    vi p(N);
    vi move(N);

    for (int i = 0; i < N; i++) {
        cin >> p[i];
        --p[i];
        move[i] = p[i] == i ? 0 : p[i] > i ? 1 : -1;
    }

    auto proc = [&](vi& grp) {
        vi vals;

        int left = -1, right = -1;
        for (int i : grp) {
            int& which = move[i] == -1 ? left : right;
            if (which > p[i]) fail();
            which = p[i];

            vals.push_back(p[i]);
        }

        sort(all(vals));
        if (vals != grp) fail();
        grp.clear();
    };

    vi grp;
    for (int i = 0; i < N; i++) {
        if (i > 0 && !!move[i] == !!move[i-1]) {
            proc(grp);
        }
        if (move[i]) grp.push_back(i);
    }
    proc(grp);

    cout << "Yes\n";

    return 0;
}



Measured memory_bytes: 4724
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	
	static void printMatrixInt(int[][] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[0].length; j++) {
				if (j > 0)
					System.out.print(" ");
				System.out.print(array[i][j]);
			}
			System.out.println();
		}

	}
	
	public static void main(String[] args) throws IOException {
		StringBuilder out = new StringBuilder();
		BufferedReader in;
		
			in = new BufferedReader(new InputStreamReader(System.in));

		char a[] = in.readLine().toCharArray();
		char b[] = in.readLine().toCharArray();
		
		int dp[][] = new int[a.length+1][b.length+1];
		
		for( int i =1; i <= a.length; i++ ) {
			for( int j = 1; j <= b.length;j++ ) {
				if( a[i-1] == b[j-1] ) {
					dp[i][j] = Math.max(dp[i-1][j-1] + 1, Math.max(dp[i-1][j], dp[i][j-1])); 
				}else {
					dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);
				}
			}
		}
		
		ArrayList<Character> values = new ArrayList();
		
		solve( out, a.length, b.length, dp, a );
		
		//System.out.println(values);
		
		System.out.println(out);
		//printMatrixInt(dp);

	}
	
	public static void solve( StringBuilder out, int x, int y, int dp[][], char a[] ) {
		
		if( x > 0 && dp[x-1][y] == dp[x][y] ) {
			solve(out, x-1, y, dp, a);
		}
		else if( y > 0 && dp[x][y-1] == dp[x][y] ) {
			solve( out, x, y-1, dp, a );
		}else if( x > 0 || y > 0 ) {
			solve( out, x-1, y-1, dp, a );
			out.append( a[x-1] );
		}
	}
	
	public static int[] readInts(String cad) {
		String read[] = cad.split(" ");
		int res[] = new int[read.length];
		for (int i = 0; i < read.length; i++) {
			res[i] = Integer.parseInt(read[i]);
		}
		return res;
	}
	
}


Measured memory_bytes: 82516
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N,sum=0,M,i,p,x;
    cin >> N;
    vector<int> T(N);
    for(i=0;i<N;i++){
        cin >> T.at(i);
        sum += T.at(i);
    }
    cin >> M;
    for(i=0;i<M;i++){
        cin >> p >> x;
        cout << sum - T.at(p-1) + x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String[] n = str.split("");
        int sum = 0;
        
        ListIterator<String> iterator = Arrays.asList(n).listIterator();
        
        while(iterator.hasNext()){
            sum += Integer.parseInt(iterator.next());
        }
        
        int num = Integer.parseInt(str);
        if(num % sum == 0) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 21460
import sys

sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7
fac = [1]
caf = [1]

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


def pow(n, p):
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod


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


def ncr(n, r):
    if n < r or r < 0:
        return 0
    return (fac[n] * caf[r] * caf[n - r]) % mod


if K >= N - 1:
    print(ncr(N + N - 1, N))
else:
    res = 0
    for i in range(K + 1):
        res += (ncr(N, i) * ncr(N - 1, N - i - 1)) % mod
        res %= mod
    print(res)


Measured memory_bytes: 94684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
ll mod=1e9+7;
using P=pair<int,int>;
struct op{int a,b,c,d;};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,h;cin>>n>>h;
    vector<int> a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    int maxi=0,tot=0;
    rep(i,n)if(maxi<a[i])maxi=a[i];
    sort(b.begin(),b.end(),greater<int>());
    for(int i=0;i<n;i++){
        if(b[i]<maxi)break;
        h-=b[i];
        tot++;
        if(h<=0)break;
    }
    if(h>0)tot+=(h+maxi-1)/maxi;
    cout<<tot<<endl;
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007
int n;

ll dp[2100000];
int main() {

	cin >> n;
	vector<vector<int> > a(n, vector<int>(n));
	rep(i,n) rep(j,n) cin >> a[i][j];
	dp[0] = 1;
	for(ll s = 1; s < (1 << n); s++) {
		int i = __builtin_popcount(s);
		rep(j,n) {
			if(a[i-1][j] == 1 && (s & (1 << j))) {
				dp[s] = (dp[s] + dp[(s^1<<j)])%MOD;
			}
		}
	}
	cout << dp[(1<<n)-1] << endl;

  return 0;
}



Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ll ans=0;
	int n;
	cin>>n;
	for(int i=1;i<n;i++) {
		ll tmp=(n/i);
		if(n%i==0) tmp--;
		ans+=tmp;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_set>

using namespace std;

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

  for (int i = 0; i < s.size(); i++)  {
    for (int j = i + 1; j < s.size(); j++) {
      if (s[i] == s[j]) {
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
//arc064_d.cpp
//Sat Dec 28 22:15:50 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	char first = s[0];
	char last = s[s.length()-1];

	if (first==last){
		if (s.length()%2==1){
			cout << "Second" << endl;
		}else {
			cout << "First" << endl;
		}
	}else {
		if (s.length()%2==1){
			cout << "First" << endl;
		}else{
			cout << "Second" << endl;
		}
	}

//	cout << mp[first] << endl;

}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "Trace On! (Line: " << __LINE__ << ")\n"; d_f(string(#args), args); } while(0)
	void d_f(__attribute__((unused)) string str) {}
	template<typename Head, typename... Tails> void d_f(string str, Head H, Tails... T) { cerr << "\t" << str.substr(0, str.find(", ")) << " <=> [" << H << "]\n"; d_f(str.substr(str.find(", ") + 2), T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int in;
	cin >> in;

	ld sum = in;
	ld dim = sum / 3;
	cout << dim * dim * dim << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3788
x,n=map(int,input().split())
if (n==0):
  print(x)
else:
  p=[0]*n
  av=[0]*n
  p=list(map(int,input().split()))

  check=x
  if (p.count(x)==0):
      print(check)
  else:
      check1=check
      check2=check
      for i in range(100):
          check1=check1-1
          if (p.count(check1)==0):
              print(check1)
              break
          check2=check2+1
          if (p.count(check2)==0):
              print(check2)
              break

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

using namespace std;
typedef pair<int, int> ii;

int n;
int arr[101];

const int MOD = (int)1e9 + 7;

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

    long long dp[n][k+1];

    if(n == 1 and arr[0] != k) {
        cout << "0";
    } else if(n == 1) {
        cout << "1";
    } 
    if(n == 1) return 0;
    for(int i = 0; i <= k; ++i) {
        dp[n-1][i] = 0;
        if(i <= arr[n-1]) dp[n-1][i] = 1;
    }

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

    for(int i = n-2; i >= 0; --i) {
        for(int j = 0; j <= k; ++j) {

            dp[i][j] = dp[i+1][j] - ( (j-arr[i] > 0)?dp[i+1][ j - arr[i] - 1] : 0);

            if(j and i) {
                dp[i][j] += dp[i][j-1];
            }
            dp[i][j] %= MOD;
        }

    }


    cout << (dp[0][k] + MOD)%MOD;

}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
 //stringstream num(c);
    //        num >> x;
using namespace std;
int main()
{
    int k;
    int a,b,flag=0;
    cin>>k;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            flag=1;
            break;
        }

    }
    if(flag==0)
        cout<<"NG";

    return 0;
}




Measured memory_bytes: 3636