akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 div_ceil(int64 lhs, int64 rhs){ return (lhs-1)/rhs + 1; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    uint oddN =div_ceil(s.size(), 2);
    uint evenN=s.size()/2;
    
    int odd0=0, odd1=0;
    int even0=0, even1=0;
    for(uint i=0; i<s.size(); ++i){
        if(i & 1){ if(s[i]=='0'){ ++odd0;  }else{ ++odd1;  }
        }  else  { if(s[i]=='0'){ ++even0; }else{ ++even1; } }
    }
    cout << min(oddN-odd0 + evenN-even1, oddN-odd1 + evenN-even0) << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll a; cin>>a;
	ll b; cin>>b;
	ll c; cin>>c;
	ll d; cin>>d;
	while(1){
		c-=b;
		if(c<=0)break;
		a-=d;
		if(a<=0)break;
	}
	if(a<=0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#include <stdlib.h>
#include <unordered_map>
#define ll long long
using namespace std;
int a[100];
int b[100];
int main()
{
    string s,t;
    int cnt1=0,cnt2=0;
    vector<int> c,d;
    cin>>s>>t;
    for(auto c:s)
            a[c-'a']++;
    for(auto c:t)
            b[c-'a']++;
    for(int i=0;i<26;i++){
        c.push_back(a[i]);
        d.push_back(b[i]);
    }
    sort(c.begin(),c.end());
    sort(d.begin(),d.end());
    for(int i=0;i<26;i++){
        if(c[i]!=d[i]){
            cout<<"No";
            return 0;
        }
    }
        cout<<"Yes";
}


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


int main (){
    int n;
    cin >>n;
    vector<float> v(n);
    rep(i,n){
        cin >>v[i];
    }
    sort(v.begin(),v.end());
    rep(i,n-1){
        v[i+1] = (v[i] +v[i+1])/2;
    } 
    cout << v[n-1] <<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

// s からスタートしたときの最長パス
int dfs(const vector<vector<int>>& g, vector<int>& lp, int s) {
  if (lp[s] != INF) return lp[s];
  int ret = 0;
  for (auto& v : g[s]) {
    chmax(ret, dfs(g, lp, v) + 1);
  }
  lp[s] = ret;
  return ret;
}

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

  int n, m;
  cin >> n >> m;
  vector<int> lp(n, INF);

  vector<vector<int>> g(n, vector<int>());
  rep(i, m) {
    int x, y; cin >> x >> y; x--; y--;
    g[x].push_back(y);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = dfs(g, lp, i);
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	
    long long  n,i,j,k,sum=0,count=0,ans=0,l,r,x,y;
	cin>>n;
	
	for(i=1;i<=n;i++)
	{
	    for(j=1;j<=n;j++)
	    {
	        for(k=1;k<=n;k++)
	        {
	            l=__gcd(i,j);
	            l=__gcd(l,k);
	            ans+=l;
	        }
	    }
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <chrono>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using namespace std::chrono;

const int MAX_BIT = 40;

inline bool is_bit(long long mask, int b) {
  return (mask >> b) & 1;
}

long long check(const vector<int>& ans) {
  int res = 0;
  const int n = ans.size();

  for (int mask = 1; mask < (1 << n); ++mask) {
    if (__builtin_popcount(mask) & 1)
      continue;

    vector<int> buf;
    for (int b = 0; b < n; ++b)
      if (is_bit(mask, b))
        buf.push_back(ans[b]);

    const int half = buf.size() / 2;
    bool ok = true;
    for (int i = 0; i < half; ++i)
      if (buf[i] != buf[i + half])
        ok = false;
    if (ok)
      ++res;
  }
  return res;
}

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  long long n;
  cin >> n;

  int max_pw = MAX_BIT;
  for (; max_pw >= 0 && !is_bit(n, max_pw); --max_pw);

  int id = max_pw + 1;
  deque<int> left, middle, right;
  for (int i = 1; i < id; ++i)
    middle.push_back(i);
  left.push_back(id);
  right.push_back(id);
  ++id;

  for (int b = 0; b < max_pw; ++b) {
    if (is_bit(n, b)) {
      left.push_back(id);
      right.push_front(id);
      ++id;
    }
    left.push_back(b + 1);
  }

  vector<int> ans;
  while (!left.empty()) {
    ans.push_back(left.front());
    left.pop_front();
  }
  while (!middle.empty()) {
    ans.push_back(middle.front());
    middle.pop_front();
  }
  while (!right.empty()) {
    ans.push_back(right.front());
    right.pop_front();
  }

  cout << ans.size() << endl;
  for (int i : ans)
    cout << i << ' ';
  cout << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


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

using namespace std;

int main(){
    int n;  cin >> n;
    int mini = (int)(1e9+1);
    long long int ans = 0;
    int count = 0;
    for (int i=0; i<n; i++){
        int m;  cin >> m;
        mini = min(mini, abs(m));
        ans += abs(m);
        if (m < 0)  count++;
    }

    if (count%2 == 1)  ans -= 2*mini;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
while (true) {
  $n = trim(fgets(STDIN));
  if (!$n) break;

  $points = explode(" ", trim(fgets(STDIN)));
  $avg = array_sum($points) / $n;

  $dispersion = 0;
  foreach ($points as $point) $dispersion += pow($avg - $point, 2);
  $dispersion /= $n;

  echo sprintf("%.10f\n", abs(sqrt($dispersion)));
}



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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> plus;
    vector<ll> minus;
    ll zero = 0;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if (A > 0)
            plus.push_back(A);
        else if (A < 0)
            minus.push_back(-A);
        else
            zero++;
    }
    sort(begin(plus), end(plus));
    sort(begin(minus), end(minus));
    ll l = -(1e18 + 1), r = 1e18;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        ll cnt = 0;
        if (mid >= 0) {
            for (int i = 0; i < plus.size(); i++) {
                cnt += upper_bound(begin(plus), end(plus), mid / plus[i]) -
                       begin(plus);
                if (plus[i] * plus[i] <= mid)
                    cnt--;
                cnt += zero;
                cnt += minus.size();
            }
            cnt += zero * plus.size();
            cnt += zero * minus.size();
            cnt += zero * (zero - 1);
            for (int i = 0; i < minus.size(); i++) {
                cnt += upper_bound(begin(minus), end(minus), mid / minus[i]) -
                       begin(minus);
                if (minus[i] * minus[i] <= mid)
                    cnt--;
                cnt += zero;
                cnt += plus.size();
            }
        } else {
            ll x = -mid;
            for (int i = 0; i < plus.size(); i++) {
                cnt += end(minus) - lower_bound(begin(minus), end(minus),
                                                (x + plus[i] - 1) / plus[i]);
            }
            for (int i = 0; i < minus.size(); i++) {
                cnt += end(plus) - lower_bound(begin(plus), end(plus),
                                               (x + minus[i] - 1) / minus[i]);
            }
        }
        cnt /= 2;
        if (K <= cnt)
            r = mid;
        else
            l = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 2420
x,y=map(int,input().split())

if x<y:
  x,y=y,x
  
def cmb(n,r,p):
  if r<0 or n<r:
    return 0
  r=min(r,n-r)
  return fact[n]*factinv[r]*factinv[n-r]%p

p=10**9+7
N=10**6
fact=[1,1]
factinv=[1,1]
inv=[0,1]

for i in range(2,N+1):
  fact.append((fact[-1]*i)%p)
  inv.append((-inv[p%i]*(p//i))%p)
  factinv.append((factinv[-1]*inv[-1])%p)
  

if 2*y>=x and (x+y)%3==0:
  print(cmb((x+y)//3,(2*y-x)//3,p))
else:
  print(0)
        
  
  

Measured memory_bytes: 122040
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    uint64_t W = 0;
    uint64_t H = 0;
    uint64_t x = 0;
    uint64_t y = 0;
    cin >> W >> H >> x >> y;
    double Sh = (double)W * (double)H * 0.5;

    int result = 0;
    if(W%2 == 0 && H % 2 == 0) {
        if(x == W/2 && y == H/2) {
            result = 1;
        }
    }
    cout << Sh << " " << result << endl;
    return 0;
}


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

int n;
LL a[maxn];

void init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
}

void solve()
{
	LL ans=0;
	if (n&1)
	{
		int m=(n+1)/2;
		for (int i=1;i<m-1;++i)
			ans-=a[i]<<1;
		for (int i=m+2;i<=n;++i)
			ans+=a[i]<<1;
		ans+=max(2*a[m+1]-a[m]-a[m-1],a[m+1]+a[m]-2*a[m-1]);
	} else
	{
		int m=n/2;
		for (int i=1;i<m;++i)
			ans-=a[i]<<1;
		for (int i=m+2;i<=n;++i)
			ans+=a[i]<<1;
		ans+=a[m+1]-a[m];
	}
	cout<<ans<<endl;
}

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

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
#define N 200010
struct star{
  ll x,y,b;
  bool operator<(const star&key)const{
      return this->b<key.b;
  }  
};
ll n,k;
star s[N];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
	cin>>s[i].x>>s[i].y>>s[i].b;
    }
    sort(s,s+n);
    ll p=0;
    multiset<ll> xx,yy;
    ll ans=0;
    for(int i=0;i<n;i++){
	for(;p<n&&s[p].b<=s[i].b+k;p++){
	    xx.insert(s[p].x);
	    yy.insert(s[p].y);
	}
	auto ix=xx.end(); ix--;
	ll dx=*ix-*xx.begin();
	auto iy=yy.end(); iy--;
	ll dy=*iy-*yy.begin();
	ans=max(ans,dx*dy);
	xx.erase(xx.find(s[i].x));
	yy.erase(yy.find(s[i].y));
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 26604
# Union Find 木
from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def pos(x, i):
    j, k = x[i]
    if i == j:
        return i, 0
    l, m = pos(x, j)
    x[i] = (l, m + k)
    return x[i]


setrecursionlimit(10 ** 6)

N, M = map(int, input().split())
LRD = [tuple(map(int, input().split())) for _ in range(M)]

parent = [-1] * (N + 1)
x = [(i, 0) for i in range(N + 1)]
for L, R, D in LRD:
    i = find(parent, L)
    j = find(parent, R)
    if i != j:
        x[j] = (i, D - pos(x, R)[1] + pos(x, L)[1])
        parent[i] += parent[j]
        parent[j] = i
    else:
        if pos(x, L)[1] + D != pos(x, R)[1]:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 45840
def resolve():
  N, A, B= map(int, input().split(" "))
  S = list(input())

  sum_of_successful_candidate = 0
  sum_of_successful_b = 0

  for i, s in enumerate(S):
    if sum_of_successful_candidate >= A + B:
      for _ in range(N-i):
        print("No")
      return True

    if s == "a":
      sum_of_successful_candidate += 1
      print("Yes")
    elif s == "b" and sum_of_successful_b < B:
      sum_of_successful_candidate += 1
      sum_of_successful_b += 1
      print("Yes")
    else:
      print("No")

  return True


if __name__ == "__main__":
  resolve()

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

struct node{
	int id,rank;
	node(int x,int y):id(x),rank(y){}
	bool operator <(const node& rhs) const {
		return rank>rhs.rank;
	}
};

priority_queue<node> Q;
int n,x,y;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		Q.push(node(i,x));
	}
	while(!Q.empty()){
		printf("%d ",Q.top());Q.pop();
	}
}

Measured memory_bytes: 1780
implicit none
integer :: n
integer,allocatable :: a(:),b(:),c(:),dp(:)
integer :: i,j
integer(8) :: ans,s

read *,n
allocate(a(n))
read *,a
call cs11(n,a)
allocate(b(n))
read *,b
call cs11(n,b)
allocate(c(n))
read *,c
call cs11(n,c)

allocate(dp(0:n))
dp(0) = 0

j = 1
do i = 1, n
   do while (j < n .and. a(j) < b(i))
      j = j + 1
   enddo
   if (j == n .and. a(n) < b(i)) then
      dp(i:n) = n
      exit
   endif
   dp(i) = j - 1
enddo

ans = 0
j = 1
s = 0
do i = 1, n
   do while (j < n .and. b(j) < c(i))
      s = s + dp(j)
      j = j + 1
   enddo
   if (j == n .and. b(j) < c(i)) then
      s = s + dp(n)
      ans = ans + s * (n-i+1)
      exit
   endif
   ans = ans + s
enddo

print '(i0)',ans

stop

contains

subroutine cs11(Ncomb,a)
integer, intent(in) :: Ncomb
integer, intent(inout) :: a(Ncomb)
integer :: icomb, jcomb,rswp
logical :: flg_swp

icomb = Ncomb
flg_swp = .false.
do while (icomb > 1 .or. flg_swp)
   icomb = (icomb * 10) / 13
   if (icomb < 1) then
      icomb = 1
   else if (icomb == 9 .or. icomb == 10) then 
      icomb = 11
   endif
   flg_swp = .false.
   do jcomb = 1, Ncomb-icomb
      if (a(jcomb) > a(jcomb+icomb)) then
         rswp = a(jcomb) 
         a(jcomb) = a(jcomb+icomb)
         a(jcomb+icomb) = rswp
         flg_swp = .true.
      endif
   enddo
enddo
endsubroutine cs11

end

Measured memory_bytes: 2432
#include<stdio.h>
#include<string.h>

int main(void)
{
   char a[11],b[11],c[11];
   int i1=0,i2=0;

   scanf("%s%s%s",a,b,c);

   if((a[strlen(a)-1]==b[0])&&(b[strlen(b)-1]==c[0]))
      printf("YES\n");
   else
      printf("NO\n");
   return 0;
}

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

int main() {
	int l,r,d;
	cin >> l >> r >> d;

	int cnt = 0;

	for (int i = l; i <= r; i++){
		if (i % d == 0){
			//cout << i << endl;
			cnt++;
		}
	}
	cout << cnt << endl;

}

Measured memory_bytes: 3548
# A内で完結するものと、連結したときに変わるものがある
#
# 3 4 2 1 2 -> 3+3+1+0+0 = 7
# 3 4 2 1 2 | 3 4 2 1 2 -> (3*2)+(1*1+3*2)+(1*2)+0+(1*1) + 7 = 16 + 7
# 3 4 2 1 2 | 3 4 2 1 2 | 3 4 2 1 2 -> (3*3)+(2*1+3*3)+(1*3)+0+(2*1) + 16+7 = 25+16+7
# Aについて、i<jなるjでAi>Ajになるものがk個、Ai<Ajになるものがk-1個ある
# k=3で考えると
# 順方向: (m*3)+(m*3)+(m*1)+(0)+(0), m=1~3 = 7+14+21=42
# 逆方向：(0)+(m*1)+(0)+(0)+(m*1), m=1~2 = 2+4=6 （逆方向はk-1個）
# 合わせて48となりこれは上記で試してたのと等しい
# ということで、それぞれ等差数列の和が使えそう
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7

# 順方向
base = 0
for i in range(n):
    for j in range(i, n):
        if a[i] > a[j]:
            base += 1
# 逆方向
additional = 0
for i in range(n):
    for j in range(i):
        if a[i] > a[j]:
            additional += 1

ans = (k * (k + 1) // 2 % mod * base +
       (k - 1) * k // 2 % mod * additional) % mod
print(ans)


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

long long n;
int main(){
    cin >> n;
    for(long long i = sqrt(n+10000LL); i >= 1; i--){
        if(i*i <= n && n % i == 0){ cout << i+n/i-2; return 0; }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int lcm(int a, int b){
	return (a * b) / (__gcd(a, b));
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout << fixed << showpoint << setprecision(10);
	int n;
	cin >> n;
	int arr[n], lc = 0;
	cin >> arr[0];
	lc = arr[0];
	for(int i = 1; i < n; i++){
		cin >> arr[i];
		lc = lcm(lc, arr[i]);
	} 
	int deno = 0;
	for(int i = 0; i < n; i++){
		deno += lc / arr[i];
	}
	double ans = (double)lc /(double)deno;
	cout << ans;
}

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

using namespace std;

typedef long long ll;
const ll inf = 0x3f3f3f3f;
#define case(i) "Case #" << i << ": "
 
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
    out << '(' << p.first << ", " << p.second << ')';
    return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++) out << v[i] << ' ';
    if (l > 0) out << v[l - 1];
    return out;
}

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

    int n;
    cin >> n;
    vector<int> v(n);

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

    int cur = 1;
    int ans = 0;
    for(int x: v) {
        if(x == cur) cur++;
        else ans++;
    }
    if(ans == n) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	} else if x == 2 {
		return true
	} else if x%2 == 0 {
		return false
	}
	for i := 3; float64(i) <= math.Sqrt(float64(x)); i = i + 2 {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	n := nextInt(sc)

	count := 0
	for i := 0; i < n; i++ {
		x := nextInt(sc)
		if isPrime(x) {
			count++
		}
	}
	fmt.Println(count)
}



Measured memory_bytes: 1136
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}
void dfs(ll i,vector<ll>a[],ll vi[])
{
    if(vi[i]==1)
        return;
 
    vi[i]=1;
   // s.insert(i);
    cout<<i<<" ";
    for(int j=0;j<a[i].size();j++)
    {
        if(vi[a[i][j]]==false)
        {
            dfs(a[i][j],a,vi);
        }
    }
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
int n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
unordered_map<int,int>m;
for(int i=0;i<n;i++)
{
    ll k=a[i];
    if(k%2==0)
    {
        m[2]++;
        while(k%2==0)
        {
            k/=2;
        }
    }
    for(int j=3;j<=sqrt(k);j+=2)
    {
        if(k%j==0)
        {
            m[j]++;
          while(k%j==0){  
          k/=j;
          } 
        }
    }
    if(k>1)
    {
        m[k]++;
    }
}
/*for(auto x:m)
{
    cout<<x.first<<" "<<x.second<<"\n";
}*/
int co=0,f=0;
for(auto x:m)
{
  if(x.second==1)
  {
      co++;
  }
  if(x.second==n)
  {
      f=1;
  }
}
if(f==1)
{
    cout<<"not coprime";
}
else
{
    if(co==m.size())
    {
        cout<<"pairwise coprime";
    }
    else
    {
        cout<<"setwise coprime";
    }
}
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    ll A, B, C;
    cin >> A >> B >> C;
    vector<string> Q(N);
    for(int i=0; i<N; i++) cin >> Q[i];
    
    vector<char> ans;
    for(int i=0; i<N; i++)
    {
        string q = Q[i];
        if(q == "AB")
        {
            if(A == 0 && B == 0)
            {
                cout << "No" << endl;
                return 0;
            }
            if(A == B)
            {
                if(i+1<N && Q[i+1] == "AC")
                {
                    ans.push_back('A');
                    A++; B--;
                }
                else
                {
                    ans.push_back('B');
                    A--; B++;
                }
            }
            else if(A < B)
            {
                ans.push_back('A');
                A++; B--;
            }
            else
            {
                ans.push_back('B');
                A--; B++;
            }
        }
        else if(q == "BC")
        {
            if(B == 0 && C == 0)
            {
                cout << "No" << endl;
                return 0;
            }
            if(B == C)
            {
                if(i+1<N && Q[i+1] == "AB")
                {
                    ans.push_back('B');
                    B++; C--;
                }
                else
                {
                    ans.push_back('C');
                    B--; C++;
                }
            }
            else if(B < C)
            {
                ans.push_back('B');
                B++; C--;
            }
            else
            {
                ans.push_back('C');
                B--; C++;
            }
        }
        else if(q == "AC")
        {
            if(A == 0 && C == 0)
            {
                cout << "No" << endl;
                return 0;
            }
            if(A == C)
            {
                if(i+1<N && Q[i+1] == "AB")
                {
                    ans.push_back('A');
                    A++; C--;
                }
                else
                {
                    ans.push_back('C');
                    A--; C++;
                }
            }
            else if(A < C)
            {
                ans.push_back('A');
                A++; C--;
            }
            else
            {
                ans.push_back('C');
                A--; C++;
            }
        }
    }
    cout << "Yes\n";
    for(auto c : ans) cout << c << '\n';

    return 0;
}

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

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

  vector<int> s;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int sumt = 0;
    int t    = i;
    while (true) {
      int tmp = t % 10;
      sumt += tmp;
      if (t < 10) break;
      t -= tmp;
      t /= 10;
    }
    if (sumt >= a && sumt <= b) { sum += i; }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
n,k = gets.chomp.split().map(&:to_i)
x = gets.chomp.split().map(&:to_i)

ans = Float::INFINITY

(n-k+1).times do |i|
  l = x[i]
  r = x[i+k-1]

  if r < 0
    a = l.abs
  elsif 0 < l
    a = r
  else
    a = [l.abs * 2 + r, l.abs + r * 2].min
  end
  ans = [ans, a].min
end

puts ans


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

import bisect
n,k = map(int, input().split())
a = sorted(list(map(int, input().split())))

def cnt(x):
  ret = 0
  for ai in a:
    ret += (ai+(x-1))//x - 1
  return ret

ok, ng = a[-1], 0
while ok - ng > 1:
  nw = (ok + ng) // 2
  if cnt(nw)<=k:
    ok = nw
  else:
    ng = nw

print(ok)


Measured memory_bytes: 31072
A,B,C,X,Y = map(int,input().split())
achete_A = 0
achete_B = 0
price = 0
C = 2 * C #=A,B
while achete_A < X and achete_B < Y:
    if A+B <= C:
        achete_A += 1
        achete_B += 1
        price += (A+B)
    else:
        achete_A += 1
        achete_B += 1
        price += C
if achete_A < X :
    while achete_A < X:
        if A < C:
            achete_A += 1
            price += A
        else:
            achete_A += 1
            price += C
elif achete_B < Y:
    while achete_B < Y:
        if B < C:
            achete_B += 1
            price += B
        else:
            achete_B += 1
            price += C
print(price)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <list>
#include <queue>
using namespace std;


int main()
{
    priority_queue<long long int> q;

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        long long int tmp;
        cin >> tmp;
        q.push(tmp);
    }

    for (int i = 0; i < m; i++) {
        long long int tmp;
        tmp = q.top();
        q.pop();
        q.push(tmp / 2);
    }

    long long int res = 0;
    while (!q.empty()) {
        res += q.top();
        q.pop();
    }

    cout << res << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n,m = 0;
	cin >> n;
	
	vector<int> v(n);
	REP(i,n)
	{
		cin >> v[i];
		if(v[i] % 2 == 0)
		{
			m++;
		}
	}
	
	ll ans = 1,hiku = 1;;
	
	REP(i,n)
	{
		ans *= 3;
	}
	REP(i,m)
	{
		hiku *= 2;
	}
	
	cout << ans - hiku << endl;
	
	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<LL> A;

LL ans = INF;

void solve(){
    vector<LL> A_cpy(A);
    //正の数から開始
    {
        int sum = 0;
        LL counter = 0;
        for(int i=0;i<N;i++){
            //奇数回目では和が負なら良い
            if(i%2==1){
                if(sum+A_cpy[i]>=0){
                    counter += ((sum+A_cpy[i])+1);
                    A_cpy[i] = -(sum+1);
                }
                sum += A_cpy[i];
            }
            //偶数回目では和が正なら良い
            if(i%2==0){
                if(sum+A_cpy[i]<=0){
                    counter += (-(sum+A_cpy[i])+1);
                    A_cpy[i] = (-sum+1);
                }
                sum += A_cpy[i];
            }
        }
        // for(int i=0;i<N;i++){
        //     cout << A_cpy[i] << " ";
        // }
        // cout << endl;
        ans = min(ans,counter);
    }

    //負の数から開始
    {
        int sum = 0;
        LL counter = 0;
        for(int i=0;i<N;i++){
            //偶数回目では和が負なら良い
            if(i%2==0){
                if(sum+A[i]>=0){
                    counter += ((sum+A[i])+1);
                    A[i] = -(sum+1);
                }
                sum += A[i];
            }
            //奇数回目では和が正なら良い
            if(i%2==1){
                if(sum+A[i]<=0){
                    counter += (-(sum+A[i])+1);
                    A[i] = (-sum+1);
                }
                sum += A[i];
            }
        }
        // for(int i=0;i<N;i++){
        //     cout << A[i] << " ";
        // }
        // cout << endl;
        ans = min(ans,counter);
    }
}
 
int main(){
    cin >> N;
    A = vector<LL>(N);
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

    cout << ans << endl;
    return 0;
}

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

lint pd[100010];
int h[100010];
int n;

long long sapo1(int i){
	if(pd[i] != -1) return pd[i];
	if(i == n) return pd[i] = 0;
	if(i == n-1) return pd[i] = abs(h[i] - h[n]);
	return pd[i] = min(abs(h[i] - h[i+1]) + sapo1(i+1),
					   abs(h[i] - h[i+2]) + sapo1(i+2));
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>h[i];
	memset(pd,-1,sizeof(pd));
	cout<<sapo1(1)<<"\n";
	return 0;	
}


Measured memory_bytes: 2944
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,bt,tmp,abt;
  string ans="";
  cin >> n;
  if(n==0){
    cout <<"0\n";
    return 0;
  }
  bt = 1;
  while(n!=0){
    tmp = abs(n);
    abt = abs(bt);
    if(tmp&abt){
      n -= bt;
      ans+="1";
    }else{
      ans += "0";
    }
    bt *= -2;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
}


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

int main() {
  int64_t a,b=0;
  cin>>a;
  for(int i=1;i<=a;i++){
    if(!(i%3==0)&&!(i%5==0)){
      b+=i;
    }
  }
  cout<<b<<endl;
}

Measured memory_bytes: 3624
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}
// memo {{{
/*

  - ある値が見つかるかどうか
    <https://dlang.org/phobos/std_algorithm_searching.html#canFind>

    canFind(r, value); -> bool

  - 条件に一致するやつだけ残す
    <https://dlang.org/phobos/std_algorithm_iteration.html#filter>

    // 2で割り切れるやつ
    filter!"a % 2 == 0"(r); -> Range

  - 合計
    <https://dlang.org/phobos/std_algorithm_iteration.html#sum>

    sum(r);

  - 累積和
    <https://dlang.org/phobos/std_algorithm_iteration.html#cumulativeFold>

    // 今の要素に前の要素を足すタイプの一般的な累積和
    // 累積和のrangeが帰ってくる(破壊的変更は行われない)
    cumulativeFold!"a + b"(r, 0); -> Range

  - rangeをarrayにしたいとき

    array(r); -> Array

  - 各要素に同じ処理をする
    <https://dlang.org/phobos/std_algorithm_iteration.html#map>

    // 各要素を2乗
    map!"a * a"(r) -> Range

  - ユニークなやつだけ残す
    <https://dlang.org/phobos/std_algorithm_iteration.html#uniq>

    uniq(r) -> Range

  - 順列を列挙する
    <https://dlang.org/phobos/std_algorithm_iteration.html#permutations>

    permutation(r) -> Range

  - ある値で埋める
    <https://dlang.org/phobos/std_algorithm_mutation.html#fill>

    fill(r, val); -> void

  - バイナリヒープ
    <https://dlang.org/phobos/std_container_binaryheap.html#.BinaryHeap>

    // 昇順にするならこう(デフォは降順)
    BinaryHeap!(T[],  "a > b") heap;
    heap.insert(val);
    heap.front;
    heap.removeFront();


  - 浮動小数点の少数部の桁数設定

    // 12桁
    writefln("%.12f", val);

  - 浮動小数点の誤差を考慮した比較
    <https://dlang.org/phobos/std_math.html#.approxEqual>

    approxEqual(1.0, 1.0099); -> true

  - 小数点切り上げ
    <https://dlang.org/phobos/std_math.html#.ceil>

    ceil(123.4); -> 124

  - 小数点切り捨て
    <https://dlang.org/phobos/std_math.html#.floor>

    floor(123.4) -> 123

  - 小数点四捨五入
    <https://dlang.org/phobos/std_math.html#.round>

    round(4.5) -> 5
    round(5.4) -> 5

*/
// }}}

void main() {
  auto cin = new Scanner;
  int n, m;
  cin.scan(n, m);
  writeln((1900 * m + 100 * (n - m)) * 2 ^^ m);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstring>
using namespace std;
vector<vector<int>> vt;
int visited[16001],visited1[16001];
int main()
{
	memset(visited, -1, sizeof(visited));
	memset(visited1, -1, sizeof(visited1));
	string a;
	cin >> a;
	vt.resize(2);
	int ch = 0;
	int t = a.size();
	int cnt = 0;
	for (int i = 0; i < t; i++)
	{
		if (a[i] == 'F')cnt++;
		else {
			vt[ch].push_back(cnt);
			cnt = 0;
			ch ^= 1;
		}
	}
	if (cnt)
		vt[ch].push_back(cnt);
	vector<int> vt1;
	for (int i = 0; i < vt[0].size(); i++)
	{
		vector<int> gap;
		if (!i)vt1.push_back(8000);
		for (int y = 0; y < vt1.size(); y++)
		{
			if (visited[vt1[y] + vt[0][i]] != i)
			{
				visited[vt1[y] + vt[0][i]] = i;
				gap.push_back(vt1[y] + vt[0][i]);
			}
			if (i) {
				if (visited[vt1[y] - vt[0][i]] != i)
				{
					visited[vt1[y] - vt[0][i]] = i;
					gap.push_back(vt1[y] - vt[0][i]);
				}
			}
		}
		vt1 = gap;
	}
	vt1.clear();
	for (int i = 0; i < vt[1].size(); i++)
	{
		vector<int> gap;
		if (!i)vt1.push_back(8000);
		for (int y = 0; y < vt1.size(); y++)
		{
			if (visited1[vt1[y] + vt[1][i]] != i)
			{
				visited1[vt1[y] + vt[1][i]] = i;
				gap.push_back(vt1[y] + vt[1][i]);
			}
			if (visited1[vt1[y] - vt[1][i]] != i)
			{
				visited1[vt1[y] - vt[1][i]] = i;
				gap.push_back(vt1[y] - vt[1][i]);
			}
		}
		vt1 = gap;
	}
	int n, m;
	cin >> n >> m;
	n += 8000;
	m += 8000;
	int tt = vt[0].size() - 1;
	int tt1 = vt[1].size() - 1;
	if ((visited[n]==tt && visited1[m]==tt1))
		puts("Yes");
	else puts("No");
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e6 + 5;
const int P = 998244353;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int fac[MAXN], inv[MAXN];
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int binom(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	int n, m, ans = 0;
	read(n), read(m);
	init(n + 3 * m);
	int s = 3 * m;
	for (int i = 0; i <= m && i <= n; i++) {
		if ((s - i) & 1) continue;
		int tmp = (s - i) / 2;
		update(ans, 1ll * binom(n, i) * binom(tmp + n - 1, n - 1) % P);
	}
	s -= 2 * m;
	for (int i = 0; i <= m && i <= n; i++) {
		if ((s - i) & 1) continue;
		int tmp = (s - i) / 2;
		if (i != 0) update(ans, P - 1ll * n * binom(n - 1, i - 1) % P * binom(tmp + n - 1, n - 1) % P);
		if (tmp != 0) update(ans, P - 1ll * n * binom(n - 1, i) % P * binom(tmp + n - 2, n - 1) % P);
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 22784
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=505,mod=1e9+7;
int n,m,f[N][N],g[N][N],a[N];

void update(int x){
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) g[i][j]=f[i][j],f[i][j]=0;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(g[i][j]){
		if(j+x<=m) f[i+1][j+x]=(1ll*f[i+1][j+x]+1ll*(i+1)*g[i][j])%mod;
		f[i][j]=(1ll*f[i][j]+1ll*g[i][j]*(mod+j-i*(x-1)))%mod;
		for(int k=1;k<x&&j+k<=m;k++) f[i][j+k]=(1ll*f[i][j+k]+2ll*g[i][j]*i)%mod;
		for(int k=0;k<x-1&&j+k<=m;k++) f[i-1][j+k]=(1ll*f[i-1][j+k]+1ll*g[i][j]*(x-k-1)*(i-1))%mod;
	}
}

signed main(){
	read(n,m);m++;
	for(int i=1;i<=n;i++) a[i]=read(a[i])+1;
	sort(a+1,a+1+n,greater<int>());
	f[1][a[1]]=1;
	for(int i=2;i<=n;i++) update(a[i]);
	write(f[1][m]);
}

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


int main(){
    int N=0,A=0,B=0,C=0,D=0;
    string str;
    int count = 0;
    int ans=0;
    bool check=true,CC=false;


    cin>>str;

    if(str[0]=='A'){
        for(int i=1;i<str.size();i++){
            
            if(str[i]=='C'&&1<i&&i<str.size()-1){
                if(CC){
                check=false;
                }else{
                    CC=true;
                }
            }

            else if(str[i]<'a'||'z'<str[i]){
                check=false;

            }
        }
    }

if(check&&CC){
    cout<<"AC"<<endl;
}else{
    cout<<"WA"<<endl;
}





}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;

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

int main(){
    ll a,b;
    cin>>a>>b;
    ll g=gcd(a,b);
    ll ans=0;
    for(ll i=2;i*i<=g;i++){
        if(g%i==0){
            ans++;
            while(g%i==0){
                g/=i;
            }
        }
    }
    ans++;
    if(g!=1)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N, M;
  cin >> N >> M;
  vi A(N);
  cin >> A;
  int s = accumulate(all(A), 0LL);
  int cnt = 0;
  rep(i, 0, N) {
    if (A[i] * 4 * M >= s) {
      cnt++;
    }
  }
  if (cnt >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include<iostream>
#define no cout<<"No";return 0;
using namespace std;
int main(){
int a,b;
cin>>a>>b;
for(int i=0;i<a+b+1;i++){
char c;
cin>>c;
if(i==a){if(c!='-'){no;}}
else{if(c<'0'||'9'<c){no;}}
}
cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    // ある連続するK個の部分以外は最適にできる
    int N, K;
    cin >> N >> K;
    vector<i64> A(N), B, SA(N + 1, 0), SB(N + 1, 0);
    for(auto &x : A) {
        cin >> x;
        B.push_back(max(x, i64(0)));
    }
    for(int i = 0; i < N; i++) {
        SA[i + 1] = A[i] + SA[i];
        SB[i + 1] = B[i] + SB[i];
    }
    i64 ans = -1;
    for(int i = K; i <= N; i++) {
        ans = max(ans, SB[i - K] + max(SA[i] - SA[i - K], i64(0)) + SB[N] - SB[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3704
from itertools import combinations_with_replacement
from sys import stdin
input = stdin.readline

N,M,Q = map(int, input().split())
A = [0]*Q
B = [0]*Q
C = [0]*Q
D = [0]*Q
for i in range(Q):
    A[i],B[i],C[i],D[i] = list(map(int, input().split()))

ans = 0
X = [i for i in range(1,M+1)]
for tup in combinations_with_replacement(X,N):
    total = 0
    for i in range(Q):
        if tup[B[i]-1] - tup[A[i]-1] == C[i]:
            total += D[i]
    ans = max(ans,total)

print(ans)

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

bool array_equal(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return false;
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return false;
    }
  }
  return true;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

int main() {
  std::cout << std::setprecision(9);
  long a, b;
  cin >> a >> b;

  cout << a * b / gcd(a, b) << endl;
}

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

struct league {
	string name;
	int w, l, d, p;

	bool operator < (const league & rhs) const {
		return p > rhs.p;
	}
};

int main()
{
	int n;

	cin >> n;

	while (n > 0) {
		league sc[10];

		for (int i = 0; i < n; i++) {
			cin >> sc[i].name >> sc[i].w >> sc[i].l >> sc[i].d;
			sc[i].p = sc[i].w * 3 + sc[i].d;
		}

		sort(sc, sc + n);

		for (int i = 0; i < n; i++)
			cout << sc[i].name << "," << sc[i].p << endl;

		cin >> n;

		if (n > 0)
			cout << endl;
	}

	return 0;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    ll N = S.length() - 1;

    cout << S;

    if(S[N] == 's'){
        cout << "es" << endl;
    }
    else{
        cout << 's' << endl;
    }
    return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const ll INF = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

ll N, X;

ll get(int i, const vector<ll> &A)
{
    return A[(N+i) % N];
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> N >> X;
    vector<ll> A(N), B(N, INF);
    ll ans = INF;
    rep(i, N) cin >> A[i];
    rep(k, N) {
        ll tmp = 0;
        rep(i, N) {
            B[i] = min(B[i], get(i-k, A));
            tmp += B[i];
        }
        ans = min(ans, X * k + tmp);
    }
    cout << ans << endl;
}



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

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

int main()
{
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592