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

typedef long long ll;

int main(){
	string s;
	cin >> s;
	if(s.size()%2==1){
		puts("No");
		return 0;
	}
	
	for(int i=0;i+1<s.size();i+=2){
		if(s[i]!='h'||s[i+1]!='i'){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

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

	int n = gcd(a,b);
	vector<int> arr;
	for(int i = 1;i <= n;i++){
		if(n % i == 0)arr.push_back(i);
	}

	cout << arr[arr.size()-k] << endl;
}


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

const int MAX_N=1100000;

int memo[MAX_N];

int rec(int n){
    int pow6,pow9;
    if(n==0) return 0;
    if(memo[n]!=-1)return memo[n];

    int res=n;

    for(pow6=1;pow6<=n;pow6*=6){
        res=min(res,rec(n-pow6)+1);
    }

    for(pow9=1;pow9<=n;pow9*=9){
        res=min(res,rec(n-pow9)+1);
    }

    //cout<<n<<" "<<res<<endl;
    return memo[n]=res;
}

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

    for(int i=0;i<MAX_N;i++)memo[i]=-1;
    cout<<rec(N)<<endl;
}

Measured memory_bytes: 10960
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        vector<pair<int,int> > ar(n);
        for(int i=0;i<n;i++){
            int n[3];
            for(int j=0;j<3;j++){
                scanf("%d",&n[j]);
            }
            ar[i]=make_pair(n[0],n[1]+n[2]);
        }
        int maxa,maxb=0;
        for(int i=0;i<n;i++){
            if(ar[i].second>maxb){
                maxa=ar[i].first;
                maxb=ar[i].second;
            }
        }
        printf("%d %d\n",maxa,maxb);
        
    }
}

Measured memory_bytes: 892
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int x,y;
    cin>>x>>y;
    rep(t,101){
        int k=x-t;
        if(k<0) continue;
        if(2*t+4*k==y){
            Yes;
            return 0;
        }
    }
    No;
}/*
./problem.exe
*/

Measured memory_bytes: 3644
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto n = lread();
    auto a = aryread();
    long ans;
    foreach (i; 0 .. n)
    {

        ans += a[i] - 1;
    }
    writeln(ans);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3648
a,b,c,d=map(int,input().split())
dp=[]
MOD=998244353
for i in range(c+1):
  dp.append([])
  for j in range(d+1):
    dp[-1].append(0)
dp[a][b]=1
for i in range(a,c+1):
  for j in range(b,d+1):
    if i+1<=c and j+1<=d:
      dp[i+1][j+1]=(dp[i+1][j+1]-dp[i][j]*i*j)%MOD
    if i+1<=c:
      dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j)%MOD
    if j+1<=d:
      dp[i][j+1]=(dp[i][j+1]+dp[i][j]*i)%MOD
print(dp[c][d])

Measured memory_bytes: 147352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    double ans = 0.5;
    if (n % 2) {
        ans = (n / 2 + 1) / (double)n;
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;char e,f,g,h;cin >> e >> f >> g >> h;bool y,m;
  a = e-'0';b = f-'0';c = g-'0';d = h-'0';
  y = (1<=a*10+b && a*10+b<=12);
  m = (1<=c*10+d && c*10+d<=12);
  if(y && m) cout << "AMBIGUOUS" << endl;
  else if(!y && m) cout << "YYMM" << endl;
  else if(y && !m) cout << "MMYY" << endl;
  else cout << "NA" << endl;
}

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

int main(){
  double x1, y1, x2, y2, x, y;
  cin>>x1>>y1>>x2>>y2;
  x=x2-x1;
  y=y2-y1;
  printf("%f\n", sqrt(x*x+y*y));
  return 0;
}

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

int main() {
  int N,x,k=0;
  cin >> N >> x;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for(; 0<=x && k<N; k++){
    x=x-a.at(k);
  }
  if(x!=0){
    k=k-1;
  }
  cout << k << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>
 
#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
 
using namespace std;
 
/////////////////////////////////////////////////////
 
 
int N,T,A,H[1010];
float K[1010];
int ans,i, j;
int main(){
    scanf("%d%d%d",&N,&T,&A);
    fornum(i,0,N){
        scanf("%d", &H[i]);
        K[i] = T - H[i] * 0.006;
        K[i]=K[i]>A?K[i]-A:A-K[i];
        ans = K[i] < K[ans] ? i : ans;
    }
    printf("%d\n", ans + 1);
 
    return 0;
}

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


int main()
{
	int n, d;
	std::cin >> n >> d;
	double points[10][10] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			std::cin >> points[i][j];
		}
	}

	double temp;
	double result;
	int count = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			temp = 0;
			for (int k = 0; k < d; k++) {
				temp += std::pow(points[i][k] - points[j][k], 2);
				//std::cout << points[i][k] << "  " << points[j][k] << "   " << pow(points[i][k] - points[j][k], 2) << std::endl;
			}
			result = std::sqrt(temp);
			//std::cout << "result " << result << std::endl;
			if (std::ceil(result) == result)
				count++;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

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

int n;
int vals[4];
double dp[301][301][301];

double recurse(int i, int j, int k)
{
    if (abs(dp[i][j][k] + 1) > 1e-9)
        return dp[i][j][k];
    
    double ret = 0;
    ret += (double)n / (double)(i + j + k);

    if (i > 0)
        ret += (double)i / (double)(i + j + k) * recurse(i - 1, j, k);
    if (j > 0)
        ret += (double)j / (double)(i + j + k) * recurse(i + 1, j - 1, k);
    if (k > 0)
        ret += (double)k / (double)(i + j + k) * recurse(i, j + 1, k - 1);
    dp[i][j][k] = ret;

    return ret;
}

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

    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 0;

    //printf() recurse(vals[1], vals[2], vals[3]) << endl;
    printf("%.10lf\n", recurse(vals[1], vals[2], vals[3]));
}

Measured memory_bytes: 216856
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 301
#define mod(x, MOD) ((x % MOD) + MOD) % MOD

using namespace std;

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

int main() {
    int N;
    char S[MAX_N][MAX_N];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> S[i][j];
        }
    }
    
    bool same[MAX_N][MAX_N];
    for (int i = 0; i < N; ++i) {
        fill(same[i], same[i] + N, false);
    }
    
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            bool flag = true;
            for (int k = 0; k < N; ++k) {
                if (S[i][mod(j + k, N)] != S[mod(i + k, N)][j]) {
                    flag = false;
                }
            }
            if (flag) {
                same[i][j] = true;
            }
        }
    }
    
    int ans = 0;
    
    for (int A = 0; A < N; ++A) {
        for (int B = 0; B < N; ++B) {
            bool flag = true;
            for (int i = 0; i < N; ++i) {
                if (!same[mod(i + A, N)][mod(i + B, N)]) {
                    flag = false;
                }
            }
            if (flag) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  bool hasY = false;
  for (int i = 0; i < N; i++)
  {
    char color;
    cin >> color;
    if (color == 'Y')
    {
      hasY = true;
    }
  }
  if (hasY)
  {
    cout << "Four" << endl;
  }
  else
  {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,k;
string s;

int main(){
	cin>>n>>k;
	k--;
	cin>>s;
	if(s[k]=='A'){
		s[k]='a';
	}else if(s[k]=='B'){
		s[k]='b';
	}else{
		s[k]='c';
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5+5;
const ll mod = 1e9+7;
ll pd[MAX][15];
char s[MAX];

ll solve(int i, int m, int n) {
	if(pd[i][m] != -1) return pd[i][m];
	if(i == n && m == 5) return 1;
	if(i == n) return 0;
	pd[i][m] = 0;
	if(s[i] == '?') {
		REP(j, 0, 9)
			pd[i][m] = (pd[i][m] + solve(i+1, (m*10+j)%13, n)) % mod;
	}
	else pd[i][m] = solve(i+1, (m*10+(s[i]-'0'))%13, n) % mod;
	return pd[i][m];
}

int main(int argc, char ** argv) {
	scanf("%s", s);
	memset(pd, -1, sizeof pd);
	cout << solve(0, 0, strlen(s)) << endl;
	return 0;
}


Measured memory_bytes: 19840
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int a, b, d, r; double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double)a / b;
    // cout << d << " " << r << " " << f << endl;
    printf("%d %d %lf\n", d, r, f);
    return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
  ll n,check;
  cin >> n;
  vector<ll> A;
  A.push_back(1);
  check = 6;
  while(check <= 100000){
    A.push_back(check);
    check *= 6;
  }
  check = 9;
  while(check <= 100000){
    A.push_back(check);
    check *= 9;
  }
  vector<vector<ll>> H(A.size()+1, vector<ll>(n+1, 100009));
  H[0][0] = 0;
  for(ll i=0; i<A.size(); i++){
    for(ll j=0; j<=n; j++){
      if(j-A[i]>=0){
        H[i+1][j] = min(H[i+1][j-A[i]] + 1, H[i][j]);
      }else{
        H[i+1][j] = H[i][j];
      }
    }
  }
  /*
  for(ll i=0; i<A.size(); i++){
    for(ll j=0; j<=n; j++){
        cout << H[i][j] << " ";
    }
    cout << endl;
  }
  */
  cout << H[A.size()][n] << endl;
  return 0;
}

Measured memory_bytes: 11264
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


import sys

readline = sys.stdin.readline

N, Q = map(int, readline().split())
tree = UnionFind(N)
res = []
for _ in range(Q):
    t, u, v = map(int, readline().split())
    if t:
        res.append(int(tree.is_connected(u, v)))
    else:
        tree.unite(u, v)
print("\n".join(map(str, res)))


Measured memory_bytes: 18796
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();

        StringBuilder str = new StringBuilder();
        for (int i=0; i<N; i++) {
            if ((i+1) == K) {
                str.append(S.substring(i,i+1).toLowerCase());
            }
            else {
                str.append(S.substring(i,i+1));
            }
        }

        System.out.println(str.toString());
    }
}

Measured memory_bytes: 22996
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

flag = 0

for i in range(1,5):
    if [a1,a2,a3,b1,b2,b3].count(i) == 3:
        flag = 1
        break
    else:
        flag = 0
if flag == 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
//
//  main.cpp
//  B
//
//  Created by Charles on 2017/9/24.
//  Copyright © 2017年 Charles. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
int n,m,k;
int main(int argc, const char * argv[]) {
    scanf("%d%d%d",&n,&m,&k);
    int flag=0;
    int tmp=0;
    for(int i=0;i<=n;++i){
        tmp=i*m;
        for(int j=0;j<=m;++j){
            int kk=tmp+j*n-j*i*2;
            if(kk==k){
                flag=1;
                break;
            }
            
        }
        if(flag) break;
    }
    if(flag) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
 
a=list(map(int,input().split()))
n=4*int(input())
p=[]
for i in range(4):
    p.append([2**i,a[i]*4,(a[i]*4)/2**i])
 
 
p=sorted(p,key=itemgetter(2))
 
ans=0
 
for i in range(4):
    t=n//p[i][0]
    ans += t*p[i][1]
    n -= t*p[i][0]
 
print(ans//4)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll x,y; cin >> x >> y;
  ll ans = lcm(x,y)-x;
  if(ans == 0) cout << "-1" << endl;
  else cout << ans << endl;

  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

int main(void){
  int a;
  scanf("%d",&a);

  if (a<1200) {
    printf("ABC");
  }else if (a>=1200 && a < 2800) {
    printf("ARC");
  }else if(a >= 2800){
    printf("AGC");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(args...) do { cout << "\033[32;1m" << #args << " -> "; err(args); } while (0)
#else
#define dbg(...)
#endif
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); }
template<typename T, typename... Args>
void err(T a, Args... args) { cout << a << ' '; err(args...); }

LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
////////////////////////////////////////////////////////////////////////////////////

void addedge(int x, int y) {
    printf("%d %d\n", x, y);
}

const int N = 1E5 + 100;
char s[N];
int n, cnt;

void solve(int sz) {
    int last = 1;
    FORD (i, sz, 0) {
        ++cnt;
        dbg(i, s[i], last, cnt);
        if (s[i] == '0') {
            addedge(last, cnt);
        } else {
            addedge(cnt - 1, cnt);
            last = cnt;
        }
    }
}

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    if (s[n] == '1' || s[1] == '0') {
        puts("-1");
        return 0;
    }
    FOR (i, 1, n) {
        if (s[i] != s[n - i]) {
            puts("-1");
            return 0;
        }
    }
    cnt = 1;
    // FORD (root, n / 2, -1) {
    //     if (s[root] == '1') {
    //         solve(root);
    //         addedge(1, ++cnt);
    //         FOR (i, cnt + 1, n + 1) {
    //             addedge(cnt, i);
    //         }
    //         break;
    //     }
    // }
    // solve(n - 1);

    int last = 1;
    FOR (i, 2, n + 1) {
        addedge(last , i);
        if (s[i - 1] == '1') {
            last = i;
        }
    }
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;


bool right(char c){
	if(c == 'y' || c == 'u' || c == 'i' || c == 'o' || c == 'p' || c == 'h' || c == 'j' || c == 'k' || c == 'l' || c == 'n' || c == 'm') return true;
	else return false;
}

int main() {

	string s;
	while(cin >> s, s != "#"){
		int ans = 0;
		REP(i, 1, s.size()){
			if(right(s[i-1]) != right(s[i])) ans++;
		}
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin>>N;
  if(N==2){
    ll a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }
  else cout<<"Hello World"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
constexpr int R = 14;
int main(void){
    int N, number;
    char suite;
    cin >> N;
    vector<bool> S(R), H(R), C(R), D(R); 
    for(int i=0; i<N; i++){
        cin >> suite >> number;
        switch(suite){
            case 'S':   S[number] = true; break;
            case 'H':   H[number] = true; break;
            case 'C':   C[number] = true; break;
            case 'D':   D[number] = true; break;
        }
    }
    for(int n=1; n<R; n++) if(!S[n]) cout << "S " << n << endl;
    for(int n=1; n<R; n++) if(!H[n]) cout << "H " << n << endl;
    for(int n=1; n<R; n++) if(!C[n]) cout << "C " << n << endl;
    for(int n=1; n<R; n++) if(!D[n]) cout << "D " << n << endl;
}


Measured memory_bytes: 3080
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  writeln(s.count('+').to!int - s.count('-').to!int);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    int cnt=0;
    for(int i=0;i<n-1;i++){
        if(p[i]==i+1){
            cnt++;
            swap(p[i],p[i+1]);
        }
    }
    if(p[n-1]==n)cnt++;
    //for(auto it:p)cout<<it<<' ';
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]

b=[]
for x in a:
  if "#" in x:
    b.append(x)

c=[]
for y in zip(*b):
  if "#" in y:
    c.append(y)
c1=[]
c1=zip(*c)
    
#c=zip(*[y for y in zip(*b) if "#" in y])

for d in c1:
  print("".join(d))

Measured memory_bytes: 3188
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
pret = 0
prex = 0
prey = 0
for _ in range(n):
    t, x, y = MAP()
    dis = abs(x - prex) + abs(y - prey)
    delta = t - pret
    if delta - dis >= 0 and (delta - dis) % 2 == 0:
        pret = t
        prex = x
        prey = y
        continue
    else:
        print('No')
        exit()
print('Yes')

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)



int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, Q; cin >> N >> Q;
  vector<vector<int>> nbr(N+1);
  vector<int> added(N+1);
  vector<int> val(N+1);
  for (int i = 0; i < N-1; i++) {
    int a, b; cin >> a >> b;
    nbr.at(a).push_back(b);
    nbr.at(b).push_back(a);
  }
  for (int i = 0; i < Q; i++) {
    int p, x; cin >> p >> x;
    added.at(p) += x;
  }

  function<void(int,int,int)> dfs = [&](int n, int parent, int acc) {
    acc += added.at(n);
    val.at(n) = acc;
    for (int c : nbr.at(n)) {
      if (c == parent) continue;
      dfs(c, n, acc);
    }
  };

  dfs(1, -1, 0);
  for (int i = 1; i <= N; i++) {
    if (i > 1) cout << " ";
    cout << val.at(i);
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 30592
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b_d=[[0,0] for _ in range(n+1)]
b_u=[[0,0] for _ in range(n+1)]
b_d[n]=[a[n],a[n]]
b_u[0]=[1,1]
for i in range(1,n+1):
    l=(1+b_d[n+1-i][0])//2+a[n-i]
    r=(b_d[n+1-i][1])+a[n-i]
    if l>r:
        print(-1)
        exit()
        break
    b_d[n-i]=[l,r]
    l=max(0,b_u[i-1][0]-a[i-1])
    r=2*(b_u[i-1][1]-a[i-1])
    if l>r:
        print(-1)
        exit()
        break
    b_u[i]=[l,r]
ans=0

for i in range(n+1):
    if b_d[i][0]>b_u[i][1] or b_u[i][0]>b_d[i][1]:
        print(-1)
        exit()
    else:
        ans+=min(b_u[i][1],b_d[i][1])
print(ans)

Measured memory_bytes: 727748
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if v<w:
    print("NO")
elif v==w:
    if a==b:
        print("YES")
    else:
        print("NO")
elif v>w:
    t0 = abs((a-b)/(v-w))
    if t0<=t:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 61556
#include<stdio.h>
int main(){
    int i,j,H,W,a[100][100],b[100];
    long long int t;
    scanf("%d %d",&H,&W);
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<W;i++)scanf("%d",&b[i]);
    for(i=0;i<H;i++){
        t=0;
        for(j=0;j<W;j++)t+=a[i][j]*b[j];
        printf("%d\n",t);
    }
    return 0;
}


Measured memory_bytes: 2144
a, b, c = gets.split.map(&:to_i)
def how(a, b, c)
  if (a != b) && (b != c) && (c != a)
    puts "No"
  elsif a == b && b == c
    puts "No"
  else
    puts "Yes"
  end
end

puts how(a, b, c)

Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;

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

ll _lcm (ll a, ll b){
    return a * b / _gcd(a, b);
}


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    int k;
    cin >> k;

    ll result = 0;

    for1n(i, k)for1n(j, k)for1n(c, k){
        result += _gcd(_gcd(i, j), c);
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 3648
/*input
10 4
40 10 20 70 80 10 20 70 80 60
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
#define endl '\n'
const int N =6e5+5;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int powmod(int base,int exp,int mod)
{
	int res=1LL;
	while(exp>0)
	{
		if(exp&1LL)
			res=(res*base)%mod;
		exp/=2LL;
		base=(base*base)%mod;
	}
	return res%mod;
}
int dp[N];
signed main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	Rep(i,n)
	{
		cin>>a[i];
	}
	dp[1]=0;
	for(int i=2;i<=min(n,k);i++)
	{
		int ans=1e10;
		for(int j=1;j<i;j++)
		{
			ans=min(ans,dp[j]+abs(a[i]-a[j]));
		}
		dp[i]=ans;
	}
	for(int i=k+1;i<=n;i++)
	{
		int ans=1e10;
		for(int j=i-k;j<i;j++)
		{
			ans=min(ans,dp[j]+abs(a[i]-a[j]));
		}
		dp[i]=ans;
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1792
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 N = int.Parse(Console.ReadLine());
            var r = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (N == 1)
            {
                Console.WriteLine(r[0]);
                return;
            }

            List<int> ret = new List<int>();

            bool flg = false;
            for (int i = 0; i < N; i++)
            {
                if (flg)
                {
                    ret.Add(r[i]);
                }
                else
                {
                    ret.Insert(0,r[i]);
                }
                flg = !flg;
            }
            if (N % 2 != 0)
            {
                Console.WriteLine(string.Join(" ",ret));
            }
            else
            {
                ret.Reverse();
                Console.WriteLine(string.Join(" ",ret));
            }
        }

    }
}

Measured memory_bytes: 43704
#include <iostream>

int main(){
  int n = 3, i;
  char s[n][n];
  for(i = 0; i<n; i++){
    for(int j = 0; j<n; j++){
      std::cin >> s[i][j];
    }
  }
  for(i = 0; i<n; i++){
    std::cout << s[i][i];
  }
  return 0;
}

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

int comp_time(int x, int y)
{
  int c = 0;
  int t = 0;
  while ((x>0) || (y>0))
  {
    int xi = x % 10;
    int yi = y % 10;
    t += xi * yi + c;
    if (xi + yi + c >=10) c=1; else c=0;
    x = x / 10;
    y = y / 10;
  }
  return t + c;
}

int main()
{
  int n;
  int x[300];

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

  // table
  int sum[300][300];
  int time[300][300];

  for (int i=0;i<n;i++)
  {
    sum[i][1]=x[i];
    time[i][1]=0;
  }

  for (int k=2; k<=n; k++)
  {
    for (int i=0;i<=n-k;i++)
    {
      sum[i][k]=x[i] + sum[i+1][k-1];
      int min_time = comp_time(x[i], sum[i+1][k-1]) + time[i+1][k-1];
      for (int l=2; l<=k-1; l++)
      {
        int r=k-l;
        int t = time[i][l] + time[i+l][r] + comp_time(sum[i][l], sum[i+l][r]);
        if (t < min_time) min_time = t;
      }
      time[i][k] = min_time;
    }
  }

  // for (int k=1;k<=n;k++)
  // {
  //   for (int i=0; i<=n-k; i++)
  //   {
  //     cout << sum[i][k] << ' ';
  //   }
  //   cout << endl;
  // }
  // cout << endl;

  // for (int k=1;k<=n;k++)
  // {
  //   for (int i=0; i<=n-k; i++)
  //   {
  //     cout << time[i][k] << ' ';
  //   }
  //   cout << endl;
  // }
  // cout << endl;

  cout << time[0][n] << endl;
  return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
#define MOD 1000000007 
typedef long long ll;

int main(void){
  string S;cin >> S;
  int N=S.length();
  map<char,int> m = {
    {'A',0},
    {'B',1},
    {'C',2},
  };
  //
  int i,j;
  ll dp[N+1][4];
  //初期化
  REP(j,4)dp[N][j] = 0;
  dp[N][3] = 1;
  for(i=N;i>=0;i--){
    for(j=3; j>=0; j--){
      if(i==N) dp[i][j] = j==3 ? 1:0;
      else{
        dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3 : 1 );
        if(j<3 && ( S[i] == '?' || j == m[S[i]] ) ) dp[i][j] += dp[i+1][j+1];
        dp[i][j] %= MOD;
      }
    }
  }
  cout << dp[0][0] << endl;;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll A[N+1];
    A[0]=0;
    map<ll,ll> mp;
    mp[0]++;
    for(int i=1;i<N+1;i++){
        ll a;
        cin >> a;
        A[i]=A[i-1]+a;
        mp[A[i]]++;
    }
    ll sum=0;
    for(auto x:mp){
        sum+=x.second*(x.second-1)/2;
    }



    cout << sum << endl;
}

/*



 */



Measured memory_bytes: 14336
n, a, b = map(int, input().split())
if a+b-1 > n or a*b < n:
  print(-1)
  exit()
L = [[] for _ in range(b)]
L[-1] = list(range(1, a+1))
for now in range(a+1, n+1):
  temp = -2 - (now-(a+1))%(b-1)
  L[temp].append(now)
for l in L:
  print(*l, end=" ")

Measured memory_bytes: 37596
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	map<string,bool>mp;
	char prev='a';
	for(int i=0;i<n;i++){
		string a;
		cin>>a;
		if(i==0){
			mp[a]=true;
			prev=a[a.size()-1];
			//cout<<"1="<<i<<endl;
		}
		else{
			if(mp.find(a)!=mp.end()){
				//cout<<"2="<<i<<endl;
				cout<<"No"<<endl;
				return 0;
			}
			else if(a[0]!=prev){
				//cout<<"3="<<i<<endl;
				cout<<"No"<<endl;
				return 0;
			}
			else{
				//cout<<"4="<<i<<endl;
				mp[a]=true;
				prev=a[a.size()-1];
			}
		}

	}
	cout<<"Yes"<<endl;
}

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

int main() {
  string S; cin >> S;
  vector<int> v;
  for (int i = 0; i < S.size() - 2; i++) {
    string str = "";
    string three = str + S.at(i) + S.at(i + 1) + S.at(i + 2);
    int x = stoi(three);
    v.push_back(x);
  }
  int ans = 10000000;
  for (int i = 0; i < v.size(); i++) {
    int dif = abs(753 - v.at(i));
    ans = min(ans, dif);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#define MAX 10000
using namespace std;
int compare(pair<int,int> a,pair<int,int> b)
{
  return a>b;
}
int main()
{
    int N,M;
    while(cin>>N>>M&&N)
    {
    int d,p;
    int P=0;
    pair<int,int> pd[MAX];
    int i;
    for(i=0;i<N;i++)
    {
        cin>>d>>p;
        pd[i]=make_pair(p,d);
    }
    sort(pd,pd+N,compare);

    for(i=0;i<N;i++)
    {
        //cout<<pd[i].first<<pd[i].second<<endl;
        if(pd[i].second<=M)
         M-=pd[i].second;
        else //if(0<=M&&pd[i].second>M)
        {
            P+=(pd[i].second-M)*pd[i].first;
            M=0;
        }
    }
    cout<<P<<endl;
    }
    return 0;
}



Measured memory_bytes: 3188
package main

import (
	"fmt"
)

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func getTotal(a, b int) (c int) {
	switch {
	case a == b:
		c = a * 2
	case a > b:
		c = a*2 - 1
	case a < b:
		c = b*2 - 1
	}
	return
}

func main() {
	nums := scanNums(2)
	fmt.Println(getTotal(nums[0], nums[1]))
}


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


void solve(long long N, std::string S, std::string T)
{
    for(int i=0;i<N;i++)
        cout<<S[i]<<T[i];
    cout<<endl;
}

int main()
{
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

ll modpow(ll a, ll b){
  if(b == 0) return 1;
  if(b % 2){
    return a * modpow(a, b - 1) % MOD;
  }else{
    ll half = b / 2;
    half = modpow(a, half);
    return (half * half) % MOD;
  }
}

ll modfact(ll n){
  ll res = 1;
  rep(i, n) res = (res * (i + 1)) % MOD;
  return res;
}

ll modcomb(ll n, ll r){
  ll res = 1;
  rep(i, r) res = (res * (n - i)) % MOD;
  return (res * modpow(modfact(r), MOD - 2)) % MOD;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> v;
  ll ans = 1;
  rep(n, 2, 100000){
    if(M == 1) break;
    int num = 0;
    while(M % n == 0){
      M /= n;
      num++;
    }
    if(num){
      ans *= modcomb(num + N - 1, N - 1);
      ans %= MOD;
    }
  }
  if(M != 1){
    ans *= modcomb(N, N - 1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x


using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

int main() {
    int n;cin>>n;
    vector<ll> A(n);cin>>A;
    
    ll cnt=0;
    ll sum  =0;
    rep(i,n){
        
        if(A[i]==0){
            cnt+=sum/2;
            sum=0;
        }
        sum+=A[i];
        
    }
    
    cnt+=sum/2;
    
    cout<<cnt<<endl;
    
    return 0;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n;
ll x,a[100001];

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

	cin>>n>>x;
	REP(i,n) cin>>a[i+1];
	ll cnt=0;
	REP(i,n){
		if(a[i]+a[i+1]>x) {
			cnt+=(a[i+1]-(x-a[i]));
			a[i+1]=x-a[i];
		}
	}
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 1024
s = gets.chomp
k = gets.to_i
count = 0
flag = false

if s.split("").to_a.uniq.length == 1 && s.length % 2 == 1
  flag = true
end

c = 0
if s[0] == s[-1]
  (s.length / 2).times do |i|
    c += 1 if s[i] == s[0]
    c += 1 if s[s.length - 1 - i] == s[0]
  end
end

(1...s.length).each do |i|
  str_a = ("a".."z").to_a
  if s[i] == s[i - 1]
    str_a.delete(s[i - 1])
    i == (s.length - 1) ? str_a.delete(s[0]) : str_a.delete(s[i + 1])
    s[i] = str_a.pop
    count += 1
  end
end

if flag
  puts count * k + (k / 2)
elsif s[0] == s[-1] && c % 2 == 0
  puts count * k + (k - 1)
else
  puts count * k
end

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
int func(int j) {
	int tmp = j;
	int ans=1;
	tmp /= 10;
	while (tmp!=0) {
		ans++;
		tmp /=10;
	}
	return ans;
}

int main() {
	int N;
	int ans=0;
	cin >> N;
	for (int i = 1; i <=N; i++) {
		if (func(i) % 2 == 1) {
			ans++;
		}
	}
	cout << ans;
}
	


Measured memory_bytes: 3604
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    if (((B + A) % 3 == 0) || ((A % 3) == 0) || ((B % 3) == 0)) {
      System.out.println("Possible");
    } else {
      System.out.println("Impossible");
    }

  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int g[3][110];int n;
int num[3][110];
int dp(int x,int y){
    if(x==2&&y==n)return g[2][n];
    if(x>2||y>n)return 0;
    if(num[x][y])return num[x][y];
    num[x][y]=g[x][y];
    num[x][y]+=max(dp(x+1,y),dp(x,y+1));
    return num[x][y];
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            scanf("%d",&g[i][j]);
        }
    }
    cout<<dp(1,1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	char  s[n],a[n];
	cin>>s>>a;
	for(int i=0;i<n;i++){
		cout<<s[i];
		if(i<n){
			cout<<a[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p=0
for i in range(n):
  q=a[i]+a[i+1]
  if q<=b[i]:
    p+=q
    a[i]=a[i+1]=0
  else:
    p+=b[i]
    a[i+1]=min(a[i+1],a[i+1]+a[i]-b[i])
    a[i]=max(0,a[i]-b[i])
print(p)

Measured memory_bytes: 18624