akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
using namespace std;
typedef long long LL; 

int main(){
        LL N,M;
        cin>>N>>M;
        if(N>M) swap(N,M);
        if(N==1){
                if(M==1) cout<<1<<endl;
                else cout<<M-2<<endl;
        }else cout<<(N-2)*(M-2)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<ll, int>;
const ll INF = 1e18;
const ll MAX = 1e15;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  --s, --t;
  vector<vector<int>> to(n), yen(n), snuke(n);
  rep(i, m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    --u, --v;
    to[u].push_back(v);
    to[v].push_back(u);
    yen[u].push_back(a);
    yen[v].push_back(a);
    snuke[u].push_back(b);
    snuke[v].push_back(b);
  }
  vector<ll> node1(n, INF), node2(n, INF);
  priority_queue<P, vector<P>, greater<P>> que;
  node1[s] = 0;
  que.push({0, s});
  while (!que.empty()) {
    ll cost;
    int now;
    tie(cost, now) = que.top();
    que.pop();
    if (cost > node1[now])
      continue;
    rep(i, to[now].size()) {
      if (chmin(node1[to[now][i]], cost+yen[now][i]))
        que.push({node1[to[now][i]], to[now][i]});
    }
  }
  node2[t] = 0;
  que.push({0, t});
  while (!que.empty()) {
    ll cost;
    int now;
    tie(cost, now) = que.top();
    que.pop();
    if (cost > node2[now])
      continue;
    rep(i, to[now].size()) {
      if (chmin(node2[to[now][i]], cost+snuke[now][i]))
        que.push({node2[to[now][i]], to[now][i]});
    }
  }
  rep(i, n)
    que.push({node1[i]+node2[i], i+1});
  rep(i, n) {
    while (que.top().second <= i)
      que.pop();
    cout << MAX-que.top().first << endl;
  }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> edge[200000];
    for(int i=0;i<N-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    queue<pair<int, int>> Q;
    Q.push({0, 0});
    int u;
    bool checked[200000] = {0};
    checked[0] = true;
    while(!Q.empty()){
        auto t = Q.front();
        Q.pop();
        for(int to : edge[t.first]){
            if(checked[to]) continue;
            checked[to] = true;
            Q.push({to, t.second+1});
            u = to;
        }
    }
    
    Q.push({u, 0});
    int d = 0;
    for(int i=0;i<N;i++) checked[i] = (i==u);
    while(!Q.empty()){
        auto t = Q.front();
        Q.pop();
        for(int to : edge[t.first]){
            if(checked[to]) continue;
            checked[to] = true;
            Q.push({to, t.second+1});
            d = t.second+1;
        }
    }
    d++;
    if(d % 3 == 2) cout << "Second" << endl;
    else cout << "First" << endl;

    return 0;
}

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

int main() {
  ll w,a,b;
  cin >> w >> a >> b;
  if(w+a<=b) cout << b-a-w << endl;
  else if(w+b<=a) cout << a-b-w << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int c = 0;
        if (x == 1 && y == 1) {
            c += 400000;
        }
        if (x == 1) {
            c += 300000;
        }
        if (x == 2) {
            c += 200000;
        }
        if (x == 3) {
            c += 100000;
        }
        if (y == 1) {
            c += 300000;
        }
        if (y == 2) {
            c += 200000;
        }
        if (y == 3) {
            c += 100000;
        }

        System.out.println(c);

    }

}

Measured memory_bytes: 23124
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// メイン
int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	return 0;
}


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

int main(){
  int a[5],sum=0;

  for(int i=0;i<5;++i){
    cin>>a[i];
    if(a[i]<40) a[i]=40;
    sum+=a[i];
  }

  cout << sum/5 << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int x[1<<18];
int t[1<<18][2];

int wh_max(int a,int b){
	if(a==-1)return b;
	if(b==-1)return a;
	return x[a]>x[b]?a:b;
}

int wh_max(int a,int b,int c){
	return wh_max(wh_max(a,b),c);
}

int update(int a,int b){
	if(t[a][0]==t[b][0])t[a][1]=wh_max(t[a][1],t[b][1]);
	else if(x[t[a][0]]<x[t[b][0]])t[a][1]=wh_max(t[a][0],t[a][1],t[b][1]),t[a][0]=t[b][0];
	else t[a][1]=wh_max(t[a][1],t[b][0],t[b][1]);
}

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	int s=0;
	memset(t,-1,sizeof(t));
	cin>>n;
	for(i=0;i<(1<<n);i++){
		cin>>x[i];
		t[i][0]=i;
		for(j=0;j<n;j++){
			if(i&(1<<j))update(i,i-(1<<j));
		}
	}
	for(i=1;i<(1<<n);i++){
		s=max(s,x[t[i][0]]+x[t[i][1]]);
		if(i>0)cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll N;
    string S;
    cin>>N>>S;
    ll ans=0;
    rep(i,1000){
        string ex=to_string(i);
        if(ex.size()==1) ex="00"+ex;
        if(ex.size()==2) ex="0"+ex;
        ll ichi=0;
        rep(j,N){
            if(ichi==3) break;
            if(S.at(j)==ex.at(ichi)) ichi++;
        }
        if(ichi==3) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int s;
  cin >> s;
  
  int yangbener;
  long long min=999999;
  int  tes=111;
  
  if(s/100==((s%100)/10) && ((s%100)/10)==s%10 && s/100==s%10){
   cout << s << endl; 
  }
  else{
    for(int i=0;i<9;i++){
    	
    	if(abs(tes-s)<min && tes>s){
    		min=abs(tes-s);
    		yangbener=tes;
		}
		tes+=111;
	}
	cout << yangbener << endl;
  }
}

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

const int N=2e5+5;
const ll INF = ll(1e18);
ll A[N], pos[N], neg[N], pn=0, nn=0;

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

    int n;
    ll k;
    cin >> n >> k;
    for(int i=0; i<n; i++) {
    	cin >> A[i];
    	if(A[i]<0) neg[nn++]=-A[i];
    	else pos[pn++]=A[i];
    }
    sort(pos, pos+pn);
    sort(neg, neg+nn);

    ll lb=-INF-1, ub=INF;

    // 
    while( ub-lb>1 ) {
    	ll x = (lb+ub)/2;
    	bool ok = [&] {
    		ll res = 0;
    		if(x < 0) { // - +
    			int j = nn;
    			for(int i=0; i<pn; i++) {
    				while(j > 0 && pos[i]*neg[j-1] >= -x) j--; // smaller than x
    				res += nn - j;
    			}
    		} else { // - -, + +
    			res += nn * pn;
    			int j;
    			j = pn-1;
   				for(int i=0; i<pn; i++) {
	    			while( j > i && pos[i]*pos[j] > x ) j--;
   					if(j <= i) break;
	    			res += j-i;
   				}
   				j = nn - 1;
   				for(int i=0; i<nn; i++) {
   					while( j > i && neg[i]*neg[j] > x ) j--;
   					if(j <= i) break;
   					res += j-i;
   				}
    		}
    		// cout << res << endl;
    		if( res >= k ) return true; // x too large
    		else return false; // x too small
    	}();
    	// cout << "x = " << x << endl;
    	if( ok ) ub = x;
    	else lb = x;
    	// cout << lb << ' ' << ub << endl;
    }
    cout << ub << endl;
	return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
std::string decipher(std::string src, int alpha, int beta)
{
	for (auto&i : src)
	{
		if ('a' <= i && i <= 'z')
		{
			i = ((i - 'a') * alpha + beta) % 26 + 'a';
		}
	}
	return src;
}
int main()
{
	int n;
	std::cin >> n;
	std::cin.ignore();
	for (int i = 0; i < n; i++)
	{
		std::string origin;
		std::getline(std::cin, origin);
		for (int alpha = 0; alpha < 100; alpha++)
		{
			for (int beta = 0; beta < 26; beta++)
			{
				const std::string deciphered = decipher(origin, alpha, beta);
				if (deciphered.find("this") != std::string::npos || deciphered.find("that") != std::string::npos)
				{
					std::cout << deciphered << std::endl;
					alpha = beta = 100;
				}
			}
		}
	}
	return 0;
}


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

int main(){
	int H, W;
	while (true){
		cin >> H >> W;
		if (H == 0 && W == 0)break;

		for (int j = 0; j < W; j++) cout << "#";
		cout << endl;

		for (int i = 1; i < H-1; i++){
			cout << "#";
			for (int j = 1; j < W-1; j++)	cout << ".";
			cout << "#" << endl;
		}

		for (int j = 0; j < W; j++) cout << "#";
		cout << endl;

		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2e5+10;
int ti[MAXN];
int main(){
	int n,t;
	while(cin>>n>>t){
		for(int i=1;i<=n;i++) cin>>ti[i];
		ll sum=0;
		sum+=t;
		for(int i=2;i<=n;i++){
			sum+=min(t,ti[i]-ti[i-1]);
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

int dist(P a, P b){
    return abs(a.F-b.F)+abs(a.S-b.S);
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    vp a(n),b(m);
    rep(i,n)cin>>a[i].F>>a[i].S;
    rep(i,m)cin>>b[i].F>>b[i].S;

    rep(i,n){
        int res=0;
        int min=dist(a[i],b[0]);
        range(j,1,m){
            if(min>dist(a[i],b[j])){
                min=dist(a[i],b[j]);
                res=j;
            }
        }
        cout<<res+1<<endl;
    }
}

Measured memory_bytes: 3644
def distance_check(arr_1,arr_2)
  c = 0
  sum = 0
  while c < arr_1.size
    sum += (arr_1[c] - arr_2[c])**2
    c += 1
  end
  if Math.sqrt(sum) - Math.sqrt(sum).to_i == 0
    return true
  else
    return false
  end
end
n,d = gets.chomp.split(' ').map(&:to_i)
count = 0
arr = []
n.times do
  pts = gets.chomp.split(' ').map(&:to_i)
  arr.push(pts)
end
i = 0
while i < arr.size - 1
  j = i + 1
  while j < arr.size
    if distance_check(arr[i],arr[j])
      count += 1
    end
    j += 1
  end
  i += 1
end
puts count

Measured memory_bytes: 14308
import java.io.IOException;
import java.util.Arrays;

public class Main {

	private static final int INF = 1000001;

	public static void main(String[] args) {
		int[] pollock = new int[180];// 180*181*182/6が条件内で最大の正四面体数
		for (int i = 1; i <= pollock.length; i++) {
			pollock[i - 1] = (i * (i + 1) * (i + 2)) / 6;
		}

		int[][] dp = new int[2][INF];// dp[奇数？][jを作るのに必要な正四面体数の数の最小値]
		Arrays.fill(dp[0], Integer.MAX_VALUE);// 全部用
		Arrays.fill(dp[1], Integer.MAX_VALUE);// 奇数用

		// 最初は0
		dp[0][0] = 0;
		dp[1][0] = 0;

		for (int i = 0; i < pollock.length; i++) {
			for (int j = pollock[i]; j < INF; j++) {
				// 各pollock数について、調べる
				dp[0][j] = Math.min(dp[0][j], dp[0][j - pollock[i]] + 1);
				if (pollock[i] % 2 == 1) {
					// pollock数が奇数の時
					dp[1][j] = Math.min(dp[1][j], dp[1][j - pollock[i]] + 1);
				}
			}

		}

		while (true) {
			int N = nextInt();
			if (N == 0) {
				break;
			}

			System.out.println(dp[0][N] + " " + dp[1][N]);

		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

Measured memory_bytes: 28024
N = int(input())
D = []
for i in range(N):
    a, b = map(int, input().split())
    D.append((a, b))

num = 0
for i in range(N - 1, -1, -1):
    if (D[i][0] + num) % D[i][1] > 0:
        num += D[i][1] - (D[i][0] + num) % D[i][1]
print(num)


Measured memory_bytes: 16592
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    vector<string> t;
    vector<int> a, b, pos(2 * n);
    for (int i = 0; i < 2 * n; ++i) {
        if (s[i] == 'a') {
            pos[i] = a.size();
            a.push_back(i);
        } else {
            pos[i] = b.size();
            b.push_back(i);
        }
        if (a.size() == b.size()) {
            string f;
            if (a.back() < b.back()) {
                int lst = -1;
                for (int j = 0; j < a.size(); ++j) {
                    if (a[j] > lst) {
                        f += "ab";
                        lst = b[j];
                    }
                }
            } else {
                int l = i - 2 * a.size() + 1;
                for (int j = 0; j < a.size(); ++j) {
                    string g;
                    for (int k = l; k <= i; ++k)
                        if (pos[k] >= j)
                            g += s[k];
                    f = max(f, g);
                }
            }
            t.push_back(f);
            a.clear();
            b.clear();
        }
    }
    s.clear();
    reverse(t.begin(), t.end());
    for (auto &f : t)
        s = max(s, f + s);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int p[n]; for (int i = 0; i < n; i++) cin >> p[i];
    int c[n] = {};
    c[p[0]] = 1;
    int ans = 0;
    for (int i = 1; i < n; i++) c[p[i]] = 1 + c[p[i]-1], ans = max(ans, c[p[i]]);
    cout << (n == 1 ? 0 : n-ans) << endl;
}


Measured memory_bytes: 1920
N, M = map(int,input().split())
key = [0] * M
cost = [0] * M
for i in range(M):
    a, b = map(int,input().split())
    cost[i] = a
    key_id = list(map(int,input().split()))
    for j in range(b):
        key[i] |= (1 << (key_id[j] - 1))
dp = [[float("inf")] * (1<<N)] * (M + 1)
dp[0][0] = 0
for i in range(M):
    for j in range(1<<N):
        if dp[i + 1][j | key[i]] > dp[i][j] + cost[i]:
            dp[i + 1][j | key[i]] = dp[i][j] + cost[i]
        if dp[i + 1][j] > dp[i][j]:
            dp[i + 1][j] = dp[i][j]
if dp[-1][-1] == float("inf"):
    print(-1)
else:
    print(dp[-1][-1])

Measured memory_bytes: 47192
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
	string S;
	cin>>S;
	
	int w=0,s=0,n=0,e=0;
	fx(S.size()){
		switch(S.at(x)){
			case 'N':n++;break;
			case 'S':s++;break;
			case 'W':w++;break;
			case 'E':e++;break;
		}
	}
	bool can=true;
	if(w>0){
		if(e==0){can=false;}
	}else if(e>0){can=false;}
	
	if(s>0){
		if(n==0){can=false;}
	}else if(n>0){can=false;}
	
	if(can){
		ce("Yes")
	}else{
		ce("No")
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int GCD (int x, int y) {
  if (y == 0) return x;
  return GCD(y, x%y);
}

int main() {
    int n,X;
    cin >> n >> X;
    vector<int> x(n);
    rep(i,n) {
        cin >> x[i];
        x[i] = abs(X-x[i]);
    }
    int ans = GCD(x[1],x[0]);
    rep(i,n-1) {
        ans = GCD(ans, abs(x[i+1]-x[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std; 
using ll=long long;
#define endl "\n"
#define F(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ALL(v) v.begin(),v.end()
void solve(){
    
    ll a;
    cin>>a;
    cout<<3*a*a;

}
signed main(){
    fast;
     
    solve();
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int get() {
  char t, o;
  cin >> t >> o;
  return (t-'0') * 10 + o - '0';
}

string ans[2][2] = {
  {"NA", "YYMM"},
  {"MMYY", "AMBIGUOUS"}
};

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int a = get();
  int b = get();
  a = a && a <= 12;
  b = b && b <= 12;
  cout << ans[a][b] << nl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;
struct node{
    int mid;
    int l, r;

}arr[100010];

bool cmp(node a, node b){
    return a.mid < b.mid;
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i ++){
        scanf("%d%d", &arr[i].mid, &arr[i].l);
        arr[i].r = arr[i].l + arr[i].mid;
        arr[i].l = arr[i].mid - arr[i].l;
        //arr[i].l ++;
        arr[i].r --;
    }
    sort(arr, arr + n, cmp);
    int ans = 0;
    node last;
    last = arr[0];
    ans = 1;
    for(int i = 0; i < n - 1; i ++){
        if(last.r < arr[i + 1].l){
            last = arr[i + 1];
            ans ++;
        }
        else if(last.r > arr[i + 1].r){
            last = arr[i + 1];
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 1e5 + 10;
int n, m, T, a[maxn];

ll dp[maxn];

int main() {
  scanf("%d %d %d", &n, &m, &T);
  rep(i, 1, n) a[i] = read();
  int l = 1, r = 1;
  static int Q[maxn];
  int tpos = -1; ll tmin = 1e18;
  rep(i, 1, n) {
    for (; tpos < i && 2 * a[tpos + 1] <= 2 * a[i] - T; tpos++) {
      if (~tpos) chkmin(tmin, dp[tpos] - 2 * a[tpos + 1]);
    }
    while (l <= r && 2 * a[Q[l] + 1] <= 2 * a[i] - T) l++;
    dp[i] = tmin + 2 * a[i];
    if (l <= r) {
      chkmin(dp[i], dp[Q[l]] + T);
    }
    while (l <= r && dp[Q[r]] >= dp[i]) r--;
    Q[++r] = i;
  }
  printf("%lld", dp[n] + m);
  return 0;
}

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

#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define FILL(v,p) memset(v,p,sizeof v)
#define FIO ios::sync_with_stdio(NULL); cin.tie(NULL)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define PI acos(-1.0)

const ll MOD = 1000000007;
const ll INF = 2000000000000000001LL;
const ld EPS = 1e-9;

ll MUL(ll x, ll y){return (x%MOD * y%MOD)%MOD;}

ll fastpow(ll a, ll p)
{
    if(p==0) return 1;
    ll mul= fastpow(a,p/2);
    
    if(p&1) return (MUL(MUL(mul,mul),a));
    return MUL(mul,mul);
}

ll red(ll n, ll r)
{
    ll ans=1;
    n--, r--;
    if(r > n-r) r=n-r;
    for(int i=1;i<=r;i++)
    {
        //~ans=MUL(ans,((n-i+1)/i));
        
        ans*=(n-i+1);        
        ans%=MOD;
        ans*= fastpow(i,MOD-2);
        ans%=MOD;
    }
    
    return ans;
}

int main()
{
    FIO;
    
    ll n, a, b;
    cin >> n >> a >> b;
    
    ll ans= fastpow(2,n)-1;
    ans+=MOD;
    ans%=MOD;
    
    ans-=red(n+1,a+1);
    ans+=MOD;
    ans%=MOD;
    
    ans-=red(n+1,b+1);
    ans+=MOD;
    ans%=MOD;
    
    cout << ans%MOD << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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 <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  string S;
  cin >> S;

  if (S[6] == '1') {
    if (S[5] == '1') {
      COUT("TBD");
      return 0;
    }
    COUT("Heisei");
    return 0;
  }
  if (S[6] == '2') {
    if (S[5] == '1') {
      COUT("TBD");
      return 0;
    }
    COUT("Heisei");
    return 0;
  }
  if (S[6] == '3') {
    COUT("Heisei");
    return 0;
  }

  if (S[6] == '4') {
    COUT("Heisei");
    return 0;
  }

  COUT("TBD");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
    string S;
    int n, i, num, ans=1000;

    cin >> S;

    n = S.size();

    for(i=0; i<=n-3; i++){
        num = (S[i]-'0') * 100 + (S[i+1]-'0') * 10 + (S[i+2]-'0');
        
        ans = min(abs(num-753), ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n;
  cin>>n;
  
  vector<int> a(n),b(n),c(n-1);
  
  for(int i=0;i<n;i++){cin>>a[i],a[i]--;}
  for(int i=0;i<n;i++){cin>>b[i];}
  for(int i=0;i<n-1;i++){cin>>c[i];}

  int ans=0;

  for(int i=0;i<n;i++){
    ans+=b[a[i]];
    if(i&&a[i-1]+1==a[i])ans+=c[a[i-1]];
  }

  cout<<ans<<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))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	char S[100001];
	while (~scanf("%s", S)) {
		bool ans = string(S).find("YAKI") == 0;
		puts(ans ? "Yes" : "No");
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0 ;i < (int)(n) i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 << endl;
	}
	else {
		cout << n / 2 + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void solve() {
	ll a, b;
	cin >> a >> b;
	ll ans = 0;
	if (a <= 0 && b >= 0) {
		cout << "Zero" << en;
		return;
	}
	if (a < 0) ans = - a + b - 1;
	cout << ((ans % 2 == 0) ? "Positive" : "Negative") << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main(){
  var b string
  fmt.Scan(&b)

  var out []rune
  for _,v := range b {
    switch v {
    case 'B':
      if len(out) > 0 {
        out = out[:len(out) - 1]
      }
      default:
        out = append(out, v)
    }
  }
  fmt.Println(string(out))
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
int main() {
	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	puts((c - a - b) > 0 && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct _point {
  double x, y;
} point;

// テ」ツδ凖」ツつッテ」ツδ暗」ツδォa, bテ」ツ?ョテ・ツ、ツ姪ァツゥツ催」ツ?ョテ・ツ、ツァテ」ツ?催」ツ?陛」ツつ津ヲツアツづ」ツつ?」ツつ凝」ツ??
double cross(point a, point b) {
  return a.x * b.y - a.y * b.x;
}

int main() {
  int Tc, tc;
  point A, B, C, D;
  scanf("%d", &Tc);
  for(tc = 0; tc < Tc; ++tc) {
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
          &A.x, &A.y, &B.x, &B.y, &C.x, &C.y, &D.x, &D.y);
    point va, vb;
    va.x = B.x - A.x;
    va.y = B.y - A.y;
    vb.x = D.x - C.x;
    vb.y = D.y - C.y;
    // テ」ツδ凖」ツつッテ」ツδ暗」ツδォa, bテ」ツ?ョテ・ツ、ツ姪ァツゥツ催」ツ?ョテ・ツ、ツァテ」ツ?催」ツ?陛」ツ?? テ「ツ??テ」ツδ凖」ツつッテ」ツδ暗」ツδォa, bテ」ツ?ッテ・ツケツウティツ。ツ?
    if(cross(va, vb) == 0.0) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1048
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        if (h + r > 0) {
            System.out.println(1);
        } else if (h + r == 0) {
            System.out.println(0);
        } else {
            System.out.println(-1);
        }
    }
}



Measured memory_bytes: 26292
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 long long f(long long x){

     long long  cnt=0;
     while(x){
      cnt += 1;
      x = x/10;
     }

 return cnt;
 }

 int main(){

 long long n,ans=0;
 cin>>n;


 for(long long i=1;i<= sqrt(n);i++){

   if(n%i == 0){
     if(ans == 0)
        ans = max(f(i),f(n/i));
     else
        ans = min(max(f(i),f(n/i)),ans);
   }
 }

 cout<<ans<<endl;

  return 0;
 }


Measured memory_bytes: 3520
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] p = new int[n];
    long sum = 0;
    int count = 0;
    for(int i=0;i<n;i++){
      p[i] = Integer.parseInt(sc.next());
      if(p[i]==i+1){
        count++;
      }else{
        sum+=(count+1)/2;
        count = 0;
      }
    }
    sum+=(count+1)/2;
    System.out.println(sum);
  }
}


Measured memory_bytes: 59124
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 106
#define mod 1000000007
int dp[N][N],n,s[N],st[N],v[N],v2[N],ct,as=1;
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i]),v[i]=s[i];
	sort(v+1,v+n+1);
	v[0]=1;for(int i=1;i<=n;i++)if(v[i]!=v[i-1])v2[++ct]=v[i];
	for(int i=1;i<=n;i++)for(int j=1;j<=ct;j++)if(s[i]==v2[j])st[i]=j;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	if(s[i]==1)
	{
		int su=0;
		for(int j=0;j<=ct+1;j++)su=(su+dp[i-1][j])%mod;
		as=2ll*as*su%mod;
		dp[i][0]=1;
	}
	else if(s[i-1]<=1)
	{
		for(int j=1;j<=st[i];j++)
		dp[i][j]=pw(2,s[i]-v2[j-1]+(j>1));
		dp[i][st[i]+1]=2;
		for(int j=1;j<=st[i];j++)dp[i][j]=(dp[i][j]-dp[i][j+1]+mod)%mod;
	}
	else if(s[i]<=s[i-1])
	{
		for(int j=1;j<=st[i-1]+1;j++)
		if(j>st[i])dp[i][st[i]+1]=(dp[i][st[i]+1]+2ll*dp[i-1][j])%mod;
		else dp[i][j]=dp[i-1][j];
	}
	else
	{
		for(int j=1;j<=st[i-1];j++)dp[i][j]=1ll*dp[i-1][j]*pw(2,s[i]-s[i-1])%mod;
		for(int j=st[i-1]+1;j<=st[i];j++)dp[i][j]=2ll*dp[i-1][st[i-1]+1]*pw(2,s[i]-v2[j-1])%mod;
		dp[i][st[i]+1]=2ll*dp[i-1][st[i-1]+1]%mod;
		for(int j=st[i-1]+1;j<=st[i];j++)dp[i][j]=(dp[i][j]-dp[i][j+1]+mod)%mod;
	}
	int su=0;
	for(int j=0;j<=ct+1;j++)su=(su+dp[n][j])%mod;
	as=1ll*as*su%mod;
	printf("%d\n",as);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N; //頂点の数、辺の数
vector<vector<int>> dist(301, vector<int>(301, 0));
vector<vector<bool>> nec(301, vector<bool>(301, false));

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i <= N; i++) dist[i][i] = 0;
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= N; ++j){
            scanf("%d", &dist[i][j]);
        }
    }
    
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= N; ++j){
            for(int k = 1; k <= N; ++k){
                if(i == j || i == k || j == k) continue;
                ll a = dist[j][i], b = dist[i][k], c = dist[j][k];
                if(a + b < c){ printf("-1\n"); return 0; }
                if(a + b == c) nec[j][k] = true;
            }
        }
    }
    
    ll ans = 0;
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= i; ++j){
            if(!nec[i][j]) ans += dist[i][j];
        }
    }
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define vpi vector<pair<int,int> > 
#define vpll vector<pair<lli,lli> > 
#define vvi vector<vector<int> >
#define vvll vector<vector<lli> >
#define maxn 500005
#define mod 1000000007
#define inf 10000000000000000
 
 
 
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    vi p(n),c(n);
    for(int i=0;i<n;i++)
    cin>>p[i],p[i]--;
    for(int i=0;i<n;i++)
    cin>>c[i];
    bitset<5001> fr;
    lli ans=-1e15;
    for(int i=0;i<n;i++)
    {
        int st=p[i];
        vi cur;cur.pb(st);
        while(st!=i)
        {
            st=p[st];
            cur.pb(st);
        }
        int n1=cur.size();
        lli tot=0,pm=-1e15,pm2=-1e15;
        lli num=k/n1;
        lli rem=k%n1;
        for(int i=0;i<n1;i++)
        {
            if(i<k) tot+=c[cur[i]],ans=max(ans,tot),pm=max(pm,tot);
            if(i<rem) pm2=max(pm2,tot);
        }
        if(num!=0)
        ans=max(ans,num*tot+max(pm2,0ll));
        if(num>=1)
        ans=max(ans,(num-1)*tot+pm);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3736
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
F = factorization(N)
f = len(F)
answer = 0
for i in range(f):
    count = 1
    if F[i][0] == 1:
        break
    if F[i][1] == 1:
        answer += 1
    else:
        while True:
            if F[i][1] < count:
                break
            else:
                F[i][1] = F[i][1] - count
                count += 1
                answer += 1

print(answer)

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;
 
 
int main(void){
 
  int N;
  cin >> N;
  
  if(((N%10)==7) || ((N%100)/10)==7 || N/100==7){
    cout << "Yes";
  }else{
    cout << "No";
  }
 
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		
		int n = N % 10;
		
		switch(n){
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			break;
			
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;
			
		default:
			System.out.println("bon");
		}
    }
}

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

int main(){
    int n,m;
    int ac=0,pe=0;
    cin>>n>>m;
    vector<bool> pro(n,false);
    vector<int> wa(n,0);
    rep(i,m){
        int pi;
        string si;
        cin>>pi>>si;
        if(!pro[pi]){
            if(si=="AC"){
                pro[pi]=true;
                ac++;
                pe+=wa[pi];
            }else{
                wa[pi]++;
            }
        }
    }
    cout<<ac<<" "<<pe;
    return 0;
}


Measured memory_bytes: 640
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    r,d,x= map(int, sys.stdin.readline().split(' '))
    for i in range(10):
        x=r*x - d
        print(x)
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

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

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

    long long sum=0;
    vector<long long> candidate(2);
    // 和の符号が負、正、負、正、、、、
    long long ans=0;
    for (int i=0; i<N; i++) {
        sum += A[i];
        if (i%2 == 0) {
            if (sum >= 0) {
                ans += sum+1;
                sum += -1-sum;
            }
        }
        else if (i%2 == 1) {
            if (sum <= 0){
                ans += 1-sum;
                sum += 1-sum;
            }
        }
    }
    candidate[0] = ans;

    // 和の符号が正、負、正、負、、、、
    ans=0;
    sum=0;
    for (int i=0; i<N; i++) {
        sum += A[i];
        if (i%2 == 0) {
            if (sum <= 0){
                ans += 1-sum;
                sum += 1-sum;
            }
        }
        else if (i%2 == 1) {
            if (sum >= 0) {
                ans += sum+1;
                sum += -1-sum;
            }
        }
    }
    candidate[1] = ans;

    cout << min(candidate[0], candidate[1]) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl dp(n+1, INF);  // dp[i] : i円引き出すのに必要な操作回数の最小値
    dp[0] = 0;
    rep(i, n) {
        ll pow6 = 1;
        while(i + pow6 <= n) {
            chmin(dp[i + pow6], dp[i] + 1);
            pow6 *= 6;
        }
        ll pow9 = 1;
        while(i + pow9 <= n) {
            chmin(dp[i + pow9], dp[i] + 1);
            pow9 *= 9;
        }
    }

    out(dp[n]);
    re0;
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

/////////////////////////////////////////////////////

ll N;
char S[40];

ll i, j, k;

int main(){
    scanf("%lld%lld%lld", &i, &j, &k);
    ll a = (i - 1) / j + 1;
    printf("%lld\n", a * k);

    return 0;
}

Measured memory_bytes: 3836
import collections

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


a = collections.Counter(a)

a = a.most_common()
if k<len(a):
	x = 0
	for i in range(k,len(a)):
		x += a[i][1]

	print(x)
else:
	print(0)


Measured memory_bytes: 42492
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int main(){

	ll n, x;
	cin >> n >> x;

	vector< ll > data;
	for(ll i = 0; i < n; i++)
	{
		ll a;
		cin >> a;
		data.push_back(abs(a-x));
	}

	if(data.size() == 1){
		cout << abs(data[0]) << endl;
		return 0;
	}

	ll ans = gcd(data[0], data[1]);
	
	for(ll i = 2; i < n; i++)
	{
		ans = gcd(ans,data[i]);
	}
	cout << ans << endl;
	

	
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int n = cin.Int();
        string A = Console.ReadLine();
        string B = Console.ReadLine();
        string C = Console.ReadLine();

        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) ans += 2;
            else if (A[i] == B[i] && B[i] == C[i]) continue;
            else ans += 1;
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

void topsort(int i, int n, vector<vector<int>>& graph, vector<bool>& visited, vector<int>& ret) {
    visited[i] = true;
    vector<int>& myedges = graph[i];
    for(int& edge : myedges) {
        if(!visited[edge]) {
            topsort(edge, n, graph, visited, ret);
        }
    }
    ret.insert(ret.begin(), i);
}

int32_t main() {

    int n, m; cin >> n >> m;
    vector<vector<int>> graph(n+1, vector<int>());
    for(int i = 0; i < n+m-1; ++i) {
        int u, v; cin >> u >> v;
        graph[u].push_back(v);
    }
    vector<bool> visited(n+1);
    vector<int> ret;
    for(int i = 1; i <= n; ++i) {
        if(!visited[i])
            topsort(i, n, graph, visited, ret);
    }

    vector<vector<int>> working(n+1, vector<int>());
    vector<int> parents(n+1);

    int root = ret[0];
    parents[root] = 0;
    for(int edge : graph[root]) {
        working[edge].push_back(root);
    }
    for(int i = 1; i < n; ++i) {
        int cur = ret[i];
        vector<int>& w = working[cur];
        int ans = w[w.size()-1];
        parents[cur] = ans;
        for(int edge : graph[cur]) {
            working[edge].push_back(cur);
        }
    }

    for(int i = 1; i <= n; ++i) {
        cout << parents[i] << endl;
    }
    
    return 0;
}

/*
1:
2: 1,3,6
3:
4: 1,2,6
5:
6: 1,5

426531

4 = 0
2 = 4
6 = 2
5 = 6
3 = 2
1 = 6
                       
*/


Measured memory_bytes: 19700