akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete

signed main(){

    int N, A[3];
    cin>>N>>A[0]>>A[1]>>A[2];
    vector<pint> S;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        if(s=="AB"){
            S.eb(0, 1);
        }
        else if(s=="BC"){
            S.eb(1, 2);
        }
        else{
            S.eb(2, 0);
        }
    }

    string ans;

    for(int i=0;i<N;i++){
        pint p=S[i];
        int a, b;
        tie(a, b)=p;
        // cout<<a<<" "<<b<<endl;
        // cout<<A[0]<<" "<<A[1]<<" "<<A[2]<<endl;

        //両方共0のとき
        if(!A[a] && !A[b]){
            cout<<"No"<<endl;
            return 0;
        }
        //両方とも1のとき
        else if(A[a]==1 && A[b]==1 && i<N-1){
            pint next=S[i+1];
            int alpha, beta;
            tie(alpha, beta)=next;

            //次の選択肢で使われる方を増やす
            if(a==alpha || a==beta){
                ans+=char('A'+a);
                A[a]++, A[b]--;
            }
            else{
                ans+=char('A'+b);
                A[b]++, A[a]--;
            }
        }
        //両方とも2以上のとき
        else if(A[a] && A[b]){
            if(A[a]<=A[b]){
                ans+=char('A'+a);
                A[a]++, A[b]--;
            }
            else{
                ans+=char('A'+b);
                A[b]++, A[a]--;
            }
        }
        //片方が0のとき
        else if(!A[a] || !A[b]){
            if(!A[a]){
                ans+=char('A'+a);
                A[a]++, A[b]--;
            }
            else{
                ans+=char('A'+b);
                A[b]++, A[a]--;
            }
        }
    }
    cout<<"Yes"<<endl;
    for(char c:ans)
        cout<<c<<endl;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(n-1);
  int k=0;
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  for(int i=0;i<n;i++){
    int b;
    cin >> b;
    k+=b;
  }
  for(int i=0;i<n-1;i++)
    cin >> c.at(i);
  
  for(int i=0;i<n-1;i++){
    if(a.at(i)+1==a.at(i+1))
      k+=c.at(a.at(i)-1);
  }
  cout << k << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for(int i=0; i<values.length; i++){
                values[i] = i + 1;
            }
            for(int i=0; i<n; i++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0])-1;
                int b = Integer.parseInt(ab[1])-1;

                int tmp = values[a];
                values[a] = values[b];
                values[b] = tmp;
            }
            for(int i=0; i<values.length; i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 26232
#include <stdio.h>

int main(void)

{

 int W,H,x,y,r;

 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

 if( x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){

  printf("Yes\n");

 }

 else{

  printf("No\n");

 }

 return 0;


}

Measured memory_bytes: 580
#include <algorithm>
#include <queue>
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9;
const long long LLINF = 1e18;

int dfs(const vector<vector<int>> &G, int v, int p){
  int ret = 0;
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    ret = max(ret,dfs(G,v_,v)+1);
  }
  return ret;
}

long long solve(const vector<vector<int>> &G, const vector<int> &C){
  int N = G.size();
  vector<int> D(N,INF);
  queue<int> Q;
  for(auto v : C) Q.push(v), D[v] = 0;
  while(not Q.empty()){
    int v = Q.front();
    Q.pop();
    for(auto v_ : G[v]){
      if(D[v_] < INF) continue;
      D[v_] = D[v]+1;
      Q.push(v_);
    }
  }
  int d = *max_element(D.begin(), D.end());
  vector<int> dig_max(d+1,0);
  for(int i = 0; i < N; ++i){
    if(C.size() == 1 and not D[i]){
      dig_max[D[i]] = max(dig_max[D[i]],(int)G[i].size());
      continue;
    }
    dig_max[D[i]] = max(dig_max[D[i]],(int)G[i].size()-1);
  }
  long long l = C.size();
  for(int i = 0; i < d; ++i){
    l *= dig_max[i];
  }
  return l;
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for(int i = 0; i < N-1; ++i){
    int a,b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    ans = max(ans,dfs(G,i,-1));
  }
  int d = (ans+1)/2;
  vector<int> C;
  for(int i = 0; i < N; ++i){
    if(dfs(G,i,-1) != d) continue;
    C.push_back(i);
  }
  long long l = LLINF;
  if(C.size() == 2) l = solve(G,C);
  else{
    l = min(l,solve(G,C));
    int c = C[0];
    for(auto c_ : G[c]){
      //if(dfs(G,c_,-1) != d+1) continue;
      C.push_back(c_);
      l = min(l,solve(G,C));
      C.pop_back();
    }
  }
  cout << ans/2+1 << " " << l << endl;
}


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

using namespace std;

int main() {
    string s1, s2, s3;

    cin >> s1 >> s2 >> s3;
    transform (s1.begin(), s1.end(), s1.begin(), ::toupper);
    transform (s2.begin(), s2.end(), s2.begin(), ::toupper);
    transform (s3.begin(), s3.end(), s3.begin(), ::toupper);

    cout << s1[0] << s2[0] << s3[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
k, t = map(int, raw_input().split())
a = map(int, raw_input().split())

while len(a) > 1:
    a.sort()
    tmp = abs(a.pop() - a.pop())
    if tmp:
        a.append(tmp)

if not a:
    print 0
else:
    print a[0] - 1

Measured memory_bytes: 2568
using System;
using System.Linq;

namespace ALDS1_2A{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var A = sr.Next<int>(N);

            var res = 0;
            for(var i = N - 1; i >= 0; i--){
                for(var j = 0; j < i; j++){
                    if(A[j] > A[j + 1]){
                        ExMath.Swap(ref A[j], ref A[j + 1]);
                        res++;
                    }
                }
            }

            Console.WriteLine(string.Join(" ", A.Select(x => x.ToString()).ToArray()));
            Console.WriteLine(res);
            //---------------------------------
        }
    }

    public class ExMath{
        public static void Swap<T>(ref T left, ref T right){
            var tmp = left;
            left = right;
            right = tmp;
        }  
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 10160
#include <iostream>

using namespace std;

int main(){
    int N;
    cin>>N;
    int A;
    int Boss[200005]={0};
    int K = N;
    while (K--) {
        cin>>A;
        if(A==1)
            Boss[0]=Boss[0]+1;
        else
            Boss[A-1]=Boss[A-1]+1;
        if(K==1)
            break;
    }
    int i = 0;
    while (N--) {
        cout<<Boss[i]<<endl;
        i = i+1;
    }

}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
#define mp make_pair

const int MX = 200000;

int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

// Returns n^(-1) mod p
int modInverse(int n, int p){
	return power(n,p-2,p);
}

int fac[MX+5];
void init(int mod){
	fac[0] = 1;
	for (int i=1 ; i<=MX; i++)
		fac[i] = fac[i-1]*i%mod;
}

int C(int n,int r,int p){
	if (r==0)return 1;
	return (fac[n]*modInverse(fac[r],p)%p * modInverse(fac[n-r],p)%p)%p;
}

signed main(){
  const int mod=1000000007;
  init(mod);
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(auto& i:a)cin>>i;
  sort(a.begin(),a.end());
  int pos=0,neg=0;
  for(int i=n-1;i>=k-1;--i){
    int d = C(i,k-1,mod)*a[i]%mod;
    pos = (pos + d) % mod;
  }
  for(int i=0;i<=n-k;++i){
    int d = C(n-i-1,k-1,mod)*a[i]%mod;
    neg = (neg + d) % mod;
  }
  int res=pos-neg;
  while(res<0)res+=mod;
  res%=mod;
  cout<<res;
}


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

string check(string a, string b) {
  if (a.length() > b.length())
    return "GREATER";
  if (a.length() < b.length())
    return "LESS";
  for (int i = 0; i < a.length(); i++) {
    if (a[i] > b[i])
      return "GREATER";
    if (a[i] < b[i])
      return "LESS";
  }
  return "EQUAL";
}

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

  cout << check(A, B) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

void paint(vector<map<int, int>>& g, int node, vector<int>& visited) {
  if (g[node].size() == 0) return;
  int idx = 1;
  set<int> in_use;
  for (auto v : g[node]) {
    if (v.second != -1) {
      in_use.insert(v.second);
    }
  }
  debug(in_use);
  for (auto& v : g[node]) {
    if (v.second == -1) {
      if (!in_use.count(idx)) {
        v.second = idx;
        g[v.first][node] = idx;
        in_use.insert(idx);
        idx++;
      } else {
        idx++;
        v.second = idx;
        g[v.first][node] = idx;
        in_use.insert(idx);
        idx++;
      }
    }
  }
  visited[node] = 1;
  debug(node, g);
  for (auto v : g[node]) {
    if (visited[v.first] == 0) paint(g, v.first, visited);
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N - 1), b(N - 1);
  int tmp0, tmp1;
  vector<map<int, int>> g(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> tmp0 >> tmp1;
    a[i] = tmp0 - 1;
    b[i] = tmp1 - 1;
    g[a[i]][b[i]] = -1;
    g[b[i]][a[i]] = -1;
  }
  int col_num = 0;
  for (int i = 0; i < N; i++) {
    if (g[i].size() > col_num) {
      col_num = max(col_num, (int)g[i].size());
    }
  }
  vector<int> visited(N);
  paint(g, 0, visited);
  debug(g);
  cout << col_num << endl;
  for (int i = 0; i < N - 1; i++) {
    cout << g[a[i]][b[i]] << endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;

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

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

  vector<int> v;
  int now = 1;
  int cnt = 0;
  rep(i, n) {
    if (s[i] == (now + '0')) {
      ++cnt;
    } else {
      v.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if (cnt != 0) v.push_back(cnt);
  int V = v.size();
  if (V % 2 == 0) v.push_back(0);

  // vector<int> a(V + 1);
  // rep(i, V) a[i + 1] = a[i] + v[i];

  int add = 2 * k + 1;
  int ans = 0;
  int l = 0;
  int r = 0;
  int sum = 0;

  for (int i = 0; i < V; i += 2) {
    int nl = i;
    int nr = min(i + add, V);

    while (l < nl) {
      sum -= v[l];
      ++l;
    }

    while (r < nr) {
      sum += v[r];
      ++r;
    }
    // int add = 2 * k + 1;
    // int sum = a[min(i + add, V)] - a[i];
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
int main(){
    ll n;cin>>n;
    vl t(n),a(n);
    rep(i,n)cin>>t[i];
    rep(i,n)cin>>a[i];
    vl ans(n);
    ll pre=0;
    ll mx=0;
    ll mx2=0;
    rep(i,n){
        if(pre!=t[i]){
            ans[i]=t[i];
        }
        pre=t[i];
        mx=max(mx,t[i]);
    }
    rep(i,n){
        mx2=max(mx2,a[i]);
    }
    if(mx!=mx2){
        cout<<0<<endl;
        return 0;
    }
    pre=0;
    drep(i,n){
        if(ans[i]!=0&&i!=0&&i!=n-1&&pre<mx){
            if(ans[i]!=a[i]){
                cout<<0<<endl;
                return 0;
            }
        }
        if(pre!=a[i]){
            ans[i]=a[i];
        }
        pre=a[i];
    }
    ll p=0;
    ll l=0;
    ll cnt=0;
    mint ret=1;
    for(int i=1;i<n-1;i++){
        if(ans[i]==0){
            if(cnt==0){
                l=ans[i-1];
            }
            cnt++;
            if(ans[i+1]!=0){
                ll w=min(l,ans[i+1]);
                ret*=mint(w).pow(cnt);
                cnt=0;
            }
        }
    }
    cout<<ret.x<<endl;
    return 0;
}

Measured memory_bytes: 2560
N = int(input())
A = list(map(int, input().split()))
ans = 1
tip = 0
sub = 0
for i in range(N):
  ans = ans * A[i]
  if ans > 10 ** 18:
    tip = 1
    ans = 0
  if A[i] == 0:
    sub = 1
if sub == 1:
  ans = 0
elif tip == 1:
  ans = -1
print(ans)

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

int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string moneyS;
	vector<int> money;
	vector<int> money2;
	int ans = 0, ans2 = 0;
	cin>>moneyS;
	for (int i = (int)moneyS.size() - 1; i >= 0; i--) {
		money.push_back(moneyS[i]-'0');
	}
	money.push_back(0);
	money2=money;
	for (int i = 0; i < (int)money.size(); i++) {
		if (money[i] > 5 || (money[i] == 5 && money[i+1] >= 5)) {
			ans += 10-money[i];
			int j = i + 1;
			while (money[j] == 9) {
				money[j] = 0;
				j++;
			}
			money[j]++;
		}else{
			ans+=money[i];
		}
	}
	
	// for (int i = 0; i < (int)money2.size(); i++) {
	// 	if (money2[i] > 5) {
	// 		ans2 += 10-money2[i];
	// 		int j = i + 1;
	// 		while (money2[j] == 9) {
	// 			money2[j] = 0;
	// 			j++;
	// 		}
	// 		money2[j]++;
	// 	}else{
	// 		ans2+=money2[i];
	// 	}
	// }
	cout<<ans<<'\n';
	// if (ans2 < ans) {
	// 	cout<<ans<<' '<<ans2<<'\n';
	// 
	// }
	return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int i;
    cin >> i;
    int A = i / 1000;
    int B = (i - A * 1000) / 100;
    int C = (i - A * 1000 - B * 100) / 10;
    int D = i % 10;
    if (A + B + C + D == 7)
    {
        cout << A << "+" << B << "+" << C << "+" << D  << "=7"<< endl;
    }
    else if (A + B + C - D == 7)
    {
        cout << A << "+" << B << "+" << C << "-" << D  << "=7"<< endl;
    }
    else if (A + B - C + D == 7)
    {
        cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
    }
    else if (A + B - C - D == 7)
    {
        cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
    }
    else if (A - B + C + D == 7)
    {
        cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
    }
    else if (A - B + C - D == 7)
    {
        cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
    }
    else if (A - B - C + D == 7)
    {
        cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
    }
    else if (A - B - C - D == 7)
    {
        cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
    }
}

Measured memory_bytes: 256
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF 1e18

int main()
{
	io;
	ll x,y;
	cin>>x>>y;
	if(y<=4*x&&(4*x-y)%2==0&&y-2*x>=0&&(y-2*x)%2==0){cout<<"Yes";}
	else{cout<<"No";}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b,f=0;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		f++;
	}
if(f>0)
cout<<"OK";
else
cout<<"NG";



}

Measured memory_bytes: 3604
N, M, *L = map(int, open(0).read().split())
dic = [[] for i in range(N+1)]
for a,b in zip(*[iter(L)]*2):
  dic[a].append(b)
  dic[b].append(a)

log = set([1])
pre = [1]
p = 1
while True:
  for v in dic[p]:
    if v not in log:
      break
  else:
    break
  p = v
  pre.append(v)
  log.add(v)
ans = pre[::-1]
p = 1
while True:
  for v in dic[p]:
    if v not in log:
      break
  else:
    break
  p = v
  ans.append(v)
  log.add(v)
print(len(ans))
print(' '.join(map(str,ans)))

Measured memory_bytes: 35156
use std::cmp::*;
use std::io::*;
const MOD: usize = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let _: usize = itr.next().unwrap().parse().unwrap();
    let s: Vec<char> = itr.next().unwrap().chars().collect();

    let mut a = vec![0; 30];
    for &c in s.iter() {
        let i = (c as u8 - 'a' as u8) as usize;
        a[i] += 1;
    }

    let mut ans = 1;
    for i in 0..26 {
        ans = ans * (a[i] + 1) % MOD;
    }
    ans = (ans + MOD - 1) % MOD;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  string o, e; cin >> o >> e;
  int n = e.size();
  rep(i, n) {
    cout << o.at(i) << e.at(i);
  }
  if (o.size() > n) {
    cout << o.at(n);
  }
  cout << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
x = a[0]
y = sum(a)-a[0]
ans = abs(x-y)
for i in range(1, n-1):
    x += a[i]
    y -= a[i]
    if ans > abs(x-y):
        ans = abs(x-y)
print(ans)

Measured memory_bytes: 76752
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    n <- readLn
    -- スペース区切り整数の入力
    l <- map strToInt . words <$> getLine
    -- 出力
    putStrLn $ solve l n

solve :: [Int] -> Int -> String
solve l n = if lf >= lo - 1 + c then "Yes" else "No"
    where
        fours = filter ((== 0) . flip mod 4) l
        ones  = filter ((== 1) . flip mod 2) l
        lf = (length fours)
        lo = (length ones)
        c = if n == lf + lo then 0 else 1


Measured memory_bytes: 33148
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define pp4 pair<pp, pp>
#define pp3 pair<ll, pair<int, int> > 
#define fi first
#define se second
#define N  2020
#define mod 1000000007
#define inf 2000000001
#define esp 1e-9
#define BLOCK 333
#define BITNUM 555
#define BASE 311097
typedef long long ll;
// const ll oo = (ll)1e18 + 1;
using namespace std;
string s;

int main() {
    ios::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    cin >> s;
    cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a, b, c;
  scanf("%d %d %d",&a,&b,&c);
  if(a <= b && b <= c)printf("%d %d %d\n",a,b,c);
  else if(a <= c && c <= b)printf("%d %d %d\n",a,c,b);
  else if(b <= c && c <= a)printf("%d %d %d\n",b,c,a);
  else if(b <= a && a <= c)printf("%d %d %d\n",b,a,c);
  else if(c <= a && a <= b)printf("%d %d %d\n",c,a,b);
  else printf("%d %d %d\n",c,b,a);
  return 0;
}

Measured memory_bytes: 1768
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def ceil(x,y):
  return (x-1)//y+1
n = int(input())
A=[];B=[]
for i in range(n):
  a,b = map(int,input().split())
  A.append(a);B.append(b)
for i in range(n-1,-1,-1):
  count += B[i] - ((A[i]+count-1)%B[i]+1)
print(count)


Measured memory_bytes: 51676
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////

int main(){
    int n,m;cin>>n>>m;
    int c[n];memset(c,0,sizeof(c));
    while(m--){
        int x,y;cin>>x>>y;x--;y--;
        c[x]++;c[y]++;
    }
    rep(i,0,n-1){
        if(c[i]%2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    
    //変数：乗車券を「　b1　」と特急券を「　b2　」と乗車・特急券を「　b3　」と置く
    int b1, b2, b3;
    
    //入力：乗車券を「　b1　」と特急券を「　b2　」と乗車・特急券を「　b3　」を入力する
    cin >> b1 >> b2 >> b3;
    
    //条件⓵：乗車券を「あり」と特急券を「なし」と乗車・特急券を「なし」
    //条件⓶：乗車券を「なし」と特急券を「あり」と乗車・特急券を「なし」
    //条件⓷：乗車券を「あり」と特急券を「あり」と乗車・特急券を「なし」
    //条件⓸：乗車券を「なし」と特急券を「なし」と乗車・特急券を「あり」
    //条件⓹：乗車券を「なし」と特急券を「なし」と乗車・特急券を「なし」
    //注意：今回ありは「　1　」、なしを「　0　」と置いている
    if( b1 == 1 && b2 == 0 && b3 == 0) cout << "Close" << endl;
    else if( b1 == 0 && b2 == 1 && b3 == 0) cout << "Close" << endl;
    else if( b1 == 1 && b2 == 1 && b3 == 0) cout << "Open" << endl;
    else if( b1 == 0 && b2 == 0 && b3 == 1) cout << "Open" << endl;
    else cout << "Close" << endl;

}


Measured memory_bytes: 3100
#include <iostream>
#include <math.h>
using namespace std;


int main(){
	int e;
	while(cin >> e && e > 0){
	    int min = 1000000;
		for (int y = 0; y <= 1000; y++){
			for (int z = 0; z <= 100; z++){
				int x = e - z*z*z - y*y;
				if ((x + y + z < min) && (x >= 0)){
					min = x + y + z;
				}

			}
		}
		cout << min << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, m, x;
	cin >> n >> m >> x;
	vi c(n);
	vvi a(n, vi(m));

	rep(i, n) {
		cin >> c[i];
		rep(j, m)cin >> a[i][j];
	}

	int ans = INF;

	rep(i, 1 << n) {
		int cost = 0;
		vi learn(m, -x);

		rep(j, n)if ((i >> j) & 1) {
			cost += c[j];
			rep(k, m)learn[k] += a[j][k];
		}

		bool ok = true;
		rep(j, m)if (learn[j] < 0)ok = false;
		if (ok)ans = min(ans, cost);
		
	}

	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

const int INF = int(1e9 + 7);
typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    int a, b;
    cin >> a >> b;
    int A = 1, B = 3;
    int res;
    for (int x = 2, y = 3; B <= 499500; x++, y++)
    {
    	if (A-a == B-b && A-a >= 0)
    	{
    		res = A-a;
    		break;
    	}
    	A += x;
    	B += y;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N) {
  ll result = 0;
  for (int i = 1; i <= N; i += 2) {
    ll d = 0;
    for (int j = 1; j <= (N / 2); j++) {
      if (i % j == 0)
        d++;
      if (d > 7)
        break;
    }
    if (d == 7)
      result++;
  }

  cout << result << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


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

using namespace std;

int main(){

	string str;
	while(cin>>str&&str!="0"){
		vector<string> field;
		field.push_back(str);
		for(int i = 0; i < 2; i++){
			cin>>str;
			field.push_back(str);
		}
		bool fin=false;
		// æ±
		for(int i = 0; i < 3; i++){
			bool f=false;
			char ch=field[i][0];
			if(ch!='+'){
				for(int j = 1; j < 3; j++){
					if(ch!=field[i][j]){
						f=true;
						break;
					}
				}
				// sè
				if(!f){
					cout<<ch<<endl;
					fin=true;
					break;
				}
			}
		}
		if(!fin){
			// ½Ä
			for(int i = 0; i < 3; i++){
				bool f=false;
				char ch=field[0][i];
				if(ch!='+'){
					for(int j = 1; j < 3; j++){
						if(ch!=field[j][i]){
							f=true;
							break;
						}
					}
					// sè
					if(!f){
						fin=true;
						cout<<ch<<endl;
						break;
					}
				}
			}
			if(!fin){
				// ÈÈß
				char ch=field[0][0];
				if(ch!='+'&&field[1][1]==ch&&field[2][2]==ch){
					fin=true;
					cout<<ch<<endl;
				}
				else if(field[1][1]!='+'&&field[1][1]==field[2][0]&&field[2][0]==field[0][2]){
					fin=true;
					cout<<field[1][1]<<endl;
				}
				else
					cout<<"NA"<<endl;
			}
		}
	}
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  long long N = S.size();
  long long dp[N];
  long long pow_10 = 1;
  for (int i = N - 1; i >= 0; i--){
    if (i == N - 1) dp[i] = S[i] - '0';
    else dp[i] = (dp[i + 1] + (S[i] - '0') * pow_10) % 2019;
    pow_10 *= 10; pow_10 %= 2019;
  }
  long long count = 0;
  long long sum[2019];
  for (int i = 0; i < 2019; i++) sum[i] = 0;
  for (int i = 0; i < N; i++){
    sum[dp[i]]++;
  }
  sum[0]++;
  for (int i = 0; i < 2019; i++){
    count += sum[i] * (sum[i] - 1) / 2;
  }
  cout << count << endl;
}

Measured memory_bytes: 5260
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
int n,i,f[500005];
long long sum;
string st;
int main(){
	cin>>st;n=st.size();
	rep(i,n){
		if(st[i-1]=='<') f[i]=max(f[i],f[i-1]+1);
	}
	rep(i,n){
		if(st[n-i]=='>') f[n-i]=max(f[n-i],f[n-i+1]+1);
	}
	rep(i,n+1){
		sum+=f[i-1];
	}cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5828
def examA():
    AB = [I() for _ in range(2)]
    for i in range(1,4):
        if not i in AB:
            ans = i
            break
    print(ans)
    return

def examB():
    N = I()
    S,T = LSI()
    ans = ""
    for i in range(N):
        ans += S[i]+T[i]
    print(ans)
    return

def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examC():
    A, B = LI()
    ans = lcm(A,B)
    print(ans)
    return

def examD():
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 38488
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
  int N,i,ans=0;
  scanf("%d", &N);
  if (N >= 10) {
    ans += 9;
  }
  else {
    ans += N;
    goto end;
  }
  if (N < 100) {
    goto end;
  }
  if (N >= 1000) {
    ans += 900;
  }
  else {
    ans += N-99;
    goto end;
  }
  if (N < 10000) {
    goto end;
  }
  if (N >= 100000) {
    ans += 90000;
  }
  else {
    ans += N-9999;
    goto end;
  }
  end:
  printf("%d", ans);
  return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

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

    if(b==1){
        cout<<0<<endl;
    }

    else {
    int sum=1,ans=0;

    for(int i=1;i<21;i++){
        sum=(sum-1)+a;
        if(sum>=b){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    }
}



Measured memory_bytes: 256
def dif_temp(T, A, x):
    return abs(T - x * 0.006 - A)

N = int(input())
T, A = map(int, input().split())
H = [dif_temp(T, A, int(i)) for i in input().split()]
for i in range(N):
    if H[i] == min(H):
        print(i + 1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>

int b()
{
    int n, m;
    std::cin >> n >> m;
    
    std::vector<int> vote(n);
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        int temp;
        std::cin >> temp;
        vote[i] = temp;
        sum += temp;
    }
    
    std::sort(vote.begin(), vote.end(), std::greater<int>());
    
    int th = sum / (4 * m);
    if(sum % (4 * m) == 0)
    {
        th--;
    }
    
    if(th < vote[m-1])
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    
    return 0;
}


int main(int argc, const char * argv[])
{
    b();
    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 n = sc.nextInt();
		int m = sc.nextInt();

		int[] s = new int[m];
		int[] p = new int[m];

		for (int i = 0; i < m; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt();
				s[i] += Math.pow(2, a - 1);
			}
		}

		for (int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
		}

		int N = (int) Math.pow(2, n);

		int ans = 0;

		for (int i = 0; i < N; i++) {
			int flag = 1;
			for (int j = 0; j < m; j++) {
				int count = i & s[j];
				int bits = 0;
				while (count != 0) {
					if ((count & 1) == 1) {
						bits++;
					}
					count = count >>> 1;
				}
				if (bits % 2 != p[j]) {
					flag = 0;
					break;
				}
			}
			if (flag == 1) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 23892
import Data.List

trans::String->[Bool]
trans = (map (\(i,b)->if mod i 2 == 0 then b else not b)).(zip [0..]).(map (\c-> c=='0'))


main::IO()
main=print.solver=<<getLine

eat_with_stack::[Bool]->[Bool]->Int
eat_with_stack _ []      = 0
eat_with_stack [] (y:ys) = eat_with_stack (y:[]) ys
eat_with_stack (x:xs) (y:ys) = if x == y then 2 + (eat_with_stack xs ys) else eat_with_stack (y:x:xs) (ys)

solver::String->Int
solver = (eat_with_stack []).trans


Measured memory_bytes: 7548
A, B, K = list(map(int, input().split()))

if (A+K) < (B-K+1):  
  for x in range(A,A+K):
    print(x)

  for x in range(B-K+1,B+1):
    print(x)
else:
  for x in range(A,B+1):
    print(x)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		if(n % 111 == 0) {
			System.out.println(n);
		}else {
			for(int i = 111; i <= 999; i+=111) {
				if(n <= i) {
					System.out.println(i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		int ans = 0;
		for (int i = a; i <= b; i++) {
			String temp1 = String.valueOf(i).substring(0, 1);
			String temp2 = String.valueOf(i).substring(1, 2);
//			String temp3 = String.valueOf(i).substring(2, 3);
			String temp4 = String.valueOf(i).substring(3, 4);
			String temp5 = String.valueOf(i).substring(4, 5);

			if ( temp1.equals(temp5) && temp2.equals(temp4)) {
				ans ++;
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 41172
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

a, b = na()

if a > b:
    c = a
    a -= 1
else:
    c = b
    b -= 1

if a > b:
    c += a
    a -= 1
else:
    c += b
    b -= 1




print(c)


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  string S;
  cin>>S;
  bool rain=false;
  int c=0;
  int ans=0;
  for(int i=0;i<S.size();i++){
    if(rain){
      if(S[i]=='R'){
        c++;
      }
      else{
        ans=max(ans,c);
        c=0;
        rain=false;
      }
    }
    else{
      if(S[i]=='R'){
        c++;
        rain=true;
      }
    }
  }
  cout<<max(ans,c)<<endl;
  return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def p(n, k, mod):
  x = 1
  for ik in range(k):
    x *= (n - ik)
    x %= mod
  return x

MAX = 10 ** 9 + 7
def main():
  n, m = map(int, input().strip().split())
  s = 0
  nck = 1
  mpk = 1
  mkpnk = p(m, n, MAX)
  for k in range(0, n+1):
    if 0 < k <= n:
      nck *= (n - (k-1)) * pow(k, MAX-2, MAX) 
      nck %= MAX
    if 0 < k <= m:
      mpk *= (m - (k-1))
      mpk %= MAX
    if 0 < k <= n:
      mkpnk *= pow(m - (k - 1), MAX-2, MAX) 
      mkpnk %= MAX
    s += nck * ( (-1) ** k) * mpk * (mkpnk) ** 2
    s %= MAX
  print(s)
  

if __name__=='__main__':
  main()



Measured memory_bytes: 73660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    for(;;) {
        C -= B;
        if(C <= 0) {
            cout << "Yes" << endl;
            break;
        }

        A -= D;
        if(A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        br.readLine();
        List<Integer> data = Stream.of(br.readLine().split(" "))
            .map(e -> Integer.valueOf(e)).collect(Collectors.toList());
        Optional<Integer> min = data.stream().min(Comparator.naturalOrder());
        Optional<Integer> max = data.stream().max(Comparator.naturalOrder());
        long total = data.stream().mapToLong(e -> e).sum();
        System.out.println(min.get() + " " + max.get() + " " + total);
    }
}

Measured memory_bytes: 33392
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
bool fn(vector<vector<lg>>& gr,vector<vector<lg>>& nodes)
{
    lg l = gr.size();
    lg n = nodes.size();
    lg j=0;

    if(n>l) return false;

    for(lg i=0;i<l;i++)
    {
        if(nodes[j][0]==gr[i][0] && nodes[j][1]==gr[i][1])
            j++;

        if(j==n) return true;

        if(nodes[j][0]<gr[i][0])
            return false;
    }
    return false;
}
int main()
{
    lg n,m,t;
    cin>>n>>m>>t;

    vector<lg>rows(n,0);
    vector<lg>cols(m,0);
    vector<vector<lg>>gr;
    vector<lg>cord(2,0);
    for(lg i=0;i<t;i++)
    {
        lg a,b;
        cin>>a>>b;
        cord[0]=a-1;
        cord[1]=b-1;
        gr.pb(cord);
        rows[a-1]++;
        cols[b-1]++;
    }
    sort(gr.begin(),gr.end());
    lg r=0,c=0;
    for(lg i=0;i<n;i++)
        r=max(r,rows[i]);
    vector<lg>rr;
    for(lg i=0;i<n;i++)
        if(rows[i]==r)
            rr.pb(i);

    for(lg i=0;i<m;i++)
        c=max(c,cols[i]);
    vector<lg>cc;
    for(lg i=0;i<m;i++)
        if(cols[i]==c)
            cc.pb(i);

    lg maxnum=r+c;

    vector<vector<lg>>nodes;

    lg x=rr.size();
    lg y=cc.size();
    if(x*y>t)
    {
        cout<<maxnum<<endl;
    }
    else
    {
        for(lg i=0;i<x;i++)
            for(lg j=0;j<y;j++)
            {
                cord[0]=rr[i];
                cord[1]=cc[j];
                nodes.pb(cord);
            }

        if(fn(gr,nodes))
            maxnum--;

        cout<<maxnum<<endl;
    }
}



Measured memory_bytes: 48036
#define R register
#define ll long long
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;

int n, k, a[maxn], b[maxn];

int main()
{
    scanf("%d%d", &n, &k);
    if(k == 2) return printf("%d", n - 1), 0;
    if(k == n) return puts("1"), 0;
    if((n - 1) % (k - 1) == 0) printf("%d", (n - 1) / (k - 1));
    else printf("%d", (n - 1) / (k - 1) + 1);
    return 0;
}

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

int main()
{
  int l,r,n,res=0;
  cin>>l>>r>>n;
  for(int i=l;i<=r;i++)
  {
     if(i%n==0)
     {
       res++;
     }
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int N,M;
  cin>>N>>M;
  vector<pair<ll,ll>> vec;
  ll sum=0;
  for(int i=0;i<N;i++){
    ll a;
    cin>>a;
    vec.push_back(make_pair(a,1));
  }
  
  for(int i=0;i<M;i++){
    ll b,c;
    cin>>b>>c;
    vec.push_back(make_pair(c,b));
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  ll k=0;
  while(N>0){
    if(vec[k].second>N) {
      sum+=N*vec[k].first;
      break;
    }
    sum+=vec[k].second*vec[k].first;
    N-=vec[k].second;
    k++;
  }
  cout<<sum;
}

Measured memory_bytes: 6256
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

MOD = 10**9 + 7

MAXN = 2 * 10**5

fact, inv_fact = [0] * (MAXN + 1), [0] * (MAXN + 1)
fact[0] = 1
for i in range(MAXN):
    fact[i + 1] = fact[i] * (i + 1) % MOD

inv_fact[-1] = pow(fact[-1], MOD - 2, MOD)
for i in reversed(range(MAXN)):
    inv_fact[i] = inv_fact[i + 1] * (i + 1) % MOD


def nCr_mod(n, r):
    res = 1
    while n or r:
        a, b = n % MOD, r % MOD
        if a < b:
            return 0
        res = res * fact[a] % MOD * inv_fact[b] % MOD * inv_fact[a - b] % MOD
        n //= MOD
        r //= MOD
    return res


def main():
    n, k = map(int, input().split())
    for i in range(1, k + 1):
        print((nCr_mod(n - k + 1, i) * nCr_mod(k - 1, i - 1)) % MOD)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 35820