akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,k;
    cin >> n >> k;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    vector<ll> vec;
    REP(i,n){
        ll sum = 0;
        for(int j = i; j < n; j++){
            sum += a[j];
            vec.push_back(sum);
        }
    }
    ll ans = 0;
    for(int i = 40; i >= 0; i--){
        ll mask = 1LL << i;
        int cnt = 0;
        vector<ll> use;
        REP(j,vec.size()){
            if(vec[j] & mask){
                cnt++;
                use.emplace_back(vec[j]);
            }
        }
        if(cnt >= k){
            ans += mask;
            vec = use;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6384
// 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,prev=0,set_v=100000000000;
  map<ll,ll> mp,mpv;
  cin >> n;
  vector<ll> a(n),ans(n,0);
  mp[0] = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(mp[a[i]]==0){
      mpv[a[i]] = i;
    }
    mp[a[i]]++;
  }
  vector<P> cpm(mp.begin(),mp.end());
  sort(cpm.begin(),cpm.end(),greater<P>());
  for(auto itr=cpm.begin();(itr+1)!=cpm.end();itr++){
    ll v = itr->first;
    ll nv = (itr+1)->first;
    ll dis =v-nv;
    set_v = min(set_v,mpv[v]);
    ans[set_v] += dis*(itr->second+prev);
    prev += itr->second;
  }
  for(auto i:ans){
    cout << i << endl;
  }
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=a;i++){
		int cnt=0;
		cnt+=4*i;
		cnt+=2*(a-i);
		if(cnt==b){
			cout<<"Yes"<<endl;
			return 0; 
		}
	}
	cout<<"No"<<endl;
	return 0;
 } 

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

vector<int> dp(100005);

int main(){
    
    int n,k; 
    cin>>n>>k;
    
    vector<int> v (n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    
    dp[0] = 0;
    
    for(int i=1; i<n; i++){
        int x = INT_MAX;
        for(int j=1; j<=k; j++){
            
            if(j<=i){
            dp[i] = min((dp[i-j]+abs(v[i]-v[i-j])),x);
            x = dp[i];
            }
        }
        
    }
    cout<<dp[n-1]<<endl;
    
}



Measured memory_bytes: 4028
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>

/*naci najkrace puteve od cvora x do svih ostalih cvorova u grafu. Slozenost O(n log n) */
/*dva vektora se koriste */
using namespace std;

const long long inf=-1e15;
const int maxN=1e5+5;

long long d[maxN],ob[maxN],c;
int tr,n,m,l,r,x;
priority_queue< pair <long long,int> > pq;
vector < int > g[maxN];
vector< long long > g1[maxN];
int q,k;
void pre_cal()
{
    for (int i=1;i<=n;i++)
        d[i]=inf;
}

void dijkstra(int x)
{
    pre_cal();
    d[x]=0;
    pq.push({0,x});

    while (!pq.empty())
    {
       tr=pq.top().second;
       if (!ob[tr]){
       ob[tr]=1;
       pq.pop();

       for (int i=0;i<g[tr].size();i++)
       {
          if (ob[g[tr][i]]==0 && d[tr]-g1[tr][i]>d[g[tr][i]])
          {
              d[g[tr][i]]=d[tr]-g1[tr][i];
              pq.push({d[g[tr][i]],g[tr][i] });
          }
       }

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

    for (int i=1;i<n;i++)
    {
        scanf("%d%d%lld",&l,&r,&c);
        g[l].push_back(r);
        g1[l].push_back(c);
        g[r].push_back(l);
        g1[r].push_back(c);
    }

    cin>>q>>x;

     dijkstra(x);

    for (int i=1;i<=q;i++)
    {
        int o,p;
        scanf("%d%d",&o,&p);
        printf("%lld\n",d[o]+d[p]);
    }

    return 0;
}


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

#define ll  long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)

int main(){
    ll m = (ll)1000000007;
    ll x,y;
    cin >> x >> y;
    ll grid[x][y];
    rep(i,0,x){
        rep(j,0,y){
            char c;
            cin >> c;
            if(c == '.'){
                grid[i][j] = 1;
            }
            else grid[i][j] = 0;
        }
    }
    rep(i,0,x){
        rep(j,0,y){
            if(i == 0 && j == 0)continue;

            if(grid[i][j] == 1){
                if(j - 1 < 0){
                    grid[i][j] = grid[i - 1][j] % m ;
                }
                else if(i - 1 < 0){
                    grid[i][j] = grid[i][j - 1] % m;
                }
                else grid[i][j] = (grid[i][j - 1] + grid[i - 1][j]) % m;
            }
        }
    }
    cout << grid[x - 1][y - 1];
}

Measured memory_bytes: 8064
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

int main(){
    llong A,B,C,D;
    cin >> A >> B >> C >> D;
    if((A*B)<=(C*D)){
        cout << C*D << endl;
    }else{
        cout << A*B << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int n,m;
ll x[1010],y[1010],z[1010];
vector<ll> choice;

int main(){
	cin>>n>>m;
	ll sum=0;
	ll mx=0;
	ll ans=-10000000000000000;
	REP(i,n){
		cin>>x[i]>>y[i]>>z[i];
	}
	REP(i,2)REP(j,2)REP(k,2){
		mx=0;
		choice.clear();
		REP(l,n){
			sum=0;
			if(i%2==0)sum+=x[l];
			else sum-=x[l];
			if(j%2==0)sum+=y[l];
			else sum-=y[l];
			if(k%2==0)sum+=z[l];
			else sum-=z[l];
			choice.pb(sum);
		}
		sort(choice.begin(),choice.end(),greater<ll>());
		REP(l,m)mx+=choice[l];
		if(ans<mx)ans=mx;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())

    if a % 2 != 0 and b % 2 != 0 and c % 2 != 0:
        print(min(a*b, b*c, c*a))
    else:
        print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k; string s; string sp;
char maze[60][60];
int dis[60][60];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	cin >> n >> s; int res = n; vector<int> numa(n); vector<int> numb(n);
	int cnt1 = 0;
	int cnt2 = 0;
	rep(i, n) {
		if (s[i] == '.') {
			cnt2++;
		}
	}
	chmin(res, cnt1 + cnt2);
	rep(i, n) {
		if (s[i] == '#') {
			cnt1++;
		}
		else {
			cnt2--;
		}
		chmin(res, cnt1 + cnt2);
	}
	cout << res << endl;
}

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

int main(){
  int n;cin>>n;bool f1=0,f2=0;
  if(n%100>=1&&n%100<=12) f2=1;
  n/=100;
  if(n%100>=1&&n%100<=12) f1=1;

  cout<<(f1&&f2?"AMBIGUOUS":f1&&!f2?"MMYY":!f1&&f2?"YYMM":"NA");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n, m;
	cin>> n;
	int ans = 0;
	for(long long i=2;i<=n;i++){
		if(n<=i*i){
			ans++;
			break;
		}
		if(n%i==0){
			int ansi = 0;
			while(n%i==0){
				n /= i;
				ansi++;
			}
			int a = (int)sqrt(2*ansi);
			for(int j=0; j<=3;j++){
				if(ansi < (a+j)*(a+j+1)/2){
				ans += a+j-1;
				break;
				}
			}
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 3684
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[][] c = new long[10][10];
    for(int i = 1; i <= n; i++) {
      String s = String.valueOf(i);
      int d1 = Integer.parseInt(String.valueOf(s.charAt(0)));
      int d2 = Integer.parseInt(String.valueOf(s.charAt(s.length() - 1)));
      c[d1][d2]++;
    }
    long ans = 0;
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        ans += (c[i][j] * c[j][i]);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 41776
#include<stdio.h>
int main(void)
   {int H[10000], W[10000], i, j, k, l;
    i = 0;
    while(1) {
       scanf("%d %d", &H[i], &W[i]);
       i++;
       if(H[i - 1] == 0 && W[i - 1] == 0)
          break;
    }
    for(j = 0; j < i - 1; j++) {
       for(k = 0; k < H[j] ; k++) {
          if(k % 2 == 0 || k == 0){
             for(l = 0; l < W[j]; l++) {
                if(l % 2 == 0 || l == 0){
                   printf("#");
                }
                else{
                   printf(".");
                }
             }
             printf("\n");
          }
          else{
             for(l = 0; l < W[j]; l++) {
                if(l % 2 == 0 || l == 0){
                   printf(".");
                }
                else{
                   printf("#");
                }
             }
             printf("\n");
          }
       }
       printf("\n");
    }
    return 0;
}

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

using namespace std;

int main()
{
    char s[4];
    cin>>s;
    sort(s,s+4);
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

vector<pair<int,int>> g[100010];
int ans[100010];

void dfs(int node,int par){

	int c = 1;
	int ppi = -1;
	for(int i = 0;i<g[node].size();i++){
		if(g[node][i].ff==par)
			ppi = g[node][i].ss;
	}
	for(auto it:g[node]){
		if(it.ff==par) continue;
		if(ppi!=-1 )if (ans[ppi]==c)c++;
		ans[it.ss] = c;
		dfs(it.ff,node);
			//c++;
		
		c++;
	}

}


int32_t main(){
    IOS;

    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
    	int a,b;
    	cin>>a>>b;
    	g[a].pb({b,i});
    	g[b].pb({a,i});
    }
    memset(ans,0,sizeof ans);
    dfs(1,-1);

    int k = 0;
    for(int i = 0;i<n-1;i++)
    	k = max(k,ans[i]);

    cout<<k<<endl;
    for(int i=0;i<n-1;i++)
    	cout<<ans[i]<<endl;

    return 0;
}

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

int main() {
	string S;
	cin >> S;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (S.at(i) == 'R') {
			count++;
			break;
		}
	}
			for (int i = 0; i < 2; i++) {
				if (S.at(i) == 'R' && S.at(i + 1) == 'R') {
					count++;
				}
			}
			cout << count << endl;
		}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll n,a[200005],tr[200005][16],hell=pow(10,15);
vector<ll> func(){
	vector<ll> dp(n+2,0);
	for(ll i=0;i<16;i++)
	tr[n][i]=i;
	for(ll i=n-1;i>=1;i--){
		ll p=1,t=1,c=0;
		dp[i]=hell;
		for(ll j=0;j<16;j++){
			while((1.0*a[i+1]/p)<(1.0*a[i]/t)){
				t*=4;
				c++;
			}
			tr[i][j]=j+tr[i+1][min(ll(15),c)]+(n-i)*max(ll(0),c-15);
			p*=4;
			dp[i]=min(dp[i],tr[i][j]);
		}
	}
	return dp;
}
void solve(){
	cin>>n;
	for(ll i=1;i<=n;i++)
	cin>>a[i];
	vector<ll> dp=func();
	reverse(a+1,a+n+1);
	for(ll i=1;i<=n;i++)
	a[i]*=2;
	vector<ll> pd=func();
	reverse(pd.begin(),pd.end());
	ll res=hell;
	for(ll i=1;i<=n+1;i++)
	res=min(res,2*(dp[i]+pd[i-1])+i-1);
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 33036
n = int(input())

f = [0] * 10**5
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            f[i**2+j**2+k**2+i*j+j*k+k*i] += 1

for i in range(1, n+1):
    print(f[i])

Measured memory_bytes: 75052
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    vector<int> x(15, -1);

    int exp = 0;
    while (true) {
        int mod = N % 26;
        if (mod == 0) {mod = 26;}
        x[exp] = mod;
        N -= mod;
        if (N <= 0) {break;}
        N /= 26;
        exp++;
    }

    reverse(x.begin(), x.end());

    vector<char> _res;
    for (auto i : x) {
        if (i > 0) {
            char c = char(97 + i -1);
            _res.push_back(c);
        }
    }

    string res = string(_res.begin(), _res.end());

    cout << res << endl;
    
}


Measured memory_bytes: 3112
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;

  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }

  inline T fact(int k) const { return _fact[k]; }

  inline T rfact(int k) const { return _rfact[k]; }

  inline T inv(int k) const { return _inv[k]; }

  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }

  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

using mint = modint998244353;

signed main(){
	Combination<mint>bc(500050);
	int N;
	cin >> N;
	vector<int>h(2 * N);
	cin >> h;
	using T = pair<int, vector<mint>>;
	priority_queue<T, vector<T>, function<bool(T, T)>>que(
		[](T a, T b){return a.first > b.first;}
	);
	vector<mint>fa(2 * N + 1, 1);
	for(int i = 2; i < fa.size(); i++) {
		fa[i] *= fa[i - 2] * i;
	}
	{
		map<int, int>mp;
		for(auto e: h) {
			mp[e]++;
		}
		for(auto [hoge, cnt]: mp) {
			vector<mint>ret(cnt / 2 + 1, 1);
			REP(i, cnt / 2 + 1) {
				ret[i] = bc.C(cnt, cnt - i * 2) * (i ? fa[i * 2 - 1] : 1);
			}
			que.push({ret.size(), ret});
		}
	}
	while(que.size() >= 2) {
		auto a = que.top().second;
		que.pop();
		auto b = que.top().second;
		que.pop();
		auto c = convolution(a, b);
		que.push({c.size(), c});
	}
	auto dp = que.top().second;
	mint ans = 0;
	REP(i, dp.size()) {
		//out(i, dp[i].val());
		mint mul = (N * 2 - i * 2 - 1 >= 0 ? fa[N * 2 - i * 2 - 1] : 1);
		ans += (i % 2 ? -dp[i] : dp[i]) * mul;
	}
	out(ans.val());
}

Measured memory_bytes: 22788
using System;
class Program
{
  static void Main (string[] args)
  {
    int N = int.Parse(Console.ReadLine());
    string[] input = Console.ReadLine().Split(' ');
    int[] mountains = new int[N];
    for (int i = 0; i < N; i++) {
      mountains[i] = int.Parse(input[i]);
    }
    
    int count = 0;
    for (int i = 0; i < N; i++) {
      bool can = true;
      for (int j = 0; j < i; j++) {
        if (mountains[i] < mountains[j]) {
          can = false;
          break;
        }
      }
      if (can) { count++; }
    }
    Console.WriteLine(count);
  }
}

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

int main(int argc, char** argv) {
	int a, b;
	int num = 0;
	cin >> a >> b;

	do {
		if (b == 1) {
			num = 0;
			break;
		}
		num++;
	} while ((((a - 1) * (num - 1)) + a) < b);

	cout << num << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long long N, i, j, I, p[1005], c;
    scanf("%lld", &N);
    for (i=2; i<=N; i++) {
        p[i]=0;
    }
    for (i=2; i<=N; i++) {
        I=i;
        for (j=2; j<=i; j++) {
            while (I%j==0) {
                I/=j;
                p[j]++;
                // printf("%d, %d\n", i, j);
            }
        }
    }
    c=1;
    for (i=2; i<=N; i++) {
        c*=p[i]+1;
        c%=1000000007;
    }
    printf("%lld", c);
    /*
    for (i=2; i<=N; i++) {
        printf("p[%d] == %d\n", i, p[i]);
    }
    */
    return 0;
}

Measured memory_bytes: 128
N, X = map(int, input().split())
Size = [1]
Patty = [1]

for i in range(51):
    Size.append(Size[-1] * 2 + 3)
    Patty.append(Patty[-1] * 2 + 1)


def count_p(n, x):
    if x == 0:
        return 0
    if n == 0:
        return min(x, 1)
    if (Size[n]+1) // 2 > x:
        return count_p(n-1, x-1)
    elif (Size[n]+1) // 2 == x:
        return Patty[n-1] + 1
    else:
        return Patty[n-1] + 1 + count_p(n-1, x - ((Size[n]+1) // 2))


print(count_p(N, X))

Measured memory_bytes: 3064
n, m = map(int, input().split())
list_a = list(map(int, input().split()))
cnt = 0
sum_a = sum(list_a)
bdr = sum_a / (4 * m)
for a in list_a:
    if a >= bdr:
        cnt += 1
print('Yes' if cnt >= m else 'No')

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            string result = "";

            string line1 = Console.ReadLine();
            string line2 = Console.ReadLine();
            string line3 = Console.ReadLine();


            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            for (int j = 0; j < n; ++j) {
                // 整数の入力
                string num = Console.ReadLine();

                line1 = line1.Replace(num, "0");
                line2 = line2.Replace(num, "0");
                line3 = line3.Replace(num, "0");
            }

            // 整数配列の入力
            var line1Array = line1.Split(' ').Select(i => long.Parse(i)).ToArray();
            var line2Array = line2.Split(' ').Select(i => long.Parse(i)).ToArray();
            var line3Array = line3.Split(' ').Select(i => long.Parse(i)).ToArray();

            if(line1Array.Sum() == 0 || line2Array.Sum() == 0 || line3Array.Sum() == 0) {
                Console.WriteLine("Yes");
                return;
            }

            for (int i = 0; i < 3; ++i) {
                if (line1Array[i] == 0 && line2Array[i] == 0 && line3Array[i] == 0) {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            if(line1Array[0] == 0 && line2Array[1] == 0 && line3Array[2] == 0) {
                Console.WriteLine("Yes");
                return;
            }

            if (line1Array[2] == 0 && line2Array[1] == 0 && line3Array[0] == 0) {
                Console.WriteLine("Yes");
                return;
            }

            Console.WriteLine("No");

        }
    }
}

Measured memory_bytes: 19048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const int n = s.size();
	vector<int> h(3);
	for(int i = 0; i < n; ++i){ ++h[s[i] - 'a']; }
	const int t = n / 3;
	bool answer = true;
	for(int i = 0; i < 3; ++i){
		if(h[i] != t && h[i] != t + 1){ answer = false; }
	}
	cout << (answer ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var p = Console.ReadLine();
            var s = Console.ReadLine();
            p += p;

            var result = p.Contains(s) ? "Yes" : "No";
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 9820
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

int main(){
    int n,ans=0;;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,n) {
        bool a=true;
        for(int j=0;j<i;j++){
            if(h[j]>h[i]){
                a=false;
                break;
            }
        }
        if(a)ans++;
    }
    cout << ans << endl;
}


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

vector<int> edge[100010];

int dfs(int from, int par) {
	int ret = 0;
	for(int to : edge[from]) {
		if(to == par) continue;
		ret ^= dfs(to, from) + 1;
	}
	return ret;
}

int main() {
	int n; cin >> n;
	for(int i = 0; i < n - 1; ++i) {
		int x, y; cin >> x >> y;
		--x, --y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	if(dfs(0, -1) == 0) {
		cout << "Bob" << '\n';
	} else {
		cout << "Alice" << '\n';
	}
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int		main(void)
{
	ll A, B;
	cin >> A >> B;
	int ans = 0;
	ll mx = max(A, B);
	for (int i = 1; i <= sqrt(mx); i++)
	{
		if (mx % i == 0)
		{
			ll another = mx / i;
			if (A % another == 0 && B % another == 0)
			{
				if (IsPrime(another))
					ans++;
			}
		}
		if (A % i == 0 && B % i == 0)
		{
			if (IsPrime(i))
				ans++;
		}
	}
	cout << ++ans << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
  class Program
  {
    static void Main(string[] args)
    {
      int n = int.Parse(Console.ReadLine());
      while(n-- != 0){ 
        var a = Console.ReadLine().Split(' ').Select( x => int.Parse(x)).ToArray();
        Array.Sort(a);
        Console.WriteLine("{0}",a[0]*a[0]+a[1]*a[1] == a[2]*a[2]? "YES": "NO");
      }
    }
  }
}

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

using namespace std;
typedef  long long ll;

int main()
{
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string res;
    while (n>0){
        int i = (n-1) % 26;
        char c = 'a' + i;

        res = c + res;

        n = (n-1) / 26;
    }cout << res;
    return 0;
}


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

using namespace std;

const int INF = 1 << 30;

int H[4], W[4];
int A[4][2000][2000];
int big, small;

int reach[2000];

bool check2(int i, int v)
{
  const int low = big - v;
  const int high = small + v;

  for(int j = 0; j < H[i]; j++) {
    reach[j] = 0;
    while(reach[j] < W[i] && A[i][j][reach[j]] <= high) ++reach[j];
    if(j > 0) reach[j] = min(reach[j], reach[j - 1]);
  }
  for(int j = 0; j < H[i]; j++) {
    for(int k = reach[j]; k < W[i]; k++) {
      if(A[i][j][k] < low) return (false);
    }
  }
  return (true);
}

bool check(int v)
{
  for(int i = 0; i < 4; i++) if(check2(i, v)) return (true);
  return (false);
}


int main()
{
  cin >> H[0] >> W[0];

  big = -INF;
  small = INF;

  for(int i = 0; i < H[0]; i++) {
    for(int j = 0; j < W[0]; j++) {
      cin >> A[0][i][j];

      big = max(big, A[0][i][j]);
      small = min(small, A[0][i][j]);
    }
  }

  for(int i = 1; i < 4; i++) {
    H[i] = W[i - 1], W[i] = H[i - 1];
    for(int j = 0; j < H[i - 1]; j++) {
      for(int k = 0; k < W[i - 1]; k++) {
        A[i][W[i - 1] - k - 1][j] = A[i - 1][j][k];
      }
    }
  }

  int ok = big - small, ng = -1;
  while(ok - ng > 1) {
    int mid = (ok + ng) >> 1;
    if(check(mid)) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;
}

Measured memory_bytes: 65580
//答え見ました
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  deque<int>d;
  for(int i=0; i<n; i++){
    int p = lower_bound(d.begin(),d.end(),a[i])-d.begin();
    if(p==0){
     d.push_front(a[i]); 
    }
    else d[p-1] = a[i];
  }
  int ans = d.size();
  cout << ans << endl;
  
}
  


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

int main(void)
{
  int a, b;
  char c;
  std::cin >> a >> c >> b;

  int ans;
  if (c == '+') {
    ans = a + b;
  }
  else {
    ans = a - b;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3584
import Data.List

solver::[Int]->Int->Int
solver xs n = sum (take n (sortBy (\x y-> compare y x) xs))

main::IO()
main=do
  nkc<-getLine
  let n:k:[]=map read (words nkc)
  datc<-getLine
  let dat = map read (words datc)
  print (solver dat k)

Measured memory_bytes: 764
object Main extends App {
  
  val sc = new java.util.Scanner(System.in) 
  val S = sc.next().toList.map(_.toString)
  var ans = 999
  for(i <- 0 to (S.length - 3)) {
    val diff = (753 - (S(i) + S(i+1) + S(i+2)).toInt).abs
    ans = ans.min(diff)
  }
  println(ans) 
}

Measured memory_bytes: 55540
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    string S;
    cin >> S;
    for (char i = 'a'; i <= 'z'; i++){
        if (end(S) == find(begin(S), end(S), i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
w,h,n = gets.split.map(&:to_i)
dot = []
n.times do
  dot << gets.split.map(&:to_i)
end

arr_x = Array.new(w,0)
arr_y = Array.new(h,0)

dot.each do |a|
  case a[2]
  when 1
    arr_x.fill(1,0,a[0])
  when 2
    arr_x.fill(1,a[0],w)
  when 3
    arr_y.fill(1,0,a[1])
  when 4
    arr_y.fill(1,a[1],h)
  end
end

p arr_x.count(0) * arr_y.count(0)


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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b; cin >> a >> b;
	if (2 * b >= a) cout << 0 << '\n';
	else cout << a - (2 * b) << '\n';
}

Measured memory_bytes: 3656
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
S=list(map(int,list(input())))

l=[]
count=1
for i in range(N-1):
    if S[i]==S[i+1]:
        count+=1
    else:
        l.append(count)
        count=1
l.append(count)

ans=0
if S[0]==0:
    l=[0]+l

if len(l)%2==0: #エラー回避の長さ調整
    l.append(0)

tgt=sum(l[:2*K+1])
ans=max(ans,tgt)

#lは1から始まることが前提
for i in range(0,len(l)-(2*K+1))[::2]:
    tgt-=l[i]
    tgt-=l[i+1]
    tgt+=l[2*K+1+i]
    tgt+=l[2*K+2+i]
    ans=max(ans,tgt)
    
#print(l)    
print(ans)

Measured memory_bytes: 5400
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 200005
#define ll long long
#define ld double
#define mod 1000000007 
using namespace std;
char inp[maxn];
int a, b, c, d;
bool check(int x, int y)
{
	if(x == y) return 1;
	if(x + 1 <= y && inp[x + 1] == '.')
		return check(x + 1, y);
	else if(x + 2 <= y && inp[x + 2] == '.')
		return check(x + 2, y);
	return 0;
}
int main()
{
	int n;
	cin>>n>>a>>b>>c>>d;
	scanf("%s", inp + 1);
	int ans = 0;
	if(c < d)
		if(check(b, d) && check(a, c)) ans = 1;
		else ans = 0;
	else 
	{
		ans = 1;
		while(1)
		{
			int fl = 0;
			if(a != c)
			{
				if(a + 1 <= c && a + 1 != b && inp[a + 1] == '.') a++, fl = 1;
				else if(a + 2 <= c && a + 2 != b && inp[a + 2] == '.') a += 2, fl = 1;
				else if(b + 1 <= d && b + 1 != a && inp[b + 1] == '.') b++, fl = 1;
				else if(b + 2 <= d && b + 2 != a && inp[b + 2] == '.') b += 2, fl = 1;
			}
			else
			{
				inp[c] = '#';
				ans = check(b, d);
				break;	
			} 
	//		cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
			if(!fl) 
			{
				ans = 0;
				break;
			}
		}
	}
	if(ans) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
const ll one = 1;

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> a(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    a[0] = zero;

    bool check = true;
    vector<ll> imos(N+2);
    ll cnt = zero;
    while(check){
        fill(ALL(imos), 0);
        for (ll i = 1; i <= N; i++) {
            imos[max(one, i-a[i])]++;
            imos[min(N+1, i+a[i]+1)]--;
        }
        check = false;
        for (ll i = 1; i <= N; i++) {
            a[i] = a[i-1] + imos[i];
            if(a[i] != N){
                check = true;
            }
        }

        cnt++;
        if(cnt >= K){
            check = false;
        }


    }
    for (int i = 1; i <= N; i++) {
        printf("%lld ", a[i]);
    }

}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (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 W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

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

int mp[4][4];

int main()
{
	REP(i,3)REP(j,3)cin >> mp[i][j];
	
	REP(i,201)
	{
		REP(j,201)
		{
			REP(k,201)
			{
				int a = i - 100;
				int b = j - 100;
				int c = k - 100;
				bool flag = true;
				REP(q,3)
				{
					if(mp[q][0] - a != mp[q][1] - b)flag = false;
					if(mp[q][2] - c != mp[q][1] - b)flag = false;
					if(mp[q][0] - a != mp[q][2] - c)flag = false;
				}
				if(flag)
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}

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

using namespace std;

#define JAM(x) cout << #x << " = " << x << "\n"
#define II() ({ int a ; read(a) ; a; })
#define LL() ({ ll a ; read(a) ; a; })
#define DD() ({double a; scanf("%lf", &a); a; })

//Fast Reader
template <class T>
inline bool read(T &x)
{
    int c = getchar();
    int sgn = 1;
    while (~c && c < '0' || c > '9')
    {
        if (c == '-')
            sgn = -1;
        c = getchar();
    }
    for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sgn;
    return ~c;
}

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPI;

const int INF = 2e9;
const int MX = 100005;
const int MOD = 1000000007;
const double PI = acos(-1.0);



long long int power(long long int a, long long int b)
{
    a %= MOD;
    long long int res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
bool isprime(int n)
{
    if (n == 1)
        return false;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}


/*_______________________________________________*/



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i;
    cin>>n;
    long long mx=LLONG_MIN,mx1=LLONG_MIN;
    long long mn=LLONG_MAX,mn1=LLONG_MAX;
    for(i=0;i<n;i++)
    {
        long long int x,y;
        cin>>x>>y;
        mx=max(mx,x+y);
        mn=min(mn,x+y);
        mx1=max(mx1,x-y);
        mn1=min(mn1,x-y);
    }
    cout<<max(mx-mn,mx1-mn1);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int A,B,C,K;cin>>A>>B>>C>>K;
  if(abs(A-B)>1000000000000000000){
    print("Unfair");re 0;
  }
  if(K%2==0){
    print(A-B);
  }
  else{
    print(B-A);
  }


}


Measured memory_bytes: 256
s=input()
mod=2019
dp=[0]*mod
k=0
t=1
for x in map(int,s[::-1]):
    k+=t*x
    k%=mod
    dp[k]+=1
    t*=10
    t%=mod
print(sum(i*(i-1)//2 for i in dp)+dp[0])

Measured memory_bytes: 9268
#include <iostream>
using namespace std;
int main() {
	string s; cin >> s;
	int n = s.size();
	int ans = 2000;
	for(int i=0;i<n-2;i++){
		int a = 100*(s[i]-'0')+10*(s[i+1]-'0')+s[i+2]-'0';
		ans = min(ans, abs(753-a));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
var
 s:ansistring;
 i,j,k:longint;
begin
 readln(s);
 for i:=1 to length(s)-2 do
  begin
   k:=0;
   for j:=i to i+2 do
    if s[i]<>s[j] then begin k:=1; break; end;
   if k=0 then begin writeln('Yes'); halt; end;
  end;
 writeln('No');
end.

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>

using namespace std;
#define N 4
#define N2 16

static const int dx[4]={0,-1,0,1};
static const int dy[4]={1,0,-1,0};
static const char dir[4]={'r','u','l','d'};
int MDT[N2][N2];

struct Puzzle{
    int f[N2],space,MD;
    int cost;
    
    bool operator < (const Puzzle& p) const{
        for(int i=0;i<N2;i++){
            if(f[i]==p.f[i]) continue;
            return f[i]<p.f[i];
        }
        return false;
    }
};

struct State{
    Puzzle puzzle;
    int estimated;
    bool operator < (const State& s) const {
        return estimated > s.estimated;
    }
};

int getAllMD(Puzzle pz){
    int ret=0;
    for(int i=0;i<N2;i++){
        if(pz.f[i]==N2) continue;
        ret+=MDT[i][pz.f[i]-1];
    }
    return ret;
}

int Astar(Puzzle s){
    priority_queue<State> PQ;
    s.MD=getAllMD(s);
    s.cost=0;
    map<Puzzle,bool> V;
    Puzzle u,v;
    State initial;
    initial.puzzle=s;
    initial.estimated=getAllMD(s);
    PQ.push(initial);
    
    while(!PQ.empty()){
        State st=PQ.top(); PQ.pop();
        u=st.puzzle;
        
        if(u.MD==0) return u.cost;
        V[u]=true;
        
        int sx=u.space/N;
        int sy=u.space%N;
        
        for(int r=0;r<4;r++){
            int tx=sx+dx[r];
            int ty=sy+dy[r];
            if(tx<0||ty<0||tx>=N||ty>=N) continue;
            v=u;
            
            v.MD -= MDT[tx*N+ty][v.f[tx*N+ty]-1];
            v.MD += MDT[sx*N+sy][v.f[tx*N+ty]-1];
            
            swap(v.f[sx*N+sy],v.f[tx*N+ty]);
            v.space=tx*N+ty;
            if(!V[v]){
                v.cost++;
                State news;
                news.puzzle=v;
                news.estimated=v.cost+v.MD;
                PQ.push(news);
            }
        }
    }
    return -1;
}

int main(){
    for(int i=0;i<N2;i++)
        for(int j=0;j<N2;j++)
            MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
    
    Puzzle in;
            
    for(int i=0;i<N2;i++){
        cin>>in.f[i];
        if(in.f[i]==0){
            in.f[i]=N2;
            in.space=i;
        }
    }
    cout<<Astar(in)<<endl;
    
    return 0;
}


Measured memory_bytes: 257684
#include<iostream>
#include<math.h>
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int n, a[55];
    a[0] = 11;
    cin>>n;

    for(int i=1; i<n; i++) {
        int k = a[i-1]+1;
        while(!IsPrime(k) || k%5!=1) k++;
        a[i]=k;
    }
    for(int i=0; i<n; i++) {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


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



Measured memory_bytes: 256
#include <stdio.h>
int main(){

 int a, b;
 scanf("%d%d", &a, &b);
 if(a < b)
 printf("a < b\n");
 else if(a > b)
 printf("a > b\n");
 else if(a == b)
 printf("a == b\n");

 return 0;

}



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

int main(){
    int a, b, c;
    int sum = 0;
    cin >> a >> b >> c;
    for (int i = a;i <= b;i++){
        if (c % i == 0){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long A = scan.nextLong();
		float B = scan.nextFloat();

		long ans = (A * ((long)(B * 100 + 0.5))) / 100;

		System.out.println(ans);

	}
}

Measured memory_bytes: 37332
#include<stdio.h>
int main(){
  int a,b,max=0;
  scanf("%d %d",&a,&b);
  for(int k=0;k<=1;k++){
  if(a>b){
    max+=a;
    a=a-1;
  }
  else{
    max+=b;
    b=b-1;
  }
  }
  printf("%d\n",max);
  return 0;
}

  
  



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] in = new int[10];
		for(int i=0;i<10;i++){
			in[i] = sc.nextInt();
		}
		int big[] = {0,0,0};
		
		for(int i =0;i<10;i++){
			if(big[0] < in[i]){
				big[2] = big[1];
				big[1] = big[0];
				big[0] = in[i];
			}
			else if(big[1] < in[i]){
				big[2] = big[1];
				big[1] = in[i];
			}
			else if(big[2] < in[i]){
				big[2] = in[i];
			}
		}
		
		for(int i=0;i<3;i++){
			System.out.println(big[i]);
		}
	}

}

Measured memory_bytes: 26044
def float?(str)
  Float(str)
  true
rescue ArgumentError
  false
end

while line = gets
  a = line.chomp.split
  b = []
  while a.any?
    a.join(' ')
    str = a.shift
    if float?(str)
      b << str.to_f
    else
      c = b.pop
      d = b.pop
      b << eval("#{d} #{str} #{c}")
    end
  end

  puts sprintf('%.6f', b.pop + 0.0)
end

Measured memory_bytes: 8744
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        var S = Console.ReadLine();
        var len = S.Length;
        var answer = 1000;
        for (int i = 1; i < len - 1; i++) {
                var x = int.Parse(S[(i - 1)..(i + 2)]);
                var abs = Math.Abs(x - 753);
                answer = Math.Min(answer, abs);
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27540
from collections import defaultdict
from itertools import combinations
from functools import reduce

N = int(input())

S = [0] * N
for _ in range(N):
    S[_] = input()

# solve

nd = defaultdict(int)

for name in S:
    if name[0] in "MARCH":
        nd[name[0]] += 1

if len(nd.keys()) < 3:
    print(0)
    exit()

ans = 0
for trio in combinations(nd.keys(), 3):
    # ans += [nd[x] for x in trio]
    # ans += reduce((lambda x, y: nd[x] * nd[y]), trio)
    ans += nd[trio[0]] * nd[trio[1]] * nd[trio[2]]

print(ans)


Measured memory_bytes: 10220
//gcc -std=gnu11 -O2 -o a.out main.c -lm

#include <stdio.h>

int main(void)
{
    int res;

    int n;
    int k;
    int i;
    int pattern;

    // input
	res = scanf("%d%d", &n, &k);

    // calculate k * (k-1) * (k-1) ...
    for (i = 0; i < n; i++) {
        if (i == 0) {
            pattern = k;
        } else {
            pattern *= (k - 1);
        }
    }

    // output
    printf("%d\n", pattern);

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int N=505;

int val[N][N],dis[N][N];
int n;
int dx[]= {0,0,-1,1};
int dy[]= {-1,1,0,0};
void bfs(int x,int y)
{
    queue<pair<int,int>> q;
    q.push({x,y});
    while(!q.empty())
    {
        pair<int,int>next=q.front();
        q.pop();
        for(int i=0; i<4; i++)
        {
            int nx=next.first+dx[i];
            int ny=next.second+dy[i];
            if(nx==0||nx==n+1||ny==0||ny==n+1)
                continue;
            if(dis[nx][ny]>dis[next.first][next.second]+val[next.first][next.second])
            {
                dis[nx][ny]=dis[next.first][next.second]+val[next.first][next.second];
                q.push({nx,ny});
            }
        }
    }
}
int main()
{
    ll ans=0;
    cin>>n;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
        {
            dis[i][j]=min(min(i-1,j-1),min(n-i,n-j));
            val[i][j]=1;
        }
    int t;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
        {
            cin>>t;
            int x=(t+n-1)/n;
            int y=(t%n==0?n:t%n);
            val[x][y]=0;
            bfs(x,y);
            ans+=dis[x][y];
        }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int n;
  long long ans, march[5] = {0};
  cin >> n;
  string s;
  for(int i = 0; i < n; i++){
    cin >> s;
    if( s[0] == 'M' )
      march[0]++;
    else if( s[0] == 'A' )
      march[1]++;
    else if( s[0] == 'R' )
      march[2]++;
    else if( s[0] == 'C' )
      march[3]++;
    else if( s[0] == 'H' )
      march[4]++;
  }
  ans =  march[0]*march[1]*march[2]  //MAR
        +march[0]*march[1]*march[3]  //MAC
        +march[0]*march[1]*march[4]  //MAH
        +march[0]*march[2]*march[3]  //MRC
        +march[0]*march[2]*march[4]  //MRH
        +march[0]*march[3]*march[4]  //MCH
        +march[1]*march[2]*march[3]  //ARC
        +march[1]*march[2]*march[4]  //ARH
        +march[1]*march[3]*march[4]  //ACH
        +march[2]*march[3]*march[4]; //RCH

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256