akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl factorize(ll n) {
  vvl ret;
  for(ll i = 2; i * i <= n; i++) {
    ll c = 0;
    while(n % i == 0) n /= i, c++;
    if(c!=0) ret.push_back(vll{i, c});
  }
  if(n != 1) ret.push_back(vll{n, 1});
  return ret;
}

ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  if(p==-1){
    while(b>0){
      if(b%2) ret *= num;
      num = num * num;
      b /= 2;
    }
  }else{
    while(b>0){
      if(b%2) ret = (ret*num)%p;
      num = (num*num)%p;
      b /= 2;
    }
  }
  return ret;
}
ll gcd(ll a, ll b){
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
vll extgcd(ll a, ll b) {
  ll x, y;
  for (ll u = y = 1, v = x = 0; a;) {
    ll q = b / a;
    swap(x -= q * u, u);
    swap(y -= q * v, v);
    swap(b -= q * a, a);
  }
  return vll{x, y, b};
}

int main(){
  ll n;std::cin >> n;
  auto p = factorize(2LL * n);
  ll m = p.size();
  ll ans = 2*n;
  if(((n*(n+1))/2)%n==0) ans = n;

  for(int i=0;i<m;i++) p[i][0] = mpow(p[i][0], p[i][1]);
  for(ll i=1;i<(1<<m);i++){
    ll x = 1;
    for(ll j=0;j<m;j++){
      if((i>>j)&1){//use
        x *= p[j][0];
      }
    }
    ll y = (2*n)/x;
    //mod xでy=1
    if(x==1||y==1) continue;
    auto a = extgcd(y, x);// y, x
    swap(a[0], a[1]);

    if(a[0]>0){
      ll adnum = a[0]/y + 1;
      a[0] -= adnum * y, a[1] += adnum * x;
    }
    if(a[1]<0){
      ll ab = abs(a[1]);
      ll adnum = ab / x + 1;
      a[0] -= adnum * y, a[1] += adnum * x;
    }
    x *= a[0], y*=a[1];
    if(abs(y)-abs(x)==1) ans = min(ans, abs(x));
    //std::cout << x << " " << y << '\n';
  }
  std::cout << ans << '\n';
}


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

int main() {
    int n;
    string s, t, ans;
    cin >> n >> s >> t;

    for(int i=0; i<s.size(); i++) {
        ans = ans + s.at(i) + t.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include<bits/stdc++.h>
#define mod 100002
#define ll long long int
#define pb push_back
#define mk make_pair

using namespace std;


int main(){
   int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i]==(i+1)){
            int temp=a[i];
            a[i]=a[i+1];
            a[i+1]=temp;
            ans++;
        }
        else
            continue;
    }
    if(a[n-1]==(n))ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1], inv[1];
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}


int n;
int dist[100001];

int main() {
    memset(dist, 0x3f, sizeof(dist));

    int k;
    scanf("%d", &k);
    dist[1] = 1;
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push({1, 1});

    while (!pq.empty()) {
        pii tv = pq.top();
        pq.pop();

        if (dist[tv.second] != tv.first) continue;

        int next = tv.second + 1;
        next %= k;
        if (dist[next] > tv.first + 1) {
            dist[next] = tv.first + 1;
            pq.push({tv.first + 1, next});
        }

        next = tv.second * 10;
        next %= k;
        if (dist[next] > tv.first) {
            dist[next] = tv.first;
            pq.push({tv.first, next});
        }
    }

    printf("%d", dist[0]);
}

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

vector<string> a;
bool d(int i, int j) {
	int N = a[i].length();
	if (N != a[j].length())return false;
	for (int k = 0; k < N; k++) {
		if (a[i][k] != a[j][k])return false;
	}
	return true;
}

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		sort(s.begin(), s.end());
		a.push_back(s);
	}
	sort(a.begin(), a.end());
	long long sum = 0;
	long long c = 1;
	int i = 0, j = 1;
	while (j < N) {
		if (d(i, j)) {
			j++;
			c++;
		}
		else {
			i = j;
			j++;
			sum += c * (c - 1) / 2;
			c = 1;
		}
	}
	sum += c * (c - 1) / 2;
	cout << sum;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


int digitsum(int n){
    int s = 0;
    while (n > 0){
        s += n % 10;
        n /= 10;
    }
    return s;
}
signed main() {

    int n;
    cin>>n;
    if(n%digitsum(n)==0) Yes;
    else No;
    
    return 0;
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int h, n;
  cin >> h >> n;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  cout << (sum >= h ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
// Aizu Vol0 0095: Surf Smelt Fishing Contest
// 2017.7.30

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

#define MAX 20

int a[MAX + 5];

int main()
{
	int i, j, n;
	int no, v, max;
	
	scanf("%d", &n);
//	for (i = 0; i <= MAX; i++) a[i] = 0;
	max = 0;
	for (i = 0; i < n; i++) {
		scanf("%d%d", &no, &v);
		if (no > MAX) while (1);
		a[no] += v;
		if (a[no] > max) max = a[no];
	}
	for (j = 1; ; j++) {
		if (a[j] == max) {
			printf("%d %d\n", j, max);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	int n,W;
	cin>>n>>W;
	vi w(n),v(n);
	rep(i,0,n) cin>>w[i]>>v[i];
	int M=0;
	for(int i=0;i<n;i++) M+=v[i];
	vl dp(M+1,INT_MAX);
	//dp[i]->min capacity of knapsack required to get the value i....
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=M-v[i];j>=0;j--){
			dp[j+v[i]]=min(dp[j+v[i]],w[i]+dp[j]);
		}
	}
	ll ans=0;
	for(int i=0;i<=M;i++){
		if(dp[i]<=W) ans=max(ans,(ll)i);
	}
	cout<<ans;
	
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
 
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H')
		cout << b << endl;
	else if (b == 'H')
		cout << 'D' << endl;
	else
		cout << "H" << endl;

	return 0;
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 100010;

char str[MAXN];

int main()
{
	scanf("%s", str + 1);
	int n = strlen(str + 1);

	int ans = n;
	
	FOR(i, 1, n - 1) {
		if (str[i] != str[i + 1]) {
			chkmin(ans, Max(i, n - i));
		}
	}

	printf("%d\n", ans);
	
	return 0;
}


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

int n;
vector<int> x, y;
vector<bool> viewed;

double dist(int a, int b){
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b]));
}

bool dfs(int v, double t, int c){
    if(c == n) return true;

    for(int i=0;i<n;i++){
        if(viewed[i]) continue;
        if(t + dist(v, i) >= dist(i, n+1)) return false;
    }

    for(int i=0;i<n;i++){
        if(viewed[i]) continue;
        double nt = t + dist(v, i);
        if(nt < dist(i, n+1)){
            viewed[i] = true;
            if(dfs(i, nt, c+1)) return true;
            viewed[i] = false;
        }
    }

    return false;
}

int main(){
    while(1){
        cin >> n;
        if(n == 0) break;
        x.assign(n+2, 0);
        y.assign(n+2, 0);
        cin >> x[n] >> y[n] >> x[n+1] >> y[n+1];
        for(int i=0;i<n;i++){
            cin >> x[i] >> y[i];
        }
        viewed.assign(n, false);
        if(dfs(n, 0, 0)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

typedef pair<int, int> point;
#define X first
#define Y second

constexpr int NUMBER_OF_COLORS = 6;
constexpr int dx[] = {1, -1, 0, 0};
constexpr int dy[] = {0, 0, 1, -1};

int h, w, c;

inline bool out(int x, int y) {
	return x < 0 || x >= w || y < 0 || y >= h;
}

int calc(const vector<vector<int>> &panel) {
	queue<point> que;
	que.push({0, 0});

	const int color = panel[0][0];
	vector<vector<bool>> visited(h, vector<bool>(w, false));
	visited[0][0] = true;
	int res = 0;

	while(!que.empty()) {
		const auto cp = que.front();
		que.pop();

		++res;

		for(int d = 0; d < 4; ++d) {
			const int nx = cp.X + dx[d];
			const int ny = cp.Y + dy[d];

			if(out(nx, ny) || visited[ny][nx]) continue;
			if(panel[ny][nx] == color) {
				visited[ny][nx] = true;
				que.push({nx, ny});
			}
		}
	}

	return res;
}

vector<vector<int>> change(const vector<vector<int>> &panel, int to) {
	const int from = panel[0][0];
	vector<vector<int>> res(panel);
	if(from == to) return res;

	queue<point> que;
	que.push({0, 0});
	res[0][0] = to;

	while(!que.empty()) {
		const auto cp = que.front();
		que.pop();

		for(int d = 0; d < 4; ++d) {
			const int nx = cp.X + dx[d];
			const int ny = cp.Y + dy[d];

			if(out(nx, ny)) continue;
			if(res[ny][nx] == from) {
				res[ny][nx] = to;
				que.push({nx, ny});
			}
		}
	}

	return res;
}

int rec(const vector<vector<int>> &panel, int rest) {
	if(rest == 1) return calc(change(panel, c));

	int res = 0;
	for(int i = 0; i < NUMBER_OF_COLORS; ++i) {
		res = max(res, rec(change(panel, i), rest - 1));
	}
	return res;
}


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

	while(cin >> h >> w >> c && h) {
		--c;
		vector<vector<int>> panel(h, vector<int>(w));
		for(auto &row : panel) for(auto &e : row) cin >> e, --e;
		cout << rec(panel, 5) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    vector<int> v;
    int cnt = 1;

    while(true){
        
        int tmp = (cnt*(cnt+1)*(cnt+2))/6;
        if(tmp > 1000000) break;
        v.push_back(tmp);
        cnt++;
    }
    int s = v.size();
    int dp[1000005];
    int  odd[1000005];
    for(int i = 0; i < 1000005;i++){
        dp[i] = inf;
        odd[i] = inf;
    }
    dp[0] = 0;
    dp[1] = 1;
    odd[0] = 0;
    odd[1] = 1;
    for(int i = 0; i < 1000005; i++){
        for(int j = 0; j < v.size(); j++){
            if(i + v[j] < 1000005){
                dp[i+v[j]] = min(dp[i+v[j]],dp[i] + 1); 
                if(v[j] % 2 == 1){
                    odd[i+v[j]] = min(odd[i+v[j]],odd[i] + 1); 
                }
            }
        }
    }
    while(true){
        int x;  cin >> x;
        if(x == 0) break;
        cout << dp[x] << ' ' << odd[x] << endl;
    }
}


Measured memory_bytes: 10828
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

typedef pair<int, int> P;

ll powmod(ll a, ll p) {
	ll ans = 1;
	ll mul = a;
	for (; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
		if ((p & 1) == 1)ans = (ans * mul) % MOD;
	}
	return ans;
}

vll fact;//階乗
vll revFact;//階乗の逆元
void setFact(int N) {
	fact = vll(N);
	revFact = vll(N);
	fact[0] = 1;
	FOR(i, 1, N) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}
	revFact[N - 1] = powmod(fact[N - 1], MOD - 2);
	REPR(i, N - 1) {
		revFact[i] = revFact[i + 1] * (i + 1);
		revFact[i] %= MOD;
	}
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int fm = M;
	vi Prime;
	int s = sqrt(M) + 1;
	int r = 0;
	vector<P> VP;
	FOR(i, 2, s + 1) {
		if ((M % i) == 0) {
			r = 0;
			do {
				r++;
				M = M / i;
			} while ((M%i) == 0);
			VP.push_back(P(i, r));
		}
	}
	if (M > s) {
		VP.push_back(P(M, 1));
	}
	ll ans = 1;
	setFact(1000000);
	if (1 == fm) {
		cout << 1 << endl;
		return 0;
	}
	/*if (SZ(VP) == 0) {
		cout << N << endl;
		PAU;
		return 0;
	}
	*/
	REP(i, SZ(VP)) {
		int n = N;
		int k = VP[i].second;
		ans = (((ans*fact[n + k - 1]) % MOD * revFact[k]) % MOD) * revFact[n - 1] % MOD;
	}
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 16120
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
char ans[100][100];
inline void nxt(int &x,int &y)
{
    y+=2;
    if(y>=100)
    {
        x+=2;
        y=0;
    }
}
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<100<<" "<<100<<'\n';
    for(int i=0;i<100;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(i>=50) ans[i][j]='#';
            else ans[i][j]='.';
        }
    }
    int x=0,y=0;
    for(int i=1;i<b;i++,nxt(x,y))
        ans[x][y]='#';
    x=52,y=0;
    for(int i=1;i<a;i++,nxt(x,y))
        ans[x][y]='.';
    for(int i=0;i<100;i++)
    {
        for(int j=0;j<100;j++)
            cout<<ans[i][j];
        cout<<'\n';
    }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,k,a,i;
long dp[2<<17],mod=1e9+7;
main()
{
	cin>>n>>k;
	dp[k]=1;
	for(;cin>>a;i++)
	{
		for(int j=k;j--;)(dp[j]+=dp[j+1])%=mod;
		for(int j=0;j<k;j++)(dp[j]+=mod-dp[j+a+1])%=mod;
	}
	cout<<dp[0]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
    int cnt = 0;
    char c;
    const char *T = "CODEFESTIVAL2016";
    for (int i = 0; i < 16; i++) {
        cin >> c;
        if (c != T[i]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

int main(){
	int n;
	cin>>n;
	VI h(n);
	rep(i,n){
		cin>>h.at(i);
	}
	VI data(n,0);
	int cnt=0;
	for(int i=n-1;i>=0;i--){
		if(i==n-1){
			data.at(i)=0;
			continue;
		}
		if(h.at(i)>=h.at(i+1)){
			cnt++;
		}else{
			cnt=0;
		}
		data.at(i)=cnt;
	}

	int ans=-1;
	rep(i,n){
		chmax(ans,data.at(i));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const divisor = 1000000007

func main() {
	n := getInt()

	ans := 1
	for i := 1; i <= n; i++ {
		ans = (ans * i) % divisor
	}

	fmt.Println(ans)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

int main() {

	int N;
	cin >> N;

	if (N % 2 == 0) {
		cout << N / 2 << endl;
	}
	else {
		cout << (N + 1) / 2 << endl;
	}

	return 0;

}

Measured memory_bytes: 3556
INFTY = 10**12
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = [bin(A[i])[2:] for i in range(N)]
for i in range(N):
    A[i] = (40-len(A[i]))*"0"+A[i]
K = bin(K)[2:]
m = len(K)
K = (40-len(K))*"0"+K
dp = [[-INFTY for _ in range(2)] for _ in range(41)]
dp[0][0] = 0
for i in range(1,41):
    nd = int(K[i-1])
    cnt0 = 0
    cnt1 = 0
    for j in range(N):
        cnt0 += int(A[j][i-1])
        cnt1 += 1-int(A[j][i-1])
    if nd==0:
        dp[i][0] = 2*dp[i-1][0]+cnt0
    else:
        dp[i][0] = 2*dp[i-1][0]+cnt1
    f1 = 2*dp[i-1][1]+max(cnt0,cnt1)
    if nd==0:
        f0 = -INFTY
    else:
        f0 = 2*dp[i-1][0]+cnt0
    dp[i][1] = max(f1,f0)
tot = max(dp[40][0],dp[40][1])
print(tot)    

Measured memory_bytes: 99168
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;
template<class T>
void read_1d(std::vector<T>& a,int64_t num){
	a.reserve(num);
	for(int64_t i1=0;i1<num;i1++){
		T temp;
		cin>>temp;
		a.push_back(temp);
	}
}
template<class T>
void read_2d(std::vector<std::vector<T> >&a,int64_t x,int64_t y ){
	a.resize(x);
	for(int64_t i1=0;i1<x;i1++){
		a[i1].reserve(y);
		for(int64_t i2=0;i2<y;i2++){
			T temp;
			cin>>temp;
			a[i1].push_back(temp);
		}
	}
}
template<class InputIterator>
void debug(InputIterator first,InputIterator last){
	for(auto i1=first;i1!=last;i1++){
		cout<<(*i1)<<endl;
	}
}

int main(){
	int n,p;
	cin>>n>>p;
	vector<int> a;
	read_1d(a,n);
	int64_t odd=0;
	int64_t even=1;
	for(auto i1=a.begin();i1!=a.end();i1++){
		if((*i1)%2==0){
			odd=odd*2;
			even=even*2;
		}else{
			odd=odd+even;
			even=odd;
		}
	}
	if(p==0){
		cout<<even<<endl;
	}else{
		cout<<odd<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define LL long long
#define PLL pair<LL, LL>
#define LD long double
#define VI vector<int>
#define VPII vector<PII>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define FOR(a,s,d) for (int a = (s); a <= (int)(d); ++a)
#define FORD(a,s,d) for (int a = (s); a >= (int)(d); --a)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RE(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define siz(x) ((int)x.size())
#define Sim template <class s
Sim, class d> ostream & operator<<(ostream &os, pair<s,d> x){return os << "<" << x.F << ", " <<
  x.S << "> ";}
Sim> auto operator<<(ostream &os, s x) -> typename enable_if<!is_same<s,string>::value,
  decltype(x.begin(), os)>::type
{ int o = 0; os << "{"; for (auto c : x) {if(o++) os << ", "; os << c;}return os << "} ";}
void dor() {cerr << endl;}
Sim, class ...t> void dor(s x, t...y) {cerr << x << " "; dor(y...);}
#ifdef DEB
#define debug(c...) dor(__FUNCTION__, ":", __LINE__, ": ", c)
#else
#define debug(...)
#endif
const int M = 1024 * 256;

int n, T[M];
LL res;

int main()
{
  //ios_base::sync_with_stdio(0);
  //cin.tie(0);
  scanf("%d", &n);
  REP(i, n)
  {
    scanf("%d", T + i);
  }
  int last = T[n - 1];
  res = T[n - 1];
  for (int i = n - 2; i >= 0; i--)
  {
    last--;
    if (T[i] < last)
    {
      printf("-1\n");
      return 0;
    }
    if (last < T[i])
    {
      res += T[i];
      last = T[i];
    }
  }
  if (last != 0)
  {
    printf("-1\n");
    return 0;
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 1024
/**
 * @jakestrj
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include "bits/stdc++.h"
using namespace std;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define rep(i, j, k) for(int i=(j);i<(k);++i)
#define repi(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>(k);--i)
#define peri(i, j, k) for(int i=(j);i>=(k);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(), greater<int>()
#define mem(a, b) memset(a, (b), sizeof(a))
#define mem2(a, b) memset(a, (b), sizeof(a[0][0])*len(a)*len(a[0]))
#define sz(x) ((int)(x).size())
#define len(x) (int)(sizeof(x)/sizeof(x[0]))
#define endl "\n"
#define INF 1e18
#define EPS 1e-9
#define PI 2*acos(0)
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
typedef tuple<int, int, int> trio;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef map<int,int> mpii;
typedef set<int> si;

const int MN = 110;
int cost[MN][MN];

struct D {
	void solve(std::istream& cin, std::ostream& cout) {
		mem(cost, 0);
		int V, E; cin >> V >> E;
		vector<trio> allpairs;
		rep(i, 0, MN) rep(j, 0, MN) cost[i][j]=1e8;
		rep(i, 0, E){
			int u,v,c; cin >> u >> v >> c;
			--u; --v;
			allpairs.eb(u,v,c);
			cost[u][v]=c;
			cost[v][u]=c;
		}
		rep(k, 0, V){
			rep(i, 0, V){
				rep(j, 0, V){
					cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
				}
			}
		}
		int res=0;
		rep(i, 0, E){
			int a,b,c;
			tie(a,b,c) = allpairs[i];
			//if cost {u,v} = v, edge UV is contained
			//else cost {u,v} = e1+e2+..., then UV is NOT contained
			if(cost[a][b]!=c) ++res;
		}
		cout << res << endl;
	}
};


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


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

#define ll long long int
#define mp make_pair 
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define ff first
#define ss second
#define MOD  1000000007
#define ll_MAX 922337203685477999
#define endl "\n"
inline ll absdiff(ll a,ll b) {return (a>b)?a-b:b-a;}
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

ll dp[50000];

int main()
{
    // fast
    ll t_c;t_c = 1;
    // cin>>t_c;
    for (ll ti = 0; ti < t_c; ++ti)
    {   
        fill_n(dp,50000,ll_MAX);
        ll h,n;cin>>h>>n;
        pair<ll,ll> arr[n];
        for(ll i=0;i<n;++i){
            cin>>arr[i].ff>>arr[i].ss;
        }
          

        ll ans=ll_MAX;
        dp[0]=0;
        for(ll i=1;i<50000;++i){
            for(ll j=0;j<n;++j){
                if(i-arr[j].ff>=0){
                    dp[i] = min(dp[i],dp[i-arr[j].ff]+arr[j].ss);
                }
            }
            if(i>=h) ans=min(ans,dp[i]);
        }
        cout<<ans;
    }
    return 0;
}   

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
  
int main(void){
  
  int x[1000];
  int y[1000];
  int n;
  double P1 = 0;
  double P2 = 0;
  double P3 = 0;
  double Pinf = 0;
  double max = 0;
  double calc = 0;
  register int i;
  
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&x[i]);
  }
  for(i = 0;i < n;i++){
    scanf("%d",&y[i]);
  }
  
  for(i = 0;i < n;i++){
    P1 += fabs(x[i] - y[i]);
  }
  
  for(i = 0;i < n;i++){
    P2 += pow(fabs(x[i] - y[i]),2);
  }
  P2 = sqrt(P2);
  
  for(i = 0;i < n;i++){
    P3 += pow(fabs(x[i] - y[i]),3);
  }
  P3 = pow(P3,0.3333333333333);
  
  for(i = 0;i < n;i++){
    calc = fabs(x[i] - y[i]);
    if(max < calc){
      max = calc;
    }
  }
  Pinf = max;
  
  printf("%lf\n",P1);
  printf("%.8f\n",P2);
  printf("%.8f\n",P3);
  printf("%lf\n",Pinf);
  
  return 0;
}

Measured memory_bytes: 708
use proconio::{input, marker::Bytes};

fn main() {
    input! {
        s: Bytes,
        t: Bytes,
    }

    let ans = (0..=s.len() - t.len())
        .map(|offset| {
            s[offset..]
                .iter()
                .zip(&t)
                .filter(|(&c1, &c2)| c1 != c2)
                .count()
        })
        .min()
        .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 2140
// -*- coding:utf-8-unix -*-

use proconio::input;

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: u64, b: u64, g: u64) -> u64 {
    a / g * b
}

fn main() {
    input! {
        n: u64,
        m: u64,
        s: String,
        t: String,
    }

    let vs: Vec<char> = s.chars().collect();
    let vt: Vec<char> = t.chars().collect();
    let g = gcd(n, m);
    let l = lcm(n, m, g);

    // 理解しやすいが計算量の増える別解: LCM(N/L, M/L) の倍数の位置すべてを確認する
    // https://betrue12.hateblo.jp/entry/2018/10/14/121018
    // GCD が分母にくる理由を端折らずに解説してくださる良心
    // https://microkents.hatenablog.com/entry/2018/12/30/145128
    // 双方の文字列が進んでいく上で進み幅 L/N と L/M の公倍数となる位置がぶつかる
    // 例えば s については LCM(L/N, L/M) 動くと公倍数となり、文字一つで動く量は L/N
    // LCM(L/N, L/M) / (L/N) = L^2/NM * N/L = L/M
    for i in 0..g {
        // if vs[(i * (n / g)) as usize] != vt[(i * (m / g)) as usize] {
        if vs[(i * (l / m)) as usize] != vt[(i * (l / n)) as usize] {
            println!("-1");
            return;
        }
    }

    println!("{}", l);
}


Measured memory_bytes: 2936
s = input()
ans1 = 0
ans2 = 0

for a in s:
  if a == "A" or a == "T" or a == "C" or a == "G":
    ans2 += 1
  else:
    if ans1 < ans2:
      ans1 = ans2
      ans2 = 0
    else:
      ans2 = 0
print(max(ans1, ans2))

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

const int MOD = 1e+9 + 7;

int main(){
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;

    ll ans;
    int i;
    bool prex;
    if(s1[0] == s2[0]){
        prex = true;
        ans = 3;
        i = 1;
    } else {
        prex = false;
        ans = 6;
        i = 2;
    }
    while(i < n){
        if(s1[i] == s2[i]){
            if(prex){
                ans = ans * 2 % MOD;
            }
            i++;
            prex = true;
        } else {
            if(prex){
                ans = ans * 2 % MOD;
            } else {
                ans = ans * 3 % MOD;
            }
            i += 2;
            prex = false;
        }
    }
    cout << ans << endl;
    return 0;
}

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

string s[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

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

    int ans = 0;
    for (int i = 0; i < 7; i++) {
        if (s[i] == S){
            if (i == 0) ans = 7;
            else ans = 7 - i;
        }
    }
cout << ans << endl;


    return 0;
}


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

int main(){ 
    int K, A, B;
    cin >> K >> A >> B;

    bool flag = false;

    if ((A-1)/K < B / K) flag = true;

    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;

}

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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int a = h1 * 60 + m1;
  int b = h2 * 60 + m2;
  int ans = b - a - k;
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MEM(a,num) memset(a,num,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=3e5+100;
char str[maxn];
int N;
int main()
{
	scanf("%d",&N);scanf("%s",str);
	int cw=0,ce=0,se=0,ans=1e9,sw=0,tmp=1e9;
	rep(i,0,N-1)
		if(str[i]=='E')se++;
		else sw++;
	rep(i,0,N-1)
	{	
		if(str[i]=='E')tmp=cw+se-ce-1;
		else tmp=cw+se-ce;
		ans=min(tmp,ans);
		if(str[i]=='E')ce++;
		else cw++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
from collections import deque
 
N, M = map(int,input().split())
 
edges = [[] for _ in range(N)]
for _ in range(M):
    u, v = map(int,input().split())
    edges[u-1].append(v-1)
 
S, T = map(int,input().split())
S -= 1
T -= 1
 
visited = {}
q = deque()
q.append((S, 0))
d = -1
while q:
    s, c = q.popleft()
    if s in visited and (c % 3) in visited[s]:
        continue
    if s not in visited:
        visited[s] = set()
    visited[s].add(c % 3)
    for n in edges[s]:
        if n == T and c % 3 == 2:
            d = c + 1
            break
        q.append((n, c+1))
 
    if d % 3 == 0:
        break
 
if d == -1:
    print(-1)
else:
    print(d//3)


Measured memory_bytes: 122204
s = input()
let = []
one = ''
two = ''
for i in s:
    if i not in let:
        let.append(i)
    elif one == '':
        one = i
    elif one != '' and i != one:
        two = i

if one != '' and two != '':
    print('Yes')
else:
    print('No')
    
        
    

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

using namespace std;

const int Mod = 998244353;
const int maxn = 1e6 + 10;

void Chkadd(int &x, int y)
{
	if ((x += y) >= Mod) x -= Mod;
}

int Power(int a, int k)
{
	int x = 1;
	for (; k; k >>= 1)
	{
		if (k & 1) x = 1ll * x * a % Mod;
		a = 1ll * a * a % Mod;
	}
	return x;
}

int fac[maxn], inv[maxn];

int Count(int n, int m)
{
	if (n < 0 || m < 0) return 0;
	return 1ll * fac[n + m] * inv[n] % Mod * inv[m] % Mod;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	if (n < m) swap(n, m);
	int tot (n + m);
	fac[0] = 1;
	for (int i = 1; i <= tot; ++ i)
		fac[i] = 1ll * fac[i - 1] * i % Mod;
	inv[tot] = Power(fac[tot], Mod - 2);
	for (int i = tot; i; -- i)
		inv[i - 1] = 1ll * inv[i] * i % Mod;
	int ans = 0;
	for (int i = 1; i <= m; ++ i)
		Chkadd(ans, 1ll * Count(i, i) * Count(n - i, m - i) % Mod);
	ans = 1ll * ans * Power(2 * Count(n, m), Mod - 2) % Mod;
	printf("%d\n", (ans + n) % Mod);
	return 0;
}


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

int main() {
    string S;
    cin >> S;
    string ans = "No";
    if(S[0] == S[1] && S[2] == S[3]) ans = "Yes";
    if(S[0] == S[2] && S[1] == S[3]) ans = "Yes";
    if(S[0] == S[3] && S[1] == S[2]) ans = "Yes";
    if(S[0] == S[1] && S[1] == S[2] && S[2] == S[3]) ans = "No";
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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



	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) co("Yes");
	else co("No");


	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, X[201010];
int Q;
//---------------------------------------------------------------------------------------------------
int toRight[201010], toLeft[201010];
int toR[19][201010], toL[19][201010];
int totR[19][201010], totL[19][201010];
//---------------------------------------------------------------------------------------------------
int getTot(int L, int R) {
	int res = 1;
	int cu = L;
	rrep(p, 18, 0) {
		if (toR[p][cu] <= R) {
			res += 1 << p;
			cu = toR[p][cu];
		}
	}
	return res;
}
int getRight(int L, int R) {
	int cnt = getTot(L, R);

	ll tot = R; cnt--;
	int cu = R;
	rep(p, 0, 19) if (cnt & (1 << p)) {
		tot += totL[p][cu];
		cu = toL[p][cu];
	}

	return tot;
}
int getLeft(int L, int R) {
	int cnt = getTot(L, R);

	ll tot = L; cnt--;
	int cu = L;
	rep(p, 0, 19) if (cnt & (1 << p)) {
		tot += totR[p][cu];
		cu = toR[p][cu];
	}

	return tot;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	rep(i, 0, N) cin >> X[i];
	cin >> Q;

	rep(i, 0, N) toRight[i] = lower_bound(X, X + N, X[i] + K) - X;
	rep(i, 0, N) {
		int id = upper_bound(X, X + N, X[i] - K) - X;
		toLeft[i] = id - 1;
	}

	rep(p, 0, 19) toR[p][N] = N;
	rep(i, 0, N) toR[0][i] = toRight[i];
	rep(p, 1, 19) rep(i, 0, N) toR[p][i] = toR[p - 1][toR[p - 1][i]];

	rep(i, 0, N) totR[0][i] = toR[0][i];
	rep(p, 1, 19) rep(i, 0, N) totR[p][i] = totR[p - 1][i] + totR[p - 1][toR[p - 1][i]];

	rep(i, 0, N) toL[0][i] = toLeft[i];
	rep(p, 1, 19) rep(i, 0, N) {
		if (toL[p - 1][i] < 0) toL[p][i] = -1;
		else toL[p][i] = toL[p - 1][toL[p - 1][i]];
	}

	rep(i, 0, N) totL[0][i] = toL[0][i];
	rep(p, 1, 19) rep(i, 0, N) {
		if (toL[p - 1][i] < 0) totL[p][i] = totL[p - 1][i];
		else totL[p][i] = totL[p - 1][i] + totL[p - 1][toL[p - 1][i]];
	}

	rep(q, 0, Q) {
		int L, R; cin >> L >> R;
		L--; R--;
		ll ans = getRight(L, R) - getLeft(L, R) + getTot(L, R);
		printf("%lld\n", ans);
	}

}







Measured memory_bytes: 65808
#include<iostream>
int N,T,L,r,i,m[101],n[101];
main(){
  for(std::cin>>N>>T>>L>>L;i<N;i++)std::cin>>m[i]>>n[i];
  i=r=0;
  for(;m[i]+n[i];){
    bool broken=false;
    if(m[i]){
      m[i]--;
      r+=10;
      T++;
    }else{
      n[i]--;
      r+=100;
    }
    if(T>L)broken=true;
    if(r>=90){
      r-=90;
      if(r/10 > T){
        broken=true;
      }else{
        m[i]+=r;
        T-=r/10;
        r=0;
      }
    }
    if(broken)break;
    i = (i+1)%N;
  }
  std::cout<<i+1<<"\n";
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
vector <int> g[1000001];
int h, w, m;
int dp[1000001];

int f(int node) {
	if(node==h*w-1)
	return 1;
	if(dp[node]!=-1)
	return dp[node];
	int ans = 0;
	for(int i=0; i<g[node].size(); ++i)
	ans = (ans + f(g[node][i])%m)%m;
	dp[node]= ans;
	return ans;
}

int main() {
	m = 1000000007;
	cin>>h>>w;
	char r[h][w];
	for(int i=0; i<h; ++i)
	for(int j=0; j<w; ++j)
	cin>>r[i][j];
	for(int i=0; i<h-1; ++i) {
		for(int j=0; j<w-1; ++j) {
			if(r[i][j]=='#')
			continue;
			else {
				if(r[i][j+1]=='.')
				g[i*w+j].push_back(i*w+j+1);
				if(r[i+1][j]=='.')
				g[i*w+j].push_back((i+1)*w+j);
			}
		}
	}
	for(int i=0; i<h-1; ++i){
		if(r[i][w-1]=='#')
		continue;
		else {
			if(r[i+1][w-1]=='.')
			g[i*w+w-1].push_back((i+1)*w+w-1);
		}
	}
	for(int j=0; j<w-1; ++j) {
		if(r[h-1][j]=='#')
		continue;
		else{
			if(r[h-1][j+1]=='.')
			g[(h-1)*w+j].push_back((h-1)*w+j+1);
		}
	}
	
	for(int i=0; i<h*w; ++i)
	dp[i]=-1;
	
	/*for(int i=0; i<h*w; ++i) {
		for(int j=0; j<g[i].size(); ++j)
		cout<<g[i][j]<<" ";
		cout<<endl;
	}*/
	
	cout<<f(0);
	return 0;
}

Measured memory_bytes: 63100
#include<bits/stdc++.h> 
using namespace std; 
typedef long long int ll; 
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    ll l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(ll idx, ll val, ll bit[], ll n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
ll query(ll idx, ll bit[], ll n) 
{ 
    ll sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(ll arr[], ll n, Query queries[], ll q) 
{ 
    // initialising bit array 
    ll bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    ll last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    ll ans[q]; 
    ll query_counter = 0; 
    for (ll i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (ll i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{ 
    ll n,q,x,y;
	cin>>n>>q;
	ll a[n];
	
	for(ll i=0;i<n;i++)
		cin>>a[i]; 
    
	Query queries[q+1];
	
	for(ll i=0;i<q;i++){
		cin>>x>>y;
		queries[i].l=x-1;
		queries[i].r=y-1;
		queries[i].idx=i;
	}  

    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q);
	
    return 0; 
} 

Measured memory_bytes: 35032
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int main (){
	int NN,MM,QQ;
	cin >> NN >> MM >> QQ;
	int fields[NN+1][NN+1];
	rep(i,NN+1){
		rep(j,NN+1){
			fields[i][j]=0;
		}
	}
	int templ,tempr,templl,temprr;
	rep(i,MM){
		cin >> templl >> temprr;
		templ = min(templl,temprr);
		tempr = max(templl,temprr);
		fields[templ][tempr]++;
	}
	rep(i,NN+1){
		rep(j,NN){
			fields[i][j+1] += fields[i][j];
		}
	}
	rep(j,NN+1){
		rep(i,NN){
			fields[i+1][j] += fields[i][j];
		}
	}
	int ans = 0;
	rep(i,QQ){
		cin >> temprr >> templl;
		templ = min(templl,temprr);
		tempr = max(templl,temprr);		
		ans = 0;
		ans = fields[tempr][tempr] + fields[templ-1][templ-1] - fields[tempr][templ-1] - fields[templ-1][tempr];
		cout << ans << endl;
	}

	return 0;


}


Measured memory_bytes: 1920