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

const int N = 10005;

using namespace std;

int a[N];

int main() {
	int n, x, y; cin >> n >> x >> y;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	int first = 0, sec = 0, thi = 0;
	for(int i = 0;i < n;i++){
		if(a[i] <= x){
			first++;
		}if(a[i] >= x+1 && a[i] <= y){
			sec++;
		}if(a[i] >= y+1){
			thi++;
		}
	}
	cout << min(first,min(sec, thi));
	return 0;
}

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

def max(a,b):
    if a >= b:
        return b
    else:
        return a
def min(n,a,b):
    if n-a-b > 0:
        return 0
    else:
        return abs(n-a-b)
print(max(a,b),min(n,a,b))

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

using namespace std;
#define ll long long
const int N = 1e5 + 5;
vector<int> jobs[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (m - a + 1 > 0)
            jobs[m - a + 1].push_back(b);
    }
    priority_queue<int> pq;
    int ans = 0;
    for (int i = m; i >= 1; i--) {
        for (auto x:jobs[i]) pq.push(x);
        if (pq.size()) ans += pq.top(), pq.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
// AOJ 0504: Card Game II
// 2017.12.6 bal4u@uu

#include <stdio.h>
#include <string.h>

#define N 6
char ans[10015];
int d[10015];

void calc(int b, int n)
{
	int i, a = 1;

	for (i = 0; i <= n; i++) {
		if (a >= b) d[i] += a / b, a %= b;
		if (!a) break;
		a *= 10;
	}
}

int main()
{
	int n, k, m, r, i;
	
	while (scanf("%d%d%d%d", &n, &k, &m, &r) && n > 0) {
		r += N;
		memset(d, 0, sizeof(d));
		calc(n, r);
		if (m == 1) for (k = n, i = 1; i < n; i++, k+=n) calc(k, r);
		for (k = 0, i = r; i >= 0; i--) {
			k += d[i];
			if (k >= 10) ans[i] = '0' + k % 10, k /= 10;
			else         ans[i] = '0' + k, k = 0;
		}
		ans[r-N+1] = 0;
		putchar(ans[0]), putchar('.'), puts(ans+1);
	}
	return 0;
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
    using namespace std;
    int main() {
      int n;
      cin>>n;
      for(int i=1 ; i<=9 ; i++) {
        for(int j=1 ; j<=9 ; j++) {
          if(i*j==n) {
            cout<<"Yes";
            return 0;
          }
        }
      }
      cout<<"No";
    }

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n-h+1) * (n-w+1) << endl;
}

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


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

int main(int argc, char const *argv[])
{
    int a,b;
    cin >> a >> b;
    if(a<b) {
        cout << "a" << " < " << "b" << endl;
    }
    else if(a==b) {
        cout << "a" << " == " << "b" << endl;
    }
    else {
        cout << "a" << " > " << "b" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int r; cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 256
#define s(X,Y,Z) (t=X,X=Y,Y=t,f(Z?&X:&Y),a&7)
f(int*a){*a=(*a&7)<<4|*a>>4;}k,m,a,b,c,t,r;main(n){while(scanf("%d",&n),n){for(r=1,a=97,b=82,c=67;n--;scanf(" %c%*s",&k),m=k-76,r+=m%6==0?s(c,b,m):1<m&&m<8?s(b,a,m^7):s(c,a,m>0));printf("%d\n",r);}}

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

int main(){
  int N;
  cin >> N;
  
  int t[100010];
  int x[100010];
  int y[100010];
  t[0] = x[0] = y[0] = 0;
  
  rep(i,N){
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  
  bool can = true;
  rep(i,N){
    int time = t[i+1]-t[i];
    int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(time < dist) can = false;
    if(time%2 != dist%2) can = false;
  }
  
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  int s;
  cin >> s;
  ll ans=0;
  while(1){
    bool b = true;
    string a = to_string(s);
    for(int i = 1;i <a.length();i++){
      if(a[0]!=a[i]){
        b = false;
        break;
      }
      ans = s;
    }
    if(b){
      break;
    }
    s++;
  }
  pri(ans);
  return 0;
}


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

const long M = 1046527;
string H[M];

long getKey(string str){
    long sum = 0 , digit = 0 , p = 1;
    for (int i = 0; i < str.size() ; ++i) {
        if (str[i] == 'A') {
            digit = 1;
        } else if (str[i] == 'C') {
            digit = 2;
        } else if (str[i] == 'G') {
            digit = 3;
        } else if (str[i] == 'T') {
            digit = 4;
        } else digit = 0;
        sum += p * digit;
        p *= 5;
    }
    return sum;
}

long hash1(long x) { return x % M ; }
long hash2(long x) { return 1 +  x % (M - 1)   ;}

long insert(string str){
    long x =getKey(str);
    for (int i = 0;  ; i++) {
            long h = (hash1(x) +  i ) % M;
            if (H[h] == str) return 1;
            else if (H[h].size() == 0){
                H[h] = str;
                return 0;
            }
        }
    }


long find(string str){
    long x =getKey(str);
    for (int i = 0;  ; i++) {
        long h = (hash1(x) +  i ) % M;
        if (H[h] == str) return 1;
        else if (H[h].empty()) return 0;
    }
}

int main(){
    string str,com;
    int n;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> com >> str;
        if(com == "insert"){
            insert (str);
        } else if (com == "find") {
            if(find (str)){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 25876
import math
n = float(input())
a = math.floor(n/1.08)
x = []
if math.floor((a)*1.08) == n:
  print(a)
elif math.floor((a+1)*1.08) == n:
  print(a+1)
elif math.floor((a+2)*1.08) == n:
  print(a+2)
elif math.floor((a+3)*1.08) == n:
  print(a+3)
elif math.floor((a-1)*1.08) == n:
  print(a-1)
else:
  print(":(")

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

int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    bool flag = true;
    int sz = s.size();
    rep(i,sz) if(s[i] != t[i]) flag = false;
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int mo = 1e9 + 7, sz = 5e3;
typedef long long ll;
int a,b,c;
int d[8],e[3][sz];
const int INF = mo/4;

void shortestPath(vector<vector<int> > & dist)
{
    int n=dist.size();
    for(int k=0;k<n;k++)
    {
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);

            }

        }
    }
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>a>>b>>c;
    vector<int> v(c);
    for(int i=0;i<c;i++)
    {
        cin>>v[i];
        --v[i];
    }
    sort(begin(v),end(v));

    vector<vector<int> > dist(a,vector<int>(a,INF));

    for(int i=0;i<b;i++)
    {
        int A,B,C;
        cin>>A>>B>>C;
        --A,--B;
        dist[A][B]=dist[B][A]=C;
    }
    shortestPath(dist);
    
    int ans=INF;
    do
    {
        int sum=0;
        for(int i=1;i<c;i++)sum+=dist[v[i-1]][v[i]];
        ans=min(ans,sum);

    }while(next_permutation(begin(v),end(v)));
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

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

    int m;
    cin >> m;
    cout << 48-m << endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (int NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  ll n,m;
  
  cin >> n >> m;
  
  BREP(i,m/n+1){
    
    if(m%i == 0){
      cout<<i<<endl;
      return 0;
    }
    
  }
}

Measured memory_bytes: 256
#----------------------------------------------------------
P = 10**9 + 7
N = 200001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b:
        return -1 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
#----------------------------------------------------------

n, k = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a, key=lambda x: x, reverse=False)
ans = 0
# a[i]が最小値になる場合の数
for i in range(len(a)):
    tmp = comb(n-1-i, k-1)
    if tmp<0:
        continue
    if a[i] < 0:
        ans = (ans + (abs(a[i])*tmp)%P)%P
    else:
        ans = (ans - (abs(a[i])*tmp)%P + P)%P

# a[i]が最大値になる場合の数
for i in range(len(a)):
    tmp = comb(n-1-i, k-1)
    if tmp<0:
        continue
    if a[n-1-i] < 0:
        ans = (ans - (abs(a[n-1-i])*tmp)%P + P)%P
    else:
        ans = (ans + (abs(a[n-1-i])*tmp)%P)%P
print(ans)


Measured memory_bytes: 37856
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, W;
  cin >> N >> W;
  vvi WV(N, vi(2));
  cin >> WV;

  vi dp(1000 * N + 1, INF);
  dp[0] = 0;
  rep(i, N){
    rrep(j, 1000 * N, 0){
      if(j - WV[i][1] >= 0 and dp[j - WV[i][1]] + WV[i][0] <= W){
        chmin(dp[j], dp[j - WV[i][1]] + WV[i][0]);
      }
    }
  }
  i64 ans = 0;
  rep(i, 1000 * N + 1){
    if(dp[i] <= W) ans = i;
  }
  cout << ans << "\n";
}

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

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

int main() {
  int N;

  cin >> N;

  vector<int> d(N);

  for(int i=0; i<N; i++) {
      cin >> d.at(i);
  }

  vector<int> sort(N,0);

  for(int i=0; i<N; i++) {
      for(int j=0; j<N; j++) {
          if(sort.at(i) <= d.at(j)) sort.at(i)=d.at(j);
      }
      for(int j=0; j<N; j++) {
          if(sort.at(i) == d.at(j)) {
              d.at(j)=0;
              break;
          }
      }
  }

  int count=1;
  for(int i=0;i<N-1;i++) {
      if(sort.at(i) > sort.at(i+1)) count++;
  }

  cout << count << endl;
}

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

int main() {
  int N;

  cin >> N;

  vector<int> d(N);

  for(int i=0; i<N; i++) {
      cin >> d.at(i);
  }

  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());

  int count=1;
  for(int i=0;i<N-1;i++) {
      if(d.at(i) > d.at(i+1)) count++;
  }

  cout << count << endl;
}*/

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

int isprime(int n);
int isSmallTwinPrime(int n);
int GetMaxTwinPrimeNumber(int argRange);

int main()
{
	int const size = 10000;
	int data[size];	
	
	int i=0;
	while(1) //for(int i=0; data[i]!=0; i++)
	{
		cin >> data[i];
		if(data[i]<=0) break;
		i++;
	}
	
	int outputNum;
	
	for(int i=0; data[i]!=0; i++)
	{
		outputNum = GetMaxTwinPrimeNumber(data[i]);
		if(outputNum!=0)
		{
			cout << outputNum-2 << " " << outputNum << endl;
		}
	}
	
	return 0;
}

int isprime(int n) 
{
	for(int i = 2; i * i <= n; i++) 
	{
		if(n % i == 0) 
		{
			return 0;
		}
	}
	return 1;
}

int isSmallTwinPrime(int n)
{
	for(int i = 2; i * i <= n; i++) 
	{
		if((n-2) % i == 0) 
		{
			return 0;
		}
	}
	return 1;
}

int GetMaxTwinPrimeNumber(int argRange)
{
	int maxTwinPrimeNum = 0;
	
	for(int i=0; ; i++)
	{
		int Num = argRange - i;
		
		if(isprime(Num)==1 && isSmallTwinPrime(Num)==1)
		{
			maxTwinPrimeNum = Num;
			return maxTwinPrimeNum;
		}
		
		if(Num==0)
		{
			return 0;
		}
	}
}

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

int main() {
  string s;
  cin >> s;
  int l = 0;
  int r = s.size() - 1;

  int ans = 0;
  while (l < r) {
    if (s[l] != s[r]) ans++;
    l++;
    r--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int dp[100005];
int n,k;
int a[100005];

int main()
{
//	freopen("input.txt","r",stdin);
	memset(dp,0x3f,sizeof(dp));
	ios_base::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	dp[0]=0;
	for(int i=0;i<n-1;i++)
	{
		for(int j=1;j<=k;j++)
		{
			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
  
  int H, W, D, Q;
  cin >> H >> W >> D;
  vector A(H, vector<int>(W));
  vector<P> point(H * W + 1);
  rep(i,H) rep(j,W) {
    cin >> A[i][j];
    point[A[i][j]] = make_pair(i, j);
  }
  cin >> Q;
  vector<int> L(Q), R(Q);
  rep(i,Q) cin >> L[i] >> R[i];

  vector<ll> sum(H * W + 1, 0);
  rep(k,D) {
    int now = (D == 0 ? D : k);
    while (now + D <= H * W) {
      int next = now + D;
      sum[next] = sum[now];
      sum[next] += abs(point[now].first - point[next].first);
      sum[next] += abs(point[now].second - point[next].second);
      now = next;
    }
  }

  rep(i,Q) {
    cout << (sum[R[i]] - sum[L[i]]) << endl;
  }

  return 0;
}

Measured memory_bytes: 5872
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i = 0; i < n; i++){
    cin >> A.at(i);
  }
  int q;
  cin >> q;
  vector<int> M(q);
  for(int i = 0; i < q; i++){
    cin >> M.at(i);
  }
  set<int> s;
  for(int tmp = 1; tmp < (1 << n); tmp++){
    bitset<20> bit(tmp);
    int sum = 0;
    for(int i = 0; i < n; i++){
      if(bit.test(i)){
        sum += A.at(i);
      }
    }
    s.insert(sum);
  }
  for(int i = 0; i < q; i++){
    if(s.count(M.at(i))) cout << "yes" << endl;
    else cout << "no" << endl;
  }

}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(ll int a, ll int b) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
int gcd(int a,int b)
{
    if(a<b)
        swap(a,b);
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
	faltu;
	int n,d;
	cin>>n>>d;
	d*=2;
	d++;
	cout<<(n+d-1)/d<<endl;

}










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

int main(void){
    long long int n,a,b;
    cin >> n >> a >> b;
    if(a == 0)cout << 0;
    else {
        long long int ans = (n / (a+b))*a;
        if(n % (a+b) != 0){
            if(n % (a+b) < a)ans += (n % (a+b));
            else ans += a;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   int i_tmp = N, sum = 0;
   for(int i = 0; i < 8; i++){
      sum += i_tmp % 10;
      i_tmp /= 10;
   }

   cout << (N % sum == 0 ? "Yes" : "No") << endl;

   return 0;
}

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

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

    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
  	sort(x.begin(),x.end());
    int total = 0;
  	rep(i,n){
    	total += x[i];
    }
  	int p = total/n;
    int fiz_1 = 0;
  	int fiz_2 = 0;
    rep(i,n){
        fiz_1 += (x[i] - p)*(x[i] - p);
    }
  	int p_1 = p+1;
  	rep(i,n){
        fiz_2 += (x[i] - p_1)*(x[i] - p_1);
    }
    cout << min(fiz_1,fiz_2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
typedef  long long ll;
using namespace std;

int main(void) {
	ll N;
	cin >> N;
	vector<ll> X(N);
	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
	}

	ll ans = 100000000;
	

	for (int i = 0; i <= 100; i++)
	{
		ll distancce = 0;
		for (int j = 0; j < N; j++)
		{
			distancce += (X[j] - i) * (X[j] - i);
			
		}
		if (ans > distancce)
			{
				ans = distancce;
			}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long  int
int main()
{   ll n;
cin>>n;
 vector<pair<int,int> >v(n+1);
    for(ll i=1;i<=n;i++){
        cin>>v[i].first;
       v[i].second=i;
}
sort(v.begin(),v.end());
  for(ll i=1;i<=n;i++)
    cout<<v[i].second<<" ";



}


Measured memory_bytes: 1536
n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
m = A[0]
for i in range(n-1):
    if A[i+1] <= 2*m:
        ans += 1
    else:
        ans = 1
    m += A[i+1]
print(ans)

Measured memory_bytes: 63856
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 120000;
typedef long long ll;
int n,m,k;
int a[4];
bool ok(){
    if(a[0]==a[1]&&a[0]!=a[2])
        return 1;
    if(a[1]==a[2]&&a[0]!=a[2])
        return 1;
    return 0;
}
int main(){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(ok()){
        puts("Yes");
    }
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::collections::HashSet;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn main() {
    let mut s = read::<String>();
    let cset: HashSet<char> = s.chars().clone().collect();
    let alpha: HashSet<char> = "abcdefghijklmnopqrstuvwxyz".chars().collect();
    let mut rest: Vec<char> = alpha.difference(&cset).cloned().collect::<Vec<char>>();
    rest.sort();
    let ans:String = if rest.len() != 0 {
        s.push(rest[0]);
        s
    } else {
        let cv: Vec<char> = s.chars().collect();
        let mut tail = vec![cv[25] as u8];
        let mut an: String = String::from("-1");
        for i in 1..26 {
            if cv[25-i] > char::from(tail[0]) {
                tail.insert(0,cv[25-i] as u8);
            } else {
                tail.sort();
                let add = tail.iter().cloned().fold(tail[tail.len()-1] as u8,|c,x| if (cv[25-i] as u8) < x && x < c {x} else {c});
                let mut anv = cv[..25-i].iter().cloned().map(|c| c as u8).collect::<Vec<u8>>();
                anv.push(add as u8);
                an = String::from_utf8(anv).ok().unwrap();
                break;
            }
        }
        an
    };
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<map>

using namespace std;

int main(void){
	std::ios_base::sync_with_stdio();

	int n;
	int arr[12];
	int arr2[12];
	int cnt;
	map<int,int> ind;
	bool f;

	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		f=true;
		cnt=-1;
		while(f){
			cnt++;
			ind.clear();
			for(int i=0;i<n;i++){
				arr2[i]=arr[i];
			}
			for(int i=0;i<n;i++){
				ind[arr[i]]=0;
			}
			for(int i=0;i<n;i++){
				ind[arr[i]]++;
			}
			for(int i=0;i<n;i++){
				arr[i]=ind[arr[i]];
			}
			f=false;
			for(int i=0;i<n;i++){
				if(arr[i]!=arr2[i]) f=true;
			}
		}
		cout<<cnt<<endl;
		for(int i=0;i<n-1;i++){
			cout<<arr[i]<<" ";
		}
		cout<<arr[n-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
 
int a[N*N];
int G[N][N];
int main() {
//	freopen("in15.txt","r",stdin);
    int h,w,n;
    scanf("%d%d",&h,&w);
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
 
    int cnt=1;
    for(int i=1; i<=h; i++) {
        if(i%2) {
            for(int j=1; j<=w; j++) {
                if(a[cnt]==0) {
                    cnt++;
                    G[i][j]=cnt;
                    a[cnt]--;
                }
                else if(a[cnt]>0) {
                    G[i][j]=cnt;
                    a[cnt]--;
                }
            }
        }
        else {
            for(int j=w; j>=1; j--) {
                if(a[cnt]==0) {
                    cnt++;
                    G[i][j]=cnt;
                    a[cnt]--;
                }
                else if(a[cnt]>0) {
                    G[i][j]=cnt;
                    a[cnt]--;
                }
            }
        }
    }
 
    for(int i=1; i<=h; i++) {
        for(int j=1; j<=w; j++)
            printf("%d ",G[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n, a[100010], t[100010];
int memo[100010];
int height[100010];
bool d[100010];
signed main() {
	cin >> n;
	fill(memo, memo + n, INF);
	rep(i, n) {
		cin >> a[i];
		if (!i || a[i - 1] != a[i]) {
			d[i] = true;
			height[i] = a[i];
		}
		else memo[i] = min(memo[i], a[i]);
	}
	rep(i, n)cin >> t[i];
	reverse(t, t + n);
	rep(i, n) {
		if (!i || t[i - 1] != t[i]) {
			d[n - i - 1] = true;
			height[n - i - 1] = t[i];
		}
		else memo[n - i - 1] = min(memo[n - i - 1], t[i]);
	}
	rep(i, n) {
		if (!d[i])height[i] = 1;
	}
	if (height[0] != a[0]) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < n; i++) {
		if (a[i] != max(a[i - 1], height[i])) {
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n - 1) {
		if (t[n - i - 1] != max(t[n - i - 2], height[i])) {
			cout << 0 << endl;
			return 0;
		}
	}
	if (height[n - 1] != t[0]) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 1;
	rep(i, n) {
		if (!d[i])ans *= memo[i];
		ans %= moder;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct Query {
  i64 type, a, b;
};

i64 n;
vector<Query> qs;
int main() {
  cin >> n;
  init_n(qs, n);
  set<i64> st;
  for (i64 i = 0; i < n; ++i) {
    cin >> qs[i].type;
    if (qs[i].type == 1) {
      cin >> qs[i].a >> qs[i].b;
      st.insert(qs[i].a);
    }
  }
  map<i64, i64> mp;
  for (i64 x : st) {
    mp[x] = mp.size() + 1;
  }

  priority_queue<i64> lpq;
  priority_queue<i64, vector<i64>, greater<i64>> rpq;
  i64 bs = 0, cnt = 0, lsum = 0, rsum = 0;
  for (i64 i = 0; i < n; ++i) {
    const Query& q = qs[i];
    if (q.type == 1) {
      bs += q.b;
      if (lpq.empty() || q.a <= lpq.top()) { 
        lpq.push(q.a);
        lsum += q.a;
      } else {
        rpq.push(q.a);
        rsum += q.a;
      }
      while (lpq.size() > rpq.size()) {
        rpq.push(lpq.top());
        lsum -= lpq.top();
        rsum += lpq.top();
        lpq.pop();
      }
      while (lpq.size() < rpq.size()) {
        lpq.push(rpq.top());
        rsum -= rpq.top();
        lsum += rpq.top();
        rpq.pop();
      }
      ++cnt;
    } else {
      i64 med = lpq.top();
      i64 c = rsum - lsum + (cnt % 2 == 1 ? med : 0);
      cout << med << ' ' << c + bs << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 19136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

size_t f(size_t x) {
    size_t a = 100;
    size_t c = 0;
    while (a < x) {
        a = static_cast<size_t>(a * 1.01);
        ++c;
    }
    return c;
}

int main() {
    string s = input();
    if (s[1] == 'B')
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
#define max 100000
using namespace std;
ll l = 1000000007;

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

	if (n == 7 || n == 5 || n == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    string S;
    cin >> S;
    if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
vector<int> primeFactors(int n) {
    vector<int> v;
    int i = 2;
    while (i * i <= n) {
        if (n % i == 0) {
            v.push_back(i);
            n /= i;
        } else {
            i++;
        }
    }
    if(n!=1)v.push_back(n);
    return v;
}
int MOD =1000000000+7;
ll  doublePower(ll a, ll b ){
    if(b==0)return 1;
    if(b%2==0){
        long long d=doublePower(a,b/2);
        return (d*d)%MOD;
    }else{
        return (a*doublePower(a,b-1)%MOD);
    }
}
ll MOD_nCr(ll n,ll r,ll MOD){;
    ll denom=1;
    ll numer=1;
    for(ll i=1;i<=r;i++) numer=(numer*i)%MOD;
    for(ll i=n-r+1;i<=n;i++)denom=(denom*i)%MOD;
    return (denom*doublePower(numer, MOD-2)%MOD);
}
signed main(){
    int n,m; cin  >>  n >> m;
    auto primes = primeFactors(m);
    map<int,int>Map; for(auto e:primes)Map[e]++;
    int ans = 1;
    for(auto itr:Map){
        ans *= MOD_nCr(itr.second+n-1, itr.second, MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

char odd[51], even[51];

int main(void) {

	int i;
	int lenodd, leneven;

	gets(odd);
	gets(even);

	lenodd = strlen(odd) - 1;
	leneven = strlen(even) - 1;

	if (leneven == lenodd) {
		for (i = 0; i <= lenodd; i++) {
			putchar(odd[i]);
			putchar(even[i]);
		}
		printf("\n");
	}
	else {
		for (i = 0; i <= leneven; i++) {
			putchar(odd[i]);
			putchar(even[i]);
		}
		putchar(odd[leneven+1]);
		printf("\n");

	}

	return 0;

}

Measured memory_bytes: 128
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
INF = float("inf")
mod = 10**9+7
n,m = map(int,input().split())
def factorial(x):
    ans = 1
    for i in range(1,x+1):
        ans =ans*i%mod
    return ans


if abs(n-m)>=2:
    print(0)
elif abs(n-m)==1:
    print((factorial(n)*factorial(m))%mod)
else:
    print((factorial(n)*factorial(m)*2)%mod)

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

#define forn(i,a,b) for(int i=(a);i<(b); ++i)
#define nfor(i,b,a) for(int i=(b-1);i>=a;--i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ifile freopen("point1.in", "r", stdin)
#define ofile freopen("point1.out   ", "w", stdout)
#define fast ios_base::sync_with_stdio(0);\
             cin.tie(0);\
             cout.tie(0);
//#define mp make_pair
#define pb push_back
//#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll_min LONG_LONG_MIN
#define ll_max LONG_LONG_MAX
#define _1 first
#define _2 second
#define sqr(a) ((a)*(a))
const ld PI = 3.141592653589793238462643383279;
const ld EPS = 1e-6;
const ll INF = 1e9 + 7;
const ll MOD = INF;
const ll maxn = 2e5+2;
const ll HASH_MODS[] = { 1000000007333,1000000009367, 1000000075747, 1000000158923, 1000000203119 };
//||||||||||||||||||||LOCAL||||||||||||||||||||||||||
string a[51];
string b[51];

int main(){
    int n,m;
    cin>>n>>m;
    forn(i,0,n){
        cin>>a[i];
    }
    forn(i,0,m)
        cin>>b[i];
    forn(i,0,n-m+1)
        forn(j,0,n-m+1){
            bool yes=true;
            forn(k,0,m){
              //  cout<<"CHECK "<<b[k]<<" "<<a[i+k].substr(j,m)<<"\n";
                if (b[k]!=a[i+k].substr(j,m))
                    yes=false;
            }
            if (yes){
                cout<<"Yes";
                return 0;
            }
        }
    cout<<"No";
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == 1) {
    cout << "YES" << endl;
    return 0;
  }

  int B_apper[B];
  for (int i=0; i<B; i++) B_apper[i] = 0;
  int k = 1;
  while(1) {
    int mod = (k*A) % B;
    if (mod == C) {
      cout << "YES" << endl;
      return 0;
    } else if (B_apper[mod] == 1) {
      cout << "NO" << endl;
      return 0;
    }
    B_apper[mod] = 1;
    k++;
  }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define LEN 100005

typedef struct pp{
  string name;
  int t;
}P;

//P Q[LEN+1];
vector<P> Q(LEN+1);
int head, tail, n;

bool is_full() {
    return (head == (tail+1) % LEN ? true : false);
}
void enqueue(P x){
    assert(!is_full());

    Q.at(tail) = x;
    tail = (tail + 1) % LEN;
}

bool is_empty(void) {
    return head == tail;
}

P dequeue(){
    assert(!::is_empty());
    P p = Q.at(head);
    head = (head + 1) % LEN;

    return p;
}

void initialize(void) {
    head = 0;
    tail = 0;
}

int main(){
  int elaps = 0, c;
  int n, q;
  P u;
  scanf("%d %d", &n, &q);

  initialize();

  for (int i = 0; i < n; i++){
    cin >> Q[i].name;
    cin >> Q[i].t;
    P p;
    p.name = Q[i].name;
    p.t = Q[i].t;
    enqueue(p);
//    scanf("%s", Q[0].name);
//    scanf("%d", &Q[0].t);
  }


  vector<P> ans_s;
  int time = 0;

  while (::is_empty() != true) {
      P p = dequeue();

      if (p.t <= q) {
          time += p.t;
          p.t = time;
          ans_s.push_back(p);
      }
      else {
        p.t -= q;
        time += q;
        enqueue(p);
      }
  }

  for (auto ans : ans_s) {
      cout << ans.name << " " << ans.t << endl;
  }
  return 0;
}


Measured memory_bytes: 7952
// A - Maximize the Formula
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b,c; cin>>a>>b>>c;
	int maxi = max({a,b,c});
	int ans = 0;
	if(maxi == a) ans = maxi*10 + b + c;
	else if(maxi == b) ans = maxi*10 + c + a;
	else if(maxi == c) ans = maxi*10 + a + b;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int h,w,d;
    vector<vector<char>> b;
    Problem(LL h, LL w):h(h),w(w),b (h,vector<char>(w)){};

    void solve(){
        vector<char> ans ={'R','Y','G','B'};
        cin >> d;
        //int t=__builtin_ctz(d);
        if(d%2==1){
        //DBG(t)
            for(int i=0; i<h; ++i){
                for(int j=0; j<w; ++j){
                    if(i%2==0 and j%2==0)cout <<'R';
                    if(i%2==0 and j%2==1)cout <<'Y';
                    if(i%2==1 and j%2==0)cout <<'G';
                    if(i%2==1 and j%2==1)cout <<'B';
                }
                cout << "\n";
            }
            cout << "\n";
        }else{
            for(int i=0; i<h; ++i){
                for(int j=0; j<w; ++j){
                    auto pr= conv(i,j,1);
                    DBG(i,j,pr)
                    auto ii =pr.first,jj=pr.second;
                    ii=(ii+1000000)/(d/2);
                    jj=(jj+1000000)/(d/2);
                    if(ii%2==0 and jj%2==0)cout <<'R';
                    if(ii%2==0 and jj%2==1)cout <<'Y';
                    if(ii%2==1 and jj%2==0)cout <<'G';
                    if(ii%2==1 and jj%2==1)cout <<'B';
                }
                cout << "\n";
            }
        }
    }
    pair<int,int> conv(int a, int b, int h){
        if(h==0)return{a,b};
        if((a+b)%2==1)a--;
        int c =(a+b)/2;
        int d = (a-b)/2;
        return conv(c,d,h-1);
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long h=0,w;
    cin >> h >> w;
    Problem p(h,w);
    p.solve();
    return 0;
}



Measured memory_bytes: 768
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    void solve(Scanner sc) {
        int s = sc.nextInt();
        int preA = s;
        int m = 1;
        Set<Integer> set = new HashSet<>();
        set.add(preA);
        while (true) {
            m++;
            int a;
            if (preA % 2 == 0) {
                a = preA / 2;
            } else {
                a = 3 * preA +1;
            }

            if (set.contains(a)) {
                System.out.println(m);
                return;
            }

            set.add(a);
            preA = a;
        }
    }
}


Measured memory_bytes: 23636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	m := intScanner()
	k := intScanner()
	f := false
	for i := 0; i <= n; i++ {
		for j := 0; j <= m; j++ {
			if i*(m-j)+j*(n-i) == k {
				f = true
			}
		}
	}
	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640