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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

long long extGcd(long long a, long long b, long long &p, long long &q) {  
    if (b == 0) { p = 1; q = 0; return a; }  
    long long d = extGcd(b, a%b, q, p);  
    q -= a/b * p;  
    return d;  
}

//--------------------------- Solve ---------------------------//

int N, MM;

// 中国剰余定理
// リターン値を (r, m) とすると解は x ≡ r (mod. m)
// 解なしの場合は (0, -1) をリターン
pair<long long, long long> ChineseRem(const vector<long long> &b, const vector<long long> &m) {
    long long r = 0, M = 1;
    for (int i = 0; i < (int)b.size(); ++i) {
        long long p, q;
        long long d = extGcd(M, m[i], p, q); // p is inv of M/d (mod. m[i]/d)
        if ((b[i] - r) % d != 0) return make_pair(0, -1);
        long long tmp = (b[i] - r) / d * p % (m[i]/d);
        r += M * tmp;
        M *= m[i]/d;
        
        //print("r:", r, "M:", M, "tmp:", tmp);
        if (abs(r) > MM) {
            cout << 0 << '\n';
            exit(0);
        }
    }
    return make_pair(mod(r, M), M);
}

void solve() {
    cin >> N >> MM;
    vector<long long> b(N), m(N);
    for (int i = 0; i < N; i++) {
        cin >> m[i];
        b[i] = m[i] / 2;
    }

    pair<long long, long long> p = ChineseRem(b, m);
    
    if (p.second == -1) {
        cout << 0 << '\n';
        return;
    }

    //print(p.first, p.second);

    int ans = (MM - p.first) / p.second + 1;

    cout << ans << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 5124
def kruskal(n):
    cost = []
    tree = [{i} for i in range(n)]
    while edge:
        cmin = min(weight)
        index = weight.index(cmin)
        i, j = edge[index]
        del weight[index], edge[index]
        for t in tree:
            if {i, j} <= t:
                break
        else:
            cost.append(cmin)
            for n in range(len(tree)):
                if i in tree[n]:
                    tmp = tree[n]
                    del tree[n]
                    break
            for n in range(len(tree)):
                if j in tree[n]:
                    tree[n] |= tmp
                    break
    return sum(cost)

n = int(input())
edge = []
weight = []
for i in range(n):
    for j, c in enumerate(map(int, input().split())):
        if c != -1 and not {i, j} in weight:
            edge.append({i, j})
            weight.append(c)
print(kruskal(n))

Measured memory_bytes: 9512
#d=日数, c=満足低下度, s=満足上昇度, t=コンテストの日程 
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(d)]
t = [int(input()) for j in range(d)]
last = [0 for i in range(26)]
#print(c)
res = 0
count = 0
#while count != len(t):
for day in range(d):
  res += s[day][t[day]-1]
  last[t[day]-1] = day+1
  #print(last)
  #print(c[last[t[day]-1]])
  for i in range(26):
    #print(c[i] * (day + 1 - last[i]))
    res -= c[i] * (day + 1 - last[i])
  print(res)


Measured memory_bytes: 9208
import java.util.Scanner;

class Point {
	double x;
	double y;

	Point(double x, double y) {
		this.x = x;
		this.y = y;
	}

	void print() {
		 System.out.printf("%.8f %.8f%n", this.x, this.y);
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point p1 = new Point(0, 0);
		Point p2 = new Point(100, 0);
		p1.print();
		Koch(n, p1, p2);
		p2.print();
	}

	public static void Koch(int n, Point p1, Point p2) {
		if (n == 0) {
			return;
		}
		Point s = new Point((p1.x * 2.0 + p2.x * 1.0) / 3.0, (p1.y * 2.0 + p2.y * 1.0) / 3.0);
		Point t = new Point((p1.x * 1.0 + p2.x * 2.0) / 3.0, (p1.y * 1.0 + p2.y * 2.0) / 3.0);
		Point u = new Point((t.x - s.x) * 0.5 - (t.y - s.y) * Math.sqrt(3.0) *0.5 + s.x,
			             	(t.x - s.x) * Math.sqrt(3.0) *0.5 + (t.y - s.y) * 0.5 + s.y);

		Koch(n - 1, p1, s);
		s.print();
		Koch(n - 1, s, u);
		u.print();
		Koch(n - 1, u, t);
		t.print();
		Koch(n - 1, t, p2);
	}
}


Measured memory_bytes: 44736
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, m, s[10], c[10], num[10];

bool dfs(int cur){
    if(cur == n){
        if(n != 1 && num[0] == 0) return false;
        rep(i, m){
            if(num[s[i]-1] != c[i]) return false;
        }
        return true;
    }
    rep(i, 10){
        num[cur] = i;
        if(dfs(cur + 1)) return true;
        num[cur] = -1;
    }
    return false;
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, m) scanf("%d%d", &s[i], &c[i]);
    rep(i, n) num[i] = -1;
    if(dfs(0)) rep(i, n) printf("%d", num[i]);
    else puts("-1");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main() {
	int n;
	cin >> n;
	multiset<int> st;
	REP(i,n){
		int a;
		scanf("%d", &a);
		st.insert(a);
	}
	int m;
	cin >> m;
	REP(i,m){
		int a;
		scanf("%d", &a);
		if (st.count(a) == 0){
			cout << "NO" << endl;
			return 0;
		}
		st.erase(st.find(a));
	}
	cout << "YES" << endl;
    
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007 
#define ff first
#define ss second
#define pb push_back  
#define INF 1000000000000
									//nestedcode



long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%M;
        a = a * a%M;
        b >>= 1;
    }
    return res;
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,ans;
    cin>>n;
    ll d = n/3;
    ll p = n/5;
    ll k = n/15;
    k = (k*(k+1))/2*15;
    d = (d*(d+1))/2*3;
    p = (p*(p+1))/2*5;
    ans = (n*(n+1))/2;
    ans = ans -p - d + k;
    cout<<ans;
    
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
using namespace std;

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

const long long INF = 1LL << 60;
string S;
int main()
{
	cin >> S;
	char str[26] = {};
		for (int j = 0;j < S.size();j++) {
			str[S[j] - 'a']++;
		}
	string res;
	for (int i = 0;i < 26;i++) {
		if (!str[i]) {
			res = 'a'+i;
			break;
		}
		if (i == 25) {
			res = "None";
			break;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 512
# coding: utf-8
# Your code here!
n=int(input())
a,b,c=[],[],[]
f=0
for i in range(n):
    x=int(input())
    a.append(x)
    if f==0:
        b.append(x)
    else:
        c.append(x)
    f=1-f

a.sort()
#b=a[0:n:2]
d=a[1:n:2]
sc=set(c)
sd=set(d)
ans=len(sd-sc)
print(ans)

Measured memory_bytes: 66392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,T,A,ans;
  double mar = 10000;

  cin >> N >> T >> A;

  vector<int> H(N);

  for(int i=0;i<N;i++){
    cin >>H.at(i);
  }//入力終了

    for(int i=0;i<N;i++){

    double s = T - (double)H.at(i) * 6 / 1000;

    if(abs(A-s)<=mar){
      ans=i+1;
      mar=abs(A-s);
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	if (k <= a)
	{
		ans = k;
	}
	else if (k > a)
	{
		if (k >= a + b)
		{
			ans = a - (k - a - b);
		}
		else if (k < a + b)
			ans = a;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int k,min_;
    int sum=0, mul=1;
    cin >> k;
    for (int i=1; i<=k; i++){
        for (int j=1; j<=k; j++){
            for (int l=1; l<=k; l++){
                int i1 = i;
                int j1 = j;
                int l1 = l;
                mul = 1;
                
                for (int m=2; m<=max(max(i1,j1),l1);){
                    if( i1 % m == 0 && j1 % m == 0 && l1 % m == 0 ){
                        mul = mul*m;
                        i1 = i1 / m;
                        j1 = j1 / m;
                        l1 = l1 / m;
                    }
                    else m++;
                    if( i1 < m || j1 < m || l1 < m ) break; // この工夫がないとACされない
                }
                sum += mul;
                
            }
        }
    }
    
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
//#define TEST
const ll MOD = 1e9+7;

vector<map<int, int>> edges;
struct idx{
    int i;
    bool operator < (const idx& o) const{
        return edges[i].size() < edges[o.i].size();
    }
};

int main(int argc, char** argv) {
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    int n;
    cin >> n;
    edges.resize(n+1);
    FOR1(i, n-1){
        int a, b;
        cin >> a >> b;
        edges[a][b] = 1;
        edges[b][a] = 1;
    }
    auto edges0 = edges;
    vi c(n+1);
    FOR1(i, n)
        cin >> c[i];

    sort(c.begin()+1, c.end());

    vector<int> vals(n+1);
    queue<int> Q;
    FOR1(u, n){
        if (edges[u].size() == 1)
            Q.push(u);
    }
    int i = 1;
    while(!Q.empty()){
        int u = Q.front(); Q.pop();
        vals[u] = c[i++];
        for(auto v : edges[u]){
            edges[v.first].erase(u);
            if (edges[v.first].size() == 1)
                Q.push(v.first);
        }
    }

    /*
    vector<idx> ids;
    FOR1(i, n) {
        idx ii;
        ii.i = i;
        ids.push_back(ii);
    }
    sort(ids.begin(), ids.end());

    FOR(i, n){
        vals[ids[i].i] = c[i+1];
    }
     */

    ll sum = 0;
    FOR1(u, n){
        int vu = vals[u];
        for(auto v : edges0[u]){
            int vv = vals[v.first];
            sum += min(vv, vu);
        }
    }
    cout << sum / 2 << '\n';
    FOR1(u, n)
        cout << vals[u] << ' ';



    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


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

int main(){
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
#define ld long double
 
using namespace std;
 
const int N = 5e5 + 123;
const ll mod = 1e9 + 7;

int dp[3011][3011];
pair<int, int> tt[3011];
pair<int, int> pr[3011][3011];
string a, b;

void rec(pair<int, int> v){
	if(min(v.X, v.Y) == 0)
		return;
	rec(pr[v.X][v.Y]);
	cout << a[v.X - 1];
}

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

	cin >> a >> b;

	//for(int i = 1;i <= (int)b.size();i++)
	//	tt[i].Y = i;

	pair<int, int> res = MP(0, 0);
	for(int i = 1;i <= (int)a.size();i++){
		for(int j = 1;j <= (int)b.size();j++){
			if(a[i - 1] == b[j - 1]){
				pair<int, int> v = tt[j - 1];
				dp[i][j] = dp[v.X][v.Y] + 1;
				pr[i][j] = v;
			}
		//	cout << dp[i][j] << " ";
		}
		//cout << "\n";
		for(int j = 1;j <= (int)b.size();j++){
			if(dp[tt[j].X][tt[j].Y] < dp[tt[j - 1].X][tt[j - 1].Y]){
				tt[j] = tt[j - 1];	
			}
			if(dp[tt[j].X][tt[j].Y] < dp[i][j]){
				tt[j] = MP(i, j);	
			}
			if(dp[res.X][res.Y] < dp[tt[j].X][tt[j].Y])
				res = MP(i, j);
			//if(i == 1)
				//cout << j << " " << tt[j].X << " " << tt[j].Y << " " << dp[tt[j].X][tt[j].Y] << " " << dp[tt[j - 1].X][tt[j - 1].Y] << "\n";
		}
	}

	//cout << res.X << " " << res.Y << "\n";
		

	rec(res);
}

Measured memory_bytes: 106496
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>


using namespace std;

int main()
{  
    string s;
    //int count=0;
        
    cin>>s;
    
    if(s.at(0)==s.at(1) && s.at(1)==s.at(2))       
        cout<<"Yes"<<endl;
    else if(s.at(1)==s.at(2) && s.at(2)==s.at(3))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
         
    return 0;
    
}

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

int main(void) {
    int a, b;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a % 2 != b % 2) {
        cout << "IMPOSSIBLE" << "\n";
    } else {
        cout << (a + b) / 2 << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i=0; i<=N/R; i++) {
    for (int j=0; j<=N/G; j++) {
      int bB = N-i*R-j*G;
      if (bB>=0&&bB%B==0) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//stringray

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

/*#ifndef __LOCAL__ 
#pragma comment(linker,"/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif*/ 

using namespace std;
using namespace __gnu_pbds;

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

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<set<int>> vsi;

#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define F first
#define S second
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)


const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

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;}
template<typename T>
istream& operator >> (istream& is,vector<T>& vec){
  for(T &x:vec)is>>x;
  //for(int i=0;i<vec.size();++i)is>>x[i];
  return is;
}

template<typename T>
ostream& operator << (ostream& os,vector<T>& vec){
  for(int i=0;i<vec.size();++i){
    os<<vec[i]<<(i+1==vec.size()?"":" ");
  }
  return os;
}

ll mpow(ll a, ll b){
  ll ret=1;
  while(b>0){
    if(b&1)ret=(ret*a)%mod;
    (a=a*a)%=mod;
    b>>=1LL;
  }
  return ret;
}

//#define int int64_t
int a[10+2][12];
void solve(){
  int n,d;cin>>n>>d;
  fori(i,n){
    fori(j,d)cin>>a[i][j];
  }
  int ans=0;
  fori(i,n){
    fori(j,n){
      if(i<j){
        int val=0;
        fori(k,d)val+=mpow(a[i][k]-a[j][k],2);
        int sq=sqrt(val);
        if(sq*sq==val)ans++;
      }
    }
  }
  cout<<ans<<endl;
  
}
int32_t  main(){
  IOS;
  solve();
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,n;
    cin>>x>>n;
    int f[105];
    for(int i=0;i<=104;i++) f[i]=-1;
    for(int i=0;i<n;i++){
        int xx;
        cin>>xx;
        f[xx] = 1;
    }
    int ans = 9999999;
    int xx;
    for(int i=0;i<=101;i++){
        if(f[i]==-1){
            if(abs(x-i)<ans){
                ans = abs(x-i);
                xx = i;
            }
        }
    }
    cout<<xx<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>

int main()
{
    char S[20];

    scanf("%s", S);

    int len = 0;
    len = strlen(S);
    int cnt = 0;

    for(int i = 0; i < len; i++) {
        if (S[i] == 'x')
        {
            cnt++;
        }
    }

    // printf("%d", cnt);


    if (cnt > 7) {
        printf("NO");
    } else {
        printf("YES");
    }

    return 0;
}

Measured memory_bytes: 128
import std.stdio, std.string, std.conv, std.math;

void main() {
	int n = stdin.readln.chomp.to!int;

	long debt = 100000;
		foreach(i;0..n) {
		debt += debt * 0.05;
		debt = (((debt / 1000.0).ceil) * 1000).to!long;
	}
	debt.writeln;
}

Measured memory_bytes: 2408
z;t[99],k,i;char s[99];f(int*x){z=*x-*1[&x];}main(n){for(;scanf("%d",&n),z=n*=2;){for(;i=z;t[--z]=*s,t[--z]=i)for(scanf(" %[^\n]",s),k=n;k-=2;)i+=s[k]&2?30:s[k]&1?0:999;for(qsort(t,n/2,8,f);n;puts(t-~n))n-=2;}}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
//use ll or int for gcd
Val gcd(Val a, Val b) {

    if (b==0) return a;
    else return gcd(b, a%b);
}
//count vector and return pair (count,vector item)
template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->emplace_back(count,A->at(i));
        count = 1;
      }
    }else{
      R->emplace_back(count,A->at(i));
      count = 1;
    }
  }
}



//---------------------------------------------------------------

int main(){
  int N;
  cin>>N;
  vector<ll> T(N);
  vector<ll> Time(N);
  ll g;
  ll ans=1;
  ll tt;
  rep(i,N){
    cin>>T.at(i);
    if(i>0){
      g = gcd(T.at(i),tt);
      tt = tt/g;
      tt*=T.at(i);
    }else{
      tt=T.at(i);
    }
  }

  cout<<tt<<endl;

}


Measured memory_bytes: 256
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18

void solve(){
	ll x; cin>>x;
	for(ll i=-5000;i<=5000;i++){
		for(ll j=-5000;j<=5000;j++){
			ll tmp = i*i*i*i*i - j*j*j*j*j;
			if(tmp == x){
				cout<<i<<" "<<j<<endl;
				return;
			}
		}
	}
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

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


Measured memory_bytes: 1984
N = int(input())
X = [0]*N
Y = [0]*N
for TN in range(0,N):
    A,B = (int(T) for T in input().split())
    X[TN] = A-B
    Y[TN] = A+B
print(max(max(X)-min(X),max(Y)-min(Y)))

Measured memory_bytes: 24680
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int k;
	 cin>>k;
	 if(k%2==0 || k%5==0)
	 {
		cout<<-1<<'\n';
		return 0;
	 }
	 int mod = 7%k;
	 int ans = 1;
	 int p = 7%k;
	 while(mod!=0)
	 {
		 p=(p*10)%k;
		 mod = (mod%k+p)%k;
		 ++ans;
		 if(ans>1e6)
         {
           ans=-1;
           break;
         }
	 }
	 cout<<ans<<'\n';
	 return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,x;
  cin>>a>>b>>x;
  if(x>=a&&x<=a+b)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        sc.close();
        if(N==K)
            System.out.println(1);
        else{
            if((N-1)%(K-1) == 0)
                System.out.println((N-1)/(K-1));
            else
                System.out.println((N-1)/(K-1) + 1);
        }
    }
}

Measured memory_bytes: 50144
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

int par[200];
int ran[200];

void init(int n){
	rep(i, n){
		par[i] = i;
		ran[i] = 0;
	}
}

int find(int x){
	if(x == par[x]){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

bool same(int x, int y){
	if(find(x) == find(y)) return true;
	else return false;
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(ran[x] > ran[y]){
		par[y] = x;
	}else{
		par[x] = y;
		if(ran[x] == ran[y]) ran[y]++;
	}
}
PP bridge[10000];

int main(){
	int n, m, a, b, c;
	int res;
	while(cin >> n >> m && (n ||m)){
		res = 0;
		init(n);
		rep(i, m){
			cin >> bridge[i].second.first >> bridge[i].second.second >> bridge[i].first;
		}
		sort(bridge, bridge + m);
		int pos = 0;
		while(n > 1){
			PP pp = bridge[pos++];
			a = pp.second.first;
			b = pp.second.second;
			c = pp.first;
			if(!same(a, b)){
				unite(a, b);
				n--;
				res += c;
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define bn "\n"

const ll N=1e7+5;
std::vector <ll> prime;
ll sol[N];

void save ( )
{
//	std::fill (sol, sol + n, false);
	for (ll i = 2; i < N; ++i)
	{
	//	if (sol[i]==0) prime.push_back (i);
		for (ll j = 2; i * j < N; ++j)
			sol[i * j]++;
	}
	for(ll i=1;i<N;i++)
	{
	    sol[i]++;
	    sol[i]++;
	    sol[i]=sol[i-1]+(sol[i]*i);
	}
	
}


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	save();
	ll n;
	cin>>n;
	cout<<(sol[n]-1)<<bn;
	
	return 0;
}

Measured memory_bytes: 81776
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i=1;i<=9;i++){
        if(n%i==0){
            if(n/i<10){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()

int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;
    int n;
    cin>>n;
    int ar[n+1],c=0;
    for(int i=1;i<=n;i++){
        cin>>ar[i];
        if(i%2==1&&ar[i]%2==1){
            c++;
        }
    }
    cout<<c;


    return 0;
}


Measured memory_bytes: 3584
import sys

h,w = map(int,input().split())
field = [list(input()) for i in range(h)]

field.insert(0,list('.'*w))
field.append(list('.'*w))
for i in range(h+2):
    field[i].insert(0,'.')
    field[i].append('.')

for i in range(1,h+1):
    for j in range(1,w+1):
        c = 0
        if field[i][j] == '#':
            for x,y in [[0,1], [1,0], [0,-1],[-1,0]]:
                if field[i+x][j+y] == '#':
                    c += 1
            
            if c == 0:
                print('No')
                sys.exit()
    
print('Yes')

Measured memory_bytes: 39792
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL a[202020], f[202020];
LL k;

bool cond(LL mid){
    LL num = 0;
    REP(i, n){
        if(a[i] * f[i] <= mid)continue;
        num += ((a[i] * f[i] - mid)/f[i]) + ((a[i] * f[i] - mid)%f[i] != 0);
    }
    //cout << mid << " " << num << " " << k << endl;
    return num <= k;
}

int main(){
    cin >> n >> k;
    REP(i, n)cin >> a[i];
    sort(a, a + n);
    REP(i, n)cin >> f[i];
    sort(f, f + n);
    reverse(f, f + n);
    LL l = -1, r = HINF<LL>();
    while(r - l > 1){
        LL mid = (l + r)/2;
        //cout << mid << endl;
        if(cond(mid))r = mid;
        else l = mid;
    }
    cout << r << endl;
}

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

int main(){

    int r, c;
    cin >> r >> c;

    vector<vector<int>> table(r+1, vector<int>(c+1));
    for(int i = 0; i < r; ++i){
        for(int j = 0; j < c; ++j){
            cin >> table[i][j];
        }
    }

    for(int i = 0; i < r; ++i){
        int horizontal = 0;
        for(int j = 0; j < c; ++j){
            horizontal += table[i][j];
        }
        table[i][c] = horizontal;
    }
    
    for(int i = 0; i <= c; ++i){
        int vertical = 0;
        for(int j = 0; j < r; ++j){
            vertical += table[j][i];
        }
        table[r][i] = vertical;
    }

    for(int i = 0; i <= r; ++i){
        for(int j = 0; j <= c; ++j){
            cout << table[i][j];
            if(j == c){
                cout << endl;
            }
            else{
                cout << ' ';
            }
        }
    }

    return 0;
}


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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<std::vector<long long>> D){
  ll dc = 0;
  ll mdc = 0;
  for (ll i = 0; i < N; ++i) {
    if (D[i][0] == D[i][1]) {
      dc++;
    } else {
      dc = 0;
    }
    mdc = max(mdc, dc);
  }
  cout << (mdc >= 3 ? YES : NO) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long N;
  std::cin >> N;
  std::vector<std::vector<long long>> D(N, std::vector<long long>(2));
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < 2 ; j++){
      std::cin >> D[i][j];
    }
  }
  solve(N, std::move(D));
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <map>
#include <utility>
using namespace std;
#define int long long
#define DEBUG(x) cerr << #x << " = " << x << endl
int MOD = 998244353;
int power(int x, int y) {
  int res = 1;
  for(; y > 0; y >>= 1, (x *= x) %= MOD) {
    if(y & 1) (res *= x) %= MOD;
  }
  return res;
}
int extgcd(int a, int b, int &x, int &y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}
int mod_inv(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}
int fact[200001];
void prepare(const int N) {
  fact[0] = 1;
  for(int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= MOD;
  }
}
int comb(const int n, const int k) {
  int r = fact[n];
  r *= mod_inv(fact[n - k], MOD);
  r %= MOD;
  r *= mod_inv(fact[k], MOD);
  r %= MOD;
  return r;
}
signed main() {
  int N, M, K; cin >> N >> M >> K;
  int ans = 0;
  prepare(N);
  for (int k = 0; k <= K; k++) {
    int r = M * comb(N - 1, k);
    r %= MOD;
    r *= power(M - 1, N - 1 - k);
    r %= MOD;
    ans += r;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4756
pi = 3.1415926

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n,m,x = invr()
nums = []
ans = [10**8]

for i in range(n):
    nums.append(inlt())
    
def cal(ins):
    aaa = [0 for i in range(m)]
    cost = 0
    for i in ins:
        cost += nums[i][0]
        
        for index,j in enumerate(nums[i][1:]):
            aaa[index] += j

    for i in range(m):
        if aaa[i] < x:
            return 10**8
    else:
        return cost
    
def printCombination(arr, n, r): 
      
    # A temporary array to  
    # store all combination 
    # one by one 
    data = [0]*r; 
  
    # Print all combination  
    # using temprary array 'data[]' 
    combinationUtil(arr, data, 0,  
                    n - 1, 0, r); 
  
# arr[] ---> Input Array 
# data[] ---> Temporary array to 
#         store current combination 
# start & end ---> Staring and Ending 
#             indexes in arr[] 
# index ---> Current index in data[] 
# r ---> Size of a combination  
# to be printed  
def combinationUtil(arr, data, start,  
                    end, index, r): 
                          
    # Current combination is ready  
    # to be printed, print it 
    if (index == r):
        ins = []
        for j in range(r): 
            ins.append(data[j])

        result = cal(ins)
        if result < ans[0]:
            ans[0] = result 
        return; 
  
    # replace index with all 
    # possible elements. The 
    # condition "end-i+1 >=  
    # r-index" makes sure that  
    # including one element at 
    # index will make a combination  
    # with remaining elements at  
    # remaining positions 
    i = start;  
    while(i <= end and end - i + 1 >= r - index): 
        data[index] = arr[i]; 
        combinationUtil(arr, data, i + 1,  
                        end, index + 1, r); 
        i += 1; 
    
arr = [i for i in range(n)]
for i in range(1,n + 1):
    printCombination(arr,n,i)

print(ans[0] if ans[0] < 10**8 else -1)
    


Measured memory_bytes: 69980
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

template<typename T>
void input(T &x) {
	x=0; T a=1;
	register char c=getchar();
	for(;c<48||c>57;c=getchar())
		if(c==45) a=-1;
	for(;c>=48&&c<=57;c=getchar())
		x=x*10+c-48;
	x*=a;
	return;
}

#define MAXN 200010

struct Ball {
	
	int x,y;

	void Input() {
		input(x),input(y);
		if(x>y) swap(x,y);
		return;
	}

	bool operator < (const Ball &q) const {
		if(x!=q.x) return x<q.x;
		return y<q.y;
	}

};

Ball a[MAXN];

int main() {
	int n;
	input(n);
	if(n==1) {
		puts("0");
//		fclose(stdin),fclose(stdout);
		return 0;
    }
	for(int i=1;i<=n;i++) a[i].Input();
	sort(a+1,a+n+1);
	int Max=a[1].y,Min=a[1].x,_max=1,_min=1;
	for(int i=2;i<=n;i++) {
		if(a[i].x<=Min&&a[i].y>=Max){
			Min=a[i].x;Max=a[i].y;
			_max=i;_min=i;
		} else if(a[i].x<Min) {
			Min=a[i].x;
			_min=i;
		} else if(a[i].y>Max){
			Max=a[i].y;
			_max=i;
		}
	}
	int Rmax=Max,Bmin=Min,Rmin=a[_min].y,Bmax=a[_max].x;
	for(int i=1;i<=n;i++){
		Rmin=min(Rmin,a[i].y);
		Bmax=max(Bmax,a[i].x);
	}
	ll ans=(ll)(Rmax-Rmin)*(Bmax-Bmin);
	if(_max!=_min) {
		Bmax=Max;
		Bmin=Min;
		Rmax=max(a[n].x,a[1].y);
		int premin=a[1].y;
		Rmin=min(a[1].y,a[2].x);
		ll ans0=Rmax-Rmin;
		for(int i=2;i<n;i++) {
			Rmax=max(a[i].y,Rmax);
			Rmin=min(min(premin,a[i].y),a[i+1].x);
			premin=min(premin,a[i].y);
			if(Rmax-Rmin<ans0)ans0=Rmax-Rmin;
		}
		ans0*=Bmax-Bmin;
		ans=min(ans,ans0);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh


#else

ll dp[111][111];

ll a, b;
ll f(ll x) {
    return floor(a * x / b) - floor(x / b) * a;
}

void solve() {

    ll n;
    cin >> a >> b >> n;
    ll l = 1;
    ll r = n;

    while (r - l > 2) {
        ll m_l = (2 * l + r) / 3;
        ll m_r = (l + 2 * r) / 3;
        if (f(m_l) > f(m_r)) {
            r = m_r;
        } else {
            l = m_l;
        }
    }

    ll f_min = 0;
    for (ll i = l; i <= r; ++i)
        f_min = max(f_min, f(i));

    cout << f_min;
}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++) << ": ";
        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

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

using namespace std;

bool bit(long long mask, int i) {return (mask>>i)&1;}
int main() {
	long long A, B; cin >> A >> B;
	if (A == B) return cout << "1\n", 0;
	int X = 60;
	while (bit(A, X) == bit(B, X)) X--;
	long long dw = A, up = B;
	while (up - dw > 1) {
		long long md = (up+dw)>>1;
		if (bit(md, X)) up = md;
		else dw = md;
	}
	for (int i = X - 1; i >= 0; i--) if (bit(B, i)) B |= (1ll<<(i+1)) - 1;	
	cout << min(B - A + 1, (1ll<<X)) + up - A << "\n";

	return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

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


Measured memory_bytes: 23764
let comparison list =
  match list with
  | first :: second :: third :: [] -> first < second && second < third
  | _ -> false;;

let mystring_of_bool flag =
  match flag with
  | true -> "Yes"
  | false -> "No";;

read_line()
|> Str.split (Str.regexp " ")
|> comparison
|> mystring_of_bool
|> print_endline



Measured memory_bytes: 2096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;


void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

LL dp[100005];

int main(){
	int n,w;
	int i,j,k;
	LL a,b,c;
	for(i=1;i<=100000;i++)dp[i]=INF;
	cin>>n>>w;
	for(i=0;i<n;i++){
		cin>>a>>b;
		for(j=1e5;j>=b;j--){
			if(dp[j-b]==INF)continue;
			dp[j]=min(dp[j],dp[j-b]+a);
		}
	}
	for(i=1e5;i>=0;i--){
		if(dp[i]<=w)break;
	}
	cout<<i<<endl;
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  for(int i = 0; i < 1010; ++i){
    double A = floor((double)i * 0.08);
    double B = floor((double)i * 0.1);
    if((int)A == a && (int)B == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,i,ans = 100000000000000;
	cin >> n;
	for (i = 1; (i * i) <= n; i++) {
		if (n % i == 0) ans = min(((n / i) - 1) + i - 1,ans);
	}
	cout << ans << endl;

}


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

namespace ABC050_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            if(s[1] == "+")
            {
                Console.WriteLine(int.Parse(s[0]) + int.Parse(s[2]));
            }
            else
            {
                Console.WriteLine(int.Parse(s[0]) - int.Parse(s[2]));
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;

void Onigiri()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ok=1;
  while(a!=0&&c!=0)
  {
    if(ok)
    {
      ok^=1;
      c-=b;
      if(c<=0){cout<<"Yes";return;}
    }
    else {
      
      ok^=1;
      a-=d;
      if(a<=0){cout<<"No";return;}
    }
  }
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("in", "r", stdin);freopen("out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999

int a, b, c;

int main() {
	cin >> a >> b >> c;
	cout << max(0, c - (a - b)) << endl;
	return 0;
}


Measured memory_bytes: 764
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

# X,Y に辺を貼る -> 連結成分ごとに1回

N,M = map(int,readline().split())
m = map(int,read().split())
XYZ = list(zip(m,m,m))

X,Y,Z = zip(*XYZ)

graph = csr_matrix(([1]*M,(X,Y)),(N+1,N+1))
Ncomp,_ = connected_components(graph,connection='weak')

answer = Ncomp - 1
print(answer)

Measured memory_bytes: 43892
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        s=0;
        Rep(i,n)
        {
            Rep(j,n)
            {
                Rep(k,n)
                {
                    x=gcd(i,j);
                    x=gcd(x,k);
                    s+=x;
                }
            }
        }
        cout<<s<<en;
    }
}



Measured memory_bytes: 3576
N = int(input())
t = [list(map(int, input().split())) for _ in range(N)]
t.insert(0, [0, 0, 0])
x = [t[i][1] for i in range(N+1)]
y = [t[i][2] for i in range(N+1)]
t = [t[i][0] for i in range(N+1)]
for i in range(1, N+1):
    if abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) > t[i] - t[i-1] or (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])) %2 != (t[i] - t[i-1]) % 2:
        print('No')
        exit()
print('Yes')


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

int main() {
  int n, x;
  int count = 0;
  while (1) {
    cin >> n >> x;
    count = 0;
    if (n ==0 && x ==0) {
      break;
    }
    for (int i = 1; i <= n - 2; i++) {
      for (int j = i + 1; j <= n - 1; j++) {
        for (int k = j + 1; k <= n; k++) {
          if ((i + j + k) == x) {
            count++;
          }
        }
      }
     }
    cout << count << endl;
  }
  return 0;
}

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

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

	if(n/100==1){
		n+=800;
	}else{
		n-=800;
	}
	if(n/10%10==1){
		n+=80;
	}else{
		n-=80;
	}
	if(n%100%10==1){
		n+=8;
	}else{
		n-=8;
	}


	cout<<n<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 1000000000001
using namespace std;


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

  ll n;
  cin>>n;
  ll a[n+1];
  for(ll i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  ll dp[n+1];
  dp[1]=0;
  dp[2]=abs(a[2]-a[1]);
  for(ll i=3;i<=n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n];


}


Measured memory_bytes: 1792