akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
//const int mod = 1000000007;
const int mod = 998244353;

struct mint {
	ll x;
	mint(ll x = 0) :x(x% mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

mint dp[3005][3005];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, s;
	cin >> n >> s;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	dp[0][0] = 1;
	rep(i, n) {
		for (int j = 0; j <= s; ++j) {
			dp[i + 1][j] += dp[i][j] * 2;
			if (j - a[i] >= 0) dp[i + 1][j] += dp[i][j - a[i]];
		}
	}
	printf("%d\n", dp[n][s]);
	return 0;
}


Measured memory_bytes: 74296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;

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

int main() {
    ll k,ans = 0;cin >> k;
    for(int i= 1;i<=k;i++) {
        for(int j= 1;j<=k;j++) {
            for(int l= 1;l<=k;l++) {
                ans += gcd(i,gcd(j,l));
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define For(i, s, e) for(int i = s;i <= e;i++)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;

int main() {
    int s,w;
    cin>>s>>w;
    if(s<=w) {
        cout << "unsafe";
    } else {
        cout << "safe";
    }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

long long k, a, b, ans;
int main(){
  scanf("%lld%lld%lld", &k, &a, &b); k++;
  if(a+2 >= b) ans = k;
  else{
    k -= a;
    ans = a + (b - a)*(k/2) + k%2;
  }
  printf("%lld\n", ans);
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
std::vector<std::string> split(const std::string &str, const char delemiter) {std::vector<std::string> res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int X; cin >> X;
    int ans;
    if(400<=X && X< 600) ans = 8;
    else if(600 <= X && X < 800) ans = 7;
    else if(800 <= X && X < 1000) ans = 6;

    else if(1000 <= X && X < 1200) ans = 5;
    else if(1200 <= X && X < 1400) ans = 4;
    else if(1400 <= X && X < 1600) ans = 3;
    else if(1600 <= X && X < 1800) ans = 2;
    else ans = 1;
    cout << ans << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  string hi = "";
  bool can = false;
  rep(i,5){
    hi += "hi";
    if(hi == s) {
      can = true;
      break;
    }    
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#define Inf 1<<21
#define Lens 105

using namespace std;
int N;
int w[Lens][Lens], p[Lens], d[Lens];
char c[Lens];

int prime()
{
	d[0] = 0;
	int num = 0;
	while (true)
	{
		int minv = Inf;
		int u = -1;
		for (int i = 0; i < N; i++)
		{
			if (minv > d[i] && c[i] == 'w')
			{
				minv = d[i];
				u = i;
			}
		}
		if (u == -1) break;
		c[u] = 'b';
		for (int i = 0; i < N; i++)
		{
			if (c[i] == 'w'&&w[u][i] != -1)
				if (d[i] > w[u][i])
				{
					d[i] = w[u][i];
					p[i] = u;
				}
		}
	}
	int sum = 0;
	for (int i = 1; i < N; i++)
	{
		sum = sum + w[i][p[i]];
	}
	return sum;
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		c[i] = 'w';
		d[i] = Inf;
		p[i] = -1;
		for (int j = 0; j < N; j++)
		{
			int k;
			cin >> k;
			w[i][j] = (k == -1) ? Inf : k;
		}
	}
	cout << prime() << endl;
	return 0;
}



Measured memory_bytes: 3164
N = int(input())
men = []
for _ in range(N):
    H,P = map(int,input().split())
    men.append((H,P,H+P))
men.sort(key=lambda x: x[2])

maxH = max(men)[0]
inf = maxH+1
#dp[i][j] -> i人目までみたとき、j人が座布団を積む場合の最小枚数
dp = [[-1]*(N+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    h,p,a = men[i-1]
    for j in range(1,N+1):
        if 0 <= dp[i-1][j-1] <= h:
            if dp[i-1][j] == -1:
                dp[i][j] = dp[i-1][j-1]+p
            else:
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-1]+p)
        else:
            dp[i][j] = dp[i-1][j]

for j in range(N,-1,-1):
    if dp[-1][j] != -1:
        print(j)
        break


Measured memory_bytes: 233476
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

const int MAX = 200010;
int main() {

  int H,W,A,B;
  cin >> H >> W >> A >> B;

  vector<long long> fac(MAX,1),finv(MAX,1),inv(MAX,1);
  for(int i = 2;i < MAX;i++) {
    fac.at(i) = fac.at(i-1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD%i) * (MOD/i) % MOD;
    finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
  }

  int l = H - A;
  long long ans = 0;
  for(int i = 0;i < l;i++) {
    long long bef = fac.at(B+i-1)*(finv.at(i)*finv.at(B-1)%MOD) % MOD;
    long long aft = fac.at(W-B+H-i-2)*(finv.at(W-B-1)*finv.at(H-i-1)%MOD) % MOD;
    ans += (bef * aft)%MOD;
    ans %= MOD;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

/*踏み入れた箇所の3で割った余りが違う場合はもう一度そこを使うこととする*/
lli flag[100100][3];

signed main(){

	lli n,m;
	cin>>n>>m;

	vector<vector<lli>> v(n);
	REP(i,0,m){
		lli tmpU,tmpV;
		cin>>tmpU>>tmpV;
		tmpU--,tmpV--;
		v[tmpU].push_back(tmpV);
	}

	lli s,t;
	cin>>s>>t;
	s--,t--;

	REP(i,0,100100)REP(j,0,3)flag[i][j]=-1;

	queue<lli> q;
	queue<lli> depth;

	q.push(s);
	depth.push(0);
	flag[s][0]=0;

	while(q.size()){
		lli top = q.front();
		lli topD = depth.front();
		lli nextD = (topD+1)%3;
		q.pop(),depth.pop();

		for(auto e:v[top]){
			if(flag[e][nextD]!=-1)continue;
			flag[e][nextD] = topD+1;
			q.push(e);
			depth.push(topD+1);
		}
	}

	if(flag[t][0]==-1)cout<<-1<<endl;
	else cout<<flag[t][0]/3<<endl;

	return 0;
}

Measured memory_bytes: 8064
n = int(input())
a = list(map(int,input().split()))

cnt = [0] * (10**5 + 1)

for i in a:
    cnt[i] += 1

x_cnt = [0] * (10**5 +1)
for x in range(1, 10**5):
    tmp = cnt[x-1] + cnt[x] + cnt[x+1]
    x_cnt[x] = tmp

print(max(x_cnt))

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

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

  for (int i = 0; i < N; i++){
    int seat_n, seat_m, temp;
    cin >> seat_n >> seat_m;
    temp = seat_m - seat_n + 1;
    sat_seat += temp;
  }

  cout << sat_seat << endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Russian Flag
 */
public class Main {

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

		line = br.readLine();

		int N, M;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		M = parseInt(line.substring(line.indexOf(' ') + 1));
		int[][] wbr = new int[N][3];

		for (int i = 0; i < N; i++) {
			line = br.readLine();
			int w = 0;
			int b = 0;
			int r = 0;
			for (char c : line.toCharArray()) {
				if (c == 'W') w++;
				else if (c == 'B') b++;
				else r++;
			}
			wbr[i][0] = b + r;
			wbr[i][1] = w + r;
			wbr[i][2] = w + b;
		}

		int min = N * M;
		for (int i = 1; i < N - 1; i++) {
			for (int j = i; j < N - 1; j++) {
				int change = 0;
				for (int k = 1; k < N - 1; k++) {
					if (k < i) {
						change += wbr[k][0];
					} else if (i <= k && k <= j) {
						change += wbr[k][1];
					} else {
						change += wbr[k][2];
					}
				}
				min = Math.min(min, change);
			}
		}

		System.out.println(wbr[0][0] + min + wbr[N - 1][2]);
	}
}

Measured memory_bytes: 24392
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <vector>

using namespace std;

int s=99999999;

void kakerukamosirenai(int total,int left,int a,int b,int c,int f){
	if(left>0){
		if(f==0){
			kakerukamosirenai(total+380,left-200,a+200,b,c,0);//a toru
			kakerukamosirenai(total,left,a,b,c,1);//a toranai
		}else if(f==1){
			kakerukamosirenai(total+550,left-300,a,b+300,c,1);//b toru
			kakerukamosirenai(total,left,a,b,c,2);//b toranai
		}else if(f==2){
			kakerukamosirenai(total+850,left-500,a,b,c+500,2);//c
		}
	}else if(left==0){
		int cnt=0;
		while(a>=1000){
			a-=1000;
//			total -= 380;
			cnt++;
		}
		total-=(1900*cnt)*20/100;
		cnt=0;

		while(b>=1200){
			b-=1200;
//			total -= 330;
			cnt++;
		}
		total-=(2200*cnt)*15/100;
		cnt=0;

		while(c>=1500){
			c-=1500;
//			total -= 306;
			cnt++;
		}
		total-=(2550*cnt)*12/100;

		if(s>total){
			s = total;
		}
	}else{
//		cout << "erratta" <<endl;
	}
}

int main(){

	vector<int> p;
	int n,c=0,a,t;

	while(1){
		cin >> n;
		p.push_back(n);
		if(p[c]==0)break;
		c++;
	}

	for(int i=0;i<c;i++){
		kakerukamosirenai(0,p[i],0,0,0,0);
		cout << s << endl;
		s = 999999999;
	}

	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 999999999999 //10^13-1
#define P pair<int,int>
#define prique priority_queue
int k,n;
int a[400000];
set<int>st;
signed main(){
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
		st.insert(a[i]);
	}
	int d=st.size();
	if(d<=k)cout<<0<<endl;
	else{
		sort(a,a+n);
		int cnt=1,ans=0;
		vector<int>vec;
		rep(i,n){
			if(a[i]==a[i+1])cnt++;
			else if(i!=n-1){
				vec.push_back(cnt);
				cnt=1;
			}
			if(i==n-1)vec.push_back(cnt);
		}
		sort(vec.begin(),vec.end());
		rep(i,d-k){
			ans+=vec[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 13304
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, functools, copy
# import resource
# print(resource.getrlimit(resource.RLIMIT_STACK))

# resource.setrlimit(resource.RLIMIT_STACK, (8388608, 67104768))
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
# print(sys.getrecursionlimit())
sys.setrecursionlimit(10**7)
# print(sys.getrecursionlimit())
inf = float('inf')
mod = 10**9+7
ans = inf ; count = 0; pro = 1

n=int(input())
count=0
# memo=[0]*(n+1)
# memo[0]=0
@functools.lru_cache(maxsize=None)
def func(n):
    if n==0:return 0
    # if memo[n] or n==0:return memo[n]
    # print(n)
    # global count
    # count+=1
    # if count%10==0:print(count)
    if n==0:
        return 0
    re=inf
    k=s=1
    while 9**s<=n:
        re=min(re,func(n-9**s)+1)
        s+=1
    while 6**k<=n:
        re=min(re,func(n-6**k)+1)
        k+=1
    re=min(re,func(n-1)+1)
    # memo[n]=re
    return re
    
print(func(n))
# print(memo)



Measured memory_bytes: 41684
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        int a=ni(),b=ni(),c=ni(),can=a-b,transferred=Math.min(can, c);
        pn(c-transferred);
    }


    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;
    static long mod=(long)1e9+7l;

    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

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

int main()
{
	int n,A,B;
	cin>>n>>A>>B;
	int t1=0,t2=0,t3=0;
	for (int i=1;i<=n;i++) {
		int x; scanf("%d",&x);
		if (x<=A) t1++;
		if (x>A && x<=B) t2++;
		if (x>B) t3++;
	}
	cout<<min(t1,min(t2,t3));
}


Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted([int(i) for i in input().split(" ")])
B = [int(i) for i in input().split(" ")]
C = sorted([int(i) for i in input().split(" ")])

ans = 0
for b in B:
    a = bisect.bisect_left(A, b) # 使えるAの要素数
    c = N - bisect.bisect_right(C, b) # 使えるCの要素数
    ans += a * c  

print(ans)

Measured memory_bytes: 23616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    if(n == 1)cout << abs(a[0]-w) << endl;
    else cout << max(abs(a[n-1]-w), abs(a[n-1]-a[n-2])) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

#include <array>

/*
    nCk, nPk, 階乗をmodをとりつつ求めるライブラリ
*/
template <int MAX_N = 100000, long long MOD = 1000000007LL>
class Combination {
    std::array<long long, MAX_N + 1> _fact;
    std::array<long long, MAX_N + 1> _fact_inv;

public:
    // xの逆元
    // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    long long inv(long long a) const {
        long long b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);

            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0)
            u += MOD;
        return u;
    }
    // n!
    long long fact(long long n) const {
        return _fact[n];
    }
    // 1 / n!
    long long fact_inv(long long n) const {
        return _fact_inv[n];
    }
    // nPk
    long long perm(long long n, long long k) const {
        return fact(n) * fact_inv(n - k) % MOD;
    }
    // nCk
    long long comb(long long n, long long k) const {
        return perm(n, k) * fact_inv(k) % MOD;
    }

    Combination() : _fact{}, _fact_inv{} {
        _fact[0] = _fact[1] = 1LL;
        for (int i = 2; i <= MAX_N; ++i) {
            _fact[i] = _fact[i - 1] * i % MOD;
        }
        _fact_inv[MAX_N] = inv(_fact[MAX_N]);
        for (int i = MAX_N - 1; i >= 0; --i) {
            _fact_inv[i] = _fact_inv[i + 1] * (i + 1) % MOD;
        }
    }
};
Combination<200000> cm;

int main() {
    constexpr ll mod = inf;
    ll n ,k;cin >> n >> k;
    if (k >= n - 1) k = n - 1;
    ll ans = 0;
    for (ll i = 0; i <= k; ++i) {
        ans += cm.comb(n, i) * cm.comb(n - 1, i) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

double dist(int xi, int xj, int yi, int yj){
	return sqrt(pow(xi-xj, 2) + pow(yi-yj, 2));
}

int main(void){

	int N; cin >> N;
	vector<int> x(N);
	vector<int> y(N);

	REP(i,N) cin >> x[i] >> y[i];
	vector<int> idx(N);
	REP(i,N) idx[i] = i;

	ll n = 1;
	REP(i,N) n *= (N-i);

	double ans = 0.0;
	do{
		double sum = 0.0;
		FOR(i,1,N){
			int pre = idx[i-1];
			int nxt = idx[i];
			sum += dist(x[pre], x[nxt], y[pre], y[nxt]);
		}
		ans += sum;
	}while(next_permutation(all(idx)));

	ans /= n;
	printf("%.10f\n", ans);

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1000000 + 5
#define inf 1000000000000000
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define Next(i, u) for(int i = h[u]; i; i = e[i].next)
typedef double D;
struct edge{
    int v, next; D w;
}e[N << 1];
struct node{
    int p; D w;
    bool operator < (const node &x) const{
        return w > x.w;
    }
};
bool book[N];
int n, s, t, xs, ys, xt, yt, tot, h[N], x[N], y[N], r[N];
D dis[N];
priority_queue <node> q;
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
void add(int u, int v, D w){
    if(w < 0) w = 0;
    e[++tot].v = v, e[tot].w = w, e[tot].next = h[u], h[u] = tot;
    e[++tot].v = u, e[tot].w = w, e[tot].next = h[v], h[v] = tot;
}
D dist(int x, int y, int xx, int yy){
    return sqrt(1ll * (x - xx) * (x - xx) + 1ll * (y - yy) * (y - yy));
}
int main(){
    xs = read(), ys = read(), xt = read(), yt = read();
    n = read(), s = 0, t = n + 1;
    add(s, t, dist(xs, ys, xt, yt));
    rep(i, 1, n){
        x[i] = read(), y[i] = read(), r[i] = read();
        add(s, i, dist(xs, ys, x[i], y[i]) - r[i]), add(i, t, dist(xt, yt, x[i], y[i]) - r[i]);
    }
    rep(i, 1, n) rep(j, i + 1, n) add(i, j, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]);
    q.push(node{s, 0}); rep(i, 1, t) dis[i] = inf;
    while(!q.empty()){
        int u = q.top().p; q.pop();
        if(book[u]) continue; book[u] = true;
        Next(i, u){
            int v = e[i].v; 
            if(dis[v] > dis[u] + e[i].w) dis[v] = dis[u] + e[i].w; q.push(node{v, dis[v]});
        }
    }
    printf("%.10lf", dis[t]);
    return 0;
}

Measured memory_bytes: 35308
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

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

	string ret;
	if(s[0]=='9' || s[1]=='9') ret = "Yes";
	else ret = "No";

	cout << ret << endl;
	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll A[N*3];
    ll i;
    for(i=0;i<N*3;i++){
        cin >> A[i];
    }
    sort(A,A+N*3);
    ll ans=0;
    for(i=1;i<N+1;i++){
        ans+=A[3*N-2*i];
    }
    cout << ans;
    return 0;
}

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

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

LL n;

int main()
{
	cin >> n;
	
	LL res = 1LL;
	for (LL i = 1LL; i <= (n - 1LL) / i; i ++ )
		if ((n - 1LL) % i == 0LL)
		{
			if (i > 1LL) res ++ ;
			if ((n - 1LL) / i != i) res ++ ;
		}
		
	for (LL i = 2LL; i <= n / i; i ++ )
		if (n % i == 0LL)
		{
			LL t = n;
			while (t % i == 0LL) t /= i;
			if (t % i == 1LL) res ++ ;
		}
		
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define repins(a,n) vector<string> a(n);rep(i,n){cin>>a[i];}
#define repind(a,n) vector<double> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 
#define all(x) (x).begin(),(x).end()
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)
#define range(i,s,c) for(ll i=(s);i<(s+c);++i)
using vell = vector<ll>;
using ves = vector<string>;
using ved = vector<double>;

ll mod = 1000000007;

ll mmul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod;}

ll mpow(ll a, ll b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll d = mpow(a, b / 2);
		return (d * d) % mod;
	}
	return (a * mpow(a, b - 1)) % mod;
}

ll mdiv(ll a, ll b) { return mmul(a, mpow(b, mod - 2)); }

int main()
{
	in(n);

	if(n%2==0){
		out(0.5);
	}else{
		out(ceil(n/2.0)/n);
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
int main(void)
{
  int n,a,b,c;
  
  scanf("%d",&n);
  
  a=n/100;
  b=(n-a*100)/10;
  c=n-a*100-b*10;
  
  if(c==2||c==4||c==5||c==7||c==9)
    printf("hon");
  if(c==0||c==1||c==6||c==8)
    printf("pon");
  if(c==3)
    printf("bon");
    
}

Measured memory_bytes: 1728
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    map<int,int> mp;
    REP(i,0,6){
        int tmp;
        cin>>tmp;
        mp[tmp]++;
    }
    bool ans=true;
    for(auto x : mp) if(x.second>=3) ans=false;
    YESNO(ans);
    
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


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

int n, v[2], tp, p;
long long a[2];

int main()
{
	cin>>n>>p;
	for(int i = 1; i <= n; i++)
	{
		cin>>tp;
		v[tp % 2]++;
	}
	a[0] = 1;
	while(v[1])
	{
		a[1] += a[0];
		a[0] = a[1];
		v[1]--;
	}
	while(v[0])
	{
		a[1] *= 2;
		a[0] *= 2;
		v[0]--;
	}
	cout<<a[p];
}


Measured memory_bytes: 256
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    c=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    c+=1
    print(c)


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

string pad(string s, int l){
    while(s.size() < l)s = "0"+s;
    return s;
}

int main(){
    string s;
    cin>>s;
    bool yymm = false, mmyy = false;
    FOR(y,0,100)FOR(m,1,12+1){
        string a = pad(to_string(y),2);
        string b = pad(to_string(m),2);
        if(s==a+b)yymm=true;
        if(s==b+a)mmyy=true;
    }
    if(yymm && mmyy)puts("AMBIGUOUS");
    else if(yymm)puts("YYMM");
    else if(mmyy)puts("MMYY");
    else puts("NA");
    return 0;
}


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

struct data {
  int p, bf;
  long long sum;
};

struct Unionfind {
  vector<int> par;
  vector<int> treerank;
  Unionfind(int n = 1) { stree(n + 1); }
  void stree(int n = 1) {
    par.assign(n, -1);
    treerank.assign(n, 0);
  }
  int root(int x) {
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] > treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) ++treerank[y];
    par[y] -= size(x);
    par[x] = y;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

long long n, m, sum = 0;
vector<long long> w, edge[100005], memo;
vector<bool> used, passed;
Unionfind uf;
queue<data> qu;

long long solve();
bool dfs(int now, int bf);

int main() {
  cin >> n >> m;
  w.resize(n);
  for(int i = 0; i < n; ++i) cin >> w[i];
  for(int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    edge[--x].push_back(--y);
    edge[y].push_back(x);
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  uf = Unionfind(n);
  sum = w[0];
  passed.assign(n, 0);
  used.assign(n, 0);
  dfs(0, -1);
  memo.assign(n, 0);
  for(int i = 0; i < n; ++i)
    if(uf.issame(i, 0)) {
      bool ch = 0;
      for(int j = 0; j < edge[i].size(); ++j)
        if(!uf.issame(0, edge[i][j])) {
          ch = 1;
          break;
        }
      if(ch) qu.push({i, -1, 0});
    }
  while(!qu.empty()) {
    data now = qu.front();
    qu.pop();
    if(memo[now.p] != now.sum) continue;
    for(int i = 0; i < edge[now.p].size(); ++i)
      if(edge[now.p][i] != now.bf &&
         !uf.issame(0, edge[now.p][i])) {
        data nextp = now;
        nextp.p = edge[now.p][i];
        nextp.bf = now.p;
        nextp.sum += w[nextp.p];
        ans = max(ans, nextp.sum);
        if(memo[nextp.p] < nextp.sum) {
          memo[nextp.p] = nextp.sum;
          qu.push(nextp);
        }
      }
  }

  return ans + sum;
}

bool dfs(int now, int bf) {
  if(used[now]) return 1;
  if(passed[now]) return 0;
  used[now] = 1;
  passed[now] = 1;
  bool ans = 0;
  for(int i = 0; i < edge[now].size(); ++i)
    if(bf != edge[now][i]) ans |= dfs(edge[now][i], now);
  used[now] = 0;
  if(ans) {
    uf.uni(0, now);
    if(now != 0) sum += w[now];
  }
  return ans;
}


Measured memory_bytes: 24816
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace AtcoderProblem
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = System.Console.ReadLine();
            var stArrayData = line.Split(' ');
            int N = int.Parse(stArrayData[0]);
            int X = int.Parse(stArrayData[1]);
            int T = int.Parse(stArrayData[2]);

            int Z = Convert.ToInt32(Math.Ceiling((double)N / X));
            int anser = Z * T;
            Console.WriteLine(anser);
        }         
    }
}


Measured memory_bytes: 27580
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

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

	VecP sl, sr;
	Vec se;
	ll sumL = 0, sumR = 0;
	rep(i, n){
		string s;
		cin >> s;
		ll l = 0, r = 0;
		rep(i, s.size()){
			if(s[i] == '(') l++;
			else r++;
		}

		sumL += l, sumR += r;
		ll max = 0;
		if(l >= r){
			l = 0, r = 0;
			rep(i, s.size()){
				if(s[i] == '(') l++;
				else r++;
				chmax(max, r - l);
			}
			if(l > r) sl.pb({max, l - r});
			else se.pb(max);
		}else if(r > l){
			l = 0, r = 0;
			repr(i, s.size()){
				if(s[i] == '(') l++;
				else r++;
				chmax(max, l - r);
			}
			sr.pb({max, r - l});
		}
	}
	sort(all(sl));
	sort(all(sr));
	sort(all(se));

	if(sumL != sumR){
		puts("No");
		return 0;
	}

	ll sum = 0;
	for(auto i : sl){
		if(sum < i.fs){
			puts("No");
			return 0;
		}
		sum += i.sc;
	}
	sum = 0;
	for(auto i : sr){
		if(sum < i.fs){
			puts("No");
			return 0;
		}
		sum += i.sc;
	}
	for(ll i : se){
		if(sum < i){
			puts("No");
			return 0;
		}
	}

	puts("Yes");
	return 0;
}


Measured memory_bytes: 19132
#include<stdio.h>

int gcd(int, int);
void swap(int, int);

int main()
{
  int x, y, n;

  scanf("%d %d", &x, &y);
  n = gcd(x, y);
  printf("%d\n", n);

  return 0;
}

int gcd(int x, int y)
{
  int r;
  
  if(x < y) swap(x, y);

  while(y >0){
    r = x % y;
    x = y;
    y = r;
  }

  return x;

}

void swap(int x, int y)
{
  int temp;

  temp = x;
  x = y;
  y = temp;

}

Measured memory_bytes: 592
#142b
N,K = map(int, input().split()) #K<=100
h_list = list(map(int, input().split()))

#高橋君の仲間たちは N人で遊園地に遊びにいきました。
#遊園地の一番人気のジェットコースターに乗るためには、身長が K cm以上必要です。
#高橋君の i番目の仲間の身長は hi cm です。
#高橋君の仲間たちのうち、一番人気のジェットコースターに乗ることができる人の数を求めてください。

OK_h_list = [h_list[i] for i in range(N) if h_list[i]>=K]
print(len(OK_h_list))

Measured memory_bytes: 11912
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> dp(n + 2);
  for (auto idx(0); idx < m; ++idx) {
    cin >> a[idx];
  }
  dp[n] = 1;
  for (auto idx(n - 1); idx >= 0; --idx) {
    dp[idx] = (dp[idx + 2] + dp[idx + 1]) % 1000000007;
    if (a.size() != 0 && a.back() == idx) {
      dp[idx] = 0;
      a.pop_back();
    }
  }
  cout << dp[0] % 1000000007 << endl;
  
  
return 0;}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  string s;
  cin>>s;
  vector<int>a(26);
  rep(i,s.size()){
    a[s[i]-'a']++;
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int cnt=0;
  rep(i,a.size()){
    if(a[i]==1)cnt++;
  }
  if(cnt==s.size())cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    string s; cin >> s;
    if (s[a] != '-') {cout << "No" << endl; return 0;}
    rep(i, a + b + 1) {
        if (i == a) continue;
        if (s[i] < '0' || s[i] > '9') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()-1
  let ar=tnn(n),ans=0;
  ans=ar[0]+ar[n-1]
  for(let i=1;i<n;i++){
    ans+=min(ar[i-1],ar[i])
  }
  to(ans)
}
main()


Measured memory_bytes: 7372
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
import collections
import sys

BIGINT = int(1e9) + 7

def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

S = input().strip()

slots = [0] * 13
slots[0] = 1

for p, c in enumerate(reversed(S)):
    xx = pow(10, p, 13)
    new_slots = [0] * 13
    if c == "?":
        for i in range(10):
            for k in range(13):
                idx = (i * xx + k) % 13
                new_slots[idx] = (new_slots[idx] + slots[k]) % BIGINT
    else:
        n = int(c)
        for k in range(13):
            new_slots[(n * xx + k) % 13] = slots[k]
    slots = new_slots

print(slots[5])

Measured memory_bytes: 43372
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> p = new ArrayList<Integer>();
		BigInteger to = new BigInteger("102000");

		for(BigInteger x = BigInteger.ONE;x.compareTo(to)<0;){
			x = x.nextProbablePrime();
			p.add(Integer.parseInt(x.toString()));
		}

		while(true){
			String[] s = br.readLine().split(" ");
			int n = Integer.parseInt(s[0]);
			int m = Integer.parseInt(s[1]);
			if(n == -1 && m == -1) break;

			int start = 0;
			for(;p.get(start)<=n;start++);

			ArrayList<Integer> sum = new ArrayList<Integer>();
			int size = start + m;
			for(int i=start;i<size;i++){
				for(int j=i;j<size;j++){
					sum.add(p.get(i) + p.get(j));
				}
			}
			Collections.sort(sum);
			System.out.println(sum.get(m-1));
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    ll l, r;
    cin >> l >> r;
    r = min(r, l+2019);

    vector<int> cand;
    for (int i = l; i <= r; ++i) {
        cand.push_back(i % 2019);
    }

    int ans = 1e9;
    for (int i = 0; i < cand.size(); ++i) {
        for (int j = i+1; j < cand.size(); ++j) {
            ans = min(ans, (cand[i]*cand[j]) % 2019);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// ABC 154-D
// 2020.2.9 bal4u

#include <stdio.h>

typedef long long ll;

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int s[200005];

int main()
{
	int i, K, N, ans;
	
	N = in(), K = in();
	for (i = 1; i <= N; ++i) s[i] = s[i-1] + (in()+1);

	ans = 0;
	for (i = K; i <= N; ++i) {
		if (s[i]-s[i-K] > ans) ans = s[i]-s[i-K];
	}
	printf("%.10lf\n", 0.5*ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,k;
	int ans=1;
	cin >>n>>k;
	rep(i, n) { ans += min(k, ans); }
	cout<<ans<<endl;
}

Measured memory_bytes: 3604
N = int(input())
HN = input().split()

def build_stairs(N=N, HN=HN):
    if N == 1:
        return "Yes"
    for n in range(N-1):
        if HN[n] - HN[n+1] > 1:
            return "No"
        elif HN[n] - HN[n+1] == 1:
            HN[n+1] += 1
        if HN[n] < HN[n+1]:
            continue
    return "Yes"

HN = [int(i) for i in HN]
ans = build_stairs(N, HN)
print(ans)
print("")

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD 998244353


ll N,M;
ll a[333][333];
ll dp1[333][333][2],dp2[333][333][2],dp3[333][333][2];
ll i,j,k,l,ans;
inline void addd(ll aa,ll bb){
    if(aa==bb)
        return;
    ll i;
    fornum(i,0,M){
        a[aa][i] = (a[aa][i] + a[bb][i]) % 2;
    }
}
int main(){
    scanf("%lld%lld", &N, &M);
    fornum(i,0,N){
        fornum(j,0,M){
            scanf("%lld", &a[i][j]);
        }
    }
    k = 0;
    fornum(i,0,M){
        fornum(j,k,N){
            if(a[j][i]){
                addd(k, j);
                break;
            }
        }
        //printf("%lld,%lld,%lld\n", i, j, k);
        if(j==N)
            continue;
        fornum(j,k+1,N){
            if(a[j][i]){
                addd(j, k);
            }
        }
        k++;
        
    }
    j = 1;
    fornum(i,1,N+M-k){
        j = (j * 2) % MOD;
    }
    //printf("%lld\n", j);
    ans = 1;
    fornum(i,1,N+M){
        ans = (ans * 2) % MOD;
    }
    //printf("%lld\n", ans);
    ans = (ans + MOD - j) % MOD;

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;

  if(abs(a-b) <= d && abs(b-c) <= d || abs(a-c) <= d){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
    char S;
    cin >> S;

    if(S == 'a' || S == 'e' || S == 'i' || S == 'o' || S == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;

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

//container util
//------------------------------------------
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define PRINT(V)     \
  for (auto v : (V)) \
  cout << v << " "
#define PRINTL(V)    \
  for (auto v : (V)) \
  cout << v << endl
#define SORT(V) sort((V).begin(), (V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//最大公約数
//------------------------------------------
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

//grobal variable
//------------------------------------------
int N, M;
VI Vec;

//main
//------------------------------------------
signed main()
{
  int d,n,k,v,c=0;
  cin >> n >> k;
  VI a(n,0);
  int b;
  for (int i = 0; i < k; i++)
  {
    cin >> d;
    for (int j = 0; j < d; j++)
    {
      cin >> v;
      a[v-1] = 1;
    }
  }
  for (auto &e : a){
    if(e==0){
      c++;
    }
  }
  cout << c;
}

Measured memory_bytes: 3584
N = int(input())
A = input()
B = input()
C = input()

ans = 0

for i in range(N):
    a = A[i]
    b = B[i]
    c = C[i]

    s = set()
    s.add(a)
    s.add(b)
    s.add(c)

    ans += (len(s) - 1)

print(ans)

Measured memory_bytes: 3064