akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(uniqu7e(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << "Yes" << endl; exit(0);}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
 VLL A(n);
 INPUT(A);
 LL length = 0;
 REPx(x, A) length += x;
 LL tmp = 0;
 LL ans = INF;
 REP(i, n)
 {
 	tmp += A[i];
 	if (tmp >= length/2)
 	{
 		chmin(ans, abs(tmp - (length-tmp)));
 		chmin(ans, abs(tmp-A[i] - (length-(tmp-A[i]))));
 		break;
 	}
 }
 cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100005],ans,r[100005],f[100005];
int g(int a,int b){
    return b?g(b,a%b):a;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        r[i+1]=g(r[i],a[i]);
    }
    for(int i=n-1;i>0;i--){
        f[i]=g(f[i+1],a[i]);
    }
    for(int i=0;i<n;i++)ans=max(ans,g(r[i],f[i+1]));
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
/*
		int a;
		do{
			System.out.print("窓の長さ:");
			a = stdIn.nextInt();
		}while(!(a>=1 && a<=100));

		int b;
		do {
			System.out.print("カーテンの長さ:");
			b = stdIn.nextInt();
		}while(!(b>=1 && b<=100));

		int c = b *= 2; //両カーテンの長さの合計

		if(a-y)
		System.out.println("カーテンで隠れていない部分の横方向の長さは"+(a-c)+"です。");

		else {
			System.out.println(0);
		}
	*/
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		if(a>=b*2) {
			System.out.println(a-b*2);
		}else {
			System.out.println(0);
		}
		
		
		

	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#define x first.first
#define y first.second
#define r second.first
#define color second.second

using namespace std;

typedef pair<double,double> P;
typedef pair<P,P> C;

bool check(C a,C b){
  return a.r+b.r>sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
 
int count(int bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits =(((bits >> 4) + bits) & 0x0f0f0f0f);
  bits += bits >> 8;
  return (bits + (bits >> 16)) & 0xff;
}
 
bool dp[(1<<25)];
 
int main(void){
 
	int n;
	while(cin >> n,n){
		C c[25];
		for(int i=0;i<n;i++)
			scanf("%lf %lf %lf %lf",&c[i].x,&c[i].y,&c[i].r,&c[i].color);
		
		fill(dp,dp+(1<<n),false);
		dp[(1<<n)-1]=true;
		int ans=0;
		
		for(int S=(1<<n)-1;S>=0;S--){
			if(!dp[S])continue;
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					
					int nx=S;
					nx&=~(1<<i) & ~(1<<j);
					if(dp[nx])continue;
					
					if(!(S>>i&1) || !(S>>j&1))continue;
					if(c[i].color!=c[j].color)continue;
					
					bool fg=false;
					for(int k=0;k<n;k++){
						if(!(S>>k&1))continue;
						fg|= k<i && check(c[i],c[k]);
						fg|= k<j && check(c[j],c[k]);
						if(fg)break;
					}
					
					if(!fg)dp[nx]|=dp[S];
				}
			}
			if(dp[S])ans=max(ans,n-count(S));
		}
		cout << ans << endl;
	}
   
  return 0;
}

Measured memory_bytes: 19688
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 10010;
const int MAXP = 10000000;
const u64 MOD = 998244353;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int b[11] = {0,2,5,5,4,5,6,3,7,6};
int u[11];

bitset<10010> F[5010];

void print(int i, int j)
{
	if (i == 0) return;
	for (int x = 9; x >= 1; -- x) if (u[x])
		if (i-b[x] >= 0 && F[j-1][i-b[x]])
		{
			printf("%d", x);
			print(i-b[x], j-1);
			break;
		}
}

int main()
{
	
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i)
	{
		int x;
		scanf("%d", &x);
		u[x] = 1;
	}
	F[0][0] = 1;
	for (int j = 0; j <= 5000; ++ j)
		for (int x = 1; x <= 9; ++ x) if (u[x])
			F[j+1] |= F[j]<<b[x];
	int ans = 0;
	for (int j = 5000; j >= 0; -- j)
		if (F[j][n])
		{
			ans = j;
			break;
		}
	print(n, ans);
	
	return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int64_t K, N, d = -1;
    cin >> K >> N;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for (int i = 0; i < N - 1; i++){
        d = max(d, A.at(i + 1) - A.at(i));
    }
    d = max(d, K - A.at(N - 1) + A.at(0));
    cout << K - d << endl;
 
}


Measured memory_bytes: 1920
import std.stdio,
       std.conv,
       std.array,
       std.string;

void main() {
  int n = to!int(chomp(readln()));
  while(n--) {
    string[] l = split(readln());
    int a = to!int(l[0]);
    int b = to!int(l[1]);
    int c = to!int(l[2]);
    if(a*a==b*b+c*c
     ||b*b==c*c+a*a
     ||c*c==a*a+b*b) {
      writeln("YES");
    }
    else {
      writeln("NO");
    }
  }
}

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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

void cominit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i=2; i<MAX; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll com(ll n, ll k)
{
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll modpow(ll a, ll n)
{
  ll res=1;
  while (n>0) {
    if (n&1) res = res*a % mod;
    a = a*a % mod;
    n >>= 1;
  }
  return res;
}

void solve()
{
  cominit();
  ll n,a,b,c; cin>>n>>a>>b>>c;

  ll pa = a * inv[a+b] % mod;
  ll pb = b * inv[a+b] % mod;

  ll ans = 0;
  for (int i=0; i<n; i++) {
    ans += modpow(pa,n) * modpow(pb,i) % mod * com(n-1+i, i) % mod * (i+n) % mod;
    ans += modpow(pb,n) * modpow(pa,i) % mod * com(n-1+i, i) % mod * (i+n) % mod;
    ans %= mod;
  }
  ans = ans * inv[a+b] % mod * 100LL % mod;
  cout << ans << endl;
}

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


Measured memory_bytes: 12160
package main

import "fmt"

func main() {
	var x int
	var a int

	_, err := fmt.Scan(&x, &a)
	if err != nil {
		fmt.Println("fmt Scan error:", err)
		return
	}

	if x < a {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n, x;
  cin >> n >> x;
  vi l(n);
  rep(i,n) cin >> l[i];
  int d = 0;
  int ans = 0;
  while(d <= x && ans < n+1) {
    d += l[ans];
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N, K = map(int, input().split())
    if N == 0:
        exit()
    A = [int(input()) for _ in range(N)]
    S = sum(A[:K])

    ans = S
    for i in range(K, N):
        S = S-A[i-K]+A[i]
        ans = max(ans, S)
    print(ans)


def solve2():
    N, K = map(int, input().split())
    if N == 0:
        exit()
    else:
        A = [int(input()) for _ in range(N)]
        A = [0]+list(accumulate(A))
        ans = max([A[i+K]-A[i] for i in range(N-K)])
        print(ans)


while True:
    solve2()



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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  ll res = 0;
  for(int i = 1; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0)res += (ll)i;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3652
def main
  problem_num = gets.chomp.to_i
  difficulty = gets.chomp.split(' ').map(&:to_i).sort

  # difficulty[(problem_num)/2-1]<Z<=difficulty[(problem_num)/2]

  print(difficulty[problem_num / 2] - difficulty[problem_num / 2 - 1])
end

main


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct LowLink{
    const vector<vector<int>> &g;
    vector<int> used,ord,low;
    vector<int> articulation;
    vector<pair<int,int>> bridge;
    LowLink(const vector<vector<int>> &g):g(g){}
    int dfs(int pre,int now,int k){
        used[now]=1;
        ord[now]=k++;
        low[now]=ord[now];
        bool is_articulation=false;
        int cnt=0;
        for(auto &to:g[now])if(to!=pre){
            if(!used[to]){
                cnt++;
                k=dfs(now,to,k);
                low[now]=min(low[now],low[to]);
                is_articulation|=(pre>=0 and low[to]>=ord[now]);
                if(ord[now]<low[to]) bridge.push_back(minmax(now,to));
            }else{
                low[now]=min(low[now],ord[to]);
            }
        }
        is_articulation|=(pre==-1 and cnt>1);
        if(is_articulation) articulation.push_back(now);
        return k;
    }
    void build(){
        used.assign(g.size(),0);
        ord.assign(g.size(),0);
        low.assign(g.size(),0);
        int k=0;
        for(int i=0;i<(int)g.size();i++)if(!used[i]) k=dfs(-1,i,k);
    }
    bool isBridge(int u,int v){
        if(ord[u]>ord[v]) swap(u,v);
        return ord[u]<low[v];
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,m;cin>>n>>m;
    vector<vector<int>> g(n);
    rep(i,m){
        int u,v;cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    LowLink L(g);
    L.build();

    sort(ALL(L.articulation));
    for(auto x:L.articulation) cout<<x<<endl;

    return 0;
}



Measured memory_bytes: 4664
import sys
sys.setrecursionlimit(500000)
N = int(input())
Node = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    Node[a].append(b)
    Node[b].append(a)
Route = [1]
def dfs(n, np):
    for nc in Node[n]:
        if nc == np:
            continue
        elif nc == N:
            Route.append(N)
            return True
        else:
            Route.append(nc)
            if dfs(nc, n):
                return True
            else:
                Route.pop()
    return False

dfs(1, 0)
b = (len(Route)+1)//2
Node[Route[b-1]].remove(Route[b])
Node[Route[b]].remove(Route[b-1])

cnt = 0
def dfs2(n, np):
    global cnt
    for nc in Node[n]:
        if nc == np:
            continue
        else:
            cnt += 1
            dfs2(nc, n)

dfs2(1, 0)
cnt = -cnt
dfs2(N, 0)
if cnt >= 0:
    print("Snuke")
else:
    print("Fennec")


Measured memory_bytes: 110400
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const int MAX = 200002;
ll fact[MAX], invfact[MAX];

int mod = 1e9 + 7;

map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

ll mod_pow(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}

	return res;
}

ll mod_inverse(ll a, ll m) {
	return mod_pow(a, m - 2, m);
}

ll nCr(ll n, ll r) {
	return fact[n] * invfact[r] % mod * invfact[n - r] % mod;
}

void init() {
	fact[0] = invfact[0] = 1;
	rep(i, 1, MAX) {
		fact[i] = (fact[i - 1] * i) % mod;
		invfact[i] = mod_inverse(fact[i], mod);
	}
}

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

	int N, M;
	cin >> N >> M;

	map<int, int> m = prime_factor(M);

	init();
	ll rsl = 1;
	for(map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
		(rsl *= nCr(it->second + N - 1, N - 1) % mod) %= mod;
	}

	cout << rsl << endl;


}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int Q;
	cin >> Q;
	while(Q--){
		long long A,B;
		long long int s,tmp,ans;
		cin >> A >> B;
		s = A*B ;
		tmp = (long long int)sqrt(s);
		if( tmp*tmp < s ){
			if(tmp*(tmp+1)< s) ans = tmp*2;
			else ans = tmp*2 -1;
			if(A <= tmp || B <= tmp) ans--;
		}
		else{
			if( (tmp-1) * tmp <s) ans = (tmp-1)*2;
			else ans = tmp*2 -1;
			if(A <= (tmp-1) || B <= (tmp-1)) ans--;
		}
        cout << ans << endl;
	}
}


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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  bool ans = false;
  
  for (int i = 0;i < k;i++){
    int j = k-i;
    int bb = b;
    int cc = c;
    for (int n = 0;n < i;n++){
      bb *= 2;
    }
    for (int m = 0;m < j;m++){
      cc *= 2;
    }
    if (a < bb && bb < cc){
      ans = true;
    }
  }
  
  if (ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e7+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{

	  ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n;
    cin>>n;
    int cnt=0;
    int x;
    for(int i=1;i<=n;i++){
      cin>>x;
      if(i%2 && x%2)
        cnt=cnt+1;
    }
    cout<<cnt;
}

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

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

    if(a==0)  cout<<"1"<<endl;
    else if(b==0) cout<<"2"<<endl;
    else if(c==0) cout<<"3"<<endl;
    else if(d==0) cout<<"4"<<endl;
    else if(e==0) cout<<"5"<<endl;



}




Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string.h>
#include <string>

using namespace std;
int main()
{
	char s[15];
	int ans = 0;
	cin >> s;
	for (int i = 0; i < 15; i++) {
		if (s[i] == 'o') {
			ans++;
		}
		if (s[i] == NULL) {
			ans++;
		}
	}
	if (ans >= 8) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
#define ld long double
int const M=2e5+10,inf=1e9+10,mod=1e9+7,M2=1e6+10,sq=447;
pii cur[M];
int fnd(int x)
{
	int now=0,sm=0;
	for(int i=18;i>=0;i--)
	{
		int ind;
		for(int j=0;j<=9;j++)
		{
			if(sm+j+i*9>=x)
			{
				ind=j;
				break;
			}
		}
		sm+=ind;
		now*=10,now+=ind;
	}
	return now;
}
int fnd(int now,int lim)
{
	bool ok=0;
	vector<int>dig;
	while(lim!=0)dig.pb(lim%10),lim/=10;
	while(dig.size()<19)dig.pb(0);
	int sm=0,ans=0;
	for(int i=18;i>=0;i--)
	{
		int ind;
		//cout<<dig[i]<<"****"<<endl;
		for(int j=0;j<=9;j++)
		{
			if(j<dig[i] && !ok)continue;
			if(j+sm+i*9>=now)
			{
				ind=j;
				break;
			}
		}
		//cout<<ind<<"************"<<" "<<ans<<endl;
		sm+=ind;
		ans*=10,ans+=ind;
		if(ind>dig[i])ok=1;
	}
	return ans;
}
bool cmp(pii a,pii b)
{
	int tmp=a.F*b.S;
	int tmp2=a.S*b.F;
	if(tmp!=tmp2)return tmp<tmp2;
	return a.F<b.F;
}
int sm(int x)
{
	int now=0;
	while(x!=0)now+=x%10,x/=10;
	return now;
}
int32_t main()
{
	int k;
	cin>>k;
	for(int i=1;i<=9*16;i++)
	{
		cur[i].F=fnd(i);
		cur[i].S=i;
		//cout<<i<<" "<<cur[i].F<<endl;
	}
	//cout<<fnd(10,10)<<"************"<<endl;
	//return 0;
	//cout<<sm(109)<<endl;
	sort(cur,cur+9*16+1);
	int cnt=0;
	int last=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=9*16;j++)
		{
			cur[j].F=fnd(j,last+1);
			cur[j].S=j;
		}
		sort(cur+1,cur+9*16,cmp);
		cout<<cur[1].F<<endl;
		last=cur[1].F;
	}
}

Measured memory_bytes: 256
import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        N, K = map(int, self.input_data().split())
        p = list(map(int, self.input_data().split()))

        p.sort()

        result = 0
        for i in range(K):
            result += p[i]

        print(str(result))

solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 9980
#include<cstdio>
using namespace std;
int main(){
  int a,b,c,d;
  bool flag=true;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  while(true){
  	if(flag){
    	if(c-b>0){
        c=c-b;
          flag=false;
        }
      else{printf("Yes");return 0;}
    }
    else{
    if(a-d>0){
    a=a-d;
      flag=true;
    }
      else{printf("No");return 0;}
    }
  }
}


Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  string a;
  cin >> a;
  
  
  if(a[0]=='9'){
    cout << "Yes" << endl;
  }else if(a[1]=='9'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n, k) for(int i=k; i<n; ++i)
#define drep(i, n, k) for(int i=k; i>=n; --i)
#include<math.h>
using namespace std;

int main(){
  int n, st, sum, ans = 0;
  cin >>  n >> st;
  
  int  x[n][st];
  rep(i, n, 0){
    rep(j, st, 0) cin >> x[i][j];
  }
  
  rep(i, n, 0){
    rep(j, n, i+1){
      sum = 0;
      rep(k, st, 0){
        sum += pow((x[i][k]-x[j][k]), 2);
      }
      int root = sqrt(sum);
      if(sum == pow(root, 2)) ans++;
    }
  }
  cout << ans << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

using P = pair<i64, bool>;

int main() {
    i64 N, H; cin >> N >> H;

    priority_queue<P> pq;
    REP(i, N) {
        i64 a, b; cin >> a >> b;
        pq.push(P(a, true));
        pq.push(P(b, false));
    }

    i64 cnt = 0;
    i64 i = 0;
    while (H > 0) {
        P p = pq.top(); pq.pop();
        if (p.second) {
            i64 n = (H / p.first + (H % p.first > 0));
            H -= p.first * n;
            cnt += n;
        } else {
            H -= p.first;
            cnt++;
            i++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

char a[501][501];
int n; 
vector<int> adj[1051];
int dist[1051];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	bool allempty = 1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='#') allempty=0;
		}
	}
	if(allempty)
	{
		cout<<-1<<'\n';
		return 0;
	}
	int fullcol = 0;
	for(int j = 0; j < n; j++)
	{
		bool full=1;
		for(int i=0;i<n;i++)
		{
			if(a[i][j]=='.')
			{
				full=0;
				break;
			}
		}
		if(full) fullcol++;
	}
	if(fullcol==n)
	{
		cout<<0<<'\n'; return 0;
	}
	int minans = 1000000;
	for(int i = 0; i < n; i++)
	{
		//find min steps to make row i full
		int cntemp = 0;
		for(int j = 0; j < n; j++)
		{
			if(a[i][j]=='.') cntemp++;
		}
		if(cntemp==0)
		{
			minans=0; break;
		}
		bool pos=0;
		for(int j = 0; j < n; j++)
		{
			if(a[j][i]=='#')
			{
				pos=1;
			}
		}	
		if(!pos)
		{
			cntemp++;
			pos=1;
		}
		if(pos)
		{
			minans=min(minans,cntemp);
		}
	}
	minans+=n-fullcol;
	cout<<minans<<'\n';
}


Measured memory_bytes: 512
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


V,E = map(int,input().split())

boss = [i for i in range(V)]
height = [0 for i in range(V)]

def get_boss(index):
    if index == boss[index]:
        return index
    else:
        boss[index] = get_boss(boss[index])
        return boss[index]


def is_same_group(a,b):
    return get_boss(a) == get_boss(b)

def unite(x,y):
    boss_x = get_boss(x)
    boss_y = get_boss(y)

    if boss_x == boss_y:
        return

    if height[x] > height[y]:

        boss[boss_y] = boss_x

    elif height[x] < height[y]:

        boss[boss_x] = boss_y

    else:
        boss[boss_y] = boss_x
        height[x] += 1


for loop in range(E):
    A,B = map(int,input().split())
    unite(A,B)

num_query = int(input())

for loop in range(num_query):
    A,B = map(int,input().split())
    if is_same_group(A,B) == True:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 11184
#include <stdio.h>

int main() {
  int n;
  char S[101], T[101];
  scanf("%d", &n);
  scanf("%s %s", S, T);
  for (int i = 0; i < n; i++) {
    putchar(S[i]);
    putchar(T[i]);
  }
  putchar('\n');
  return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> d(k);
  vector<int> sun(n,0);
  vector<int> a(110);
  for(int i=0;i<k;i++){
    cin >> d[i];
    for(int j=0;j<d[i];j++){
      cin >> a[j];
      sun[a[j]-1]++;
    }
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(sun[i]==0) cnt++;
  }
  cout << cnt;
}


Measured memory_bytes: 3636
n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

def tt(num)
  r = 0
  while num % 2 == 0
    r += 1
    num /= 2
  end
  r
end

t = tt(a.first)
1.upto(n-1) do |i|
  if tt(a[i]) != t
    p 0
    exit
  end
end

l = a.map{|e| e/2}.inject(:lcm)
p (m / l / 2.0).ceil


Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll dp[100000];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll h, n;
	cin >> h >> n;
	ll a[n], b[n];
	zep(i, 0, n){
		cin >> a[i] >> b[i];
	}
	
	
	dp[0] = 0;
	rep(i, 1, 100000-1){
		dp[i] = INF;
	}

	zep(i, 0, h){
		zep(j, 0, n){
			dp[i+a[j]] = min(dp[i]+b[j], dp[i+a[j]]);
		}
		rrep(j, i+10000, i){
			dp[j] = min(dp[j+1], dp[j]);
		}
	}
	print(dp[h])
	return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  final static Long MAX = 1000000000000000000L;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.nextLine();
    List<Long> l = new ArrayList<Long>();
    for(int i = 0;i < n;i++) {
      l.add(sc.nextLong());
    }
    sc.close();

    if(l.contains(0L)) {
      System.out.println(0);
    }else {

      Long sum = 1L;

      for(Long l2:l) {
        if(sum > MAX/l2) {
          System.out.println(-1);
          return;
        }
        sum *= l2;
      }
      System.out.println(sum);
    }


  }

}


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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int l,r,d;
  cin>>l>>r>>d;
  int f=0;
  for(int i=l;i<=r;i++){
    if(i%d==0){
      f++;
    }
  }
  cout<<f<<endl;

}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	string a, aa, aaa;
	cin >> a >> aa >> aaa;
	char l1 = a[0];
	char l2 = aa[0];
	char l3 = aaa[0];
	l1-=32;
	l2-=32;
	l3-=32;
	cout << l1 << l2 << l3 << "\n";
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,k;
  cin >> n >> k;

  ll p[n];
  for(ll i=0;i<n;i++)cin >> p[i];
  ll s=0,m=0;
  for(ll i=0;i<k;i++)s+=p[i];
  m=max(m,s);

  for(ll i=0;i<n-k;i++){
    s-=p[i];
    s+=p[i+k];
    m=max(m,s);
  }
  double r=m;
  printf("%f",(r+k)/2);



}

Measured memory_bytes: 5256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

  static class TaskA {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.nextInt();
      out.printLine(n * (n + 1) / 2);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      boolean isSpaceChar(int ch);

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(int i) {
      writer.println(i);
    }

  }
}



Measured memory_bytes: 22484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;

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

    while(scanf("%d%d%d%d",&a,&b,&c,&d) != EOF)
    {
        int t1 = max(a,c);
        int t2 = min(b,d);
        int ans = t2-t1;

        if(ans <= 0) printf("0\n");
        else printf("%d\n",t2-t1);
    }

    return 0;
}


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

typedef long long int LLI;
typedef pair<LLI, LLI> Pair;

int N;
LLI A[314514];
LLI B[314514];
vector<Pair> ps;

bool check(LLI K) {
  LLI sum = 0;
  LLI b;
  multiset<LLI> as;

  for (LLI i=0; i<K; i++) {
    as.insert(A[i]);
    sum += A[i];
    b = B[i];
  }

  if (sum <= K*b) return true;
  for (LLI i=K; i<N; i++) {
    sum -= *as.rbegin();
    as.erase(as.find(*as.rbegin()));
    as.insert(A[i]);
    sum += A[i];
    b = B[i];
    if (sum <= K*b) return true;
  }
  return false;
}

int main() {
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    scanf("%lld%lld", &A[i], &B[i]);
    ps.emplace_back(Pair(B[i], A[i]));
  }
  sort(ps.begin(), ps.end(), greater<Pair>());
  for (int i=0; i<N; i++) {
    A[i] = ps[i].second;
    B[i] = ps[i].first;
  }
  

  LLI low = -1;
  LLI high = N+1;
  while (high - low > 1) {
    LLI mid = (high+low)/2;
    if (check(mid)) low = mid;
    else high = mid;
  }
  printf("%lld\n", low);
}

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


int main(){
  int q;
  cin >> q;
  deque<int> dq;
  vector<int> ac;
  for(int i=0;i<q;++i){
    int x;
    cin >> x;
    if(x==0){
      int d,k;
      cin >> d >> k;
      if(d==0){
        dq.push_front(k);
      }else{
        dq.push_back(k);
      }
    }else if(x==1){
      int p;
      cin >> p;
      ac.push_back(dq[p]);
    }else{
      int d;
      cin >> d;
      if(d==0){
        dq.pop_front();
      }else{
        dq.pop_back();
      }
    }
  }
  for(int i=0;i<ac.size();++i){
    cout << ac[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 4584
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

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

// constant
// const ll MOD = 1e9 + 7;
// const ll INF = 1e12;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// --------------------------------------------------------


int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define MIN 1
int GetNumEqual( int *pNum );
void BubSort( int *pNum );

int main( void )
{
    int getNum[3] = {};
    
    for( int i = 0 ; i < 3 ; i++ )
    {
        if( 0 != GetNumEqual( getNum + i ) )
        {
            return 0;
        }
    }
    
    BubSort( getNum );
    
    return 0;
}

int GetNumEqual( int *pNum )
{
    int getNum;
    
    scanf( "%d" , &getNum );
    
    if( ( getNum >= MIN ) && ( getNum <= MAX ) )
    {
        *pNum = getNum;
        return 0;
    }
    
    return -1;
}

void BubSort( int *pNum )
{
    int value = 0;
    for( int i = 0 ; i < 3 ; i++ )
    {
       for( int j = 2 ; j > i ; j-- )
       {
           if( pNum[j] < pNum[j-1] )
           {
               value = pNum[j];
               pNum[j] = pNum[j-1];
               pNum[j-1] = value;
           }
       }
    }
    
    printf( "%d %d %d\n" , pNum[0] , pNum[1] , pNum[2] );
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	bool four = false;
	int i;
	cin >> N;
	for (i=0; i < N; i++){
		string s;
		cin >> s;
		if (s == "Y"){
			four = true;
		}
	}
	if (four == true){
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
}

Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline

def main():
  n = int(input())
  abs = [tuple(map(int, input().split())) for _ in range(n)]

  pq = []

  for ab in abs:
    a,b = ab[0],ab[1]
    heapq.heappush(pq, tuple([b,a]))

  dl = 0
  tc = 0

  ans = "Yes"

  for i in range(n):
    ba = heapq.heappop(pq)
    dl = ba[0]
    tc += ba[1]
    if dl < tc:
      ans = "No"
      break
  print(ans)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 99680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const int mod=1e9+7;
vector<int> v[500005];
map<vector<int>,ll> maps;


int main(){
	ios::sync_with_stdio(0);	
	cin.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(a>=b){
		b*=2;
		--k;
	}
	while(b>=c){
		c*=2;
		--k;
	}
	cout<<(k<0?"No":"Yes");
	return 0;
}


Measured memory_bytes: 15324
N = int(input())
As = [int(x) for x in input().split()]

Ss = [0]
nums = {0: 1}
for A in As:
    S = Ss[-1] + A
    Ss.append(S)
    if not S in nums:
        nums[S] = 0
    nums[S] += 1
ans = 0
for n in nums.values():
    ans +=  (n * (n - 1)) // 2

print(ans)


Measured memory_bytes: 38676
#include <bits/stdc++.h>
#define rint register int
using namespace std;
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 3e5 + 2333;
int n, a[N];
#define GG (puts("No"), exit(0))
inline void dfs(int l) {
  if (l == n + 1)
    return ;
  if (a[l] == l) {
    dfs(l + 1);
    return ;
  }
  // split l - r = a[l] - a[r]
  int r = l, mx = 0;
  while (r <= n) {
    mx = max(mx, a[r]);
    if (mx == r)
      break;
    ++ r;
  }
  if ((r - l) & 1) GG;
  // cout << l << " " << r << "\n";
  for (int i = l + 1; i <= r - 1; i += 2)
    if (a[i] != i) GG;
  // cerr << "233\n";
  
  vector<int> L, R;
  for (int i = l; i <= r; i += 2) {
    if (a[i] < i)
      L.push_back(a[i]);
    else
      R.push_back(a[i]);
  }
  // for (int i : L) cout << i << " "; puts("");
  // for (int i : R) cout << i << " "; puts("");
  for (int i = 0; i < (int) L.size() - 1; i ++)
    if (L[i] > L[i + 1]) GG;
  for (int i = 0; i < (int) R.size() - 1; i ++)
    if (R[i] > R[i + 1]) GG;
  dfs(r + 1);
}

main(void) {
  read(n);
  for (int i = 1; i <= n; i ++)
    read(a[i]);
  dfs(1);
  puts("Yes");
}


Measured memory_bytes: 67072
#double underscore makes a class variable or a class method private
mod = 1000000007
ii = lambda :  int(input())
si = lambda :  input()
dgl = lambda : list(map(int, input()))
f = lambda :   map(int, input().split())
il = lambda :  list(map(int, input().split()))
it = lambda :  tuple(map(int, input().split()))
ls = lambda :  list(input())
n=ii()
l=il()
mx=0
c=0
for i in range(1,n):
    if l[i]<=l[i-1]:
        c+=1
    else:
        mx=max(mx,c)
        c=0
print(max(mx,c))

Measured memory_bytes: 14480