akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
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;}
const ll mod = 1000000007;

int main(){
  /*
  ifstream in("hand_01.txt");
  cin.rdbuf(in.rdbuf());
  */

  int N, K; cin >> N >> K;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  ll ans = 1;
  if(N==K){
    rep(i,N) {ans *= ((A[i]+mod)%mod); ans %= mod;}
    cout << ans << endl;
    return 0;
  }
  int noz=0; int z=0;
  int ppp = 0; int mmm = 0;
  rep(i,N) {
    if(A[i]!=0) noz++;
    if(A[i]==0) z++;
    if(A[i]>0) ppp++;
    if(A[i]<0) mmm++;
  }
  if(noz < K){
    cout << 0 << endl;
    return 0;
  }
  if(z && noz==K && mmm%2==1){
    cout << 0 << endl;
    return 0;
  }
  if(z && ppp==0 && K%2==1){
    cout << 0 << endl;
    return 0;
  }


  vector<ll> B;
  rep(i,N) if(A[i]!=0) B.pb(A[i]);
  N = sz(B);
  vector<ll> pls,mns;
  rep(i,N) {
    if(B[i]>0) pls.pb(B[i]);
    else mns.pb(B[i]);
  }

  if(ppp==0&&K%2==1){
    sort(rall(mns));
    rep(i,K){
      ans *= (mns[i]+mod)%mod;
      ans %= mod;
    }
    cout << ans << endl;
    return 0;
  }


  sort(rall(pls));
  sort(all(mns));
  pls.pb(0);
  pls.pb(0);
  mns.pb(0);
  mns.pb(0);
  mns.pb(0);
  int idp=0,idm=0;
  rep(i,K){
    if(pls[idp]*pls[idp+1]>=mns[idm]*mns[idm+1] || i==K-1){
      ans *= pls[idp];
      ans %= mod;
      idp++;
    }
    else{
      ans *= (mns[idm]*mns[idm+1]%mod);
      ans %= mod;
      idm += 2;
      i++;
    }
  }



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


Measured memory_bytes: 9428
#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 n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  vector<ll> dp(n);
  rep(i, n) dp[i] = 1e15;

  dp[0] = 0;
  rep(i, n) {
    if(i+1 < n) dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    if(i+2 < n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
  }

  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 4552
# ABC 142 D - Disjoint Set of Common Divisors
def divisor(n): 
    """
    xの約数を列挙する。

    Parameters
    ----------
    x: int
        約数を求めたい自然数

    Returns
    -------
    retlist：list
        約数のリスト

    """
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def isPrime(p):
    for i in range(2, int(p**0.5)+1):
        if p % i == 0:
            return False
    return True

a,b = map(int,input().split())
A =[]
B =[]
C =[]
AB = []
ans = 0
A = divisor(a)
B = divisor(b)
for aa in A:
    if aa in B:
        AB.append(aa)

for ab in AB:
    if isPrime(ab):
        ans+=1
        C.append(ab)

print(ans)

Measured memory_bytes: 4224
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

const int M = 510;
int c[M][M];
int occ[M][M];

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

int ans;
int n;

void dfs(int i, int j){
  int d = c[i][j] + occ[i][j];
  rep(k, 4){
    int ni = i + di[k];
    int nj = j + dj[k];
    if(ni < 0 || ni >= n || nj < 0 || nj >= n){
      continue;
    }
    if(chmin(c[ni][nj], d)){
      dfs(ni, nj);
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin >> n;
  rep(i, n)rep(j, n){
    occ[i][j] = 1;
    c[i][j] = min({i, j, n-1-i, n-1-j});
  }
  rep(it, n*n){
    int x;
    cin >> x;
    x--;
    int i = x/n;
    int j = x%n;
    occ[i][j] = 0;
    ans += c[i][j];
    dfs(i, j);
  }
  print(ans);
}


Measured memory_bytes: 21056
# AtCoder ABC147-B Palindrome-philia

S = input()
num_hug = 0

s1 = S[:len(S)//2]  # 1st half (shorter if odd
s2x = list(S[len(S)//2:]) # 2nd half

for c in s1:
    if c != s2x.pop():
        num_hug += 1
        
print(num_hug)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=3e5+5;
typedef unsigned long long ull;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
int n,x;
int l=0;
int main(){
    cin>>n>>x;
    int ans=1;
    for(int i=0;i<n;i++){
        int u;cin>>u;
        l+=u;
        if(l<=x)ans++;
    }
    o(ans);
}

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

int main(){
  int h,w;
  while(true){
    cin>>h>>w;
    if(h==0&&w==0)break;
    rep(i,h){
      rep(j,w){
        cout<<'#';
      }
      cout<<endl;
    }
    cout<<endl;
  }
}


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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	ll n, p, s;
	cin >> n;
	p = 1;
	s = 0;
	while (p <= n) {
		s += min(n+1, p*10)-p;
		p *= 100;
	}
	cout << s << ende;
  return 0;
}


Measured memory_bytes: 256
def gcd(x, y)
  while x >= y
    if y == 0
      puts x
      break
    else
      x, y = y, x % y
    end
  end
end

x, y = gets.split.map(&:to_i)
if x >= y
  gcd(x, y)
else
  gcd(y, x)
end

Measured memory_bytes: 8656
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> dp(H + 1, vector<int>(W, 0));
  dp[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = 0; k < 1 << (W - 1); k++) {
        bool ok = true;
        for (int l = 0; l < W - 2; l++)
          if (((k >> l) & 1) && ((k >> (l + 1)) & 1))
            ok = false;

        if (ok) {
          if (1 <= j && ((k >> (j - 1)) & 1))
            dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j]) % MOD;
          else if (j <= W - 2 && ((k >> j) & 1))
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
          else
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
        }
      }
    }
  }
  cout << dp[H][K - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
//printf("%.yf\n",x); xを小数点以下y桁で
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b&&b < c) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a;
	bool date[33];
	for (int i = 1; i <= 30; i++) {
		date[i] = true;
	}
	for (int i = 1; i <= 28; i++) {
		cin >> a;
		date[a] = false;
	}
	for (int i = 1; i <= 30; i++) {
		if (date[i]) {
			cout << i << endl;
		}
	}
}


Measured memory_bytes: 3108
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

string S;
string T;
string finalAns;
int cnt = 0;
int isPossible;
int ans;
int pos = -1;

int main()
{
	cin >> S;
	cin >> T;

	for(int i = 0; i < S.size() - T.size() + 1; i++)
	{
		isPossible = 1;
		for(int j = 0; j < T.size(); j++)
		{
			if(S[i + j] == T[j] || S[i + j] == '?')
			{
				continue;
			}
			else
			{
				isPossible = 0;
			}
		
		}
			// cout << isPossible;
		if(isPossible)
		{
			pos = i;
		}
	}
	if(pos >= 0)
	{
		for(int i = 0; i < T.size(); i++)
		{
		
			S[pos + i] = T[i];

		}
		for(int i = 0; i < S.size(); i++)
		{
			if(S[i] == '?')
			{
				S[i] = 'a';
			}
		}
		cout << S;
	}
	else
	{
		cout << "UNRESTORABLE";
	}

	return 0;
}


/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
n = gets.to_i

d = gets.chomp.split.map(&:to_i)
dd = gets.chomp.split.map(&:to_i)

pry = []

i = 1

while i <= n
	pry << i
	i += 1
end

res = []
count = 0

pry.permutation(n) do |item|
	count += 1
	if item[0..n-1] == d || item[0..n-1] == dd
		res << count
	end
end

puts res.max - res.min

Measured memory_bytes: 1788
def abc155_d():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    from bisect import bisect_left, bisect_right
    lower = -10**18
    upper = 10**18
    while upper - lower > 1:
        x = (upper + lower) // 2
        cnt = 0
        for i in range(n-1):
            a = A[i]
            if a < 0:
                idx = bisect_left(A, (x+a+1)//a)
                cnt += n - max(idx, i+1)
            elif a > 0:
                idx = bisect_right(A, x//a)
                cnt += max(0, idx - i - 1)
            else:  # a == 0
                if x >= 0:
                    cnt += n - i - 1
            if cnt >= k: break
        if cnt >= k: upper = x
        else: lower = x
    print(upper)

if __name__ == '__main__':
    abc155_d()

Measured memory_bytes: 104912
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=3*100005;
LL dp1[N],dp2[N],a[N];
priority_queue<LL,vector<LL>,greater<LL> >q1;
priority_queue<LL>q2;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=3*n; i++)
    {
        scanf("%d",&a[i]);
    }

    LL sum=0;
    for(int i=1; i<=3*n; i++)
    {
        sum+=a[i];
        q1.push(a[i]);
        dp1[i]=sum;
        if(q1.size()>n)
        {
            sum-=q1.top();
            q1.pop();
            dp1[i]=sum;
        }
    }

    sum=0;
    for(int i=3*n; i>=1; i--)
    {
        sum+=a[i];
        q2.push(a[i]);
        dp2[i]=sum;
        if(q2.size()>n)
        {
            sum-=q2.top();
            q2.pop();
            dp2[i]=sum;
        }

    }
    
    LL  ans=-1e18;
    for(int i=n;i<=2*n;i++)
	{
		ans=max(dp1[i]-dp2[i+1],ans);
	}
	cout<<ans<<endl;
    return 0;

}


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

int main(void){
  int h,w;
  cin>>h>>w;
  vector<vector<char> > buf(h,vector<char>(w));
  vector<vector<int> > dp(h,vector<int>(w,0));
  for(int i = 0 ; i < h ; i ++)for(int j = 0 ; j < w ; j ++)cin>>buf[i][j];
  for(int i = 0 ; i < h ; i ++){
    for(int j = 0 ; j < w ; j ++){
      dp[i][j]=buf[i][j]-'0';
     }
  }
  for(int i = 1 ; i < w ; i ++){dp[0][i]+=dp[0][i-1];}
  for(int i = 1 ; i < h ; i ++){
    dp[i][0]+=dp[i-1][0];
    
      //cout<<dp[i][0]<<" ";
    for(int j = 1 ; j < w ; j ++){
      dp[i][j]+=min(dp[i-1][j],dp[i][j-1]);
      //cout<<dp[i][j]<<" ";
     }
     //cout<<endl;
  }
  
  cout<<(int)dp[h-1][w-1]<<endl;

}

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/
int N;
map<int,int> prime_factor(int64_t n) {
  map<int,int> ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N;
  
  map<int,int> vec;  //key: 素因数,value: 個数
  
  
  REP(j,N){ //j:1 ~ N
    for(auto i:prime_factor(j)){
      vec[i.first] += i.second;
    }
  } 
   
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  
  
  ll ans = 1;
  for(auto i:vec){
    //cout << i.first <<' '<< i.second << endl;
    ans *= (i.second + 1);
    ans %= MOD;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int N, Y;
  cin >> N >> Y;
  for (int x = 0; x <= N; x++)
  {
    for (int y = 0; y <= N - x; y++)
    {
      int z = N - x - y;
      if (10000 * x + 5000 * y + 1000 * z == Y)
      {
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int ai[200005];

int main(){

	int i;

	int n;

	scanf("%d",&n);

	for(i=1;i<=n;i++){
		scanf(" %d",&ai[i]);
	}

	if(n%2==0){

		if(n==2){
			printf("%d %d\n",ai[2],ai[1]);
			return 0;
		}

		for(i=n;i>=2;i-=2){
			printf("%d ",ai[i]);
		}

		for(i=1;i<=n-3;i+=2){
			printf("%d ",ai[i]);
		}
		printf("%d\n",ai[n-1]);

	}
	else{
		if(n==1){
		printf("%d\n",ai[1]);
		return 0;
		}
		if(n==3){
		printf("%d %d %d\n",ai[3],ai[1],ai[2]);
		return 0;
		}
		for(i=n;i>=1;i-=2){
			printf("%d ",ai[i]);
		}

		for(i=2;i<=n-3;i+=2){
			printf("%d ",ai[i]);
		}
		printf("%d\n",ai[n-1]);
	}


	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

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

    int a = m;
    int b = (int)sqrt(m);

    vector<int> p;
    for (int i = 2; i <= b; i++) {
        if (a % i == 0) {
            int c = 0;
            while (a % i == 0) a /= i, c++;
            p.push_back(c);
        }
    }
    if (a > 1) p.push_back(1);

    init(n + 1000);

    ll r = 1;
    for (auto& c : p) {
        r *= comb(c + n - 1, n - 1);
        r %= P;
    }

    cout << r << endl;

    return 0;
}


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

int main()
{
	int n,a,i,ans=0;
	
	cin>>n;
	
	for(i=0;i<n;i++){
		cin>>a;
		
		if(i%2==0&&a%2==1){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
S = input()
n = len(S)
if n%2 == 0:
    print("No")
    exit()
else:
    for i in range(n//2):
        if S[i] != S[(n-1)-i]:
            print("No")
            exit()
    for i in range(((n-1)//2)//2):
        if S[i] != S[(((n-1)//2)-1)-i]:
            print("No")
            exit()
    for i in range((n//2)+1,(n//2)+1+(n-(n//2)+1)//2):
        if S[i] != S[(n-1)-i]:
            print("No")
            exit()
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

ll mpow(ll base, ll n) {
  if (n == 0)
    return 1;
  ll prev = mpow(base, n / 2);
  if (n % 2 == 0)
    return (prev * prev) % MOD;
  else
    return (((prev * prev) % MOD) * base) % MOD;
}

int main() {
  ll n, k;
  cin >> n >> k;
  map<ll, ll> mp;
  for (ll i = k; i >= 1; i--) {
    mp[i] = mpow(k / i, n);
    ll p = 2;
    while (p * i <= k) {
      mp[i] -= mp[p * i];
      if (mp[i] < 0)
        mp[i] += MOD;
      assert(mp[i] >= 0);
      p++;
    }
  }
  ll ans = 0;
  rep(i, 1, k + 1) {
    // cerr << i << " " << mp[i] << endl;
    ans += (ll)i * mp[i];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9824
from scipy.misc import comb
N, P = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in range(N):
    B[i] = A[i] % 2

num_1 = sum(B)
num_0 = N - num_1
cnt_num_1 = 0
for i in range(1, num_1+1, 2):
    cnt_num_1 += comb(num_1, i, exact=True) * (2 ** num_0)

if P == 1:
    print(cnt_num_1)
else:
    print(2 ** N - cnt_num_1)

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};

mint f(int n)
{
    if(n==0)return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2==1) x*=2;
    return x;
}

mint combi(int n, int r){
    mint x = 1, y = 1;
    rep(i,r){
        // 分子
        x *= (n-i);
        // 分母
        y *= i+1;
    }
    return x/y;
}

int main()
{
    ll con = pow(10, 9) + 7;
    ll n, a, b;
    mint rel;
    cin >> n >> a >> b;
    rel = 0;
    // 全事象
    rel = f(n);
    rel -=1;
    rel -= combi(n,a);
    rel -= combi(n,b);
    // 余事象
    cout << rel.x << endl;
    return 0;
}

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

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

    ll r,g,b,n;
    cin >> r >> g >> b >> n;
    ll ans = 0;
    for (ll i = 0; i <= n; i++){
        for (ll j = 0; j <= n; j++){
            ll x = n - (r*i + g*j);
            if (x >= 0 && x%b == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3592
a = []
ans = 0
while 1:
    s = input()
    a.append(s)
    if s == "=" :
        break

ans = int(a[0])
for i in range(len(a)//2):
    if a[2*i + 1] == "+":
        ans += int(a[2*i +2])
    elif a[2*i + 1] == "-":
        ans -= int(a[2*i +2])
    elif a[2*i + 1] == "*":
        ans *= int(a[2*i +2])
    elif a[2*i + 1] == "/":
        ans //=int(a[2*i +2])
    elif a[2*i + 1] == "=":
        print(ans)


Measured memory_bytes: 5596
N, M = map(int, input().split())
n_list = [[int(i) for i in input().split()] for i in range(N)] 
m_list = [[int(i) for i in input().split()] for i in range(M)] 

def cal_distance(x1, x2, y1, y2):
    return abs(x1 - x2) + abs(y1 - y2)

for n in n_list:
    distance = 10 ** 16
    index = 0
    ans = 0
    for m in m_list:
        index += 1
        if distance > cal_distance(n[0], m[0], n[1], m[1]):
            distance = cal_distance(n[0], m[0], n[1], m[1])
            ans = index

    print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)















int main(){
    ll h, n;
    cin >> h >> n;
    REP(i, n){
        ll a;
        cin >> a;
        h -= a;
    }
    cout << ((h <= 0)? "Yes" : "No") << endl;
}

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

int pow(int n, int x){
   if(x == 0)
     return 1;
   if(x == 1)
     return n;
   int power = pow(n, x / 2);
   if(x % 2 == 0)
     return ((power % MOD) * (power % MOD)) % MOD;
   else
     return ((n % MOD) * (power % MOD) * (power % MOD)) % MOD;
}

int32_t main(){
    int x;
    cin >> x;
    cout << !x;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(void)
{
  int a,b,c;
  cin>>a>>b>>c;
  int color=3;
  
  if(a==b){color--;}
  if(b==c){color--;}
  if(c==a){color--;}
  if((a==b)&&(b==c)&&(c==a)){color=1;}
  
  cout<<color<<endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    vector<ll> c(m);
    vector<ll> path(m);
    priority_queue<pair<ll, int>> ind;
    vector<pair<int, int>> ls(m);
    int maxr = 0;
    for (int i = 0; i < m; ++i) {
        cin >> l[i] >> r[i] >> c[i];
        maxr = max(maxr, r[i]);
        ls[i].first = l[i];
        ls[i].second = i;
    }
    if (maxr < n) {
        cout << "-1\n";
        return 0;
    }
    r.push_back(1);
    sort(ls.begin(), ls.end());
    if (ls[0].first > 1) {
        cout << "-1\n";
        return 0;
    }

    ind.push({100000000000000000LL, r.size() - 1});
    vector<int> buff;
    for (int i = 0; i < m; ++i) {
        if (i > 0) {
            if (ls[i].first != ls[i - 1].first) {
                for (int j = 0; j < buff.size(); ++j) {
                    ind.push({100000000000000000LL - path[buff[j]], buff[j]});
                }
                buff.clear();
            }
        }
        while (!ind.empty() && r[ind.top().second] < ls[i].first) {
            ind.pop();
        }
        if (ind.empty()) {
            cout << "-1\n";
            return 0;
        }
        buff.push_back(ls[i].second);
        path[ls[i].second] = 100000000000000000LL - ind.top().first + c[ls[i].second];
    }
    ll ans = 100000000000000000LL;
    for (int i = 0; i < m; ++i) {
        if (r[i] == n) {
            ans = min(ans, path[i]);
        }
    }
    cout << ans << '\n';

    return 0;
}


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

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

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


int main()
{
    /*A
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3])
    {
        if(s[1]==s[2])
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
    }
    */
    int n;
    cin>>n;
    vector <int> a(n);
    rep(i,n)
    {
        cin>>a[i];
    } 
    int count=0;
    for(int i=1;i<n-1;i++)
    {
        if(a[i]>a[i-1] && a[i]<a[i+1])
        {
            count++;
        }
        else if(a[i]>a[i+1]&&a[i]<a[i-1])
        {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

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

int main(){
  int a,b;
  
    cin>>a>>b;
 int d[120];
  
 for (int i =0;i<a;i++){
     cin >>  d[i] ;
 }
  
     int e = b;
  
 
  for(int j =0;j<a;j++){
    
       e -= d[j];
    }
  sort(d,d+a);
  
    cout << a+(e/d[0]) << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int d[n][2];
    for (int i=0;i<n;i++){
        cin>>d[i][0]>>d[i][1];
    }
    bool flag=false;
    for (int i=0;i<n-2;i++){
        if(d[i][0]==d[i][1] and d[i+1][0]==d[i+1][1] and d[i+2][0]==d[i+2][1]){
            flag=true;
        }
    }
    if(flag) cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3632
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		Scanner sc=new Scanner(System.in);
		String buf;
		buf=sc.nextLine();
		int a=Integer.parseInt(buf.split(" ")[0]);
		int b=Integer.parseInt(buf.split(" ")[1]);
		if(a<=8 && b<=8){
			System.out.println("Yay!");
		}else{
			System.out.println(":(");
		}
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
}

Measured memory_bytes: 23252
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,K = map(int,input().split())

    mod = 10 ** 9 + 7

    res = 0

    for i in range(K,N+2):
        r = (2 * N - i + 1) * i // 2
        l = (i - 1) * i // 2
        res += r - l + 1
        res %= mod

    print(res)



main()


Measured memory_bytes: 9188
c = []
for i in range(3):
    c.append([int(x) for x in input().split(' ')])

for i in range(2):
    for j in range(2):
        if c[i][j+1]-c[i][j] != c[i+1][j+1]-c[i+1][j]:
            print('No')
            exit()
    
print('Yes')

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

using namespace std;

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

using ll = long long;

ll dxor(ll X, int digit) {
  if (digit == 60 || X <= 0) return 0LL;
  ll xd = (1LL << digit);
  ll per = (1LL << (digit + 1));
  ll x = (X / per) * per / 2;
  if ((X / xd) % 2 != 0) {
    x += X % xd + 1;
  }
  ll res = x % 2 == 0 ? 0 : xd;
  return dxor(X, digit + 1) + res;
}

int main() {
  ll A, B;

  cin >> A >> B;
  cout << (dxor(B, 0) ^ dxor(A-1, 0)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

  int A,B,result;
  
  cin >> A >> B;
  
  if (A <= 9 && B <= 9) {
  
    result = A*B;
    
  }else{
    result = -1;
  }
    
  cout << result << endl;
  
}

Measured memory_bytes: 256
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N=int(input())
S=[input() for i in range(N)]
S=Counter(S)

for s in ["AC","WA","TLE","RE"]:
    print(s,"x",S[s])


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int x;
  cin >> x;
  if (x >= 30) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 3644
#!/usr/bin/env python

def chmin(a, b):
    return b if a > b else a

def chmax(a, b):
    return b if a < b else a

def main(N, h):
    INF = 10 ** 9
    dp = [INF] * (10 ** 5 + 10)
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
    return dp[N-1]

if __name__ == '__main__':
    N = int(input())
    h = list(map(int, input().split()))
    print(main(N, h))


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

int main(){
	string n;  cin >> n;
	long sum = 0;
	for(auto ni : n){
		sum += (long)(ni - '0');
	}
	
	string ans = "Yes";

	if(sum % 9)  ans = "No";

	cout << ans << endl;

	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(M);
  vector<int>D(M);
  vector<int>E(N);
  vector<int>F(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
    E.at(i) = 1000000000;
  }
  for (int i = 0; i < M; i++) {
    cin >> C.at(i) >> D.at(i);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (E.at(i) > abs(A.at(i) - C.at(j)) + abs(B.at(i) - D.at(j))) {
        E.at(i) = abs(A.at(i) - C.at(j)) + abs(B.at(i) - D.at(j));
        F.at(i) = j + 1;
      }
    }
    cout << F.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double dp[3000][3000];
double P[30000];
int main() {
      int n,i,j;
      cin>>n;
      for(i=0;i<n;i++){
      	cin>>P[i];
      }
      dp[0][0]=1;
      for(i=1;i<=n;i++){
      	dp[0][i]=0;
      }
      for(i=1;i<=n;i++){
      	dp[i][0]=dp[i-1][0]*(1-P[i-1]);
      }
      for(i=1;i<=n;i++){
      	for(j=1;j<=n;j++){
      		dp[i][j]=dp[i-1][j]*(1-P[i-1])+dp[i-1][j-1]*P[i-1];
      	}
      }
      double sum=0;
     /* for(i=0;i<=n;i++){
      	for(j=0;j<=n;j++){
      	cout<<dp[i][j]<<" ";
      	}
      	cout<<endl;
      }*/
      for(i=(n+1)/2;i<=n;i++){
      	sum+=dp[n][i];
      }
      cout<<fixed<<setprecision(10)<<sum<<endl;
	return 0;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double

signed main(){
    int a,b;
    cin>>a>>b;
    if(a>b)
    cout<<"a > b"<<endl;
    else if(a<b)
    cout<<"a < b"<<endl;
    else
    cout<<"a == b"<<endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    ll A[N];
    rep(i,0,N) cin>>A[i];
    vector<ll> v;
    v.pb(0);
    rep(i,0,N){
        v.pb(v[i]+A[i]);
    }
    sor(v);
    vector<ll> res;
    int l=0,r=0;
    while(l<N+1){
        while(r<N+1&&v[r]==v[l]){
            r++;
        }
        res.pb(r-l);
        l=r;
    }
    ll ans=0;
    rep(i,0,sz(res)){
        ans+=(res[i]-1)*res[i]/2;
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int A[114514];
double mean;

int main() {
  scanf("%d", &N);
  rep(i, N) {
    scanf("%d", &A[i]);
    mean += A[i];
  }
  mean /= N;

  int ans = 0;
  rep(i, N) {
    if (abs(mean-A[i]) < abs(mean-A[ans])) {
      ans = i;
    }
  }
  printf("%d\n", ans);
}


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

int main(){

    int n, d, x;
    cin >> n;
    cin >> d >> x;
    int cnt = 0;
    vector<int> a(n);

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

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            if(a[i]*j < d){
                cnt++;
            }
        }
    }
    cout << cnt+x << endl;

    return 0;
}

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

int main(){
    int x,y,n,d;
    double Min = 999999999;
    int book = 1;
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++){
        scanf("%d",&d);
        double temp = x - d * 0.006;
        temp = fabs(y - temp);
        if(temp < Min){
            Min = temp;
            book = i;
        }
    }
    printf("%d\n",book);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

void swap(int * a, int * b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

void print_int(int n)
{
    printf("%d\n",n);
    
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

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

    return sum;
}


void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            //intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}




int main(void)
{
   char s[4];
   scanf("%s", s);
   int a, b;
   a = (s[0] - '0')*10 + s[1] - '0';
   b = (s[2] - '0')*10 + s[3] - '0';
   if(b >= 1 && b <= 12 || a >= 1 && a <= 12)
   {
       if(a >= 1 && a <= 12 && b >= 1 && b <= 12)
       {
           printf("AMBIGUOUS");
       }
       else if(b >= 1 && b <= 12)
       {
           printf("YYMM");
       }
       else
       {
           printf("MMYY");
       }
   }
   else
   {
       printf("NA");
   }
   
   
   

    return 0;
}



Measured memory_bytes: 128
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N);
  vector<int64_t> B(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  queue<int64_t> B_is_smaller;
  queue<int64_t> A_is_smaller;
  for (int64_t i = 0; i < N; ++i) {
    cin >> B[i];
    if (A[i] > B[i]) {
      B_is_smaller.emplace(A[i] - B[i]);
    } else if (A[i] < B[i]) {
      A_is_smaller.emplace(B[i] - A[i]);
    }
  }

  auto IncrementA = [&](const int64_t amount) -> bool {
    if (A_is_smaller.empty()) {
      return false;
    }
    int64_t remain = amount;
    while (!A_is_smaller.empty()) {
      int64_t d_A_smaller = A_is_smaller.front();
      A_is_smaller.pop();
      if (d_A_smaller >= 2) {
        d_A_smaller = (d_A_smaller / 2) * 2;
      }
      if (remain == d_A_smaller) {
        remain = 0;
        break;
      } else if (remain > d_A_smaller) {
        remain -= d_A_smaller;
      } else {
        d_A_smaller -= remain;
        A_is_smaller.emplace(d_A_smaller);
        remain = 0;
        break;
      }
    }
    if (remain > 0) {
      return false;
    }
    return true;
  };

  while (!B_is_smaller.empty()) {
    int64_t d_B_smaller = B_is_smaller.front();
    B_is_smaller.pop();
    const bool incremented = IncrementA(d_B_smaller * 2);
    if (!incremented) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3880
MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '3
  1 2 3
  1
  5'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

n = line[0].to_i
arr1 = line[1].split.map(&:to_i)
m = line[2].to_i
arr2 = line[3].split.map(&:to_i)


cnt = 0
arr2.each do |key|
  left = 0
  right = n
  while left<right
    mid = (left+right)/2
    if(arr1[mid]==key)
      cnt+=1
      break
    elsif key<arr1[mid]
      right = mid
    else
      left = mid+1
    end
  end
end
puts cnt

Measured memory_bytes: 17276
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()

bool right(int d,int m) {
	if(d%10<2) return false;
	if(d/10<2) return false;
	if(m==(d%10)*(d/10)) return true;
	return false;
}

signed main() {
    std::ios_base::sync_with_stdio(0); 
    std::cin.tie(0);
	int M,D;
	std::cin >> M >> D;
	int count = 0;
	for(int m=1;m<=M;m++) for(int d=1;d<=D;d++) count+=(int)right(d,m);
	print(count);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

template <typename T>
class FixedQueue
{
public:

    typedef typename std::deque<T>::iterator iterator;
    typedef typename std::deque<T>::const_iterator const_iterator;

    //! サイズ指定コンストラクタ
    FixedQueue(size_t size)
    {
        que.resize(size);
    }

    //! 後ろに要素を追加
    void push_back(const T&& t)
    {
        que.pop_front();
        que.push_back(t);
    }

    void push_back(const T& t)
    {
        que.pop_front();
        que.push_back(t);
    }

    //! 前に要素を追加
    void push_front(const T&& t)
    {
        que.pop_back();
        que.push_front(t);
    }

    void push_front(const T& t)
    {
        que.pop_back();
        que.push_front(t);
    }

    iterator begin() { return que.begin(); }
    const_iterator begin() const { return que.begin(); }

    iterator end() { return que.end(); }
    const_iterator end() const { return que.end(); }

private:

    std::deque < T > que;       //!< データが格納されているコンテナ
};

void solve() {
    map<ll,int> mp;
    int N;
    cin >> N;
    REP(_,N) {
        int a; cin >> a;
        if(!mp.count(a)) mp[a] = 0;
        mp[a]++;
    }

    FixedQueue<ll> que(2);
    for(const auto &p: mp) {
        auto [v,cnt] = p;
        if (cnt >= 4) {
            que.push_back(v);
            que.push_back(v);
        } else if (cnt >= 2) {
            que.push_back(v);
        }
    }

    ll ans = 1;
    for(const auto &it: que) ans *= it;

    cout << ans << endl;


}

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

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

using i64 = int64_t;

int main(){
    i64 n;
    cin >> n;
    int ans = 0;
    while(n > 1){
        n = (n+2)/3;
        ans++;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3088
// 解説AC	:(
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<30)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  sort(a.begin(), a.end());
  
  ll ans1 = a[N-1];
  ll dis = INF;
  ll ans2;
  rep(i, N) {
    if(abs(a[i]-ans1/2.0) < dis) {
      dis = abs(a[i]-ans1/2.0);
      ans2 = a[i];
    }
  }

  cout << ans1 << " " << ans2 << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 4084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct node{
  int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int);
void init(void);
void printList(void);
void deleteFirst(void);
void deleteLast(void);
void delete(int);
void insert(int);
 
int main(){
  int n,i,num,np,nd,size;
  char order[11];
 
  init();
  size = np = nd = 0;
 
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%s %d" ,order ,&num);
 
    if(order[0] == 'i'){
      insert(num);
      np++; 
      size++;
    }else if(order[0] == 'd'){
      if(strlen(order) > 6){
    if(order[6] == 'F'){
      deleteFirst();
    }else if(order[6] == 'L'){
      deleteLast();
    }
      }else{
    delete(num);
    nd++;
      }
      size--;
    }
  }
  printList();
 
  return 0;
}
 
NodePointer listSearch(int key){
  NodePointer x,y;
 
  y = nil;
  x = y->next;
 
  while(x != nil){
    if(x->key == key){
      return y;
    }
    y = x;
    x = y->next;
  }
  return NULL;
}
 
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
  nil->key = -1;
}
 
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
 
  while(1){
    if(cur == nil) break;
    if(isf == 0) printf(" ");
    printf("%d" ,cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteFirst(){
  NodePointer x,y;
 
  x = nil->next;
  y = x->next;
  y->prev = nil;
  nil->next = y;
  free(x);
}
 
void deleteLast(){
  NodePointer x,y;
 
  x = nil->prev;
  y = x->prev;
  y->next = nil;
  nil->prev = y;
  free(x);
}
 
void delete(int key){
  NodePointer x,y,z;
 
  if(nil->next->key == key){
    deleteFirst();
    return;
  }
 
  x = listSearch(key);
  if(x == NULL){
    return;
  }
  z = x->next;
 
  y = x->next->next;
  x->next = y;
  y->prev = x;
   
  free(z);
}
 
void insert(int key){
  NodePointer x,y;
  x = malloc(sizeof(struct node));
  x->key = key;
   
  y = nil->next;
  nil->next = x;
  x->prev = nil;
  x->next = y;
  y->prev = x;
}


Measured memory_bytes: 33004