akhauriyash/Code-Regression huggingface dataset:
//map_range_search
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecll = vector<long long>;
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
    multimap<string, ll> M;
    string key, R, L;
    ll q, que, x;

    cin >> q;
    rep(i, q)
    {
        //input_分けたい
        //cin >> que >> ((que == 3) ? L : key); //使えない??
        cin >> que;

        //que
        switch (que)
        {
        case 0:
            cin >> key >> x;
            M.insert({key, x});
            break;
        //M.insert_or_assign({key, x}); //C++17から
        case 1:
            cin >> key;
            for (auto itr = M.equal_range(key).first; itr != M.equal_range(key).second; itr++)
                cout << itr->second << endl;
            break;
        case 2:
            cin >> key;
            M.erase(key);
            break;
        case 3:
            cin >> L >> R;
            auto begin_itr = M.lower_bound(L);
            auto end_itr = M.upper_bound(R);
            //delctype(M)::iterator でも可能
            //map<string, ll>::iterator begin_itr = M.lower_bound(L);
            //map<string, ll>::iterator end_itr = M.upper_bound(R);
            for (auto itr = begin_itr; itr != end_itr; itr++)
                cout << itr->first << ' ' << itr->second << endl;
            //ポインタがさす構造体.メンバ名
            //cout << (*itr).first << ' ' << (*itr).second << endl;
            break;
        }

        /* //C++17から
            for (const auto &[a, b] : M)
            {
                cout << b << endl;
            }*/
    }
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    ll N;
    cin >> N;

    ll cnt[3];

    rep(i, 3)
    {
        cnt[i] = -1;
    }

    ll ans = 1;

    rep(i, N)
    {
        ll a;
        cin >> a;

        ll ct = 0;
        bool flag = true;
        rep(j, 3)
        {
            if (cnt[j] == a - 1) {
                ++ct;
                if (flag) {
                    cnt[j]++;
                    flag = false;
                }
            }
        }
        ans *= ct;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    int n = stdin.nextInt();
    int min = 0;
    int max = 0;
    long sum = 0;

    for (int i = 0; i < n; i++) {
      int m = stdin.nextInt();
      sum += m;

      if (i == 0) {
        min = m;
        max = m;
      } else {
        min = Math.min(min, m);
        max = Math.max(max, m);
      }
    }

    System.out.printf("%d %d %d%n", min, max, sum);
  }

}

Measured memory_bytes: 31780
n, m = map(int, input().split())
total = 0
mini = 0
ans = 0

for i in range(n):
    a = int(input())
    total += a
    mini = min(mini, a)
    if mini == 0:
        mini = a
        
ans = (m-total) // mini
ans += n
print(ans)

Measured memory_bytes: 3064
s = input()
t = input()
dict_s = ["_"]*26
dict_t = ["_"]*26
alphabet = [chr(i) for i in range(97, 97 + 26)]
for i in range(len(s)):
    if dict_s[alphabet.index(s[i])] == "_":
        dict_s[alphabet.index(s[i])] = t[i]
    elif dict_s[alphabet.index(s[i])] != t[i]:
            print("No")
            exit()
    if dict_t[alphabet.index(t[i])] == "_":
        dict_t[alphabet.index(t[i])] = s[i]
    elif dict_t[alphabet.index(t[i])] != s[i]:
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 3632
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#define LL long long
using namespace std;
string f;
int n;
int ans;
int read()
{
	int _=0,__=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}
	return _*__;
}
int main()
    {
        cin>>f;
        ans=f.size();
        n=f.size();
        for(int i=1;i<f.size();i++){
            if(f[i]!=f[i-1])
                ans=min(ans,max(i,n-i));
        }
        cout<<ans<<endl;
        return 0;
	} 


Measured memory_bytes: 512
#include<bits/stdc++.h>
const int N=5e5+10;
typedef long long ll;
using namespace std;
ll n,a[N],d,b[N],c[N],f[N];
inline ll read(){
	ll f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
inline ll labs(ll x){return x<0?-x:x;}
int main(){
	n=read();d=read();c[0]=d;ll cur=0,lim=0;
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)c[i]=min(c[i-1],labs(c[i-1]-a[i]));
	f[n+1]=1;
	for(int i=n;i;i--)f[i]=f[i+1]<<1<=a[i]?f[i+1]:f[i+1]+a[i];
	int q=read();for(int i=1;i<=n;i++)b[i]=d;
	for(int i=1;i<=n;i++){
		if(cur+a[i]>d){b[i]=cur;lim++;continue;}
		if(cur+a[i]==d){cur+=a[i];b[i]=cur;lim++;break;}
		if(cur+a[i]<d)cur+=a[i],lim++;
		b[i]=cur;
	}
	//if(cur!=d){
	//	for(int i=1;i<=q;i++)puts("YES");
	//	return 0;
//	}
	while(q--){
		int x=read();
		//if(x>lim&&cur==d){puts("NO");continue;}
		puts(c[x-1]>=f[x+1]?"YES":"NO");
	}
}

Measured memory_bytes: 17536
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

class Pointer{
public:
  long long p;
  long long w;
};

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

  cout << s[0];
  cout << s.length() - 2;
  cout << s[s.length() - 1] << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  if(n % 2 == 1) cout << "No" << endl;
  else {
    rep(i,(n/2)){
      if(s[i] != s[i+(n/2)]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}









































//以下、ライブラリ
//ユークリッドの互除法

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define num(a) a-'0'
#define charr(a) a - 'a'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	ll n;
	cin>>n;
	vl a(n);
	ll ans = 0;
	ll p;
	cin>>a[0];
	p=a[0];
	rep(i,1,n){
		cin>>a[i];
		if(a[i] < p){
			ans+=p-a[i];
		}
		else{
			p=a[i];
		}
	}
	cout<<ans<<ln;
}	

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


Measured memory_bytes: 4776
#include <stdio.h>
#include <string.h>

int main(void){
    long long int A,B,N;
    long long int x;
    long long int ans;
    scanf("%ld %ld %ld", &A, &B, &N);

    x=B-1;
    if(x>N){
        x=N;
    }
    ans = (A*x/B)-A*((x/B));
    printf("%ld",ans);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if(A == B) cout << C << endl;
	else if(B == C) cout << A << endl;
	else if(C == A) cout << B << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		double sum = 0;
		for (int i = 0; i < n; i++) {
			double x = sc.nextDouble();
			String u = sc.next();
			
			if (u.equals("BTC")) x *= 380000.0;
			
			sum += x;
		}
		
		System.out.println(sum);
		
		sc.close();
	}
}




Measured memory_bytes: 29008
n=int(input())
a=list(map(int,input().split()))
a.sort()
eq={}
for i in range(n-1):
  if a[i]==a[i+1]:
    if a[i] in eq:
      eq[a[i]]+=1
    else:
      eq[a[i]]=1
sousa=0
for i in eq.values():
  sousa+=i
if sousa%2==0:
  print(n-sousa)
else:
  print(n-sousa-1)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
#include <bits/stdc++.h>
int main() {
    int a , b , c;
    cin >> a >> b >> c;
    if(a <= c && c <= b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],ans;
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for(i=1;i<=n;i++)
		if(i+1>a[i+1]){
			ans=1;
			for(j=i+1;a[j]==i;j++) ans^=1;
			ans&=(a[i]-i+1)&1;
			printf(ans ? "Second" : "First");
			return 0;
		  }
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>
#define show(x) cout<<#x<<" "<<x<<'\n'
 
#define MAX 1000000007
#define N 100000
 
using namespace std;
using namespace __gnu_pbds;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n,i;
  cin>>n;
  vector<long long int> A(n+1);
  vector<long long int> B(n+1);
  vector<long long int> C(n);
  for(i=1;i<=n;i++){
    cin>>A[i];
  }
  for(i=1;i<=n;i++){
    cin>>B[i];
  }
  for(i=1;i<n;i++){
    cin>>C[i];
  }
  long long int sum = B[A[1]];
  for(i=2;i<=n;i++){
    sum += B[A[i]];
    if(A[i]==A[i-1]+1){
      sum+=C[A[i-1]];
    }
  }
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;

#define DIM 3009
#define MODULO 1000000007
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double

long long i,j,k,l,n,m;

long long dp[DIM][DIM][2],a[DIM],pr[DIM];

long long rec(long long l,long long r,long long type){
    if(l==r){
        if(type==1)return a[l];
        else return -a[l];
    }

    if(dp[l][r][type]!=-1)return dp[l][r][type];

    long long sum=pr[r]-pr[l-1];

    if(type==1){
        dp[l][r][type]=max(rec(l+1,r,2)+a[l],rec(l,r-1,2)+a[r]);
    }
    else{
        dp[l][r][type]=min(rec(l+1,r,1)-a[l],rec(l,r-1,1)-a[r]);
    }

    return dp[l][r][type];
}

int main()
{
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i],pr[i]=pr[i-1]+a[i];

    memset(dp,-1,sizeof(dp));

    cout<<rec(1,n,1)<<endl;

    return 0;
}


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

int a()
{
    int n;
    std::cin >> n;
    
    int rem = n % 10;
    std::string ans;
    
    if(rem == 3)
    {
        ans = "bon";
    }
    else if(rem == 0 || rem == 1 || rem == 6 || rem == 8)
    {
        ans = "pon";
    }
    else
    {
        ans = "hon";
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}


int main(int argc, const char * argv[])
{
    a();
    return 0;
}

Measured memory_bytes: 3600
/*  -*- coding: utf-8 -*-
 *
 * t.cc: T - Permutation
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 3000;
const int MOD = 1000000007;

/* typedef */

/* global variables */

char s[MAX_N + 4];
int dp[MAX_N][MAX_N + 1];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  dp[0][0] = 1;

  for (int l = 0; l < n - 1; l++) {
    for (int i = 0; i <= l; i++)
      if (dp[l][i] > 0) {
	if (s[l] == '<') {
	  addmod(dp[l + 1][i + 1], dp[l][i]);
	  addmod(dp[l + 1][l + 2], MOD - dp[l][i]);
	}
	else {
	  addmod(dp[l + 1][0], dp[l][i]);
	  addmod(dp[l + 1][i + 1], MOD - dp[l][i]);
	}
      }

    for (int i = 0; i <= l; i++)
      addmod(dp[l + 1][i + 1], dp[l + 1][i]);
  }

  int sum = 0;
  for (int i = 0; i < n; i++) addmod(sum, dp[n - 1][i]);
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 34176
#include <stdio.h>
int main(void){
    // Your code here!
    char strs[3][101];
    char *pstrs[3] = {strs[0],strs[1],strs[2]};
    char next = 0;
    char ans;
    
    scanf("%100s%100s%100s",strs[0],strs[1],strs[2]);
    
    while(1){
        if(*pstrs[next] == 0x00){
            ans = 'A' + next;
            break;
        }
        
        if(next == 0){
                char tmp = next;
                next = *pstrs[next]-'a';
                pstrs[tmp]++;
        }
        else if(next == 1){
                char tmp = next;
                next = *pstrs[next]-'a';
                pstrs[tmp]++;
        }
        else if(next == 2){
                char tmp = next;
                next = *pstrs[next]-'a';
                pstrs[tmp]++;
        }
        
    }
    
    printf("%c\n",ans);
}


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

int main(){
  int64_t N,j,i,a,b;
  cin >> N;
  for(i=1; i<=sqrt(N);i++){
    if(N%i==0){
      j  = N/i;
      if(i>j){
        break;
      }
      a=i;
      b=j;
    }
  }
    cout << a+b-2 <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int n, m, Q;    cin >> n >> m >> Q;
    vector<vector<int> > a(n+1, vector<int>(n+1, 0));
    for (int i = 0; i < m; i++) {
        int l, r;   cin >> l >> r;
        a[l][r]++;
    }
    vector<int> p(Q), q(Q);
    for (int i = 0; i < Q; i++)
        cin >> p[i] >> q[i];

    vector<vector<int> > sum(n+2, vector<int>(n+2, 0));
    for (int i = 0; i < n+1; i++) {
        for (int j = 0; j < n+1; j++) {
            sum[i+1][j+1] = a[i][j] + sum[i+1][j] + sum[i][j+1] - sum[i][j];
        }
    }

    for (int i = 0; i < Q; i++) {
        cout << sum[q[i]+1][q[i]+1] - sum[p[i]][q[i]+1] - sum[q[i]+1][p[i]] + sum[p[i]][p[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 6140
n=int(input())
a = list(map(int,input().split()))
a.sort()
 
def gcd(a,b):
  if a>b:
    return gcd(b,a)
  else:
    if b%a==0:
      return a
    else:
      return gcd(b%a,a)

dp=[[0 for i in range(n)] for j in range(2)]
dp[0][0]=a[0]
dp[1][0]=a[0]
dp[0][1]=gcd(a[0],a[1])
dp[1][1]=a[1]
for i in range(n-2):
  dp[0][i+2]=gcd(dp[0][i+1],a[i+2])
  dp[1][i+2]=max(gcd(dp[1][i+1],a[i+2]),dp[0][i+1])

bp=[[0 for i in range(n)] for j in range(2)]
bp[0][0]=a[0]
bp[1][0]=a[0]
bp[0][1]=gcd(a[0],a[1])
bp[1][1]=a[0]
for i in range(n-2):
  bp[0][i+2]=gcd(bp[0][i+1],a[i+2])
  bp[1][i+2]=max(gcd(bp[1][i+1],a[i+2]),bp[0][i+1])
 
print(max(dp[1][n-1],bp[1][n-1]))

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
 #define int long long
int dp[3000+10][3000+10];
int dps[3000+10][3000+10];
const int mod=998244353;
int32_t main()
{
    // cout<<"fafaf"<<endl;
	int n,s;
	cin>>n>>s;
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[1][a[1]]=1;
	dps[1][a[1]]=1;
	int ans=0;
	for(int i=2;i<=n;i++){
		for(int sum=a[i]+1;sum<=3000;sum++)
		{
            dp[i][sum]=dps[i-1][sum-a[i]];
		}
		dp[i][a[i]]=i;
		dp[i][a[i]]%=mod;		
		for(int sum=0;sum<=3000;sum++){
		    dps[i][sum]=dps[i-1][sum];
		    dps[i][sum]+=dp[i][sum];
		    dps[i][sum]%=mod;
		}


	}	
	for(int i=1;i<=n;i++) ans+=(1ll*(n-i+1)*dp[i][s])%mod,ans%=mod;
	cout<<ans;	

	
	return 0;
}


Measured memory_bytes: 141568
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int a[6];
  for (int i(0);i<6;i++) cin>>a[i];
  for (int i(0);i<5;i++){
    for (int j(i);j<5;j++){
      if (a[j]-a[i]>a[5]){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <deque>
#include <vector>

using namespace std;

typedef long long ll;

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

int main(void) {
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    deque<char> deq;
    for (int i = 0; i < (int) S.size(); i++) {
        deq.push_back(S[i]);
    }

    int direction = 1;

    for (int i = 0; i < Q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            direction *= -1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (direction == 1) {
                if (f == 1) {
                    // add top
                    deq.push_front(c);
                } else {
                    // add back
                    deq.push_back(c);
                }
            } else {
                if (f == 1) {
                    // add top
                    deq.push_back(c);
                } else {
                    // add back
                    deq.push_front(c);
                }
            }
        }
    }

    // ll siz = (ll) deq.size();
    // for (ll i = 0; i < siz; i++) {
    //     char c;
    //     if (direction > 0) {
    //         c = deq.front();
    //         deq.pop_front();
    //     } else {
    //         c = deq.back();
    //         deq.pop_back();
    //     }
    //     printf("%c", c);
    // }
    // printf("\n");

    int siz = (int) deq.size();
    if (direction > 0) {
        for (int i = 0; i < siz; i++) {
            printf("%c", deq[i]);
        }
    } else {
        for (int i = siz - 1; i >= 0; i--) {
            printf("%c", deq[i]);
        }
    }
    printf("\n");

    // if (direction < 0) {
    //     reverse(deq.begin(), deq.end());
    // }
    // for (int i = 0; i < (int) deq.size(); i++) {
    //     char c = deq.push_front();
    //     deq.pop_front();
    //     printf("%c", deq[i]);
    // }
    // for (ll i = 0; i < (ll) deq.size(); i++) {
    //     printf("%c", deq[i]);
    // }
    // printf("\n");

    return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
using namespace std;
int n,x,pos,l;
int main(){
	scanf("%d%d",&n,&x);
	for(register int i=1;i<=n;i++){
		scanf("%d",&l);
		pos+=l;
		if(pos>x){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<n+1<<endl;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split(' ').map(v => parseInt(v))
    const N = input[0]
    const Y = input[1]
    let xCount = -1
    let yCount = -1
    let zCount = -1

    for(let x = 0; x <= N; x++){
        for(let y = 0; y <= N; y++){
            let z = N - x - y
            let total = 10000 * x + 5000 * y + 1000 * z
            if(z >= 0 && total === Y){
                xCount = x
                yCount = y
                zCount = z
                break
            }
        }
    }

    console.log("%d %d %d", xCount, yCount, zCount)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int k;
	cin >> k;
	
	if( k % 2 == 0 || k % 5 == 0 ) {
		cout << -1 << endl;
		return 0;
	}
	
	int c = 7 % k;
	int cnt = 1;
	
	while( c ) {
		c = 10 * c + 7;
		c %= k;
		cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}


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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
const ll MAX_N=131072;
const ll INF=1000000;
const ll MOD=1000000007;

int main(){
    int N,L;cin>>N>>L;
    vector<string> S(N);
    rep(i,N){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    string ans;
    for(auto s:S){
        ans+=s;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
const int mo = 1e9 + 7, N = 2e3 + 10, E = 5e6;
typedef long long ll;
ll f[N][N],jc[E],njc[E],suf[N][N];
ll n,k;
ll ksm(ll x,ll y) {
	ll ret = 1; for (; y; y>>=1) {if (y&1) ret = ret * x % mo;
		x = x * x % mo;
	}
	return ret;
}
ll C(ll x,ll y) {
	if (x < y) return 0;
	return jc[x] * njc[x-y] % mo * njc[y] % mo;
}
int main() {
	cin>>n>>k; if (k == 1) {
		printf("1"); return 0;
	}
	suf[0][0] = f[0][0] = 1;
	jc[0] = 1; for (int i = 1; i < E; i++) jc[i] = jc[i-1] * i % mo;
	njc[E-1] = ksm(jc[E - 1],mo-2);
	for (int i = E-2; ~i; i--) njc[i] = njc[i+1] * (i+1) % mo;
	for (int i = 1; i <= n; suf[i][0]=suf[i][1],i++) for (int j = i; j; j--) {
		f[i][j] = suf[i-1][j-1] * C(k+k*(i-1)-j-1,(i-1)*k-j+1) % mo;
		suf[i][j] = (suf[i][j+1] + f[i][j]) % mo;
	}
	printf("%lld\n",suf[n][1] * jc[n] % mo);
}

Measured memory_bytes: 139904
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a, b;
int main() {
	scanf("%d%d", &a, &b);
	printf("%d\n",  max(0, a - b));
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ckmax(a,b) a=max(a,b)

using namespace std;

ll n,a[7],ans,max1;

int main(){ 
	cin>>n;
	for(int i=1;i<=6;i++)
		cin>>a[i];
	if(a[1]<=a[4]&&a[2]>=a[5]&&a[3]>=a[6]){
		n=n/a[1]*a[4]+n%a[1];
		for(int i=0;i<=n;i++){
			int j=n-i;
			ckmax(max1,i%a[5]+j%a[6]+i/a[5]*a[2]+j/a[6]*a[3]);
		}
	}
	else if(a[1]>=a[4]&&a[2]<=a[5]&&a[3]>=a[6]){
		n=n/a[2]*a[5]+n%a[2];
		for(int i=0;i<=n;i++){
			int j=n-i;
			ckmax(max1,i%a[4]+j%a[6]+i/a[4]*a[1]+j/a[6]*a[3]);
		}
	}
	else if(a[1]>=a[4]&&a[2]>=a[5]&&a[3]<=a[6]){
		n=n/a[3]*a[6]+n%a[3];
		for(int i=0;i<=n;i++){
			int j=n-i;
			ckmax(max1,i%a[4]+j%a[5]+i/a[4]*a[1]+j/a[5]*a[2]);
		}
	}
	else if((a[1]<=a[4]&&a[2]<=a[5]&&a[3]<=a[6])||(a[1]>=a[4]&&a[2]>=a[5]&&a[3]>=a[6])){
		for(int i=0;i<=n;i++)
			for(int j=0;i+j<=n;j++){
				int k=n-i-j;
				ans=max(i/a[1]*a[4]+i%a[1],i/a[4]*a[1]+i%a[4])+
					max(j/a[2]*a[5]+j%a[2],j/a[5]*a[2]+j%a[5])+
					max(k/a[3]*a[6]+k%a[3],k/a[6]*a[3]+k%a[6]);
				ckmax(max1,ans);
			}
	}
	else if(a[1]>=a[4]){//a[2]<=a[5]
		for(int i=0;i<=n;i++){
			int j=n-i;
			ckmax(max1,i%a[2]+j%a[3]+i/a[2]*a[5]+j/a[3]*a[6]);
		}
		max1=max1/a[4]*a[1]+max1%a[4];
	}
	else if(a[2]>=a[5]){
		for(int i=0;i<=n;i++){
			int j=n-i;
			ckmax(max1,i%a[1]+j%a[3]+i/a[1]*a[4]+j/a[3]*a[6]);
		}
		max1=max1/a[5]*a[2]+max1%a[5];
	}
	else{
		for(int i=0;i<=n;i++){
			int j=n-i;
			ckmax(max1,i%a[1]+j%a[2]+i/a[1]*a[4]+j/a[2]*a[5]);
		}
		max1=max1/a[6]*a[3]+max1%a[6];
	}
	cout << max1 << endl;
	return 0;
}


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

int main() {
	ll n, k;
	cin >> n >> k;
	int i = 1;
	while (true) {
		if (n < pow(k, i)) {
			cout << i << endl;
			return 0;
		}
		else i++;
	}
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int ls=0,lt=0;
  rep(i,s.size()-1){
    if(s[i]=='S'){
      if(s[i+1]=='S'){
        ls++;
      }else{
        i++;
      }
    }else{
      if(ls>0) ls--;
      else lt++;
    }
  }
  if(s[s.size()-1]=='S') ls++;
  else if(ls>0) ls--;
  cout<<lt+ls<<endl;
}

Measured memory_bytes: 720
/************************ D ********************************/
#include <iostream>
#include <string>
#include <climits>
using namespace std;
int main()
{
	int N, T;
	cin >> N >> T;
	int A[N];
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	int current_min = INT_MAX;
	int max_profit = 0;
	int tie = 0;
	for(int i = 0; i < N; i++){
		int profit = A[i] - current_min;
		if(profit > max_profit){
			tie = 1;
			max_profit = profit;
		}else if(profit == max_profit){
			tie++;
		}
		if(A[i] < current_min){
			current_min = A[i];
		}
	}	
	cout << tie << endl;

	return 0;
}

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



int main() {
    int n;
    cin >> n;
    
    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
    }
    
    h[0]--;
    for(int i = 1; i < n; i++) {
        if(h[i] < h[i-1]) {
            cout << "No" << endl;
            return 0;
        }
        else if(h[i] > h[i-1]) {
            h[i]--;
        }
    }
    
    cout << "Yes" << endl;
    
    
    
    return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a - b > c) {
      cout << 0 << '\n';
    } else {
      cout << c - (a - b) << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
string test[2000];
int ok[213456];
signed main() {
	int n, m, a = 0, sum = 0, ans = 100000000000; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> m; a += m; ok[h] = m;
	}
	a /= n;
	//if (a > 0) { a = (a + n - 1) / n; }
	//else { a = (a - n + 1) / n; }
	for (int i = a - 50; i <= a + 50; i++) {
		for (int h = 0; h < n; h++) {
			sum += (abs(ok[h] - i)) * (abs(ok[h] - i));
		}
		ans = min(ans, sum); sum = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int target = a * b;
    
    if(target % 2 == 1){
      System.out.println("Odd");
    }else{
      System.out.println("Even");
    }
  }
}


Measured memory_bytes: 21204
z = input()
a,b,c = [ int(x) for x in z.split() ]
tryno = 0
ans = 0
if a == b:
    if (c % a) == 0:
        ans = 1
    else:
        ans = 0
else:
    while (a + tryno - 1) < b:
        if c % (a + tryno) == 0:
            ans += 1
            tryno += 1
        else:
            tryno += 1
print (str(ans))


Measured memory_bytes: 5604
from itertools import accumulate

def eratosthenes(mx):
    array = [1 for _ in range(mx)]
    array[0] = array[1] = 0
    for i in range(4, mx, 2):
        array[i] = 0
    for i in range(3, mx, 2):
        if not array[i]:
            continue
        for j in range(i+i, mx, i):
            array[j] = 0
    return array

q = int(input())
l,r = [], []
for i in range(q):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)

mx = max(r)
array = eratosthenes(mx + 1)
prime = [1 if i % 2 == 1 and array[i] and array[(i+1) // 2] else 0 for i in range(mx + 1)]
acc = list(accumulate(prime))
# print(acc[:20])

for i in range(q):
    print(acc[r[i]] - acc[l[i]-1])


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

using namespace std;

int main() {
    int N, D;
    int E = 0;

    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for(int n = 0;n < N; ++n){
        for(int d = 0;d < D; ++d){
            cin >> X[n][d];
        }
    }
    int A = 0;
  

    for(int n = 0;n < N; ++n){
        for(int o = n + 1;o < N; ++o){
            int C = 0;
            for(int d = 0;d < D; ++d){
                int B = abs(X[n][d] - X[o][d]);
                C += B * B;
                // cout << C << endl;
            };
            bool flag = false;
            for(int n = 0;n  <= C; ++n){
                if(n * n == C){
                    flag = true;
                }
            }
            if(flag){
                ++E;
            }
        }



        

    }
    cout << E <<endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);

    int ans = a[n - 1] - a[0];

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
def combination(n, r, p):
    """
    nCr mod p の組み合わせ数を求める関数
    n: 総数
    r: 取り出す個数
    p: 法
    """
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a ** 2 % mod
        n >>= 1
    return res

n, a, b = a_list = list(map(int, input().split()))
p = 10 ** 9 + 7

_n = modpow(2, n, p)
_a = combination(n, a, p)
_b = combination(n, b, p)

ans = _n - _a - _b - 1

print(ans%p)

Measured memory_bytes: 3064
import numpy as np
n,k = list(map(int,input().split()))
h=np.array([int(i) for i in input().split()])
dp = np.array([0]*n)
for i in range(1,n):
    j=max(0,i-k)
    dp[i] = np.min(dp[j:i]+abs(h[i]-h[j:i]))
print(dp[-1])


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

int main(){
  int a,b,ans;
  char op;

  while(true){
    cin>>a;
    cin>>op;
    cin>>b;
    if(op=='?') break;
    else if(op=='+') cout<<a+b<<endl;
    else if(op=='-') cout<<a-b<<endl;
    else if(op=='/') cout<<a/b<<endl;
    else if(op=='*') cout<<a*b<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
//      freopen("q.in","r",stdin);
//      freopen("q.out","w",stdout);
      int n,m,x;
      cin>>n>>m>>x;
      int a=max(m,n);
      int ans=x/a;
      if(x%a)ans++;
      cout<<ans;
}


Measured memory_bytes: 256
"*****     ",
  "     *****",
  "==========",
  " **** ****",
  "* **** ***",
  "** **** **",
  "*** **** *",
  "**** **** "
};

main(f,i,j){
  char s[9];
  for(f=0;~scanf("%s",s);){
    if(f)puts("");
    f=1;
    for(i=0;i<8;puts(""),i++){
      for(j=0;j<5-strlen(s);j++)
        putchar(m[i][0]);
      for(j=0;j<strlen(s);j++)
        putchar(m[i][s[j]-'0']);
    }
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a, b, c = [], [], []
for _ in range(n):
    ai, bi, ci = map(int, input().strip().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
dp = []
dp.append((a[0], b[0], c[0]))
for i in range(1, n):
    prev = dp[i-1]
    chosen_a = a[i] + max(prev[1], prev[2])
    chosen_b = b[i] + max(prev[0], prev[2])
    chosen_c = c[i] + max(prev[0], prev[1])
    dp.append((chosen_a, chosen_b, chosen_c))
res = dp[n-1]
print(max(res[0], res[1], res[2]))

Measured memory_bytes: 100676
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(" ").map(String::toInt)
    val countMap = xs.groupBy { it }.mapValues { it.value.size }
    val ans = countMap.map { if (it.value >= it.key) it.value - it.key else it.value }
    println (ans.sum())
}


Measured memory_bytes: 59628
#include<bits/stdc++.h>
using namespace std;
multiset<int> mp;
int main()
{
	int n;scanf("%d",&n);
	while (n--) {int w;scanf("%d",&w);mp.insert(w);}
	scanf("%d",&n);
	while (n--)
	{
		int w;scanf("%d",&w);
		if (mp.find(w)==mp.end()) {puts("NO");return 0;}
		mp.erase(mp.find(w));
	}
	puts("YES");
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
#define mp make_pair
using namespace std;

int main()
{
ll n;
    cin >> n;
    ll x = 0;
    ll res = 0;
    if(n % 2 == 0){
        cout << -1 << endl;
        return 0;
    }
    while(1){
        res++;
        x = x*10 + 7;
        x %= n;
        if(x % n == 0){
            cout << res << endl;
            break;
        }
        if(res > n){
            cout << -1 << endl;
            break;
        }
    }

return 0;
}


Measured memory_bytes: 3580
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
    a: i32,
    b: i32,
    );
    let s: &str = if a * b % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", s);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
int fac[200010],inv[200010];
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
inline int C(int n,int m){return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    fac[0]=1;
    for(int i=1;i<=200000;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[200000]=power(fac[200000],mod-2);
    for(int i=200000;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
    int n=read(),m=read(),ans=0;
    for(int i=0;i<=min(m,n);i++)ans=ad(ans+1LL*C(n,i)*C(n-1,n-i-1)%mod);
    pr2(ans);
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 100;

int main() {
	int N, M, X;
	int x = 0, y = 0;

	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		if (a < X)x++;
		else y++;
	}

	cout << min(x, y) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;
s64 k;
vector< vs32 > dp(1 << 9, vs32(100001, -1));
vector< P > vw;

int rec(int v, int l)
{
    if (v == 0) return 0;
    if ((1 << k) > v && dp[v][l] >= 0)
    {
        return dp[v][l];
    }

    int ret = rec(v / 2, l);
    if (l >= vw[v - 1].second) ret = max(ret, rec(v / 2, l - vw[v - 1].second) + vw[v - 1].first);

    if ((1 << k) > v) dp[v][l] = max(dp[v][l], ret);
    return ret;
}


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

    int n;
    cin >> n;

    vw.resize(n);
    rep (i, n)
    {
        cin >> vw[i].first >> vw[i].second;
    }

    while ((1ll << (2 * k)) < n) ++k;
    for (int v = 1; v < (1 << k); ++v)
    {
        rep (l, 100000 + 1)
        {
            rec(v, l);
        }
    }

    int q;
    cin >> q;
    while (q--)
    {
        int v, l;
        cin >> v >> l;
        cout << rec(v, l) << "\n";
    }

    return 0;
}



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

a1 = a % 10
b1 = b % 10
c1 = c % 10
d1 = d % 10
e1 = e % 10

if a1 == 0:
  a1 = 10
if b1 == 0:
  b1 = 10
if c1 == 0:
  c1 = 10
if d1 == 0:
  d1 = 10
if e1 == 0:
  e1 = 10

a2 = a - a1 + 10
b2 = b - b1 + 10
c2 = c - c1 + 10
d2 = d - d1 + 10
e2 = e - e1 + 10

ans = a2 + b2 + c2 + d2 + e2 - 10 + min(a1, b1, c1, d1, e1)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << (val) << "\n";
using namespace std;

int main(void){
    CIN(int, a);
    CIN(int, b);
    
    COUT(1.0 * a / b);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
			for(int j=i+1;j<s.size();j++)
			{
				if(s[j]=='F') {cout<<"Yes";return 0;}
				}
		}
	cout<<"No";
	return 0;
	}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

ll gcd(ll a, ll b){
  if(a < b){
    ll box = a;
    a=b;
    b = box;
  }
  if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}

int N;
vector<int> A, B, C;

int main(){
  cin >> N;
  A.resize(N+1), B.resize(N+1), C.resize(N+1);
  REP(i, N){
    cin >> A[i];
  }
  REP(i, N){
    cin >> B[i];
  }
  REP(i, N){
    cin >> C[i];
  }
  A[N]=B[N]=C[N]=INF+10;
  C[N]++;
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  int idA, idB, idC;
  idA = idB = idC = 0;

  ll ans = 0;
  while(A[0] >= B[idB]){
    idB++;
  }
  while(B[idB] >= C[idC]){
    idC++;
  }

  FOR(i, idB, N){
    while(A[idA] < B[i]){
      idA++;
    }
    while(B[i] >= C[idC]){
      idC++;
    }
    //cout << idA << " " << idC << endl;
    ans += (ll)idA * (N-idC);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
n=int(input())
bag=[]
ans="Yes"
total=0
for i in range(n):
    a,b=map(int,input().split())
    bag.append([a,b])
d=sorted(bag, key=lambda x:x[1])

for j in range(n):
    total=total+d[j][0]
    if total>d[j][1]:
        ans="No"
        break

print(ans)

Measured memory_bytes: 39692
#include<iostream>
#include<cstdio>
using namespace std;
 
int main()
{
  int n,x;
  while(scanf("%d %d",&n,&x),n!=0){
    int res=0;
    for(int a=1;a<=n;a++){
      for(int b=a+1;b<=n;b++){
        for(int c=b+1;c<=n;c++){
          if(a+b+c==x) res+=1;
        }
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string s; cin >> s;
    int n = s.size();
    string ans;
    for(int i = 0; i < n; i += 2){
        ans += s[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 3672
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

sx,sy,gx,gy = map(int,input().split())

ans = []
# go
way1 = ["U"] * (gy-sy) + ["R"] * (gx-sx)
#return
way2 = ["D"] * (gy-sy) + ["L"] * (gx-sx)

way3 = ["L"] + ["U"] * (gy-sy+1) + ["R"] * (gx-sx+1) + ["D"]
way4 = ["R"] + ["D"] * (gy-sy+1) + ["L"] * (gx-sx+1) + ["U"]
ans += way1 + way2 + way3 + way4

print("".join(ans))
# print(len(ans))


Measured memory_bytes: 5964
n=int(input())
arr=list(map(int,input().split()))
ans=100000000000000
for i in range(1,101):
    temp=0
    for j in range(len(arr)):
        xx=(arr[j]-i)
        yy=xx*xx 
        temp+=yy 
    ans=min(ans,temp)
print(ans)

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

typedef int64_t i64;
typedef uint64_t ui64;

const int inf=1073741823;
const i64 llinf=4611686018427387903LL;

int main(void){
    int x;
    scanf("%i",&x);
    printf("%i\n",x*x*x);
    return 0;
}



Measured memory_bytes: 3184
#include <stdio.h>
#include <string.h>
#define LEN 100000

typedef struct qu {
	char name[100];
	int t;
} TT;
	TT Q[LEN];
	int head,tail,n;
	
void enqueue(TT x){
	Q[tail] = x;
	
	tail = (tail+1) % LEN;

} 
TT dequeue(){
	TT x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a,int b){
	return a < b ? a:b;
}

int main(void){
	int elaps = 0,c;
	int i,q;
	TT r;
	scanf("%d %d", &n,&q);
	
	for(i = 1;i <= n;i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1;
	tail = n + 1;
	
	
	while(head != tail){
		r = dequeue();
		c = min(q,r.t);
		r.t = r.t -c;
		elaps += c;
		if( r.t > 0)enqueue(r);
		else{
			printf("%s %d\n", r.name,elaps);
		}
	}
	return 0;

}


Measured memory_bytes: 11884