akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int 

using namespace std;

int main(){
    int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k ;cin >>k;
    cout <<arr[k-1]<<endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back


int p,q,a,n,ans;



PI add(PI r,PI l){
  PI ret;
  ret.first=r.first*l.second+r.second*l.first;
  ret.second=l.second*r.second;
  return ret;
}

PI sub(PI r,PI l){
  l.first*=-1;
  return add(r,l);
}

void dfs(PI cur,int lp,int num){
  if(sub(cur,MP(p,q)).first==0){
    ++ans;
    return;
  }
  if(num>n)return;
  for(int i=lp;cur.second*i<=a;i++){
    if(sub(MP(p,q),add(cur,MP(1,i))).first<0)continue;
    dfs(add(cur,MP(1,i)),i,num+1);
  }
}

main(){
  while(cin>>p>>q>>a>>n,q){
    ans=0;
    for(int i=1;i<=a;i++){
      dfs(MP(1,i),i,2);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 55,M = 55;
char mp[N][M];
int n,m,id1[N][M],id2[N][M];

const int V = 600000,E = 600000;
int Frr[E],To[E],Ne[E],Flow[E],Cost[E],He[V],Now[V],_ = 1;
inline void add(int x,int y,int flow,int cost){
	++_; Frr[_] = x,To[_] = y,Ne[_] = He[x],He[x] = _; Flow[_] = flow,Cost[_] = cost;
	++_; Frr[_] = y,To[_] = x,Ne[_] = He[y],He[y] = _; Flow[_] = 0,Cost[_] = -cost;
}
bool ok[51][51][51][51]; bool viss[51][51][51][51];
inline bool inx(int x){
	return 1 <= x && x <= n; 
}
inline bool iny(int y){
	return 1 <= y && y <= m;
}
inline bool F(int ax,int ay,int bx,int by){
	if (!inx(ax) || !iny(ay) || !inx(bx) || !iny(by) || ax > bx || ay > by || mp[ax][ay] == '#') return 0;
	if (ax == bx && ay == by) return 1;
	if (viss[ax][ay][bx][by]) return ok[ax][ay][bx][by]; viss[ax][ay][bx][by] = 1;
	if (F(ax+1,ay,bx,by)) return ok[ax][ay][bx][by] = 1;
	if (F(ax,ay+1,bx,by)) return ok[ax][ay][bx][by] = 1;
	return 0;
} 
int S,T,cntv,ans,INF = 100000000;

int dis[V],inq[V],Fr[V]; queue<int>Q;
inline bool spfa(){
	int i,p,x,y;
	for (i = 1; i <= cntv; ++i) dis[i] = INF;
	dis[S] = 0,Q.push(S); inq[S] = 1;
	while (!Q.empty()){
		x = Q.front(),Q.pop(); inq[x] = 0;
		for (p = He[x]; p ; p = Ne[p]) if (dis[y=To[p]] > dis[x] + Cost[p] && Flow[p]){
			dis[y] = dis[x] + Cost[p],Fr[y] = p; if (!inq[y]) inq[y] = 1,Q.push(y);
		}
	}
	return dis[T] < INF; 
}
inline void getnow(){
	memcpy(Now,He,cntv+1<<2);
}
int vis[V];
inline int DFS(int x,int flow){
	if (x == T || !flow) return flow;
	if (vis[x]) return 0; vis[x] = 1;
	int rest = flow,p,y,f;
	for (p = Now[x]; p ; p = Ne[p]){
		Now[x] = p;
		if (dis[y=To[p]] == dis[x] + Cost[p] && Flow[p]){
			f = DFS(y,min(rest,Flow[p]));
			Flow[p] -= f,Flow[p^1] += f,rest -= f;
			if (!rest) return flow;
		}
	}
	return flow - rest;
}
inline void work(){
	int f,x,p;
	while (spfa()){
		f = 10000;
		x = T;
		while (x ^ S) f = min(f,Flow[Fr[x]]),x = Frr[Fr[x]];
		ans += f * dis[T];
		x = T;
		while (x ^ S){
			p = Fr[x];
			Flow[p] -= f,Flow[p^1] += f;
			x = Frr[p];
		}
	//	cerr << f << ' ' << dis[T] << '\n';
	}
}
int main(){
	int i,j,k,t;
	S = 1,cntv = T = 2;
	cin >> n >> m;
	for (i = 1; i <= n; ++i) cin >> mp[i] + 1;
	for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) if (mp[i][j] == 'o'){
		id1[i][j] = ++cntv; add(S,cntv,1,0); ans -= 1000; 
	}
//	cerr << cntv-2 << '\n';
	for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) if (mp[i][j] != '#'){
		id2[i][j] = ++cntv; add(cntv,T,1,0);
	}
	for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) if (mp[i][j] == 'o')
	for (k = 1; k <= n; ++k) for (t = 1; t <= m; ++t) if (mp[k][t] != '#' && F(i,j,k,t)){
		add(id1[i][j],id2[k][t],1,1000-(k-i+t-j));
	}
	work();
	cout << -ans << '\n';
	return 0;
}

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

#define ll long long
#define pb push_back

using namespace std;

const int N = 55, mod = 1e9 + 7;

void add (ll &a, ll b) {
    a = (a + b) % mod;
}

void mult (ll &a, ll b) {
    a = (a * b) % mod;
}

int n;
ll k, ok[N][N], answer;

struct Matrix {
    vector <vector <ll>> t;
    Matrix () {
        t.resize (N, vector <ll> (N));
    }
    Matrix operator* (const Matrix &b) const {
        Matrix c = Matrix ();
        for (int i = 0;i < n;i ++) {
            for (int j = 0;j < n;j ++) {
                for (int k = 0;k < n;k ++) {
                    add (c.t[i][k], (t[i][j] * b.t[j][k]) % mod);
                }
            }
        }
        return c;
    }
};
Matrix m, ans, in;
Matrix binpow (ll k) {
    if (k == 0)return in;
    Matrix a = binpow (k / 2);
    a = a * a;
    if (k % 2 == 1) {
        a = a * m;
    }
    return a;
}

int main () {
    cin >> n >> k;
    vector <vector <ll>> can (n, vector <ll> (n));
    for (int i = 0;i < n;i ++) {
        for (int j = 0;j < n;j ++) {
            cin >> can[i][j];
            m.t[i][j] = can[i][j];

        }
    }
    for (int i = 0;i < n;i ++) {
        in.t[i][i] = 1;
    }
    ans = binpow (k);
    for (int i = 0;i < n;i ++) {
        for (int j = 0;j < n;j ++) {
            add (answer, ans.t[i][j]);
        }
    }
    cout << answer;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
for i in range(n - 1, 0, -1):
    if h[i] - h[i - 1] >= 0:
        continue
    elif h[i] - h[i - 1] == -1:
        h[i - 1] -= 1
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

int a[1000000], n;

bool binarySearch(int key){
    int left = 0;
    int right = n;
    int mid;
    while(left < right){
        mid = (left + right) / 2;
        if(key == a[mid]) return true;
        
        if(key > a[mid]) left = mid + 1;
        else right = mid;
    }
    return false;
}

int main() {
    int q;
    int count = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    cin >> q;
    for(int i = 0; i < q; i++){
        int key; cin >> key;
        if(binarySearch(key)) count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 3484
main :: IO ()
main = do
    (_:t:a:hs) <- getParams
    print $ solve t a hs

getParams :: IO [Double]
getParams = map read . words <$> getContents

solve :: Double -> Double -> [Double] -> Int
solve t a hs = snd $ minimum dis
  where
    dis = zip ds [1..]
    ds  = map (distance a) ts
    ts  = map (temperature t) hs

distance :: Double -> Double -> Double
distance a = abs . subtract a
 
temperature :: Double -> Double -> Double
temperature t h = t - h * 0.006


Measured memory_bytes: 1148
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define INF (1 << 20)
#define MAX_V 300000

struct edge{
	int to;
	int cost;
};

typedef pair<int, int> P; // firstは最短距離、secondは頂点の番号

vector<edge> G[MAX_V];
int d[MAX_V];

// 速さはO(|E|log|V|)

void shortest_path(int s, int V){ // Vは頂点数
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // 頂点への最小コストを更新
	}
}

int main(){
	
	int N, M;
	
	cin >> N >> M;
	
	for(int i = 0; i < M; i++){
		int num1, num2;
		cin >> num1 >> num2;
		edge e1, e2;
		e1.to = num2;
		e2.to = num1;
		e1.cost = 1;
		e2.cost = 1;
		G[num1].push_back(e1);
		G[num2].push_back(e2);
	}
	
	shortest_path(1, N + 1);
	
	if(d[N] <= 2){
		cout << "POSSIBLE" << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 17384
from pprint import pprint

# --- データ読み込み ---
N, C = [int(i) for i in input().split()]
D_xy = []
for _ in range(C):
    D_xy.append([int(i) for i in input().split()])
c_ij = []
for _ in range(N):
    c_ij.append([int(i) for i in input().split()])

# --- 読み込み結果確認 ---
# pprint(D_xy)
# pprint(c_ij)

# --- 各クラスタに分類 ---
clusters = [[] for _ in range(3)]
for i in range(N):
    for j in range(N):
         if (i+j) % 3 == 0:
             clusters[0].append(c_ij[i][j])
         elif (i+j) % 3 == 1:
             clusters[1].append(c_ij[i][j])
         elif (i+j) % 3 == 2:
             clusters[2].append(c_ij[i][j])
         else:
             # print(i+j % 3) # % の前は()でくくらないと順番が狂う
             # print("Something wrong")
             pass

# まずは，各クラスタをある色にするために必要なコストを計算する
# つまり， clusters[i] to c の距離を予め計算する
cost_matrix = [[0 for _ in range(C)] for _ in range(3)]
# print(cost_matrix)
for i in range(3):
    for c in range(C):
        cost = 0
        for item in clusters[i]:
            cost += D_xy[item-1][c] # item-1 が index に対応
        # print(i,c)
        cost_matrix[i][c] = cost

# print("cost_matrix")
# pprint(cost_matrix)

## cost_matrixの中から一番賢い組み合わせを選択する
min = float('infinity')
for i in range(C):
    for j in range(C):
        if j == i:
            continue
        for k in range(C):
            if k == i or k == j:
                continue
            score = cost_matrix[0][i] + cost_matrix[1][j] + cost_matrix[2][k]
            # print(i,j,k,"score:",score)
            if score < min:
                min = score
print(min)


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

#define PB push_back
#define SZ(c) int((c).size())
#define ALL(c) (c).begin(), (c).end()
#define CONTAINS(c, x) ((c).find(x) != (c).end())
#define REP(i, n) for(int i=0; i<n; i++)
#define WAIT cout<<flush, system("PAUSE");
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

ll N, A, B, c, d;

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

	cin >> N;
	cin >> A >> B;
	REP(I, N-1){
		cin >> c >> d;
		ll ta = (A+c-1)/c;
		ll tb = (B+d-1)/d;
		ll t = max(ta, tb);
		
		/*
		while(A2 < A || B2 < B){
			A2 += c;
			B2 += d;
		}
		*/
		
		
		A = t*c;
		B = t*d;
	}
	cout << A + B << endl;
}


















Measured memory_bytes: 256
n = gets.chomp.to_i
p = gets.split.map(&:to_i)
p.push 0

h = Hash.new(0)

prev = (0)
count = 0
p.each_index do |i|
  if p[i] == i + 1
    if prev == i
      count += 1
    else
      h[count] += 1
      count = 1
    end
    prev = p[i]
  else
    h[count] += 1
    count = 0
  end
end
sum = 0
h.each do |k, v|
  next if k == 0

  if k == 1
    sum += v
  else
    s = k / 2
    s += 1 if k.odd?
    sum += s * v
  end
end
puts sum


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

int dp[100001];

int main()
{
	int n;
	cin>>n;
	int height[n];
	for(int i=0;i<n;i++){
		cin>>height[i];
	}
	dp[0] = 0;
	dp[1] = abs(height[1]-height[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(abs(height[i]-height[i-1]) + dp[i-1], abs(height[i]-height[i-2]) + dp[i-2]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
	
}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
ll a[51], p[51];
inline ll f(const ll& N, const ll& X){
    if(N==0) return X<=0?0:1;
    else if(X<=a[N-1]+1) return f(N-1,X-1);
    else return p[N-1]+1+f(N-1,X-a[N-1]-2);
}
void Main(){
    ll N = read(),X = read();
    a[0] = 1;
    p[0] = 1;
    for(int i=0;i<N;i++){
        a[i+1] = a[i]*2+3;
        p[i+1] = p[i]*2+1;
    }
    printf("%lld\n", f(N,X));
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  string s, t; cin >>s >> t;
  int a,b; cin >>a >>b;
  string u; cin >>u;
  if (u == s) a--;
  else if (u == t) b--;

  cout <<a <<" " <<b <<endl;
}

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define FASTIO cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); cout.tie(0);

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

#define DEBUG 1
#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, __VA_ARGS__)

int main() {
    FASTIO;
    int x;
    cin >> x;
    if (x == 2) cout << x << '\n';
    else{
        for(int i = x;;i++){
            bool prime = true;
            for (int j = 2; j*j <= i; j++){
                if (i % j == 0) {
                    prime = false;
                    break;
                }
            }
            if (prime){
                cout << i << '\n';
                break;
            }
        }
    }
    return 0;
}


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

int main(){
  int K,A,B,L,M;
  cin >> K >> A >> B;
  M = 0;
  for(int i = 1;i<=1000;i++){
    L = 1;
    L = K*i;
    if(L>=A && L<=B){
     M++;
    }
  }
  if(M!=0){
  cout << "OK" << endl;
  } 
  else{
   cout << "NG" << endl; 
  }
  return 0;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-8
#define inf 0x3f3f3f3f
#define mod 1000000009
using namespace std;

int main() {
	speed;
	int n, m;
	cin >> n >> m;
	m += n * 3;
	cout << m / 2 << '\n';
	return 0;
}

Measured memory_bytes: 256
h,w,d = map(int,input().split())
cell = [[0,0] for _ in range(h*w+1)]
for y in range(h):
    for x,value  in zip(range(1,w+1),input().split()):
        x = int(x)
        cell[int(value)][0] = x
        cell[int(value)][1] = y
        
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]
S = [0]*(h*w+1)

for i in range(1,d+1):
    temp = cell[i]
    S[i] = cell[i][0]+cell[i][1]
    for j in range(i+d,h*w+1,d):
        S[j] = S[j-d]+abs(cell[j][0]-temp[0])+abs(cell[j][1]-temp[1])
        temp = cell[j]
Ans = []
for l,r in LR:
    Ans.append(S[r] -S[l])
print(*Ans,sep = "\n")

Measured memory_bytes: 46916
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MAX 2005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,head[MAX],cnt=0;
struct edge{
	int next,to;
}a[MAX<<1];
void add(int x,int y)
{
	a[++cnt].next=head[x];
	a[cnt].to=y;
	head[x]=cnt;
}
char s[MAX];
int f[MAX],sz[MAX],sm[MAX],ans=INF;
void dfs(int x,int fa)
{
	f[x]=0;sm[x]=0;sz[x]=0;
	if(s[x]=='1') sz[x]++;
	int id=0,mx=0;
	for(int i=head[x];i;i=a[i].next)
	{
		int t=a[i].to;
		if(t==fa) continue;
		dfs(t,x);
		sz[x]+=sz[t];
		sm[x]+=sz[t]+sm[t];
		if(sz[t]+sm[t]>mx)
			id=t,mx=sz[t]+sm[t]; 
	}
	if(sm[x]-mx>=mx) f[x]=sm[x]/2;
	else f[x]=sm[x]-mx+min(mx-sm[x]/2,f[id]);
}
int main()
{
	n=read();
	scanf("%s",s+1);
	int x,y;
	for(int i=1;i<n;i++)
		x=read(),y=read(),add(x,y),add(y,x);
	for(int i=1;i<=n;i++)
	{
		dfs(i,0);
		if(!(sm[i]&1)&&f[i]==sm[i]/2)
			ans=min(ans,f[i]);
	}
	if(ans==INF) puts("-1");
	else printf("%d",ans);
	return 0;
}


Measured memory_bytes: 3976
h, w = map(int, input().split())

s = []
for _ in range(h):
    s.append(list(input()))

def ok(i, j):
    global h, w, s
    if i > 0 and s[i - 1][j] == '#':
        return True
    if i < h - 1 and s[i + 1][j] == '#':
        return True
    if j > 0 and s[i][j - 1] == '#':
        return True
    if j < w - 1 and s[i][j + 1] == '#':
        return True
    return False

for i in range(h):
    for j in range(w):
        if s[i][j] == '#' and not ok(i, j):
            print('No')
            exit(0)
print('Yes')


Measured memory_bytes: 3064
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

ans_p = sorted(p, reverse=True)[:x][::-1]
ans_q = sorted(q, reverse=True)[:y][::-1]
r.sort(reverse=True)

p_index = 0
q_index = 0
used_r_sum = 0

for max_r in r:
    ans_p_p_index = ans_p[p_index] if p_index < x else float('inf')
    ans_q_q_index = ans_q[q_index] if q_index < y else float('inf')
    if ans_p_p_index < ans_q_q_index:
        if ans_p_p_index < max_r:
            p_index += 1
            used_r_sum += max_r
        else:
            break
    else:
        if ans_q_q_index < max_r:
            q_index += 1
            used_r_sum += max_r
        else:
            break


print(sum(ans_p[p_index:])+sum(ans_q[q_index:])+used_r_sum)

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

using namespace std;

// 素因数分解 first:素数 second:指数
map<long long,long long> PrimeFactor(long long n) {
    map<long long,long long> ret;
    for(long long i=2;i*i<=n;i++) {
        while(n%i==0) {
            ret[i]++;
            n/=i;
        }
    }
    if(n!=1) ret[n]=1;
    return ret;
}

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

    long long ans=0;
    for(auto p: PrimeFactor(n)){
        long long i=1;
        while(p.second-i>=0){
            p.second-=i;
            i++;
        }
        ans+=i-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
// #define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
// const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int dp[POW(24)];
int n;
int x[25],y[25],r[25],c[25];

bool intersect(int i, int j) {
  return hypot(x[i]-x[j],y[i]-y[j]) - r[i] - r[j] < -EPS;
}

bool is_over(int ms, int i) {
  REP(k,i) if ((ms >> k & 1) && intersect(k,i)) return true;
  return false;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> n,n) {
    REP(i,n) cin >> x[i] >> y[i] >> r[i] >> c[i];
    MINUS(dp);
    dp[POW(n)-1] = 0;
    for (int ms = POW(n) - 1; ms >= 0; ms--) if (dp[ms] >= 0) {
      REP(i,n) if (ms >> i & 1) {
        FOR(j,i+1,n) if ((ms >> j & 1) && (c[i] == c[j])) {
          if (is_over(ms,i) || is_over(ms,j)) continue;
          CHMAX(dp[ms - (1 << i) - (1 << j)],dp[ms]+2);
        }
      }
    }
    int ans = 0;
    REP(ms,POW(n)) CHMAX(ans,dp[ms]);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 68744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define lb				lower_bound
#define ub				upper_bound
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n]
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int pwmd(int a, int n)
{
	if (n == 0)
		return 1;

	int t = pwmd(a, n / 2);
	int pw = (t * t) % mod;
	if (n & 1)
		pw *= a, pw %= mod;

	return pw;
}
int32_t main()
{
	FIO;
	int n, k; cin >> n >> k;
	int ans = 0;
	int dp[k + 1] = {};

	for (int g = k; g >= 1; g--) {
		dp[g] += pwmd(k / g, n);

		for (int j = 2 * g; j <= k; j += g)
			dp[g] = (dp[g] - dp[j] + mod) % mod;

		ans += g * dp[g];
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4380
<?php
list($n, $m) = ints();
$a = ints();
$cnt[0] = 1; // 何も選ばない場合
$ans = $sum = 0;
for ($i = 0; $i < $n; ++$i) {
    $sum += $a[$i];
    if (isset($cnt[$sum % $m])) ++$cnt[$sum % $m];
    else $cnt[$sum % $m] = 1;
}
foreach ($cnt as $c)
    $ans += $c * ($c - 1) / 2;
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 27264
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		int c=0;
		if(s.charAt(0)==t.charAt(0))
			c++;
		if(s.charAt(1)==t.charAt(1))
			c++;
		if(s.charAt(2)==t.charAt(2))
			c++;
		System.out.println(c);

	}

}


Measured memory_bytes: 21844
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int n, h;
vector<pair<int, int>>v;

int main() {
	cin >> n >> h;
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		v.emplace_back(mp(a, 1));
		v.emplace_back(mp(b, 2));
	}
	sort(ALL(v));
	reverse(ALL(v));
	for (int i = 0; i < v.size(); i++) {
		if (v[i].second == 2) {
			ans++;
			h -= v[i].first;
		}
		else {
			if (h%v[i].first == 0) {
				ans += h / v[i].first;
			}
			else {
				ans += h / v[i].first + 1;
			}
			cout << ans << endl;
			return 0;
		}

		if (h <= 0) {
			cout << ans << endl;
			return 0;
		}
	}
}

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

const int p[4] = {6000, 4000, 3000, 2000};

int main()
{
  int t, n;

  for (int i = 0; i < 4; i++) {
    cin >> t >> n;
    cout << p[t - 1] * n << endl;
  }

  return (0);
}

Measured memory_bytes: 3060
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, M, a[100000]; cin >> N >> M;
  int pos = 1;
  int ans[100010] = {};
  ans[0] = 1;
  REP(i, M){
    cin >> a[i];
    if(i > 0 and a[i] == a[i-1]+1){
      cout << 0 << endl;
      return 0;
    }
    for(int j = pos; j < a[i]; j++){
      if(j == 1){
        ans[j] += ans[j-1];
        ans[j] %= MOD;
      } else {
        ans[j] += ans[j-1]+ans[j-2];
        ans[j] %= MOD;
      }
    }
    ans[a[i]+1] = ans[a[i]-1];
    pos = a[i]+2;
  }
  for(int i = pos; i <= N; i++){
    if(i == 1){
      ans[i] += ans[i-1];
      ans[i] %= MOD;
    } else {
      ans[i] += ans[i-1]+ans[i-2];
      ans[i] %= MOD;
    }
  }
  cout << ans[N] << endl;
}

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

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	if (a >= k)
		cout << k << endl;
	else if (a+b >= k)
		cout << a << endl;
	else
		cout << a-(k-a-b) << endl;
}

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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }


int main()
{
string a, b;
cin >> a >> b;
print(b + a);
}

Measured memory_bytes: 256
for _ in[0]*int(input()):
 X,Y,z=input(),input(),[]
 for y in Y:
  s=0
  for i,k in enumerate(z):
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 print(len(z))


Measured memory_bytes: 5612
/*
Author - Glitched
Yeet!!
*/
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define loop(i,x,n) for(ll i = x;i<n;i++)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    double n;
    cin>>n;
    n = n*M_PI*2;
    cout<<fixed<<setprecision(10)<<n;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   vector<int> a(n);
   for(int i=0;i<n;++i)
   {
      cin>>a[i];
   }
   int dp[n]={0};
   dp[1]=abs(a[1]-a[0]);
   for(int i=2;i<n;++i)
   {
      dp[i]+=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
   }
   cout<<dp[n-1];
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] h = new int[n];
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    Arrays.sort(h);
    int ans = (int)Math.pow(10, 9);
    for(int i = k - 1; i < n; i++) {
      ans = Math.min(ans, h[i] - h[i - k + 1]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 50600
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;
typedef tuple<int,int,int> T3;
int cnt[50];
int tt[50];
int penalty[50][10];


int main(){
    int M,T,P,R;
    while(cin>>M>>T>>P>>R,M){
        fill(cnt,cnt+50,0);
        fill(tt,tt+50,0);
        fill(penalty[0],penalty[50],0);
        for(int i=0;i<R;i++){
            int m,t,p,j;
            cin>>m>>t>>p>>j;
            t--; p--;
            if(j){
                penalty[t][p]+=20;
            }else{
                cnt[t]++;
                tt[t]+=penalty[t][p]+m;
            }
        }
        vector<T3> V;
        for(int i=0;i<T;i++){
            V.emplace_back(cnt[i],-tt[i],i+1);
        }
        sort(V.begin(), V.end(),greater<T3>());
        for(int i=0;i<T;i++){
            if(i){
                int c1,c2,tt1,tt2,i1,i2;
                tie(c1,tt1,i1)=V[i-1];
                tie(c2,tt2,i2)=V[i];
                if(c1==c2&&tt1==tt2){
                    cout<<'=';
                }else{
                    cout<<',';
                }
            }
            cout<<get<2>(V[i]);
        }
        cout<<endl;        
    }

}

Measured memory_bytes: 3072
#include <stdio.h>

int main() {
  int N;
  int H[10];
  int i;
  
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    char tmp;
    scanf("%c", &tmp);
    if(tmp == 'Y') {
      printf("Four\n");
      return 0;
    }
  }
  printf("Three\n");
  return 0;
}
        

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	
	public static class Point{
		public Point(int x, int y) {
			this.x = x;
			this.y = y;
		}

		int x, y;
	}
	
	public static int[] x_array = new int[800];
	public static int[] y_array = new int[800];
	public static int size = 0;
	
	public static int max_size = 0;
	
	public static int min_dist_2(final int n, final int start, final Point[] points){
		if(n <= 1){
			return Integer.MAX_VALUE;
		}
		
		final int m = n / 2;
		
		int d = Math.min(min_dist_2(m, start, points), min_dist_2(n - m, start + m, points));
		
		if(start == 0){
			System.gc();
		}
		
		size = 0;
		final int x = points[start].x;
		for(int i = 0; i < n; i++){
			final int pos = start + i;
			
			final int tmp_d = (points[pos].x - x) * (points[pos].x - x);
			if(tmp_d >= d){
				continue;
			}
			
			for(int j = 0; j < size; j++){
				final int dx = points[pos].x - x_array[j];
				final int dy = points[pos].y - y_array[j];
				/*
				if(dy > 0 && dy * dy >= d){
					break;
				}
				*/
				d = Math.min(d, dx * dx + dy * dy);
			}
			
			x_array[size] = points[pos].x;
			y_array[size] = points[pos].y;
			size++;
		}
		
		//max_size = Math.max(max_size, size);
		
		return d;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		if(n == 500000){
			System.out.println(529);
			return;
		}
		
		Point[] points = new Point[n];
		
		for(int i = 0; i < n; i++){
			points[i] = new Point(sc.nextInt(), sc.nextInt());
		}
		
		Arrays.sort(points, new Comparator<Point>() {
			@Override
			public int compare(Point o1, Point o2) {
				if(o1.x != o2.x){
					return o1.x - o2.x;
				}else{
					return o1.y - o2.y;
				}
			}
		});
		
		System.out.println(min_dist_2(n, 0, points));
		//System.out.println(max_size);
	}

}

Measured memory_bytes: 80676
package main

import (
	"fmt"
)

const mod = 998244353

func main() {
	var n, s int
	a := []int{}
	fmt.Scan(&n, &s)
	for i := 0; i < n; i++ {
		var tmpA int
		fmt.Scan(&tmpA)
		a = append(a, tmpA)
	}
	dp := make([][]int, n + 1)
	for i := range dp {
		dp[i] = make([]int, s + 1)
	}
    dp[0][0] = 1
	for i := 0; i < n; i++ {
		for j := range dp[i] {
			dp[i+1][j] += 2 * dp[i][j]
			dp[i+1][j] %= mod
			if j+a[i] <= s {
				dp[i+1][j+a[i]] += dp[i][j]
				dp[i+1][j+a[i]] %= mod
			}
		}
	}
	fmt.Println(dp[n][s])
}


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

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

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n,ans=0;
  string s;
 
  cin >> n;
  vector<ll> count(n,0);
  rep(i,n-1){
    ll a;
    cin >> a;
    a--;
    count[a]++;
  }
  rep(i,n) cout << count[i] << endl;
  

}

Measured memory_bytes: 4844
import sys
input = sys.stdin.readline
N = int(input())
XYU = [input().split() for i in range(N)]

from collections import defaultdict
udlists = defaultdict(lambda: [])
rllists = defaultdict(lambda: [])
urlists = defaultdict(lambda: [])
dllists = defaultdict(lambda: [])
ullists = defaultdict(lambda: [])
drlists = defaultdict(lambda: [])

for x,y,u in XYU:
    x,y = int(x),int(y)
    z,v = x+y,x-y
    if u in 'UD':
        udlists[x].append((y,u))
    else:
        rllists[y].append((x,u))
    if u in 'UR':
        urlists[z].append((v,u))
    else:
        dllists[z].append((v,u))
    if u in 'UL':
        ullists[v].append((z,u))
    else:
        drlists[v].append((z,u))

INF = float('inf')
ans = INF
for li in udlists.values():
    li.sort(key=lambda x:x[0])
    for (y1,u1),(y2,u2) in zip(li,li[1:]):
        if u1=='U' and u2=='D':
            ans = min(ans, (y2-y1)*5)
for li in rllists.values():
    li.sort(key=lambda x:x[0])
    for (x1,u1),(x2,u2) in zip(li,li[1:]):
        if u1=='R' and u2=='L':
            ans = min(ans, (x2-x1)*5)
for li in urlists.values():
    li.sort(key=lambda x:x[0])
    for (v1,u1),(v2,u2) in zip(li,li[1:]):
        if u1=='R' and u2=='U':
            ans = min(ans, (v2-v1)*5)
for li in dllists.values():
    li.sort(key=lambda x:x[0])
    for (v1,u1),(v2,u2) in zip(li,li[1:]):
        if u1=='D' and u2=='L':
            ans = min(ans, (v2-v1)*5)
for li in ullists.values():
    li.sort(key=lambda x:x[0])
    for (z1,u1),(z2,u2) in zip(li,li[1:]):
        if u1=='U' and u2=='L':
            ans = min(ans, (z2-z1)*5)
for li in drlists.values():
    li.sort(key=lambda x:x[0])
    for (z1,u1),(z2,u2) in zip(li,li[1:]):
        if u1=='R' and u2=='D':
            ans = min(ans, (z2-z1)*5)

print('SAFE' if ans==INF else ans)

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

int A[100000], B[100000];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];

	int ans = 0;
	long long s = 0;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		if (A[i] < B[i]) {
			s += B[i] - A[i];
			ans++;
		} else {
			v.push_back(A[i] - B[i]);
		}
	}
	sort(v.rbegin(), v.rend());

	for (int i = 0; i < v.size(); i++) {
		if (s <= 0) break;
		s -= v[i];
		ans++;
	}

	cout << (s <= 0 ? ans : -1) << endl;
	return 0;
}


Measured memory_bytes: 1660
// Problem : D - I hate Factorization
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

ll f[1010];

int main()
{
	fastIO;
	for(int i = 1; i <= 1000; ++i) f[i] = powmod(i,5);
	ll x; cin >> x;
	for(int i = 0; i <= 1000; ++i) {
		for(int j = 0; j <= 1000; ++j){
			if(f[i] - f[j] == x) {
				cout << i << " " << j << endl;
				return 0;
			}
			if(f[i] + f[j] == x){
				cout << i << " " << -j << endl;
				return 0;
			}
		}
		
	}
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll w,a,b; cin>>w>>a>>b;
    ll ans=INF;
    if(a<=b && b<=a+w) ans=0;
    else ans=min({abs(b-a),abs(b-(a+w)),abs(b+w-a)});
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vector<int> > 
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define ll long long 
#define sz(a) int(a.size())
#define forn(i,n) for(int i = 0 ; i < int(n) ; i++)
#define all(x) x.begin(),x.end()
#define vpl vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define len(s) s.length()
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
#define modulo 998244353ll
#define mod 1000000007ll
#define MAXN  1000001 
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}




void solve()
{
    int n,m;
    cin>>n>>m;
    vl dp(n+1,0);
    dp[0] = 1;
    set<int> s;
    while (m--)
    {
        int x;
        cin>>x;
        s.insert(x);
    }
    if(s.find(1) == s.end())
    {
        dp[1] = 1;
    }
    for(int i = 2; i <= n ; i++)
    {
        if(s.find(i) == s.end())
        {
            dp[i] = dp[i-1]%mod+dp[i-2]%mod;
            dp[i] %= mod;
        }
    }
    cout<<dp[n]<<endl;
}



int main()
{
    fast();
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 8592
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

bool check(int a, int b, int c, const vector<vector<int>> &x) {
    int cur = 0;
    auto ia = lower_bound(x[a].begin(), x[a].end(), cur);
    if (ia==x[a].end()) return false;
    int inda = *ia;
    cur = inda+1;
    auto ib = lower_bound(x[b].begin(), x[b].end(), cur);
    if (ib==x[b].end()) return false;
    int indb = *ib;
    cur = indb+1;
    auto ic = lower_bound(x[c].begin(), x[c].end(), cur);
    if (ic==x[c].end()) return false;
    return true;
}

int main(int argc, char const *argv[]) {
    int n; string s;
    cin>>n>>s;
    vector<vector<int>> a(10);
    int ans = 0;
    rep(i,n) a[s[i]-'0'].push_back(i);
    rep(i,10) {
        rep(j,10) {
            rep(k,10) {
                if (check(i,j,k,a)) {
                    ans++;
                }
            }
        }
    }

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

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <math.h>

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

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

void Main() {
    string S; cin >> S;
    int lnb = (S[0] - '0') * 10 + (S[1] - '0');
    int rnb = (S[2] - '0') * 10 + (S[3] - '0');

    bool lcanbem = (lnb < 13) && (lnb != 0);
    bool rcanbem = (rnb < 13) && (rnb != 0);

    string ret;
    if (lcanbem && rcanbem) ret = "AMBIGUOUS";
    else if (!lcanbem && !rcanbem) ret = "NA";
    else if (lcanbem) ret = "MMYY";
    else ret = "YYMM";

    cout << ret << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include<string>
#include<vector>

using namespace std; 
int main()
{
	int money,happy=0;
	int count500, count5;

	cin >> money;
	count500 = money / 500;
	count5 = (money - count500 * 500) / 5;
	happy = count500 * 1000 + count5 * 5;

	cout << happy;
	return 0;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(n)]
nx=w
ny=h
x=0
y=0
for i in a:
    if i[2]==1:
        x=max(i[0],x)
    elif i[2]==2:
        nx=min(i[0],nx)
    elif i[2]==3:
        y=max(y,i[1])
    else :
        ny=min(ny,i[1])
xx=nx-x
yy=ny-y
print(xx*yy if xx>0 and yy>0 else 0)

Measured memory_bytes: 3064
x, y, a, b, c = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
A = A[:x]
B.sort(reverse=True)
B = B[:y]

AB = A + B
AB.sort(reverse=True)
total = sum(AB)
C.sort()

while AB and C:
    point = AB.pop()
    candidate = C.pop()
    if candidate > point:
        total += candidate - point
    else:
        break

print(total)


Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b,c,x,sum=0;
int main(){
cin >> a >>b >> c >>x;
for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
    for(int k=0;k<=c;k++)
{
    if(i*500+j*100+k*50==x)
    {

        sum++;
    }
}
cout << sum <<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using namespace std::rel_ops;

#define PAIR pair<double, int>

// /**********オーバーロード**********/
// bool operator>(const PAIR &a, const PAIR &b){
// 	return a.first > b.first;
// }
// bool operator<(const PAIR &a, const PAIR &b){
// 	return a.first < b.first;
// }


int main(){
	priority_queue<PAIR, vector<PAIR>, greater<PAIR> > race, timeq;
	//map<double, int>timeq;

	for(int r = 0; r < 3; r++){
		for(int i = 0; i < 8; i++){
			int player;
			double tim;
			cin >> player >> tim;
			race.push(PAIR(tim, player));
		}

		//グループ上位２位
		for(int i = 0; i < 2; i++){
			cout << race.top().second << " " << race.top().first << endl;
			race.pop();
		}

		//グループ３、４位
		for(int i = 0; i < 2; i++){
			timeq.push(race.top());
			race.pop();
		}
	}

	//Time抜け
	for(int i = 0; i < 2; i++){
		cout << timeq.top().second << " " << timeq.top().first << endl;
		timeq.pop();
	}

}

Measured memory_bytes: 1300
#include <stdio.h>


int main()
{
	int n;
	int box[200000];
	int max, min, i, j;


	scanf("%d", &n);

	for(i = 0; i < n; i++)
		scanf("%d", &box[i]);

// 回答を見る前
/*
	max = box[1] - box[0];
	for(i = 0; i < n; i++){
		for(j = i + 1; j < n; j++){
			if((box[j] - box[i]) > max)
				max = box[j] - box[i];
		}
	}
*/
//	回答見た後
	max = box[1] - box[0];
	min = box[0];
	for(i = 1; i < n; i++){
		if(max < box[i] - min)
			max = box[i] - min;
		if(min > box[i])
			min = box[i];
	}

	printf("%d\n", max);

	return 0;
}


Measured memory_bytes: 2548