akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, i0, n) for (int i = i0; i < n; ++i)

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());

  if(a.front() == 0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  const ll b = 1e18;
  rep(i,n){
    if(ans > b || b/a[i] < ans) {
      ans = -1;
      break;
    } 
    ans *= a[i];
  }

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

Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  string s,t;cin>>s>>t;
  int cnt = 0;
  rep(i,s.size()){
    if(s[i] != t[i])cnt++;
  }
  print(cnt);
  return 0;
}

Measured memory_bytes: 3856
import itertools
import sys
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)

@lru_cache(None)
def solve(N,K):
    # print(N,K)
    if N <= 10:
        if K == 0:
            return 1
        elif K == 1:
            return N
        else:
            return 0

    if K < 0 or len(str(N)) < K:
        return 0

    ans = 0
    m, last = divmod(N,10)
    ans += solve(m,K-1) * last + solve(m-1,K-1) * (9 - last) + solve(m,K)

    return ans


def main():
    N,K = map(int,[input(),input()])

    print(solve(N,K))

if __name__ == "__main__":
  main()


Measured memory_bytes: 14292
N = int(input())
HList = list(map(int, input().split()))
last = 0
ans = True
for i in range(N):
    # 前のマスより大きければ、自身を下げてよい
    if last < HList[i]:
        HList[i] = HList[i] - 1
    # 前のマスより小さい場合は、No確定
    if last > HList[i]:
        ans = False
        break
    last = HList[i]
print("Yes" if ans else "No")


Measured memory_bytes: 14252
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(U == S) {
        A -= 1;
    } else if(U == T) {
        B -= 1;
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N + 1];
		long sum = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		}
		long sum2 = 0;
		for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		}
		System.out.println(sum-sum2);

	}
}


Measured memory_bytes: 60100
//***Wherever you are, and whatever you do, be in love.***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define PI 3.14159265 

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main(){
	int N;
	cin >>  N;
	vector<int> t(N);
	vector<int> x(N);
	vector<int> y(N);
	rep(i,N) scanf("%d %d %d",&t[i],&x[i],&y[i]);

	int dx,dy,dt;
	int flag=0;

	if((x[0]+y[0]>t[0]) || ((t[0]-x[0]-y[0])%2==1)) flag=1;
	rep(i,N-1){
		dx = abs(x[i+1]-x[i]);
		dy = abs(y[i+1]-y[i]);
		dt = t[i+1]-t[i];
		if((dx+dy>dt) || ((dt-dx-dy)%2==1))	flag=1;
	}

	if(flag==1) cout << "No";
	else cout << "Yes";
}


Measured memory_bytes: 1408
while True:
	n,m=map(int,input().split())
	if n==m==0:
		break
	else:
		score=[0]*n
		for i in range(m):
			p=list(map(int,input().split()))
			for j in range(n):
				score[j]+=p[j]
		print(max(score))


Measured memory_bytes: 5716
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    cin>>m;
    vector<int> b(m);
    for(int i=0;i<m;i++)cin>>b[i];
    sort(All(a));
    int res=0;
    for(int i=0;i<m;i++){
        if(binary_search(All(a),b[i]))res++;
    }
    cout<<res<<endl;

}


Measured memory_bytes: 4040
N=int(input())
l={}

for i in range(N):
  s=input()
  if s in l:
    l[s]+=1
  else:
    l[s]=1


# l=sorted(l,key=lambda x:x[1])

# ma=max(l)
max_value=max(l.values())
# max_value=0
# for i in l:
#   if max_value<l[i]:
#     max_value=l[i]

ans=[]

for i in l:
  if max_value==l[i]:
    ans.append(i)
ans.sort()

for i in ans:
  print(i)


Measured memory_bytes: 32096
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  double t,x;
  cin >> t >> x;
  printf("%.12lf",t/x);
}

Measured memory_bytes: 256
import heapq
n = raw_input()
heap = [x*(1) for x in map(float, raw_input().split(' '))]
heapq.heapify(heap)

while(len(heap)>1):
	u,v = heapq.heappop(heap), heapq.heappop(heap)
	w = 0.5*(u+v)
	heapq.heappush(heap, w)

print heap[0]

Measured memory_bytes: 28012
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

int main() {
	string s;
	cin >> s;
    int ans = 1000;
    REP(i, s.size() - 2) {
        int n = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') * 1;
        n = abs(n - 753);
        if (ans > n) {
            ans = n;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 112000000012345678LL

template<typename T>
class SegTree {
public:
  int n;
  vector<T> segMax, segAdd;
  vector<int> segIdx;
  void _add(int a, int b, T x, int k, int l, int r){
    if(r<=a || b<=l) return;
    if(a<=l && r<=b){segAdd[k]+=x; return;}
    int cl = k*2+1, cr = k*2+2;
    _add(a,b,x,cl,l,(l+r)/2);
    _add(a,b,x,cr,(l+r)/2,r);
    T vl = segMax[cl]+segAdd[cl];
    T vr = segMax[cr]+segAdd[cr];
    if(vl > vr){
      segMax[k] = vl;
      segIdx[k] = segIdx[cl];
    } else {
      segMax[k] = vr;
      segIdx[k] = segIdx[cr];
    }
  }
  pair<T, int> _max(int a, int b, int k, int l, int r){ // <val, idx> (tree上でのidx)
    if(r<=a || b<=l) return mp(-INF, -100);
    if(a<=l && r<=b) return mp(segMax[k]+segAdd[k], segIdx[k]);
    pair<T,int> vl = _max(a,b,k*2+1,l,(l+r)/2);
    pair<T,int> vr = _max(a,b,k*2+2,(l+r)/2,r);
    if(vl.fi > vr.fi) return mp(vl.fi+segAdd[k], vl.se);
    else return mp(vr.fi+segAdd[k], vr.se);
  }
  SegTree(vector<long> &v){
    int n_ = v.size();
    n=1;
    while(n<n_) n*=2;
    segMax.resize(2*n-1);
    segAdd.resize(2*n-1, 0);
    segIdx.resize(2*n-1);
    rep(i,n_) segMax[n+i-1] = v[i];
    for(int i=n-2; i>=0; i--) segMax[i] = max(segMax[2*i+1], segMax[2*i+2]);
    rep(i,n-1,2*n-1) segIdx[i] = i;
    for(int i=n-2; i>=0; i--){
      if(segMax[2*i+1] > segMax[2*i+2]) segIdx[i] = 2*i+1;
      else segIdx[i] = 2*i+2;
    }
  }
  inline void add(int a, int b, T x){ _add(a,b,x,0,0,n);} // add x in [a,b)
  inline pair<T,int> getMax(int a,int b){return _max(a,b,0,0,n);} // <max-val, idx> idx はst.n-1を引いたほうがいいかも
};

int main(){
  int n;
  cin>>n;
  vector<long> x(n), s(n);
  rep(i,n) cin>>x[i]>>s[i];

  long acc = 0;
  vector<long> iv(n);
  rep(i,n){
    acc += s[i];
    iv[i] = acc + x[0] -x[i];
  }

  SegTree<long> st(iv);

  long ans = st.getMax(0,n).first;
  rep(i,1,n){
    st.add(i, n, -s[i-1]-x[i-1]+x[i]);
    long tmp = st.getMax(i,n).first;
    ans = max(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15232
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        int w,h;
        cin >> w >> h;
        if(w==0) break;
        // y x.
        vector<vector<char> > A(h,vector<char>(w,'.'));
        rep(i,h) rep(j,w){
            cin >> A[i][j];
        }
        rep(height,h) rep(width,w){
            if(A[height][width] != '.') continue;
            bool white = false;
            bool black = false;
            // y x
            queue<pair<int,int> > Q;
            Q.push(mp(height,width));
            vector<vector<char> > Got(h,vector<char>(w,0));
            Got[height][width] = true;
            while(!Q.empty()){
                pair<int,int> p = Q.front();
                Q.pop();
                if(A[p.first][p.second] == 'W'){
                    white = true;
                    continue;
                }
                if(A[p.first][p.second] == 'B'){
                    black = true;
                    continue;
                }
                rep(i,4){
                    int ny = p.first + dy[i];
                    int nx = p.second + dx[i];
                    if(nx == -1 or ny == -1 or nx == w or ny == h or Got[ny][nx]) continue;
                    Got[ny][nx] = true;
                    Q.push(mp(ny,nx));
                }
            }
            rep(hh,h) rep(ww,w){
                if(A[hh][ww] == '.' and Got[hh][ww]){
                    if(white and black){
                        A[hh][ww] = 'x';
                    }else if (white){
                        A[hh][ww] = 'w';
                    }else if(black){
                        A[hh][ww] = 'b';
                    }else{
                        A[hh][ww] = 'z';
                    }
                }
            }
        }
        int whitecnt=0,blackcnt=0;
        rep(height,h) rep(width,w){
            if(A[height][width] == 'w') whitecnt++;
            if(A[height][width] == 'b') blackcnt++;
        }
        cout << blackcnt << " " << whitecnt << endl;
    }
    return 0;
}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define endl '\n'

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

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;



int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	for(int i=0; i<s.size(); i++) if(s[i] == '?') s[i] = 'D';
	cout << s;
}



Measured memory_bytes: 3744
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <map>

using namespace std;

template<typename value_type>
class extended_euclidean
{
public:
	value_type gcd;
	value_type lcm;
	value_type x0;
	value_type y0;

public:
	extended_euclidean(value_type a, value_type b)
		: gcd(0), lcm(0), x0(0), y0(0)
	{
		tie(gcd, x0, y0) = process(a, b);
		lcm = a * b / gcd;
	}

public:
	tuple<value_type, value_type, value_type> process(value_type a, value_type b)
	{
		if (a == 0) return make_tuple(b, 0, 1);

		value_type g, x, y;
		tie(g, x, y) = process(b % a, a);

		return make_tuple(g, y - (b / a) * x, x);
	}
};

//extended_euclidean<long long> ee(a, b);
//long long gcd = ee.gcd;
//long long lcm = ee.lcm;



namespace math_helper
{
	const double pi = acos(-1.0);

	template<typename value_type>
	value_type mod(const value_type a, const value_type m)
	{
		if (a >= 0) return a % m;
		return ((-a / m + 1) * m + a) % m;
	}

	template<typename value_type>
	value_type mod_inverse(const value_type a, const value_type m)
	{
		extended_euclidean<value_type> ee(a, m);

		if (ee.gcd != 1) return -1;
		return mod<value_type>(ee.x0, m);
	}

	template<typename value_type>
	map<value_type, int> factorization(value_type num)
	{
		map<value_type, int> factor_map;

		for (value_type factor_num = 2; factor_num * factor_num <= num; factor_num++)
		{
			if (factor_num > num) break;
			if (num % factor_num != 0) continue;

			while (num % factor_num == 0)
			{
				num /= factor_num;
				factor_map[factor_num]++;
			}
		}

		if (num != 1) factor_map[num]++;

		return factor_map;
	}

	template<typename value_type>
	map<value_type, int> factorization(value_type num, const vector<value_type>& prime_list)
	{
		map<value_type, int> factor_map;

		for (value_type prime_num : prime_list)
		{
			if (prime_num > num) break;
			if (num % prime_num != 0) continue;

			while (num % prime_num == 0)
			{
				num /= prime_num;
				factor_map[prime_num]++;
			}
		}

		if (num != 1) factor_map[num]++;

		return factor_map;
	}

	template<typename value_type>
	value_type fast_power(const value_type a, const value_type n)
	{
		if (n == 1) return a;

		value_type ret = fast_power(a, n / 2);
		ret = (ret * ret);
		if (n % 2 != 0) ret = (a * ret);
		return ret;
	}
};

//double pi_value = math_helper::pi;
//long long mod_value = math_helper::mod<long long>(value, mod);
//long long mod_inverse_value = math_helper::mod_inverse<long long>(value, mod);
//map<long long, int> factor_map_naive = math_helper::factorization<long long>(value);
//map<long long, int> factor_map = math_helper::factorization<long long>(value, prime_list);
//long long power_value = math_helper::fast_power<long long>(value, power);

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

	long long A, B;
	cin >> A >> B;

	extended_euclidean<long long> ee(A, B);
	map<long long, int> factor_map_naive = math_helper::factorization<long long>(ee.gcd);

	cout << factor_map_naive.size() + 1;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int n; cin >> n;
  map<int,int> m;

  rep2(i, 1, n) {
    int x = i;
    rep2(j, 2, sqrt(x)) {
      int cnt = 0;
      while (x % j == 0) {
        x /= j;
        ++cnt;
      }

      m[j] += cnt;
    }

    if (x != 1) ++m[x];
  } 

  ll ans = 0;
  int cnt_3 = 0, cnt_5 = 0, cnt_15 = 0, cnt_25 = 0;

  for (auto e : m) {
    ++e.se;

    if (e.se >= 3) ++cnt_3;
    if (e.se >= 5) ++cnt_5;
    if (e.se >= 15) ++cnt_15;
    if (e.se >= 25) ++cnt_25;
    if (e.se >= 75) ++ans;
  }

  auto nCr = [&](int x, int y) {
    ll res = 1;

    rep(i, y) res *= (x - i);
    rep2(i, 1, y) res /= i;

    return res;
  };

  ans += cnt_25 * (cnt_3 - 1);
  ans += cnt_15 * (cnt_5 - 1);
  ans += cnt_5 * (cnt_5 - 1) * (cnt_3 - 2) / 2;

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final int answer = IntStream.range(0, n)
            .map(i -> scanner.nextInt())
            .sorted()
            .limit(k)
            .sum();
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 34712
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main() {
    string s, t;
    cin >> s >> t;
    if(s.size() < t.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<string> ans;
    bool f1 = false;
    for(int i=0; i<s.size(); ++i) {
        bool f = true;
        for(int j=0; j<t.size(); ++j) {
            if(s[i+j]!='?'&&s[i+j]!=t[j]) {
                f = false;
                break;
            }
        }
        if(f) {
            f1 = true;
            string s2 = s;
            for(int j=0; j<t.size(); ++j) {
                s2[i+j] = t[j];
            }
            ans.push_back(s2);
        }
    }
    if(!f1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(ans.begin(), ans.end());
    string u = ans[0];
    for(int i=0; i<u.size(); ++i) {
        if(u[i]=='?') u[i] = 'a';
    }
    cout << u << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m;
    cin>>n>>m;
    if (n<m) {
        if (n==1) {
            cout<<n*m-2<<endl;
        } else if (n==2) {
            cout<<0<<endl;
        } else {
            cout<<(n-2)*(m-2)<<endl;
        }
    } else if (n>m) {
        if (m==1) {
            cout<<n*m-2<<endl;
        } else if (m==2) {
            cout<<0<<endl;
        } else {
            cout<<(n-2)*(m-2)<<endl;
        }
    } else {
        if (n==1&&m==1) {
            cout<<1<<endl;
        } else if (n==2&&m==2) {
            cout<<0<<endl;
        } else {
            cout<<(n-2)*(m-2)<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  ll sum = 0;
  ll cnt = 0;
  while (sum < N) {
    cnt++;
    sum += cnt;
  }
  ll ignore = sum - N;
  for (int i = 1; i <= cnt; i++) {
    if (i != ignore) cout << i << endl;
  }
  return 0;
}

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

long long solve();
long long f(long long, long long);

int main()
{
	printf("%lld\n", solve());
	return 0;
}

long long solve()
{
	long long n, s;
	scanf("%lld%lld", &n, &s);
	long long multiple{std::abs(n - s)}, min{n * 2};
	if (s == n) return s + 1;
	for (long long i = 1; i * i <= multiple; i++)
	{
		if (multiple % i) continue;
		if (f(n, i + 1) == s)
			return i + 1;
		if (f(n, multiple / i + 1) == s)
			min = multiple / i + 1;
	}
	if (min < n * 2) return min;
	return -1;
}

long long f(long long n, long long b)
{
	if (n < b) return n;
	else return f(n / b, b) + n % b;
}

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

void test3(){
    int n,x;
    //while(cin>>n>>x){
        long long ret=0;
        cin>>n>>x;
        vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];
        int r=x;
        for(int i=0;i<n;i++){
            if(a[i]>r) {
                ret=ret+a[i]-r;
                //cout<<ret<<" ";
                a[i]=r;
            }
            r=x-a[i];
            //cout<<r<<" ";
        }
        cout<<ret<<endl;
   // }
    return;
}
int main()
{
    //freopen("data","r",stdin);
    test3();
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  long long N;
  cin >> N;
  N--;
  int i=1;
  while(N>=pow(26,i)) {
    N -= pow(26,i);
    i++;
  }
  vector<char> ans;
  for(;i>0;i--) {
    ans.push_back('a'+N%26);
    N /= 26;
  }
  for(i=ans.size()-1;i>=0;i--)cout << ans[i];
  cout << endl;
}

Measured memory_bytes: 4104
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    ll x;
    cin >> x;
    ll k = 0;
    while ((k) * (k + 1) / 2 < x)
        ++k;
    cout << k << endl;

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long int H, W;
    
    while(1) {
        cin >> H >> W;
        if ( H == 0 && W == 0) break;
        for (int i = 0 ; i < H ; ++i) {
                for(int j = 0 ; j < W ; ++j) {
                    if(i == 0 || i == H-1 || j == 0 || j == W-1){ 
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] n = sc.next().toCharArray();
		boolean flag = false;
		for(int i = 1; i < n.length; i++) {
			if(n[i] != '9') {
				flag = true;
				break;
			}
		}
		int ans;
		if(flag) {
			 ans = (n[0]-'1')+9*(n.length-1);
		}
		else {
			 ans = (n[0]-'0')+9*(n.length-1);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
vector<int> Graph[110000];
vector<P> lis[110000];
vector<int> Depth[110000];
vector<int> Deep(110000);
vector<int> Parent(110000);
vector<int> child[110000];
vector<int> color(110000);
vector<int> ans(110000);
int root = 0;
void BFS() {
  for (int i = 0; i < (int)Deep.size(); i++) {
    Deep[i] = 999999;
  }
  priority_queue<P, vector<P>, greater<P>> Q;
  Q.push(make_pair(0,root));
  Depth[0].push_back(root);
  Deep[root] = 0;
  while (!Q.empty()) {
    P p = Q.top();
    Q.pop();
    for (int i = 0; i < (int)Graph[p.S].size(); i++) {
      if (Deep[Graph[p.S][i]] > p.F + 1) {
        Q.push(make_pair(p.F+1,Graph[p.S][i]));
        Deep[Graph[p.S][i]] = p.F + 1;
        Depth[p.F+1].push_back(Graph[p.S][i]);
        Parent[Graph[p.S][i]] = p.S;
        child[p.S].push_back(Graph[p.S][i]);
      }
    }
  }
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    lis[a].emplace_back(b,i);
    lis[b].emplace_back(a,i);
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  BFS();
  
  color[0] = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = 0; j < (int)Depth[i].size(); j++) {
      int s = Depth[i][j];
      int num = 1;
      for (int k = 0; k < (int)child[s].size(); k++) {
        if (num == color[s]) num++;
        color[child[s][k]] = num;
        num++;
      }
    }
  }
  cout << *max_element(color.begin(),color.end()) << endl;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < (int)lis[i].size(); j++) {
      if (Deep[lis[i][j].F] < Deep[i]) {
        ans[lis[i][j].S] = color[i];
      }
    }
  }
  for (int i = 0; i < N-1; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

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

//arc063_b
//18:45

const int nm = 1e5;
int n, t, a[nm], b[nm - 1], c = 0, m = 0;

int main() {
	cin >> n >> t;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	b[n - 2] = a[n - 1];
	for (int i = n - 3; i >= 0; i--)
		b[i] = max(b[i + 1], a[i + 1]);
	for (int i = 0; i < n - 1; i++) {
		if (b[i] - a[i] > m) {
			m = b[i] - a[i];
			c = 1;
		} else if (b[i] - a[i] == m)
			c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 1024
import sys

S =int(input())
a = S//100
b = S%100
if 1 <= a <= 12 and 1 <= b <= 12 :
    print("AMBIGUOUS")
    sys.exit()

elif 1 <= a <= 12 :
    print("MMYY")
    sys.exit()

elif 1 <= b <= 12 :
    print("YYMM")
    sys.exit()
else : print("NA")


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

int main()
{
    ll n;
    cin >> n;
    ll a[n], b[n];
    rep(i, n)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b + n, greater<>());
    rep(i, n)
    {
        if (a[i] == b[0])
            cout << b[1] << endl;
        else
            cout << b[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,ans = 0,count = 1;
    cin >> n;
    int a[n];
    a[n] = 0;
    rep(i, n)cin >> a[i];
    rep(i, n){
        if (a[i] == a[i + 1]) {
            ++count;
        }else{
            ans += count / 2;
            count = 1;
        }
    }
   cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int read() {
	int x;
	scanf("%d", &x);
	return x;	
}
ll readLL() {
	char ch = getchar(); ll x = 0;
	while (!isdigit(ch)) {
		ch = getchar();	
	}
	bool F = 0;
	int R = 9;
	while (isdigit(ch) || ch == '.') {
		if (ch != '.') x = x * 10 + ch - '0', R -= F;
		else F = 1;
		ch = getchar();
	}
	return 1ll * x * pow(10, R);
}
const int maxn = 3e5 + 10;
int n;
double a[maxn];
ll b[maxn], f5[maxn], f2[maxn], g[200][200];
int main() {
	#ifdef LOCAL
		freopen("1.in", "r", stdin);
	#endif
	int n = read();
	long long ans = 0;
	ll LM = 0, RM = 0;
	for (int i = 1; i <= n; ++i) {
		b[i] = readLL();
		while (b[i] % 5 == 0) b[i] /= 5, f5[i]++;
		while (b[i] % 2 == 0) b[i] /= 2, f2[i]++;
		g[f5[i]][f2[i]]++;
		LM = max(LM, f5[i]);
		RM = max(RM, f2[i]);
	}
	for (int i = 0; i <= LM; ++i) {
		for (int j = 0; j <= RM; ++j) {
			if (!g[i][j]) continue;
			for (int a = i; a <= LM; ++a) {
				for (int b = (i == a) ? j : 0; b <= RM; ++b) {
					if (!g[a][b] || min(i + a, b + j) < 18) continue;
					if (i == a && j == b) ans += 1ll * g[a][b] * (g[a][b] - 1) / 2;
					else ans += 1ll * g[i][j] * g[a][b];
				}
			}	
		}
	}
	cout << ans << endl;
	return 0;	
}
 	

Measured memory_bytes: 8720
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N;
        String S;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            S = sc.next();
        }
        char[] ch = S.toCharArray();
        int[] arr = new int[ch.length];
        for (int i = 0; i < ch.length; i++) {
            arr[i] = ch[i] - 48;
        }
        int result = 0;
        for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                for (int k = 0; k <= 9; k++) {
                    int target = 0;
                    for (; target < arr.length; target++) {
                        if (arr[target] == i) {
                            target++;
                            break;
                        }
                    }
                    for (; target < arr.length; target++) {
                        if (arr[target] == j) {
                            target++;
                            break;
                        }
                    }
                    for (; target < arr.length; target++) {
                        if (arr[target] == k) {
                            result++;
                            break;
                        }
                    }
                }
            }
        }


        System.out.println(result);
    }
}


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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int a, b, c, d, e, k;
int main()
{
	std::cin >> a >> b >> c >> d >> e >> k;

	if (e - a > k)
		std::cout << ":(" << std::endl;
	else
		std::cout << "Yay!" << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
  #include "debug.hpp"
#else
  #define DUMP(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
using value_type = typename iterator_traits<FwdIter>::value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int /*argc*/, char ** /*argv*/) {
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

  size_t n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  cin >> a >> b >> c;
  --a;
  int out = 0;
  for (const auto i: a) {
    out += b[i];
  }
  DUMP(out);
  for (size_t i = 1; i < n; ++i) {
    if (a[i] == a[i - 1] + 1) {
      out += c[a[i - 1]];
    }
  }

  cout << out;
  return EXIT_SUCCESS;
}


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

// Shabdan Batyrkulov

using namespace std;

#define MAX 1007
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
#define ll long long
#define ld long double

const long long N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;

int a[N], r[N];

int main () {
        ios::sync_with_stdio(0);
        int n; cin >> n;
        for (int i = 1; i <= n; i++) {
                cin >> a[i];
        }
        for (int i = 1; i <= n; i++) {
                r[a[i]] = i;
        }
        for (int i = 1; i <= n; i++) {
                ll ans = 30000 * i;
                cout << ans;
                if (i == n) continue;
                cout << ' ';
        }
        cout << endl;
        for (int i = 1; i <= n; i++) {
                ll ans = 30000 * (n - i) + r[i];
                cout << ans;
                if (i == n) continue;
                cout << ' ';
        }
        cout << endl;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template <typename T>
class FenwickTree
{
    int n;
    std::vector<T> bit;

  public:
    FenwickTree(int _n) : n(_n), bit(_n, 0) {}

    void add(int pos, const T &w)
    {
        assert(0 <= pos && pos < n);
        for (int i = pos; i < n; i |= i + 1)
            bit[i] += w;
    }
    // v[0] + ... + v[pos-1]
    T sum(int pos)
    {
        assert(0 <= pos && pos <= n);
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1)
        {
            res += bit[i];
        }
        return res;
    }
    T sum(int l, int r)
    {
        assert(0 <= l && l <= r && r <= n);
        return sum(r) + (-sum(l));
    }
};

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

    int x;cin>>x;
    cout<<x*x*x<<endl;
}


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

using namespace std;


int main() {
    long long n, k;
    cin >> n >> k;
    long long count = 0;
    for (long long b = k + 1; b < n + 1; ++b) {
        count += (n / b) * max(0ll, b - k);
        count += max(0ll, n % b - k + 1);
    }
    if (k == 0)count = n * n;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int s,w;
  cin >> s >> w;
  if(s<=w){
    cout << "unsafe" << endl;
  }
  else if(s>w){
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << "\n";
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
a = 0
for i in range(A+1):
    if 500*i < X:
        AA = 500*i
        for j in range(B+1):
            if 100*j < X-AA:
                BB = 100*j
                for k in range(C+1):
                    if 50*k == X-AA-BB:
                        a +=1
                    else:
                        pass
            elif 100*j == X-AA:
                a += 1
            else:
                pass
    elif 500*i == X:
        a +=1       
print(a)

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

string c;
string x[]={"a","i","u","e","o"};

signed main(){
    cin>>c;
    rep(i,0,5){
        if(x[i]==c){
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

const int maxn = 2e5 + 7;
const LL mod = 1e9 + 7;

LL fac[maxn],finv[maxn],inv[maxn];

void Cominit(int SIZE,LL mod) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2 ; i < SIZE ; i++) {
        fac[i] = (fac[i-1]*i)%mod;
        inv[i] = mod - (inv[mod%i]*((mod/i)))%mod;
        finv[i] = (finv[i-1]*inv[i])%mod;
    }
}

LL Com(int n,int m,LL mod) {
    if(n < m) return 0;
    if(n < 0 || m < 0) return 0;
    return (fac[n]*((finv[m]*finv[n-m])%mod))%mod;
}

int main() {
    int n,k;
    Cominit(maxn,mod);
    while(~scanf("%d%d",&n,&k)) {
        if(n < k) k = n - 1;
        LL ans = 0;
        for(int i = 0 ; i <= k ; i++) {
            ans = (ans % mod + ((Com(n,i,mod)%mod) * (Com(n-1,i,mod)%mod))%mod)%mod;
        }
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 4992
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define M 10000000000081
#define ld long double
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
ld arr[3005];
ld dp[3][3005][3005];
lli rec(lli start,lli l,lli r)
        {if(dp[start][l][r]!=-M)
             return dp[start][l][r];
        if(l==r)
             {if(start==1)
                return arr[l];
              else
                return -arr[l];
              }
            ld a;
          if(start==1)
            {
            a=max(rec(2,l+1,r)+arr[l],rec(2,l,r-1)+arr[r]);
            dp[start][l][r]=a;
            return a;
            }
          if(start==2)
           {
             a=min(rec(1,l+1,r)-arr[l],rec(1,l,r-1)-arr[r]);
             dp[start][l][r]=a;
              return a;
           }


        }
int main()
   {harry
    lli n;
    cin>>n;
    for(lli i=1;i<=n;i++)
        cin>>arr[i];
    for(lli i=1;i<=n;i++)
    {for(lli j=1;j<=n;j++)
       {dp[1][i][j]=-M;
        dp[2][i][j]=-M;

       }

    }
    for(int i=1;i<=n;i++)
       {dp[1][i][i]=arr[i];
        dp[2][i][i]=-arr[i];
        }
    cout<<rec(1,1,n);




    }

















Measured memory_bytes: 284416
#include<iostream>
#include<string>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	string s;
	while(cin>>n,n){
		int dt[n];
		rep(i,n)dt[i]=0;
		int field=0;
		cin>>s;
		int cnt=0;
		rep(i,s.size()){
			if(s[i]=='M'){
				dt[cnt]++;
			}else if(s[i]=='S'){
				dt[cnt]++;
				field+=dt[cnt];
				dt[cnt]=0;
			}else{
				dt[cnt]+=(field+1);
				field=0;
			}
			cnt++;
			cnt%=n;
		}
		sort(dt,dt+n);
		rep(i,n)cout<<dt[i]<<" ";
		cout<<field<<endl;
	}
	return 0;
}

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

int *a, n, ans;

int main() {
  scanf("%d", &n);
  n <<= 1;
  a = new int[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  std::sort(a, a + n);
  for (int i = 0; i < n; i += 2) {
    ans += std::min(a[i], a[i + 1]);
  }
  printf("%d\n", ans);
  return 0;
}

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

int main(){
  int a,b,n,t=0;
  cin >> a >> b >> n;
  for(int i=0; i<n*2; i=i+2){
    int num,num2;
    cin >> num >> num2;
    if(num<a&&num2>a){
      t=1;
    }
    if(num<b&&num2>b){
      t=1;
    }
    if(num==a&&num2==b)t=1;
    if(a<num&&b>num2)t=1;
  }
  cout << t << endl;
}



Measured memory_bytes: 3104
n = int(input())
maxx, minx, maxy, miny = -10**10, 10**10, -10**10, 10**10
for _ in range(n):
	x, y = map(int, input().split())
	x, y = x+y, x-y
	maxx = max(maxx, x)
	minx = min(minx, x)
	maxy = max(maxy, y)
	miny = min(miny, y)
print(max(maxx - minx, maxy - miny))


Measured memory_bytes: 9172