akhauriyash/Code-Regression huggingface dataset:
from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日
    for d in range(ct):
        last[T[d]] = d + 1
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    score -= S[ct][prei]
    score += S[ct][ci]
    for d in range(ct, D):
        if d != ct and T[d] == prei:
            break
        score += C[prei]*(d + 1 - ct - 1)
        score -= C[prei]*(d + 1 - last[prei])
    for d in range(ct, D):
        if d != ct and T[d] == ci:
            break
        score += C[ci]*(d + 1 - last[ci])
        score -= C[ci]*(d + 1 - ct - 1)
    T[ct] = ci
    return score, T


def local_search():
    pass


def main(D, C, S):
    T = []
    for d in range(D):
        # d日目終了時点で満足度が一番高くなるようなコンテストiを開催する
        max_score = -INF
        best_i = 1
        for i in range(26):
            T.append(i)
            score = calc_score(D, C, S, T)
            if max_score < score:
                max_score = score
                best_i = i
            T.pop()
        T.append(best_i)
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    T = [int(input())-1 for i in range(D)]
    M = int(input())
    DQ = [[int(i)-1 for i in input().split()] for j in range(M)]
    score = calc_score(D, C, S, T)
    for d, q in DQ:
        score, T = update_score(D, C, S, T, score, d, q)
        print(score)


Measured memory_bytes: 97716
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            long a, b;
            ReadLong(out a, out b);
            long ans = a * b / Gcd(a, b);
            Console.WriteLine(ans);
        }

        static long Gcd(long a, long b)
        {
            while (b != 0)
            {
                long next = a % b;
                a = b;
                b = next;
            }

            return a;
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13396
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,X,Y = list(map(int , input().split()))

combi = list(itertools.combinations(range(1,N+1),2))

ansList = [0 for _ in range(N)]

for i,j in combi:
    kyori = min(j-i, abs(j-Y) + abs(X-i) + 1)
    ansList[kyori] += 1
#    print(i,j,ansList)

for ans in ansList[1:]:
    print(ans)



Measured memory_bytes: 147876
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<string> v;
    string str;
    cin >> str;
    stringstream ss{str};
    string buf;
    while(getline(ss, buf, '/')){
        v.push_back(buf);
    }
    if(stoi(v[0])<=2018){
        cout << "Heisei" << endl;
    }else if(stoi(v[0])==2019 && stoi(v[1])<=4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }

    return 0;
}

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

long long n;

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    long long num = 1;
    long long sum = 0;

    while (n > 1) {
        sum += num;
        num *= 2;
        n /= 2;
    }
    cout << sum + num << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: "List[int]"):
    A.sort()
    print(A[-1]-A[0])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int n;
  int i,count=0;

  scanf("%d", &n);

  for(i=1;i<=n;i++){
    if(i / 10 < 1){
      //一桁
      count++;
    }else if(i / 100 < 1){
      i += 89;
    }else if(i / 1000 < 1){
      count++;
    }else if(i / 10000 < 1){
      i += 8999;
    }else if(i / 100000 < 1){
      count++;
    }
  }

  printf("%d\n", count );
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

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

map<int, int> m;

int main() {
    int n;
    cin >> n;
    rep(i, n){
        int a; cin >> a;
        m[a]++;
    }

    bool flag = false;

    for(const auto& e : m){
        if(e.second > 1){
            flag = true;
        }
    }

    if(flag){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 9600
big = 10**9 + 7

def typical_stairs(n,m,a):

    flag = [True]*(n+1)
    for i in range(m):
        tmp = a[i]
        flag[tmp] = False

    route = [0]*(n+1)
    route[0] = 1
    ans = route[0]
    if flag[1]:
        route[1] = 1
    else:
        route[1] = 0

    for i in range(2,n+1):
        if flag[i]:
            route[i] = route[i-1] + route[i-2]

        ans = route[i]

    return ans%big
if __name__ == '__main__':
    n,m = map(int,raw_input().split())
    a = [int(raw_input()) for _ in range(m)]
    print typical_stairs(n,m,a)

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

int n;
const int maxn = 2e5 + 5;
typedef long long ll;

ll a[maxn];
set<ll> s;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    bool flag = true;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        if(i > 1 and a[i] > a[i - 1] + 1){
            flag = false;
        }
    }
    if(!flag){
        cout << -1 << endl;
        return 0;
    }
    s.clear();
    ll ans = 0;
    for(int i = n;i >= 1;i--){
        ans += s.size();
        if(s.size() > 0 and *s.begin() == n - i){
            s.erase(s.begin());
        }
        if(a[i] > 0)
            s.insert(a[i] + n - i);
    }
    if(s.size() != 0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main() {

	while (true) {
		string a;

		cin >> a;

		if (a == "0")break;
		int ans = 0;
		for (int i = 0; i < a.size(); i++) {
			ans += a[i]-'0';
		}
		cout << ans << endl;
	}
	return 0;

}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define inp(a) int a; cin>>a;
#define inpa(a,n) vector<int>a(n+1); FOR(i,1,n) cin>>a[i];
#define PI 3.141592653589793238
#define QUICK ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vec(x) vector<x>
#define pii pair<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define FOR(i,j,n) for(int i= j; i<=n; i++)
#define srt(a); sort(a.begin(), a.end())
#define CASE int t; cin>>t; while(t--)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define print(x) for(auto c : x) cout << c << " ";
#define dbg(x) cerr << #x << " :: "<< x << endl;
#define dbg2(x,y) cerr << #x << " :: "<<x <<"\t" << #y << " :: "<<y <<endl;
#define upcase(s)  transform(s.begin(), s.end(), s.begin(), ::toupper)
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define int ll
const int INF = 1e9 + 7;
const int SIZE = 1e9 + 5;
const int MOD = 1e9 + 7; 
//////////// template ends here //////////////////////////

const int maxn = 1e5 + 3;

vector<int>graph[maxn];
vec(int)depth(maxn, 0);
vec(bool) vis(maxn, 0);

void dfs(int node, int parent){
	
	vis[node] = 1;
	for(int c : graph[node]){
		if(!vis[c])
			dfs(c, node);
		else
			depth[node] = max(depth[node], depth[c] + 1);
	}

	depth[parent] = max(depth[parent], depth[node]  + 1);
}

void solve(){
	inp(n); inp(m);

	FOR(i,1,m){
		inp(a); inp(b);
		graph[a].pb(b);
	}

	FOR(i,1,n){
		if(!vis[i])
			dfs(i, 0);
	}

	int ans = 0;

	FOR(i,0,n){
		//dbg(depth[i])
		ans = max(ans, depth[i]);
	}
	cout << ans-1  << endl;	
}



int32_t main(){
	#ifndef ONLINE_JUDGE 
		freopen ("input.txt","r",stdin);
		freopen ("output.txt","w",stdout);
	#endif	
	QUICK;
	//CASE{
		solve();
	//}
	printclock;
}

Measured memory_bytes: 12080
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
vector<int> a[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x <= m) a[m - x].push_back(y);
  }
  int64 ret = 0;
  multiset<int> A;
  for (int k = m - 1; k >= 0; --k) {
    for (auto& it : a[k]) A.insert(it);
    if (A.size()) {
      auto it = std::prev(A.end());
      ret += *it;
      A.erase(it);
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 7808
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder_B
{
    class Program
    {
        static void Main(string[] args)
        {

            var input = Enumerable.Range(0, 5).Select(i => Console.ReadLine()).Select(x => int.Parse(x)).ToArray();
            var xxx = input.OrderBy(x => (x + 9) % 10);
            var last = xxx.First();
            var total = xxx.Skip(1).Select(x => ((x + 9) / 10) * 10).Sum() + last;
            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>

using namespace std;

int main(){
    int N, K, d, a;
    int A[101] = {};
    cin >> N >> K;
    for(int i=0; i<K; i++) {
        cin >> d;
        for(int j=0; j<d; j++){
            cin >> a;
            A[a-1] += 1;
        }
    }
    int ans = 0;
    for(int i=0; i<N; i++) ans += (A[i] != 0 ? 0 : 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

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

string to_string(string s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

int H, W;

int dist(pair<int, int> p, pair<int, int> q)
{
    return (abs(p.first - q.first) + abs(p.second - q.second));
}

int main()
{
    cin >> H >> W;

    int left = W, right = 0, up = H, down = 0;
    vector<string> grid(H);
    for (int i = 0; i < H; i++)
    {
        cin >> grid[i];
        for (int j = 0; j < W; j++)
        {
            if (grid[i][j] == 'B')
            {
                left = min(left, j);
                right = max(right, j);
                up = min(up, i);
                down = max(down, i);
            }
        }
    }

    set<pair<int, int>> st;
    for (int i = 0; i < W; i++)
    {
        if (grid[up][i] == 'B')
            st.insert({up, i});
        if (grid[down][i] == 'B')
            st.insert({down, i});
    }

    for (int i = 0; i < H; i++)
    {
        if (grid[i][left] == 'B')
            st.insert({i, left});
        if (grid[i][right] == 'B')
            st.insert({i, right});
    }

    vector<pair<int, int>> v;
    for (auto &p : st)
    {
        v.push_back(p);
    }

    int ans = 0;
    int N = v.size();
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i == j)
                continue;
            ans = max(dist(v[i], v[j]), ans);
        }
    }

    //debug_out(v);
    cout << ans << endl;
}



Measured memory_bytes: 4096
// https://atcoder.jp/contests/agc022/tasks/agc022_a
#include<stdio.h>
#include<string.h>

void addunusedchar();
int main(void){
    char strin[27], output[27];
    scanf("%s", strin);

    int usedchars[26] = {};

    if(strcmp(strin, "zyxwvutsrqponmlkjihgfedcba") == 0){
        puts("-1");
        return 0;
    }

    /*長さが26(全アルファベットが既出)の場合
    後ろから見て代償が逆転しているところを入れ替える
    */
   else if(strlen(strin) == 26){
       for(int i=24; i >= 0 ; i--){
           int change;
           for(change=25; change> i && strin[change] < strin[i]; change--);
           if(change > i){
               strncpy(output, strin, i);
                output[i] = strin[change];
                output[i+1] = '\0';
                break;
           }
           
       }
   }
    /*長さが26未満の場合
    まだ出てきてない文字の中で最小のものを最後尾につける
    */
    else{
        for(int i=0; strin[i] != '\0'; i++){
            usedchars[strin[i] - 'a'] = 1;
        }
        strcpy(output, strin);
        for(int k=0; k<26; k++){
            if(usedchars[k] == 0){
                output[strlen(strin)] = 'a' + k;
                output[strlen(strin) + 1] = '\0';
                break;
            }
        }
   }

    puts(output);
    return 0;
}

Measured memory_bytes: 128
from sys import stdin


def main() -> None:
    n = next_int()
    print(("No", "Yes")[n % s(n) == 0])


def s(n: int) -> int:
    result = 0
    while n != 0:
        result += n % 10
        n //= 10
    return result


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }



int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    bool win[T.length()];
    REP(i, T.length()){
        win[i] = true;
    }
    ll sum = 0;
    REP(i, K){
    
        if(T[i] == 'r'){
            sum += P;
        }
        else if(T[i] == 's'){
            sum += R;
        }
        else if(T[i] == 'p'){
            sum += S;
        }
    }
    for(int i = K; i < T.length(); i++){
        if(T[i] == T[i - K] && win[i - K]){
            win[i] = false;
        }
        else if(T[i] == 'r'){
            sum += P;
        }
        else if(T[i] == 's'){
            sum += R;
        }
        else if(T[i] == 'p'){
            sum += S;
        }
    }
  	cout << sum << endl; 
    return 0;
}


Measured memory_bytes: 512
import collections
from collections import deque
def tree(s,m):
    INF=-10**9
    visited = [INF for i in range(n)]

    def bfs():
        d = deque()
        d.append(s)
        ans=m
        mod=10**9+7
        count=0
        visited[s]=0
        while len(d):
            v = m
            x = d.popleft()
            if count<2:
                count+=1
            v-=count
            for i in range(len(b[x])):
                y=b[x][i]
                if visited[y] == INF:
                    visited[y]=0
                    d.append(y)
                    ans*=v
                    ans%=mod
                    v-=1
        return ans
    return bfs()

# ユニオンファインド
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m= map(int, input().split())
a = [list(map(int, input().split())) for i in range(n-1)]
b = [[] for i in range(n)]
uf=UnionFind(n)
for i in range(n-1):
    b[a[i][0]-1].append(a[i][1]-1)
    b[a[i][1]-1].append(a[i][0]-1)
    uf.union(a[i][0]-1,a[i][1]-1)

u=uf.find(0)


c=tree(u,m)
print(c)


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

#define fastIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    fastIO;
    int N, W;
    cin >> N >> W;
    int w, v;
    vector<vector<ll>> DP(N + 1, vector<ll>(W + 1));
    for(int i = 1; i < N + 1; i++) {
        cin >> w >> v;
        DP[i] = DP[i - 1];
        for(int _w = w; _w < W + 1; _w++)
            DP[i][_w] = max(v + DP[i - 1][_w - w], DP[i - 1][_w]);
    }
    cout << DP[N][W];
}

Measured memory_bytes: 83112
#include <iostream>

using namespace std;

void call(int n){
	int i=1;
	do{
		int x=i;
		if (x%3==0){
			cout<<" "<<i;
		}
		else {
			do {
				if (x%10==3){
					cout<<" "<<i;
					break;
				}
				x/=10;
			}while (x);
		}
	}while (++i<=n);
	cout<<endl;
}

int main(){
	int n;
	cin>>n;
	call(n);
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define mod (1000000007)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
vector<int>dp(1010,0);
void solve() 
{
    int h,w;cin>>h>>w;
    dp[1]=1;
    REP(i,h){
        string s;cin>>s;
        rep(j,1,w+1)
            s[j-1]=='#'?dp[j]=0:dp[j]=(dp[j]+dp[j-1])%mod;
    }
    cout<<dp[w]<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  
  int num1;
  
  int A;
  int B;
  
  scanf("%d",&num1);
  
  if(num1 == 1){
    puts("Hello World");
  }
  else {
    scanf("%d %d",&A,&B);
    printf("%d",A + B);
  }
  
  return 0;
}
    

Measured memory_bytes: 128
A, B, C, D = map(int, input().split())
sb = B // C
sa = (A - 1) // C
tb = B // D
ta = (A - 1) // D


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


lcm = (C * D) // gcd(C, D)


mb = B // lcm
ma = (A - 1) // lcm

L = sb - sa + tb - ta - (mb - ma)
print(B - A - L + 1)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  int x = 1;
  while (x * (x - 1) / 2 < n) {
    x += 1;
  }
  if (x * (x - 1) / 2 != n) {
    cout << "No" << endl;
    return;
  }
  vector<vi32> ans(x);
  int now = 1;
  rep(i, x) rep(j, i) {
    ans[i].emplace_back(now);
    ans[j].emplace_back(now);
    now += 1;
  }
  cout << "Yes" << endl;
  cout << x << endl;
  rep(i, x) {
    cout << sz(ans[i]) << " " << ans[i] << endl;
  }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 2222;
int l[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ina(n, l);
    sort(l + 1, l + n + 1);
    int ans = 0;
    rep(i, 1, n - 2) {
        int r = i + 1;
        rep(j, i + 1, n - 1) {
            while(r < n && l[r + 1] < l[i] + l[j]) r++;
            if(r == j) continue;
            int d = abs(l[i] - l[j]);
            int k = upper_bound(l + j + 1, l + r + 1, d) - l;
            if(k <= r) {
                ans += r - k + 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    string X;
    cin >> X;
    int countS, countT, l = -1, r=0;
    while(l != r){
        countS = countT = l = r = 0;
        for(int i=0;i<X.size();++i){
            if(X[i] == 'S'){
                if(countS != 0 && countT != 0){
                    r = i - (countT - min(countS, countT));
                    l = i - countT - min(countS, countT);
                    break;
                }
                ++countS;
            }
            else{
                if(countS == 0){
                    continue;
                }
                else{
                    ++countT;
                }
            }
        }
        if(countT !=0 && countS != 0 && l == 0 && r == 0){
            r = X.size() - (countT - min(countS, countT));
            l = X.size() - countT - min(countS, countT);
        }


        X = X.substr(0, l) + X.substr(r, X.size()-r);
    }
    cout << X.size() << endl;
}


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

int main(){
    int n;
    long long a, sm=0, mx=0;
    vector<long long> v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        sm += a;
        v.push_back(a);
    }
    mx = sm;
    sort(v.begin(), v.end());
    for(int i=0;i<n-1;i+=2){
        sm -= 2*v[i];
        sm -= 2*v[i+1];
        mx = max(mx, sm);
    }
    cout << mx << endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int W = scan.nextInt(); 
        int H = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();
        if(H >= (y + r) && W >= (x + r) && (x - r) >= 0 && (y - r) >= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26348
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;

#define lld long long

lld K;
lld memo[15][15];

int solved(int num,int place){
    if(memo[place][num] != 0) return memo[place][num];
    int ans = solved(num,place-1);
    if(num-1 >= 0){
        ans += solved(num-1,place-1);
    }
    if(num+1 <= 9){
        ans += solved(num+1,place-1);
    }
    return memo[place][num] = ans;
}

int main(){
    int K;
    cin >> K;
    memset(memo,0,sizeof(memo));
    for (int i = 0; i < 10; i++) {
        memo[0][i] = 1;
    }
    for (int i = 0; i < 10; i++) {
        solved(i,9);
    }
    lld sum = 0;
    lld mi = -1,mj = -1;
    for(int i=0;i<10;i++){
        for(int j=1;j<10;j++){
            sum += memo[i][j];
            if(sum >= K){
                lld nowi = i-1;
                lld nowj = j;
                lld diff = K - (sum - memo[i][j]);
                cout << j;
                while(nowi > -1){
                    lld sumd = 0;
                    for(int k=max(nowj-1,0LL);k<=nowj+1;k++){
                        sumd += memo[nowi][k];
                        if(diff <= sumd){
                            nowj = k;
                            diff -= (sumd-memo[nowi][k]);
                            break;
                        }
                    }
                    cout << nowj;
                    nowi--;
                }
                cout << endl;
                exit(0);
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>

int main(){


  double l;
  cin>>l;
  
  double answer=(l/3)*(l/3)*(l/3);
  
  cout<<fixed<<setprecision(12);
  cout<<answer<<endl;
  
  
  
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int nax=305;
double p[nax][nax][nax],ev[nax][nax][nax];

int main()
{
    int n;
    cin>>n;
    vector<int> cnt(4);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        cnt[x]++;
    }
    p[cnt[1]][cnt[2]][cnt[3]]=1;
    for(int c=n;c>=0;c--){
        for(int b=n;b>=0;b--){
            for(int a=n;a>=0;a--){

                 if(a==0 && b==0 && c==0) continue;
                  if(a+b+c>n) continue;
                   double p_waste=(double)(n-(a+b+c))/n;
                   double ev_waste=p_waste/(1-p_waste)+1;
                   ev[a][b][c]+=ev_waste*p[a][b][c];


                 if(a!=0){
                       double p_go=(double)a/(a+b+c);
                    p[a-1][b][c]+=p[a][b][c]*p_go;
                    ev[a-1][b][c]+=ev[a][b][c]*p_go;

                 }
                 if(b!=0){
                     double p_go=(double)b/(a+b+c);
                    p[a+1][b-1][c]+=p[a][b][c]*p_go;
                    ev[a+1][b-1][c]+=ev[a][b][c]*p_go;
                 }
                 if(c!=0){
                        double p_go=(double)c/(a+b+c);
                    p[a][b+1][c-1]+=p[a][b][c]*c/(a+b+c);
                    ev[a][b+1][c-1]+=ev[a][b][c]*p_go;
                 }

            }
        }
    }

    cout<<fixed<<setprecision(10)<<ev[0][0][0];
}


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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

int n;
ll a[505][505];
std::set<ll> s;

inline bool chk(int x) {
    for(int i = 2; (ll)i*i <= x; ++i) {
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    vector<int> v;
    for(int i = 2; ; ++i) {
        if(chk(i)) { v.pb(i); }
        if(v.size() == 1002) break;
    }

    read(n);
    if(n == 2) {
        puts("4 7");
        puts("23 10");
        return 0;
    }

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            if((i+j)%2==0) {
                a[i][j] = 1ll * v[(i+j)/2] * v[(i-j)/2+750];
                s.insert(a[i][j]);
            }
        }
    }

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            if((i+j)&1) {
                ll lcm = 1;
                if(i>1) lcm = a[i-1][j] / std::__gcd(lcm, a[i-1][j]) * lcm;
                if(i<n) lcm = a[i+1][j] / std::__gcd(lcm, a[i+1][j]) * lcm;
                if(j>1) lcm = a[i][j-1] / std::__gcd(lcm, a[i][j-1]) * lcm;
                if(j<n) lcm = a[i][j+1] / std::__gcd(lcm, a[i][j+1]) * lcm;

                a[i][j] = lcm + 1;
                s.insert(a[i][j]);
            }
        }
    }

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            printf("%lld ", a[i][j]);
        }
        puts("");
    }

    return 0;
}


Measured memory_bytes: 16896
#include <stdio.h>
int dfs(int n, int s, int x){  
    int sum=0;  
if(n==0 && s==0)
return 1; 
if(n>0){      
    for(int i=x; i<10; i++){     
        if(s-i>=0) 
        sum+=dfs(n-1, s-i, i+1);  
        }
        }  
        return sum;
    
}
        int main(void){ 
            int n, s;  
        while(scanf("%d %d",&n,&s)!= EOF){  
            if(n==0 && s==0) 
        break;      
        printf("%d\n",dfs(n, s, 0)); 
        } 
    return 0;
        
    }
    


Measured memory_bytes: 1924
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = (0 until n).map { readLine()!! }

    var s0 = ""
    val sa = mutableListOf<String>()
    val sb = mutableListOf<String>()
    val sc = mutableListOf<String>()

    for (si in s) {
        when {
            si.first() == 'B' && si.last() == 'A' -> s0 += si
            si.last() == 'A' -> sa.add(si)
            si.first() == 'B' -> sb.add(si)
            else -> sc.add(si)
        }
    }

    var cur = 0
    while (cur < sa.size && cur < sb.size) {
        if (cur == 0) {
            s0 = sa[cur] + s0 + sb[cur]
        } else {
            s0 += sa[cur] + sb[cur]
        }
        cur++
    }

    if (cur < sa.size) {
        s0 = sa.slice(cur until sa.size).joinToString("") + s0
    }

    if (cur < sb.size) {
        s0 += sb.slice(cur until sb.size).joinToString("")
    }

    s0 += sc.joinToString("")

    var ans = 0
    for (i in 1 until s0.length) {
        if (s0[i - 1] == 'A' && s0[i] == 'B') ans++
    }
    println(ans)
}


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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 3556
n, k = map(int, input().split())

ans = 0

for i in range(k, n+2):
    ans += ((i * (2 * n - i + 1) / 2) - (i * (i - 1) / 2) + 1) % (10 ** 9 + 7)


print(int(ans % (10 ** 9 + 7)))


Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
int n,c,l[10];
double dp[500][(1<<7)],t,ans;
int main()
{
    cin>>n>>c; 
    for(int i=0;i<n;++i)
    cin>>l[i];
    sort(l,l+n);
    do
    {
        memset(dp,0,sizeof(dp));
        dp[l[n-1]*n][0]=1;
        for(int i=0;i<=n*c;++i)
        for(int j=i;j<=n*c;++j)
        for(int S=0;S<(1<<n-1);++S)
            if(i%n && !((S>>(i%n-1))&1))
                dp[min(n*c,max(j,i+l[i%n-1]*n))][S|(1<<(i%n-1))]+=dp[j][S];
        ans+=dp[n*c][(1<<n-1)-1];
        t++;
    }
    while(next_permutation(l,l+n-1));
    printf("%.15lf",(double)ans/t/pow(c,n-1));
    return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n,l;cin>>n>>l;

	vector<int> ap;
	int sum=0;
	int tmp =100000000;
	int mi=0;
	bool judge =false;
	for(int i=l; i<l+n; i++){
		ap.push_back(i);
		sum +=i;

		if(i ==0){
			judge =true;
		}
		if(abs(i-0) <tmp){
			tmp =abs(i-0);
			mi =i;
		}
	}
	if(judge){
		writeln(sum);
		return 0;
	}
	writeln(sum-mi);



}




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

int main(){
    int t, x;
    std::cin >> t >> x;

    std::cout << std::fixed << std::setprecision(15) << (double)t / x << std::endl;

    return 0;
}

Measured memory_bytes: 3740
import fractions

A,B,C,D = map(int,input().split())

# CとDの最小公倍数算出
bi = C*D//fractions.gcd(D,C)

A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
# print(B-A-sa)

Bc = B//C
Bd = B//D

Ac = A//C
Ad = A//D

print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))

Measured memory_bytes: 5372
# 演習１－１２
while True:
    a = int(input())
    if a == 0:
        break
    else:
        li = [0]*a
        for i in range(a):
            li[i] = int(input())
        li_sort = sorted(li)
        del li_sort[0]
        del li_sort[-1]
        print(int(sum(li_sort)/len(li_sort)))


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int main(){
	string str;
	int n;
	cin >> n >> str;
	if(n%2==1){cout<<"No"<<endl;return 0;}	
	for(int i=0;i<n/2;i++){
		if(str[i]!=str[n/2+i]){
			cout<<"No"<<endl;
			return 0;
		}	
	}	
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
using namespace std;

const int maxn = 100000+10;
struct POINT{
    int first,second,tag;
}point[maxn];
bool visited[maxn];
int dist[maxn];
inline int cost(const int a, const int b)
{
    return min(abs(point[a].first-point[b].first), abs(point[a].second-point[b].second));
}
pair<int, int> line[maxn*2];
bool cmpx(const POINT a, const POINT b)
{
    return a.first<b.first;
}
bool cmpy(const POINT a, const POINT b)
{
    return a.second<b.second;
}
bool cmptag(const POINT a, const POINT b)
{
    return a.tag<b.tag;
}
bool cmp(const pair<int, int> a, const pair<int, int> b)
{
    return cost(a.first, a.second)<cost(b.first, b.second);
}
int fa[maxn];
int djs(const int n)
{
    return n==fa[n]?n:fa[n]=djs(fa[n]);
}
int main ()
{
    int n;
    while(scanf("%d",&n)!=EOF){
        for(int i=0; i<n; i++){
            scanf("%d %d",&point[i].first,&point[i].second);
            point[i].tag=i;
        }
        sort(point, point+n, cmpx);
        for(int i=0; i<n-1; i++){
            line[i].first=point[i].tag;    
            line[i].second=point[i+1].tag;
        }
        sort(point, point+n, cmpy);
        for(int i=0; i<n-1; i++){
            line[i+n-1].first=point[i].tag;
            line[i+n-1].second=point[i+1].tag;
        }
        sort(point, point+n, cmptag);
        for(int i=0; i<n; i++) fa[i]=i;
        sort(line, line+2*(n-1), cmp);
        long long ans = 0;
        for(int i=0; i<2*(n-1); i++){
            if(djs(line[i].first)==djs(line[i].second))continue;
            ans += cost(line[i].first,line[i].second);
            fa[djs(line[i].first)]=djs(line[i].second);
        }
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
//typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
//#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}


#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}
//素因数分解
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
    ll N,M; cin >> N >> M;
    vel part;
    set<ll> part2;
    make();
    for(auto p : prime_factor(M)) while(p.sc--) { part.pub(p.fs); part2.insert(p.fs); }
    map<ll, int> va;
    rep(i,part.size()) va[part[i]]++;
    ll ans = 1LL;
    vel part22(all(part2));
    rep(i,part22.size()) { ans *= comb(va[part22[i]] + N - 1, va[part22[i]]); ans %= MOD; }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main{
    
    public static void main(String [] args){
        Scanner in=new Scanner(System.in);
        int w,h,x,y,r;
        w=in.nextInt();
        h=in.nextInt();
        x=in.nextInt();
        y=in.nextInt();
        r=in.nextInt();
        if(isInside(w,h,x,y,r)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        in.close();
    }
    
    public static boolean isInside(int w,int h,int x,int y,int r){
        if(x-r>=0&&x+r<=w&&y+r<=h&&y-r>=0){
            return true;
        }
        return false;
    }
}


Measured memory_bytes: 26380
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int power[100005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,k;
   cin>>n>>k;
   if(n==0)
      cout<<1;
   else
   {
      int cnt=0;
      while (n!=0)
      {
         cnt++;
         n/=k;
      }
      cout<<cnt;
      
   }
   

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=3e5+10;
int n,a[4][N],a1,a2,b1,b2;

int bit[N];
void add(int x){for (;x;x-=x&-x) bit[x]^=1;}
int qry(int x){int s=0; for (;x<=n;x+=x&-x) s^=bit[x]; return s;}

int main(){
	scanf("%d",&n);
	rep (i,1,3) rep (j,1,n){
		scanf("%d",&a[i][j]);
		if (i>1&&(a[i][j]-1)/3!=(a[i-1][j]-1)/3) return puts("No"),0;
		if (!((((a[i][j]-1)/3)^j)&1)) return puts("No"),0;
	}
	rep (i,1,n) if (a[2][i]!=(a[2][i]-1)/3*3+2) return puts("No"),0;
	rep (i,1,n) if (a[1][i]>a[3][i]) (i&1)?a1^=1:a2^=1;
	for (int i=1;i<=n;i+=2) b1^=qry((a[2][i]-1)/3+1),add((a[2][i]-1)/3+1);
	memset(bit,0,sizeof(bit));
	for (int i=2;i<=n;i+=2) b2^=qry((a[2][i]-1)/3+1),add((a[2][i]-1)/3+1);
	puts((b1==a2)&&(b2==a1)?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3840
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;
	cin>>n;
	VI l(n,0);
	rep(i,n){
		cin>>l[i];
	}
	int ans = 0;
	sort(all(l));
	for(int i = 0;i<n;i++){
		for(int j = i+1;j<n;j++){
			for(int k = j+1;k<n;k++){
				if(l[i] == l[j] or l[j]==l[k] or l[k]==l[i]){
					continue;
				}
				if(l[i]+l[j]>l[k]){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3588