akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    ll ans = 0LL;
    for(ll i=1;i<=n;++i) {
        ans += (n/i) * (n/i + 1) / 2  * i;
    }

    cout << ans << endl;
}


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


int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  vector<int> c(n);
  vector<int> d(n);
  rep(i,n) cin>>v[i];
  rep(i,n) cin>>c[i];
  rep(i,n){
    d[i]=v[i]-c[i];
  }
  sort(d.begin(),d.end(),greater<int>());
  int ans=0;
  rep(i,n){
    if(d[i]>0) ans += d[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int i, count_1 = 0, count_2 = 0;
	int n[3];
	
	scanf("%d%d%d", &a, &b, &c);
	if(a + b + c == 17) {
		n[0] = a;
		n[1] = b;
		n[2] = c;
		for( i = 0; i < 3; i++) {
			if(n[i] % 7 == 0) {
				count_1++;
			}
			if(n[i] % 5 == 0) {
				count_2++;
			}
		}
		if(count_1 == 1 && count_2 == 2) {
			printf("YES");
		}
		else {
			printf("NO");
		}
	}
	else {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    
    vector<int> p(m),y(m),num(m,0);
    typedef std::pair<int, int> pair;
    vector<pair> py(m);
    
    
    for(int i=0;i<m;i++){
        cin >> p[i] >> y[i];
        py.at(i) = pair(p[i],y[i]);
    }
    std::vector<int> index(py.size());
    std::iota(index.begin(), index.end(), 0);
    
    std::sort(
        index.begin(),
        index.end(),
        [&](int x, int y){return py[x].second < py[y].second;}
    );
    
    vector<int> pnum(*max_element(p.begin(),p.end())+1,0);

    for(auto& i:index){
        pnum.at(py[i].first)++;
        num[i] = pnum[py[i].first];
    }
    
    for(int i=0;i<m;i++){
        printf("%06d",py.at(i).first);
        printf("%06d\n",num[i]);
    }
    
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  vt<int> a(n);

  int num = 0, fi = 0;
  rep(i,n) {
    std::cin >> a[i];
    if(fi <= a[i]) {
      num = i;
      fi = a[i];
    }
  }

  sort(a.begin(),a.end());
  rep(i,n) {
    if(i == num)
      std::cout << a[n-2] << '\n';
    else
      std::cout << fi << '\n';
  }
  return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<map>
#include<unordered_map>
#include<set>
#include<algorithm>
#include <cstdlib>
#include<unordered_set>
#include<cmath>
#include<list>
#include<functional>
#include<cmath>
#include <iostream>
#include <fstream>
using namespace std;

int main() {
	int n;
	int len;
	cin >> n>>len;
	vector<string> segs;
	for (int i = 0; i < n; i++) {
		string seg;
		cin >> seg;
		segs.push_back(seg);
	}
	sort(segs.begin(), segs.end());
	string res;
	for (string seg : segs) {
		res += seg;
	}
	cout << res<< endl;
	return 0;
}


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

using namespace std;


int main(int argc, char const *argv[])
{
    /* code */
    int h, w;
    cin >> h >> w;
    vector<vector<char> > a(h, vector<char>(w, 0));
    vector<bool> row_flg(h, false);
    vector<bool> col_flg(w, false);
    for (auto i=0;i<h;++i) {
        for(auto j=0;j<w;++j) {
            cin >> a[i][j];
            if (a[i][j] == '#') {
                row_flg[i] = true;
                col_flg[j] = true;
            }
        }
    }

    for(auto i=0;i<h;++i) {
        if (row_flg[i]) {
            for(auto j=0;j<w;++j) {
                if(col_flg[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}


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

int main()
{
  string S, T;
  cin>>S>>T;
  int len, count=0;
  len=S.length();
  for(int i=0; i<len; i++)
  {
    if(S[i]==T[i])
      continue;
    else
      count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl

void solve() {
  ll n;
  cin >> n;
  ll p = 100, year = 0;
  while (p < n) {
    p += p / 100;
    year++;
  }
  cout << year << '\n';
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll test = 1;
  // cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3628
#include "cstdio"
#include "math.h"
#include <vector>

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<int> arr(n);

	int origin = (int)(ceil((float)n / 2)) - 1;
	int expand = 0;
	bool even = n % 2 == 0;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		if (i % 2 == 0) {
			if (even) {
				arr[origin - expand] = a;
			} else {
				arr[origin + expand] = a;
			}
		} else {
			expand++;
			if (even) {
				arr[origin + expand] = a;
			} else {
				arr[origin - expand] = a;
			}
		}
	}
	std::reverse(arr.begin(), arr.end());
	for (int i = 0; i < n; i++){
		printf("%d ", arr[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll c;
struct node
{
	ll v;
	ll x;
};
node a[maxn];
ll shun[maxn];
ll ni[maxn];
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	gbtb;
	cin>>n>>c;
	repd(i,1,n)
	{
		cin>>a[i].x>>a[i].v;
	}
	ll ans=0ll;
	repd(i,1,n)
	{
		shun[i]=shun[i-1]+a[i].v-(a[i].x-a[i-1].x);
	}
	repd(i,1,n)
	{
		shun[i]=max(shun[i-1],shun[i]);
	}
	a[n+1].x=c;
	for(int i=n;i>=1;i--)
	{
		ni[i]=ni[i+1]+a[i].v-(a[i+1].x-a[i].x);
	}
	for(int i=n;i>=1;i--)
	{
		ni[i]=max(ni[i],ni[i+1]);
	}
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,shun[i]);
		ans=max(ans,ni[i]);
		ans=max(ans,shun[i]-a[i].x+ni[i+1]);
		ans=max(ans,ni[i]-(c-a[i].x)+shun[i-1]);
	}	
	cout<<ans<<endl;
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second

string arr[1003];

int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	int m, n, x1, y1, x2, y2;	cin>>m>>n; 
	cin>>x1>>y1;	cin>>x2>>y2;
	x1--, y1--, x2--, y2--;
	
	int inf = INT_MAX - 100;
	vector<vector<int>> dist(m, vector<int>(n, inf));
	
	for(int i=0; i<m; i++)	cin>>arr[i];
	
	int ans = -1, f = 0;
	
	deque<pair<int, pair<int,int>>> Q;
	dist[x1][y1] = 0;
	Q.push_front({0, {x1, y1}});
	pair<int, pair<int,int>> temp;
	
	while(!Q.empty()) {
		temp = Q.front();	Q.pop_front();
		
		if(temp.s.f == x2 && temp.s.s == y2) {
			ans = temp.f;
			break;
		}
		
		int dir[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};

		for(int i=0; i<4; i++) {
			int r = temp.s.f + dir[i][0], c = temp.s.s + dir[i][1];
			
			if(r >= 0 && c >= 0 && r < m && c < n && arr[r][c] != '#')
				if(dist[r][c] > dist[temp.s.f][temp.s.s]) {
					dist[r][c] = dist[temp.s.f][temp.s.s];
					
					Q.push_front({dist[r][c], {r, c}});
				}
		}
		
		for(int i=-2; i<=2; i++) for(int j=-2; j<=2; j++) {
			if(abs(i) + abs(j) == 1) continue;
			
			int r = temp.s.f + i, c = temp.s.s + j;
			
			if(r >= 0 && c >= 0 && r < m && c < n && arr[r][c] != '#')
				if(dist[r][c] > 1 + dist[temp.s.f][temp.s.s]) {
					dist[r][c] = 1 + dist[temp.s.f][temp.s.s];
					
					Q.push_back({dist[r][c], {r, c}});
				}
		}	
		
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 8896
#include <iostream>
#include <string>
using namespace std;
 
int main(void){
    int X = 0, Y = 0;
    cin >> X >> Y;
    
    int ans = 0;
    
    if(X == 1){
        ans += 300000;
    } else if (X == 2) {
        ans += 200000;
    } else if (X == 3) {
        ans += 100000;
    }

    if(Y == 1){
        ans += 300000;
    } else if (Y == 2) {
        ans += 200000;
    } else if (Y == 3) {
        ans += 100000;
    }
    
    if( X == 1 && Y == 1) ans += 400000;
    
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define all(x) (x).begin(), (x).end()

const int INF = 1e9;
int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, -1, 1, 0};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    rep(i, 0, h) cin >> s[i];

    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pii> dq;
    dq.emplace_back(ch, cw);
    dist[ch][cw] = 0;

    while (!dq.empty()) {
        int x = dq.front().first;
        int y = dq.front().second;
        dq.pop_front();

        if (x == dh && y == dw) break;
        rep(i, 0, 4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (dist[nx][ny] > dist[x][y]) {
                if (s[nx][ny] != '#') {
                    dist[nx][ny] = dist[x][y];
                    dq.emplace_front(nx, ny);
                }
            }
        }
        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                int nx = x + i;
                int ny = y + j;
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if (dist[nx][ny] > dist[x][y] + 1) {
                    if (s[nx][ny] != '#') {
                        dist[nx][ny] = dist[x][y] + 1;
                        dq.emplace_back(nx, ny);
                    }
                }
            }
        }
    }

    int ans = dist[dh][dw];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	if(s == "ABC"){
		cout << "ARC" << endl;
	}else{
		cout << "ABC" << endl;
	}
    return 0;
}



Measured memory_bytes: 3548
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll  long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
// #define max INT_MAX
ll int count(ll int n)
{
    int sz=0;
    while(n>0)
    {
        sz++;
        n /=10;
    }
    return sz;
}
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    ll int n,ans;
    cin >> n;
    for(ll int i=1;(i*i)<=n;i++)
    {
        if(n%i==0)
        {
            ans = max(count(i),count(n/i));
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int M,T,P,R;
int kan[55][15];
int ac[55][15];
int wa[55][15];

signed main(){
	vector<string>ans;
	while(cin>>M>>T>>P>>R,M||T||P||R){
		int m,t,p,j;
		memset(ac,0,sizeof(ac));
		memset(wa,0,sizeof(wa));
		memset(kan,0,sizeof(kan));
		REP(i,R){
			cin>>m>>t>>p>>j;
			t--;p--;
			if(j){
				if(ac[t][p])continue;
				wa[t][p]++;
			}else{
				if(ac[t][p])continue;
				ac[t][p] = m;
				kan[t][p]++;
			}
		}
		vector<pair<pair<int,int>,int>>score(T,{{0,0},0});
		REP(i,T)score[i].second = i+1;
		REP(i,T){
			REP(j,P){
				if(kan[i][j]==0)continue;
				score[i].first.first++;
				score[i].first.second -= ac[i][j] + wa[i][j] * 20;
			}
		}
		sort(ALL(score));
		string ret = "";
		RREP(i,T){
			ret+=to_string(score[i].second);
			if(i!=0){
				if(score[i].first==score[i-1].first){
					ret+='=';
				}else{
					ret+=',';
				}
			}
		}
		ans.push_back(ret);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 3304
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,k,s,a[25];
int main()
{
	scanf("%d",&n);
	for (int i=0;i<=20;i++)
		if (n&(1<<i)) k++,a[k]=i;
	printf("%d %d\n",a[k]+1,a[k]+a[k]+k-1);
	for (int i=1;i<a[k]+1;i++)
	{
		printf("%d %d %d\n",i,i+1,0);
		printf("%d %d %d\n",i,i+1,(1<<(i-1)));
	}
	s=(1<<a[k]);
	for (int i=k-1;i>=1;i--)
	{
		printf("%d %d %d\n",a[i]+1,a[k]+1,s);
		s|=(1<<a[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
char a[200010];
ll num[100];
ll len;
ll ans;
int main(){
	scanf("%s",a);len=strlen(a);
	int i,j;
	for(i=0;i<len;++i){
		num[a[i]-'a']++;
	}
	for(i=0;i<=26;++i){
		ans+=num[i]*(num[i]-1)/2;
	}
	printf("%lld\n",len*(len-1)/2-ans+1);
	return 0;
}

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


  
int main(){
    int h,w;
    int mod=1e9+7;
    cin>>h>>w;
    vector<string> a(h);
    rep(i,h){
        cin>>a[i];
    }
    int dp[1001][1001];
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='.'){
                if(i==0){
                    if(j!=0){
                        (dp[i][j]+=dp[i][j-1])%=mod;
                    }
                }else if(j==0){
                    (dp[i][j]+=dp[i-1][j])%=mod;
                }else{
                    (dp[i][j]+=dp[i-1][j]+dp[i][j-1])%=mod;
                }    
            }else{
                dp[i][j]=0;
            }
            
        }
    }
    
    cout<<dp[h-1][w-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 5248
//ITP1-1-C:Rectangle
//17D8101001H 伊東 優生 ID:C_17D8101001H C++

#include <iostream>
#include <string>

using namespace std;

int main(void) {

  double a, b;
  cin >> a >> b;

  double area = a * b;
  double len = 2 * (a + b);

  cout << area << " " << len << endl;
  return 0;
}

/* 実行結果:
$ ./ITP_1_1_C
3 5
15 16

$ ./ITP1_1_C
4.5 9
40.5 27
*/


Measured memory_bytes: 3260
import math
if __name__ == "__main__":
    n, p = map(int, input().split())
    if n == 1:
        print(p)
    else:
        res = 1
        sup = math.ceil(p ** (1 / n))
        i = 2
        while(i <= sup and i <= p):
            if p % i == 0:
                k = 1
                p /= i
                while(p % i == 0):
                    p /= i
                    k += 1
                if k >= n:
                    for s in range(k // n):
                        res *= i
            i += 1
        print(res)

Measured memory_bytes: 3188
# C - pushpush
n = int(input())
a = list(map(str,input().split()))

b = [""]*n
var = 0

if n % 2 == 0:
    for i in range(n):
        res = a[i]
        var += i*(-1)**i
        ind = n//2 + var
        b[ind] = res
else:
    for i in range(n):
        res = a[i]
        var += i*(-1)**i
        ind = n//2 - var
        b[ind] = res

ans = " ".join(b)
print(ans)


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return 0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

struct mcount {
  vector<mint> fact;  // n! (mod MOD)
  vector<mint> ifact; // k!^{M-2} (mod MOD)
  mcount(int n) : fact(n + 1), ifact(n + 1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint perm(int n, int k) { // nPk (mod MOD)
    if (k < 0 || n < k) return 0;
    return fact[n] * ifact[n - k];
  }
  mint comb(int n, int k) { // nCk (mod MOD)
    dump(n, k);
    if (k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

mint nCr(int n, int k) {
  static vector<mint> fact(1, 1); // n! (mod MOD)
  if (k < 0 || n < k) return 0;
  int pn = fact.size();
  if (pn < n + 1) {
    fact.resize(n + 1);
    for (int i = pn; i <= n; i++) fact[i] = fact[i - 1] * i;
  }
  return fact[n] * fact[k].inv() * fact[n - k].inv();
}

// mint nCr(int n, int r) {
//   if (n < 0 || r < 0 || n < r) return 0;
//   if (r == 0) return 1;
//   if (r > n - r) r = n - r;
//   return (nCr(n - 1, r - 1) + nCr(n - 1, r));
// }

void solve() {
  int n, m;
  cin >> n >> m;
  mint ans = 1;
  map<ll, int> prime;
  mcount mc(100050);
  for (ll i = 2; i * i <= m; i++) {
    while (m % i == 0) {
      prime[i]++;
      m /= i;
    }
  }
  if (m != 1) prime[m] = 1;
  for (auto p : prime) {
    // ans *= mc.comb(n + p.second - 1, n - 1);
    ans *= nCr(n + p.second - 1, n - 1);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3456
A, B, C, K = map(int, input().split())

point = 0

for card, card_point in [(A, 1), (B, 0), (C, -1)]:
    if K == 0:
        break
    if K >= card:
        point += card_point * card
        K -= card
    else:
        point += card_point * K
        K = 0


print(point)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll x , y , s;
ll a,b;
bool solve(){
	cin >> x >> y >> s;
	if(x + y + s == 0)return false;
	ll ans = 0;
	for(a=1;a<s;a++){
		for(b=1;b<s;b++){
			ll na,nb,ma,mb;
			na = (100 + x)  * a / 100;
			nb = (100 + x) * b / 100;
			ma = (100 + y ) * a / 100;
			mb = (100 + y) * b / 100;
			if(na + nb == s)ans = max(ans,ma+mb);
		}
		
	}
	cout << ans << endl;
	return true;
}
int main(){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,n,i,x;
    vector<int>v;

    cin>>k>>n;
    x=n;

    for(i=0;i<k-1;i++)
    {
        v.push_back(--x);
    }

    for(i=0;i<k;i++)
    {
        v.push_back(n++);
    }

    sort(v.begin(),v.end());

    for(i=0;i<v.size();i++)
        cout<<v[i]<<" ";

    cout<<endl;


    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
  sort(ALL(c));
  ll ans = 0;
  REP(i,0,N-1) ans += c[i];
  cout << ans << endl;
  vvi g(N);
  rep(i,N-1){
    int ah,bh; ah = a[i]-1; bh = b[i]-1;
    g[ah].pb(bh);
    g[bh].pb(ah);
  }
  vl rank(N,-1);
  rank[0] = 1;
  function<void(int)> dfs = [&](int u){
    for(auto v:g[u]){
      if(rank[v]!=-1) continue;
      rank[v] = rank[u]+1;
      dfs(v);
    }
  };
  dfs(0);
  dump(rank);
  vi idx(N);
  iota(ALL(idx),0);
  sort(ALL(idx),[&](int lhs,int rhs){return rank[lhs]>rank[rhs];});
  vi res(N);
  rep(i,N){
    res[idx[i]] = c[i];
  }
  rep(i,N) cout << res[i] << (i!=N-1?" ":"\n");
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N-1);
  std::vector<long long> b(N-1);
  for(int i = 0 ; i < N-1 ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  std::vector<long long> c(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&c[i]);
  }
  solve(N, std::move(a), std::move(b), std::move(c));
  return 0;
}


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

int d[100], a[100];
map<vector<int>, int>id;
vector<int>re[5040];
int dp[100][5040];

int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, n)scanf("%d", &a[i]);
	vector<int>v(7); iota(v.begin(), v.end(), 0);
	int p = 0;
	do {
		id[v] = p; re[p] = v;
		int cnt = 0, t = 0;
		for (int i : v) {
			rep(j, 7) {
				if ((t >> j & 1) && abs(j - i) <= d[j])cnt += a[j];
			}
			t |= 1 << i;
		}
		dp[0][p] = cnt;
		p++;
	} while (next_permutation(v.begin(), v.end()));
	int ans = 0;
	for (int i = 1; i + 6 < n; i++)rep(j, 5040) {
		rep(k, 8) {
			auto t = re[j].begin();
			int cnt = 0, p = 0, o = 0;
			vector<int>q(7);
			rep(l, 8) {
				if (k == l) {
					rep(y, 8) {
						if ((p >> y & 1) && y + d[i - 1 + y] >= 7)
							cnt += a[i - 1 + y];
					}
					p |= 1 << 7; q[o++] = 6;
				}
				else {
					if ((p >> 7 & 1) && 7 - d[i + 6] <= *t)cnt += a[i + 6];
					p |= 1 << *t;
					if (*t)q[o++] = *t - 1;
					t++;
				}
			}
			int v = id[q];
			dp[i][v] = max(dp[i][v], dp[i - 1][j] + cnt);
			ans = max(ans, dp[i][v]);
		}
	}
	printf("%d\n", ans);
}

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

using namespace std;

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

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

  int ans = 1, count = 1;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] < a[i]) count++;
    else if (a[i - 1] > a[i]) count = 1;
    ans = max(ans, count);
  }

  count = 1;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] > a[i]) count++;
    else if (a[i - 1] < a[i]) count = 1;
    ans = max(ans, count);  
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

long long pref[int(2e5 + 5)];

int main () { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
	int n, k;
	long long a, p = 0;
	map <int, int> mp;
	mp[0] = 1;
	long long ans = 0;
	cin >> n >> k;
	for (int i = 1 ; i <= n ; ++ i) {
		cin >> a;
		p += a - 1;
		if (i - k >= 0) {
			mp[pref[i - k] % k]--;
		}
		ans += mp[p % k];
		mp[p % k]++;
		pref[i] = p;
	}
	cout << ans;
}


Measured memory_bytes: 11264
N,M = map(int,input().split())
KS = [list(map(int,input().split())) for i in range(M)]
P = list(map(int,input().split()))

def Bit(x,N):
    bit = [0 for _ in range(N)]
    for i in range(N):
        if x - 2**(N-i-1) >= 0:
            bit[i] = 1
            x -= 2**(N-i-1)
    return bit

def judge(a,N):
    bit = Bit(a,N)
    LB= [P[i] for i in range(M)]
    for i in range(N):
        if bit[i] == 1:
            for j in range(M):
                if i+1 in KS[j][1:len(KS[j])]:
                    LB[j] += 1
                    LB[j] %= 2
    if sum(LB) == 0:
        return True
    else:
        return False

count = 0
for i in range(2**N):
    if judge(i,N):
        count += 1
print(count)


Measured memory_bytes: 3188
X, Y = map(int, input().split())
count = 0
ans = 0

for i in range(X+1):
    count = 2*i + 4*(X-i)
    if(count == Y):
        ans = 1
        break
    else:
        ans = 2

if(ans == 1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

ans = 0
bef = N+1
for now in A:
    now -= 1
    ans += B[now]
    if bef + 1 == now:
        ans += C[bef]
    bef = now
print(ans)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// --------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S,T;
  cin >> S >> T;
  int ans = inf;
  for(int i=0; i+T.size()<=S.size(); i++){
    int cnt = 0;
    for(int j=0; j<T.size(); j++){
      if(S[i+j] != T[j]) cnt++;
    }
    chmin(ans,cnt);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n = (int)s.length();
	ll result = 0;
	ll cnt = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		if (s[i] == 'B')
		{
			result += n - 1 - cnt - i;
			cnt++;
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	switch (n % 10)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9: cout << "hon"; break;
	case 0:
	case 1:
	case 6:
	case 8: cout << "pon"; break;
	case 3: cout << "bon";

	}
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}



Measured memory_bytes: 3664
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int a,b,c,d,e,f;

int main(){
	cin>>a>>b>>c>>d>>e>>f;
	cout<<((a+5*b+10*c+50*d+100*e+500*f>=1000)?1:0)<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll=long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll t[110];
int main(){
  ll n,tmp=0;
  cin>>n;
  rep(i,0,n)cin>>t[i];
  tmp=t[0];
  rep(i,1,n){tmp/=GCD(tmp,t[i]);tmp*=t[i];}
  cout<<tmp;
}


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

int main() {
  int N;
  cin >> N;
  int time = 0;
  vector<int> next(N);
  for(int i = 0;i < N;i++){
    cin >> next.at(i);
  }
  int now = next.at(0);
  for(int j = 0;j<N;j++){
    if(now == 2){
      break;
    }
    now = next.at(now - 1);
    time++;
  }
  
  if(time == N){
    cout << -1 << endl;
  }else{
    cout << time + 1 << endl;
  }
}


Measured memory_bytes: 640
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

typedef struct {
	uint64_t A;
	uint64_t B;
} val;

int compare_f(const void *a, const void *b) {
	return ((val *)a)->A < ((val *)b)->A ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static val info[100000];

int main(void) {
	size_t N, M;

	scanf("%zu %zu\n", &N, &M);
	for (size_t i = 0; i < N; i++) {
		scanf("%"PRIu64" %"PRIu64, &(info[i].A), &(info[i].B));
		if (i < N - 1) {
			scanf("\n");
		}
	}

	qsort(info, N, sizeof(val), compare_f);

	uint64_t min = 0;

	for (size_t i = 0; i < N && 0 < M; i++) {
		const uint64_t count = MIN(info[i].B, M);

		min += count * info[i].A;
		M -= (size_t)count;
	}

	printf("%"PRIu64"\n", min);

	return 0;
}


Measured memory_bytes: 3324
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

############
############
############

class UnionFind(object):
 
    def __init__(self, N):
        self.N = N
        self.parent = list(range(self.N))
        self.rank = [0] * self.N
        self.size = [1] * self.N
 
    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
 
        if self.rank[x] < self.rank[y]:
            x, y = y, x
 
        self.size[x] += self.size[y]
        self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def count(self, x):
        return self.size[self.find(x)]

n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(m)]

uni = UnionFind(n)
ans = []
kota = n*(n-1)/2
ans.append(kota)
for i in range(m-1,0,-1):
    x,y = a[i]
    x-=1;y-=1
    xs = uni.count(x)
    ys = uni.count(y)
    if uni.find(x) == uni.find(y):
      ans.append(kota)
      continue
    uni.union(x,y)
    kota -= ys*xs
    ans.append(kota)
for i in ans[::-1]:
  print(int(i))


Measured memory_bytes: 38588
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  vector<ll> s(n);
  REP(i,n) cin >> s[i];
  ll ans = 0;
  ll cnt = 0;
  REP(i,n-1){
    if(s[i]>=s[i+1]){
      cnt++;
    }
    if(s[i]<s[i+1] || i==n-2){
      ans = max(ans,cnt);
      cnt = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
    int n;
    cin>>n;
   string s,t;
   cin>>s;
   cin>>t;
   for(int i=0;i<n;i++){
       cout<<s[i];
       cout<<t[i];
   }
   cout<<endl;
}


Measured memory_bytes: 256
a, b, k = map(int, input().split())
l1 = [i for i in range(1, a+1) if (a % i == 0)]
l2 = [i for i in range(1, b+1) if (b % i == 0)]
l = list(set(l1) & set(l2))
l.sort(reverse = True)
print(l[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c; cin >> a >> b >> c;
	for(int i = 1; i <= 200; i++) if((i*a)%b == c) return cout << "YES" << endl, 0;
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()

	ca := func(a []int) map[int]int {
		c := map[int]int{}
		for i := range a {
			w := 0
			switch {
			case a[i]%4 == 0:
				w = 2
			case a[i]%2 == 0:
				w = 1
			}
			c[w]++
		}
		return c
	}(a)

	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(ca[2]-ca[0] >= 0 || ca[0]-ca[2] == 1 && ca[1] == 0)])
}


Measured memory_bytes: 5248
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	ll A, B, C;
	cin >> A >> B >> C;
	
	ll cure = A + B;
	ll eatC = min(cure, C);
	ll eatB = B;
	ll last = C > eatC ? 1 : 0;
	cout << (eatC + eatB + last) << endl;
	
	
    return 0;
}

Measured memory_bytes: 256
def examA():
    S = SI()
    cur = 0; ans = 0
    for i,s in enumerate(S):
        if s=="W":
            ans += i-cur
            cur +=1
    print(ans)
    return

def examB():
    N = I()
    A = LI(); A.sort(reverse = True)
    ans = 0
    c = Counter(A)
    for a in A:
        cur = (1 << a.bit_length()) - a
        if c[a]>0 and c[cur]>0:
            if a==cur:
                ans += c[a]//2
                c[a]=0
                continue
            n = min(c[a],c[cur])
            c[a] -= n; c[cur] -= n
            ans += n
#            print(a,cur,c)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 101512
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    stack<int> st;
    rep(i,len(s)){
        if(s[i] == 'S'){
            st.push(0);
        }else{
            if(st.empty()){
                st.push(1);
            }else{
                int p = st.top();
                if(p == 0){
                    st.pop();
                }else{
                    st.push(1);
                }
            }
        }
    }
    cout << len(st) << endl;
    return 0;
}


Measured memory_bytes: 1300
import operator

n, m = map(int, input().split())
bridges = [0]
ms1 = (tuple(map(int, input().split())) for i in range(m))
ms2 = sorted(ms1, key=operator.itemgetter(1))

for i in range(m):
    if ms2[i][0] <= bridges[-1]:
        pass
    else:
        bridges.append(ms2[i][1] - 1)

if __name__ == "__main__":
    print(len(bridges)-1)    # 0 の分を除く


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

ll maxi(ll a, ll b){
    return (a>b)? a : b;
}

ll mini(ll a, ll b){
    return (a<b)? a : b;
}


int main(){
    int n; cin>> n;
    double a[n+1][n+1], p[n+1], ans=1;
    a[0][0]=1;
    for(int i=1; i<=n; i++){
        cin>> p[i];
        a[i][0]=a[i-1][0]*(1-p[i]);
        a[i][i]=a[i-1][i-1]*p[i];
        for(int j=1; j<i; j++){
            a[i][j]=(p[i]*a[i-1][j-1])+((1-p[i])*a[i-1][j]);
        }
        if(i==1) ans=p[i];
        else{
            (i%2==0)? ans-=((1-p[i])*(a[i-1][i/2])) : ans+=(p[i]*(a[i-1][(i-1)/2]));
        }
    }
    printf("%.12lf\n", ans);
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	int N;
	string S;
	bool flag = true;

	cin >> N;
	cin >> S;

	if (N % 2 == 1)
	{
		cout << "No" << endl;
		return 0;
	}

	rep(i, (int)(N / 2))
	{
		if (S[i] != S[(int)(N / 2) + i])
		{
			flag = false;
			break;
		}
	}

	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int GreatestCommonDivisor(int,int);

int main()
{
  int x,y,gcd;
  scanf("%d %d",&x,&y);

  gcd = GreatestCommonDivisor(x,y);
  printf("%d\n",gcd);

  return 0;
}

int GreatestCommonDivisor(int x,int y)
{
  int n=1;

  // x>yの状態にする
  if( x < y ){
    n = x;
    x = y;
    y = n;
  }

  //ユークリッドの互除法
  while( n != 0 ){
  n = x % y;
  x = y;
  y = n;
  }

  return x;
}


  
  



Measured memory_bytes: 2144
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b;
    if(a>=6&&a<=12)b/=2;
    else if(a<=5)b=0;
    Cout(b);
    return 0;
}

Measured memory_bytes: 256