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

int main() {
    ll n, minv = 1000000000001;
    cin >> n;
    for (ll i = 1; i*i <= n; i++)
    {
        if (n % i == 0)
        {
            minv = min(i + (n / i) - 2, minv);
        }
    }
    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------

map<int, int> res;
void prime_factors(int n) {
  for(int i = 2; i*i <= n; ++i) {
    while(n % i == 0) {
      res[i]++; // 素数i^{res[i]}
      n /= i;
    }
  }
  if(n!=1) res[n]++;
}

ll dp[100010][40];

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;

    prime_factors(M);

    ll ans=1;
    ll iter=res.size();
    for(auto i : res) {
        ll x=i.second;
        rep(j,100005){
            rep(k,40){
                dp[j][k]=0;
            }
        }
        dp[0][0]=1;
        rep(j,N){ // j番目
            rep(k,x+1){ // k個すでに使っている
                rep(l,x-k+1){ // l個使う
                    dp[j+1][k+l]+=dp[j][k];
                    dp[j+1][k+l]%=MOD;
                }
            }
        }
        ans*=dp[N][x];
        ans%=MOD;
    }
    cout<< ans<<"\n";

}   
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 31616
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000000

int main(){

	lli n,ma,mb;
	cin>>n>>ma>>mb;

	vector<lli> a(n),b(n),c(n);
	REP(i,n)cin>>a[i]>>b[i]>>c[i];

	lli dp[500][500];
	REP(i,500)REP(j,500)dp[i][j]=INF;

	dp[0][0]=0;

	REP(now,n)for(lli i=499;i>=0;i--)for(lli j=499;j>=0;j--){
		lli nowA = a[now];
		lli nowB = b[now];
		lli nowC = c[now];
		if(dp[i][j] != INF){
			dp[i+nowA][j+nowB] = min(dp[i+nowA][j+nowB],dp[i][j]+nowC);
		}
	}

	lli ans = INF;

	/* 1:2だったら*/
	/* (i,j)=(1,2)(2,4)(3,6) */

	REP(i,500)REP(j,500){
		if(i==0&&j==0)continue;
		if(i%ma == 0 && (ma*j)==(i*mb)){
			if(DEBUG)cout<<"i="<<i<<" j="<<j<<" dp[i][j]="<<dp[i][j]<<endl;
			ans = min(ans,dp[i][j]);
		}
	}

	if(ans==INF)cout<<-1<<endl;
	else cout<<ans<<endl;

	return 0;
}
 

Measured memory_bytes: 2176
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 1e6 + 100, T = 4, OO = 1e9 + 100, M = 1e9 + 7, P = 6151, SQ = 50, lg = 21;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
	use_fast;
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	n -= k;
	if(n <= 0)
		return cout << 0, 0;
	int sum = 0;
	for(int i = 0; i < n; i++)
		sum += a[i];
	cout << sum << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main(){
    cout<<fixed<<setprecision(10);
    string s,t;
    cin>>s>>t;
    cout<<t+s;
    return 0;
}


Measured memory_bytes: 256
def solve():
  ans = 0
  N, A = map(int, input().split())
  X = list(map(int, input().split()))
  x = sum(X)
  dp = [[[0]*2550 for _ in range(N+1)] for _ in range(N+1)]
  dp[0][0][0] = 1
  for i in range(N):
    for j in range(i+1):
      for k in range(x):
        dp[i+1][j][k] += dp[i][j][k]
        dp[i+1][j+1][k+X[i]] += dp[i][j][k]
  for j in range(1,N+1):
    ans += dp[-1][j][j*A]
  return ans
print(solve())

Measured memory_bytes: 117812
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int s = in.nextInt();

            boolean[] used = new boolean[1 << 20];

            int a = s;
            int n = 1;
            used[a] = true;

            for (;;) {
                a = f(a);
                n++;
                if (used[a]) {
                    System.out.println(n);
                    return;
                }
                used[a] = true;
            }
        }
    }

    private static int f(int n) {
        return n % 2 == 0 ? (n / 2) : (3 * n + 1);
    }
}


Measured memory_bytes: 25300
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, A, B = sc.nextLong()
  val count = A match {
    case B => 1
    case _ if B - A < 0 || (N == 1 && 0 < B - A) => 0
    case _ =>
      val min = A * (N - 1) + B
      val max = A + B * (N - 1)
     max - min + 1
  }
  println(count)
}


Measured memory_bytes: 55228
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int x, y;
int ans;

signed main() {
	cin >> x >> y;
	if (x == 3)ans = 100000;
	if (x == 2)ans = 200000;
	if (x == 1)ans = 300000;
	if (y == 3)ans += 100000;
	if (y == 2)ans += 200000;
	if (y == 1)ans += 300000;
	if (x == 1 && y == 1)ans += 400000;
	cout << ans << endl;
}

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

using namespace std;

int n;

int a[30], dp[30], ans = 1, pref[30];

int main () {
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
        pref[i] = max (pref[i - 1], a[i]);
    }
    for (int i = 2;i <= n;i ++) {
        if (pref[i - 1] <= a[i]) ans ++;
    }cout << ans;
}


Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

w_cnt=Array.new(300000)
N,d=gets.chomp.split(' ').map{|n| n.to_i}
S=gets.chomp.split('')
N=S.size
w_cnt=Array.new(N)
e_cnt=Array.new(N)
S[0] == "W" ? w_cnt[0] = 1 : w_cnt[0]=0
S[0] == "E" ? e_cnt[0] = 1 : e_cnt[0]=0
1.upto(N-1){|i|
	w_cnt[i] = w_cnt[i-1] + (S[i] == "W" ? 1 : 0)
	e_cnt[i] = e_cnt[i-1] + (S[i] == "E" ? 1 : 0)
}
dpp w_cnt
dpp e_cnt
dst = 0
min=(e_cnt[N-1]-e_cnt[0])
dputs min
1.upto(N-2){|i|
	tmp = (w_cnt[i-1]) + (e_cnt[N-1]-e_cnt[i])
	dputs tmp
	if(min > tmp)
		min = tmp
		dst = i
	end
}
if(min > tmp = (w_cnt[N-2]))
	dputs tmp
	min = tmp
	dst = N
end
puts min


Measured memory_bytes: 36984
#include <stdio.h>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

map<int, int> a[100001];
int n, m;

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a[x%m][x / m]++;
	}
	int res = 0;
	for (int i = 0; i <= m - i; i++) {
		if (i == 0 || i == m - i) {
			int sum = 0;
			for (map<int, int>::iterator it = a[i].begin(); it != a[i].end(); it++)
				sum += it->second;
			res += sum / 2;
		}
		else {
			int odd1 = 0, odd2 = 0, sum1 = 0, sum2 = 0;
			for (map<int, int>::iterator it = a[i].begin(); it != a[i].end(); it++) {
				odd1 += it->second % 2;
				sum1 += it->second - it->second % 2;
			}
			for (map<int, int>::iterator it = a[m - i].begin(); it != a[m - i].end(); it++) {
				odd2 += it->second % 2;
				sum2 += it->second - it->second % 2;
			}
			if (odd1 > odd2) {
				swap(odd1, odd2);
				swap(sum1, sum2);
			}
			res += odd1;
			odd2 -= odd1;
			odd2 -= odd2 % 2;
			if (sum1 >= odd2) res += odd2 + (sum1 - odd2) / 2 + sum2 / 2;
			else res += sum1 + sum2 / 2;
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

int main(){
  int n, flag, counter, a[100];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  flag = 1;
  counter = 0;

  while(flag){
    flag = 0;
    for (int i = n - 1; i > 0; i--){
      if(a[i-1] > a[i]){
        swap(a[i-1], a[i]);
        counter++;
        flag = 1;
      }
    }
  }

  cout << a[0];
  for(int i = 1; i < n; i++){
    cout << " " << a[i];
  }

  cout << endl << counter << endl;

  return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<vector<int>> v(n);
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    set<int> s, t;
    for (int i = 0; i < n; i++) {
        if (v[i].size() > 1) s.emplace(i), t.emplace(i);
    }
    bool ok = true;
    vector<int> st;
    auto f = [&](auto f, int curr, int prev) -> int {
        s.erase(curr);
        for (auto &to: v[curr]) {
            if (to == prev) continue;
            if (s.count(to)) {
                if (prev == -1) f(f, to, curr), prev = curr;
                else return f(f, to, curr);
            }
        }
        st.emplace_back(curr);
        return curr;
    };
    auto x = f(f, *s.begin(), -1);
    if (!s.empty()) {
        cout << -1 << "\n";
        return 0;
    }
    auto calc = [&](int st) {
        int c = n;
        vector<int> p(n+1, -1); set<int> used;
        auto g = [&](auto g, int curr, int prev) -> void {
            int nx = -1;
            for (auto &to: v[curr]) {
                if (to == prev) continue;
                if (!t.count(to)) continue;
                assert(nx == -1);
                nx = to;
            }
            int x = v[curr].size() - 1;
            if (prev != -1) x--;
            c -= x;
            for (int i = 1; i <= x + (prev != -1); i++) {
                p[c+i] = c;
            }
            if (nx != 1) used.emplace(c);
            c--;
            if (nx != -1) g(g, nx, curr);
        };
        g(g, st, -1);
        vector<int> ans; int mini = n+1;
        for (int i = n; i > 0; i--) {
            if (p[i] == -1 && !used.count(i)) ans.emplace_back(i);
            else {
                if (p[i] < mini) {
                    if (!used.count(i)) ans.emplace_back(i);
                    if (p[i] == -1) continue;
                    ans.emplace_back(p[i]);
                    used.emplace(p[i]);
                    mini = p[i];
                } else if (p[i] == mini) {
                    if (!used.count(i)) ans.emplace_back(i);
                }
            }
        }
        assert(ans.size() == n);
        reverse(ans.begin(), ans.end());
        return ans;
    };

    assert(st.size() <= 2);
    auto ax = calc(st[0]);
    if (st.size() == 2) {
        auto bx = calc(st[1]);
        for (int i = 0; i < n; i++) {
            if (ax[i] != bx[i]) {
                if (ax[i] > bx[i]) swap(ax, bx);
                break;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << ax[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define All(x) (x).begin(), (x).end()
#define lowbit(x) ((x) & -(x))
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const ll mod = 1e9 + 7;
const int N = 4e6 + 10;
const db pi = acos(-1);
vi v;
int main()
{
	int Q = read();
	while(Q --)
	{
		int op = read();
		if(op == 0) v.pb(read());
		if(op == 1) cout << v[read()] << endl;
		if(op == 2) v.pop_back();
	}
	return 0;
}



Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
int main(){
    long double n; cin >> n;
    long long sum = 0;
    for(long double i = 1 ; i <= n ; i ++){
        sum += (i / 2) * floor(n / i) * floor(1 + n / i);
    }
    cout << sum << '\n';
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    while(cin >> S,S!="."){
        cin >> T;
        string U="",V="";
        vector<string> s,t;
        int ok=0;
        for (int i=0;i<S.size();++i){
            if (S[i]=='\"'){
                ok^=1;
                if (ok) s.emplace_back("");
            }
            (ok?s.back():U)+=S[i];
        }
        ok=0;
        for (int i=0;i<T.size();++i){
            if (T[i]=='\"'){
                ok^=1;
                if (ok) t.emplace_back("");
            }
            (ok?t.back():V)+=T[i];
        }
        if (U!=V||s.size()!=t.size()){
            cout << "DIFFERENT" << '\n';
            continue;
        }
        int cnt=0;
        for (int i=0;i<s.size();++i)
            if (s[i]!=t[i]) ++cnt;
        cout << (!cnt?"IDENTICAL":(cnt==1?"CLOSE":"DIFFERENT")) << '\n';
    }
}


Measured memory_bytes: 3224
import java.util.*

fun gcd(x: Int, y: Int): Int {
    if (x < y) {
        return gcd(y, x)
    }
    if (y == 0) {
        return x
    }
    return gcd(y, x % y)
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val x = scanner.nextInt()
    val y = scanner.nextInt()

    println(gcd(x, y))
}



Measured memory_bytes: 25548
#coding:UTF-8

def is_prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True


mx = 10 ** 5
p = [0 for _ in range(mx + 1)]
for i in range(3, mx + 1):
    if i == 2017 or (is_prime(i) and is_prime((i + 1) // 2)):
        p[i] = 1
d = [0 for i in range(mx + 1)]
for i in range(3, mx + 1):
    d[i] += p[i] + d[i - 1]

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(d[r] - d[l - 1])

Measured memory_bytes: 7192
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int cnt=0;
	int i,j;
	string w;
	cin>>w;
	while(1){
		string s;
		cin>>s;
		if(s=="END_OF_TEXT")	break;
		for(i=0;i<s.size();i++){
			if('A'<=s[i]&&s[i]<='Z'){
				s[i]=s[i]+('a'-'A');
			}
		}
		if(w==s) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};


void slove(int n){
	vpint num(n);//num[??????]
	num[0].fi = 0; num[0].se = 0;//fi???x??§?¨? sey??§?¨?
	reps(i, 1, n){//?\\??°???????????????i
		int s, t;//s?????£??\????????¨?????????t???????????????????????????
		scanf("%d %d", &s, &t);
		if (t == 0){//????????????
			num[i].fi = num[s].fi - 1;
			num[i].se = num[s].se;
		}else if(t == 1){//????????????
			num[i].fi = num[s].fi;
			num[i].se = num[s].se - 1;
		}else if(t == 2){//????????????
			num[i].fi = num[s].fi + 1;
			num[i].se = num[s].se;
		}else if(t == 3){//????????????
			num[i].fi = num[s].fi;
			num[i].se = num[s].se + 1;
		}
	}
	int mx_x = 0, mi_x = 0, mx_y = 0, mi_y = 0;
	reps(i, 1, n){
		mx_x = max(num[i].fi, mx_x);//x??????????????§????????¢???
		mi_x = min(num[i].fi, mi_x);//x?????????????°?????????¢???
		mx_y = max(num[i].se, mx_y);
		mi_y = min(num[i].se, mi_y);
	}
	/*
	rep(i, n) printf("%d : %d %d\n", i, num[i].fi, num[i].se);
	printf("????????????%d %d %d %d\n", mx_x, mi_x, mx_y, mi_y);
	*/
	printf("%d %d\n", mx_x - mi_x + 1, mx_y - mi_y + 1);
	return;
}

int main(void){
	int n;
	rep(i, 1000){
		cin >> n;
		if (n == 0) break;
		slove(n);
	}
	return 0;
}

Measured memory_bytes: 3224
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C = map(int, input().split())
    if A == B:
        print(C)
    elif A == C:
        print(B)
    elif B == C:
        print(A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<<X<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
struct P2{int x,y;};
//struct edge{int from,cost,to;};

const int MOD7=1000000007;
const int INF=100000000;
int mode=0;

int main(){
	string s;
	int count=0;
	char a='a',b;
	cin>>s;
	for(int i=0;i<26;i++){
		for(int j=0;j<s.size();j++){
			if(s[j]==a){
				count=1;
			}
		}
		if(count==0){
			cout<<a<<endl;
			return 0;
		}
		count=0;
		DEB(a);
		a++;
	}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

// BEGIN CUT HERE
template<class Z> Z gcd(Z a, Z b) {
  while (b) swap(a %= b, b);
  return a;
}
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  int res = 1;
  while (n--) {
    int a; cin >> a;
    res = res * a / gcd(res, a);
  }
  cout << res << '\n';
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int ans = H * W - (W * h + H * w - h * w);
    cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		int turn = 0;
		char target = 'a';

		while(true){
			if(param.get(turn).length() == 0) break;
			target = param.get(turn).charAt(0);
			param.set(turn,param.get(turn).substring(1));
			
			if(target == 'a'){
				turn = 0;
			}else if(target == 'b'){
				turn = 1;
			}else if(target == 'c'){
				turn = 2;
			}
		}
		System.out.println(Character.toUpperCase(target));
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    cin >> a;
    vector<vector<pl>> dp(N + 1, vector<pl>(N + 1, {0, INFLL}));
    // first = sum, second = cost;
    function<pl(int, int)> dfs = [&](int left, int right) {
        if (right - left == 1) return make_pair(a[left], 0LL);
        if (dp[left][right].second != INFLL) return dp[left][right];

        for (int i = left + 1; i < right; i++) {
            pl left_min = dfs(left, i);
            pl right_min = dfs(i, right);
            ll sum = left_min.first + right_min.first;
            ll cost = left_min.second + right_min.second + sum;
            if (cost < dp[left][right].second) {
                dp[left][right] = make_pair(sum, cost);
            }
        }
        return dp[left][right];
    };

    cout << dfs(0, N).second << endl;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll t[1005], a[1005];

int main() {
    cin >> n;
    rep(i, n) cin >> t[i] >> a[i];

    ll x = 1, y = 1;
    rep(i, n) {
        ll nx = (x + t[i] - 1) / t[i];
        ll ny = (y + a[i] - 1) / a[i];
        ll p = max(nx, ny);
        x = p * t[i];
        y = p * a[i];
    }
    cout << x + y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
ll n,k;
bool ok(ll c,vector<ll> a,vector<ll> f){
    ll sum=0;
    for(int i=0;i<a.size();i++){
        sum+=max(0ll,a[i]-c/f[i]);
    }
    return sum<=k;
}
int main(){
    cin >> n >> k;
    vector<ll> a(n),f(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> f[i];
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll l=-1,r=1000000000000;
    while(l+1<r){
        ll c=(l+r)/2;
        if(ok(c,a,f)) r=c;
        else l=c;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 6552
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  double a[100];
  double sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum=sum+(1/a[i]);
  }
  sum = (1/sum);
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>

void test_case()
{
    int N=100010;
    vector<int> primes={2};
    bool vis[N]={};

    for(int i=3; i*i<=N; i+=2) {
        if(!vis[i]) {
            for(int j=i*i; j<=N; j+=2*i) {
                vis[j]=1;
            }
        }
    }

    for(int i=3; i<=N; i+=2) {
        if(!vis[i])
            primes.pb(i);
    }
    int x;
    cin>>x;
    cout<<*lower_bound(primes.begin(), primes.end(), x);


}


int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 3868
import sys

readline = sys.stdin.readline
MOD = 998244353
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())

    mat = []
    for _ in range(K):
        l, r = map(int, readline().split())
        mat.append((l, r))

    dp = [0] * (2 * N + 5)
    acc = [0] * (2 * N + 5)
    cur = 0
    acc[1] = 1
    acc[2] = -1

    for i in range(1, N + 1):
        cur += acc[i]
        cur %= MOD
        dp[i] = cur
        dp[i] %= MOD
        for l, r in mat:
            acc[i + l] += dp[i]
            acc[i + l] %= MOD
            acc[i + r + 1] -= dp[i]
            acc[i + r + 1] %= MOD

    print(dp[N] % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74364
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	cout << a[n-1]-(a[0]+a[n-1])/2 << endl;
}



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

using namespace std;

using ll = long long;
constexpr ll N = 2e5;
//ll a[N];





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

	map<int, bool> c;

	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (c.count(a)) {
			cout << "NO";
			return 0;
		}
		c[a] = true;
	}

	cout << "YES";
		
	
	
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    vector<vector<long long int>> dp(n+1, vector<long long int>(3,0));
    for(int i=0;i<n;i++){
        long long int a,b,c;
        cin>>a>>b>>c;
        dp[i+1][0] = a + max(dp[i][1], dp[i][2]);
        dp[i+1][1] = b + max(dp[i][0], dp[i][2]);
        dp[i+1][2] = c + max(dp[i][1], dp[i][0]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
    return 0;
}

Measured memory_bytes: 5760
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    if S == T[:-1]:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD=1e9+7;
ll fact[200001];
ll ifact[200001];

ll mult(ll a, ll b)
{
	return (a*b)%MOD;
}

ll modpow(ll a, ll b)
{
	ll r=1;
	while(b)
	{
		if(b&1) r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}

ll inv(ll a)
{
	return modpow(a,MOD-2);
}

map<int,int> dsu[200001];
int par[200001];

int rt(int u)
{
	if(par[u]<0) return u;
	return (par[u]=rt(par[u]));
}

void merge(int u, int v)
{
	u=rt(u);v=rt(v);
	if(u==v) return ;
	if(dsu[u].size()<dsu[v].size()) swap(u,v);
	for(mit it = dsu[v].begin();it!=dsu[v].end();it++)
	{
		dsu[u][it->fi]+=it->se;
	}
	par[v]=u;
	//par[u]=-1;
}

ll solve(int x)
{
	if(x!=rt(x)) return 1;
	ll tot = 0;
	ll ans = 1;
	for(mit it = dsu[x].begin();it!=dsu[x].end();it++)
	{
		//cerr<<it->fi<<' '<<it->se<<'\n';
		tot+=it->se;
		ans=(ans*ifact[it->se])%MOD;
	}
	ans=mult(ans,fact[tot]);
	return ans;
}

vector<ii> adj[200001];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	fact[0]=1;ifact[0]=1;
	for(int i=1;i<=200000;i++)
	{
		fact[i]=mult(fact[i-1],i);
		ifact[i]=inv(fact[i]);
	}
	memset(par,-1,sizeof(par));
	int n; cin>>n;
	ll a,b;cin>>a>>b;
	vector<pair<ii,int> > vec;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;
		adj[x].pb(mp(y,i));
		vec.pb(mp(mp(y,x),i));
		dsu[i][x]++;
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<n;i++)
	{
		sort(adj[i].begin(),adj[i].end());
		for(int j=1;j<adj[i].size();j++)
		{
			if(adj[i][0].fi+adj[i][j].fi<=a)
			{
				//cerr<<adj[i][0].se<<' '<<adj[i][j].se<<'\n';
				merge(adj[i][0].se,adj[i][j].se);
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		if(vec[0].fi.se!=vec[i].fi.se&&vec[0].fi.fi+vec[i].fi.fi<=b)
		{
			//cerr<<vec[0].se<<' '<<vec[i].se<<'\n';
			merge(vec[0].se,vec[i].se);
		}
	}
	int ptr=0;
	while(ptr<n&&vec[0].fi.se==vec[ptr].fi.se) ptr++;
	if(ptr<n)
	{
		for(int i=0;i<n;i++)
		{
			if(vec[ptr].fi.se!=vec[i].fi.se&&vec[ptr].fi.fi+vec[i].fi.fi<=b)
			{
				//cerr<<vec[ptr].se<<' '<<vec[i].se<<'\n';
				merge(vec[ptr].se,vec[i].se);
			}
		}
	}
	ll ans = 1;
	for(int i=0;i<n;i++)
	{
		ans=mult(ans,solve(i));
	}
	cout<<ans<<'\n';
}	


Measured memory_bytes: 46124
#include<iostream>
using namespace std;
int ans[31];

void rec(int pos,int cnt){

  if(cnt==0){
    for(int i=1;i<pos-1;i++)cout<<ans[i]<<' ';
    cout<<ans[pos-1]<<endl;
    return;
  }

  for(int i=ans[pos-1];i>=1;i--){
    if(cnt-i<0)continue;
    ans[pos]=i;
    rec(pos+1,cnt-i);
  }

}
int main(){
  while(1){
    cin>>ans[0];
    if(ans[0]==0)break;
    rec(1,ans[0]);
  }
  return 0;
}

Measured memory_bytes: 1160
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H = int(readline())

    def dfs(h):
        if h == 1:
            return 1
        return 2 * dfs(h // 2) + 1

    print(dfs(H))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61916
s = input()
lst_a = []
lst_z = []

for i in range(len(s)):
    if (s[i] == 'A'):
        lst_a.append(i)
    if (s[i] == 'Z'):
        lst_z.append(i)

a = min(lst_a)
z = max(lst_z)
print(z-a+1)

Measured memory_bytes: 11256
#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>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    
int main(){
    int n;
    cin >> n;
    int count = 0;
    int ans = 0;
    rep(i,n){
        int x,y;
        cin >> x >> y;
        if(x==y) count++;
        else count = 0;
        chmax(ans, count);
    }
    if(ans>=3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    int N,i;
    int result=0;
    int flg=-1;
    int search=1;
    cin>>N;
    vector<int>A(N);
    for(i=0;i<N;i++)cin>>A[i];
    for(i=0;i<N;i++){
        if(A[i]==search){
            flg=0;
            search++;
        }else{
            result++;
        }
    }

    if(flg==-1)cout<<flg<<endl;
    if(flg!=-1)cout<<result<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        long[,,] DP = new long[M+1,N+1,2];
        for(int i=0;i<N+1;i++){
            if(i == 0){
                DP[0,i,1] = 1;
            }
            else{
                DP[0,i,0] = 1;
            }
        }
        for(int i=0;i<M;i++){
            for(int j=0;j<N+1;j++){
                DP[i,j,0] %= Define.mod;
                DP[i,j,1] %= Define.mod;
                if(j != N){
                    DP[i+1,j+1,0] += DP[i,j,0];
                    DP[i+1,j+1,1] += DP[i,j,1];
                }
                if(j == 1){
                    DP[i+1,j-1,1] += DP[i,j,0];
                    DP[i+1,j-1,1] += DP[i,j,1];
                }
                else if(j != 0){
                    DP[i+1,j-1,0] += DP[i,j,0];
                    DP[i+1,j-1,1] += DP[i,j,1];
                }
                if(j != N){
                    DP[i+1,j,0] += DP[i,j,0];
                    DP[i+1,j,1] += DP[i,j,1];
                }
                if(j == 1){
                    DP[i+1,j,1] += DP[i,j,0];
                    DP[i+1,j,1] += DP[i,j,1];
                }
                else if(j != 0){
                    DP[i+1,j,0] += DP[i,j,0];
                    DP[i+1,j,1] += DP[i,j,1];
                }
            }
        }
        long count = 0;
        for(int i=0;i<N+1;i++){
            count += DP[M,i,1];
        }
        count %= Define.mod;
        sb.Append(count+"\n");
    }
}
public static class Define{
    public const long mod = 1000000007;
}

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

int a[2005];

int main() {
  int n,z,w;
  scanf("%d%d%d",&n,&z,&w);
  for(int i=0;i<n;i++) scanf("%d",a+i);
  if(n == 1) printf("%d\n",abs(a[0]-w));
  else printf("%d\n",max(abs(a[n-1]-w), abs(a[n-1]-a[n-2])));
}


Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, K] = nextIntArray()
    const h = nextIntArray()
    h.sort((a,b)=>a-b)
    let ans = 0
    for(let i = 0; i<h.length-K; i++){
        ans += h[i]
    }
    console.log(ans)
}
Main()


Measured memory_bytes: 52868
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,ans=0;
  cin>>a>>b>>c;
  if(a>b)
    swap(a,b);
  for(int i=a;i<=b;i++){
    if(c%i==0)
      ans++;
  }
  cout<<ans<<'\n';
  return(0);
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vstr s(n);
    vin p(n);
    rep(i,n)cin>>s[i]>>p[i];
    vector<tuple<string,int,int>> res(n);
    rep(i,n){
        get<0>(res[i])=s[i];
        get<1>(res[i])=-p[i];
        get<2>(res[i])=i+1;
    }
    sort(all(res));
    rep(i,n){
        cout<<get<2>(res[i])<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
 
#define N 10010
  
int C[N] = {0};
  
int main()
{
  int i, j;
  int n;
  int a;
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%d", &a);
    C[a]++;
  }
      
  int l = 0;
  for (i = 0; i < N; i++){
    if (C[i] != 0) l = i;
  }
      
  for (i = 0; i < l; i++){
    for (j=0; j<C[i]; j++){
      printf("%d ", i);
    }
  }
 
  for (i = 0; i < C[l] - 1; i++)
    printf("%d ", l);
  
  printf("%d\n", l);
      
  return 0;
}

Measured memory_bytes: 636
/*
 * atcoder/abc150/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

/*
 * X = a'_i * (2p + 1)
 */
ll N, M;
vector<ll> A;
void solve() {
  cin >> N >> M;
  A.resize(N);
  loop(n,0,N) cin >> A[n];
  loop(n,0,N) A[n] /= 2;
  ll lc = 1;
  loop(n,0,N) lc = lcm(lc, A[n]);
  loop(n,0,N) if ((lc / A[n]) % 2 == 0) {
    cout << 0 << endl;
    return;
  }
  M /= lc;
  cout << (M+1)/2 << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
A.insert(0,0)
A.append(0)
yen = 0
for i in range(N+1):
    yen += abs(A[i] - A[i+1])
for i in range(1,N+1):
    print(yen + abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])))

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

int main(){
    int n;
    cin >> n;
    vector<pair<pair<string ,int> ,int>> res(n);
    for(int i=0;i<n;i++){
        string s; int p;
        cin >> s  >> p;
        res[i].first.first = s;
        res[i].first.second = p*(-1);
        res[i].second = i+1;
    }

    sort(res.begin() ,res.end());

    for(int i=0;i<n;i++){
        cout << res[i].second << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
s = [0] * N
t = [0] * N
for i in range(N):
    s[i], t[i] = map(str, input().split())
X = str(input())


for i in range(N):
    if s[i] == X:
        ans = t[i+1:]

cnt = 0
for i in range(len(ans)):
    cnt += int(ans[i])

print(cnt)

Measured memory_bytes: 3064
program main
    implicit none
    integer x, n
    integer, allocatable, dimension(:) :: p
    integer, dimension(102) :: q
    integer i, min, d, a

    read(*,*) x, n
    allocate(p(n))
    read(*,*) p

    do i = 1, 102
        q(i) = i-1
    end do

    do i = 1, n
        q(p(i)+1) = 1000
    end do

    a = 1
    min = 200
    do i = 1, 102
        d = abs(q(i)-x)
        if(d < min) then
            min = d
            a = q(i)
        else if (d == min) then
            if (q(i) < a) then
                a = q(i)
            end if
        end if
    end do


    write(*,*) a

end program


Measured memory_bytes: 2804
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
using namespace std;
#define ll long long
typedef pair<ll,ll> pi;
ll n, p;
ll twocounter;
vector<pi> v;
ll answer = 1;

ll power(ll a, ll b){
	if (b == 0) return 1;
	if (b == 1) return a;
	ll half = power(a, b/2);
	half *= half;
	if (b % 2 == 1){
		half *= a;
	}
	return half;
}

int main(){
	
	scanf("%lld%lld", &n, &p);
	while (p % 2 == 0){
		p /= 2;
		twocounter+=1;
	}
	for (ll i = 3; i*i <= p; i+=2){
		if (p % i == 0){
			ll counter = 0;
			while (p % i == 0){
				p /= i;
				counter++;
			}
			v.push_back(make_pair(i, counter));
		}
	}
	if (p != 1){
		v.push_back(make_pair(p, 1));
	}
	answer *= power(2, twocounter/n);
	for (vector<pi>::iterator it = v.begin(); it != v.end(); it++){
		answer *= power(it -> first, (it -> second)/n);
	}
	printf("%lld\n", answer);
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
using namespace std;
string s;
int a[30];
int main()
{
	cin>>s;
	if(s.size()<26)
 	{
	 	for (int i=0;i<s.size();i++)
	   		a[s[i]-'a']=1;
   		char ap;
   		for (int i=0;i<26;i++)
     	{
	     	if(a[i]!=1)
   			{
	     		ap='a'+i;
	     		break;
    		}
   		}
   		cout<<s<<ap<<endl;
	}
	else
 	{
	 	int t=24;
	 	while(t>=0)
   		{
	   		if(s[t]<s[t+1])
		   		break;
	   		t--;
   		}
   		if(t>=0)
     	{
     		char mn='z';
     		for(int i=t+1;i<26;i++)
   			{
	   			if(s[i]>s[t] && s[i]<mn)
		   			mn=s[i];
   			}
   			for (int i=0;i<t;i++)
	      		cout<<s[i];
      		cout<<mn<<endl;
   		}
     	else
	      	cout<<"-1"<<endl;
	}
	system("pause");
    return 0;
}

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

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

    if(a - b > 0){
        c = c - (a - b);
    }
    if(c < 0){
        c = 0;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL);

ll item[105][2];
ll dp[105][100005];

///vector<vector<ll>> item(105 , vector<ll>(100));
///vector<vector<ll>> dp(100 , vector<ll>(2));
 
int main() {

    fastio;

    ll n,b;


    cin >> n >> b;
     for(ll i = 1; i <= n; i++) cin >> item[i][0] >> item[i][1];

    //OPTIMAL SUB-PROBLEM :

    // dp[i][j] = max profit using the first i items and with total weight atmost j

    
    // BASE CASE :

    for(ll i = 0; i <= b; i++) dp[0][i] = 0;
    for(ll i = 0; i <= n; i++) dp[i][0] = 0;

    // RECURSIVE RELATION :

    for(ll i = 1; i <= n; i++){
        for(ll j = 1; j <= b; j++){
            if(item[i][0] <= j){
                dp[i][j] = max(dp[i-1][j-item[i][0]] + item[i][1] , dp[i-1][j]);
            }
            else dp[i][j] = max(dp[i-1][j] , dp[i][j-1] );
        }
    }

    //OPTIMAL SOLUTION :

    cout << dp[n][b];

    return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  VI a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  const int N = 30;
  lint res = 0;
  for (int i = 0; i < n; i++) {
    if ((a[i] | k) == k) res += b[i];
  }
  for (int i = 0; i < N; i++) {
    lint tmp = 0;
    if (!(k & 1 << i)) continue;
    int x = (k & ~((1 << i) - 1)) - 1;
    for (int j = 0; j < n; j++) {
      if ((a[j] | x) == x) tmp += b[j];
    }
    res = max(res, tmp);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define mp make_pair
using namespace std;
const int MAXN = 1e5 + 10;

//int a[MAXN], b[MAXN];

int main()
{
    long long int a,b,c=0;
    cin>>a>>b;
    c=(a+b)/2;
    if(c*2==(a+b))
    {
        cout<<c<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
   // cout<<(a+b)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/13
// Problem:ABC 069 K-City a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int n, m;
  cin >> n >> m;
  int ans = (n - 1) * (m - 1);
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define eps 1e-9
using namespace std;
using namespace __gnu_pbds;

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


int main()
{
    fastio
    int n;
    cin>>n;
    cout<<(n+1)/2<<endl;;
}

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

int main() {
    int n;
    cin >> n;
    long int saidai = 0;
    long int saishou = 0;
    long int goukei = 0;
    int flag = 0;
    for (int i = 0; i < n; i++) {
        long int a;
        cin >> a;
        if (flag == 0) {
            saishou = a;
            saidai = a;
        }
        if (saidai <= a)saidai = a;
        if (saishou >= a)saishou = a;
        goukei += a;
        flag = 1;
    }
    cout << saishou << " " << saidai << " " << goukei << endl;
    return 0;
}


Measured memory_bytes: 3112