akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;

int main(void){
  int size;
  cin>>size;

  vector<int> xvec(size);
  vector<int> yvec(size);

  double  mink1=0.0,mink2=0.0,mink3=0.0,mink_inf=0.0;

  for(int i=0;i<size;i++) cin>>xvec.at(i);
  for(int i=0;i<size;i++) cin>>yvec.at(i);
  mink_inf=abs(xvec.at(0)-yvec.at(0));

  for(int i=0;i<size;i++){
    mink1+=abs(xvec.at(i)-yvec.at(i));
    mink2+=pow(xvec.at(i)-yvec.at(i),2);
    mink3+=abs(pow(xvec.at(i)-yvec.at(i),3));
    if(mink_inf<abs(xvec.at(i)-yvec.at(i))) mink_inf=abs(xvec.at(i)-yvec.at(i));
  }
  mink2=pow(mink2,(double)1.0/2.0);
  mink3=pow(mink3,(double)1.0/3.0);
  cout<<setprecision(12) <<mink1<<endl;
  cout<<setprecision(12)<<mink2<<endl;
  cout<<setprecision(12)<<mink3<<endl;
  cout<<setprecision(12)<<mink_inf<<endl;

  return 0;

}



Measured memory_bytes: 3488
num=input().split()
W=int(num[0])
H=int(num[1])
x=int(num[2])
y=int(num[3])
r=int(num[4])

if x+r<=W and 0<=x-r and y+r<=H and 0<=y-r:
	print('Yes')
else:
	print('No')


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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int count = 0;
  for(int i=0; i<A+1; i++){
    for(int j=0; j<B+1; j++){
      for(int k=0; k<C+1; k++){
        if(i*500 + j*100 + k*50 == X){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    string s;
    ll k, count = 0;
    bool flag = false;
    cin >> s >> k;
    rep(i, s.length() - 1)
    {
        if (s[i] == s[(i + 1) % (s.length())])
        {
            count++;
            i++;
        }
    }
    ll cntR = 0, cntL = 0;
    if (s[0] == s[s.length() - 1])
    {
        char c = s[0];
        rep(i, s.length())
        {
            if (s[i] == c)
                cntL++;
            else
                break;
            if (i == s.length() - 1)
                goto last;
        }
        rep(i, s.length())
        {
            if (s[s.length() - 1 - i] == c)
                cntR++;
            else
                break;
        }
    }
    else
    {
        cout << count * k << endl;
        return 0;
    }
    if (cntL % 2 == 1 && cntR % 2 == 1)
        cout << (count + 1) * k - 1 << endl;
    else
        cout << count * k << endl;
    return 0;
last:
    cout << s.length() * k / 2 << endl;
    return 0;
}

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

using namespace std;

int main(void){
  string s;
  
  cin >> s;
  
  if(s.length() == 2) cout << s << endl;
  else{
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
n = len(a)
m = len(b)
dp = [[0 for i in range(m + 1)] for j in range(n + 1)]

for i in range(1, n + 1):
    for j in range(1, m + 1):
        if a[i - 1] == b[j - 1]:
            dp[i][j] = 1 + dp[i - 1][j - 1]
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

lim = dp[-1][-1]

i = n
j = m
ans = [None] * (lim)
while i > 0 and j > 0:

    if a[i - 1] == b[j - 1]:
        ans[lim-1] = a[i - 1]
        i -= 1
        j -= 1
        lim -= 1

    else:
        if dp[i - 1][j] > dp[i][j - 1]:
            i -= 1
        else:
            j -= 1
if ans:
    print("".join(ans))
else:
    print(' ')

Measured memory_bytes: 121948
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

vector<double> p(6),q(6);

double calc(double P){
	double ret = 0.0;
	for(int i=0;i<6;i++){
		if(p[i]+q[i]<0.01)continue;
		ret += (P * p[i] / 100.0 + (1.0-P) * q[i] / 100.0) * max(P*p[i],(1.0-P)*q[i]) / (P*p[i]+(1.0-P)*q[i]);
	}
	
	return ret;
	
}


int main(){
	

	
	for(int i=0;i<6;i++){
		cin>>p[i];
	}
	for(int i=0;i<6;i++){
		cin>>q[i];
	}
	
	double l = 0.0;
	double r = 1.0;
	
	for(int i=0;i<500;i++){
		double m1 = l + (r-l)/3.0;
		double m2 = l + (r-l)*2.0/3.0;
		if(calc(m1)>calc(m2))l = m1;
		else r = m2;
	}
	
	cout<<fixed<<setprecision(20)<<calc(l)<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  string s;
  cin>>s;
  ll flg = 0;
  rep(i,n){
    if(s[i]>='0' && s[i] <= '9') {

    } else {
      flg++;
    }
  }
  if(s[n] != '-') flg++;
  repl(i,n+1,n+m+1){
    if(s[i]>='0' && s[i] <= '9') {

    } else {
      flg++;
    }
  }
  if(flg == 0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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


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

using namespace std;

#define LL long long

LL n,m,ans;

int main(){
	scanf("%lld%lld",&n,&m);
	if (m==0){
		printf("%lld\n",n*n);
		return 0;
	}
	for (int i=1;i<=n;i++){
		if (n%i==0){
			if (i>m) ans+=n/i*(i-m);
		}
		else{
			int j=n%i;
			if (j>=m) ans+=j-m+1;
			if (i>m) ans+=n/i*(i-m);
		}
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
 
const ll INF = 1ll<<60;
 
int main() {
  ll n, x, d;
  cin >> n >> x >> d;
 
  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    } else {
      cout << n+1 << endl;
    }
    return 0;
  }
 
  map<int, vector<P>> mp;
  rep(k,n+1) {
    ll s = k*x;
    ll l = (ll) (k-1)*k/2;
    ll r = l + (ll)k*(n-k);
    s += l*d;
    r -= l;
    mp[ (s%d+d) % d ].emplace_back(s,r);
  }
  ll ans = 0;
  for (auto p : mp) {
    vector<P> a = p.second;
    int m = a.size();
    rep(i,m) a[i].first = (a[i].first - p.first)/d;
    vector<P> ev;
    rep(i,m) {
      ev.emplace_back(a[i].first, 1);
      ev.emplace_back(a[i].first + a[i].second + 1, -1);
    }
    sort(ev.begin(), ev.end());
    ll cnt = 0, pre = -INF;
    for (auto e : ev) {
      ll len = e.first - pre;
      if (cnt) ans += len;
      cnt += e.second;
      pre = e.first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25420
import java.util.Scanner;

//Advanced Algorithm Class
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] map = new int [n+1][n+1];
			for(int i=0;i<n;i++){
				map[i][n] = Integer.MAX_VALUE;
			}
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					map[i][j] = sc.nextInt();
					map[i][n] = Math.min(map[i][n], map[i][j]);
					map[n][j] = Math.max(map[n][j], map[i][j]);
				}
			}
			int ans = 0;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(map[i][j]==map[i][n]&&map[i][j]==map[n][j])ans = map[i][j];
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
/** author: __nishad__ **/

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


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    ll n, count=0;
    cin>>n;


    if(n==105)
        cout<<"1";
    else if(n<105)
        cout<<"0";
    else if(n>105){
        loop2(i,106,n){
            if(i%2 != 0){
                ll divisor = 0;
                loop2(j,1,i){
                    if(i%j == 0)
                        divisor++;
            }
            if(divisor >= 8)
                count++;
            }
        }
        cout<<count+1;
    }


}



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

int main(){
  long long n,m,x;
  cin>>n>>m>>x;
  long long c[n], a[n][m];
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  long long ans=-1;
  for(int bit=0;bit<=(1<<n);bit++){
    long long sum=0,b[m]={0};
    for(int i=0;i<n;i++){
      if(bit & (1<<i)){
        sum+=c[i];
        for(int j=0;j<m;j++){
          b[j]+=a[i][j];
        }
      }
    }
    for(int i=0;i<m;i++){
      if(b[i]<x){
        break;
      }if(i==m-1){
        if(ans!=-1 && sum<ans){
          ans=sum;
        }else if(ans==-1){
          ans=sum;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
import collections
n = int(raw_input())
sides = map(int, raw_input().split())
obj, squares, rectangles = collections.Counter(sides), list(), list()
for i in obj:
    if obj[i] >= 4:
        squares.append(i)
        rectangles.append(i)
    elif obj[i] >= 2:
        rectangles.append(i)
if (not rectangles and not squares) or (not squares and len(rectangles) < 2):
    print('0')
elif not squares and len(rectangles) >= 2:
    rectangles.sort(reverse=True)
    print(rectangles[0] * rectangles[1])
elif not rectangles and squares:
    squares.sort(reverse=True)
    print(squares[0] ** 2)
else:
    rectangles.sort(reverse=True)
    squares.sort(reverse=True)
    print(rectangles[0] * rectangles[1] if rectangles[0] * rectangles[1] > squares[0] ** 2 else squares[0] ** 2)


Measured memory_bytes: 16432
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int main() {
    int k, n;
    cin>>k>>n;
    
    vector<int> dist(n);
    cin>>dist[0];
    int max_dist = -1;

    for(int i=1; i<n; i++) {
        cin>>dist[i];
        int curr_dist = dist[i]-dist[i-1];
        if(curr_dist>max_dist) max_dist = curr_dist;
    }
    
    int curr_dist = k-dist[n-1]+dist[0];
    if(curr_dist>max_dist) max_dist = curr_dist;
    cout<<k-max_dist<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main() {
    int i,j,k,a,b,c,d,n,m[4][3][10];
    scanf("%d",&n);
    for(i=0;i<4;i++)
    	for(j=0;j<3;j++)
    		for(k=0;k<10;k++)
    			m[i][j][k] = 0;
    for(i=0;i<n;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		m[a-1][b-1][c-1] += d;
	}
	for(i=0;i<4;i++){
		if(i!=0)
			printf("####################\n");
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",m[i][j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2044
class Main{
    public static void main(String[] a){
        for(int count1 = 1; count1 < 10; count1++) {
	    for(int count2 = 1; count2 < 10; count2++) {
		System.out.println(count1 + "x" + count2 + "=" + (count1 * count2));
	    }
	}
    }
}

Measured memory_bytes: 23940
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){
	string N;
	cin >> N;
	if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) cout << "Yes";
	else cout << "No";

	return 0;
}




Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:10 on 2019-11-16.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    string s;
    cin >> n >> s;
    if (n % 2 != 0) {
        cout << "No" << '\n';
        return;
    }
    if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int e = stdIn.nextInt();
			if(e == 0) break;
			int max = 1000000;
			for(int i = 0; i*i*i <= e; i++) {
				if(i >= max) break;
				for(int j = 0; i*i*i+j*j <= e; j++) {
					int k = e -(i * i * i + j * j);
					if(i + j + k < max) {
						max = i + j + k;
					}
				}
			}
			System.out.println(max);
		}
	}
}

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

int n;
int a,b,c;

int ans[100002];

vector<pair<int,int> >vec[100002];

int slv(int now,int col){
	ans[now]=col;
	for(int i=0;i<vec[now].size();i++){
		int next=vec[now][i].first , dir=vec[now][i].second;
		if(ans[next]!=-1)continue;
		if(dir%2==1){
			slv(next,col^1);
		}
		else{
			slv(next,col);
		}
	}
	return(0);
}

int main(){
	
	cin>>n;
	for(int i=1;i<=n;i++)ans[i]=-1;
	for(int i=1;i<n;i++){
		cin>>a>>b>>c;
		vec[a].push_back(make_pair(b,c));
		vec[b].push_back(make_pair(a,c));
	}

	slv(1,0);

	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
	return(0);
}

Measured memory_bytes: 8320
#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, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << "\n";
}

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  string S = s;
  int pair_p;
  bool flag = true;
  while(flag&&(int)(s.size())>=2){
    flag = false;
    for(int i=1; i<(int)(s.size()); i++){
      if(s.at(i-1)=='('&&s.at(i)==')'){
        flag = true;
        if(i==1){
          s = s.substr(2, (int)(s.size())-2);
        }else if(i==(int)(s.size()-1)){
          s = s.substr(0, (int)(s.size())-2);
        }else{
          s = s.substr(0, i-1) + s.substr(i+1, (int)(s.size())-i+1);
        }
        break;
      }
    }
  }
  int r=0;
  int l=0;
  for(int i=0; i<s.size(); i++){
    if(s.at(i)==')'){l++;}
    else break;
  }
  for(int i=s.size()-1; 0<=i; i--){
    if(s.at(i)=='('){r++;}
    else break;
  }
  if(r==0&&l==0){
    cout << S << endl;
  }else if(r==0){
    string L(l, '(');
    cout << L << S << endl;
  }else if(l==0){
    string R(r,')');
    cout << S << R << endl;
  }else{
    string L(l,'(');
    string R(r,')');
    cout << L << S << R << endl;
  }
  return 0;
}

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

int main(){
    int A,B;
    cin >> A >> B;
    
    vector<int> v(3);
    v.at(0)=A+B;
    v.at(1)=A-B;
    v.at(2)=A*B;
    
    sort(v.begin(), v.end());
    
    int ans;
    ans=v.at(2);
    
    cout << ans <<endl;
    
    
   
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    int ans = 0;
    for(int i=0; i<n; i+=2){
        if(a[i] % 2 != 0)
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
n, *a = map(int, open(0).read().split())

left = 0
right = 0
val = 0
seen = [False] * (n + 1)
for i in range(n + 1):
    if seen[a[i]]:
        right = i
        val = a[i]
        break
    seen[a[i]] = True
for i in range(n):
    if a[i] == val:
        left = i
        break

mod = 10 ** 9 + 7

fac = [1] * (n + 5)
for i in range(1, n + 3):
    fac[i] = fac[i - 1] * i % mod
def inv(x):
    return pow(x, mod - 2, mod)
def c(n, k):
    if n < k:
        return 0
    return fac[n] * inv(fac[k] * fac[n - k]) % mod

right = n - right
for i in range(1, n + 2):
    print((c(n + 1, i) - c(left  + right, i - 1)) % mod)

Measured memory_bytes: 20452
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	const int MAX_R = 10, MAX_C = 10000;
	int R, C;
	bool field[MAX_R][MAX_C];
	int a, ans, res, c;
	
	while(true){
		ans = 0;
		scanf("%d%d", &R, &C);
		
		if(R == 0 && C == 0) break;
		
		for(int i = 0; i < R; i++){
			for(int j = 0; j < C; j++){
				scanf("%d", &a);
				field[i][j] = (a == 0)? true : false;
				if(a == 0) ans++;
			}
		}
		
		for(int i = 0; i < 1 << R; i++){
			for(int k = 0; k < R; k++){//?£???????
				if(i >> k & 1){
					for(int p = 0; p < C; p++) field[k][p] = !field[k][p];
				}
			}
			
			res = 0;
			for(int j = 0; j < C; j++){
				c = 0;
				for(int p = 0; p < R; p++){
					if(field[p][j]){
						c++;
					}
				}
				res += max(c, R - c);
			}
			
			ans = max(res, ans);
			
			for(int k = 0; k < R; k++){//?£???????????????????????????????
				if(i >> k & 1){
					for(int p = 0; p < C; p++) field[k][p] = !field[k][p];
				}
			}
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1124
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    string s; cin >> s;
    cout << (count(ALL(s), 'x') <= 7 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import sys
n = int(input())
h = list(map(int,input().split()))
for k in range(n-1):
    if h[k+1]==h[k]-1:
        h[k+1]=h[k]
    elif h[k+1]>=h[k]:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 14224
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int cnt = 0;;

void merge(vector<int>& v, int l, int m, int r){
  int n1 = m-l;
  int n2 = r-m;
  vector<int> v1(n1+1);
  vector<int> v2(n2+1);
  for (size_t i = 0; i < n1; i++) {
    v1[i] = v[l+i];
  }
  for (size_t i = 0; i < n2; i++) {
    v2[i] = v[m+i];    
  }
  v1.back() = INT_MAX;
  v2.back() = INT_MAX;
  int i = 0, j = 0;
  for (size_t k = l; k < r; k++) {
    cnt++;
    if(v1[i] < v2[j]){
      v[k] = v1[i++];
    } else{
      v[k] = v2[j++];
    }
  }
}

void mergeSort(vector<int>& v, int l, int r){
  if(l+1 < r){
    int m = (l + r) / 2;
    mergeSort(v, l, m);
    mergeSort(v, m, r);
    merge(v, l, m, r);
  }
}

int main(int argc, char *argv[]){
  size_t n;
  cin >> n;
  vector<int> v(n);
  for (size_t i = 0; i < n; i++) {
    cin >> v[i];
  }
  mergeSort(v, 0, n);
  for (size_t i = 0; i < n-1; i++) {
    cout << v[i] << " ";
  }
  cout << v.back() << endl;
  cout << cnt << endl;


  return 0;
}

Measured memory_bytes: 5068
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int main() {
	int N;
	cin >> N;
	vi a(3*N);
	rep(i, 3*N) {
		cin >> a[i];
	}
	vll f(3 * N, 0), b(3 * N, 0);
	ll sum = 0, sumb = 0;
	pqlll qf;
	priority_queue<ll> qb;
	rep(i, N) {
		sum += a[i];
		sumb += a[3 * N - 1 - i];
		qf.push(a[i]);
		qb.push(a[3 * N - 1 - i]);
	}
	f[N - 1] = sum;
	b[2 * N] = sumb;
	

	repl(i, N, 2 * N) {
		qf.push(a[i]);
		sum += a[i];
		sum -= qf.top();
		qf.pop();
		f[i] = sum;

		qb.push(a[3 * N - 1 - i]);
		sumb += a[3 * N - 1 - i];
		sumb -= qb.top();
		qb.pop();
		b[3 * N - 1 - i] = sumb;
	}

	ll ans = -INFL;
	repl(i, N - 1, 2 * N) {
		ans = max(ans, f[i] - b[i + 1]);
	}
	cout << ans << endl;

	return 0;
}

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

#undef int
int main() {
#define int long long 
    string s;
    cin >> s;

    int n=s.size();
    int ans[n]={0};
    int stop;

    for(int i=0;i<n;i++){
        if(s[i]=='R')
        {
            stop=i;
        }
        else
        {
            int diff = i-stop;
            if(diff%2!=0) {
                ans[stop+1]++;
            }
            else
            {
                ans[stop]++;
            }
            
        }
    }

    for(int i=n-1;i>=0;i--){
        if(s[i]=='L') {
            stop=i;
        }
        else
        {
            int diff=stop-i;
            if(diff%2!=0) {
                ans[stop-1]++;
            }
            else
            {
                ans[stop]++;
            }
            
        }
    }
    for(int i=0;i<n;i++) {
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int ans = 0;
	
	if(s[0]==t[0]) ++ans;
	if(s[1]==t[1]) ++ans;
	if(s[2]==t[2]) ++ans;
	
	cout<<ans;
}

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

int main(){
    int A,B;
    cin>>A>>B;
    if(A>=13){
        cout<<B<<endl;
    }else if(A>5){
        cout<<B/2<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N,M;
	cin >> N >> M;
	int P[N+1] = {};
	vector<tuple<int,int,int>> S; //first is year
	rep(i,0,M){
		int tmp,tmp1;
		cin >> tmp >> tmp1;
		S.push_back(make_tuple(tmp1,tmp,i+1));
	}
	vector<tuple<int,int,int>> ans;
	cout.fill('0');
	cout.setf(ios::right);
	sort(all(S));
	rep(i,0,M){
		P[get<1>(S[i])]++;
		ans.push_back(make_tuple(get<2>(S[i]),get<1>(S[i]),P[get<1>(S[i])]));
	}
	sort(all(ans));
	rep(i,0,M){
		cout << setw(6) << get<1>(ans[i]) << setw(6) << get<2>(ans[i])<<endl;
	}
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N,M;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    int l=0,r=10000000;
    rep(i,0,M){
        int L,R;
        cin>>L>>R;
        l=max(L,l);
        r=min(R,r);
    }
    if(r<l)cout <<0<<"\n";
    else cout <<r-l+1<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


void solve(long long N){
    ll sum=0;
    for (long long i = 1; i <= N; i++) {
        if(i%3!=0&&i%5!=0){
            sum+=i;
        }
    }
    cout << sum << endl;
}

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


Measured memory_bytes: 3808
# D - Wizard in Maze
import sys
from collections import deque
from typing import List, Tuple


class WarpableMaze:
    __slots__ = ["height", "width", "start", "goal", "road", "wall", "grid"]

    def __init__(
        self,
        height: int,
        width: int,
        start: Tuple[int, int],
        goal: Tuple[int, int],
        grid: List[str],
        road: str = ".",
        wall: str = "#",
    ) -> None:
        # Values of start and goal must be 0-origin.
        self.height = height + 4
        self.width = width + 4
        self.start = self._flatten_coordinate(*start)
        self.goal = self._flatten_coordinate(*goal)
        self.road = road
        self.wall = wall
        self.grid = self._flatten_grid(grid)

    def _flatten_coordinate(self, h: int, w: int) -> int:
        return self.width * (h + 2) + w + 2

    def _flatten_grid(self, grid: List[str]) -> str:
        flat_grid = self.wall * self.width * 2
        for row in grid:
            flat_grid += self.wall * 2 + row + self.wall * 2
        flat_grid += self.wall * self.width * 2
        return flat_grid

    def bfs(self) -> int:
        w = self.width
        move = (-w, w, -1, 1)
        warp = [-2 * w - 2, -2 * w - 1, -2 * w, -2 * w + 1, -2 * w + 2]
        warp.extend([-w - 2, -w - 1, -w + 1, -w + 2, -2, 2])
        warp.extend([w - 2, w - 1, w + 1, w + 2])
        warp.extend([2 * w - 2, 2 * w - 1, 2 * w, 2 * w + 1, 2 * w + 2])

        unsearched = 1 << 30
        dist = [unsearched] * (self.height * self.width)
        dist[self.start] = 0
        queue = deque([self.start])
        while queue:
            x = queue.popleft()
            cur_dist = dist[x]

            for dx in move:
                nx = x + dx
                if self.grid[nx] == self.wall:
                    continue
                if dist[nx] > cur_dist:
                    dist[nx] = cur_dist
                    queue.appendleft(nx)

            for dx in warp:
                nx = x + dx
                if self.grid[nx] == self.wall:
                    continue
                if dist[nx] > cur_dist + 1:
                    dist[nx] = cur_dist + 1
                    queue.append(nx)

        return dist[self.goal] if dist[self.goal] != unsearched else -1

    def debug(self):
        print(f"<DEBUG>\nstart={self.start}, goal={self.goal}", file=sys.stderr)
        for row in zip(*[iter(self.grid)] * self.width):
            print(*row, file=sys.stderr)


def main():
    H, W, CH, CW, DH, DW, *S = open(0).read().split()
    start, goal = (int(CH) - 1, int(CW) - 1), (int(DH) - 1, int(DW) - 1)
    maze = WarpableMaze(int(H), int(W), start, goal, S)
    # maze.debug()
    print(maze.bfs())


if __name__ == "__main__":
    main()


Measured memory_bytes: 220264
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {

	string S;
	cin >> S;
	int cnt = 0;
	bool flag = false;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'C' && !flag) flag = true;
		if (S[i] == 'F' && flag) flag = false, cnt++;
	}

	if (cnt != 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<string> s(2);
    for(int i=0; i<2; ++i)
        cin >> s[i];

    int i = 1;
    long long ans = 3;
    if(s[0][0] != s[1][0]){
        ++ i;
        ans *= 2;
    }

    while(i < n){
        if(s[0][i] == s[1][i]){
            if(s[0][i-1] == s[1][i-1])
                ans *= 2;
            ++ i;
        }
        else{
            if(s[0][i-1] == s[1][i-1])
                ans *= 2;
            else
                ans *= 3;
            i += 2;
        }
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int euclidean_gcd(int a, int b){
	if(a < b){
		return euclidean_gcd(b, a);
	}
	int r;
	while((r=a%b)){
		a = b;
		b = r;
	}
	return b;
}

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

	int ans;
	cin >> ans;
	for (int i = 0; i < N - 1; i++){
		int temp;
		cin >> temp;

		ans = euclidean_gcd(ans, temp);
	}

	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, A, B, ans=0;

	cin >> N >> A >> B;
	vector<ll> h(N);
	rep(i,N) cin >> h[i];

	sort( all(h) );
	int l=0, r=1e9+7;
	while(r-l>1){
		ll m = (r+l) / 2;
		bool check = false;
		//int pos = lower_bound( all(h), m*B ) - h.begin();
		ll count = 0;
		rep(i,N){
			ll lest = max<ll>(0, h[i] - m*B);
			count += lest / (A-B) + (lest%(A-B) ? 1 : 0);
		}
		if( count <= m ){
			r = m;
		}else{
			l = m;
		}
	}

	ans = r;
	cout << ans << endl;

	return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define forup(i,a,b) for(int i=(a); i<(b); ++i)
#define fordn(i,a,b) for(int i=(a); i>(b); --i)
#define rep(i,a) for(int i=0; i<(a); ++i)

#define gi(x) scanf("%d",&x)
#define gl(x) cin>>x
#define gd(x) scanf("%lf",&x)
#define gs(x) scanf(" %s",x)

#define D(x) cout << #x << " : " << x << endl

#define fs first
#define sc second

#define pb push_back
#define mp make_pair

const int inf=numeric_limits<int>::max();
const LL linf=numeric_limits<LL>::max();

const int max_n=3010;

LL n, dp[max_n][max_n], a[max_n];
bool s[max_n][max_n];

LL f(int l, int r){
    if(r<0 || l >= n || l>r) return 0;
    if(s[l][r])
        return dp[l][r];

    s[l][r] = true;
    return dp[l][r] = max(a[l]-f(l+1,r), a[r]-f(l,r-1));
}

int main() {
    gl(n);
    rep(i,n) gl(a[i]);

    cout << f(0,n-1) << endl;
    return 0;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll=long long;

using vb=vector<bool>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  string S; cin >>S;

  if (S.find('S')!=string::npos && S.find('N')==string::npos) {
    cout <<"No" <<'\n';
    return 0;
  }
  if (S.find('N')!=string::npos && S.find('S')==string::npos) {
    cout <<"No" <<'\n';
    return 0;
  }
  if (S.find('W')!=string::npos && S.find('E')==string::npos) {
    cout <<"No" <<'\n';
    return 0;
  }
  if (S.find('E')!=string::npos && S.find('W')==string::npos) {
    cout <<"No" <<'\n';
    return 0;
  }

  cout <<"Yes" <<'\n';
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

ll power(ll x, ll pw, ll mod) {
    ll res = 1;
    x = x % mod;  // if it x >= p
    while (pw > 0) {
        if (pw & 1)
            res = (res*x) % mod;
        pw /= 2;
        x = (x*x) % mod;
    }
    return res;
}
ll modInverse(ll n, ll p) {
    return power(n, p-2, p); // Fermat¡¦s little theorem
}
ll nCr(ll n, ll m, ll mod=1e9+7) {
    m = min(m, n-m);
    if (m == 0) return 1;
    ll num = 1, dem = 1;
    for(ll i = 1; i <= m; i++) {
        num = (num*(n+1-i)) % mod;
        dem = (dem*(i)) % mod;
    }
    return (num * modInverse(dem, mod)) % mod;
}
unordered_map<ll, int> fac(ll x) {
    ll p = 2;
    ll x2 = x;
    unordered_map<ll, int> prime;
    while(p*p <= x && x2 > 1) {
        while(x2 % p  == 0) {
            prime[p] += 1;
            x2 /= p;
        }
        p++;
    }
    if (x2 > 1)
        prime[x2] += 1;
    return prime;
}
int main() {
    ll mod = 1e9 + 7;
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    for(auto p: fac(m)) {
        ll freq = p.second;
        // cout << p.first << " " << p.second << endl;
        ll tmp = nCr(freq+(n-1), freq) % mod;
        ans *= tmp;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr

N=int(input())
A=sorted(map(int,input().split()))

cnt=[0]*1000001
for i in range(N):
    cnt[A[i]]+=1
ng=set()
for i in range(N):
    if cnt[A[i]]>1:
        ng.add(A[i])

s=set(A)
min_=min(A)

ans=0
for i in reversed(range(N)):
    if A[i] in ng:
        continue
    if A[i]<min_*2:
        ans+=1
        continue
    s.remove(A[i])
    arr=factor(A[i])
    ok=True
    for x in arr:
        if x in s:
            ok=False
            break
    if ok:
        ans+=1
    s.add(A[i])
print(ans)


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

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

    ll answer = pow(10, 12);

    ll tmp=0;
    for(ll i=0; i<=N; i++){
        if(i*i > N){
            tmp = i; 
            break;
        }
    }

    for(ll i=1; i<=tmp*10; i++){
        if(N % i == 0){
            if(answer > (i -2 + N / i)){
                answer = i - 2 + N / i; 
            }
        }
    }

    cout << answer << endl;

}


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

using namespace std;


int main(){
   int n,m,x;
   cin>>n>>m>>x;
   int a[110];
   for(int i=0;i<m;i++){
      cin>>a[i];
   }
   int c0=0;
   int cn=0;
   for(int i=0;i<m;i++){
      if(x<a[i]){
         cn++;
      }
      else c0++;
   }
   cout<<min(c0,cn)<<endl;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	A, B = map(int, input().split(" "))
	
	for i in range(1, 4):
		if (A * B * i) % 2 == 1:
			print("Yes")
			sys.exit()
	
	print("No")
		
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3444
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bool (bool)

main :: IO ()
main = do
  [d, t, s] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  putStrLn . bool "No" "Yes" $ d <= s * t

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3784
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> s(n);
    int sum = 0, mi = 111;
    rep(i,n){
        cin >> s[i];
        sum += s[i];
        if(s[i]%10 != 0) chmin(mi, s[i]);
    }
    if(sum%10 != 0) cout << sum << endl;
    else if(mi == 111) cout << 0 << endl;
    else cout << sum - mi << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, K;
	
	cin >> N >> K;

	int a[N];

	rep(i, N)
	{
		cin >> a[i];
	}
	int t = (N-1) % (K-1);
	int m = (N-1) / (K-1);
	cout << (t ? m + 1 : m) << endl;

	
	return 0;
}


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

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

	int N;
	double K;
	cin >> N >> K;
	// printf("%d %f \n", N, K);

	double p = 0;
	for (int i = 1; i <= N; i++) {
		// cout << i << "->" << log2(K / i) << "->";
		// cout << ceil(log2(K / i)) << "->";
		// cout << pow(2, ceil(log2(K / i))) << '\n';
		// printf("%d %0.10lf\n", i, 1 / max(1.0, pow(2, ceil(log2(K / i)))));
		p += 1 / max(1.0, pow(2, ceil(log2(K / i))));
	}

	// printf("p = ");
	printf("%0.10lf\n", p / N);

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;


int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int r,g;
	string s;
	cin >>r >>g;
	
	
	cout << 2*g -r <<"\n";
	return 0;
 
}

Measured memory_bytes: 256
import math

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

answer = []

# p = 1, 2, 3
for p in range(1, 3 + 1):
    result = 0.0
    for i in range(n):
        result += abs(x[i] - y[i]) ** p

    answer.append(result ** (1 / p))

# p = ∞
result = 0.0
for i in range(n):
    result = max(result, abs(x[i] - y[i]))

answer.append(result)

[print("{:.6f}".format(answer[i])) for i in range(len(answer))]


Measured memory_bytes: 5708
import java.util.Scanner;
class Main{
    public static void main(String[] a){
    	
    	Scanner scan = new Scanner(System.in);
    	while (scan.hasNext()){ 
    	int n = 0;
    	int count = 0;
    	n = scan.nextInt();
    	
    	for(int i = 0; i < 10;i++){
    		for(int k = 0; k < 10; k++){
    			for(int y = 0; y < 10; y++){
    				for(int j = 0; j < 10; j++){
    					
    					if(i+k+y+j == n){
    						count += 1;
    					}
    				}
    			}
    		}
    	}
    	System.out.println(count);
    	}
 }
}

Measured memory_bytes: 26564
#!/usr/bin/env ruby
require 'set'

def main
    n,m,x = gets.chomp.split(" ").map(&:to_i)
    moneys = []
    skills = []
    n.times do
        books = gets.chomp.split(" ").map(&:to_i)
        moneys.push books[0]
        skills.push books[1..-1]
    end

    ans = 1200001
    [0, 1].repeated_permutation(n) do |comb|
        sum_money = 0
        sum_array = []
        m.times do
            sum_array.push 0
        end

        (0...n).each do |i|
            if comb[i] == 1
                sum_money += moneys[i]
                (0...m).each do |j|
                    sum_array[j] = sum_array[j] + skills[i][j]
                end
            end
        end
        if sum_array.min >= x
            if ans > sum_money
                ans = sum_money
            end
        end
    end
    puts ans == 1200001 ? -1 : ans
end

main

# s[0,6] # 0番目から6文字
# s[0..6] # 0番目から6番目まで
# s[5..-1] # 5番目から最後まで
# until s.empty? do

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

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

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

    int m = n % 10;

    string ans;

    if(m == 2 || m == 4 || m == 5 || m == 7 || m == 9){
        cout << "hon" << endl;
    }else if(m == 0 || m == 1 || m == 6 || m == 8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    } 
    return 0;    
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

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

    bool c(false);
    rep(i,3){
        if(s[i]=='A' && s[i+1]=='C'){
            c = true;
            break;
        }
    }

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

    return 0;
}

Measured memory_bytes: 3652