akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,q;
    cin >> n >> q;
    vector<ppi> v;
    rep(i,n){
        int a,b,x;
        cin >> a >> b >> x;
        v.push_back(make_pair(pii(a-x,1),x));
        v.push_back(make_pair(pii(b-x,-1),x));
    }
    sort(all(v));
    int ind = 0;
    map<int,int> ma;
    rep(i,q){
        int d;
        cin >> d;
        while(ind < v.size() && v[ind].first.first <= d){
            int x = v[ind].second;
            if(v[ind].first.second == 1){//push
                ma[x]++;
            }else{//pop
                ma[x]--;
                if(ma[x] == 0)ma.erase(x);
            }
            ind++;
        }
        int ans = -1;
        if(ma.size())ans = ma.begin()->first;
        cout << ans << endl;
    }

}


Measured memory_bytes: 24168
# -*- coding:utf-8 -*-
"""解説
https://www.youtube.com/watch?v=L8grWxBlIZ4

PDFに書いてある実装をする。

....#.
..#...
.#..#.

それぞれのマスについて、

・左マスを照らせる個数: L[i][j]
・右マスを照らせる個数: R[i][j]
・上マスを照らせる個数: U[i][j]
・下マスを照らせる個数: D[i][j]

をそれぞれ計算する。

左マスを照らす漸化式L[i][j]は、

・i行j列に障害物がある場合はL[i][j] = 0
・そうでないとき、j=1ならば、L[i][j] = 1
・そうでないとき、j>1ならば、L[i][j] = L[i][j-1] + 1

求める答えは、L[i][j]+R[i][j]+U[i][j]+D[i][j]-3 の最大値


計算量はO(HW)。

H,W = 2000なので、O(HW)はO(4*10**6)。 Pythonでこの計算量は無理だろと思って実装を諦めたが、いけるっぽい。認識を改めた。というかPyPyもあるし。

と思ったら普通に無理だった。

numpyを使ったらfor文を一個減らせる。計算量が減ったかどうかは内部処理によるので知らんけどACした。結論：numpyの行列計算は速い。

・参考にした他人のコード
https://atcoder.jp/contests/abc129/submissions/5861992

"""
import numpy as np

def solve():
    H, W = list(map(int, input().split()))
    grid = []
    for i in range(H):
        grid.append(list(input()))
    grid = (np.array(grid) == ".") * 1  # ランプをおける:1, 障害物:0

    L = np.zeros((H,W), dtype=int)
    R = np.zeros((H,W), dtype=int)
    U = np.zeros((H,W), dtype=int)
    D = np.zeros((H,W), dtype=int)
    
    for j in range(W):
        if j == 0:
            L[:, j] = grid[:, j]
        else:
            L[:, j] = (L[:, j-1] + 1) * grid[:, j]
    
    for j in range(W-1, -1, -1):
        if j == W-1:
            R[:, j] = grid[:, j]
        else:
            R[:, j] = (R[:, j+1] + 1) * grid[:, j]

    for i in range(H):
        if i == 0:
            U[i] = grid[i] * 1
        else:
            U[i] = (U[i-1] + 1) * grid[i]
    
    for i in range(H-1, -1, -1):
        if i == H-1:
            D[i] = grid[i]
        else:
            D[i] = (D[i+1] + 1) * grid[i]

    ans = np.max(L+R+U+D-3)
    print(ans)


if __name__ == "__main__":
    solve()


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

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

    int n;cin>>n;

    int cnt=0;
    int cntmax=0;

    bool zo=false;
    for(int i=0;i<n;i++)
    {
        int c,d;cin>>c>>d;

        if(c==d)cnt++;
        else cnt=0;

        cntmax=max(cntmax,cnt);
    }

    puts(cntmax>=3?"Yes":"No");

    return 0;
}


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

using namespace std;

#define MAX 100
#define MAX_H 100000
#define INF (1<<29)
typedef long long ll;

int main(){
    ll N,M;
    string in;
    while(cin >> N, N){
        ll MHP = 0;
        vector<ll> HP(N);
        for(ll i = 0 ; i < N ; i++){
            cin >> HP[i];
            MHP = max(MHP,HP[i]);
        }
        cin >> M;
        vector<ll> MP(M),t(M),d(M);
        for(ll i = 0 ; i < M ; i++){
            cin >> in >> MP[i] >> in >> d[i];
            t[i] = (in == "All");
        }
        ll dp[2][MAX_H+1];
        fill(dp[0],dp[0]+2*(MAX_H+1),INF);
        dp[0][0] = dp[1][0] = 0;
        for(ll i = 0 ; i < M ; i++){
            for(ll j = 0 ; j <= MHP ; j++){
                ll nt = t[i],nhp = min(MHP,j+d[i]);
                dp[nt][nhp] = min(dp[nt][nhp],dp[nt][j]+MP[i]);
            }
        }
        for(ll i = MHP ; i > 0 ; i--){
            dp[0][i-1] = min(dp[0][i-1],dp[0][i]);
            dp[1][i-1] = min(dp[1][i-1],dp[1][i]);
        }
        ll res = INF;
        for(ll i = 0 ; i <= MHP ; i++){
            ll mp = dp[1][i],mp2 = 0;
            if(mp == INF) continue;
            for(ll j = 0 ; j < N ; j++){
                ll rest = max(HP[j]-i,0LL);
                if(rest == 0) continue;
                mp2 += dp[0][rest];
            }
            res = min(res,mp+mp2);
        }
        cout << res << endl;
    }
    return 0;
}

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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	int s,w;
	cin>>s>>w;

	if(w>=s)
	cout<<"unsafe";

	else
	cout<<"safe";

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<math.h>
#include<stdio.h>


int main()
{
	int n;
	std::string a;
	std::string b;
	std::cin >> n >> a >> b;
	for (int i=0; i < n; i++) {
		std::cout << a[i];
		std::cout << b[i];
	}std::cout << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n;
V<int> a;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int c4 = 0, c1 = 0, c2 = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] % 4 == 0) c4++;
        else if (a[i] & 1) c1++;
        else c2++;
    }
    if (c2 == 0) {
        if (c4 > 0 && c4 + 1 >= c1) cout << "Yes\n";
        else cout << "No\n";
    } else {
        if (c4 >= c1) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h, w, cnt = 0;
  cin >> h >> w;
  vector<vector<char>> a(h+1, vector<char>(w+1, 'z'));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      if (a[i][j] == '#') cnt++;
      if (cnt > h+w-1) {
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i == h-1 && j == w-1) continue;
      if (a[i][j] == '#' && a[i+1][j] != '#' && a[i][j+1] != '#') {
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  
  cout << "Possible" << endl;
}

Measured memory_bytes: 256
from collections import deque;h,w,k=map(int,input().split());m=[input()for _ in[0]*h];v=[[-1]*w for _ in[0]*h];r=9**20
for i in range(h):
 if'S'in m[i]:j=m[i].index('S');q=deque([[i,j]]);v[i][j]=0
while q:
 y,x=q.popleft();r=min(r,y,x,h-1-y,w-1-x)
 for i,j in([1,0],[-1,0],[0,1],[0,-1]):
  t,u=y+i,x+j
  if t>=0and t<h and u>=0and u<w and m[t][u]=='.'and v[t][u]<0and v[y][x]<k:v[t][u]=v[y][x]+1;q.append([t,u])
print(1-(-r//k))

Measured memory_bytes: 58972
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
unordered_set<ll>SET;
unordered_map<ll,int>byk;
const int N=2e5+5;
int arr[N];
ll ps[N];
ll kombin(ll x){
    return x*(x-1)/2;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        ps[i]=ps[i-1]+arr[i];
        SET.insert(ps[i]);
        byk[ps[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(ps[i]==0) ans++;
    }
    for(auto isi:SET){
        ans+=kombin(byk[isi]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 19088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;

bool le, nu, up, lo;
int main() {
	string h;
	cin >> h;
	if (h.length() >= 6) { le = true; }
	for (int i = 0; i < h.length(); ++i) {
		if (isdigit(h[i])) { nu = true; }
		if (isupper(h[i])) { up = true; }
		if (islower(h[i])) { lo = true; }
	}
	string ans;
	if (le&&nu&&up&lo) { ans = "VALID"; }
	else { ans = "INVALID"; }
	cout << ans << endl;
}



Measured memory_bytes: 3228
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

void __fast_IO()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
}

//##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**
//##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**

int n;
string s;
int k;
vector<string> v;

signed main()
{
    __fast_IO();
    cin >> s >> k;
    for (int i = 0; i < s.size(); i++)
    {
        string t = "";
        for (int j = i; j < s.size() && j < i + 6; j++)
        {
            t += s[j];
            v.push_back(t);
        }
    }
    uniq(v);
    cout << v[k - 1];
}

/* Note:
Check constants at the beginning of the code.
N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
No def int long long for now.
*/


Measured memory_bytes: 1916
a,b,c = map(int, input().split())
i=1
count = 0
x=[]
for i in range(101):
  try:
    if a%i==0 and b%i==0:
      count+=1
      x.append(i)
  except ZeroDivisionError:
    pass
  i+=1
print(x[-c])

Measured memory_bytes: 3060
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
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; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i =0; i < N; i++) cin >> A[i];
    map<int, int> m;
    for (int a : A) m[a]++;

    int cnt = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        cnt += (it->second) * (it->second - 1) / 2;
    }

    for (int i = 0; i < N; i++) {
        int c = m[A[i]];
        int dec = c * (c-1) / 2 - (c-1) * (c-2) / 2;
        cout << cnt - dec << endl;
    }

    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int K,S;
    cin >> K >> S;
    int X=0,Y=0,cnt=0;
    
    for(X=0;X<=K;X++){
        for(Y=0;Y<=K;Y++){
            int Z = S-X-Y;
            if(Z >= 0 && Z<= K){
                cnt++;
            }
        }
    }

cout << cnt << endl;
return 0;
}


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

using namespace std;

int main(){
	int N;
	cin >> N;
	string W[N];
	for (int i = 0; i < N; ++i)
		cin >> W[i];

	for (int i = 0; i < N; ++i){
		for (int j = i+1; j < N; ++j){
			if (W[i] == W[j]){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	for (int i = 0; i < N-1; ++i){
		if (W[i][W[i].length()-1] != W[i+1][0]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
typedef long long llong;
using namespace std;

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

	if(b / a > c) cout << c << endl;
	else cout << b / a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>


int main() {
    int P, Q, R;
    std::cin >> P >> Q >> R;
    std::cout << (P + Q + R - std::max(P, std::max(Q, R))) << std::endl;
    return 0;
}


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

using namespace std;

int main(){

	int N, M, input;
	vector<int> A;
	cin >> N >> M;

	while(M > 0){
		cin >> input;
		A.push_back(input);
		M--;
	}
	cout << "\n";
	for(int i = 0; i < A.size(); i++)
	{
		N -= A[i];
	}
	if(N >=0)
	cout << N << "\n";
	else cout << -1 << "\n";
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<ll> c;

    UnionFind(int N) : par(N),c(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        for(int i = 0; i < N; i++) c[i] = 1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    ll unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return 0; //xとyの根が同じ(=同じ木にある)時はそのまま
        ll result = c[ry] * c[rx];
        ll sum = c[ry] + c[rx];
        par[rx] = ry;
        c[ry] = sum;
        c[rx] = sum;
        return result;//xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    ll N,M;
    cin >> N >> M;
    vector<pair<ll,ll>> E(M);
    UnionFind unionFind(N);
    for(int i = 0; i < M; i++){
        ll A,B;
        cin >> A >>B;
        A--;B--;
        E[i] = make_pair(A,B);
    }
    ll invInconv[M];
    for(int i = 0; i < M; i++){
        invInconv[i] = 0;
    }
    for(ll i = M-1; i >= 0; i--){
        invInconv[i] += unionFind.unite(E[i].first,E[i].second);
        if(i != 0){
            invInconv[i - 1] = invInconv[i];
        }
    }
    for(int i = 0; i < M; i++){
        //cout << invInconv[i] << endl;
    }
    for(int i = 1; i < M; i++){
        cout << invInconv[0] - invInconv[i] << endl;
    }
    cout << invInconv[0] << endl;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define MOD 1000000000
#define MAX 10000005
#define ll long long
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define clr(x) memset(x,0,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define rep(I, N) for (ll I = 0; I < (N); ++I)
#define repp(I, A, B) for (ll I = (A); I <= (B); ++I)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
ll pwr(ll base, ll p, ll mod = MOD)
{
    ll ans = 1;
    while(p)
    {
        if(p & 1)   ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        p /= 2;
    }
    return ans;
}
// for inverse modulo : if (1/b)%mod then ans is (b^(mod-2))%mod
ll gcd(ll a, ll b)
{
    if(b == 0)  return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
    return (a*b) / gcd(a, b);
}
bool isPrime[MAX];
void sieve(int n) 
{
    for(int i = 0; i <= n;++i) 
    {
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i * i <= n; ++i) 
    {
         if(isPrime[i] == true) 
         {
             for(int j = i * i; j <= n ;j += i)
                 isPrime[j] = false;
        }
    }
}
bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.first > b.first);
}
const ll N = 2e5 + 5 ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    //freopen("A.in", "r", stdin); 
    //freopen("A.out", "w", stdout);

 
    int n;
    cin >> n;
    int ans = 0;
    repp(i,1,n)
    {
        int x, y ;
        cin >> x >> y;
        ans += (y- x + 1);
    }
    cout << ans;


    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*a+2*b;
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26156
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N,A,B;cin>>N>>A>>B;
    cout<<((B-A)%2==0?"Alice":"Borys")<<endl;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;

class Program
{
	static void Main()
	{
		var line = Console.ReadLine();
		int num = int.Parse(line);
        int maxNum = 1;
        while(maxNum * 2 <= num){
            maxNum *= 2;
        }
        Console.WriteLine(maxNum);
	}
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
  int n;
  
  scanf("%d",&n);
  int flg=0;
  if(n%10==7){
    flg=1;
  }
  n/=10;
  if(n%10==7){
    flg=1;
  }
  n/=10;
  if(n%10==7){
    flg=1;
  }
  if(flg==1)printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1644
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
    int X,Y,Z;
    int N,M;
    int tmp, sum;
    int t;
    cin >> N >> M;
    t = pow(2, M) * (1900 * M + 100 * (N - M));
    int ans = t;
    cout << ans << endl;
} 

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int main(void){
  int mv[MAX+1]={0},i,num,max,end;

  max = end = 0;
  while( scanf("%d" ,&num) != EOF ){
    mv[num]++;
    end++;
  }

  for( i = 1 ; i <= end ; i++ ){
    if( max < mv[i] ) max = mv[i];
  }

  for( i = 1 ; i <= end ; i++ ){
    if( max == mv[i] ) printf("%d\n" ,i);
  }

  return 0;
}

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

const int MAXN = 1010;
const int MAXM = 2010;

int A[MAXM], B[MAXM];
vector<int> ed[MAXN];
int dep[MAXN], par[10][MAXN];
int cnt[MAXN];
bool chk[MAXN];

void bfs(int x) {
	dep[x] = 1;
	par[0][x] = 0;
	queue<int> q;
	q.push(x);
	while(!q.empty()) {
		int t = q.front();
		q.pop();
		for(auto a : ed[t]) if(!dep[a]) {
			dep[a] = dep[t] + 1;
			par[0][a] = t;
			q.push(a);
		}
	}
}

void dfs(int x, int c) {
	cnt[x] += c;
	for(auto a : ed[x]) if(par[0][a] == x) dfs(a, cnt[x]);
}

int anc(int x, int d) {
	for(int i = 9; i >= 0; i--) if(dep[x] - (1 << i) >= d) x = par[i][x];
	return x;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int N, M;

	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		ed[A[i]].push_back(B[i]);
	}

	for(int i = 1; i <= N; i++) {
		memset(dep, 0, sizeof(dep));
		bfs(i);
		for(int j = 1; j < 10; j++) for(int k = 1; k <= N; k++) par[j][k] = par[j - 1][par[j - 1][k]];
		int k = -1;
		for(int j = 0; j < M; j++) if(dep[A[j]] && anc(A[j], dep[B[j]]) == B[j]) 
			if(k == -1 || dep[A[j]] - dep[B[j]] < dep[A[k]] - dep[B[k]]) k = j;
		if(k != -1) {
			cout << dep[A[k]] - dep[B[k]] + 1 << "\n";
			for(int t = A[k]; dep[t] >= dep[B[k]]; t = par[0][t]) cout << t << "\n";
			return 0;
		}
	}
	cout << "-1";
	return 0;
}



Measured memory_bytes: 384
n, q = [int(i) for i in input().split()]
s = input()

count = [0] * (n + 1)
for i in range(n):
    count[i+1] += count[i]
    if s[i:i+2] == "AC":
        count[i+1] += 1
for i in range(q):
    l, r = [int(i) for i in input().split()]
    print(count[r-1] - count[l-1])


Measured memory_bytes: 51160
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int n;
    cin >> n;
    cout << n * n * n << endl;

    return 0;
}



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

using namespace std;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define inside sl<=l&&r<=sr
#define outside sr<l||r<sl

typedef long long ll;
ll inf = 2000000000000000000;

int n;
list<int> adj[101];
ll dep[101];

ll dfs(int node, int ata, ll dist){
	ll ans = dist;
	for (int ch: adj[node]){
		if (ch == ata) continue; 
		ans = max(ans, dfs(ch, node, dist+1));
	}
	return ans;
}

void dfsh(int node, int ata, int h){
	dep[node] = h;
	for (int ch: adj[node]){
		if (ch == ata)continue;
		dfsh(ch, node, h+1);
	}
}

ll getans(){
	ll ans = 1;
	ll maxh = 0;
	for (int i = 0; i < n; i++) maxh = max(maxh, dep[i]);
	for (int h = maxh-1; h >= 1; h--){
		ll maxc = 0;
		for (int i = 0; i < n; i++){
			if (dep[i] == h) maxc = max(maxc, (ll)adj[i].size()-1);
		}
		ans *= maxc;
	}
	int num0 = 0;
	for (int i = 0; i < n; i++) if (dep[i] == 0) num0++;
	if (num0 == 1){
		for (int i = 0; i < n; i++) if (dep[i] == 0) ans *= adj[i].size();
	} else if (num0 == 2){
		ll maxc = 0;
		for (int i = 0; i < n; i++){
			if (dep[i] == 0) maxc = max(maxc, (ll)adj[i].size()-1);
		}
		ans *= maxc;
		ans *= 2;
	} else assert(0);
	return ans;
}

int main(){
	cin >> n;
	for (int i = 0; i < n-1; i++){
		int u, v;
		cin >> u >> v;
		u--;v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	if (n == 2){
		cout << 1 << " " << 2 << endl;
		exit(0);
	}
	
	ll maxdep = 0;
	ll mindep = 200;
	for (int i = 0; i < n; i++){
		maxdep = max(maxdep, dfs(i, -1, 0));
	}
	vector<int> maxnodes;
	for (int i = 0; i < n; i++){
		if (dfs(i, -1, 0) == (maxdep+1)/2){
			maxnodes.pb(i);
		}
	}
	
	//prarrv(maxnodes);
	
	ll ans;
	if (maxnodes.size() == 1){
		dfsh(maxnodes[0], -1, 0);
		ans = getans();
		for (int ch: adj[maxnodes[0]]){
			dfsh(maxnodes[0], ch, 0);
			dfsh(ch, maxnodes[0], 0);
			ans = min(ans, getans());
		}
	} else if (maxnodes.size() == 2){
		dfsh(maxnodes[0], maxnodes[1], 0);
		dfsh(maxnodes[1], maxnodes[0], 0);
		ans = getans();
	} else assert(0);
	
	
	cout << maxdep/2+1 << " " << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;
typedef pair<int, int> P;

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

int main()  {
    int N;
    cin >> N;
    bool flag = true;
    string word[200];
    rep(i, N) {
        cin >> word[i];
    }
    rep(i, N) {
        rep(j, N) {
            if(i == j) continue;
            if(word[i] == word[j]) flag = false;
        }
    }
    string temp1, temp2;
    FOR(i, 1, N) {
        temp1 = word[i - 1];
        temp2 = word[i];
        if(temp1[temp1.length() - 1] != temp2[0]) flag = false;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int gcd(int a,int b){
	return (b==0?a:gcd(b,a%b));
}
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a=abs(a-c);
	b=abs(b-d);
	cout<<a+b-gcd(a,b)<<endl;
}









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

#undef false
#undef true

using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;

/* [💭] [💡] [🎈] */

template<typename _Ty, typename _Fn = plus<_Ty>>
struct segment_tree {
    _Ty default_value = _Ty();
    int n = 0;
    vector<_Ty> tree;

    void _init(int x, int s, int e, const vector<_Ty> &a) {
        if (s == e) {
            tree[x] = a[s];
            return;
        }
        _init(x * 2, s, (s + e) / 2, a);
        _init(x * 2 + 1, (s + e) / 2 + 1, e, a);
        tree[x] = _Fn()(tree[x * 2], tree[x * 2 + 1]);
    }

    segment_tree() : n(0) {}

    explicit segment_tree(const vector<_Ty> &a, _Ty default_value = _Ty()) : default_value(default_value) {
        n = a.size();
        int ts = 1;
        while (ts < a.size()) ts <<= 1;
        ts <<= 1;
        tree = vector<_Ty>(ts, default_value);
        _init(1, 0, n - 1, a);
    }

    _Ty _query(int x, int s, int e, int l, int r) {
        if (r < s || e < l) return default_value;
        if (l <= s && e <= r) return tree[x];
        return _Fn()(
                _query(x * 2, s, (s + e) / 2, l, r),
                _query(x * 2 + 1, (s + e) / 2 + 1, e, l, r)
        );
    }

    _Ty query(int l, int r) {
        return _query(1, 0, n - 1, l, r);
    }

    void _change(int x, int s, int e, int i, _Ty val) {
        if (e < i || i < s) return;
        if (s == e && e == i) {
            tree[x] = val;
            return;
        }
        _change(x * 2, s, (s + e) / 2, i, val);
        _change(x * 2 + 1, (s + e) / 2 + 1, e, i, val);
        tree[x] = _Fn()(tree[x * 2], tree[x * 2 + 1]);
    }

    void change(int i, _Ty val) {
        _change(1, 0, n - 1, i, val);
    }
};

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

    int n;
    string str;

    cin >> n >> str;

    vector<int> initial[26];
    for (int i = 0; i < 26; i++) {
        initial[i].resize(n);
        for (int j = 0; j < n; j++) {
            initial[i][j] = (str[j] == 'a' + i);
        }
    }

    segment_tree<int> tree[26];
    for (int i = 0; i < 26; i++) {
        tree[i] = segment_tree<int>(initial[i]);
    }

    int q;
    cin >> q;
    while (q--) {
        int op;
        cin >> op;
        if (op == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            tree[str[i] - 'a'].change(i, 0);
            str[i] = c;
            tree[c - 'a'].change(i, 1);
        } else {
            int l, r;
            cin >> l >> r;
            l--, r--;
            int sum = 0;
            for (int i = 0; i < 26; i++) {
                sum += !!tree[i].query(l, r);
            }
            cout << sum << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 158492
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

// Convenience function to read a vector of values from standard input
template <typename T>
auto readVector(T N) {
    vector<T> A;
    for (T i = 0; i < N; i++) {
        T Ai;
        cin >> Ai;
        A.push_back(Ai);
    }
    return A;
}

auto nextLevel(const string& input) {
    return "B" + input + "P" + input + "B";
}

// Precomputer the number of layers and patties at each level
auto getLayers(uint64_t N) {
    vector<pair<uint64_t,uint64_t>> output = {{1ull,1ull}};
    while (N > 0) {
        auto last = output.back();
        auto layers = 2*last.first + 3;
        auto patties = 2*last.second + 1;
        output.push_back(make_pair(layers, patties));
        N--;
    }
    return output;
}

// Consumes up to numLayers from a burger of given level
pair<uint64_t,uint64_t> consumeBurger(uint64_t level, uint64_t numLayers, const vector<pair<uint64_t,uint64_t>>& levelCounts) {
    // If we can eat every layer in the burger at this level then can compute trivially, otherwise we have to recurse
    if (levelCounts[level].first <= numLayers) return levelCounts[level];
    // First outer bun
    auto consumedLayers = 1ull;
    auto consumedPatties = 0ull;
    if (consumedLayers == numLayers) return make_pair(consumedLayers, consumedPatties);
    // First inner burger
    auto next = consumeBurger(level - 1, numLayers - consumedLayers, levelCounts);
    consumedLayers += next.first;
    consumedPatties += next.second;
    if (consumedLayers == numLayers) return make_pair(consumedLayers, consumedPatties);
    // Middle patty
    consumedLayers++;
    consumedPatties++;
    if (consumedLayers == numLayers) return make_pair(consumedLayers, consumedPatties);
    // Second inner burger
    next = consumeBurger(level - 1, numLayers - consumedLayers, levelCounts);
    consumedLayers += next.first;
    consumedPatties += next.second;
    if (consumedLayers == numLayers) return make_pair(consumedLayers, consumedPatties);
    // Second outer bun
    consumedLayers++;
    return make_pair(consumedLayers, consumedPatties);
}    

auto solve(uint64_t N, uint64_t X) {
    const auto layers = getLayers(N);
    return consumeBurger(N, X, layers).second;
}

// Read parameters from standard input and call main solution function
int main() {
    uint64_t N, X;
    cin >> N >> X;
    cout << solve(N, X) << endl;
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if((a == b && a != c)||(b == c && a != b)||(a == c && a != b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	auto sum_d = [&] (ll n) {
		int res = 0;
		while(n != 0) {
			res += n % 10;
			n /= 10;
		}
		return 1.0 * res;
	};
	//const int N = 19999999 + 1;
	//vector <double> vv(N);
	//for (int i = 1; i < N; i++) {
		//vv[i] = 1.0 * i / sum_d(i);
	//}
	//vector <ll> ans1;
	//double mn1 = INF;
	//for (int i = (int) vv.size() - 1; i >= 1; i--) {
		//if(vv[i] <= mn1) {
			//mn1 = vv[i];
			//ans1.push_back(i);
		//}
	//}
	//reverse(all(ans1));
	
	auto power10 = [&] (int n) {
		ll res = 1;
		for (int i = 0; i < n; i++)
			res = res * 10;
		return res;
	};
	vector <pair<double, ll>> v;
	for (int i = 1; i <= 9; i++) {
		v.emplace_back(i / sum_d(i), i);
	}
	for (int i = 1; i <= 9; i++) {
		v.emplace_back((10 * i + 9) / sum_d(10 * i + 9), 10 * i + 9);
	}
	for (int i = 1; i <= 9; i++) {
		v.emplace_back((v.back().ss + 100) / sum_d(v.back().ss + 100), v.back().ss + 100);
	}
	int n = 16;
	for (int i = 4; i < n; i++) {
		if(n <= 5) {
			ll nines = power10(i - 2) - 1;
			for (int j = 10; j <= 99; j++) {
				ll x = j * power10(i - 2) + nines;
				v.emplace_back(x / (1.0 * sum_d(x)), x);
			}
		}
		else {
			ll nines = power10(i - 3) - 1;
			for (int j = 100; j <= 999; j++) {
				ll x = j * power10(i - 3) + nines;
				v.emplace_back(x / (1.0 * sum_d(x)), x);
			}
		}
	}
	//for (auto g : v) {
		//cout << g.ss << "\n";
	//}
	vector <ll> ans;
	double mn = INF;
	for (int i = (int) v.size() - 1; i >= 0; i--) {
		if(v[i].ff <= mn) {
			mn = v[i].ff;
			ans.push_back(v[i].ss);
			//cout << v[i].ss << " " << mn << "\n";
		}
	}
	reverse(all(ans));
	//for (auto g : ans) {
		//cout << g << "\n";
	//}
	//for (int i = 0; i < (int) ans1.size(); i++) {
		//cerr << ans1[i] << " " << ans[i] << "\n";
		//assert(ans1[i] == ans[i]);
	//}
	int k;
	cin >> k;
	for (int i = 0; i < k; i++) {
		cout << ans[i] << "\n";
	}
}


Measured memory_bytes: 640
#include <iostream>
#define MAX(a,b) (((a)>(b))?(a):(b))
using namespace std;

int main(void){
	int n,k;
	while (cin>>n>>k,n||k) {
		int a[100000];
		int sum=0;
		int m=0;
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=0;i<k;i++)sum+=a[i];
		m=sum;
		for(int i=k;i<n;i++){
			sum-=a[i-k];
			sum+=a[i];
			m=MAX(sum,m);
		}
		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 3296
from collections import defaultdict
MOD = 10**9 + 7

N,M = map(int,input().split(' '))

Mfact = defaultdict(int)

max_cnt = 1
for i in range(2,int(M**0.5)+1):
    cnt = 0
    while M%i == 0:
        M = M//i
        cnt += 1
    if cnt > 0:
        Mfact[i] = cnt
    max_cnt = max(cnt,max_cnt)
if M > 1:
    Mfact[M] = 1

n = max_cnt + N + 100
fact = [1]*(n+1)
inv = [1]*(n+1)
ifact = [1]*(n+1)
for i in range(1,n+1):
    fact[i] = fact[i-1]*i % MOD
    inv[i] = pow(i,MOD-2,MOD)
    ifact[i] = ifact[i-1]*inv[i] % MOD
def kHr(k,r):
    n = k+r-1
    r = min(r,n-r)
    return (fact[n] * ifact[r] * ifact[n-r]) % MOD

ans = 1
for k,v in Mfact.items():
    ans = (ans * kHr(v+1,N-1)) % MOD
print(ans)





Measured memory_bytes: 41484
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }
    let mut prev: i64 = a[0];
    let mut ans: i32 = 1;
    let mut deg: i8 = 0;
    for x in a {
        if deg==1 {
            if prev>x {
                ans += 1;
                deg = 0;
            }
        } else if deg==-1 {
            if prev<x {
                ans += 1;
                deg = 0;
            }
        } else {
            if prev<x {
                deg = 1;
            } else if prev>x {
                deg = -1;
            }
        }
        prev = x;
    }
    println!("{}", ans);
}


Measured memory_bytes: 3732
L = int(input())
A = [int(input()) for _ in range(L)]

func = [lambda x: x,
        lambda x: 2 if x == 0 else int(x%2),
        lambda x: int(x%2==0),
        lambda x: 2 if x == 0 else int(x%2),
        lambda x: x]

before = [0]*5
for i in range(L):
    bmin = 1e10
    after = [0]*5
    for j in range(5):
        bmin = min(bmin, before[j])
        after[j] = bmin + func[j](A[i])
    before = after

print(min(before))


Measured memory_bytes: 66648
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#include <bits/stdc++.h>
#define endl "\n"
#define ll   long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define plll pair<long long, pll>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }	
using namespace std;
 
ll t,ans,n,d,x,y,l,r;

void solve(){
  cin>>n>>d;
  ans=0;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    ans+=((d*d)>=(x*x+y*y));
  }
  cout<<ans;
}

int main(){
    SPEED;
   t=1;
    while(t--){
      solve();
    }
}

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

int main()
{
    int x, y;
    cin >> x >> y;

    bool ans = true;
    if (x * 2 > y) ans = false;
    if (y % 2 != 0) ans = false;
    if (x * 4 < y) ans = false;

    if (ans) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 3608
def main():
    a,b=map(int,input().split())
    p=b-a
    if b==1:print(0)
    elif p<=0:print(1)
    else:
        if p%(a-1)==0:print((p//(a-1))+1)
        else:print((p//(a-1))+2)
main()          

Measured memory_bytes: 38384
<?php

list($n, $m) = explode(' ', trim(fgets(STDIN)));
$x = explode(' ', trim(fgets(STDIN)));
$e = abs(max($x)-min($x));

rsort($x);
for($i=0; $i<$m-1; $i++){
  $d[$i] = abs($x[$i+1] - $x[$i]);
}

rsort($d);
for($i=0; $i<$n-1; $i++){
  $e -= $d[$i];
}

echo $e;

  
?>

Measured memory_bytes: 18932
#include <iostream>
using namespace std;
int main(void){
string s; 
cin>>s;
if(s=="SUN"){
    cout<<7<<endl;
}else if (s=="MON"){
    cout<<6<<endl;
}else if (s=="TUE"){
    cout<<5<<endl;
}else if (s=="WED"){
    cout<<4<<endl;
}else if (s=="THU"){
    cout<<3<<endl;
}else if (s=="FRI"){
    cout<<2<<endl;
}else if (s=="SAT"){
    cout<<1<<endl;
}
}

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

int main(){
    int N,M; cin >> N >> M;
    vector<int> P(M),Y(M);
    for(int i = 0; i < M; i++) cin >> P[i] >> Y[i], --P[i];
    
    // vals[v] := P[i] = v であるようなiについてのY[i]の値を集めたもの
    vector<vector<int>> vals(N);
    for(int i = 0; i < M; i++) vals[P[i]].push_back(Y[i]);
    
    //各pの値に対して
    for(int v = 0; v < N; v++){
        sort(vals[v].begin(), vals[v].end());
        
        //　今回は不要だが、通常は数のダブりをなくす
        vals[v].erase(unique(vals[v].begin(),vals[v].end()),vals[v].end());
    }
    
    //答え
    for(int i = 0; i < M; i++){
        int v = P[i];
        printf("%06d", v+1);
        
        //座標圧縮して導いた答え
        int id = lower_bound(vals[v].begin(),vals[v].end(),Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
        
    }
}


Measured memory_bytes: 9376
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = IS()
    if n[0]=='7' or n[1]=='7' or n[2]=='7': print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  auto step=[](int i, vector<lint> a){
    vector<lint> b(16);
    b[0]=a[0];
    rep_range(k,1,6){
      b[k]=a[k];
      if(i%2==0) b[k]+=b[k-1];
      b[k]%=mod;
    }
    rep_range(k,6,16){
      b[k]=a[k]+b[k-1];
      b[k]%=mod;
    }
    return b;
  };

  vector<vector<lint>> s2(16);
  rep(i,16){
    vector<lint> a(16,0);
    a[i]=1;
    s2[i]=step(2,step(1,a));
  }

  int binmax=31;
  vector<vector<vector<lint>>> sbin(binmax,
    vector<vector<lint>>(16,vector<lint>(16))
  );
  sbin[1]=s2;
  rep_range(bin,2,binmax){
    rep(x,16) rep(y,16) {
      lint s=0;
      rep(k,16) s+=sbin[bin-1][x][k]*sbin[bin-1][k][y];
      sbin[bin][x][y]=s%mod;
    }
  }

  int t;
  cin>>t;

  rep(_t,t){
    int n;
    cin>>n;

    if(n<5){
      cout<<0<<endl;
      continue;
    }
    n-=5;

    vector<lint> now(16,0);
    now[0]=1;
    now=step(0,now);
    lint i=0;
    rep_rev(bin,binmax,2){
      if(i+(1<<bin)<=n){
        vector<lint> tmp(16);
        rep(x,16) {
          lint s=0;
          rep(k,16) s+=now[k]*sbin[bin][k][x];
          tmp[x]=s%mod;
        }
        now.swap(tmp);
        i+=1<<bin;
      }
    }

    while(i+1<=n){
      now=step(i+1,now);
      i++;
      // cout<<i<<endl;
    }

    cout<<now[15]<<endl;
  }

}

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


Measured memory_bytes: 3656
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int m,f,r;
        while(true){
            m = sc.nextInt();
            f = sc.nextInt();
            r = sc.nextInt();
            if(m == -1 && f == -1 && r == -1){
                break;
            }
            if(m == -1 || f == -1){
                System.out.println('F');
            }
            else if(m + f >= 80){
                System.out.println('A');
            }
            else if(m + f >= 65){
                System.out.println('B');
            }
            else if(m + f >= 50){
                System.out.println('C');
            }
            else if(m + f >= 30){
                if (r >= 50){
                    System.out.println('C');
                }
                else {
                    System.out.println('D');
                }
                
            }
            else {
                System.out.println('F');
            }
        }
        
    }
}


Measured memory_bytes: 26076