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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();

		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sb.append("");

		for (int i = 0; i < n; i++) {
			sb.append(s[i]);
			sb.append(t[i]);
		}
		System.out.println(sb.toString());
		sc.close();
	}
}

Measured memory_bytes: 19924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <pair <ll, ll>> v(n);
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    v.at(i) = make_pair(b, a);
  }
  sort(v.begin(), v.end());
  ll time = 0;
  string ans = "Yes";
  rep(i, n) {
    if (v.at(i).first >= time+v.at(i).second) {
      time += v.at(i).second;
    } else {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 1010;

int N, M;
vi G[MAX];

int pos = -1;
bool vis[MAX], fin[MAX];
vi hist;

int idx[MAX];

void dfs(int v) {
    vis[v] = true;
    hist.push_back(v);
    FORE (nv, G[v]) {
        if (fin[nv]) continue;
        if (vis[nv]) {
            pos = nv;
            return;
        }
        dfs(nv);
        if (pos != -1) return;
    }
    hist.pop_back();
    fin[v] = true;
}

void solve() {
    REP (v, N) {
        dfs(v);
        if (pos != -1) break;
    }

    if (pos == -1) {
        cout << -1 << endl;
        return;
    }

    vi cycle;
    while (!hist.empty()) {
        int t = hist.back();
        cycle.push_back(t);
        hist.pop_back();
        if (t == pos) break;
    }
    reverse(ALL(cycle));

    while(1) {
        bool done = false;
        REP (i, MAX) idx[i] = -1;
        REP (i, cycle.size()) idx[cycle[i]] = i;

        REP (i, cycle.size()) {
            int cur = cycle[i];
            FORE (next, G[cur]) if (idx[next] >= 0) {
                if (idx[next] == (idx[cur] + 1) % cycle.size()) continue;

                vi v;
                bool get = false;
                for (int r = 0;; r++) {
                    if (cycle[r%cycle.size()] == next) get = true;
                    if (get){
                        v.push_back(cycle[r%cycle.size()]);
                        if (cycle[r%cycle.size()] == cur) break;
                    } 
                }

                cycle = v;
                done = true;
                break;
            }
            if (done) break;
        }
        if (!done) break;
    }

    cout << cycle.size() << endl;
    FORE (r, cycle) cout << r+1 << "\n";
    return;
}

int main() {
    cin >> N >> M;
    REP (i, M) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
    }
    solve();
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#define ll long long 
#define MOD 1000000007

using namespace std;

const int N = 101;
const int K = 100100;
ll dp[N][K];
ll a[N],s[K];
int n,k;

int  main(){
        scanf("%d%d", &n, &k) ;
        for (int i = 0; i < n; i++) scanf("%lld", &a[i]) ;
        for (int j = 0; j <= k; j++) dp[0][j] = 0 ;
        for (int j = 0; j <= n; j++) dp[j][0] = 1 ;
        for (int i = 1; i <= n; i++) {
                s[0] = 0 ;
                for (int j = 1; j <= k + 1; j++) s[j] = s[j - 1] + dp[i - 1][j - 1] ;
                for (int j = 1; j <= k; j++) {
                        dp[i][j] = s[j + 1] - s[max(0ll, j - a[i - 1])] ;
                        dp[i][j] %= MOD ;
                }
        }
//        for( int i = 0 ; i <= n ; i++ ){
//          for( int j = 0 ; j <= k ; j++ ){
//            cout << dp[i][j] << " " ;
//          }
//          cout << endl;
//        }
        printf("%lld\n", dp[n][k]) ;


        return 0 ;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

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

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N = input()
H = [2, 4, 5, 7, 9]
P = [0, 1, 6, 8]

if int(N[-1]) in H:
    print('hon')
elif int(N[-1]) in P:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
vector<bool> vis;
vector<int> dp;
vector< vector <int> > g;
void dfs(int u){
    vis[u]=true;
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(!vis[v]){
            dfs(v);
            
        }
        dp[u]=max(dp[u],1+dp[v]);
    }
}
int main(){
    int n,m,a,b;
    cin>>n>>m;
    g.resize(n+1);
    vis.resize(n+1);
    dp.resize(n+1);
    for(int i=0;i<m;i++){
        cin>>a>>b;
        g[a].push_back(b);
    }
    for(int i=0;i<=n;i++){
        vis[i]=false;
        dp[i]=0;
    }
    for(int i=0;i<=n;i++){
        if(!vis[i]){
            dfs(i);
        }
    } 
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    int h, w;
    cin >> h >> w;

    char s[25][25];
    for (int i = 0; i < h; i++) cin >> s[i];

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int p = 0; p < h; p++) {
                for (int q = 0; q < w; q++) {
                    queue<Tlll> que;
                    que.push(Tlll(i, j, 0));

                    bool b[25][25] = {};
                    b[i][j] = 1;
                    if (s[i][j] == '#') continue;

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

                    while (!que.empty()) {
                        Tlll qq = que.front(); que.pop();
                        int x = get<0>(qq), y = get<1>(qq), zz = get<2>(qq);
                        //cout << x _ y _ w << endl;
                        if (x == p && y == q) {
                            ans = max(ans, zz);
                            break;
                        }
                        for (int z = 0; z < 4; z++) {
                            int nx = x + dx[z], ny = y + dy[z];
                            if (0 <= nx && nx < h && 0 <= ny && ny < w) {
                                if (!b[nx][ny] && s[nx][ny] == '.') {
                                    b[nx][ny] = 1;
                                    que.push(Tlll(nx, ny, zz + 1));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int input[6];

    for(int i = 0; i < 6; ++i)
    {
        scanf("%d", &input[i]);
    }

    int current = 0;
    int next = 1;
    while(1)
    {
        int tmp = input[next] - input[current];
        if(tmp > input[5])
        {
            puts(":(");
            return 0;
        }

        ++next;

        if(next == 5)
        {
            ++current;
            next = current + 1;
        }

        if(current == 4)
        {
            break;
        }
    }

    puts("Yay!");

    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int A, B;
    cin >> A >> B;

    if (A == 1 && B == 13) {
      cout << "Alice" << endl;
    } else if (A == 13 && B == 1) {
      cout << "Bob" << endl;
    } else if (A == B) {
      cout << "Draw" << endl;
    } else if (A > B) {
      cout << "Alice" << endl;
    } else {
      cout << "Bob" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define  ll    long long int
#define  mod   1000000007   //10^9
#define  N     300005       //10^5
int main()
{
    int n,a,b,c,k;
    cin>>n;
    a=n%10;
    n/=10;
    b=n%10;
    n/=10;
    c=n%10;
    k=c;
    if(b>k)
    {
        k++;
        cout<<k<<k<<k<<endl;
    }
    else if(b<k)
    {
        cout<<k<<k<<k<<endl;
    }
    else
    {
        if(a<=k)
            cout<<k<<k<<k<<endl;
        else
        {
            k++;
            cout<<k<<k<<k<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll a,b;
    cin>>a>>b;
    if(a+b==15)cout<<"+"<<endl;
    else if(a*b==15)cout<<"*"<<endl;
    else cout<<"x"<<endl;
    return 0;
}


Measured memory_bytes: 256
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  string s;
  cin >> s;
  string t;
  cin >> t;
  int lenS = s.length();
  int lenT = t.length();
  
  for(int i=0;i<min(lenS,lenT);i++)
  {
    cout<<s[i]<<t[i];
  }
  if(lenS > lenT)
    cout<<s[lenS-1];
  if(lenS < lenT)
    cout<<t[lenT-1];
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iterator>

using namespace std;

int main(){
    int N;
    cin >> N;
    int D[N];
    int A[110]={0};
    int res=0;
    for (int i=0;i<N;i++)cin>>D[i];
    for (int i=0;i<N;i++){
        A[D[i]]++;
    }
    for (int i=1;i<=100;i++){
        if(A[i])res++;
    }
    cout<<res;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()
const long long INF = 1LL<<58;
const long long MOD=1e9+7;


using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
  if(a>b){
    return gcd(b,a);
  }
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}


template<class T>void chmin(T &a,T b){
  if(a>b){
    a=b;
  }
}

//formerは前方のindex(自分自身を含んで良い)
template<class T>int former(const vector<T>&v,T x){
  return upper_bound(v.begin(),v.end(),x)-v.begin()-1;
}
//latterは後方のindex(自分自身を含んで良い)
template<class T>int latter(const vector<T>&v,T x){
  return lower_bound(v.begin(),v.end(),x)-v.begin();
}


int main() {
  int A,B,C;
  cin>>A>>B>>C;
  int sum=B/A;
  if(sum>C){
    cout<<C<<endl;
  }else{
    cout<<sum<<endl;
  }
  
  



  
    

}
  




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

int main(){
	int i,j,k,l,N,p=0,count=0;
	char S[30000];
	char check[3];
	cin>>N;
	cin>>S;
	for(j=0;j<10;j++){
		for(k=0;k<10;k++){
			for(l=0;l<10;l++){
				p=0;
				check[0]=j+48;
				check[1]=k+48;
				check[2]=l+48;
				for(i=0;i<N;i++){
					if(S[i]==check[p]){
						p++;
					}
					if(p==3){
						count++;
						break;
					}
				}
			}
		}
	}
	cout<<count<<endl;
}

	

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long int L, R,kake,ans=2222;
	cin >> L >> R;
	for (long long int i = L; i <= R; i++)
	{
		for (long long int j = i+1; j <= R; j++)
		{
			kake = i*j;
			if (kake % 2019 < ans) {
				ans = kake % 2019;
			}
			if (ans == 0)break;
		}
		if (ans == 0)break;
	}
	cout << ans;
}


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

int w[100], v[100];
long long dp[101][100001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, W;
    cin >> n >> W;
    for (int i=0; i<n; i++)
        cin >> w[i] >> v[i];

    memset(dp, 127, sizeof(dp));
    dp[0][0] = 0;
    for (int i=1; i<=n; i++)
        for (int j=0; j<=100000; j++) {
            dp[i][j] = dp[i-1][j];
            if (v[i-1] <= j)
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1]);
        }

    long long ret;
    for (int j=0; j<=100000; j++)
        if (dp[n][j] <= W)
            ret = j;

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(std::string S){
    int res = 0;
    REP(i, 4) {
        if(S[i] == '+') res += 1;
        else res -= 1;
    }
    cout << res << endl;
}

int main(){

    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 5000000000000000000;

constexpr int mod = 1000000007;
struct ModInt {
    ll x;
    ModInt (ll a) : x((a % mod + mod) % mod) {}
    ModInt operator- () const {
        return ModInt(-x);
    }
    ModInt &operator+= (const ModInt &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-= (const ModInt &a) {
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    ModInt &operator*= (const ModInt &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+ (const ModInt &a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator- (const ModInt &a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator* (const ModInt &a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(ll t) const {
        if (!t) return 1;
        ModInt a = pow(t / 2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator/= (const ModInt &a) {
        return (*this) *= a.inv();
    }
    ModInt operator/ (const ModInt &a) const {
        ModInt res(*this);
        return res /= a;
    }
    friend ostream &operator<< (ostream &os, const ModInt &a){
        os << a.x;
        return os;
    }
};

vector<ModInt> fact, ifact;
void init(int N) {
    fact.resize(N, ModInt{0});
    ifact.resize(N, ModInt{0});
    fact[0] = ModInt{1};
    REP(i, N) {
        ModInt M(i);
        fact[i] = fact[i - 1] * M;
    }
    ifact[N - 1] = fact[N - 1].inv();
    for (int i = N - 1; i > 0; --i) {
        ModInt M(i);
        ifact[i - 1] = ifact[i] * M;
    }
}
ModInt comb(int x, int y) {
    if (x < y) return ModInt{0};
    else return fact[x] * ifact[y] * ifact[x - y];
}

int main() {
    int n, k;
    cin >> n >> k;
    
    init(n + 1);
    ModInt ans(0);
    rep(i, min(n - 1, k) + 1) {
        ans += comb(n, i) * comb(n - 1, i);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
int n, aa[30], ans[30];
int main()
{
	scanf("%d",&n);
	for(int j = 1; j <= n; j++){
		string s;cin>>s;
		for(int i = 0; i < s.size(); i++){
			int psx;
			psx = int(s[i]-'a'+1);
			aa[psx]++;
		}
		if(j != 1) 
			for(int i = 1; i <= 26; i++)
				ans[i] = min(ans[i], aa[i]);
		else for(int i = 1; i <= 26; i++)
				ans[i] = aa[i];
		memset(aa, 0, sizeof(aa));
	}
	for(int i = 1; i <= 26; i++){
		while(ans[i]){
			char qyx;
			qyx = char(i+'a'-1);
			cout<<qyx;
			ans[i]--;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
// Aizu Vol-2 0222: Prime Quadruplet
// 2017.8.7

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);
char buf[100];

#define MAX  10000000
#define SQRT 3162     // sqrt(MAX)
char prime[MAX + 5], *p, *q, *pmax;

int main()
{
	int n;
	int k;

	pmax = prime + MAX;
	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2) {
		if (!*p) {
			for (q = p + k; q <= pmax; q += k) *q = 1;
		}
	}
	while (1) {
		gets(buf), n = atoi(buf);
		if (n == 0) break;
		if (!(n & 1)) n--;
		for ( ; ; n -= 2) {
			if (!prime[n] && !prime[n - 2] && !prime[n - 6] && !prime[n - 8]) {
				printf("%d\n", n);
				break;
			}
		}
	}
	return 0;
}

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

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int r = in.nextInt();
			int g = in.nextInt();
			int b = in.nextInt();
			if((r * 100 + g * 10 + b) % 4 == 0) {
				out.println("YES");
			} else {
				out.println("NO");
			}
		}
	}
		
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 21332
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

int main(){
    int N,M; cin >> N >> M;
    int L = 0;
    rep(i,M) {
        int x; cin >> x;
        L += x;
    }

    if(L > N){
        cout << -1 << endl;
    }else{
        cout << N - L  << endl;
    }

    sysp;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <queue>

struct process {
    std::string name;
    int time;
};

int main()
{
    int n, q;
    int name, time, total = 0;
    process tmp;
    std::queue<process> qu;

    std::cin >> n >> q;

    for ( int i = 0; i < n; ++i ) {
        std::cin >> tmp.name >> tmp.time;
        qu.push(tmp);
    }

    while( 1 ) {
        tmp = qu.front();

        if ( tmp.time <= q ) {
            total += tmp.time;
            qu.pop();
            std::cout << tmp.name << " " <<  total << std::endl;
        } else {
            tmp.time -= q;
            total += q;
            qu.push(tmp);
            qu.pop();
        }

        if ( qu.empty() ) {
            break;
        }
    }
}

Measured memory_bytes: 4404
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define M 10000000000000000
using namespace std;
typedef unsigned long long ull;
int main()
{
    ull A,B,C,x,y;
    while(scanf("%llu %llu %llu %llu %llu",&A,&B,&C,&x,&y)!=EOF)
    {
        ull Min=M;
        ull sum=0;
        sum =sum + A*x + B*y;
        Min=min(sum,Min);
        sum=0;

        ull a=max(x,y);
        sum = sum + 2*a*C;
        Min=min(Min,sum);
        sum =0;

        if(x>y)
        {
            sum=sum+2*y*C;
            ull b=x-y;
            sum=sum+b*A;
            Min=min(Min,sum);
            sum=0;
        }
        else
        {
            sum=sum+2*x*C;
            ull b=y-x;
            sum=sum+b*B;
            Min=min(Min,sum);
            sum=0;
        }
        printf("%llu\n",Min);
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "YES":"NO"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B,C;
	while(cin>>A>>B>>C) {
		bool ok=0;
		RANGE(i, 1, 1000) {
			if(A*i%B==C) ok=1;
		}
		
		cout<<YN(ok)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
L = []
INF = 10 ** 18
for i in range(N):
    l = int(input())
    L.append(l)

def dfs(cnt, a, b, c):
    if cnt == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    
    ans1 = dfs(cnt+1, a, b, c)
    ans2 = dfs(cnt+1, a + L[cnt], b, c) + 10
    ans3 = dfs(cnt+1, a, b + L[cnt], c) + 10
    ans4 = dfs(cnt+1, a, b, c + L[cnt]) + 10
    return min(ans1, ans2, ans3, ans4)

print(dfs(0, 0, 0, 0))

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
	char c;
	cin >> c;
	char ans = 'a' + (c - 'a' + 1);
	cout << ans << endl;
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 


Measured memory_bytes: 256
#テストファイルで実行する時
import sys
if sys.platform == 'ios':
	sys.stdin=open('input_file.txt')


n,m = map(int,input().split())

a = [list(map(int,input().split())) for i in range(n)]
b = [list(map(int,input().split())) for i in range(m)]

min = 10**9
ans = 0

for i in range(n):
	for j in range(m):
		if abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]) < min:
			min = abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1])
			ans = j+1
			#print(i,j,min,ans)
	min = 10**9
	print(ans)




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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

int a[26];

void solve() {
  int h, w; scanf("%d%d", &h, &w);
  int sum = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      char c; scanf(" %c", &c);
      ++a[c-'a'];
    }
  }
  if (h > 1 && w > 1) {
    for (int i = 0; i < 26; ++i) {
      sum += a[i] %= 4;
    }
    if (h%2) sum -= w;
    if (w%2) sum -= h;
    if (w%2 && h%2) ++sum;
    if (sum) {
      puts("No");
      return;
    }
  }
  int o = 0;
  for (int i = 0; i < 26; ++i) {
    if (a[i]%2) ++o;
  }
  if (o > 1) puts("No");
  else if (h%2 && w%2 && !o) puts("No");
  else if ((h%2 == 0 || w%2 == 0) && o) puts("No");
  else puts("Yes");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 610;
const int Mod = 1e9 + 7;

int n, k;
int A[N], B[N];
int dp[N], f[N], cnt[N][N];

int main() {

	scanf("%d%d", &n, &k);
	For(i, 1, k) {
		scanf("%d%d", &A[i], &B[i]);
		if (A[i] > B[i]) swap(A[i], B[i]);
	}

	f[0] = 1;
	For(i, 1, n) f[i] = 1ll * f[i - 1] * (2 * i - 1) % Mod;

	int ans = 0;
	For(i, 0, 2 * n - 2)
		for (int j = i + 2; j <= 2 * n; j += 2) {
			For(u, 1, k) {
				int c = (A[u] <= i || A[u] > j) + (B[u] <= i || B[u] > j);
				if (c == 1) { cnt[i][j] = -1; break; }
				else if (!c) cnt[i][j]++;
			}
		}

	For(i, 0, 2 * n - 2) {
		dp[i] = -1;
		for (int j = i + 2; j <= 2 * n; j += 2) {
			dp[j] = 0;
			for (int l = i; l < j; l += 2)
				if (cnt[l][j] != -1) dp[j] = (dp[j] - 1ll * f[(j - l) / 2 - cnt[l][j]] * dp[l]) % Mod;
			ans = (ans + 1ll * dp[j] * f[(n - (j - i) / 2) - (k - cnt[i][j])]) % Mod;
		}
	}
	ans = (ans + Mod) % Mod;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  double a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<fixed<<setprecision(20)<<sqrt((a-c)*(a-c)+(b-d)*(b-d))<<endl;
}



Measured memory_bytes: 3284
// f-pond-skater.yml
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
template <typename V> using uset = unordered_set<V>;
template <typename K, typename V> using umap = unordered_map<K, V>;
template <typename C> int sz(C &v) { return v.size(); }

const int DIR[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

struct Pos {
    int x, y;
};

struct Ent { 
    int x, y, predir;
};

int R, C, K;
Pos st, en;
vector<vector<bool>> grid;
vector<vector<ll>> dis[5];
deque<Ent> q;

// priority_queue<Ent> q;


ll make_dp(ll dis, ll k) {
    return (k << 32LL) | dis;
}
const ll MSK = (1LL << 32) - 1;
inline ll gdis(ll dp) { return dp & MSK; }
inline ll gk(ll dp) { return dp >> 32LL; }

bool cmp(const ll a, const ll b) {
    return gdis(a) == gdis(b) ? gk(a) < gk(b) : gdis(a) < gdis(b);
}

inline void tryPush(int x, int y, int predir, int ndis, int k, bool inc) {
    ll disPair = make_dp(ndis, k);
    if (x < 0 || x >= R || y < 0 || y >= C || !grid[x][y] || cmp(dis[predir][x][y], disPair) || dis[predir][x][y] == disPair) return;

    Ent ent{x, y, predir};
    if (inc)
        q.push_back(ent);
    else
        q.push_front(ent);
    dis[predir][x][y] = disPair;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> R >> C >> K;
    cin >> st.x >> st.y >> en.x >> en.y;
    grid.assign(R, vector<bool>(C, true));
    for (int i = 0; i < R; i++) {
        string tmp;
        cin >> tmp;
        for (int j = 0; j < C; j++)
            grid[i][j] = tmp[j] == '.';
    }
    st.x--; st.y--;
    en.x--; en.y--;

    for (int i = 0; i < 5; i++) {
        dis[i].assign(R, vector<ll>(C, make_dp(INF, 0)));
        // inq[i].assign(R, vector<bool>(C, false));
    }

    // assert(0);
    // cout << st.x<<' '<<st.y<<endl;

    dis[4][st.x][st.y] = make_dp(0, 0);
    q.push_back({st.x, st.y, 4});
    // assert(0);
    while (!q.empty()) {
        auto c = q.front();
        q.pop_front();
        int cdis = gdis(dis[c.predir][c.x][c.y]), ck = gk(dis[c.predir][c.x][c.y]);
        // inq[c.predir][c.x][c.y] = false;

        // if (c.x == en.x && c.y == en.y) {
        //     cout << cdis << '\n';
        //     return 0;
        // }

        if (cmp(dis[c.predir][c.x][c.y], make_dp(cdis, ck))) continue;

        // cout << "pos=("<<c.x<<", "<<c.y<<") dir="<<c.predir<<" dis=("<<c.dis<<", "<<c.k<<")"<<endl;

        if (c.predir == 4) {
            for (int i = 0; i < 4; i++) {
                tryPush(c.x + DIR[i][0], c.y + DIR[i][1], i, cdis + 1, 1, true);
            }
        }
        else {
            for (int i = 0; i < 4; i++) {
                bool inc = i != c.predir || ck == K;
                int newK = inc ? 1 : (ck + 1);
                tryPush(c.x + DIR[i][0], c.y + DIR[i][1], i, cdis + inc, newK, inc);
            }
        }
    }

    // cout << "-1\n";
    int ans = INF;
    for (int i = 0; i < 5; i++)
        ans = min(ans, (int)gdis(dis[i][en.x][en.y]));
    cout << (ans == INF ? -1 : ans) << '\n';

    return 0;
}



Measured memory_bytes: 50344
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int cntn=0, cntm=0;
long long int a[200001],b[200001],sa[200001],sb[200001];
int n,m;
long int k;
long int ans=0;
int dp[200][200][2000];
long int idx;


int dfs(int i, int j, long int k){
    int res=0;
    if(dp[i][j][k] != -1 && n-i < 200 && m-j < 200 && k < 2000) return dp[i][j][k];
    if(i+j == n+m || (k - a[i] < 0 && k - b[j] < 0) ) return 0;
    else if(i == n && k - b[j] > 0){
        res = dfs(i,j+1,k-b[j])+1;
    }
    else if(j == m && k - a[i] > 0){
        res = dfs(i+1,j,k-a[i]) + 1;
    }
    else if(k - a[i] > 0 && k - b[j] > 0){
        res = max(dfs(i+1,j,k-a[i])+1, dfs(i+1,j,k-b[j])+1);
    }
    else if(k - a[i] > 0){
        res = dfs(i+1,j,k-a[i])+1;
    }
    else if(k-b[j] > 0){
        res = dfs(i,j+1,k-b[j])+1;
    }
    if(n-i < 200 && m-j < 200 && k < 2000) dp[i][j][k] = res;
    return res;
}

void bsearch(long int left, long int right, long long int thresh){
    long int res=-1;
    long int mid = (left + right)/2;
    // cout << sb[mid] << " " << left << " " << right << " " << mid << " " << thresh << endl;
    if(left == right){
        ;
        // return mid;
    }
    else if(sb[mid] > thresh){
        bsearch(left, mid, thresh);
    }
    else {

        idx = max(mid, idx);
        bsearch(mid+1, right, thresh);
        // cout << idx << " " << endl;
    }
    // return res ;

}


int main(){
    cin >> n >> m >> k;
    rep(i,n) {
        cin >> a[i];
        if(i == 0) {
            sa[i] = 0;
        }
        sa[i+1] = sa[i] + a[i];
        // cout << sa[i+1] << endl;
    }
    rep(i,m){
        cin >> b[i];
        if(i == 0) {
            sb[i] = 0;
        }
        sb[i+1] = sb[i] + b[i];
        // cout << sb[i+1] << endl;
    }

    // cout << dp[1][1][1];
    rep(i,n+1){
        if(k >= sa[i]){
            // cout << sa[i] << " i= " << i << "--------------" << endl;
            bsearch(0,m+1,k-sa[i]);
            ans = max(idx + i, ans);
            idx = 0;
        }
    }


    cout << ans << endl;

return 0;
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll ADD( ll a, ll b )
{
	return ( ( a % MOD ) + ( b % MOD ) ) % MOD;
}

ll SUB( ll a, ll b )
{
	return ( ( a % MOD ) - ( b % MOD ) + MOD ) % MOD;
}

ll MUL( ll a, ll b )
{
	return ( ( a % MOD ) * ( b % MOD ) ) % MOD;
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a , POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ) + 1; ++i )
		if ( x % i )
			return false;
	return true;
}

const int MAXN = 1e5 + 10;

int n, m;
int A[ MAXN ];
multiset < int > ms;

int main()
{
	cin >> n >> m;
	FOR( i, 0, n )
	{
		cin >> A[ i ];
		ms.insert( A[ i ] );
	}
	
	FOR( i, 0, m )
	{
		int maxi = *ms.rbegin();
		ms.erase( ms.find( maxi ) );
		ms.insert( maxi / 2 );
	}
	
	ll sol = 0;
	for ( multiset < int >::iterator it = ms.begin();it != ms.end();it++ )
	{
		sol += (ll)*it;
	}
	
	cout << sol << "\n";
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} init;

int main() {
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    if (k == 0) res = n * n;
    else {
        rep(b, k + 1, n + 1) {
            ll tmp = (n / b) * (b - k);
            if (n % b != 0) tmp += max(0LL, (n % b) - k + 1);
            res += tmp;
        }
    }
    print(res);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll n;
    cin >> n;
    vl a(n);
    for(auto &it: a) cin >> it;
    ll ct;
    ll mxc = 0;
    for(int i = 0; i < n - 1; ++i) {
        ct = 0;
        ll j = i + 1;
        while(j < n && a[i] >= a[j]) {
            ++ct;
            ++j;
            ++i;
        }
        mxc = max(ct, mxc);
    }
    cout << mxc;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int INF = 1 << 30;
const int MAXN = 1e5+10;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(b*2 < a)
        cout << a-2*b << endl;
    else
        cout << 0 << endl;
    return 0;
}


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

const ll MAXN = 200000;

ll N, M, tmp=0;
map<ll, pair<ll, ll>> MP;
map<ll, ll> MP1;
vector<string> ans;
signed main(){
    cin >> N >> M;
    ans.resize(M);
    for(int i=0;i<M;i++) {
        ll p, y;
        cin >> p >> y;
        MP[y] = make_pair(p, i);
    }
    for(map<ll, pair<ll, ll>>::iterator itr=MP.begin();itr!=MP.end();itr++) {
        pair<ll, pair<ll, ll>> pp = *itr;
        MP1[pp.second.first]++;
        string s1 = to_string(pp.second.first);
        while(s1.size()<6) {
            s1 = "0"+s1;
        }
        string s2 = to_string(MP1[pp.second.first]);
        while(s2.size()<6) {
            s2 = "0"+s2;
        }
        ans[pp.second.second] = s1+s2;
    }
    for(int i=0;i<ans.size();i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, d1, d2;
    cin >> n >> d1 >> d2;
    vector<int> color(4 * n * n);
    auto work = [&](int d, int w) {
        vector<vector<int>> e(4 * n * n);
        vector<pair<int, int>> moves;
        for (int x = -2 * n; x <= 2 * n; ++x)
            for (int y = -2 * n; y <= 2 * n; ++y)
                if (x * x + y * y == d)
                    moves.emplace_back(x, y);
        for (int x = 0; x < 2 * n; ++x) {
            for (int y = 0; y < 2 * n; ++y) {
                for (auto move : moves) {
                    int _x = x + move.first;
                    int _y = y + move.second;
                    if (_x >= 0 && _x < 2 * n && _y >= 0 && _y < 2 * n)
                        e[2 * x * n + y].push_back(2 * _x * n + _y);
                }
            }
        }
        vector<int> c(4 * n * n, -1);
        function<void(int)> dfs = [&](int u) {
            for (int v : e[u]) {
                if (c[v] == -1) {
                    c[v] = c[u] ^ 1;
                    dfs(v);
                }
            }
        };
        for (int i = 0; i < 4 * n * n; ++i) {
            if (c[i] == -1) {
                c[i] = 0;
                dfs(i);
            }
        }
        for (int i = 0; i < 4 * n * n; ++i)
            color[i] |= c[i] * w;
    };
    work(d1, 1);
    work(d2, 2);
    int cnt[4] {};
    for (int i = 0; i < 4 * n * n; ++i)
        ++cnt[color[i]];
    int c = max_element(cnt, cnt + 4) - cnt;
    for (int i = 0, j = 0; i < n * n; ++j) {
        if (color[j] == c) {
            cout << j / (2 * n) << " " << j % (2 * n) << "\n";
            ++i;
        }
    }
    return 0;
}

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

// bitの右からi+1番目が1かどうか
bool isBitI1(int bit, int i){
    return ((bit >> i) & 1) == 1;
}

int main(){
    int D,G;
    cin >> D >> G;

    // この種の配列初期化はスタック領域にメモリが確保されるから，メモリ確保に失敗する場合もあるので
    // あまり競プロでは使わないかも
    // グローバル領域に定数サイズで取得してしまうか，std::vectorを使うのが一般的
    int p[D], c[D];
    for(int i = 0; i<D; i++){
        cin >> p[i] >> c[i];
    }

    int min = 123456;
    int total, solved, rem;
    for (int bit = 0; bit < (1 << D); bit++){
        total = 0;
        solved = 0;
        for(int i = 0; i < D; i++){
            if(isBitI1(bit, i)){
                total += (i+1)*100 * p[i] + c[i];
                solved += p[i];
            }
        }

        if(total >= G){
            min = std::min(solved, min);
            continue;
        }
        rem = G - total;

        int i = D - 1;
        while(isBitI1(bit, i)) i--;
        int point = (i + 1) * 100;
        int n_solve = (rem + point - 1) / point;
        if (n_solve < p[i]) {
            min = std::min(solved + n_solve, min);
        }
    }

    cout << min << endl;
}


Measured memory_bytes: 888