akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int A, B;
    cin >> A >> B;
    int total = 0;
    REP(i, 2) {
        if (A > B) {
            total += A;
            A--;
        }
        else {
            total += B;
            B--;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
const int MAXN = 100100;
const int MOD = 1000000007;
const int INF = 2000000000;

vector<int> adj[MAXN];
int node[MAXN][2];
bool visited[MAXN];
queue<int> q;
int n;

void bfs(int k, int p)
{
	memset(visited, 0, sizeof(visited));

	int a, b;
	q.push(k);
	visited[k] = true;
	node[k][p] = 1;
	while (!q.empty())
	{
		a = q.front();
		q.pop();
		for (int i = 0; i < adj[a].size(); ++i)
		{
			b = adj[a][i];
			if (!visited[b])
			{
				q.push(b);
				visited[b] = true;
				node[b][p] = node[a][p] + 1;
			}
		}
	}
}

int main()
{
	int a, b;
	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i)
	{
		scanf("%d %d", &a, &b);
		if ((a == 1 && b == n) || (a == n && b == 1))
			continue;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	bfs(1, 0);
	bfs(n, 1);
	int cnt0, cnt1;
	cnt0 = cnt1 = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (node[i][0] == 0)
			cnt1++;
		else if (node[i][1] == 0)
			cnt0++;
		else if (node[i][0] <= node[i][1])
			cnt0++;
		else
			cnt1++;
	}

	if (cnt0 > cnt1)
		cout << "Fennec" << endl;
	else
		cout << "Snuke" << endl;

	//system("pause");
	return 0;
}
/*
7
1 2
1 3
2 4
4 5
5 6
6 7
*/

Measured memory_bytes: 6784
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  print $ n * (n - 1) `div` 2

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


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

vb calc_prime(ll Size)
{
    vb prime(Size + 1, true);
    if (Size >= 0)
        prime[0] = false;
    if (Size >= 1)
        prime[1] = false;
    for (int i = 2; i * i <= Size; i++)
        if (prime[i])
            for (ll j = i + i; j <= Size; j += i)
                prime[j] = false;
    return prime;
}

int main(void)
{
    ll n;
    cin >> n;
    if (n == 1)
        return cout << 0 << endl, 0;

    vb prime = calc_prime(sqrt(n) + 1);
    ll ans = 0;
    ll tmp = n;
    rep(i, 2, sqrt(n) + 1)
    {
        if (prime[i])
        {
            ll cnt = 0;
            while (1)
            {
                if (tmp % i == 0)
                    cnt++, tmp /= i;
                else
                    break;
            }
            ans += (-1 + sqrt(1 + 8 * cnt)) / 2;
        }
    }
    if (ans == 0 || tmp > sqrt(n))
        ans += 1;
    cout << ans << endl;
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;
	vector<ll> c(n); // Cumulative sum

	cin >> c[0];
	ll sum = c[0];
	repd(i, 1, n) {
		ll w;
		cin >> w;
		c[i] = c[i-1] + w;
		sum += w;
	}

	rep(i, n) {
		cerr << "c[" << i << "] = " << c[i] << endl;
	}

	ll ret = 0x7FFFFFFFFFFFFFFF;
	rep(i, n-1) {
		ll tmp = absi(sum - c[i] * 2);
		debug(tmp);
		if(tmp < ret) {
			ret = tmp;
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC098.D2
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var k = sc.Nextint();
            Console.WriteLine(n % k == 0 ? 0 : 1);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
 int i, c;
 printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

 if(T[u].p == NIL) printf("root, ");
 else if(T[u].l == NIL) printf("leaf, ");
 else printf("internal node, ");

 printf("[");
 for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
   if(i) printf(", ");
   printf("%d", c);
 }
 printf("]\n");

}

void calcDepth(int u, int p){
 D[u] = p;
 if(T[u].r != NIL) calcDepth(T[u].r,p);
 if(T[u].l != NIL) calcDepth(T[u].l,p+1);
}

int main(){
 int i, j, k;
 int n;
 int id, sib, child;
 int root = NIL;
 scanf("%d", &n);
 for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

 for(i=0; i<n; i++){
   scanf("%d %d", &id, &k);
   for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
     scanf("%d", &child);
     T[child].p = id;
     if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
     else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
     sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
   }
 }

 //根を求める (find the root)
 for(i=0; i<n; i++){
   if(T[i].p == -1) root = i;
 }

 //それぞれのノードの深さを求める (find depth of each node)
 calcDepth(root, 0);

 //出力 (output)
 for(i=0; i<n; i++) print(i);

 return 0;
}



Measured memory_bytes: 6384
n = int(input())

m = 10**9 + 7

A = [[[[0 for i in range(4)] for j in range(4)] for k in range(4)] for l in range(n+1)]

# A,C,G,T の順


for i in range(4):
    for j in range(4):
        for k in range(4):
            A[3][i][j][k] = 1

A[3][0][2][1] = 0
A[3][0][1][2] = 0
A[3][2][0][1] = 0

for i in range(4, n+1):
    

    for j in range(4):
        for k in range(4):
            for p in range(4):
                for q in range(4):
                    A[i][j][k][p] += A[i-1][q][j][k]
                    A[i][j][k][p] %= m


    for j in range(4) :
        hiku0 = A[i-1][0][j][2]
        A[i][j][2][1] -= hiku0
        hiku1 = A[i-1][0][2][j]
        A[i][2][j][1] -= hiku1

    A[i][2][2][1] += A[i-1][0][2][2]
    
    A[i][0][2][1] = 0
    A[i][0][1][2] = 0
    A[i][2][0][1] = 0
        

ans = 0
for j in range(4):
    for k in range(4):
        ans += sum(A[n][j][k]) % m
print(ans % m)

#print(A)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

struct Edge
{
  i64 to, cost;
};

int main()
{
  i64 n, m;
  cin >> n >> m;
  vector<Edge> edge[n];
  for (i64 i = 0; i < m; i++)
  {
    i64 a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a].push_back({b, c});
    edge[b].push_back({a, c});
  }
  set<pair<i64, i64>> ans;
  for (i64 i = 0; i < n; i++)
  {
    vector<i64> cost(n, 1e18), me[n];
    priority_queue<pair<i64, i64>, vector<pair<i64, i64>>, greater<pair<i64, i64>>> que;
    cost[i] = 0;
    que.push({0, i});
    while (que.size())
    {
      pair<i64, i64> p = que.top();
      que.pop();
      for (Edge j : edge[p.second])
        if (cost[p.second] + j.cost < cost[j.to])
        {
          cost[j.to] = cost[p.second] + j.cost;
          que.push({cost[j.to], j.to});

          me[j.to].clear();
          me[j.to].push_back(p.second);
        }
        else if (cost[p.second] + j.cost == cost[j.to])
          me[j.to].push_back(p.second);
    }

    for (i64 i = 0; i < n; i++)
      for (i64 j : me[i])
        ans.insert({min(i, j), max(i, j)});
  }
  cout << m - ans.size() << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int rem=x%1000;
        
        if(rem==0)
        System.out.println("0");
        else
        {
            rem=1000-rem;
        
        System.out.println(rem);
     }}
}

Measured memory_bytes: 35776
# import sys
# sys.setrecursionlimit
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))

N, K = geta(int)
A = [1] + geta(int)

d = dict()

cur, pos = 0, 0

while cur not in d:
    if pos == K + 1:
        print(cur)
        exit()

    d[cur] = pos
    cur = A[cur]
    pos += 1

l = d[cur] + (K - d[cur] + 1) % (pos - d[cur])

for k in d:
    if d[k] == l:
        print(k)


Measured memory_bytes: 107508
import sys

MAX = 1000000
Q = [0] * MAX
head = 0
tail = 0

def isEmpty():
    return head == tail

def isFull():
    return head == (tail + 1) % MAX

def enqueue(x):
    global tail
    if isFull():
        print("オーバーフロー")
        sys.exit()
    Q[tail] = x
    if tail + 1 == MAX:
        tail = 0
    else:
        tail += 1

def dequeue():
    global head
    if isEmpty():
        print("アンダーフロー")
        sys.exit()
    x = Q[head]
    if head + 1 == MAX:
        head = 0
    else:
        head += 1
    return x

k = int(input())

for i in range(1,10):
    enqueue(i)

for i in range(k):
    x = dequeue()
    b = x % 10
    if b != 0:
        enqueue(10 * x + b - 1)
    enqueue(10 * x + b)
    if b != 9:
        enqueue(10 * x + b + 1)
print(x)

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

int main(){
    int x, y;
    while(1){
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x<y){
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 200005
ll fact[MAX_P];
ll extgcd(ll a,ll b,ll& x,ll& y){
  ll d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
ll mod_inverse(ll a,ll m){
  ll x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

ll euler_phi(ll n){
  ll res=n;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0){
      res=res/i*(i-1);
      for(;n%i==0;n/=i);
    }
  }
  if(n!=1) res=res/n*(n-1);
  return res;
}

ll euler[MAX_N];

void euler_phi2(){
  for(ll i=0;i<MAX_N;i++) euler[i]=i;
  for(ll i=2;i<MAX_N;i++){
    if(euler[i]==i){
      for(int j=i;j<MAX_N;j+=i) euler[j]=euler[j]/i*(i-1);
    }
  }
}

ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  ll res=mod_fact(n/p,p,e);
  e+=n/p;
  if(n/p%2!=0)return res*(p-fact[n%p]) %p;
  return res*fact[n%p]%p;
} 
ll mod_comb(ll n,ll k,ll p){
  if(n==k||k==0) return 1;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%p,p)%p;
}

int main(){
  ll n;cin>>n;
  cout << euler_phi(n) << endl;
  return 0;
}

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

int a, b, h, w;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b >> h >> w;
	if (a%h == 0 && b%w == 0) {
		cout << "No\n"; return 0;
	}

	cout << "Yes\n";
	int k = 600;

	if (a%h != 0) {
		for (int j = 0; j < a; ++j) {
			for (int i = 0; i < b; ++i) {
				if (j%h == h-1)
					cout << -k*(h-1)-1 << ' ';
				else
					cout << k << ' ';
			}
			cout << "\n";
		}
	} else {
		for (int j = 0; j < a; ++j) {
			for (int i = 0; i < b; ++i) {
				if (i%w == w-1)
					cout << -k*(w-1)-1 << ' ';
				else
					cout << k << ' ';
			}
			cout << "\n";
		}
	}
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = (1 << 31) - 1;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
vl A;
struct segtree{
	int N;
	vl dat;
	void init(int n) {
		N = 1;
		while (N < n) N *= 2;
		dat = vl(N*2);
		for (int i = 0; i < 2 * N - 1; i++)
			dat[i] = INF;
	}
	// update k th element
	void update(int k, int a) {
		k += N - 1; // leaf
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	// min [a, b)
	int query(int a, int b) { return query(a, b, 0, 0, N); }
	int query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return INF;
		if (a <= l and r <= b) return dat[k];
		int m = (l + r) / 2;
		return min(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
	}
};

void input() {
	cin >> n >> q;
}


void solve() {
	segtree SEG;
	SEG.init(n);
	while (q--) {
		cin >> a >> b >> c;
		if (a == 0)SEG.update(b, c);
		else cout << SEG.query(b, c + 1) << endl;
	}
}

int main() {
	input();
	solve();
}


Measured memory_bytes: 7088
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;


my @a;
while (<>) {
    chomp;
    push @a, $_;
}
my $X = shift @a;
if ($X == 3 || $X == 5 || $X == 7) {
    say "YES";
} else {
    say "NO";
}


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

int main(){
  int a, b, n;
  cin >> a >> b;
  n = (a + b) % 2;
  if (n == 0){
    cout << (a + b) / 2 << endl;
  }
  else {
    cout << (a + b) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
s = input()
n = int(input())
for i in range(n):
    line = input().split()
    a = int(line[1])
    b = int(line[2])

    if line[0] == 'replace':
        to = line[3]
        s = s[0:a] + to + s[b + 1:]
    elif line[0] == 'reverse':
        s = s[0:a] + ''.join(reversed([c for c in s[a:b+1]])) + s[b + 1:]
    else:
        print(s[a:b + 1])



Measured memory_bytes: 5624
#include <iostream>
using namespace std;
#define MAX 1000100
 
int prime[MAX-4];
 
void is_prime(){
    for(int i = 0 ; i < MAX ; i++) prime[i] = 0;
    prime[0] = prime[1] = 1;
    for(int i = 4 ; i < MAX ; i += 2) prime[i] = 1;
     
    for(int i = 3 ; i*i < MAX ; i++){
        if(prime[i]) continue;
        for(int j = i*2 ; j < MAX ; j+= i)
            prime[j] = 1;
    }
}
 
    int main(){
        int n;
         
        is_prime();
         
        while(true){
            cin >> n;
            if(!n) break;
             
            int cnt = 0;
            for(int i = 2 ; i <= n/2 ; i++){
                if(!prime[i]&&!prime[n-i]) cnt++;
            }
            cout << cnt << endl;
        }
         
        return 0;
    }

Measured memory_bytes: 5064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int t, a, b;
  cin >> t >> a >> b;
  int planA = t * a;
  int planB = b;
  if (planA == planB || planA < planB) {
    cout << planA;
  } else {
    cout << planB; 
  }
}

Measured memory_bytes: 3564
#include<stdio.h>

char judge(int,int,int);

int main(){
	int i,j,m,f,r;
	char grade[50];
	
	i = 0;
	do{
		scanf("%d %d %d",&m,&f,&r);
		
		grade[i] = judge(m,f,r);
		i++;
	}while(m!=-1 || f != -1 || r != -1);
	
	for(j=0;j<i-1;j++){
		printf("%c\n",grade[j]);
	}
	
	return 0;
}

char judge(int m,int f,int r){
	int i,j,k,total;
	char grade;
	
	total = m + f;
	
	if(m==-1 || f==-1){
		return 'F';
	}else if(total >= 80){
		return 'A';
	}else if(total >= 65){
		return 'B';
	}else if(total >= 50){
		return 'C';
	}else if(total >= 30){
		if(r >= 50){
			return 'C';
		}else{
			return 'D';
		}
	}else{
		return 'F';
	}
}


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var r = ReadIntArray().Sum();
            Console.WriteLine(r < 10 ? r.ToString() :"error");

        }
        public static readonly Func<string> Read = () => Console.ReadLine();
        public static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        public static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
}

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

import sys

input = sys.stdin.readline

def main():
    n, m = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]
    A.sort()

    M = []
    max_c = 0
    for l in sys.stdin:
        b, c = [int(e) for e in l.strip().split()]
        max_c = max(max_c, c)
        M.append([b, c])
    last_idx = len(A)
    for i in range(len(A)):
        if max_c < A[i]:
            last_idx = i + 1
            break

    M.sort(key=lambda x: x[1], reverse=True)


    idx = 0
    for m in M:
        b, c = m[0], m[1]
        b_cnt = 0
        for i in range(idx, last_idx):
            if A[i] > c:
                break
            if A[i] < c:
                A[i] = c
                b_cnt += 1
                idx += 1
            if b_cnt == b:
                break

    print(sum(A))

main()


Measured memory_bytes: 26416
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define MIN(a,b) ((a>b)?(b):(a))
using namespace std;
int m=9999999;
int a[20];
	int n;
int solve(int i,int x,int y){
	if(i==n){
		m=MIN(abs(x-y),m);
		return 0;
	}
	solve(i+1,x,y+a[i]);
	solve(i+1,x+a[i],y);
	return 0;
}

int main(void){
	while(cin>>n,n){
		m=9999999;
		for(int i=0;i<n;i++)cin>>a[i];
		solve(0,0,0);
		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    vec<tuple<string, int, int> > mp(N);
    REP(i, N){
        string S; int P;
        cin >> S >> P;
        mp[i] = make_tuple(S, 100-P, i+1);
    }
    sort(ALL(mp));
    REP(i, N){
        cout << get<2>(mp[i]) << el;
    }
}



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

using namespace std;
using pint = pair<int, int>;

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

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

    map<pint, int> mp;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j == i) continue;
            int p = x[i] - x[j], q = y[i] - y[j];
            mp[pint(p, q)]++;
            cnt = max(cnt, mp[pint(p, q)]);
        }
    }
    cout << n - cnt << endl;
    return 0;
}


Measured memory_bytes: 384
class Node
  attr_accessor :key, :parent, :left, :right

  def initialize(key)
    @key = key
    @parent = -1
    @left = nil
    @right = nil
  end

  def add_left(left)
    @left = left
    @left.parent = self
  end

  def add_right(right)
    @right = right
    @right.parent = self
  end

  def del_left; @left = nil; end

  def del_right; @right = nil; end

end


class BinaryTree
  attr_accessor :root

  def initialize()
    @root = nil
  end

  def insert(key)
    # 初回登録
    unless @root
      @root = Node.new(key)
      return
    end

    # 2回目以降
    #   xが挿入先にあたる. ので, nilになるまで探す.
    #   xの親がyで, yにadd_xxxxを実行する.
    x, y = @root, nil
    while x
      y = x
      if key < x.key
        x = x.left
      else
        x = x.right
      end
    end
    if key < y.key
      y.add_left(Node.new(key))
    else
      y.add_right(Node.new(key))
    end
  end

  def find(key)
    # keyがあった場合, 該当Nodeを返却
    # keyがなかった場合, nilを返却
    x = @root
    while x
      return x if x.key == key
      if key < x.key
        x = x.left
      else
        x = x.right
      end
    end
    nil
  end

  def delete(key)
    x = find(key)
    return unless x

    case
    when x.left && x.right # 子2
      self.in # 中間順探索で@listを更新
      nxt_i   = @list.index(x.key) + 1 # 削除する節の次の節のkeyを得るためのindex番号を取得
      nxt_key = find(@list[nxt_i]).key # 次の節のkeyを得る
      delete(nxt_key)
      x.key = nxt_key
    when x.left  # 子1
      replace(x, x.left)
    when x.right # 子1
      replace(x, x.right)
    else # 子0
      if x.parent.left == x
        x.parent.del_left
      else
        x.parent.del_right
      end
    end
  end

  def replace(from, to)
    if from.parent.left == from
      from.parent.add_left(to)
    else
      from.parent.add_right(to)
    end
  end

  def pre
    # 行きがけ順探索(左上から順に)
    @list = []
    traverse(@root, :pre)
    @list
  end

  def in
    # 通りがけ順探索
    @list = []
    traverse(@root, :in)
    @list
  end

  def post
    # 帰りがけ順探索(左下から順に)
    @list = []
    traverse(@root, :post)
    @list
  end

  private
  def traverse(node, type)
    @list << node.key if type == :pre
    traverse(node.left, type) if node.left
    @list << node.key if type == :in
    traverse(node.right, type) if node.right
    @list << node.key if type == :post
  end
end


n = gets.to_i
cmds = []
n.times do
  stdin = gets.chomp
  if stdin.match(/print/)
    cmds << [stdin, nil]
  else
    cmd, key = stdin.split
    cmds << [cmd, key.to_i]
  end
end

tree = BinaryTree.new
cmds.each do | cmd, key |
  if cmd.match(/insert/)
    tree.insert(key)
  elsif cmd.match(/find/)
    puts tree.find(key) ? 'yes' : 'no'
  elsif cmd.match(/delete/)
    tree.delete(key)
  else
    puts " #{tree.in.join(' ')}"
    puts " #{tree.pre.join(' ')}"
  end
end


Measured memory_bytes: 186384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

bool solve()
{
    string str;
    cin >> str;

    unordered_map<char, int> um;

    for (char c: str)
    {
        um[c]++;
        if (um[c] > 2) return false;
    }

    return um.size() == 2;
}

int main()
{
    std::cout << (solve() ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())[:n]

res = 0

for i in range(k):
    dp = [0,0,0]
    idx = i
    while idx < n:
        dp[0],dp[1],dp[2] = max(dp[1],dp[2]),max(dp[0],dp[2]),max(dp[0],dp[1])
        if t[idx] == 's':
            dp[0] += r
        elif t[idx] == 'p':
            dp[1] += s
        else:
            dp[2] += p
        idx += k
    res += max(dp)
print(res)

Measured memory_bytes: 55424
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    vector<vector<int>> g(k + 1, vector<int>(k + 1));
    rep (i, 1, k + 1) {
        rep (j, 1, k + 1) {
            g[i][j] = gcd(i, j);
        }
    }
    ll ans = 0;
    rep (i, 1, k + 1) {
        rep (j, 1, k + 1) {
            rep (l, 1, k + 1) {
                ans += g[i][g[j][l]];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define INF 100000000
int main(){
    ll P,Q,R;
    cin>>P>>Q>>R;
    ll x=max(max(P,Q),R);
    cout<<(P+Q+R)-x<<endl;
}

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

Measured memory_bytes: 596
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;
int a[30];
int q;
map<int,bool>ta;

void ok(){

  rep(i,1<<n){
    int sum=0;
    rep(j,n)if(i&(1<<j))sum+=a[j];
    ta[sum]=true;
  }
}

int main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  cin>>q;
  ok();
  
  rep(i,q){
      int x;
      cin>>x;
      if(ta[x])
        cout<<"yes"<<endl;
      else
        cout<<"no"<<endl;
  }
  return 0;
}



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

int main(){
  int N,M,C; cin >> N >> M >> C;
  int r = 0;
  int b[M]; for(int i=0;i<M;i++){cin >> b[i];}
  int a;
  for(int i=0;i<N;i++){
    int temp = C;
    for(int j=0;j<M;j++){
      cin >> a;
      temp += a*b[j];
    }
    if(temp>0) r++;
  }
  cout << r << endl;
}

Measured memory_bytes: 256
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        k = bisect.bisect_left(L,(a+b))-1
        ans += k-j
print(ans)

Measured memory_bytes: 43756
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

int n, m, ans, x, a[N], cnt[N], s[N];
int main()
{
	int i, j, t1, t2;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
		s[a[i]]++;
//		cnt[a[i]]++;
	}
	for (i = n; i >= 1; i--) {
		for (j = i; j > i - s[i]; j--) cnt[j]++;
	}
	for (i = 1; i<= n; i++) if (cnt[i] > 0) ans++;
	while (m--) {
		scanf("%d %d", &t1, &t2);
		x = a[t1];
		if (x == t2) {
			printf("%d\n", n - ans);
			continue;
		}
		if (x - s[x] + 1 >= 1) {
			cnt[x - s[x] + 1]--;
			if (cnt[x - s[x] + 1] == 0) ans--;
		}
		if (t2 - s[t2] >= 1) {
			cnt[t2 - s[t2]]++;
			if (cnt[t2 - s[t2]] == 1) ans++;
		}
		s[x]--;
		s[t2]++;
		a[t1] = t2;
		printf("%d\n", n - ans);
	}
    return 0;
}


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

int main() {
	int a=0,m,n,l,cnt=1,b=0;
	while(1){
		cin>>l;
		if(l==0){
			break;
		}
		while(b<12){
			cin>>m>>n;
			a=m-n+a;
			if(a<l){
			   cnt++;
			}   
			b++;
		}
		if(cnt>0 && cnt<13){
			cout<<cnt<<endl;
		}
		else{cout<<"NA"<<endl;}
		cnt=1;
		a=0;
		b=0;
		
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
#include <bitset>
#include <algorithm>
#define int long long
using namespace std;
#define mod 1000000007
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
bool vis[30000005], vis1[3000005];
vector<int> vec[3000005];
// v1, vec1[3000005];
//int child[2000005];
//int divi[2000005];

// int dis[100005] = {0};
// int h[100005];
// int p[100005];
// int dp[100005][100];
// bool f = 0;
// int bad[100005], good[100005];
// int p5[100005];
int final_sum[200005], max_sum[10005];
//int level[200005];
//int time1 = 0;
void dfs(int node)
{
    vis[node] = 1;
    //level[node] = time1;
    //time1++;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            //  if (bit[vec[node][i]]            {

            dfs(vec[node][i]);
            final_sum[node] += final_sum[vec[node][i]];
        }
    } //  if ()
      //   if (b == 0)
      //  count1[b][node] += count1[b][vec[node][i]];
      //}
      // time1--;
}

int32_t main()
{

    int n;
    cin >> n;
    int arr[n];
    int sum = 0;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    for (int i = 1; i < n; i++)
    {
        if (arr[i - 1] > arr[i])
        {
            sum += (arr[i - 1] - arr[i]);
            arr[i] = arr[i - 1];
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 75496
#include<bits/stdc++.h>
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	if(n==1){
		puts("Hello World");
	} 
	else{
		long long a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}


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

using namespace std;

string s;

int main () {
	cin >> s;
	if (s == "SUN") 
		cout << 7;
	else if (s == "MON")
		cout << 6;
	else if (s == "TUE")
		cout << 5;
	else if (s == "WED")
		cout << 4;
	else if (s == "THU")
		cout << 3;
	else if (s == "FRI")
		cout << 2;
	else
		cout << 1;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int H,M,S,h,m,s;
    for(int i=0;i<=2;i++){
        int cnt=0;
        scanf("%d%d%d",&H,&M,&S);
        scanf("%d%d%d",&h,&m,&s);
        for(;;){
            S++;
            if(S==60){M++;S=0;}
            if(M==60){H++;M=0;}
            cnt++;
            if(S==s&&H==h&&M==m)break;
        }
        cout<<cnt/3600<<" "<<(cnt%3600)/60<<" "<<(cnt%3600)%60<<endl;
    }
    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,k;
  cin>>n>>k;
  vector<ll> a;
  a.push_back(0);
  for(i=0;i<n;i++){
    cin>>buf;
    if(buf<k){
      a.push_back(buf);
      res+=buf;
    }
  }
  sort(ALL(a));
  l=0;r=a.size()-1;
  while(abs(l-r)>1){
    buf=(l+r)/2;
    //cout<<l spa r spa buf<<endl;
    vector<bool> dp(k,false);
    dp[0]=true;
    for(i=0;i<a.size();i++){
      if(buf!=i){
        for(j=k-1;j>=0;j--){
          if(dp[j]&&j+a[i]<k)dp[j+a[i]]=true;
        }
      }
    }
    judge=false;
    for(i=k-1;i>=0;i--){
      if(dp[i]&&i+a[buf]>=k){
        judge=true;
        break;
      }
    }
    if(judge)r=buf;
    else l=buf;
    //cout<<l spa r spa buf<<endl;
  }
  if(res<k)l=r;
  cout<<l<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000
typedef long long ll;
int main(){
    ll sum=0;
    string s;cin>>s;
    bool b[s.size()];
    memset(b,0,s.size()*sizeof(bool));
    while(!b[0]){
        int j=s.size()-1;
        while(b[j])b[j--]=0;
        b[j]=1;
        ll tmp=0;
        for(int i=0;i<s.size();++i){
            tmp=tmp*10+s[i]-'0';
            if(b[i+1]){/*cout<<tmp<<endl;*/sum+=tmp;tmp=0;}
        }
        sum+=tmp;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

/**
 * B - Sum of Three Integers<br>
 * https://qiita.com/drken/items/e77685614f3c6bf86f44
 */
public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int K = in.nextInt();
		int S = in.nextInt();

		int answer = 0;

		if (S > K*3) {
			System.out.println(0);
			return;
		}

		// Z を一定の値に固定した場合で考慮
		for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23764
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

p = list(map(int, input().split()))
p.sort()
y = 0
count = 0
for i in range(0, n):
    if p[i] == x:
        y = i
    else:
        count += 1

if count == n:
    print(x)
    exit()

min = p[y] - 1
max = p[y] + 1
for i in reversed(range(0, y)):
    if p[i] != min:
        break
    else:
        min -= 1

for i in range(y+1, n):
    if p[i] != max:
        break
    else:
        max += 1

if p[y] - min < max - p[y]:
    print(min)
elif p[y] - min > max - p[y]:
    print(max)
elif p[y] - min == max - p[y]:
    print(min)

Measured memory_bytes: 9188
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

const int N = 1e5 + 1e3;
const int mod = 1e9 + 7;
int fact[N];

int mpow(int a, int b) {
  if (b == 0) return 1;
  int nesf = mpow(a, b / 2);
  if (b % 2 == 0) {
    return nesf * nesf % mod;
  }
  return a * nesf % mod * nesf % mod;
}

int mod_inv(int a) {
  return mpow(a, mod - 2);
}

int ent(int n, int k) {
  return fact[n] * mod_inv(fact[n - k]) % mod * mod_inv(fact[k]) % mod;
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
  }
  int ans = 1;
  for (int i = 2 ;i * i <= m; i++) {
    if (m % i == 0) {
      int cnt = 0;
      while (m % i == 0) {
        cnt++;
        m /= i;
      }
      ans = ans * ent(n + cnt - 1, cnt) % mod;
    }
  }
  if (m > 1) {
    ans = ans * n % mod;
  }
  cout << ans << "\n";
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   ll a,b,c,k,cnt=0;
   cin>>a>>b>>c>>k;
   if(k<=(a+b)){

   cout<<min(a,k)<<endl;

   }
   else{
    cout<<2*a-k+b<<endl;
   }
   return 0;
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
class Program
{
    //static int[] dp;
    //static decimal[,,] dp;
    //static decimal N;
    static void Main(string[] args)
    {
        // 入力
        //int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        string S = Console.ReadLine();

        if (S == "Sunny")
        {
            Console.WriteLine("Cloudy");
        }
        else if (S == "Cloudy")
        {
            Console.WriteLine("Rainy");
        }
        else if (S == "Rainy")
        {
            Console.WriteLine("Sunny");
        }
    }


}


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

int main() {
    int N; cin >> N;
    set<int> s;
    rep(i, N){
        int a; cin >> a;
        s.insert(a);
    }

    int ss = s.size();
    int x = N - ss;
    if(x%2 == 1)ss--;

    cout << ss << endl;

    return 0;
}

Measured memory_bytes: 8104
import java.util.*;
import java.math.*;

class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String a = N.substring(2,3);
        String b = N.substring(3,4);
        String c = N.substring(4,5);
        String d = N.substring(5);
        if(a.equals(b) && c.equals(d)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
	}

}

Measured memory_bytes: 23124
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto H = RD;
	auto W = RD;
	auto A = new string[](H);
	foreach (i; 0..H)
	{
		A[i] = RD!string;
	}

	bool check(long y, long x)
	{
		long cnt_p, cnt_n;
		if (y == 0 && x == 0) cnt_p = 1;
		if (y == H-1 && x == W-1) cnt_n = 1;

		
		if (y != 0)
		{
			if (A[y-1][x] == '#') ++cnt_p;
		}
		if (x != 0)
		{
			if (A[y][x-1] == '#') ++cnt_p;
		}
		if (y != H-1)
		{
			if (A[y+1][x] == '#') ++cnt_n;
		}
		if (x != W-1)
		{
			if (A[y][x+1] == '#') ++cnt_n;
		}
		
		return cnt_p == 1 && cnt_n == 1;
	}

	bool ans = true;
	foreach (y; 0..H)
	{
		foreach (x; 0..W)
		{
			if (A[y][x] == '#')
			{
				auto r = check(y, x);
				if (!r)
					ans = false;
			}
		}
	}
	
	writeln(ans ? "Possible" : "Impossible");
	stdout.flush();
	debug readln();
}


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

using namespace std;
int main(){
	int n;

	cin >> n;

	vector<int> a(n);
	bool b[n];
	for (int i = 0; i < n; i++){
		
		cin >> a[i];
		if (a[i] ==i+1){
			b[i] = true;
		}
		else {
			b[i] = false;
		}

	}
    
	int cnt = 0;
	bool fo = false;
	for (int i = 0; i < n; i++){
		if (b[i] == true){
			if (fo == true){
				cnt++;
				fo = false;
                b[i]=false;
              
              
			}
			else{
				fo = true;
			}

		}
		else{
			if (fo == true){
				cnt++;
				fo = false;
              b[i]=false;
              
			}
		}
	}
 
  if(a[n-1]==n && b[n-1]==true){
    cnt++;
  }
 
	
	cout << cnt;
	

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint f(int n){ 
  if(n == 0)return 1;
  mint x = f(n / 2); 
  x *= x; 
  if(n % 2 == 1)x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i = 0; i < a; ++i){
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

mint fact[200200];
mint inv_fact[200200];
void init(){
	fact[0] = 1;
	for(int i = 1; i < 200200; ++i){
		fact[i] = fact[i - 1] * i;
	}

	inv_fact[200200 - 1] = fact[200200 - 1].inv();
	for(int i = 200200 - 1; i >= 1; --i){
		inv_fact[i - 1] = inv_fact[i] * i;
	}
}

mint comb(ll n, ll k){
	if(n < k)return 0;
	else return fact[n] * inv_fact[n - k] * inv_fact[k];
}

ll a[100100];

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

  sort(a, a + n);
  mint ans = 0;
  for(int i = 0; i < n; ++i){
    ans += (mint)a[i] * comb(i, k - 1);
  }
  sort(a, a + n, greater<int>());
  for(int i = 0; i < n; ++i){
    ans -= (mint)a[i] * comb(i, k - 1);
  }
  
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 7524