akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			if ((n | k) == 0)
				break;
			boolean[] b = new boolean[n + 1];
			int[][] a = new int[n + 1][2];
			for (int i = 0; i < k; i++)
				b[scanner.nextInt()] = true;
			int m0 = 0;
			int m1 = 0;
			for (int i = 1; i <= n; i++) {
				a[i][0] = b[i] ? a[i - 1][0] + 1 : 0;
				a[i][1] = b[i] ? a[i - 1][1] + 1 : a[i - 1][0] + 1;
				m0 = Math.max(m0, a[i][0]);
				m1 = Math.max(m1, a[i][1]);
			}
			System.out.println(b[0] ? m1 : m0);
		}
	}
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int r;
    cin >> r;
    cout << fixed << setprecision(15) << PI*2*r << "\n";
    return 0;
}



Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const ll INF = 1LL<<61;

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  sort(a.begin(), a.end());

  ll left = -INF, right = INF;
  while (right - left > 1){
    ll mid = (right + left) / 2;
    ll S = 0, T = 0;
    for (int i = 0; i < N; ++i){
      if (a[i] > 0){
        ll left2 = -1, right2 = N;
        while (right2 - left2 > 1){
          ll mid2 = (right2 + left2) / 2;
          if (a[i] * a[mid2] <= mid) left2 = mid2;
          else right2 = mid2;
        }
        S += right2;
      }
      else if (a[i] < 0){
        ll left2 = -1, right2 = N;
        while (right2 - left2 > 1){
          ll mid2 = (right2 + left2) / 2;
          if (a[i] * a[mid2] <= mid) right2 = mid2;
          else left2 = mid2;
        }
        S += N - right2;
      }
      else if (mid >= 0) S += N;
      if (a[i] * a[i] <= mid) ++T;
    }
    ll num = (S - T) / 2;
    if (num >= K) right = mid;
    else left = mid;
  }
  cout << right << endl;
}


Measured memory_bytes: 1792
import sys
import math

f = sys.stdin
n = int(f.readline().split()[0])
A = list(map(int, f.readline().split()[:n]))
sumA = sum(A)
minA = min(A)
A.sort()
q = int(f.readline().split()[0])
M = list(map(int, f.readline().split()[:q]))


def check(p, t):
    global A, sumA, minA
    if t == 0:
        return True
    if minA > t or sumA < t:
        return False
    elif t < 0 or p > len(A) - 1:
        return False
    if check(p + 1, t - A[p]):
        return True
    return check(p + 1, t)


for ele in M:
    if minA == ele or sumA == ele:
        print("yes")
    elif check(0, ele):
        print("yes")
    else:
        print("no")






Measured memory_bytes: 5680
import itertools
N, M, Q = map(int, input().split())
abcd = [ list(map(int, input().split())) for _ in range(Q) ]

res = 0
for product in itertools.combinations_with_replacement(range(1, M+1), N):
  S = 0
  for a,b,c,d in abcd:
    if product[b-1] - product[a-1] == c:
      S += d
  res = max(res, S)

print(res)



Measured memory_bytes: 67852
(
  stdin.ReadLine() |> int,
  stdin.ReadLine(),
  stdin.ReadLine()
)
|> fun (n, ps, qs) ->
  [1..n]
  |> fun list ->
    list
    |> List.tail
    |> List.fold (
      fun acc i ->
        acc
        |> List.collect (
          fun cs ->
            list
            |> List.except cs
            |> List.map (fun x -> cs @ [x])
        )
    ) (list |> List.map (fun x -> [x]))
    |> List.mapi (
      fun i order ->
        (
          i,
          order
          |> List.map string
          |> List.reduce (fun a b -> a + " " + b)
        )
    )
    |> fun dict ->
      (
        (dict |> List.find (fun (_, v) -> v = ps) |> fun (i, _) -> i),
        (dict |> List.find (fun (_, v) -> v = qs) |> fun (i, _) -> i)
      )
|> fun (a, b) -> (a - b) |> abs
|> printfn "%d"

// [1; 2; 3]
// [
//   [1]
//   [2] 
//   [3]
// ]
// [
//   [1; 2]
//   [1; 3]
//   [2; 1]
//   [2; 3]
//   [3; 1]
//   [3; 2]
// ]
// [
//   [1; 2; 3]
//   [1; 3; 2]
//   [2; 1; 3]
//   [2; 3; 2]
//   [3; 1; 2]
//   [3; 2; 1]
// ]


Measured memory_bytes: 46744
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    char c;
    string a = "23456789TJQKA";
    while(cin >> c, c != '#'){
        array<array<string, 4>, 13> ss{};
        array<array<int, 4>, 13> sc{};
        for (int j = 0; j < 4; ++j) {
            for (int i = 0; i < 13; ++i) {
                string s;
                cin >> s;
                ss[i][j] = s;
                for (int k = 0; k < a.size(); ++k) {
                    if(s[0] == a[k]) sc[i][j] =  k;
                }
                if(s[1] == c) sc[i][j] += 150;
            }
        }
        int winner = 0;
        int p = 0, q = 0;
        for (int i = 0; i < 13; ++i) {
            for (int j = 0; j < 4; ++j) {
                if(ss[i][winner][1] == ss[i][j][1]) sc[i][j] += 15;
            }
            int yy = max_element(sc[i].begin(),sc[i].end())-sc[i].begin();
            if(yy&1) p++;
            else q++;
            winner = yy;
        }
        if(p > q){
            printf("EW %d\n", p-6);
        }else {
            printf("NS %d\n", q-6);
        }
    }
    return 0;
}


Measured memory_bytes: 3084
K = int(input())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[K - 1])

Measured memory_bytes: 3060
# -*- coding:utf-8 -*-
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(set(a))
c = Counter(a)
d = sorted(c.items(), key = lambda tmp: tmp[1])
ans = 0
if len(b) > k:
    e = len(b)
    for tmp in range(len(d)):
        if e == k:
            print(ans)
            break
        else:
            ans += (d[tmp])[1]
            e -= 1
else:
    print(ans)

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  int dif = 2147483647;
  for(int i = K-1; i < N; i++){
    if(h.at(i) - h.at(i-K+1) < dif) dif = h.at(i) - h.at(i-K+1);
  }
  cout << dif << endl;
}

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

int main()
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << fixed << setprecision(15) << W * H / 2.0;
    cout << " " << ((x + x) == W && (y + y) == H) << endl;

    return 0;
}

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

int main()
{
	int a[3], k;
	scanf("%d%d%d%d", &a[0], &a[1], &a[2], &k);
	int max = 0, add = 0;
	for (int i = 0; i < 3; ++i)
		if (max < a[i])
		{
			add += max;
			max = a[i];
		}
		else
			add += a[i];
	add += max*pow(2, k);
	printf("%d\n", add);
	return 0;
}


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

int N;
vector<int> G[10101];
bool vis[10101];
vector<int> ans;

void bfs(int n) {
  vis[n] = true;
  queue<int> q;
  q.push(n);
  ans.push_back(n);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto y : G[x]) {
      if (vis[y]) continue;

      vis[y] = true;
      q.push(y);
      ans.push_back(y);
    }
  }
}

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

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

  sort(c.begin(), c.end(), greater<int>());

  bfs(0);

  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    mp[ans[i]] = c[i];
  }

  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    for (auto x : G[i]) {
      if (x < i) continue;
      sum += min(mp[i], mp[x]);
    }
  }

  cout << sum << endl;

  for (int i = 0; i < N; i++) {
    if (i != 0) cout << " ";
    cout << mp[i];
  }
  cout << endl;

  return 0;
}


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

using namespace std;
int slv(string s,string t){
    int ret=0;
    for(int i=0;i<s.size();i++)
        ret+=(s[i]!=t[i]);

    return ret;
}
int main()
{
    ///{}
    int n;
    long long rm=1e9+7;
    cin>>n;
    vector<long long>v(n),acu(n+1);
    for(int i=0;i<n;i++){
        cin>>v[i];
        acu[i+1]=acu[i]+v[i];
        acu[i+1]%=rm;
    }
    long long ans=0ll;
    for(int i=0;i<n;i++){
        ans+=(v[i]*((((acu[n]-acu[i+1])%rm)+rm)%rm))%rm;
        ans%=rm;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 6404
n = int(input())
blue =[input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
 
maxyen = 0

for i in blue:
  bc  = blue.count(i)
  rc = red.count(i)
  if bc-rc>maxyen:
    maxyen = bc-rc
 
print(maxyen)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    s += s;
    for (int i = 0; i < s.size(); i++) {
        if (s.substr(i, t.size()) == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
double pi = 3.141592653589793;
int main(){
  cout << fixed << setprecision(18);
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double ka=abs(6.0*m-(30.0*h+0.5*m));
  ka*=pi/180.0;
  if(a<b) swap(a,b);
  a-=cos(ka)*b;
  b*=sin(ka);
  COUT(sqrt(a*a+b*b));
}

Measured memory_bytes: 4084
#include<stdio.h>

int main(void)
{
	int i, j, a;
	for(i=1; i<=9; i++)
	{
		for(j=1; j<=9; j++)
		{
			a=i*j;
			printf("%dx%d=%d\n", i, j, a);
		}
	}
	
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=3e5+5;

vector<int> v[maxn];
int cnt[maxn];

class element
{
	public:
		int l,r;
		int plus,val;
};

class Tree
{
	public:
		element tree[maxn<<2];
		void build(int id,int l,int r)
		{
			tree[id].l=l;
			tree[id].r=r;
			tree[id].plus=0;
			if(l==r)
			{
				tree[id].val=cnt[l];
				return ;
			}
			int mid=(l+r)/2;
			build(id*2,l,mid);
			build(id*2+1,mid+1,r);
			tree[id].val=max(tree[id*2].val,tree[id*2+1].val);
		}
		void add(int id,int l,int r,ll num)
		{
			if(tree[id].l>=l&&tree[id].r<=r)
			{
				tree[id].plus+=num;
				tree[id].val+=num;
				return ;
			}
			if(tree[id].l>r||tree[id].r<l) return ;
			push_down(id);
			if(tree[id*2].r>=l) add(id*2,l,r,num);
			if(tree[id*2+1].l<=r) add(id*2+1,l,r,num);
			tree[id].val=max(tree[id*2].val,tree[id*2+1].val);
		}
		void push_down(int id)
		{
			if(tree[id].l!=tree[id].r)
				rept(j,id*2,id*2+1)
				{
					tree[j].val+=tree[id].plus;
					tree[j].plus+=tree[id].plus;
				}
			tree[id].plus=0;
		}
		ll query(int id,int l,int r)
		{
			if(tree[id].l>=l&&tree[id].r<=r) return tree[id].val;
			if(tree[id].l>r||tree[id].r<l) return -inf;
			push_down(id);
			return max(query(id*2,l,r),query(id*2+1,l,r));
		}
} t;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,k;
	cin>>n>>m>>k;
	rep(i,0,k)
	{
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		cnt[y]++;
	}
	t.build(1,1,m);
	int ans=0;
	rept(i,1,n)
	{
		rep(j,0,v[i].size()) t.add(1,v[i][j],v[i][j],-1);
		ans=max(ans,t.tree[1].val+(int)v[i].size());
		rep(j,0,v[i].size()) t.add(1,v[i][j],v[i][j],1);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 37636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
int n,L,a[MAX];
int main()
{
    n=read();L=read();
    for(int i=1;i<=n;++i)a[i]=read();
    bool fl=false;int pos;
    for(int i=1;i<n;++i)if(a[i]+a[i+1]>=L)fl=true,pos=i;
    if(!fl){puts("Impossible");return 0;}
    puts("Possible");
    for(int i=1;i<pos;++i)printf("%d\n",i);
    for(int i=n-1;i>pos;--i)printf("%d\n",i);
    printf("%d\n",pos);
    return 0;
}

Measured memory_bytes: 1152
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,M,H2,M2,K=MI()
    B = H2*60 + M2
    A = H*60+M
    print(max(0, B-K-A))
if __name__ == '__main__':
    main()

Measured memory_bytes: 78068
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data1 = scanner.nextLine();
			String data2 = scanner.nextLine();

			String[] data1Array = data1.split(" ");

			int seisu = Integer.parseInt(data1Array[0]);
			int length = Integer.parseInt(data1Array[1]);

			if (length == 0) {
				System.out.println(seisu);
				return;
			}

			String[] data2Array = data2.split(" ");
			int[] arr = Stream.of(data2Array).mapToInt(Integer::parseInt).toArray();
			List<Integer> list = new ArrayList<Integer>();
			for (int num : arr) {
				list.add(num);
			}

			Map<Integer, Integer> m = new LinkedHashMap<Integer, Integer>();
			for (int i = 0; i < 102; ++i) {
				if (list.contains(i)) {
					m.put(i, 1);
				} else {
					m.put(i, 0);
				}
			}

			int ans = 9999;
			int num = 0;
			for (int i = 0; i < 102; ++i) {
				if (m.get(i) == 1) {
					continue;
				}

				int dif = Math.abs(seisu - i);
				if (ans > dif) {
					ans = dif;
					num = i;
				}
			}
			System.out.println(num);

		}
	}
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 1e5;
int n, m, a[MAXN + 5];
LL ans;
struct Node {
	int b, c;
	
	inline friend bool operator<(Node x, Node y) {
		return x.c == y.c ? x.b > y.b : x.c > y.c;
	}
} p[MAXN + 5];

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) read(a[i]);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= m; ++i) read(p[i].b), read(p[i].c);
	sort(p + 1, p + m + 1);
	for (int j = 1, i = 1; i <= m; ++i)
		for (; j <= n && p[i].b && p[i].c > a[j]; --p[i].b, ++j)
			a[j] = p[i].c;
	for (int i = 1; i <= n; ++i) ans += a[i];
	write(ans);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
 
int main(){
	int A, B, C;
 
	scanf("%d %d %d", &A, &B, &C);
 
	if(A < C && C < B) {
		printf("Yes");
	}

	else if(A == B && B == C) {
			printf("Yes");
	}

	else {
		printf("No");
	}

 
}

Measured memory_bytes: 128
from math import *
from collections import *
from itertools import *
from bisect import *
def io():
    return map(int,input().split())
def op():
    return list(map(int,input().split()))
def kl(con,x=0):
    if x==0:print('Yes') if con else print('No')
    elif x==1:print('yes') if con else print('no')
    elif x==2:print('YES') if con else print('NO')
MOD = 1000000007
MAX=2147483647
MIN=-2147483648
p=input
# for _ in range(int(p())):
s=p()
s1=p()
kl(s1[:-1]==s)



Measured memory_bytes: 65328
N = input()
W = list(map(int,input().split()))
l = W[0]
r = W[-1]
lcount = 1
rcount = -2
for i in range(len(W)-2):
    if l >= r:
        r += W[rcount]
        rcount -= 1
    else:
        l += W[lcount]
        lcount += 1

print(abs(l-r))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// // 整数の入力
		// int a = sc.nextInt();
		// // スペース区切りの整数の入力
		// int b = sc.nextInt();
		// int c = sc.nextInt();
		// // 文字列の入力
		// String s = sc.next();
		// // 出力
    // System.out.println((a+b+c) + " " + s);
    String s = sc.next();
    int ans = 0;
    for (char c : s.toCharArray()) {
      if (c == '1') ans++;
    }
    System.out.println(ans);
	}
}

Measured memory_bytes: 21588
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int n;
    cin >> n;
    map<int, int> m;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        m[x]++;
    }
    vll a;
    for (auto it = m.rbegin(); it != m.rend(); ++it) {
        int x = (*it).se;
        while (x > 1) {
            a.pb((*it).fi);
            x -= 2;
            if (a.size() == 2) break;
        }
        if (a.size() == 2) break;
    }
    if (a.size() == 2) cout << a[0] * a[1];
    else cout << 0;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 4992
// D - Xor Sum 2
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vector<int> A(N); rp(i, 0, N) cin>>A[i];
	long long ans = 0;
	int r = 0, a = 0;
	rp(l, 0, N){//しゃくとり法
		while(r < N && !(a & A[r])){ a += A[r]; r++; }
		ans += r - l;
		if(r == l) r++; else a -= A[l];
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <deque>
#include <cstring>
using namespace std;
char s[200] , sl[800];
int main() {
    int n;
    cin >> n;
    cin >> s;
    int count = 0;
    for(int i = n - 1 ; i >= 0 ; i--) {
        if(s[i] == ')') {
            count++;
        }
        else {
            count--;
            count = max(0 , count);
        }
    }
    for(int i = 0 ; i < count ; i++) {
        sl[i] = '(';
    }
    for(int i = count ; i < count + n ; i++) {
        sl[i] = s[i - count];
    }
    int m = count + n;
    count = 0;
    for(int i = 0 ; i < m ; i++) {
        if(sl[i] == '(') {
            count++;
        }
        else {
            count--;
            count = max(0 , count);
        }
    }
    for(int i = m ; i < m + count ; i++) {
        sl[i] = ')';
    }
    cout << sl << endl;
    return 0;
}

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

struct StCoord
{
  StCoord() : m_nx(0), m_ny(0), m_nHigh(0) { }

  int m_nx;
  int m_ny;
  int m_nHigh;
};

void input(vector<StCoord>& rvoCoord)
{
  int nCoordSiz;
  cin >> nCoordSiz;
  rvoCoord.resize(nCoordSiz);

  for (StCoord& roCoord : rvoCoord)
    cin >> roCoord.m_nx >> roCoord.m_ny >> roCoord.m_nHigh;
}

int calcCenterHigh(StCoord oCenter, StCoord oCoord)
{
  return  abs(oCenter.m_nx - oCoord.m_nx) 
        + abs(oCenter.m_ny - oCoord.m_ny) + oCoord.m_nHigh;
}

bool isCenter(StCoord& roCenter, const vector<StCoord>& cnrvoCoord)
{
  int nCenterHigh = 0;

  for (int i = 0; i < cnrvoCoord.size(); ++i)
    if ( cnrvoCoord[i].m_nHigh )
      if ( !nCenterHigh )
        nCenterHigh = calcCenterHigh(roCenter, cnrvoCoord[i]);
      else
        if (nCenterHigh != calcCenterHigh(roCenter, cnrvoCoord[i]))
          return false;

  for (int i = 0; i < cnrvoCoord.size(); ++i)
    if ( !cnrvoCoord[i].m_nHigh )
      if (nCenterHigh <= calcCenterHigh(roCenter, cnrvoCoord[i]));
      else
        return false;

  roCenter.m_nHigh = nCenterHigh;
  return true;
}

void calcCenterCoord(const vector<StCoord>& cnrvoCoord)
{
  StCoord oCenter;
  bool bCenter = false;
  oCenter.m_nx = -1;

  while ( !bCenter       &&
          oCenter.m_nx < 100 )
  {
    ++oCenter.m_nx;
    oCenter.m_ny = -1;

    while ( !bCenter       &&
            oCenter.m_ny < 100 )
    {
      ++oCenter.m_ny;
      bCenter = isCenter(oCenter, cnrvoCoord);
    }
  }
  if ( bCenter )  
    cout << oCenter.m_nx << " " << oCenter.m_ny << " " << oCenter.m_nHigh;
}
  
int main()
{
  vector<StCoord> voCoord;
  
  input(voCoord);
  calcCenterCoord(voCoord);

  return 0;
}

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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<n;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>

class AAC {
public:
	void solve(std::istream& in, std::ostream& out) {
        std::string s;
        in>>s;
        if(s=="ABC") out<<"ARC";
        else out<<"ABC";
	}
};


int main() {
	AAC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3624
m=0
n=int(input())
kushi= list(map(int,input().split()))
kushi.sort()

if len(kushi) %2==1:
	del kushi[-1]

for i in range(0,len(kushi)-1,2):
	if kushi[i]>kushi[i+1]:
		m+=kushi[i+1]
	else:
		m+=kushi[i]
print(m)

Measured memory_bytes: 7396
#include <bits/stdc++.h>
#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(void){
  int a,b,c,d; cin >> a >> b >> c >> d;
  int x1,x2;
  if(c%b != 0) x1 = c/b + 1;
  else x1 = c/b;
  if(a%d != 0) x2 = a/d + 1;
  else x2 = a/d;
  if(x1 <= x2) cout << "Yes" <<endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  int t,x,y;
}T;

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<T> v(N+1);
  v[0] = {0,0,0};
  rep(i,N) cin >> v[i+1].t >> v[i+1].x >> v[i+1].y;
  bool canVisit = true;
  rep(i,N){
    int t = v[i+1].t - v[i].t;
    int absx = abs(v[i+1].x - v[i].x);
    int absy = abs(v[i+1].y - v[i].y);
    if(t < absx + absy) canVisit = false;
    if((t&1) != ((absx+absy)&1) ) canVisit = false;
    if(!canVisit)break;
  }
  YesNo(canVisit);
  return 0;
}


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

#define ii pair<int, int>
#define vi vector<int>
#define LL long long int 
#define VLL vector<LL>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define INF int(1e9)

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    string s,t ;
    cin >> s >> t;
    cout << t+s << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

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

using namespace std;

int a,b,n;

main()
{
        cin>>n;

        vi s(n),p(n),q(n);
        each(&it,p)cin>>it;
        each(&it,q)cin>>it;

        do{
            a++;
        }while(prev_permutation(All(p)));

        do{
            b++;
        }while(prev_permutation(All(q)));

        cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
fn main() {
    let (n, m) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        let mut iter = line.trim().split_whitespace().map(|e| e.parse::<usize>().unwrap());
        (iter.next().unwrap(), iter.next().unwrap())
    };

    let mut a: std::collections::HashSet<usize> = std::collections::HashSet::new();
    for _ in 0..m {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        a.insert(line.trim().parse().unwrap());
    }

    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    for i in 0..(n + 1) {
        if i + 1 <= n && !a.contains(&(i + 1)) {
            dp[i + 1] = (dp[i + 1] + dp[i]) % 1000000007;
        }
        
        if i + 2 <= n && !a.contains(&(i + 2)) {
            dp[i + 2] = (dp[i + 2] + dp[i]) % 1000000007;
        }
    }

    println!("{}", dp[n]);
}


Measured memory_bytes: 8444
n = int(input())
arr = [0] + list(map(int, input().split()))
cnt = 0
ans = float('inf')
for sign in [-1, 1]:
    res = 0
    partial_sum = 0
    A = [x for x in arr]
    for i in range(n):
        partial_sum += A[i]
        diff = sign - (partial_sum + A[i+1]                )
        if sign < 0:
            diff = min(diff, 0)
        else:
            diff = max(diff, 0)
        res += abs(diff)
        A[i+1] += diff
        sign *= -1
    ans = min(ans, res)
print(ans)


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b,c,i,j,k,x,ans=0;
	int kari;

	cin >> a >> b >> c >> x;
	
	for (i = 0; i <= a; i++) {
		if (i * 500 <= x) {
			for (j = 0; j <= b; j++) {
				if (i * 500 + j * 100 <= x) {
					for (k = 0; k <= c; k++) {
						kari = i * 500 + j * 100 + k * 50;
						if (kari == x)ans++;
					}
				
				}
			
			}
		
		}
	
	}
	
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];

    int ans = 0;
    int best = 100000000;
    for (int x = 1; x <= 100; ++x) {
        int s = 0;
        rep(i, N) s += (X[i]-x)*(X[i]-x);
        if (s < best) {
            ans = x;
            best = s;
        }
    }

    cout << best << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int hour, minute, second;
int input_sec, output_time[2];

int main() {
	scanf("%d", &input_sec);
	if (0 <= input_sec < 86400) {
		int i = 0;
		int temp = input_sec;
		while (i <= 2) {
			output_time[i] = temp % 60;
			temp = (temp - output_time[i]) / 60;
			i++;
		}
		second = output_time[0];
		minute = output_time[1];
		hour = output_time[2];

		printf("%d:%d:%d\n", hour, minute, second);
	}
}


Measured memory_bytes: 2140
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
    string a;
    int b;
    int y;
} m[10005];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>m[i].a>>m[i].b;
        m[i].y=i;
    }
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            if(m[j].a<m[i].a)
            {
                node h;
                h=m[j];
                m[j]=m[i];
                m[i]=h;
            }
            if(m[j].a==m[i].a)
            {
                if(m[j].b>m[i].b)
                {
                    node h;
                    h=m[j];
                    m[j]=m[i];
                    m[i]=h;
                }
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        cout<<m[i].y+1<<endl;
    }
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int a,b;
	int c,d,e,max;
	scanf("%d%d",&a,&b);
	c=a+b;
	d=a-b;
	e=a*b;
	if(c>=d&&c>=e)
	{
		max=c;
	}
	if(d>=c&&d>=e)
	{
		max=d;
	}
	if(e>=c&&e>=d)
	{
		max=e;
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;


class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n =  sc.nextInt();
        int[] arr = new int[n];
        int ct = 0; int idx;
        for(int i = 0; i<n;i++) 
        {
            arr[i] = sc.nextInt();
        }
        
        for(int i = 0; i<n;i++)
        {
            idx = 0;
            int min = arr[i];
            for(int j = i+1 ;j<n;j++)
            {
                if(min>arr[j])
                {
                    min = arr[j];
                    idx = j;
                } 
            }
            if(min !=arr[i])
            {
                ct++;
                int temp = arr[i];
                arr[i] = min;
                arr[idx] = temp;
            }
        }
          for(int i = 0; i<n;i++) 
          {
              if(i==n-1) 
              {
                  System.out.println(arr[i]); break;
              }
              
              System.out.printf("%d ", arr[i]);
          }
          System.out.println(ct);
    }
}
       





Measured memory_bytes: 26580
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll a[200009], p[200009], l[200009], lm[200009], r[200009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);	
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] == 0) p[i] = 2;
		else p[i] = a[i] % 2;
	}
	ll s = 0;
	for (int i = 1; i <= n; i++) {
		s += a[i];
		l[i] = min(l[i - 1] + p[i], s);
	}
	s = 0;
	for (int i = n; i >= 1; i--) {
		s += a[i];
		r[i] = min(r[i + 1] + p[i], s);
	}
	s = 0;
	for (int i = 0; i <= n + 1; i++) {
		if (1 <= i && i <= n && p[i] != 1) s++;
		l[i] -= s; r[i + 1] += s;
	}
	lm[0] = l[0];
	for (int i = 1; i <= n; i++)
		lm[i] = min(lm[i - 1], l[i]);
	ll ans = lm[0] + r[1];
	for (int i = 1; i <= n + 1; i++)
		ans = min(ans, lm[i - 1] + r[i]);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 8064
from collections import defaultdict
N, W = map(int, input().split())
dd = defaultdict(int)
dd[0] = 0
for i in range(N):
    w, v = map(int, input().split())
    ddOld = dd.copy()
    ddOld2 = dd.copy()
    for dk, dv in ddOld.items():
        dd[dk+w] = max(ddOld2[dk+w], dv+v)
ans = 0
for dk, dv in dd.items():
    if dk <= W:
        ans = max(ans, dv)
print(ans)


Measured memory_bytes: 5600
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

ss=max(a,b,c,d,e)-min(a,b,c,d,e)
if ss>k:
  print(":(")
else:
  print("Yay!")
  

Measured memory_bytes: 3060
/*版权所有，拷贝必究！*/
/*若想获得，请联系许希泉*/
#include<bits/stdc++.h>
#pragma GCC optimize("O999")
const int INF = 0x3f3f3f3f;
int maxn=5000005;
using namespace std;
struct node{

};
bool is_pal(string a)
{
    string s=a;
    reverse(s.begin(),s.end());
    if(s==a)
    return true;
    else
    return false;
}
bool is_prime(int n)
{
    if(n==1)
	return false;
    if(n==2||n==3)
	return true;
    if(n%6!=1&&n%6!=5)
	return false;
    for(register int i=5;i*i<=n;i+=6)
    if(n%i==0||n%(i+2)==0)
	return false;
    return true;
}
int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	string s1,s2,s;
    int n,m,x,y,p,mut=1,sum=0,maxv=0,minv=1E5;
    cin>>s1;
    
    if(s1[s1.size()-1]=='s') 
    {
    	cout<<s1<<"es";
	}
    else
    cout<<s1<<"s";
    return 0;
}


Measured memory_bytes: 3668
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))

A.sort()
B.sort()
C.sort()
C.reverse()

ab=[0]*N
count=0

for i in range(N):
    while count<N and A[count]<B[i]:
        count+=1
    ab[i]=count

count=0
ans=0
bc=[0]*N

for i in range(N-1,-1,-1):
    while count<N and C[count]>B[i]:
        count+=1
    #bc[i]=count
    ans+=count*ab[i]

print(ans)

Measured memory_bytes: 22720
void main(){
	int a, p;
	readf("%d %d", &a, &p);
	p += a*3;
	writeln(p/2);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2736
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef long long i64;
typedef unsigned long long u64;
const i64 mod = 1e9 + 7;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

u64 modpow(u64 x, u64 k) {
	u64 y = 1;
	for(int i = 0; i < 64; i++) {
		if((k >> i) & 1) {
			y = y * x % mod;
		}
		x = x * x % mod;
	}
	return y;
}

int main() {

	const int n = read_item();
	const int k = read_item();

	const i64 nm = n + 10;
	vector<i64> fact(nm + 1), factinv(nm + 1);
	fact[0] = 1;
	fact[1] = 1;
	for(auto i : range(2, nm + 1)) {
		fact[i] = fact[i - 1] * i % mod;
	}
	factinv[0] = 1;
	factinv[1] = 1;
	for(auto i : range(2, nm + 1)) {
		factinv[i] = modpow(fact[i], mod - 2);
	}

	auto choose = [&](i64 a, i64 b) {
		assert(a >= b && a >= 0 && b >= 0);
		return fact[a] * factinv[a - b] % mod * factinv[b] % mod;
	};

	i64 ans = 0;

	for(auto zero : range(0, min(k, n - 1) + 1)) {

		auto filled = n - zero;
		i64 a = choose(n, zero) * choose(n - 1, filled - 1) % mod;
		ans = (a + ans) % mod;
		// ans += nCz * (z+f-1)C(f-1)
	}

	printf("%lld\n", ans);

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)

N = None
M = None
Q = None
L = None
ans = 0


def func(A):
    global ans
    if len(A) == N:
        point = 0
        for d in L:
            if A[d[1] - 1] - A[d[0] - 1] == d[2]:
                point += d[3]
        ans = max(ans, point)
        return
    for i in range(A[-1], M + 1):
        func(A + [i])


def solve():
    global N, M, Q, L
    N, M, Q = Scanner.map_int()
    L = Scanner.int_list_list(Q)
    for i in range(1, M + 1):
        func([i])
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10740
N=int(input())
if N==0:
    print(0)
    quit()
S=""
i=0
while(N):
    if (N-(-2)**i)%2**(i+1)==0:
        S+="1"
        N-=(-2)**i
    else:
        S+="0"
    i+=1
S=S[::-1]
I=False
t=0
for i in S:
    if i=="1":
        break
    else:
        t+=1
print(S[t:])


Measured memory_bytes: 38384
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int e = max(A, C);
    int f = min(B, D);
    cout << max(0, (f-e)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

bool is_prime(int n) {
  if (n == 2)
    return true;
  if (n % 2 == 0)
    return false;
  if (n == 1)
    return false;

  for (int i = 3; i <= sqrt(n); i += 2)
    if (n % i == 0)
      return false;
  return true;
}

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

  int n;
  cin >> n;

  int ans = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if (is_prime(a))
      ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3204
// D - Friend Suggestions
// UnionFinde version (with rank)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

class UnionFind{//union-find class (rank)
	vector<int> parent;//parent number
	vector<int> rank;//rank
	vector<int> g_size;//group size
	public:
	UnionFind(int n){
		parent.resize(n);
		rank.resize(n);
		g_size.resize(n);
		for(int v=0; v<parent.size(); ++v){
			parent[v] = v;
			rank[v] = 0;
			g_size[v] = 1;
		}
	}
	int root(int v){//get root
		if(parent[v]==v) return v;//root
		return parent[v] = root(parent[v]);//path compression
	}
	void unite(int v, int u){
		v = root(v); u = root(u);
		if(v==u) return;
		//concat low rank to high rank (but rank is no compress)
		if(rank[v]<rank[u]){
			g_size[u] += g_size[v];
			g_size[v] = 0;
			parent[v] = u;
		}
		else{
			g_size[v] += g_size[u];
			g_size[u] = 0;
			parent[u] = v;
			if(rank[v]==rank[u]) rank[v]++;//fix rank when same rank concat
		}
	}
	bool same(int v, int u){return root(v)==root(u);}//v & u the same set
	int size(int v){
		return g_size[root(v)];
	}
};

int main(){
	int N,M,K; scanf("%d%d%d",&N,&M,&K);
	UnionFind uf(N);
	vi C(N);
	int s,t;
	rp(i,0,M){
		scanf("%d%d",&s,&t); s--; t--;
		uf.unite(s,t);
		C[s]++; C[t]++;
	}
	rp(i,0,K){
		scanf("%d%d",&s,&t); s--; t--;
		if(uf.same(s,t)) C[s]++, C[t]++;
	}
	rp(i,0,N) printf("%d ", uf.size(i)-C[i]-1);
}

Measured memory_bytes: 2432