akhauriyash/Code-Regression huggingface dataset:
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (ll)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

vector<bool> visited(2 * 100000, false);
vector<vector<int>> g(2 * 100000);

PII dfs(int v) {
    if (visited[v]) return {0,0};
    visited[v] = true;
    PII p(0,0);
    for (int u : g[v]) {
        PII x = dfs(u);
        p.first += x.first;
        p.second += x.second;
    }
    if (v < 100000) p.first++;
    else p.second++;
    return p;
}

int main() {
    int N; input(N);
    REP(i, N) {
        int x, y; input(x, y);
        x--; y--;
        y += 100000;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    ll cnt = 0;
    REP(i, 2 * 100000) {
        if (visited[i]) continue;
        PII p = dfs(i);
        cnt += (ll)p.first * p.second;
    }
    cout << cnt - N << endl;
    getchar(); getchar();
}

Measured memory_bytes: 11008
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [e, d, c, b, a]
for i in range(len(l)-1):
  for j in range(len(l)):
    if l[i]-l[j] > k:
      print(":(")
      quit()
print("Yay!")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    long long c=0, d = 10;
    if(N%2 == 1){
        c = 0;
    } else {
        while(d <= N){
            c += N/d;
            d *= 5;
        }
    }
    
    cout << c << endl;
}

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

using namespace std;

typedef long long ll;
const int mod = 1000000007;

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

    deque<int> q;
    for (int i = 0; i < n; i++) {
        if (q.size() == 0) {
            q.push_back(a[i]);
        } else {
            if (a[i] <= q[0]) {
                q.push_front(a[i]);
            } else {
                int j = lower_bound(q.begin(), q.end(), a[i]) - q.begin();
                q[j-1] = a[i];
            }
        }
    }

    cout << q.size() << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll n, m;
  cin >> n >> m;
  ll total = 0;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
    total += a.at(i);
  }
  sort(all(a));
  reverse(all(a));
  ll m4 = m * 4;
  ll border = total / m4;
  if(total%m4==0){
    if(a.at(m-1)>=border){
    cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    if(a.at(m-1)>border){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

int main() {
  string s;
  cin>>s;
  
  if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
*/
int n;

int32_t main()
{
    ios;
    string s, t;
    cin >> s >> t;
    bool f = 1;
    if (s.size() + 1 == t.size())
    {
        for (int i = 0; i < s.size(); i++)
            if (s[i] != t[i])
            {
                f = 0;
                break;
            }
        if (f)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;


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

    ll ans = 0;
    if(a==0) ans = b/x + 1;
    else ans = b/x - (a-1)/x;
    cout(ans);
    return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int X = in.nextInt();
        int deg = 0;
        int ans = 0;
        do {
            ans++;
            deg += X;
            deg %= 360;
        } while (deg != 0);
        out.println(ans);
        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 32836
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		var a=sc.Arr((int)s[0],()=>sc.Ia);
		var g=new long[s[0]][];
		var b=new long[s[0]][];
		for(int i = 0;i<s[0];i++) {g[i]=new long[s[0]];}
		for(int i = 0;i<s[0];i++) {
			for(int j = 0;j<s[0];j++) {g[i][j]=a[j][i];}
			b[i]=new long[]{1};
		}
		var c=Mp(b,g,s[1]);
		long ans=0;
		for(int i = 0;i<s[0];i++) {ans=(ans+c[i][0])%mod;}
		Console.WriteLine("{0}",ans);
	}
	static long[][] Mp(long[][] r,long[][] x,long e){
		while(e>0){
			if((e&1)>0){r=Mm(x,r);}
			x=Mm(x,x);
			e>>=1;
		}
		return r;
	}
	static long[][] Mm(long[][] a,long[][] b){
		long[][] q=new long[a.Length][];
		for(int j=0;j<a.Length;j++){
			q[j]=new long [b[0].Length];
			for(int i=0;i<b[0].Length;i++){
				for(int k=0;k<a.Length;k++){q[j][i]=(q[j][i]+a[j][k]*b[k][i])%mod;}
			}
		}
		return q;
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		scanner.close();

		if (N % K == 0) {
			System.out.println(0);
		} else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 23124
from collections import defaultdict
blue, red = defaultdict(int), defaultdict(int)
n = int(input())
for _ in range(n):
    blue[input()] += 1
m = int(input())
for _ in range(m):
    red[input()] += 1
    
ans = []
for k in blue.keys():
    ans.append(max(0, blue[k]-red[k]))
print(max(ans))

Measured memory_bytes: 3316
from collections import defaultdict
import math

def comb(n, r):
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

n, a, b = map(int, input().split())
v = list(map(int, input().split()))

d = defaultdict(int)
for i in range(n):
    d[v[i]] += 1

keys = list(d.keys())
keys.sort(reverse=True)
cnt = 0
kind = 0
s = 0
for i in range(len(keys)):
    k = keys[i]
    kind += 1
    if cnt+d[k] < a:
        cnt += d[k]
        s += k*d[k]
    else:
        s += k*(a-cnt)
        break
print(s/a)
if kind > 1:
    print(comb(d[keys[kind-1]], a-cnt))
else:
    ans = 0
    for i in range(a, b+1):
        if d[keys[0]] < i:
            break
        ans += comb(d[keys[0]], i)
    print(ans)

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

int main() {
    int N,A,B;
    A = 0;
    B = 0;
    int a[100];
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    reverse(a,a+N);

    for (int i=0;i<N;i++){
        if (i%2==0){
            A += a[i];
        }else{
            B += a[i];
        }
    }
    cout << A-B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n;
    cin >> n;
    int a[n];
    map<int, int> ma;
    for (i = 0; i < n; i++) {
        cin >> a[i];
        ma[a[i]]++;
    }
    VVI v(n);
    for (i = 0; i < n; i++) {
        for (j = 1; j * j <= a[i]; j++) {
            if (a[i] % j == 0) {
                int t = a[i] / j;
                if (j != t) {
                    v[i].pb(j);
                    v[i].pb(t);
                } else
                    v[i].pb(j);
            }
        }
    }
    int cnt = 0;
    for (i = 0; i < n; i++) {
        int y = 0;
        for (j = 0; j < v[i].size(); j++) y += ma[v[i][j]];
        if (y >= 2) cnt++;
    }
    cout << n - cnt << endl;
}

Measured memory_bytes: 111700
#include<bits/stdc++.h>
#define REP(i,u) for(int i=hd[u],v;v=to[i],i;i=nxt[i])
using namespace std;
typedef long long ll;
const int N=int(1e5)+10;

int n,m,len,px,py,tot; int dep[N],sum[N],K[N],q[N]; ll res;
int hd[N],to[N*2],nxt[N*2],ecnt;
void addE(int u,int v){ to[++ecnt]=v,nxt[ecnt]=hd[u],hd[u]=ecnt; }
void dae(int u,int v){ addE(u,v),addE(v,u); }

void dfs1(int p,int fa=0,int c=1,int d=1){
	dep[p]=d,sum[p]=c;
	REP(i,p) if(v!=fa){
		if(!dep[v]) dfs1(v,p,-c,d+1);
		else px=p,py=v,len=dep[p]-dep[v]+1;
	}
}

bool prework(){
	for(int i=1;i<=n;i++) tot+=sum[i];
	if(!(len&1) && tot) return 0;
	if(len&1 && abs(tot)&1) return 0;
	return 1;
}

void dfs2(int p,int fa=0){
	if(!fa) memset(dep,0,sizeof(dep));
    dep[p]=1;
    REP(i,p) if(!dep[v])
		dfs2(v,p),sum[p]+=sum[v],K[p]+=K[v];
}

int main(){
//	freopen("father.in","r",stdin);
//	freopen("father.out","w",stdout);
	
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++)
		scanf("%d%d",&u,&v),dae(u,v);
	dfs1(1);
	
	if(!prework()) return cout<<-1,0;
	if(len&1) sum[px]-=(tot/=2),sum[py]-=tot,res+=abs(tot);
	else K[px]++,K[py]--;
	
	dfs2(1); int len=1;
	for(int i=1;i<=n;i++)
		if(!K[i]) res+=abs(sum[i]);
		else q[++len]=K[i]*sum[i];
	
	sort(q+1,q+len+1);
	int mid=q[(len+1)/2];
	for(int i=1;i<=len;i++)
		res+=abs(q[i]-mid);
	
	return cout<<res,0;
} 

Measured memory_bytes: 14960
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

vector<int> cul_day(vector<int> cs,vector<int> ss,vector<int> t, int nd){
	vector<int> lasts(26,nd);
	rep(i, nd){
		lasts[t[i]]=nd-i-1;
	}
	rep(i,26){
		cout << lasts[i] << " ";
		ss[i] -= cs[i]*(1+lasts[i]);
	}
	cout << endl;
	return ss;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  int h, w, k;
  cin >> h >> w >> k;
  vector <vector<int>> m(h,vector<int>(w, 0));
  rep(i, h){
	  string s;
	  cin >> s;
	  rep(j, w){
		  if(s[j] == '#'){
			  m[i][j] = 1;
		  }
	  }
  }
  int ans = 0;
  rep(bit, (1<<h)){
	  rep(pit, (1<<w)){
		  int sum = 0;
		  rep(j, h){
			  rep(p, w){
				  if((bit & (1<<j)) && (pit & (1<<p))){
					  sum += m[j][p];
				  }

			  }
		  }
		  if(sum == k){
			  ans++;
		  }
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = sc.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min, r);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 100148
n, k = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
for i in range(k):
    ans += (p[i] + 1) / 2
t = ans
for i in range(k, n):
    t += (p[i] + 1) / 2 - (p[i - k] + 1) / 2
    ans = max(ans, t)

print(ans)

Measured memory_bytes: 71792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using ll = long long;
using ld = long double;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

double len(pair<int, int>a, pair<int, int>b) {
    double x = a.first - b.first;
    double y = a.second - b.second;
    return sqrt(x * x + y * y);
}

signed main() {
    accell();
    int n;
    cin >> n;
    vector<pair<int, int> >a(n);
    for(auto &i : a)
        cin >> i.first >> i.second;
    vector<int>b(n);
    iota(all(b), 0);
    double cur = 0;
    do {
        for(int i = 1; i < b.size(); ++i) {
            cur += len(a[b[i - 1]], a[b[i]]);
        }
    }  while(next_permutation(all(b)));
    int kek = 1;
    for(int i = 1; i <= n; ++i)
        kek *= i;
    cout << fixed << setprecision(10) << (cur / (double)kek) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18;
const ll INF=1LL<<60;

int main(){
    
    int N,M,K;cin>>N>>M>>K;
    
    vector<ll> P(N);
    
    for(int j=0;j<N;j++){
        cin>>P[j];
    }
    vector<ll> A(N+M,0),B(N+M-M+1,0);//B[i]はi番目(1-indexed)以前の最大値
    for(int i=0;i<M;i++) A[i]=-INF;
    /*for(int i=M;i<N+M;i++){
        A[i]=P[i-M];
    }*/
    deque<int> deq(N+M);
    /*int s=0,t=0;
    for(int i=0;i<N+M;i++){
        while(s<t&&A[deq[t-1]]<=A[i]) t--;
        deq[t]=i;
        t++;
        
        if(i-M+1>=0){
            B[i-M+1]=A[deq[s]];
            if(deq[s]==i-M+1) s++;
        }
    }*/
    
    ll ans=0;
    
    for(int i=1;i<=K;i++){
        vector<ll> S(N+1,-INF);
        S[0]=0;
        for(int j=1;j<=N;j++){
            S[j]=P[j-1]*i;
        }
        for(int j=1;j<=N;j++){
            ll a=B[j-1];
            S[j]+=a;
        }
        for(int j=1;j<=N;j++){
            A[j+M-1]=S[j];
        }
        //deq.clear();
        int s=0,t=0;
        for(int j=0;j<N+M;j++){
            while(s<t&&A[deq[t-1]]<=A[j]) t--;
            deq[t]=j;
            t++;
            
            if(j-M+1>=0){
                B[j-M+1]=A[deq[s]];
                if(deq[s]==j-M+1) s++;
            }
        }
        if(i==K){
            for(int j=1;j<=N;j++) ans=max(ans,S[j]);
        }
        /*for(int j=1;j<=N;j++) cout<<S[j]<<" ";
        cout<<endl;*/
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 4992
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        boolean judge = s.startsWith("YAKI");
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

template<typename T>
class UnionFind {
public:
    UnionFind(size_t  size) : data_(size, -1) {}

    bool unite(T x, T y) {
        x = root(x);
        y = root(y);

        if (x != y) {
            if (data_[y] < data_[x]) {
                std::swap(x, y);
            }
            data_[x] += data_[y];
            data_[y] = x;
        }
        return x != y;
    }

    bool isSameGroup(T x, T y) {
        return root(x) == root(y);
    }

    T root(T x) {
        return data_[x] < 0 ? x : data_[x] = root(data_[x]);
    }

    // --
    size_t size(T x) {
        return -data_[root(x)];
    }

private:
    std::vector<T> data_;
};

int main()
{
    int64_t N, K, L;
    std::cin >> N >> K >> L;

    UnionFind<int64_t> byRoad(N), byTrain(N);

    for (decltype(K) i = 0; i < K; ++i) {
        int64_t p, q;
        std::cin >> p >> q;
        byRoad.unite(p-1, q-1);
    }

    for (decltype(L) i = 0; i < L; ++i) {
        int64_t r, s;
        std::cin >> r >> s;
        byTrain.unite(r-1, s-1);
    }

    std::unordered_map<int64_t, std::unordered_map<int64_t, int64_t>> m;

    for (int64_t i = 0; i < N; ++i) {
        m[byRoad.root(i)][byTrain.root(i)]++;
    }

    for (int64_t i = 0; i < N; ++i) {
        std::cout << m[byRoad.root(i)][byTrain.root(i)] << " ";
    }

    #if 0
    for (int64_t i = 0; i < N; ++i) {
        int64_t count = 0;
        for (int64_t j = 0; j < N; ++j) {
            if (byRoad.isSameGroup(i, j) && byTrain.isSameGroup(i, j)) {
                count++;
            }
        }
        std::cout << count << " ";
    }
    #endif

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 31304
use proconio::input;

fn main() {
    input! {
        a: i64,
        mut b: i64,
        mut c: i64,
        k: i64,
    };

    let mut m = 0;
    while a >= b {
        b *= 2;
        m += 1;
    }
    while b >= c {
        c *= 2;
        m += 1;
    }
    let ans = m <= k;
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 2144
#include <cstdio>
#include <iostream>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <cstdlib>
#define INT long long
using namespace std;

string s;
int g, p, n;

int main()
{
    cin>>s;
    for(int i = 0 ; i < s.size() ; i++)
        if( s[i] == 'g' ) g++;
        else p++;
    cout<<(g-p)/2<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << 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;
typedef long long int ll;


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

    map<int, int> counter;
    rep(i,n){
        int a;
        cin >> a;
        counter[a]++;
    }
    int know = 0;
    priority_queue<int, vector<int> , greater<int>> que;
    for(auto x : counter){
        que.push(x.second);
        know++;
    }

    int ans = 0;
    while(know > k){
        ans += que.top();
        que.pop();
        know--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10748
#include <stdio.h>

#define ARRAY_LEN 4

int
main(void)
{
	char s[ARRAY_LEN];
	int i, res = 0;

	scanf("%s", s);

	for (i = 0; i < 3; i++)
		if (s[i] == '1')
			res++;
	printf("%d\n", res);
	return (0);
}

Measured memory_bytes: 128
#define PROBLRM "https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_A"
#include <iostream>
#ifndef _MODINT_H_
#define _MODINT_H_
#include <iostream>
#include <assert.h>

template<int Mod>
struct ModInt {
    int v;
    ModInt(): v(0){}
    template<typename T>
    explicit ModInt(T t) {
        v = t % Mod;
        if (v < 0) v += Mod;
    }

    ModInt pow(int k) {
        ModInt res(1), x(v);
        while(k) {
            if (k % 2 == 1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }

    template<typename T>
    ModInt& operator=(T a) { v = a % Mod; if (v < 0) v += Mod; return *this; }
    ModInt inv() { return pow(Mod - 2); }
    ModInt& operator+=(ModInt a) { v += a.v; if (v >= Mod) v -= Mod; return *this; }
    ModInt& operator-=(ModInt a) { v += Mod - a.v; if (v >= Mod) v -= Mod; return *this; }
    ModInt& operator*=(ModInt a) { v = 1LL * v * a.v % Mod; return *this; }
    ModInt& operator/=(ModInt a) { assert(a.v != 0); return (*this) *= a.inv(); }
    ModInt operator+(ModInt a) const { return ModInt(v) += a; }
    ModInt operator-(ModInt a) const { return ModInt(v) -= a; }
    ModInt operator*(ModInt a) const { return ModInt(v) *= a; }
    ModInt operator/(ModInt a) const { return ModInt(v) /= a; }
    ModInt operator-() { return ModInt(-v); }
    bool operator==(const ModInt a) const { return v == a.v; }
    bool operator!=(const ModInt a) const { return v != a.v; }
    bool operator<(const ModInt a) const { return v < a.v; }

    friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.v; }
    friend std::istream &operator>>(std::istream &is, ModInt &a) {
        int val;
        is >> val;
        a = ModInt(val);
        return is;
    }
};

#endif // #ifndef _MODINT_H_

constexpr const int MOD = (int)1e9 + 7;

int main()
{
    int n, k;
    std::cin >> n >> k;
    ModInt<MOD> mk(k);
    auto ans = mk.pow(n);
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int g[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},x,y;
	cin >> x >> y;
	cout << ((g[x]==g[y])?"Yes":"No") << endl;
	return 0;
}

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

long double power(long double a,long n)
{
	long double res=1;
	while(n)
	{
		if(n&1)
		{
			res*=a;
			n--;
		}
		else
		{
			a*=a;
			n/=2;
		}
	}
	return res;
}


int main()
{
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	
	/*
	long double angle=(long double)(0.5*(60*h-11*m));
	if(angle>180) angle=(long double)(360-angle);
	long double res=(long double)(angle*pi/180);
	
	
	*/
	long double rad = pi * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
	
	
	
	
	
	long double d=(long double)(a*a+b*b)-(long double)(2*a*b)*cos(rad);
	
	
	cout<<fixed<<setprecision(20)<<(long double)(sqrt(d))<<endl;
	return 0;
}

Measured memory_bytes: 4164
n,m = gets.split.map(&:to_i)

road = Array.new(n+1){[]}
m.times do
    a,b = gets.split.map(&:to_i)
    road[a] << b
    road[b] << a
end

ans = 0
while s = road.index{|x| x.size == 1} do
    loop do
        ans += 1
        t = road[s].shift
        road[t].delete(s)
        road[t].size == 1 ? s = t : break
    end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
using namespace std;
int main(){

    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    int ans =0;

    for(int i=0; i<n; i++){
        cin >> v[i];
    }

    for(int i=0; i<n; i++){
        cin >> c[i];
    }

    for(int i=0;i<n;i++){
        if(v[i] > c[i]){
            ans += (v[i]-c[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, x;
  cin >> n >> x;
  int ans = 0;
  int tmp;
  cin >> tmp;
  ans = abs(x - tmp);
  rep (i, n - 1) {
    int tmp;
    cin >> tmp;
    ans = gcd(ans, abs(x - tmp));
  }
  P(ans);

  return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,k,c,num=0,cnt[200010];
string s;

int main()
{
	cin>>n>>k>>c>>s;
	int cur=0;
	while(cur<n)
	{
		while(cur<n&&s[cur]=='x') cur++;
		num++;
		cnt[cur]++;
		cur+=c+1;
	}
	if(num>k) return 0;
	cur=n-1;
	num=0;
	while(cur>=0)
	{
		while(cur>=0&&s[cur]=='x') cur--;
		cnt[cur]++;
		cur-=c+1;
	}
	rep(i,n) if(cnt[i]==2) cout<<i+1<<endl;
	return 0;
}

Measured memory_bytes: 4508
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
 int n;
 double d1,d2,d3,dinf;
 cin >> n;
 int x[n]={};
 int y[n]={};

 for(int i=0;i<n;++i){
  cin >> x[i];
 }
 for(int i=0;i<n;++i){
  cin >> y[i];
 }

 dinf=0.0;
 for(int i=0;i<n;++i){
  d1+=fabs(x[i]-y[i]);
  d2+=pow(x[i]-y[i],2);
  d3+=pow(fabs(x[i]-y[i]),3);
  
  if(fabs(x[i]-y[i])>dinf){
   dinf=fabs(x[i]-y[i]);
  }
 }

 d2=sqrt(d2);
 d3=pow(d3,1.0/3.0);

 cout << fixed << setprecision(8) << d1 << endl << d2 << endl << d3 << endl << dinf << endl;
 return 0;
}

Measured memory_bytes: 3440
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int DigitsSum(int num){
	int digits;
	int sum = 0;
	while (num) {
		digits = num % 10;
		sum += digits;
		num /= 10;
	}
	return sum;
}

int main() {
	//vector<int> a(N);
	//for (int i = 0; i < N; i++) cin >> a[i]
	//sort(a.begin(), a.end() , greater<int>());

	int H,N;
	cin >> H >> N;

	int sum = 0;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}

	if (sum < H) cout << "No";
	else cout << "Yes";

	//vector<int> p(M);
	//vector<string> S(M);
	//for (int i = 0; i < M; i++) cin >> p[i] >> S[i];

	//int ac=0, wa=0;
	//int pnum = 1;
	//int ppnum = 0;
	//int flag = 0;

	//for (int i = 0; i < M; i++) {
	//	if (pnum != ppnum) {
	//		flag = 0;
	//	}
	//	if (pnum == p[i]) {
	//		if (S[i] == "WA" && flag == 0) {
	//			wa++;
	//		}

	//		if (S[i] == "AC" && flag == 0) {
	//			ac++;
	//			pnum++;
	//			flag = 1;
	//			continue;
	//		}
	//	}
	//	ppnum = pnum;
	//}

	//cout << ac << " " << wa;
	return 0;
}


Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

//func fib(n int) int {
//	fmt.Println(n)
//	if n == 0 {
//		return 0
//	}
//	if n == 1 {
//		return 1
//	}
//	if done[n] {
//		fmt.Println("done" + fmt.Sprint(n))
//		return memo[n]
//	}
//	done[n] = true
//	memo[n] = fib(n-1) + fib(n-2)
//	return memo[n]
//}

var dp []int = make([]int, 10)
var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

func fib(n int) int {
	dp[0] = 0
	dp[1] = 1
	for i := 2; i <= n; i++ {
		dp[i] = dp[i-1] + dp[i-2]
	}
	return dp[n]
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	n := nextInt()
	for i := 0; i < n; i++ {
		a := next()
		m[a] += 1
	}
	res := []string{}
	max := 0
	for a, v := range m {
		if len(res) > 0 {
			if max < v {
				res = []string{}
				res = append(res, a)
				max = v
			} else if max == v {
				res = append(res, a)
			}
		} else {
			res = append(res, a)
			max = v
		}
	}
	sort.Strings(res)
	joined := strings.Join(res, "\n")
	fmt.Fprint(out, joined)
}


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

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++){
        if(i % d == 0) ans++;
    }
    cout << ans << endl;
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1000000007;
const int INF = 1<<18;
const lint INFLINT = 1LL << 60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(b<a){a=b;return true;}return false;}

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

int main() {
    int r;
    cin >> r;
    cout << 2.0 * PI * r;
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




//UnionFind Template
struct UnionFind{ //構造体の定義
    vector<int> d; 
    UnionFind(int n=0): d(n,-1) {} //コンストラクタ
    int find(int x){
        if(d[x]<0) return x;
        return d[x]=find(d[x]);
    }
    bool unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return false;
        if(d[x]<d[y]) swap(x,y);//d[x] is smaller. Then, connect d[x] to d[y].
        d[y]+=d[x];
        d[x]=y;
        return true;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return -(d[find(x)]);   
    }
    int rootsize(){
        int cnt=0;
        for(auto& v: d){
            if(v<0) cnt++;
        }
        return cnt;
    }
};
//How to use
//UnionFind uf(n); などと書けば使えるようになる.ufというobjectが生成される
//uf.unite(a,b);などで中の関数を使える



int main(){
    int n,m; cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        uf.unite(a,b);
    }
    cout<< uf.rootsize()-1 <<endl;
    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
         int n,k;
         cin>>n>>k;
         int p[n];
         for(int i=0;i<n;i++)cin>>p[i];
         int ans=0,mans;
         for(int i=0;i<k;i++)ans+=(p[i]+1);
         mans=ans;
         for(int i=k;i<n;i++){
             ans-=(p[i-k]+1);
             ans+=p[i]+1;
            mans=max(mans,ans);
         }
         long double aa=mans;
         cout << fixed << setprecision(15)<<(aa)/2.0;

        }


Measured memory_bytes: 1792
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	long n = read.to!long;
	
	long ans;
	for(long k = 1; k * k <= n; k ++){
		if(n % k != 0) continue;
		long m = n / k - 1;
		if(m > k) ans += m;
	}
	ans.writeln;
}

/*

n = m k + k
  = (m + 1)k, 0 <= k < m

kはnの約数
そのうちで n / k - 1 = m としたとき k < m であるようなものを言えばよい

約数は素因数分解ではなくて割ってみるでよい

*/


Measured memory_bytes: 256
N, M = map(int, input().split())

Msq = int(M**(1/2)) + 2
yaku = []

for i in range(2, Msq):
  now = 0
  while M%i == 0:
    M = M//i
    now += 1
  if now >= 1:
    yaku.append(now)
    
if M > 1:
  yaku.append(1)
  
yaku.sort()

MOD = 1000000007
frac = [1] * (N+50)
num = len(frac)
for i in range(num-1):
  frac[i+1] = frac[i] * (i+1) % MOD
  
finv = [1] * (N+50)
finv[-1] = pow(frac[-1], MOD-2, MOD)
for i in range(1, num):
  finv[num-1-i] = finv[num-i] * (num-i) % MOD
  
ans = 1
for i in yaku:
  ans = ans * frac[N+i-1] * finv[N-1] * finv[i] % MOD
  
print(ans)


Measured memory_bytes: 10996
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+10;
ll dp[55][55][105];
ll n,ara[55],k;
ll cholo(ll l,ll r,ll k){
    if(k==0) return 0;
    if(r<l){
        if(l>r) return 0;
    }
 
    ll &ret=dp[l][r][k];
    if(~ret)  return ret;
    ll sum=0;
    if(ara[l]>=0) sum=ara[l]+cholo(l+1,r,k-1);
    else if(ara[l]<0){
        if(k>1) sum=max(sum,cholo(l+1,r,k-2));
        sum=max(sum,ara[l]+cholo(l+1,r,k-1));
    }
 
    if(ara[r]>=0) sum=max(sum,ara[r]+cholo(l,r-1,k-1));
    else if(ara[r]<0){
        if(k>1) sum=max(sum,cholo(l,r-1,k-2));
        sum=max(sum,ara[r]+cholo(l,r-1,k-1));
    }
 
    return (ret=sum);
}
int main()
{
    Khela
    ll a,b,c,i,j,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>k)
    {
        for(i=0;i<n;i++)  cin>>ara[i];
        memset(dp,-1,sizeof dp);
        ll ans=cholo(0,n-1,k);
        cout<<ans<<endl;
    }
 
 
 
 
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    ll a;
    const ll MOD=1000003;
    modint(ll a_=0){
        a=((a_%MOD)+MOD)%MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y(a+x.a);
        return y;
    }
    modint operator-(const modint& x){
        modint y(a-x.a);
        return y;
    }
    modint operator*(const modint& x){
        modint y(a*x.a);
        return y;
    }
    modint operator/(const modint& x){
        return *this * x.inv();
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}
modint fc[1000003]={1};
modint fct(int n){
    return fc[n];
}
modint ifc[1000003]={1};
modint ifct(int n){
    return ifc[n];
}
void initfct(int n){
    Fr(i,n) fc[i]=fc[i-1]*i;
    ifc[n]=fct(n).inv();
    ifr(i,n) ifc[i]=ifc[i+1]*(i+1);
}
modint cmb(int n,int r){
    if(n<0||r<0||n<r) return 0;
    return fct(n)*ifct(r)*ifct(n-r);
}

template<class T,class U>
T pw(T n,U m){
    if(m==0) return 1;
    else if(m%2==0) return pw(n*n,m/2);
    else return n*pw(n,m-1);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    initfct(1000002);
    vector<modint> e;
    int q,n;
    cin>>q;
    modint x,d;
    fr(i,q){
        cin>>x>>d>>n;
        if(d==0){
            cout<<pw(x,n)<<endl;
            continue;
        }
        if(x==0||n>=1000003){
            cout<<0<<endl;
            continue;
        }
        x*=d.inv();
        if(x.a+n-1>=1000003){
            cout<<0<<endl;
            continue;
        }
        cout<<fct(x.a+n-1)*ifct(x.a-1)*pw(d,n)<<endl;
    }
}

Measured memory_bytes: 32256
#include <stdio.h>
#define SIZE 100011

int main(void) {
  int num, tmp;
  int su[SIZE] = {};
  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf("%d", &tmp);
    su[tmp]++;
    su[tmp + 1]++;
    if (tmp != 0) {
      su[tmp - 1]++;
    }
  }
  tmp = su[0];
  for (int i = 0; i < SIZE - 5; i++) {
    if (tmp < su[i + 1]) {
      tmp = su[i + 1];
    }
  }
  printf("%d", tmp);

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>

int main(void){
  int N;
  std::vector<int> d;
  std::cin >> N;
  for(int i=0;i<N;i++){
    int tmp;
    std::cin>>tmp;
    d.push_back(tmp);
  }

  long long int sum=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      sum+=d[i]*d[j];
    }
  }
  std::cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,maxn=0;
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=2;j<=10;j++)
			if(pow(i,j)>maxn&&pow(i,j)<=n)
				maxn=pow(i,j);
	cout<<maxn<<endl;
	return 0;
}

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

const int mod = 1e9 + 7;
int main(void){
    int r,c;
    cin >> r >> c;
    vector<vector<int>> dp(r,vector<int>(c,0));
    string a[r];
    for(int i = 0; i < r; i++){
        cin >> a[i];
    }
    if(a[0][0] == '#' || a[r - 1][c - 1] == '#'){
        cout << 0 << endl;
        return 0;
    }
    dp[0][0] = 1;
    for(int i = 1; i < c; i++){
        if(a[0][i] == '.'){
            dp[0][i] = dp[0][i - 1];
        }
    }
    for(int i = 1; i < r; i++){
        if(a[i][0] == '.'){
            dp[i][0] = dp[i - 1][0];
        }
    }
    for(int i = 1; i < r; i++){
        for(int j = 1; j < c; j++){
            if(a[i][j] == '.'){
                dp[i][j] = (dp[i - 1][j] + (long long)dp[i][j - 1]) % mod;
            }
        }
    }
    cout << dp[r - 1][c - 1] << endl;
}

Measured memory_bytes: 5248
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long 
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll dp[200009];
vl v;
ll n,k;

ll solve(ll i)
{
    dp[i]=dp[i-1] + abs(v[i] - v[i-1]);
    for(ll j=2;j<=k;j++)
    {
        if(i>=j)
        dp[i]=min(dp[i], dp[i-j] + abs(v[i] - v[i-j]));
        else
        break;
    }
    
    if(i==n-1)
    return dp[i];
    else
    return solve(i+1);
}




int main()
{
    SYNC
    ll temp; in(n)>>k;
    v.clear();
    l(i,0,n)
    {
        in(temp);
        //o(temp)<<" ";
        v.pb(temp);
    }
    dp[0]=0;
    ll ans = solve(1);
    o(ans)<<endl;
    
    
    
    
    
    
    
}

Measured memory_bytes: 1908