akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int n;
  cin >> n;

  int mn = 0, mx = n,id = 0;
  string tmp;
  cout << 0 << endl;
  cout.flush();
  cin >> tmp;
  if(tmp == "Vacant") return 0;
  
  while(1){
    int mid = (mx+mn)/2;
    cout << mid << endl;
    cout.flush();

    string s;
    cin >> s;
    if(s == "Vacant") return 0;
    if((s==tmp) == (id%2 == mid%2)) mn = mid;
    else mx = mid;
  }

  return 0;
}

Measured memory_bytes: 884
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
    
a.sort()
b.sort()
if n%2==1:
    a_m = a[n//2]
    b_m = b[n//2]
    ans=max(b_m-a_m+1,0)
    print(ans)
else:
    a_m = (a[n//2]+a[n//2-1])
    b_m = (b[n//2]+b[n//2-1])
    ans = max(b_m-a_m+1,0)
    print(ans)
    



Measured memory_bytes: 25392
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
using namespace std;
int main() {
	int N;	cin >> N;
	vector<int> a(N);
	vector<int> isA(N);
	isA[0] = 1;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int ans = 0;
	int num = 1;
	for (int i = 0; i < N; ++i) {
		isA[num - 1] = 0;
		num = a[num - 1];
		isA[num - 1] = 1;
		++ans;
		if (isA[0] == 0 && isA[1] == 1) {
			cout << ans << endl;
			cin >> N;
			return 0;
		}
	}
	cout << "-1" << endl;
	cin >> N;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    a.append(list(input()))
for i in range(m):
    b.append(list(input()))
for y in range(n-m+1):
    for x in range(n-m+1):
        judge = True
        for i in range(m):
            for j in range(m):
                # print(y+i)
                # print(x+j)
                # print(a)
                if a[y+i][x+j] != b[i][j]:
                    judge = False
        if judge:
            print("Yes")
            exit()
print("No")


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n, r; cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
void ac(string &S,int x,vector<long long> &memo){
    if (S[x]=='C'&& S[x-1]=='A'){
        memo[x]+=1+memo[x-1];
    }
    else{
        memo[x]=memo[x-1];
    }
}
long long get(long long a,long long b,string &S,vector<long long>&memo){
    if(a==1){
        return memo[b-1];
    }
    if(S[a-1]=='C'&& S[a-2]=='A'){
        return memo[b-1]-memo[a-2]-1;
    }
    else{
        return memo[b-1]-memo[a-2];
    }
}

int main(){
    int N; cin>>N;
    int Q; cin>>Q;
    vector<long long> memo(N);
    string S; cin>>S;
    for(int i=1;i<N;i++)ac(S,i,memo);
    //cout<<"memohazime"<<endl;
    //for(int i=0;i<N;i++)cout<<memo[i]<<endl;
    //cout<<"memoowari"<<endl;
    for(int i=0;i<Q;i++){
        long long a,b;
        cin>>a>>b;
        cout<<get(a,b,S,memo)<<endl;
    }
}

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

int di[] = { 1, 1, 1, 0, 0,-1,-1,-1};
int dj[] = { 1, 0,-1, 1,-1, 1, 0,-1};


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

    int w,h;
    while(cin >> w >> h){
        if(!w && !h) break;

        int island[h][w];
        rep(i,h) rep(j,w) cin >> island[i][j];

        stack<P> stack;

        int ans = 0;
        rep(i,h) rep(j,w) {
            if(island[i][j] == 0) continue;
            ans++;
            stack.emplace(i,j);
            while(!stack.empty()){
                P p = stack.top(); stack.pop();
                int i = p.first, j = p.second;
                island[i][j] = 0;
                rep(dir,8){
                    int ni = i + di[dir];
                    int nj = j + dj[dir];
                    if(ni<0||ni>=h||nj<0||nj>=w) continue;
                    if(island[ni][nj] == 0) continue;
                    stack.emplace(ni,nj);
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
} 
  


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

using ll = long long;

class union_find {
public:
    union_find(int n) : par(n, -1) {}

    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

private:
    vector<int> par;
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> p(n);
    for(int i = 0; i < n; ++i) {
        cin >> p[i]; p[i]--;
    }

    union_find uf(n);
    for(int i = 0; i < m; ++i) {
        int x, y; cin >> x >> y;
        uf.unite(p[x - 1], p[y - 1]);
    }

    map<int, set<int>> vp;
    for(int i = 0; i < n; ++i) {
        vp[uf.root(p[i])].insert(p[i]);
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += vp[uf.root(p[i])].count(i);
    }

    cout << ans << endl;
}


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

int fun(vector<vector<int>> &vec,vector<bool> &visited,int k)
{
    int m=vec[0].size();
    int n=vec.size();
    int count=0;
    for(int i=0;i<visited.size();++i)
    {
        if(visited[i])
        count++;
    }
    //cout<<count<<endl;
    vector<vector<int>> temp(count+1,vector<int>(m,0));
    for(int j=0;j<m;++j)
    {int sum=0;
    int k1=0;
        for(int i=0;i<n;++i)
        {
            sum+=(vec[i][j]);
            
            if(i!=n-1)
            {
            if(visited[i])
            {
                temp[k1][j]=sum;
                //cout<<sum<<" ";
                sum=0;
                k1++;
            }
            }
            
        }
        temp[k1][j]=sum;
    }
    
    int max=INT_MIN;
    
    //cout<<k<<endl;
    int flag=0;
    int sum[count+1];
    memset(sum, 0, sizeof(sum)); 
    int y=0;
    int j=0;
    while(j<m)
    {
        int lo=j;
        int i=0;
        flag=0;
        while(lo<m)
        {
        flag=0;
        for(i=0;i<(count+1);++i)
        {
            sum[i]+=temp[i][lo];
            if(sum[i]>k)
            {
                memset(sum, 0, sizeof(sum)); 
                flag=1;
                break;
            }
        }
        if(flag==1)
        {
            break;
        }
        lo++;
        }
        if(flag==1)
        {
            if(lo==j)
            break;
            else
            {
            flag=0;
            j=lo;
            y++;
            }
        }
        else
        j=lo;
    }
    if(flag==1)
    return INT_MAX;
    else
    return y;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n,m,k;
	cin>>n>>m>>k;
	vector<string> vec1(n);
	for(int i=0;i<n;++i)
	{
	    cin>>vec1[i];
	}
	vector<vector<int>> vec(n,vector<int>(m,0));
	for(int i=0;i<n;++i)
	{
	    for(int j=0;j<m;++j)
	    {
	        vec[i][j] = vec1[i][j]-'0';
	        //cout<<vec[i][j]<<" ";
	    }
	}
	ll min=9999999999999ll;
	for(ll i=0;i<(1<<(n-1));++i)
	{
	    vector<bool> visited(n-1,false);
	    int count=0;
	    for(int j=0;j<(n-1);++j)
	    {
	        int temp=i&(1<<j);
	        if(temp)
	        {
	        visited[j]=true;
	        count++;
	        }
	    }
	    //cout<<count<<" ";
	    ll num=fun(vec,visited,k);
	    //cout<<num<<" "<<count<<endl;
	    num=num+count;
	    if(num<min)
	    min=num;
	    //cout<<min<<" ";
	}
	cout<<min<<endl;
}


Measured memory_bytes: 384
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n, k = map(int, input().split())

    ans = (n//k)**3
    if k%2 == 0:
        ans += ((n+k//2)//k)**3
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9092
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();
        int c = sc.nextInt();
        int d = sc.nextInt();


        if(Math.abs(a-c) <= d || ((Math.abs(a-b)<=d && (Math.abs(b-c)<=d)))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}


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

int main(){
    int N;
    cin>>N;
    int a[N][N];
    rep(i,N)rep(j,N)a[i][j]=-1;
    rep(i,N){
        int A;
        cin>>A;
        rep(j,A){
            int x,y;
            cin>>x>>y;
            a[i][x-1]=y;
        }
    }
    int ans=0;
    for(int bit=0; bit<(1<<N); ++bit){
        int flag=1;
        int cnt=0;
        rep(i,N){
            if(bit&(1<<i)){
                rep(j,N){
                    if(a[i][j]!=-1){
                        if(a[i][j]==1){
                            if(!(bit&(1<<j))){
                                flag=0;
                                break;
                            }    
                        }
                        if(a[i][j]==0){
                            if(bit&(1<<j)){
                                flag=0;
                                break;
                            }
                        }
                    }
                }
            }
            if(flag==0)break;
        }
        if(flag==1)cnt=__builtin_popcount(bit);
        if(flag==1&&cnt>ans)ans=cnt;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  string s;
  cin >> s;
  
  for(int i =0;i<s.size();i++){
    printf("%c", (s[i] + n) > 90 ? s[i]+n-26:s[i]+n);
  }
  cout << endl;
  return 0;
}

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

using namespace std;

int main(){
    long long n;cin>>n;
    vector<long long> v(n,0);
    long long xor_val=0;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        xor_val^=v[i];
    }
    for(int i=0;i<n;i++)
    {
        printf("%lld ",xor_val^v[i]);
    }
}

Measured memory_bytes: 4848
n, a, b = gets.chomp.split(" ").map(&:to_i)
winner = nil
alice_turn = true
while winner.nil?
    if alice_turn
        if b == 2
            winner = "Borys"
        elsif a + 1 != b
            a += 1
        else
            a -= 1
        end
    else
        if a == n - 1
            winner = "Alice"
        elsif b - 1 != a
            b -= 1
        else
            b += 1
        end
    end
    alice_turn = !alice_turn
end
puts winner

Measured memory_bytes: 1788
#include <iostream>
#include <string>

using namespace std;

void func_A() {

    int n;
    cin >> n;

    while (n > 0) {
        if (n % 10 == 7) {
            cout << "Yes";
            return;
        }

        n /= 10;
    }

    cout << "No";
}

void func_B() {

    unsigned long long n;
    cin >> n;

    unsigned long long sum = 0;
    for (unsigned long long i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) sum += i; 
    }

    cout << sum;
}

int gcd(int x, int y) {

    if (y == 0) return x;

    return gcd(y, x % y);
}

void func_C() {

    int k;
    cin >> k;

    int sum = 0;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    cout << sum;

}

void func_D() {

    int n;
    cin >> n;
    string s;
    cin >> s;

    int count = 0;

    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            if (s[i] == s[j]) continue;
            for (int k = j + 1; k < n; ++k) {
               // cout << "i:" << i << " j:" << j << " k:" << k << "\n";
                if (j - i == k - j) continue;
                if (s[j] != s[k] && s[k] != s[i]) ++count;
            }
        }
    }

    cout << count;
}

void func_Dfix() {
    
    int n;
    cin >> n;

    string s;
    cin >> s;

    /*
    まずは条件１を満たす組み合わせの総数を考える
    条件1はつまるところ'R'と'G'と'B'の組み合わせなので、
    (Rの総数)*(Gの総数)*(Bの総数)で求められる
    よって、文字列からRGBの数を求める
    */
    long long num_r = 0;
    long long num_g = 0;
    long long num_b = 0;
    for (auto c : s) {
        if (c == 'R') ++num_r;
        else if (c == 'G') ++num_g;
        else if (c == 'B') ++num_b;
       // else cout << "rgb以外を検出しました\n";
    }

    long long  ans = num_r * num_g * num_b;
    
    /*
    条件1を満たす組み合わせの総数を求めたので、
    条件２を満たさない組み合わせを引けば
    求めたい値が得られる
    条件２は　j-i != k - j
    すなわち　k != 2*j - i
    よってすべての(i,j)の組み合わせについて
    s[i],s[j],s[2*j-i] で条件１を満たすものを求める。
    （これが条件1を満たすが条件２を満たさない組み合わせ）

    k = 2 * j - i　を利用することによりO(N^2)で求めることができる
    */

    for (int i = 0; i < n-1; ++i) {
        for (int j = i+1; j < n; ++j) {
            int k = 2 * j -i;
            if (k >= n) continue;
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) --ans;
        }
    }

    cout << ans;



}

void func_E(){


}

int main()
{
    //func_A();
    //func_B();
    //func_C();
    //func_D();
    func_Dfix();
    //func_E();
    return 0;

}

Measured memory_bytes: 3612
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)


Measured memory_bytes: 14636
#include <stdio.h>{
  int max(int a,int b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }
  int min(int a,int b){
    if(a<b){
      return a;
    }
    else{
      return b;
    }
  }
  int main(void){
    int n,i;
    scanf("%d",&n);
    int r[n];
    for(i=0;i<n;i++){
    scanf("%d",&r[i]);
    }

    int maxv=-2000000000;
    int minv=r[0];
    for(i=1;i<n;i++){
      maxv=max(maxv,r[i]-minv);
      minv=min(minv,r[i]);
    }

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

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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = first[b]; ~a; a = edge[a].nxt)
#define GREP(a, b) for (register int& a = cur[b]; ~a; a = edge[a].nxt)

int a, b, c;

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

    printf ("%d\n", c - min(c, a - b));
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int N, temp;
    vector<int> d;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> temp;
        d.push_back(temp);
    }
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    cout << d.size() << endl;
}

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

int main(int argc, char* argv[]) {
  int A, B, K;
  std::cin >> A >> B >> K;
  int cnt = 0;
  for (int i = std::max(A, B); i >= 1; i--) {
    if (A % i == 0 && B % i == 0) {
      cnt++;
      if (cnt == K) {
        std::cout << i << std::endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


def gcd(a, b):
    """ Greatest Common Divisor(最大公約数) """
    while b:
        a, b = b, a % b
    return a


N = d_in()
A_list = ds_in()

cum_gcd = [A_list[0]]
for a in A_list[1:]:
    pre = cum_gcd[-1]
    cum_gcd.append(gcd(a, pre))

reverse = [A_list[-1]]
for a in A_list[-2::-1]:
    pre = reverse[-1]
    reverse.append(gcd(a, pre))

ans = max(reverse[-2], cum_gcd[-2])
for i in range(1, N-1):
    # i番目を抜かす
    ans = max(ans, gcd(cum_gcd[i-1], reverse[N-2-i]))

print(ans)


Measured memory_bytes: 14196
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.12lf\n", x)


signed main(void){
  int i, j, k;
  string s;
  for(int testcase = 0;getline(cin, s);testcase++){
    int head = 0;
    double stc[80] = {0.0};
    s += " ";
    for(i = 0;i < s.size();++i){
      if(s[i] == ' ')continue;
      else if(s[i] == '+'){
        head--;
        stc[head - 1] = stc[head - 1] + stc[head];
        i++;
      }else if(s[i] == '-'){
        if(s[i + 1] != ' '){
          double sum = 0.0;
          for(i++;i < s.size();i++){
            if(s[i] == ' ')break;
            sum *= 10.0;
            sum += (double)(s[i] - '0');
          }
          stc[head++] = -sum;
        }else{
          head--;
          stc[head - 1] = stc[head - 1] - stc[head];
          i++;
        }
      }else if(s[i] == '*'){
        head--;
        stc[head - 1] = stc[head - 1] * stc[head];
        i++;
      }else if(s[i] == '/'){
        head--;
        stc[head - 1] = stc[head - 1] / stc[head];
        i++;
      }else{
        double sum = 0.0;
        for(;i < s.size();i++){
          if(s[i] == ' ')break;
          sum *= 10.0;
          sum += (double)(s[i] - '0');
        }
        stc[head++] = sum;
      }
    }
    prid(stc[0]);
    s.clear();
  }
  return 0;
}

Measured memory_bytes: 1236
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long a = sc.nextLong();
			if (a <= 2) {
				System.out.println(2);
				return;
			}

			List<Integer> primeList = new ArrayList<>();
			primeList.add(2);

			for (int i = 3; i < 110000; i++) {
				boolean isPrime = true;
				for (int prime : primeList) {
					if (i % prime == 0) {
						isPrime = false;
						break;
					}
				}
				if (isPrime) {
					if (a <= i) {
						System.out.println(i);
						break;
					}
					primeList.add(i);
				}
			}
		}
	}
}


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

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

const ll N_MAX = 100100;
vector<ll> arr(N_MAX);


void Eratosthenes(){
	for(int i = 2; i < N_MAX; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N_MAX); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N_MAX; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
    //arr[i]=1が素数
}

int main() {
    ll N;
    cin >> N;
    Eratosthenes();
    ll ct=0;
    for(int i=2;ct<N;i++){
        if(arr[i]==1 && i%5==1){
            cout << i << " ";
            ct++;
        }
    }
    cout << endl;
    return 0;
}

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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  if(c*2>=a+b){
    cout << a*x+b*y << endl;
  }else{
    int k=min(x,y);
    x-=k;
    y-=k;
    cout << k*2*c+min(a*x+b*y,c*2*max(x,y)) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int r, d ,x ;
  cin >> r>>d >>x ;
  int res = r*x-d ;
  cout <<res<<endl ;
  for (int i=0 ; i<9 ;i++){
       res = res*r-d  ;
        cout <<res<<endl;

  }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int a = 0, b = 0;
  rep(i, N) if(S[i] == 'R') ++a;
  int ans = max(a, b);
  rep(i, N){
    if(S[i] == 'R') --a;
    else ++b;
    int now = max(a, b);
    ans = min(ans, now);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3744
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int N;
ll a[200003];

void input(){
  cin>>N;
  REP(i, N)cin>>a[i];
}

void solve(){
  ll r = 1000000000000000000, s = 0, t = 0;
  REP(i, N)s+=a[i];
  REP(i, N-1) {
    s -= a[i];
    t += a[i];
    r = min(r, abs(s-t));
  }
  cout<<r<<endl;
}

int main(){
  cin.tie(0);
  
  input();
  solve();
  
  return 0;
}


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

//最大公約数を求める関数
int64_t gcd(int64_t a, int64_t b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
//最小公倍数を求める関数
int64_t lcm(int64_t a, int64_t b){
    return a/gcd(a, b)*b;
}

int main(){
    int64_t a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	long long s;
	cin >> s;
	long long m = 1000000000;
	long long c;
	long long d = (s + m - 1) / m;
	if ((s + m - 1) / m != s / m) {
		c = m - s % m;
	}
	else {
		c = 0;
	}
	cout << "0 0 1000000000 1 " << c << " " << d << endl;
	return 0;
}

Measured memory_bytes: 256
""" スニペット """
def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split()))
""" スニペット """
import math
# 2つ選ぶ通り数を算出 nC2
def choose2(n):
    return n*(n-1)//2
# インプット
N = get_int()
An = get_ints()
""" 全ての要素から2つのボールを選ぶ通り数を求める """
uni = [0] * (N+1)
# ユニーク数の配列を求める
for i in range(N):
    uni[An[i]] += 1
sumWay = 0
# 各数値の2通りの選択通り数を足していく
for i in range(N + 1):
    sumWay += choose2(uni[i])
""" 全ての要素数 - 削除する要素の通り数 + 削除する要素を引いた際の通り数 を求める """
for i in range(N):
    print((sumWay - choose2(uni[An[i]]) + choose2(uni[An[i]]-1))) 



Measured memory_bytes: 33336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int fact(int n) {
	if (n == 0) return 1;
	else return n*fact(n-1);
}

int main() {
	int n, x[10], y[10];
	cin >> n;
	rep(i,n) cin >> x[i] >> y[i];
	double ans = 0;
	vector<int> num(n);
	rep(i,n) num[i] = i;
	do
	{
		for (int i = 0; i < n-1; i++)
		{
			int a = num[i], b = num[i+1];
			int d = (x[b]-x[a])*(x[b]-x[a])+(y[b]-y[a])*(y[b]-y[a]);
			ans += pow(d, 0.5);
		}
		
	} while (next_permutation(num.begin(), num.end()));
	ans /= fact(n);
	cout << fixed << setprecision(10);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4268
N,K=map(int,input().split())
lst=[N//K]*K
lst[0]-=1
ans=0
for i in range(N%K+1):
  lst[i]+=1
for r in range(1,K):
  v=lst[K-r]
  v2=lst[r]
  if (2*r%K)==0:
    ans+=v*(v2**2)
ans+=(lst[0]**3)
print(ans)   

Measured memory_bytes: 4596
package main

import (
	"bufio"
	"fmt"
	"os"
)

var H, W, K int
var grid []string

func main() {
	H, W, K = ReadInt(), ReadInt(), ReadInt()
	grid = make([]string, H)
	for i := 0; i < H; i++ {
		grid[i] = ReadString()
	}
	ans := 0
	for h := 0; h < 1<<H; h++ {
		for w := 0; w < 1<<W; w++ {
			if f(h, w) {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

func f(h, w int) bool {
	cnt := 0
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if (w>>x)&1 == 0 {
				continue
			}
			if (h>>y)&1 == 0 {
				continue
			}
			if grid[y][x] == '#' {
				cnt++
			}
		}
	}
	return cnt == K
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 1844
n = int(input())
a = list(map(int, input().split()))
check = 1

def judge(check):
  if check > 1e18:
    print(-1)
    exit()

if 0 in set(a):
  print(0)
  exit()

for num in a:
  check = check * num
  judge(check)
  
print(check)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<max({a+b,a-b,a*b})<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

template< typename T, typename E >
struct SegmentTree{
    using F = function< T(T, T) >;
    using G = function< T(T, E) >;
    int sz;
    vector<T> dat;
    F f;
    G g;
    T t1;
    SegmentTree(int n, F f, G g, T t1) : f(f), g(g), t1(t1) {
        sz = 1;
        while(sz < n) sz *= 2;
        dat.clear();
        dat.resize(2 * sz - 1, t1);
    }
    void set(int k, T x) { dat[k + sz - 1] = x; }
    void build() {
        for(int k = sz - 2; k >= 0; k--) {
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    void update(int k, E x) {
        k += sz - 1;
        dat[k] = g(dat[k], x);
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return t1;
        if(a <= l && r <= b) return dat[k];
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    T query(int a, int b){ return query(a, b, 0, 0, sz); }
    T operator[](int k) { return dat[k + sz - 1]; }
};

vector<vector<int> > split_vector(vector<int> &a, int pivot){
    vector<vector<int> > res;
    a.push_back(pivot);
    for(int i = 0; i < a.size(); i++){
        vector<int> tmp;
        while(i < a.size() && a[i] != pivot){
            tmp.push_back(a[i++]);
        }
        if(tmp.size() != 0) res.push_back(tmp);
    }
    a.pop_back();
    return res;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];
    SegmentTree<int, int> rmq(n,
        [](int a, int b){ return min(a, b); },
        [](int a, int b){ return b; },
        INT_MAX);
    SegmentTree<int, int> RMQ(n,
        [](int a, int b){ return max(a, b); },
        [](int a, int b){ return b; },
        -1);
    rep(i, 0, n){
        rmq.update(i, p[i]);
        RMQ.update(i, p[i]);
    }
    int ans = 1;
    for(int i = 0; i < n - k; i++){
        // [i, i + k) と [i + 1, i + k + 1) が同じかどうか
        // p[i] = rmq[i, i + k) and p[i + k] = RMQ[i + 1, i + k + 1)
        if(p[i] == rmq.query(i, i + k) && p[i + k] == RMQ.query(i + 1, i + k + 1)) continue;
        ans++;
    }
    // ソート済みかどうか
    vector<int> a(n), b(n - k + 1);
    rep(i, 0, n - 1){
        if(p[i] > p[i + 1]) a[i] = 1;
    }
    int tmp = 0;
    rep(i, 0, k - 2) tmp += a[i];
    for(int i = 0; i < n - k + 1; i++){
        tmp += a[i + k - 2];
        // cout << i << ' ' << tmp << endl;
        if(tmp == 0) b[i] = 1;
        tmp -= a[i];
    }
    vector<vector<int> > c = split_vector(b, 0);
    if(c.size()) ans -= c.size() - 1;
    cout << ans << endl;
}

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

using namespace std;

long long n;
long long a[1000010];

int main()
{
	cin>>n;
	long long i,j;
	for (i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	i=n;
	long long x=-100,y=-100;
	for (i=n;i>=1;i--)
		if (a[i]==a[i-1]){
			x=a[i];
			break;
		}
	for (i-=2;i>=1;i--)
		if (a[i]==a[i-1]){
			y=a[i];
			break;
		}
	if (x==-100 || y==-100)
		cout<<0<<endl;
	else 
		cout<<x*y<<endl;
	return 0;
}

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

int year,month,day;

inline int Rd() {
	
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1;ch=getchar(); }
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main() {

	year=Rd(),month=Rd(),day=Rd();
	
	if(year<=2019) {
		if(month<=4) {
			if(day<=30) puts("Heisei");
			else puts("TBD");
		}
		else puts("TBD");
	}
	else puts("TBD"); 
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut c: Vec<(i64, i64)> = vec![];

    for _ in 0..m {
        let a = read();
        let b = read();
        c.push((a, b));
    }

    c.sort_by_key(|x| x.1);
    // println!("{:?}", c);
    //
    //
    let mut head = 0;
    let mut cnt = 0;
    for i in 0..c.len() {
        let ci = c[i];
        if ci.0 >= head {
            cnt += 1;
            head = ci.1
        }

    }
    println!("{}", cnt);
}


Measured memory_bytes: 6396
#include <algorithm>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;

void solve(long long N, std::string S){
    int count = 0;
    for (int i = 0; i < S.size() - 2; i++) {
        if (S.substr(i, 3) == "ABC") count++;
    }
    print(count);
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

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

int main(){
    double L;
    cin >> L;
    double x, y, z;
    x = L/3, y = L/3, z = L/3;
    double ans = x * y * z;
    printf("%.7f\n", ans);
    return 0;
}

Measured memory_bytes: 3788
fn main(){
  let s: String = read();
  let w: usize = read();

  let ans: String = s.chars().enumerate().filter_map(|(i, c)| if i % w == 0 {Some (c)} else {None}).collect();
  println!("{}", ans);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,c,d;cin>>a>>b>>c>>d;
  if(a*b>c*d){
    P(a*b);
  }else{
    P(c*d);
  }
  return 0;
}


Measured memory_bytes: 256
n,x,y=map(int,input().split())
x-=1
y-=1
ans=[0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        s=abs(x-i)+1+abs(y-j)
        d=min(j-i,s)
        ans[d-1]+=1 
for i in range(n-1):
    print(ans[i])

Measured memory_bytes: 3444
using System;
using System.Linq;
namespace AtCoder {
    class Program {
        static void Main(string[] args) {
            var head = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = head[0];
            var B = head[1];
            var C = head[2];
            Console.WriteLine(Math.Max(0, C - A + B));
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
const int N=300010,mod=1e9+7,lim=N-10;
int n,m;
int pr[N],np[N],tot,fac[N],inv[N];
int qp(int x,int k)
{
	int res=1;
	for(;k;k>>=1,x=1ll*x*x%mod)
		if(k&1)res=1ll*res*x%mod;
	return res;
}
void getprime()
{
	for(int i=2;i<=lim;i++)
	{
		if(!np[i])
			pr[++tot]=i;
		for(int j=1;j<=tot && i*pr[j]<=lim;j++)
		{
			np[i*pr[j]]=1;
			if(i%pr[j])break;
		}
	}
	fac[0]=inv[0]=1;
	for(int i=1;i<=lim;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[lim]=qp(fac[lim],mod-2);
	for(int i=lim-1;i;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int C(int a,int b)
{
	if(a<b)return 0;
	return 1ll*fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
	scanf("%d%d",&n,&m);
	getprime();
	int cnt;
	long long ans=1;
	for(int i=1;i<=tot;i++)
		if(m%pr[i]==0)
		{
			cnt=0;
			while(m%pr[i]==0)m/=pr[i],cnt++;
			ans=ans*C(n+cnt-1,n-1)%mod;
		}
	if(m!=1)ans=ans*n%mod;
	printf("%lld\n",ans);
	return 0;
}


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

const int MAX = 1000000;
int cnt[MAX];
bool isCmp[MAX] = {true};


int main() {
    ios::sync_with_stdio(false);
    int n;
    cnt[1] = 0;
    for(int i = 2; i < MAX; i++){
      if(! isCmp[i]){
        for(int j = 2; i*j < MAX; j++){
          isCmp[i*j] = true;
        }
      }
      cnt[i] = cnt[i-1] + !isCmp[i];
    }

    while(cin >> n){
      cout << cnt[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 6076
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T> & v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	int ans = 0;
	int n;
	vi v(5);
	while (cin >> n) {
		++v[n];
	}
	for (int x : v) {
		ans += x % 2;
	}
	YN(ans <= 2);
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        mut ab: [(usize1, usize1); m],
    }
    ab.sort_by(|x,y|{
        x.1.cmp(&y.1)
    });
    // println!("{:?}", ab);
    let mut ans = 0;
    let mut end = 0;
    for i in 0..m {
        if ab[i].0 >= end {
            end = ab[i].1;
            ans+=1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
//***___********* ___*****___****___***___*********//
/*  |   \  |   | |   |   |   \  |     |     |   |  **
/*  |   |  |   | |___|   |   _  |__   |___  |___|  **
/*  |   |  |   | |   \   |  | | |         | |   |  **
/*  |___/  |___| |    \  |__| | |___  ____| |   |  **
//*************************************************/
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<long long>
#define mii map<int,int>
#define pii pair<int,int>
#define set_zero(arr) memset(arr,0,sizeof(arr))
#include <ext/pb_ds/tree_policy.hpp>
#define forn(i,n) for(int i=0;i<(n);i++)
#include <ext/pb_ds/assoc_container.hpp>
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define TEST_CASE   int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
bool check(int n){
    int cnt = 0;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}

vi tre[100000];

bool ans = true;
bool vis[100000] = { false };
void dfs(int s){
    vis[s]=true;
    if(tre[s].size()>1){
        int cnt = 0;
        for(int i=0;i<tre[s].size();i++){
            int child = tre[s][i];
            if(tre[child].size()==1){
                cnt++;
            }
        }
        if(cnt<3){
            ans=false;
        }
    }
    for(int i=0;i<tre[s].size();i++){
        if(vis[tre[s][i]]==false)
            dfs(tre[s][i]);
    }
}
void solve(){
 string str;
 cin>>str;
 if(str == "AAA"||str =="BBB")
    cout<<"No"<<endl;
 else
    cout<<"Yes"<<endl;
}


int main(){
   //TEST_CASE
   solve();
return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator
const int MxN = 1e5+1;
int ar[MxN];

void solve() {
    int n;cin>>n;
    for(int i=0;i<n;i++) {
        cin>>ar[i];
    }
    sort(ar, ar+n);
    int a=0,b=0;
    for(int i=n-2;i>=0;i--) {
        if(a==0) {
            if(ar[i]==ar[i+1]) {
                a=ar[i];
                i--;
            }
        } else if(b==0) {
            if(ar[i]==ar[i+1]) 
                b=ar[i];
        } else
            break;
    }
    cout << 1LL * a*b <<endl;
}

int main() {
    solve();
    return 0;
}

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

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

  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A.at(i));
    A.at(i) = A.at(i) - (i + 1);
  }

  sort(A.begin(), A.end());
  int b = A.at(N / 2);

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (long long)abs(A.at(i) - b);
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void){
  char s[2][100001];
  int i,j,count[2];
  scanf("%s",s[0]);
  strcpy(s[1],s[0]);
  
  for(j=0;j<2;j++){
    if(j==1){
      if(s[j][0]=='0') s[j][0]='1';
      else s[j][0]='0';
      count[j]++;
    }
   for(i=1;i<100001;i++){
    if(s[j][i]!='\0'){
      if(s[j][i-1]==s[j][i]){
      	count[j]++;
        if(s[j][i]=='0') s[j][i]='1';
        else s[j][i]='0';
      }
    }else break;
   }
  }
  
  if(count[0]<=count[1]) printf("%d",count[0]);
  else printf("%d",count[1]);
  
  
  return 0;
}

Measured memory_bytes: 384
from collections import defaultdict

def factorize(n):
    factors = []
    
    for i in range(2, int(n**0.5)+1):
        cnt = 0
        
        while n%i==0:
            n //= i
            cnt += 1
            
        if cnt>0:
            factors.append((i, cnt))
    
    if n!=1:
        factors.append((n, 1))
    
    return factors
    
def inv(x):
    return pow(x, MOD-2, MOD)
    
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7
M = defaultdict(int)

for Ai in A:
    factors = factorize(Ai)
    
    for v, c in factors:
        M[v] = max(M[v], c)
    
L = 1

for v, c in M.items():
    L *= pow(v, c, MOD)
    L %= MOD

ans = 0

for Ai in A:
    ans += L*inv(Ai)
    ans %= MOD

print(ans)

Measured memory_bytes: 46940