akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

# 入力
N, X = map(int, input().split())
m = [int(input()) for i in range(N)]

cnt = 0

# 最初に全種類生産
for i in m:
    X -= i
    cnt += 1

# 最も安く作れるものを量産
m.sort()
cnt += int(X / m[0])

# 出力
print(cnt)

Measured memory_bytes: 38384
#include <stdio.h>

int main(){
	int n,r,b,i;
	char *str;
	scanf("%d", &n);
	str = (char *)malloc(n+1);
	scanf("%s", str);
	r=0;
	b=0;
	for(i=0;i<n;i++){
		if(str[i] == 'R') r++;
		else b++;
	}
	if(r>b){
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b,c,d,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    rrep(i,1,n-1){
        ll tmp[5]={};
        tmp[0]=a[i-1];
        tmp[1]=a[i];
        tmp[2]=a[i+1];
        sort(tmp,tmp+3);
        if(tmp[1]==a[i])ans++;
    }
    Cout(ans);
    return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N;
    cin >> N;
    vll s(N);
    rep(i, N) cin >> s[i];

    ll ans = 0;
    REP(i, 1, N/2){
        unordered_set<ll> checked;
        ll t = 0;
        for(ll j=i; j+i<N-1; j+=i){
            if(j==N-1-j || j>N-1-i || N-1-j<i) break;
            if(checked.count(j)>0 || checked.count(N-1-j)>0) break;
            t += s[j] + s[N-1-j];
            ans = max(ans, t);
            checked.insert(j);
            checked.insert(N-1-j);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8136
l = [int(input()) for i in range(5)]
l_0 = [a%10 for a in l]
ar = []
for n in l_0:
  if n != 0:
    ar.append(10-n)
  else:
    ar.append(0)
s = ar.index(max(ar))
ar.pop(s)
ans = sum(l) + sum(ar)
print(ans)

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





int main() {
    int D;
    cin >> D;
    vector<int>c(26);
    rep(i,26) cin >> c[i];
    vector<vector<ll>>s(D,vector<ll>(26));
    rep(i,D) {
        rep(j,26) cin >> s[i][j];
    }
    vector<ll>t(D);
    rep(i,D) {
        int a;
        cin >> a;
        t[i] = a;
    }
    vector<ll>last(26);
    ll score = 0;
    rep(i,D) {
        score += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j,26) {
            score -= c[j]*((i+1)- last[j]);
        }
        cout << score << endl;
    }
}

Measured memory_bytes: 3684
# coding: utf-8
# Your code here!

def solve(N, M):
    login = [0] * (M+1)
    student = [[] for i in range(M+1)]
    r = int(input())
    for i in range(r):
        t, n, m, s = map(int, input().split())
        if s == 1:
            if login[m] == 0:
                student[m].append(t)
            login[m] += 1
        else:
            login[m] -= 1
            if login[m] == 0:
                student[m].append(t)
    q = int(input())
    for i in range(q):
        s, e, m = map(int, input().split())
        ans = 0
        for j in range(0, len(student[m]), 2):
            s2 = student[m][j]
            e2 = student[m][j+1]
            l = max(s, s2)
            r = min(e, e2)
            if r - l > 0:
                ans += r - l
        print(ans)
            
while 1:
    N, M = map(int, input().split())
    if N == 0 and M == 0:
        break
    solve(N, M)


Measured memory_bytes: 6292
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n = I()
    a = LI()
    a.sort()
    gr = itertools.groupby(a)
    lst = []
    for key, group in gr:
        lenth = len(list(group))
        if lenth >= 4:
            lst.append(key)
        if lenth >= 2:
            lst.append(key)

    ans = 0
    if len(lst) >= 2:
        ans = lst[-1] * lst[-2]
    print(ans)
main()

Measured memory_bytes: 21728
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//
int L[310], R[310], X[310];
ll dp[310][310][310];
ll MOD = 1000000007;
vector<int> res[310];

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

	rep(i, M)cin >> L[i] >> R[i] >> X[i];
	rep(i, M)res[R[i]].push_back(i);
	
	memset(dp, 0, sizeof(dp));
	dp[0][0][0] = 1;
	rep(r, N)rep(g, N)rep(b, N) {
		int next = max({r, g, b}) + 1;
		
		{
			bool ok = 1;
			int mx = max(g, b);
			int mn = min(g, b);
			for (auto vi : res[next]) {
				int ct = 1;
				if (mx >= L[vi])ct++;
				if (mn >= L[vi])ct++;
				ok = ok && ct == X[vi];
			}
			if (ok) {
				dp[next][g][b] += dp[r][g][b];
				dp[next][g][b] %= MOD;
			}
		}
		{
			bool ok = true;
			int mx = max(r, b);
			int mn = min(r, b);
			for (auto vi : res[next]) {
				int ct = 1;
				if (mx >= L[vi])ct++;
				if (mn >= L[vi])ct++;
				ok = ok && ct == X[vi];
			}
			if (ok) {
				dp[r][next][b] += dp[r][g][b];
				dp[r][next][b] %= MOD;
			}
		}
		{
			bool ok = true;
			int mx = max(r, g);
			int mn = min(r, g);
			for (auto vi : res[next]) {
				int ct = 1;
				if (mx >= L[vi])ct++;
				if (mn >= L[vi])ct++;
				ok = ok && ct == X[vi];
			}
			if (ok) {
				dp[r][g][next] += dp[r][g][b];
				dp[r][g][next] %= MOD;
			}
		}
	}

	ll ans = 0;
	rep(i, N)rep(j, N) {
		ans = (dp[N][i][j] + ans) % MOD;
		ans = (dp[i][N][j] + ans) % MOD;
		ans = (dp[i][j][N] + ans) % MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 232960
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    int res = 0;
    int a[200][200];
    memset(a, 0,sizeof(a));
    
    int M, N;
    cin >> M >> N;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> a[i][j];
            
            if (i == 0) {
                if (j != 0 && j != N-1) {
                    a[i][j] = 1 - a[i][j];
                }
            }
            else if (i != 0) {
                if (j == 0 || j == N-1) {
                    a[i][j] = 1 - a[i][j];
                }
            }
        }
    }
    
    for (int i = 0; i < M; ++i) {
        int temp = 0;
        bool zeroexist = false;
        for (int j = 0; j < N; ++j) {
            //cout << a[i][j];
            
            if (a[i][j] == 1) ++temp;
            else zeroexist = true;
        }
        //cout << endl;
        
        if (N != 1) {
            if (zeroexist) ++temp;
            else --temp;
        }
        
        res += temp;
    }
    
    cout << res << endl;
    
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

int n,m,p;
int board[11][11][11];
int x[555],y[555];
int h[11][11];

/// black 1 white 2

bool check(int p){
	rep(i,n)rep(j,n)rep(k,h[i][j]){
		repl(dx,-1,2)repl(dy,-1,2)repl(dz,-1,2){
			if(dx==0&&dy==0&&dz==0)continue;
			int nx=i,ny=j,nz=k;
			int cnt=0;
			while(nx>=0&&nx<n&&ny>=0&&ny<n&&nz>=0&&ny<n&&board[nx][ny][nz]==p){
				nx+=dx,ny+=dy,nz+=dz;
				cnt++;
			}
			if(cnt==m)return true;
		}
	}
	return false;
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>m>>p;
		if(n==0)break;
		rep(i,p){
			cin>>x[i]>>y[i];
			x[i]--; y[i]--;
		}
		bool draw=true;
		memset(board,0,sizeof(board));
		memset(h,0,sizeof(h));
		rep(i,p){
			board[x[i]][y[i]][h[x[i]][y[i]]++]=i%2+1;
			if(check(i%2+1)){
				if(i%2+1==1)cout<<"Black "<<i+1<<endl;
				else cout<<"White "<<i+1<<endl;
				draw=false;
				break;
			}
		}
		if(draw)cout<<"Draw"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll h[N] , dp[N] ;
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n , k ;
    cin >> n ;
  k= 2 ;
    for (int i = 1;  i <=  n ; i ++) cin >> h[i] ;
    memset(dp , 63 , sizeof(dp)) ;
    dp[1] = 0 ;
    for (ll i = 2 ; i <= n ; i ++) {
    	ll res = 1e18 ;
    	for (ll j = i - 1; j >= max(0ll , i - k) ; j --) {
    		res = min(res , dp[j] + abs(h[i] - h[j])) ;
		}
		dp[i]=  res ;
	}
	cout << dp[n] ;
    return (0) ;
}

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

// マッチの本数を教えてくれる美人なお姉さん
int num(int a){
    switch(a){
        case 1:
            return 2;
        case 2:
            return 5;
        case 3:
            return 5;
        case 4:
            return 4;
        case 5:
            return 5;
        case 6:
            return 6;
        case 7:
            return 3;
        case 8:
            return 7;
        case 9:
            return 6;
        default:
            return 0;
    }
}

int main(void){
    int n,m; cin >> n >> m;
    vector<int> a(m); rep(i,m) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    vector<int> dp(n+1,-1); // dp[i]: ちょうどi本のマッチ棒で作れる整数の最大桁数を教えてくれる美人なお姉さん
    // dpを計算してくれるお姉さん
    dp[0] = 0;
    for(int i = 1; i <= n; ++i){
        rep(j,m){
            if(i - num(a[j]) >= 0){
                dp[i] = max(dp[i], dp[i-num(a[j])] + 1);
            }
        }
    }
    // 求める整数を出力してくれるお姉さん
    while(n >= 2){
        rep(j,m) if((n - num(a[j]) >= 0) /*参照エラー防止*/ && (dp[n-num(a[j])] == dp[n]-1)){
            cout << a[j];
            n -= num(a[j]);
            break;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	long long int A, B,ans = 1;
	cin >> A >> B;
	long long int hcf = gcd(A, B);

	for (long long int i = 2; i <= hcf / i; i++)
	{
		if (hcf % i == 0)
		{
			ans++;
			while (hcf % i == 0) { hcf /= i; }
		}
	}
	if (hcf > 2) { ans++; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

void solve(long long n, std::vector<std::string> S)
{
    map<char, int> common;
    for (size_t i = 0; i < n; i++)
    {
        string str = S[i];
        for (char c = 'a'; c <= 'z'; c++)
        {
            int cnt = 0;
            for (unsigned int i = 0; i < str.size(); i++)
            {
                if (str[i] == c)
                    cnt++;
            }

            if (common.find(c) != common.end())
            {
                if (cnt < common[c])
                {
                    common[c] = cnt;
                }
            }
            else
            {
                common[c] = cnt;
            }
        }
    }

    for (auto itr = common.begin(); itr != common.end(); ++itr)
    {
        if (itr->second == 0)
        {
            continue;
        }
        else
        {
            for (int j = 0; j < itr->second; j++)
            {
                cout << itr->first;
            }
        }
    }
    cout << endl;
}

int main()
{
    long long n;
    scanf("%lld", &n);
    std::vector<std::string> S(n);
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    solve(n, std::move(S));
    return 0;
}


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

int main()
{
	//freopen("test.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	double ans=1;
	if(n==1){
		cout<<ans<<"\n";
	}
	else if(n%2==0)
	{
		cout<<ans*0.5<<"\n";
	}
	else{
		ans = (n+1)/2;
		cout<<ans/n<<"\n";
	}
}

Measured memory_bytes: 256
def main():
    from builtins import int, str, map, list, dict, float, print, len, sorted, max, min
    from itertools import accumulate, permutations, combinations
    from collections import deque, defaultdict, Counter
    from operator import itemgetter
    from bisect import bisect_left, bisect_right, bisect
    from heapq import heappop, heappush
    from fractions import gcd
    import sys, re, math, copy
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    print('YNEOS'[not N in [3,5,7]::2])


if __name__ == '__main__':
    main()


Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    string s; cin >> s;
    int ze = 0;
    int one = 0;
    for(int i=0;i<s.size();i++){    
        if(s[i] == '1') one++;
        else ze++;
    }
    cout << 2*min(one,ze) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	register int f=1,k=0;register char c=getchar();
	while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();
	return k*f;
}
inline ll readll()
{
	register ll f=1,k=0;register char c=getchar();
	while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();
	return k*f;
}
int main()
{
	int a=read(),b=read(),c=read();ll k=readll();
	cout << ((k&1)?b-a:a-b)<<endl;/*
	for (register int i=1,tmpa,tmpb,tmpc;i<=k;i++)
	{
		tmpa=a,tmpb=b,tmpc=c;
		a=tmpb+tmpc;b=tmpa+tmpc;c=tmpa+tmpb;
	}
	cout << a-b<<endl;*/
}

Measured memory_bytes: 384
w = int(input())
n = int(input())
l = [i for i in range(1,w+1)]
while n > 0:
  a,b = map(int,input().split(','))
  l[a-1],l[b-1] = l[b-1],l[a-1]
  n -= 1
for i in l:
  print(i)

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

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;

vector<int> edge[maxn];
ll ans, k;

void dfs(int u, int pre, bool ppre)
{
    ll tmp = k - 1;
    if(ppre) tmp --;
    for(auto v: edge[u])
    {
        if(v == pre) continue;
        dfs(v, u, 1);
        (ans *= tmp) %= mod;
        tmp --;
    }
}

int main()
{
    int n, u, v;
    scanf("%d%d", &n, &k);
    for(int i = 1; i < n; i ++)
    {
        scanf("%d%d", &u, &v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    ans = k;
    dfs(1, 0, 0);
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
	int a,b,x,n,m;
	static int field[5001][5001] = {};
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> a >> b >> x;
		field[a - 1][b - 1] = x + 1;
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			field[i + 1][j] = max(field[i + 1][j],field[i][j] - 1);
			field[i + 1][j + 1] = max(field[i + 1][j + 1],field[i][j] - 1);
		}
	}
	int cnt = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) {
			if(field[i][j]) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 100760
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n;
ll a[55];

void solve()
{
    cin >> n;
    for (int i = 1; i <= n;++i)
        cin >> a[i];
    ll ans = 0;
    for (int i = 1; i <= n;++i)
        for (int j = i + 1; j <= n;++j)
        {
            ans += a[i] * a[j];
        }
    cout << ans << endl;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>

#define rep(i,n) for(int i = 0; i < n; ++i)
#define reps(i,f,n) for(int i = f; i <= n; ++i)
#define eb emplace_back
#define all(x) x.begin(), x.end()

using namespace std;
using PII=pair<int,int>;
using PPI=pair<int,PII>;


int main(void){
  int n;
  deque<int> d;
  vector<int> A;
  cin >> n;
  A.resize(n);
  for(auto& a: A) cin >> a;
  rep(i,n){
    if(i%2){
      d.push_front(A[i]);
    }else{
      d.push_back(A[i]);
    }
  }

  if(n%2){
    for(int i = n-1; i >= 0; --i){
      if(i != n-1) cout << " ";
      cout << d[i];
    }
  }else{
    rep(i,n){
      if(i != 0) cout << " ";
      cout << d[i];
    }
  }
  cout << endl;
  

  return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N ;cin>>N;
    vec A(N);
    rep(i,N){
        cin>>A[i];
    }
    ll ans = 0;
    MP mp;
    mp[A[0]]++;
    FOR(j,1,N){
        ans += mp[j-A[j]];
        mp[j+A[j]]++;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 27364
size = STDIN.gets.to_i
c = STDIN.gets.split

b = c.dup
size.times do |i|
    (size-1).downto(i+1) do |j|
        if b[j][1] < b[j-1][1]
            b[j], b[j-1] = b[j-1], b[j]
        end
    end
end

puts b.join(' ')

def stable?(a1, a2)
    h1 = Hash.new{|h, k| h[k] = []}
    h2 = Hash.new{|h, k| h[k] = []}
    a1.each do |c|
        h1[c[1]] << c
    end
    a2.each do |c|
        h2[c[1]] << c
    end
    h1.keys.each do |k|
        if h1[k] != h2[k]
            return false
        end
    end
    return true
end

if stable?(c, b)
    puts "Stable"
else
    puts "Not stable"
end

s = c.dup
s.size.times do |i|
    min = i
    i.upto(s.size-1) do |j|
        if s[j][1] < s[min][1]
            min = j
        end
    end
    if min != i
        s[i], s[min] = s[min], s[i]
    end
end

puts s.join(' ')

if stable?(c, s)
    puts "Stable"
else
    puts "Not stable"
end

Measured memory_bytes: 8792
import itertools


def actual(a, b, c, d, e):
    all_permutations = list(itertools.permutations([a, b, c, d, e], 5))

    order_time_list = []

    for orders in all_permutations:
        elapsed_time = 0

        for i in range(5):
            elapsed_time += orders[i]

            if i == 4:
                # 最後の注文は時間の調整不要
                continue

            fraction = elapsed_time % 10

            if fraction != 0:
                # 10で割り切れない場合は注文できないのでそれを調整する
                # ex: 57分なら +3分(⇔10 - 57%10)
                elapsed_time += 10 - fraction

        order_time_list.append(elapsed_time)

    return min(order_time_list)

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

print(actual(a, b, c, d, e))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

ll gcd(ll a,ll b){
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b,a%b);
    }
}

ll lcm(ll x, ll y) {
    return x / gcd(x,y) * y;
}
int main(void)
{
    IOS
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    v.push_back(x);
    sort(ALL(v));

    int ans = 0;
    if (n == 1) ans = v[1] - v[0];
    else {
        int base = v[0];
        ans = gcd(v[2]-base,v[1]-base);
        FOR(i,3,n) {
            ans = gcd(ans,v[i]-base);
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
  int n, m;

  fscanf(stdin, "%d %d", &n, &m);

  int A[n][m], b[m][1];
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      fscanf(stdin, "%d", &A[i][j]);
    }
  }
  for (i = 0; i < m; i++) {
    fscanf(stdin, "%d", &b[i][0]);
  }

  for (i = 0; i < n; i++) {
    int sum = 0;
    for (j = 0; j < m; j++) {
      sum += A[i][j] * b[j][0];
    }
    fprintf(stdout, "%d\n", sum);
  }

    
  return 0;
}

Measured memory_bytes: 644
#include <stdio.h>

#define BIT_MAX 100000

int bit_table[BIT_MAX];

void bit_init() {
	int i;
	for(i=0;i<BIT_MAX;i++)bit_table[i]=0;
}

void bit_add(int pos,int value) {
	pos++;
	while(pos<=BIT_MAX) {
		bit_table[pos-1]+=value;
		pos+=pos & (-pos);
	}
}

int bit_sum(int pos) {
	int sum=0;
	pos++;
	while(pos>0) {
		sum+=bit_table[pos-1];
		pos-=pos & (-pos);
	}
	return sum;
}

long long invader_table[BIT_MAX];
long long invader_offset;
int invader_count;
int realtime_invader_count;

int getInvader(int id) {
	int left,right,mid;
	left=0;right=BIT_MAX-1;
	while(left<=right) {
		mid=(left+right)/2;
		if(bit_sum(mid)>=id+1)right=mid-1;
		else left=mid+1;
	}
	if(left>=BIT_MAX)return -1;
	return right+1;
}

int main(void) {
	int Q;
	long long L;
	int query,p1,p2;
	int query_count;
	int left,right,mid;
	int start_invader,next_invader;
	int count;
	while(scanf("%d%lld",&Q,&L)==2 && (Q|L)!=0) {
		bit_init();
		invader_offset=0;
		invader_count=0;
		realtime_invader_count=0;
		for(query_count=0;query_count<Q;query_count++) {
			scanf("%d",&query);
			switch(query) {
				case 0:
					invader_table[invader_count]=L-invader_offset;
					bit_add(invader_count,1);
					invader_count++;
					realtime_invader_count++;
					break;
				case 1:
					scanf("%d",&p1);
					invader_offset-=p1;
					count=0;
					while(1) {
						next_invader=getInvader(0);
						if(next_invader<0)break;
						if(invader_table[next_invader]+invader_offset<=0) {
							count++;
							bit_add(next_invader,-1);
							realtime_invader_count--;
						} else break;
					}
					if(count>0)printf("damage %d\n",count);
					break;
				case 2:
					scanf("%d",&p1);
					next_invader=getInvader(p1-1);
					if(next_invader>=0) {
						bit_add(next_invader,-1);
						realtime_invader_count--;
						puts("hit");
					} else puts("miss");
					break;
				case 3:
					scanf("%d%d",&p1,&p2);
					if(realtime_invader_count>0) {
						left=0;right=realtime_invader_count-1;
						while(left<=right) {
							mid=(left+right)/2;
							if(p1-p2<=invader_table[getInvader(mid)]+invader_offset) {
								right=mid-1;
							} else {
								left=mid+1;
							}
						}
						start_invader=right+1;
						left=0;right=realtime_invader_count-1;
						while(left<=right) {
							mid=(left+right)/2;
							if(p1+p2<invader_table[getInvader(mid)]+invader_offset) {
								right=mid-1;
							} else {
								left=mid+1;
							}
						}
						next_invader=right+1;
						for(count=start_invader;count<next_invader;count++) {
							bit_add(getInvader(start_invader),-1);
							realtime_invader_count--;
						}
						printf("bomb %d\n",next_invader-start_invader);
					} else puts("bomb 0");
					break;
				case 4:
					scanf("%d",&p1);
					next_invader=getInvader(p1-1);
					if(next_invader>=0) {
						printf("distance %lld\n",invader_table[next_invader]+invader_offset);
					} else puts("distance -1");
					break;
			}
		}
		puts("end");
	}
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s, t;
  cin >> s >> t;
  int q;
  cin >> q;
  int a[q], b[q], c[q], d[q];
  for(int i = 0; i < q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i]; --c[i];
  }

  int as[s.length() + 1];
  as[0] = 0;
  for(int i = 1; i <= s.length(); i++){
    as[i] = as[i - 1] + (s[i - 1] == 'A' ? 1 : 0);
  }

  int at[t.length() + 1];
  at[0] = 0;
  for(int i = 1; i <= t.length(); i++){
    at[i] = at[i - 1] + (t[i - 1] == 'A' ? 1 : 0);
  }

  string buf;
  for(int i = 0; i < q; i++){
    int tmps = as[b[i]] - as[a[i]] + 
      2 * ((b[i] - a[i]) - (as[b[i]] - as[a[i]]));
    int tmpt = at[d[i]] - at[c[i]] + 
      2 * ((d[i] - c[i]) - (at[d[i]] - at[c[i]]));
    if((tmps % 3) == (tmpt % 3)) buf += "YES\n";
    else buf += "NO\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>                                                                        
using namespace std;                                                                            
using ll = long long;                                                                           
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }         
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }         
#define rep(i,n) for (int i=0; i< (n); ++i)                                                     
typedef pair<int, int> P;                                                                       
                                                                                                
int main() {                                                                                    
  int n;                                                                                        
  cin >> n;                                                                                     
  vector<int> l(n);                                                                             
  rep(i,n) cin >> l[i];                                                                         
  sort(l.begin(), l.end());                                                                     
  ll sum = 0;                                                                                   
  for (int i=0; i<n; i++) {                                                                     
    for (int j=i+1; j<n; j++) {                                                                 
      int limit = l[i] + l[j];                                                                  
      for (int k=j+1; k<n; k++) {                                                               
        if (l[k] >= limit) {                                                                    
          break;                                                                                
        }                                                                                       
        //      cout << i << " " << j << " " << k << endl;                                      
        sum++;                                                                                  
      }                                                                                         
    }                                                                                           
  }                                                                                             
                                                                                                
  cout << sum << endl;                                                                          
                                                                                                
                                                                                                
  return 0;                                                                                     
}  

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

using ll = long long;

int main()
{
  ll N;
  cin >> N;
  vector<ll> a(N+1);
  map<ll, ll> m;

  for(int i=1; i<=N; i++){
    cin >> a.at(i);
    m[i - a.at(i)]++;
  }

  ll sum = 0;
  for(int i = 1; i<=N; i++){
    sum += m[i+a.at(i)];
  }

  cout << sum <<endl;
}

Measured memory_bytes: 27364
import Control.Applicative

main = do xs <- (map read) . concatMap words . lines <$> getContents
          putStr . unlines $ solve xs

solve :: [Int] -> [String]
solve (x:y:xs) | x==0 && y==0 = []
               | x<=y = ((show x) ++ " " ++ (show y)) : solve xs
               | x>y = ((show y) ++ " " ++ (show x)) : solve xs

Measured memory_bytes: 4564
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;

	int ans = 0;

	for (int i = 0; i <= n; i++) {
		int tmp = i;
		int sum = 0;
		int pow10 = 1;
		while (tmp > 0) {
			sum += tmp % 10;
			pow10 *= 10;
			tmp /= 10;
		}

		if (a <= sum && sum <= b) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
dd = [list(map(int, input().split())) for _ in range(n)]

e = []
for d1, d2 in dd:
  e.append(int(d1 == d2))

for i in range(len(e)):
  if tuple(e[i: i + 3]) == (1, 1, 1):
    print('Yes')
    exit()

print('No')


Measured memory_bytes: 9176
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=3003;

char s[N];
bool used[4];
int n;

il int idx(char c){
	return c=='N'?0:(c=='W'?1:(c=='E'?2:3));
}

int main(){
	scanf("%s",s);
	n=strlen(s);
	rep0(i,n) used[idx(s[i])]=true; 
	puts((used[0]^used[3])||(used[1]^used[2])?"No":"Yes");
	return 0;
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a = int(input())
b = factorization(a)
countation = 0
for i in range(len(b)):
    t = b[i][1]
    k = 1
    n = 1
    while t >= n:
        countation += 1
        k = k + 1
        n = k*(k+1)/2
if a != 1:
    print(countation)
else:
    print(0)

Measured memory_bytes: 9500
def calc(a,b,c,d,p,q,r):
  value = a
  list=[(p,b),(q,c),(r,d)]
  
  for el in list:
    op,x = el
    if op == 0:
      value += x
    elif op == 1:
      value -= x
    else:
      raise Exception("invalid argument")
  
  return value
  
def op(p):
  if p == 0:
    return '+'
  elif p == 1:
    return '-'
  else:
    raise Exception("invalid argument")
  
  

def solve(inputstr):
  a=int(inputstr[0])
  b=int(inputstr[1])
  c=int(inputstr[2])
  d=int(inputstr[3])
  
  ops=[0,1]
  for p in ops:
    for q in ops:
      for r in ops:
        if 7 == calc(a,b,c,d,p,q,r):
          return (inputstr[0] + op(p) + inputstr[1] + op(q) + inputstr[2] + op(r) + inputstr[3] + "=7")
    

  raise Exception("invalid argument")



if __name__ == '__main__':
  inputstr = input()
  ans = solve(inputstr)
  print(ans, flush=True)

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

int main(){
    while (1){
        string x;
        cin >> x;
        if (x=="0") break;
        int sum=0;
        for (int i=0; i<x.size(); i++)
            sum += x[i] - '0';
        cout << sum << endl;
    }
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll M,D;
ll i, j, ans;
int main(){
    scanf("%lld%lld", &M,&D);
    fornum(i,1,M+1){
        fornum(j,1,D+1){
            if(j%100<20||j%10<2){
                continue;
            }
            if((j%100/10)*(j%10)==i){
                ans++;
            }

        }
    }
    printf("%lld", ans);

    return 0;
}

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

using namespace std;

const int mx = 110000;

int n, W;
int w[110], v[110];
long long dp[110000];

int main() {
	cin >> n >> W;
	for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
	
	for (int i = 0; i <= 100000; i++) dp[i] = 1e18;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 100000; j >= v[i]; j--) {
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	
	long long ans = 0;
	for (int i = 100000; i >= 0; i--) {
		if (dp[i] <= W) ans = max(ans, 1ll * i);
	}

	cout << ans << '\n';
}



Measured memory_bytes: 1024
N,M=map(int,input().split())
G=[[False]*N for i in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  G[a-1][b-1]=G[b-1][a-1]=True
V=[False]*N
V[0]=True

def dfs(v):
  if not False in V: return 1
  ret=0
  for i in range(N):
    if not G[v][i]: continue
    if V[i]: continue
    V[i]=True
    ret+=dfs(i)
    V[i]=False
  return ret

print(dfs(0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n);

    if(n == 3){
        cout << "2 5 63" <<endl;
        return 0;
    }

    int constraint = 30000;
    int num = 0;
    ll sum = 0, subsum = 0;
    for(int i = 2; i < constraint; i++){
        if(i%2==0 || i%3==0 || i%5==0){
            v[num] = i;
            num++;
            sum += ll(i);
        }
        if(num == n){break;}
    }
    if(sum%30 != 0){
        ll ex = (30 - sum%30)%30+30;
        bool flg = true;
        while(flg){
            for(int i = 1; i < ex/2; i++){
                ll ta = v[n-2] + i;
                ll tb = v[n-1] + ex-i;
                if((ta%2==0 || ta%3==0 || ta%5==0)&&(tb%2==0 || tb%3==0 || tb%5==0)){
                    v[n-2] = ta;
                    v[n-1] = tb;
                    flg = false;
                    sum += ex;
                    break;
                }
            }
        }
    }

    for(int i = 0; i < n; i++){
        cout << v[i] << " ";
    }
    cout << endl;

    return 0;
}


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

int veloc(int l, int r, int v, int x)
{
    if (x <= l) return v + (l - x);
    else if (x >= r) return v + (x - r);
    return v;
}

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

    int l[n + 2], r[n + 2], v[n + 2];

    l[0] = r[0] = l[1] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t;
        l[i] = r[i - 1];
        r[i] = l[i] + t * 2;
    }
    l[n + 1] = r[n + 1] = r[n];

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

    int pr = 0;
    int ans = 0;
    for (int x = 1; x <= r[n]; x++) {
        int mn = 1e9;
        for (int i = 0; i <= n + 1; i++) {
            mn = min(mn, veloc(l[i], r[i], v[i], x));
        }
        ans += pr + mn;
        pr = mn;
    }
    cout << setprecision(12) << double(ans) / 8 << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;

int main() {
    int N;
    cin >> N;
    int a;
    bool ans = true;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if ((a % 2 == 0) && (a % 3 != 0 && a % 5 != 0)) {
            ans = false;
            break;
        }
    }

    if (ans) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
}


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


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int MAX_N = 100000;

const string LDUR = "LDUR";
int main() {
	int n, m;
	cin >> n >> m;

	int num = m;
	map<int, int> preFacMap;
	for (int i = 2; i *i <= m; i++) {
		while (num%i == 0) {
			preFacMap[i]++;
			num /= i;
		}
	}

	if (num > 1) {
		preFacMap[num]++;
	}

	vector<ll> facto(2*MAX_N);
	facto[0] = 1;
	for (int i = 1; i < 2 * MAX_N; i++) {
		facto[i] = (i * facto[i - 1]) % MOD_CONST;
	}
	vector<ll> inv_mod(2 * MAX_N);
	inv_mod[1] = 1;
	for (int i = 2; i < 2 * MAX_N; i++) {
		inv_mod[i] = (MOD_CONST - (((MOD_CONST / i)*inv_mod[MOD_CONST%i]) % MOD_CONST)) % MOD_CONST;
	}
	
	vector<ll> inv_facto(2 * MAX_N);
	inv_facto[0] = 1;
	for (int i = 1;i < 2 * MAX_N; i++) {
		inv_facto[i] = (inv_mod[i] * inv_facto[i - 1]) % MOD_CONST;
	}

	

	ll ans = 1;

	for (auto it = preFacMap.begin(); it != preFacMap.end(); it++) {
		//cout << it->first << " " << it->second<< endl;
		ans =( (ans*facto[it->second + n - 1]) % MOD_CONST);
		ans = ((ans*inv_facto[ n - 1]) % MOD_CONST);
		ans = ((ans*inv_facto[it->second]) % MOD_CONST);
	}
	cout << ans <<  endl;

}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
	int x[3001],y[3001],i,n;
	i=1;
	scanf("%d %d" ,&x[i],&y[i]);
	while((x[i]!=0)||(y[i]!=0)){
		i++;
		scanf("%d %d" ,&x[i],&y[i]);
	}
	n=i;
	for(i=1; i<=n-1; i++){
		if(x[i]>y[i]){
			printf("%d %d\n" ,y[i],x[i]);
		}
		else{
			printf("%d %d\n" ,x[i],y[i]);
		}
	};
	return 0;
}

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

using namespace std;

long long power(long long a,long long b,long long mod) {

    long long res=1;

    while(b>0) {

        if(b&1)

            res=(res*a)%mod;

        a=(a*a)%mod;

        b>>=1;

    }

    return res;

}

long long modInverse(long long n, long long p) {

    return power(n, p - 2, p);

}

long long nCrModPFermat(long long n,long long r, long long p) {

    if (r == 0)

        return 1;

    long long fac[n + 1];

    fac[0] = 1;

    for (long long i = 1; i <= n; i++)

        fac[i] = (fac[i - 1] * i) % p;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;

}

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long s;

    cin >> s;

    long long res=0;

    for(long long i=1;; i++) {

        if(3*i>s) {

            break;

        }

        long long cur = 1;

        long long left = s - 3*i;

        long long cur2 = nCrModPFermat(left+i-1,left,1000000007);

        long long temp = cur*cur2;

        temp%=1000000007;

        res+=temp;

        res%=1000000007;

    }

    cout << res << '\n';

    return 0;

}



Measured memory_bytes: 3640
#include<stdio.h>
#include <stdlib.h>
#include <string.h>

#define exe_m  1900
#define exe_n    100

int hsi(int n, int m) {
	//printf("v=%d\n", v);
//   printf("%d\n",(m * exe_m) );
//   printf("%d\n",((n - m) * exe_n ));
        if(m ==0){
          return (n  *   exe_n);
        }  else {
         return ((m * exe_m) + ((n - m) * exe_n)  ) * pow(2 , m);
//         return ((m * exe_m) + ((n - m) * exe_n)  ) ;

    }   

}

int main()
{

    int  N, M;
 // 整数の入力
    scanf("%d %d", &N, &M);
    
   printf("%d\n", hsi(N,M));

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define  f first
#define s second
#define ll long long int
#define vll vector<long long int>
#define vi  vector<int>
#define vpi vector<pair<int,int>>
#define prec fixed<<setprecision(10)
#define set(x) __builtin_popcount(x)
#define ffs(x) __builtin_ffs(x)
#define clz(x) __builtin_clz(x)
#define inf 1000000007
#define linf 1000000000000000007
#define a(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

int main(){
    fast
    int s,w;
    cin >> s >> w;
    if(w>=s)cout << "unsafe";
    else cout << "safe"  ;
}

Measured memory_bytes: 3668
c = [list(map(int, input().split())) for _ in range(3)]

a2 = c[1][0] - c[0][0]
a3 = c[2][0] - c[0][0]

if any(c[1][x] != a2 + c[0][x] for x in [1, 2]) or any(c[2][x] != a3 + c[0][x] for x in [1, 2]):
	print('No')
else:
	print('Yes')


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	int card[50]={0};
	int mem[50]={0};
	int n;
	int r;
	int k = 0 ;
	int p,c;
	while(1){
		cin >>n >>r;
		if ((n==0)&&(r==0)) break;
		for(int i =0;i<n;i++){
			card[i]=i+1;
		}	
		for (int j=0;j<r;j++){
			cin >> p >> c ;
			for(int l=0;l<n;l++){
				mem[l]=card[l];
			}
			for(int m=0;m<p-1;m++){
				card[n-p-c+1+m]=mem[n-p+1+m];
			}
			for(int o=0;o<c;o++){
				card[n-c+o]=mem[n-p-c+1+o];
			}
		}
		cout << card[n-1] <<endl;
		

	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main() {
    int n, v, j;
    cin >> n;
    int A[n];
    for (int i=0; i<n; i++){
        cin >> A[i];
    }
    for (int i=0; i<n; i++){
        if (i == n-1){
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }
    }
    for (int i=1; i<n; i++){
        v = A[i];
        j = i-1;
        while (j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for (int j=0; j<n; j++){
            if (j == n-1){
                cout << A[j] << endl;
            } else {
                cout << A[j] << " ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3076