akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

ll N, M;
ll A[1000000];
vector<pair<ll, ll>> CB;

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

    std::cin >> N >> M;
    REP(i, N) {
        std::cin >> A[i];
    }
    REP(i, M) {
        ll b, c;
        std::cin >> b >> c;
        CB.push_back(make_pair(c, b));
    }

    sort(A, A + N);
    sort(CB.begin(), CB.end(), std::greater<pair<ll, ll>>());

    REP(i, N) {
        bool rewrite_occored = false;
        for(auto &cb : CB) {
            if(cb.second == 0) {
                continue;
            }
            else if(A[i] < cb.first) {
                A[i]            = cb.first;
                rewrite_occored = true;
                cb.second--;
                break;
            }
        }

        if(!rewrite_occored) {
            break;
        }
    }

    ll ans = 0;
    REP(i, N) {
        ans += A[i];
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n,sum=0;
	cin >> n;
	vector<int> moti(n);
	for(int i=0;i<n;++i){
		cin >> moti[i];
	}
	sort(moti.begin(),moti.end());
	n = 200;
	for(int i : moti){
		if(n != i){
			++sum;
			n = i;
		}
	}
	cout << sum << endl;
}

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

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

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int valid = 1;
        for (int j = 0; j < i; ++j) {
            if(v[j] > v[i]) valid = 0;
        }
        ans += valid;
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {

    string s; cin >> s;
    reverse(s.begin(), s.end());

    int i = 0;
    while(i < s.size()) {

        string check = "";

        for (int j = 0; j < 5; j++) {
            check += s[i+j];
        }

        if (check == "maerd" || check == "esare") {
            i += 5;
            continue;
        }

        check += s[i+5];
        if (check == "resare") {
            i += 6;
            continue;
        }

        check += s[i+6];
        if (check == "remaerd") {
            i += 7;
            continue;
        }

        cout << "NO" << endl;
        exit(0);

    }

    cout << "YES" << endl;

}

Measured memory_bytes: 512
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		Console.WriteLine(Min(I[0] * I[1], I[2]));
	}
}


Measured memory_bytes: 13268
#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> 




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

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
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);
}




int main(){
  string S,T;
  cin>>S>>T;
  bool l=true;
  int x[26];
  for(int i=0;i<26;i++){
    x[i]=-1;
  }
  for(int i=0;i<S.size();i++){
    char s=S.at(i);
    char t=T.at(i);
    if(x[s-'a']==-1){
      x[s-'a']=t-'a';
      for(int j=0;j<26;j++){
        if(j==s-'a'){
          continue;
        }
        if(x[j]==t-'a'){
          l=false;
        }
      }
    }else{
      if(x[s-'a']==t-'a'){

      }else{
        l=false;
      }
    }

  }
  if(l){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }






  


}


  
  

Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<numeric>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int A[5];
	rep(i, 5)cin >> A[i];
	int num; cin >> num;
	if (A[4] - A[0] <= num)cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let q: usize = sc.read();
    for _ in 0..q {
        let a: i64 = sc.read();
        let b: i64 = sc.read();
        let ans = solve(a, b);
        println!("{}", ans);
    }
}

fn solve(a: i64, b: i64) -> i64 {
    if a == b {
        return (a - 1) + (b - 1);
    }
    let (a, b) = if a > b { (b, a) } else { (a, b) };

    let mut ok = 0;
    let mut ng = b + 1;
    while ng - ok > 1 {
        let m = (ok + ng) / 2;
        if get_max(a, b, m) >= a * b {
            ng = m;
        } else {
            ok = m;
        }
    }
    ok + (a - 1)
}

fn get_max(a: i64, b: i64, m: i64) -> i64 {
    let left = (a + 1) * m;
    let right = a + m;

    let t1 = (m - a - 1) / 2;
    let t2 = t1 + 1;
    let mut max = cmp::max(left, right);
    if 0 <= t1 && t1 < m {
        max = cmp::max(max, (m - t1) * (a + 1 + t1));
    }
    if 0 <= t2 && t2 < m {
        max = cmp::max(max, (m - t2) * (a + 1 + t2));
    }
    max
}

// 1 ... (a-1) [a] (a+1) ...
// 1 ... (b-1) [b] (b+1) ...

// (a-x)(a+x) < ab
// m     (m-1) ...  1
// (a+1) (a+2) ... (a+m)
// (m-x)(a+1+x) = -(x+a+1)(x-m) = -x^2 - (a+1-m)x +m(a+1)
// x = (m-a-1)/2

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll L, R;
    cin >> L >> R;
    if (2019 <= R - L) {
        std::cout << 0 << '\n';
        return 0;
    }
    ll ans = INF64;
    FOR(i, L, R + 1) {
        FOR(j, L, i) {
            ll a = (ll)i * j % 2019;
            chmin(ans, a);
        }
    }

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
/*input
10 40 6 8
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// int findans(double a,double b,double c){
// 	int temp = floor(b/c); 
// 	temp -= ceil((a)/c) ;
// 	return temp+1 ; 
// }
int findans(int A, int B, int M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
}
signed main() {
	IOS;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans = b-a+1;
	ans -= findans(a,b,c);
	ans -= findans(a,b,d);
	int C = c ; 
	int D = d ; 
	ans += findans(a,b,(C*D)/(__gcd((C),(D))));
	cout << ans << endl ; 
return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(in);
    int n = sc.nextInt();
		long[] t = new long[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextLong();
		}

		long ans = t[0];
		for (int i = 1; i < n; i++) {
			ans = lcm(ans, t[i]);
		}

		out.println(ans);
	}

	private static long lcm(long x, long y) {
		return x * (y / gcd(x, y));
	}

	private static long gcd(long x, long y) {
		if (x < y) {
			long tmp = x;
			x = y;
			y = tmp;
		}

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

		return y;
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  vector<pair<string, pair<int, int> > > data;
  int n;
  cin >> n;
  REP(i, n){
    string s;
    int p;
    cin >> s >> p;
    data.pb(mp(s, mp(-1*p, i+1)));
  } 
  sort(All(data));

  REP(i, n){
    cout << data[i].second.second << endl;
  }
}

Measured memory_bytes: 256
<?php
// $tmp = [];
while($line = fgets(STDIN)){
  $tmp[] = explode(" ",trim($line));
}

foreach($tmp as $v){
    if($v[0] == "0" && $v[1] == "0"){
        break;
    }
    $ptn = str_repeat("#.", $v[1]);
    for($i=0; $i<$v[0]; $i++){
        echo substr($ptn, $i % 2, $v[1]), PHP_EOL;
    }
    echo PHP_EOL;
}


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

int main() {
    int H, A;
    cin >> H >> A;
    int ans = 0;
    if (H % A == 0) ans = H / A;
    else ans = H / A + 1;
    cout << ans << endl;
}


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

const int INF = 1e9+7;

int n, m;
int dp[50001];
int c[50001];

int solve(int n) {
    if (dp[n] != INF) return dp[n];
    int res = INF;
    if (n == 0) res = 0;
    for (int i = 0; i < m; ++i) {
        if (n-c[i] >= 0) res = min(res, solve(n-c[i])+1);
    }
    return dp[n] = res;
}

int main() {

    cin >> n >> m;

    for (int i = 0; i <= n; ++i) dp[i] = INF;
    dp[0] = 0;

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

    cout << solve(n) << endl;

}

Measured memory_bytes: 5612
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int D, N;
	int ans = 0;
	cin >> D >> N;
	if (N != 100) {
		if (D == 0) {
			ans = N;
		}
		else if (D == 1) {
			ans = 100 * N;

		}
		else if (D == 2) {
			ans = 10000 * N;

		}
	}
	else if (N == 100) {
		if (D == 0) {
			ans = 101;
		}
		else if (D == 1) {
			ans = 10100;

		}
		else if (D == 2) {
			ans = 1010000;

		}
	}

	cout << ans << endl;
}



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

int main() {
   
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n,W;
	cin>>n>>W;
	ll w[n+1];ll v[n+1];
	for(int i=1;i<=n;i++){
	   cin>>w[i]>>v[i];
	}
	ll dp[n+1][W+1];
	dp[0][0]=0;
	for(int i=1;i<=n;i++) dp[i][0]=0;
	for(int i=1;i<=W;i++) dp[0][i]=0;
	for(int i=1;i<=n;i++){
	   for(int j=1;j<=W;j++){
	      if(w[i]>j){
	         dp[i][j]= dp[i-1][j]; 
	      }
	      if(w[i]<=j){
	         dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
	      }
	   }
	}
	cout<<dp[n][W];
}

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

#define DB(x) cerr << #x << " = " << (x) << " "
#define ENDL cerr << "\n"
#define FOR(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define DBA(x, a, b) { cerr << #x << " = "; for (int _ = (a); _ <= (b); _++) cerr << x[_] << ' '; ENDL }
#define DBS(x) { cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl; }

using namespace std;

template<typename T, typename U> static void rmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void rmax(T &x, U y) { if (x < y) x = y; }

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define mid ((left + right) >> 1)
#define lson rt << 1, left, mid
#define rson rt << 1 | 1, mid + 1, right

typedef long double ld;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;

int main() {
  ios::sync_with_stdio(false);
  LL a,b;
  cin>>a>>b;
  int cnt=1;
  while(a<=b){
    a*=2;
    cnt++;
  }
  cout<<cnt-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

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

int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */

    int n, t; scanf("%d %d", &n, &t);
    vector<int> a(n); for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a.begin(), a.end());
    vector<mint> dp(n);
    dp[0] = 1;
    for (int i = 1; i < n; i++) {
        int idx = lower_bound(a.begin(), a.end(), a[i] - t) - a.begin();
		dp[i] = dp[i - 1] * (i - idx + 1);
    }
	cout << dp[n - 1].x << "\n";
    return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    string s; cin >> s;
    int n = s.size();
    ll ans = 0;
    rep(bit,1<<(n-1)) {
        ll now = s[0]-'0';
        rep(i,n-1) {
            if (bit>>i&1) {
                ans += now;
                now = s[i+1]-'0';
            }
            else now = 10*now+(s[i+1]-'0');
        }
        ans += now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//vector< vector<int> > v (size1, vector<int>(size2) );

ll N,M;

vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i*i <= n; ++i) {
        if(i>M/N) break;
        if(n % i != 0) continue;
        res.push_back(i);
        //cout<<i<<endl;
        if(n/i == i) continue; // 上の行で追加済み。
        if(n/i<=M/N) res.push_back(n/i);
        //cout<<i<<endl;
    }
    return res;
}

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

    cin>>N>>M;

    vector<ll> v;
    v=divisors(M);

    VSORTR(v);
    
    cout<<v[0]<<endl;

    /*FOR(i,0,v.size()){
        if(v[i]<=M/N){
            cout<<v[i]<<endl;
            break;
        }
    } */
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    ll x;
    for (int i = 0; i < A; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < B; i++) {
        cin >> t[i];
    }
    for (int i = 0; i < Q; i++) {
        cin >> x;
        ll sl, sr, tl, tr;
        auto itS = lower_bound(s.begin(), s.end(), x);
        auto itT = lower_bound(t.begin(), t.end(), x);
        if (itS == s.end()) {
            sl = *s.rbegin();
            sr = 100000000000;
        } else if (itS == s.begin()) {
            sl = -100000000000;
            sr = *s.begin();
        } else {
            sr = *itS; --itS;
            sl = *itS;
        }

        if (itT == t.end()) {
            // cout << "T" << endl;
            // cout << t.size() << endl;
            tl = *t.rbegin();
            tr = 100000000000;
        } else if (itT == t.begin()) {
            tl = -100000000000;
            tr = *t.begin();
        } else {
            tr = *itT; --itT;
            tl = *itT;
        }
        // cout << sl << "," << sr <<","<< tl <<","<< tr << endl;

        ll ans1 = x - min(sl, tl);
        ll ans2 = max(sr, tr) - x;
        ll ans3 = 2 * (x - sl) + (tr - x);
        ll ans4 = 2 * (x - tl) + (sr - x);
        ll ans5 = 2 * (tr - x) + (x - sl);
        ll ans6 = 2 * (sr - x) + (x - tl);
        ll ans = min(ans1, min(ans2, min(ans3, min(ans4, min(ans5, ans6)))));
        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const int maxn=5e5+100;
int f[maxn],ans[maxn],cnt[maxn],tot[maxn],fn[maxn];
int getf(int v){
	return v==f[v]?v:f[v]=getf(f[v]);
}
void merge(int a,int b){
	int x=getf(a);
	int y=getf(b);
	if(x!=y) f[x]=y;
}
int main()
{
	int n,m,k; cin>>n>>m>>k;
	for(int i=1;i<=n;i++) f[i]=i;
	while(m--){
		int a,b;
		cin>>a>>b;
		merge(a,b);
		cnt[a]++; cnt[b]++;
	}
	while(k--){
		int a,b;
		cin>>a>>b;
		if(getf(a)==getf(b)){
			tot[a]++; tot[b]++;
		}
	}
	for(int i=1;i<=n;i++) f[i]=getf(i);
	for(int i=1;i<=n;i++) fn[f[i]]++;
	for(int i=1;i<=n;i++){
		ans[i]=fn[f[i]]-1-cnt[i]-tot[i];
	}
	for(int i=1;i<=n;i++){
		printf("%d%c",ans[i],n==i?'\n':' ');
	}
	return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	int N, K;
	string str;
	cin >> N >> K >> str;

	str[K - 1] -= 'A' - 'a';

	cout << str << endl;

	return 0;
}


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

int main() {
  int64_t H, W;
  cin >> H >> W;

  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }

  if (H % 2 == 0 || W % 2 == 0) {
    cout << W * H / 2 << endl;
    return 0;
  } else {
    cout << W * (H - 1) / 2 + (W + 1) / 2 << endl;
    return 0;
  }
}

Measured memory_bytes: 3616
n,a,b = map(int,input().split())

mod = 10**9+7

all_combi = pow(2,n,mod)




p = 1
q = 1

for i in range(b):
    
    p *= n-i
    p %= mod
    q *= i+1
    q %= mod
    
    if i==a-1:
        nca = p * pow(q,mod-2,mod) % mod
        
    if i==b-1:
        ncb = p * pow(q,mod-2,mod) % mod

        
ans = all_combi -nca -ncb -1
ans %= (10**9+7)
    
print(ans)

Measured memory_bytes: 64708
#include<bits/stdc++.h>
using namespace std;
const int maxn = 6020, mod = 1e9 + 7;
int n, m, k, dp[maxn][maxn], C[maxn][maxn];
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
void pre() {
	for(int i = 0; i < maxn; i++)
		for(int j = 0; j <= i; j++)
			if(!j) C[i][j] = 1;
			else {
				add(C[i][j], C[i-1][j-1]);
				add(C[i][j], C[i-1][j]);
			}
}
int nck(int i, int j) {
	if(i < j || j < 0) return 0;
	return C[i][j];
}

int solve(int n, int m, int k) {
	int ans = 0, l = (n+m-1)/(k-1);
	for(int i = 0; i <= l && m >= i*k; i++) {
		int t = nck(m+l-1 - i*k, l-1);
		t = t*1ll*nck(l, i)%mod;
		if(i&1) add(ans, mod-t);
		else add(ans, t);
	}
	return ans;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m >> k;
	pre();
	int ans = 0;
	while(true) {
		add(ans, solve(n, m, k));
		if(m >= k) m -= k-1;
		else break;
	}
	cout << ans;
	return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

  vector<ll> a(n),b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  ll ans=0;
  for(int d = 32; d >= 0; --d){
    REP(i,n) a[i] %= (1LL << (d + 1));
    REP(i,n) b[i] %= (1LL << (d + 1));
    sort(all(a));
    sort(all(b));

    ll cnt = 0;
    ll cur = 1LL << d;
    REP(i,n){
      cnt += lower_bound(all(b), 4*cur-a[i]) - lower_bound(all(b), 3*cur-a[i]);
      cnt += lower_bound(all(b), 2*cur-a[i]) - lower_bound(all(b), cur-a[i]);
    }
    if(cnt % 2 == 1) ans += cur;
  }

  pl(ans)
  return 0;

}

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

using namespace std;
using ll = long long;

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

int main() {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's')
    s += "es";
  else
    s += "s";
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, m, z = 0, b[12];
vector<pii> a;
string s[12], t[12];

void sol() {
    if (a.size() * 2 >= n - 1) {
        if (n % 2) {
            for (int i = 0; i < n; i++) if (!b[i]) {
                a.push_back({i, i});
                break;
            }
        }
        bool c[12][12] = {}, d[4100] = {1};
        for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) c[i][j] = 1;
        for (int i = 0; i < a.size(); i++) {
            //cout << s[a[i].first] << ' ' << s[a[i].second] << '\n';
            for (int j = 0; j < m; j++) for (int k = 0; k < m; k++) if (s[a[i].first][j] != s[a[i].second][k] || s[a[i].first][k] != s[a[i].second][j]) c[j][k] = 0;
        }
        for (int i = 1; i < (1 << m); i++) {
            for (int j = 0; j < m; j++) if (i & (1 << j)) {
                for (int k = j + 1; k < m; k++) if (i & (1 << k)) {
                    if (c[j][k]) d[i] |= d[i - (1 << j) - (1 << k)];
                }
            }
        }
        if (m % 2) {
            for (int i = 0; i < m; i++) if (c[i][i] && d[(1 << m) - 1 - (1 << i)]) {
                cout << "YES";
                exit(0);
            }
        } else {
            if (d[(1 << m) - 1]) {
                cout << "YES";
                exit(0);
            }
        }
        //for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) cout << c[i][j] << " \n"[j == m - 1];
        if (n % 2) {
            a.pop_back();
        }
        return;
    }
    int o = 0;
    for (int i = n - 1; i >= 0; i--) if (b[i] == 1) {
        o = i + 1;
        break;
    }
    for (int i = o; i < n; i++) if (!b[i]) {
        for (int j = i + 1; j < n; j++) if (!b[j]) {
            if (t[i] == t[j]) {
                a.push_back({i, j});
                b[i] = 1;
                b[j] = 2;
                sol();
                a.pop_back();
                b[i] = b[j] = 0;
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i], t[i] = s[i], sort(t[i].begin(), t[i].end());
    sol();
    cout << "NO";
}


Measured memory_bytes: 3688
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

int H, W, Ch, Cw, Dh, Dw;
char m[1015][1015];
int bid = 0, b[1015][1015];
bool vis[1015][1015];
vector<int> g[1000005];
map<int, int> mp[1000005];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
bool v[1000005];
int d[1000005];

inline bool check(int x, int y)
{
	if(x < 1 || x > H || y < 1 || y > W || vis[x][y] == 1 || m[x][y] == '#')
		return false;
	return true;
}

inline bool check1(int x, int y)
{
	if(x < 1 || x > H || y < 1 || y > W || m[x][y] == '#')
		return false;
	return true;
}

inline void dfs(int x, int y, int id)
{
	vis[x][y] = 1;
	b[x][y] = id;
	for(int i = 0;i < 4;++i)
	{
		int tx = x + dx[i], ty = y + dy[i];
		if(check(tx, ty))
			dfs(tx, ty, id);
	}
}

inline void bfs(int a, int b)
{
	for(int i = 1;i <= bid;++i)
		d[i] = -1;
	queue<int> q;
	q.push(a);
	v[a] = 1;
	d[a] = 0;
	while(!q.empty())
	{
		int f = q.front();q.pop();
		if(f == b)
		{
			printf("%d\n", d[f]);
			return;
		}
		int s = g[f].size();
		for(int i = 0;i < s;++i)
		{
			int t = g[f][i];
			if(v[t] == 1)
				continue;
			v[t] = 1;
			d[t] = d[f] + 1;
			q.push(t);
		}
	}
}

int main()
{
	cin >> H >> W;
	cin >> Ch >> Cw;
	cin >> Dh >> Dw;
	for(int i = 1;i <= H;++i)
		scanf("%s", m[i] + 1);
	for(int i = 1;i <= H;++i)
		for(int j = 1;j <= W;++j)
			if(!vis[i][j] && m[i][j] == '.')
				dfs(i, j, ++bid);
	int s = b[Ch][Cw], e = b[Dh][Dw];
	if(s == e)
	{
		printf("0\n");
		return 0;
	}

	for(int i = 1;i <= H;++i)
	{
		for(int j = 1;j <= W;++j)
		{
			if(m[i][j] == '#')
				continue;
			int B = b[i][j];
			for(int Dx = -2;Dx <= 2;++Dx)
				for(int Dy = -2;Dy <= 2;++Dy)
				{
					int ti = i + Dx, tj = j + Dy;
					if(!check1(ti, tj))
						continue;
					int tB = b[ti][tj];
					if(B == tB)
						continue;
					if(mp[B][tB] == 0)
					{
						g[B].push_back(tB);
						g[tB].push_back(B);
						mp[B][tB] = mp[tB][B] = 1;
					}
				}
		}
	}

	bfs(s, e);
	
	if(d[e] == -1)
		printf("-1\n");

	return 0;
}

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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int P;
  int f=0;
  int s=0;
  int t=0;
  for(int i=0;i<N;i++){
    cin >> P;
    if(P<=A){
      f++;
    }else if(P>=B+1){
      t++;
    }else{
      s++;
    }
  }
  cout << min({f,s,t}) << endl;
  return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>v;
void printDivisors(int n)
{
    for (int i=1;i<=sqrt(n);i++)
    {
        if (n%i == 0)
        {
            if (n/i == i){
                v.push_back(i);}
            else {
                v.push_back(i);
                v.push_back(n/i);}
        }
    }
}


int main()
{
    ll a,b,mx,mn;
    cin>>a>>b;
    mx=max(a,b);
    mn=min(a,b);
    printDivisors(mn);
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        ll z=v[i]*mx;
        if(z%mn==0)
        {
            cout<<z<<endl;
            break;
        }
    }
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n;
    cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    reverse(all(v));
    stack<pii>st;
    int psum = v.front();
    int ans = v.front();
    st.emplace(v.front(),0);
    for(int i = 1; i < n; ++i){
        while(not st.empty() and st.top().first > v[i]){
            auto top = st.top();
            st.pop();
            if(st.size() >= 1){
                psum -= top.first * (top.second - st.top().second );
            }
        }
        
        if(st.empty()){
            psum = v[i] * (i+1);
        } else {
            psum += v[i] * (i - st.top().second);
        }
        st.emplace(v[i],i);
        //cout << psum << endl;
        ans += psum;
    }
    cout << ans << endl;
}



Measured memory_bytes: 5120
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,p[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    s=to_string(n);
    rep(i,Size(s)){
        cnt+=s[i]-'0';
    }
    if(n%cnt==0)Cout("Yes");
    else Cout("No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void);

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

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

/* a < b < c を判定するためには、a < b && b < cと記述する必要あり。 */
    if (a < b && b < c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return(0);
}



Measured memory_bytes: 2120
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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 Main()
{
    LL n,x;cin>>n>>x;
    VL a(n);
    REP(i,n){
        cin>>a[i];
    }

    LL result = 0;
    REP(i,n){
        if(i==0){
            LL eat = max(0LL,a[i]-x);
            result+=eat;
            a[i]-=eat;
        }
        else{
            LL eat = max(0LL, a[i]+a[i-1]-x);
            result += eat;
            a[i]-=eat;

        }
    }
    cout<<result<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
  int x,y,p,q;
  int a[] = {1,3,5,7,8,10,12},b[]={4,6,9,11};
  cin>>x>>y;
  for(int i=0; i<7; i++){
    if(x==a[i]){
     p=0;
     break;
    }
  }
  for(int j=0; j<7; j++){
    if(y==a[j]) {
      q=0;
      break;
    }
  }
  for(int c=0; c<4; c++){
    if(x==b[c]) {
      p=1; 
      break;
    }
  }
   for(int d=0; d<4; d++){
    if(y==b[d]) {
      q=1; 
      break;
    }
  }
  if(x==2)p=2;
  if(y==2)q=2;
  if(p==q)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const int INF = 1e9;
const int maxN = 3e5 + 55;


ll fact[maxN], rev[maxN];

ll quickPow(ll x, ll y){
  if(y == 0){
    return 1;
  }

  ll tmp = quickPow(x, y / 2);
  if(y % 2){
    return (((tmp * tmp) % MOD) * (x % MOD)) % MOD;
  }

  return (tmp * tmp) % MOD;
}

void preCal(){
  fact[0] = 1;
  for(int i = 1; i < maxN; i++){
    fact[i] = (fact[i - 1] * i) % MOD;
  }

  for(int i = 0; i < maxN; i++){
    rev[i] = quickPow(fact[i], MOD - 2);
  }
}

ll nCk(ll N, ll K){
  ll ans = fact[N];
  ans = (ans * rev[K]) % MOD;
  ans = (ans * rev[N - K]) % MOD;

  return ans;
}

ll n, a, b, k;

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

  preCal();

  cin >> n >> a >> b >> k;

  ll fRes = 0;

  for(ll red = 0; red <= n; red++){
    //red * a + blue * b == k
    if((k - red * a) % b == 0){
      ll blue = (k - red * a) / b;
      if(0 <= blue && blue <= n){
        fRes = (fRes + ((nCk(n, red) * nCk(n, blue)) % MOD)) % MOD;
      }
    }
  }

  cout << fRes << '\n';

  return 0;
}


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

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  printf("%lf\n", sqrt(pow(x2-x1, 2)+pow(y2-y1, 2)));
  
  return 0;
}


Measured memory_bytes: 3268
use std::io;
use std::cmp::Ordering;

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

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

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

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

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

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

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

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

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let vec: Vec<f64> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    let r = vec[0];

    println!("{} {}", r*r*3.14159265358979, 2.*r*3.14159265358979);
}



Measured memory_bytes: 5064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        List<Integer> list = new ArrayList<>(Arrays.asList(new Integer[] { 4, 6, 9, 11 }));
        boolean isSameGroup = false;
        if (x == 2 || y == 2) {
            isSameGroup = false;
        } else if (list.contains(x) && list.contains(y)) {
            isSameGroup = true;
        } else if (!list.contains(x) && !list.contains(y)) {
            isSameGroup = true;
        }
        String result = isSameGroup ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
#include <stdio.h>

#define M 101
void init(int sz, int array[], int val);

int main(void)
{
    int n, N, d, stages = 0;
    int bucket[M];
    init(M, bucket, 0);
    scanf("%d", &N);

    for(n=0; n<N; n++){
        scanf("%d", &d);
        if(bucket[d]++ == 0)
            stages++;
    }

    printf("%d\n", stages);

    return 0;
}

void init(int sz, int array[], int val){
    int n;
    for(n=0; n<sz; n++){
        array[n] = val;
    }
}

Measured memory_bytes: 128
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

max_step = 0
for i in range(H * W):
    sy, sx = i // W, i % W
    if S[sy][sx] == "#":
        continue

    steps = [[-1] * W for _ in range(H)]
    steps[sy][sx] = 0
    queue = [(sy, sx)]
    while len(queue) >= 1:
        cy, cx = queue.pop(0)
        for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            ny, nx = cy + dy, cx + dx
            if not (0 <= ny <= H - 1 and 0 <= nx <= W - 1):
                continue
            if S[ny][nx] == "#" or steps[ny][nx] >= 0:
                continue
            queue.append((ny, nx))
            steps[ny][nx] = steps[cy][cx] + 1

    ms = max(max(r) for r in steps)
    max_step = max(ms, max_step)

print(max_step)

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

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

    int v1,v2,v3;

    v1 = N % 10;
    N -= v1;
    N /= 10;
    v2 = N % 10;
    N -= v2;
    v3 = N/10;

    if(v1!=7 && v2!=7 && v3!=7){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

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

using namespace std;

int n,m,i,j,a[100005];
long long s[200005];

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
		a[i]--;
	}
	
	long long tot = 0;
	
	for(i = 1; i < n; i++){
		int l = a[i - 1];
		int r = a[i];
		
		if(l <= r){
			s[l + 2]++;
			s[r + 1]--;
			s[r + 1] -= r - l - 1;
			s[r + 2] += r - l - 1;
		}
		else{
			r += m;
			s[l + 2]++;
			s[r + 1]--;
			s[r + 1] -= r - l - 1;
			s[r + 2] += r - l - 1;
		}
		
		tot += r - l;
	}
	
	for(i = 1; i < 2 * m; i++)
	s[i] = s[i - 1] + s[i];
	for(i = 1; i < 2 * m; i++)
	s[i] = s[i - 1] + s[i];
	
	long long res = 1e18;
	
	for(i = 0; i < m; i++)
	res = min(res, tot - (s[i] + s[i + m]));
	
	printf("%lld\n", res);
}


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

template<typename T> inline void setmax(T& a, const T& b) { if (b > a) a = b; }

int main() {
    cout.tie(0)->sync_with_stdio(0);
    int H, W, M; cin >> H >> W >> M;
    map<int, int> row, col;
    map<pair<int, int>, bool> mapa; 
    int maxrow = 0, maxcol = 0;
    for (int i = 0; i < M; ++i) {
        int A, B; cin >> A >> B;
        --A, --B;
        row[A]++;
        col[B]++;
        setmax(maxrow, row[A]);
        setmax(maxcol, col[B]);
        mapa[{A, B}] = true;
    }
    set<int> setrow, setcol;
    for (int i = 0; i < H; ++i) {
        int cur = row[i];
        if (maxrow == cur) setrow.insert(i);
    }
    for (int i = 0; i < W; ++i) {
        int cur = col[i];
        if (maxcol == cur) setcol.insert(i);
    }
    for (const int a : setrow) {
        for (const int b : setcol) {
            auto it = mapa.find({a, b});
            if (it != mapa.end()) continue;
            cout << maxcol + maxrow << '\n';
            exit(0);
        }
    }
    cout << maxrow + maxcol - 1 << '\n';
}


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

int main() {
  int n,d[50],ans=0; cin>>n;
  for (int i=0;i<n;i++){
    cin>>d[i];
  }
  for(int j=0;j<n-1;j++){
    for(int k=j+1;k<n;k++){
      ans+=d[j]*d[k];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
  int n;
  std::cin >> n;
  std::string str;
  std::cin >> str;
  std::string ans;
  int no_mach_cl = 0;
  int stack = 0;
  for (auto c : str) {
    if (c == '(') {      
      ++stack;
    }
    if (c == ')') {
      if (stack <= 0)
        ++no_mach_cl;
      else 
        --stack;
    }
  }
  ans = std::string(no_mach_cl, '(') + str + std::string(stack, ')');
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
//#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int K;
int A[200010];
int B[200010];

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
	}
	double M=0,m=0;
	REP(i,N){
		M+=(double)(A[i]+1)/2.0;
		if(K<=i){
			M-=double(A[i-K]+1)/2.0;
		}
		DEB(M)END
		m=std::max(m,M);
	}
	setdouble(10,m);cout<<endl;
	return 0;
}


Measured memory_bytes: 1792