akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    const int inf = 100000000;

    int n, m;
    cin >> n >> m;

    int a[1000], b[1000], c[1000], dist[100][100];

    REP(i, m)
    {
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
    }

    REP(i, n)
    {
        REP(j, n)
        {
            if (i == j)
            {
                dist[i][j] = 0;
            }
            else
            {
                dist[i][j] = inf;
            }
        }
    }

    REP(i, m)
    {
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
    }

    REP(k, n) REP(i, n) REP(j, n)
    {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    int ans = m;
    REP(i, m)
    {
        bool shortest = false;
        REP(j, n)
        {
            if(dist[j][a[i]]+c[i] == dist[j][b[i]]) shortest = true;
        }
        if (shortest)
        {
            --ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	bool p[10010] = {};
	p[0] = p[1] = 1;
	rep2(i,2,101) {
		if(!p[i]) {
			for(int j=2*i;j<=10000;j+=i) {
				p[j] = 1;
			}
		}
	}
	int n;
	while(cin >> n, n) {
		while(p[n] || p[n-2]) --n;
		cout << n-2 << " " << n << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
import sys
input=sys.stdin.buffer.readline
n=int(input())+1
data=[0]*n*2
def update(i,x):
  i+=n
  data[i]=x
  i//=2
  while i:
    data[i]=data[i*2]|data[i*2+1]
    i//=2
def query(l,r):
  l+=n
  r+=n
  s=0
  while l<r:
    if l&1:
      s|=data[l]
      l+=1
    if r&1:
      r-=1
      s|=data[r]
    l//=2
    r//=2
  return sum(map(int,bin(s)[2:]))
for i,c in enumerate(input()[:-1]):
  update(i,2**(c-97))
for _ in range(int(input())):
  q,a,b=input().split()
  if q[0]>49:print(query(int(a)-1,int(b)))
  else:update(int(a)-1,2**(b[0]-97))

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

int main() {
	int N,M,ans=0;
	cin>>N>>M;
	vector<bool>T(N,true);
	vector<int>H(N);
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	for(int i=0;i<M;i++){
		int A,B;
		cin>>A>>B;
		if(H[A-1]>H[B-1])T[B-1]=false;
		else if(H[A-1]<H[B-1])T[A-1]=false;
		else{
			T[B-1]=false;
			T[A-1]=false;
		}
	}
	for(int i=0;i<N;i++){
		if(T[i]==true)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
const int mx=1234567;
#define ll long long
#define p push_back
#define ff first
#define ss second
ll n ,s[mx];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    cout<<(s[n-1]-s[0])<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
const int INf = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
const ll MOD = 1000000007; int ans =0;
int main() {
    int n, m,p; cin >> n >> m;
    vector<ll> a(m), b(m),bit(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        int ma = 0;
        rep(j, b[i]) {
            cin >> p; p--;
            ma += pow(2, p);
        }
        bit[i] = ma;
    }ll dp[1 << 12];
    Fill(dp, INF);
    dp[0] = 0;
    rep(i, (1 << n)) {
        rep(j, m) {
            dp[i | bit[j]] = min(dp[i | bit[j]], dp[i] + a[j]);
        }
    }
    if (dp[(1 << n) - 1] == INF) cout << -1 << endl;
    else cout << dp[(1 << n) - 1 ] << endl;
}

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

int main()
{
    long long h, n, sum = 0;
    cin >> h >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
    }
    if (h > sum)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    int u[100]; fill(u, u + 100, 0);
    int ans = 0;
    for(int i=0; i<N; i++){
        int d;
        cin >> d;
        d--;
        if(u[d] == 0) ans ++;
        u[d] ++;
    }    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space*/

const ll base = 100001;
using tli = tuple<ll,int>;
unordered_map<ll,bool> used;

unordered_map<ll,vector<tli> > mm; // comp-index, to comp-index,cost
int main(){
  int n,m; cin >> n >> m;
  rep(i,m){
    ll p,q,c; cin >> p >> q >> c;
    mm[p + base*c].pb(tli{q + base*c,0});
    mm[q + base*c].pb(tli{p + base*c,0});
    mm[p + base*c].pb(tli{p,1});
    mm[p].pb(tli{p + base*c,0});
    mm[q + base*c].pb(tli{q,1});
    mm[q].pb(tli{q + base*c,0});
  }
  using til = tuple<int,ll>;
  priority_queue<til,vector<til>,greater<til>> q;
  q.push(til{0,1});
  while(!q.empty()){
    ll comp_index;
    int turn;
    tie(turn,comp_index) = q.top(); q.pop();
    //ll comp = comp_index / base;
    used[comp_index] = 1;
    ll index = comp_index % base;
    if(index == n){
      cout << turn +1 << endl;
      return 0;
    }else{
      for(auto i:mm[comp_index]){
        ll next; int cost;
        tie(next,cost) = i;
        if(used[next] == 0)
          used[next] = 1,q.push(til{turn+cost,next});
      }
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 72436
import math
A,B=map(int,input().split())
flag=0
for i in range(0,5000):
    a=i*0.08
    b=i*0.10
    if (math.floor(a)==A)and(math.floor(b)==B):
        print(i)
        flag=1
        break
if flag==0:
    print("-1")

Measured memory_bytes: 39152
import collections
import math

N = int(input())
s =[]
ans = 0
for i in range(N):
    s.append(input())
    letters = list(s[i])
    letters.sort()
    s[i] = "".join(map(str,letters))

H = collections.Counter(s)
I  = H.most_common()
for i in range(len(I)):
    if I[i][1] > 1:
        ans += int(math.factorial(I[i][1])/math.factorial(I[i][1]-2)/2)

print(ans)


Measured memory_bytes: 24504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K,i;
  int x;
  int sum=0;
  cin >> N >> K;
  for(i=1;i<=N;i++){
	 cin >> x;
     if(x<K-x){
	sum += x*2;
     }
    else{
  	sum += (K-x)*2;
    }    
  }
cout << sum << endl;
}

Measured memory_bytes: 256
pub struct Scanner {
	handle: std::io::Stdin,
	buffer: std::collections::VecDeque<String>
}

impl Scanner {
	pub fn new() -> Scanner {
		Scanner {
			handle: std::io::stdin(),
			buffer: std::collections::VecDeque::new()
		}
	}
	pub fn next<T: std::str::FromStr>(&mut self) -> Result<T, T::Err> {
		if self.buffer.len() == 0 {
			loop {
				let mut available = String::new();
				self.handle.read_line(&mut available).unwrap();
				self.buffer = available.split_whitespace().map(String::from).collect();
				if self.buffer.len() > 0 {
					break;
				}
			}
		}
		T::from_str(&self.buffer.pop_front().unwrap())
	}
}

fn gcd(m: isize, n: isize) -> isize {
	if m == 0 {
		n
	} else {
		gcd(n % m, m)
	}
}

fn two_p(p: isize) -> isize {
	if p == 0 {
		1
	} else {
		(2 * two_p(p - 1)) % 1000000007
	}
}

fn main() {
	let mut scanner = Scanner::new();
	let n: isize = scanner.next().unwrap();
	let mut size = std::collections::HashMap::<(isize,isize,isize),isize>::new();
	let mut zero_total: isize = 0;
	for _ in 0..n {
		let mut a: isize = scanner.next().unwrap();
		let mut b: isize = scanner.next().unwrap();
		if a == 0 && b == 0 {
			zero_total = (zero_total + 1) % 1000000007;
			continue;
		}
		let mut sign = 1;
		if a < 0 {
			sign *= -1;
			a *= -1;
		}
		if b < 0 {
			sign *= -1;
			b *= -1;
		}
		sign = if a == 0 {
			-1
		} else if b == 0 {
			1
		} else {
			sign
		};
		let g = gcd(a as isize,b as isize);
		let s = size.entry((sign,(a as isize)/g,(b as isize)/g)).or_insert(0);
		*s += 1;
	}
	let mut total: isize = 1;
	for (k1,v1) in size.iter() {
		match size.get(&(-k1.0,k1.2,k1.1)) {
			Some(v2) => {
				if k1.0 > 0 {
					total = (total * ((two_p(*v1) + two_p(*v2) - 1) % 1000000007)) % 1000000007;
				}
			}
			None => total = (total * two_p(*v1)) % 1000000007
		}
	}
	total = ((total + zero_total - 1) % 1000000007 + 1000000007) % 1000000007;
	println!("{}", total);
}


Measured memory_bytes: 14788
N, A, B = map(int, input().split())
        
Y = int(B-A)

if Y%2 == 0:
    print(int(Y//2))
else:
    if A-1>=N-B:
        print(N-B+int((B-A-1)//2)+1)
    else:
        print(A-1+int((B-A-1)//2)+1)


Measured memory_bytes: 2940
import math
def check(n):
    count = 0
    end = int(math.sqrt(n)+1)
    for i in range(2,end):
        if n%i==0:
            count += 1
            n/=i
        if n%i==0:
            l = 2
            count2 = 0
            while n%i==0:
                n/=i
                count2+=1
                if count2==l:
                    count+=1
                    count2=0
                    l+=1
        if n==1:
            return count
    if n==1:
        return 0
    if count==0:
        return 1
    else:
        return count+1   
n = int(input())
ans = check(n)
print(ans)

Measured memory_bytes: 9224
#include<stdio.h>
int main()
{
    long long int d,n;
    scanf("%lld %lld",&d,&n);
    {
        long long int c=100,p=0,i;
        if(d==0 && n<100)
        {
            printf("%lld\n",n);

        }
        else if(d==0 && n==100)
        {
            printf("%lld\n",n+1);
        }
        else if(d==1)
        {
                if(n==100)
                printf("10100\n");
                else{
            p=n*100;
            printf("%lld\n",p);
                }
        }
        else if(d==2)
        {
                        if(n==100)
                printf("1010000\n");
                else{
            p=n*10000;
            printf("%lld\n",p);
                }
        }

    return 0;
}

}


Measured memory_bytes: 128
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long long int ar[100013];
long int gcd(long int a, long int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
//int sieve(long long int a)
//{
//    long long int i,j;
//    memset(ar,0,sizeof(ar));
//    for(i=2; i<=a; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=a; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    if(ar[a]==0)
//        return 1;
//    else
//        return 0;
//}

void Ok()
{
    long int a,b,c,d,e,f,g,h,t,i = 0,j = 0,k,l,m,n,r,rcv,lo,hi,mid,w,ab;
    long int sum = 0,ans_1,ans_2,ans_3,cnt_1 = 0,cnt_2 = 0,cnt_3 = 0,Max,Min,flag = 0,div,temp;
    long double aa,bb,cc,dd,ee,ff,gg;
    char aaa[1013],bbb,ccc,ddd;
    string spc,in[113],rev;

    cin>>n;
    if(n>=500)
    {
        b = n%500;
        n -= b;
        a = n/500;
        a *= 1000;
        b = b/5;
        b *= 5;
        ans_1 = a + b;
        cout<<ans_1<<endl;
    }
    else if(n>=100 && n<500)
    {
        b = n%100;
        n -= b;
        a = n/100;
        a *= 100;
        b = b/5;
        b *= 5;
        ans_1 = a + b;
        cout<<ans_1<<endl;
    }
    else if(n>=50 && n<100)
    {
        b = n%50;
        n -= b;
        a = n/50;
        a *= 50;
        b = b/5;
        b *= 5;
        ans_1 = a + b;
        cout<<ans_1<<endl;
    }
    else if(n>=10 && n<50)
    {
        b = n%10;
        n -= b;
        a = n/10;
        a *= 10;
        b = b/5;
        b *= 5;
        ans_1 = a + b;
        cout<<ans_1<<endl;
    }
    else if(n>=5 && n<10)
    {
        b = n%5;
        n -= b;
        a = n/5;
        a *= 5;
        b = b/5;
        b *= 5;
        ans_1 = a + b;
        cout<<ans_1<<endl;
    }
    else if(n>=1 && n<5)
    {
        a = n/1;
        a *= 1;
        ans_1 = a;
        cout<<ans_1<<endl;
    }
    else if(n==0)
        cout<<"0"<<endl;
    
    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, mode = 1, ans = 0, l = 1, r, now = 1;
int main() {
	cin >> n;
	r = n - 1;
	vector<ll> s(n), v1, v2, v;
	REP(i, n)cin >> s[i];
	sort(ALL(s));
	v1.push_back(0);
	REP(i, INF) {
		if (mode == 1) {
			v2.push_back(r);
			r--;
			now++;
			if (now == n)break;
			v1.push_back(r);
			r--;
			now++;
			if (now == n)break;
		}
		else {
			v2.push_back(l);
			l++;
			now++;
			if (now == n)break;
			v1.push_back(l);
			l++;
			now++;
			if (now == n)break;
		}
		mode *= -1;
	}
	reverse(ALL(v2));
	REP(i, v1.size())v2.push_back(v1[i]);
	REP(i, n)v.push_back(s[v2[i]]);
	REP(i, n - 1)ans += abs(v[i] - v[i + 1]);
	ans = max(ans, ans - abs(v[n - 2] - v[n - 1]) + abs(v[0] - v[n - 1]));
	cout << ans << endl;
}


Measured memory_bytes: 3824
$m = 1000000007

def pow(a, b)
  s = 1
  while b > 0
    if b & 1 != 0
      s = s * a % $m
    end
    a = a * a % $m
    b >>= 1
  end
  s
end

def reverse(a)
  pow(a, $m - 2)
end

def sub(n, a)
  if a > n / 2
    a = n - a
  end
  s1 = 1
  n2 = n - a
  for i in n2+1 .. n
    s1 = s1 * i % $m
  end
  s2 = 1
  for i in 1 .. a
    s2 = s2 * i % $m
  end
  s3 = reverse(s2)
  s1 * s3 % $m
end

n, a, b = gets.strip.split(" ").map(&:to_i)

all = pow(2, n)

answer = (all + 2 * $m - sub(n, a) - sub(n, b) - 1) % $m

p answer

Measured memory_bytes: 14292
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{	
	auto N = RD;
	auto A = RDR.ARR;

	auto b = new long[](N+1);
	foreach_reverse (i; 0..N)
	{
		b[i] = gcd(b[i+1], A[i]);
	}

	auto c = new long[](N+1);
	long x;
	long ans;
	foreach (i; 0..N)
	{
		c[i] = gcd(b[i+1], x);
		x = gcd(x, A[i]);
		ans = max(ans, c[i]);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 7496
#include <iostream>
#include <cstring>
#define MAXH 100
#define MAXW 100
using namespace std;

int H, W;
char farm[MAXH][MAXW];
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

void dfs(int y, int x, char tree){
	for(int i = 0; i < 4; i++){
		int h = y + dy[i];
		int k = x + dx[i];
		if(h >= 0 && h < H && k >= 0 && k < W && tree == farm[h][k]){
			farm[h][k] = 'x';
			dfs(h, k, tree);
		}
	}
}

int main(){
	while(cin >> H >> W){
		if(!W && !H) break;
		memset(farm, 0, sizeof(farm));
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++)
				cin >> farm[i][j];
		}
		
		int sum = 0;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(farm[i][j] != 'x'){
					sum++;
					dfs(i, j, farm[i][j]);
				}
			}
		}
		cout << sum <<endl;
	}
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

vector<int> fac, finv, inv;

void comb_init(int n) {
  fac  = vector<int>(n);
  finv = vector<int>(n);
  inv  = vector<int>(n);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
 
int comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
  int N, A, B, K;
  cin >> N >> A >> B >> K;

  comb_init(300010);

  int ans = 0;
  REP(i, N+1){
    int cur = A*i;
    if(K < cur) break;
    if((K-cur)%B != 0) continue;
    int b = (K-cur)/B;

    ans += comb(N, i)*comb(N, b);
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
            }
        
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            return 0;
            }
    }
}

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

int main(){
	int n;cin >> n;
	vector<long long> a(100);
	a.at(0)=2;
	a.at(1)=1;
	for(int i=2;i<100;++i){
		a.at(i)=a.at(i-2)+a.at(i-1);
	}
	cout << a.at(n) << endl;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut it = buf.split_whitespace().map(|x| x.parse::<i64>().unwrap());
    let n = it.next().unwrap();
    let a = it.next().unwrap();
    let b = it.next().unwrap();

    if a == 0 {
        println!("{}", 0);
        return;
    }

    let num = n / (a + b);
    let res = n % (a + b);

    println!("{}", a * num + if res > a { a } else { res });
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] a = new int[3000];
		int[] b = new int[3000];

		for(int i = 0 ; i<3000 ; i++){
			a[i]=scan.nextInt();
			b[i]=scan.nextInt();
			if(a[i]==0&& b[i]==0) break;
		}

		for(int i = 0 ; i<3000 ; i++){
			if(a[i]==0&& b[i]==0) break;
			if(a[i]>b[i])swap(a,b,i);
			System.out.println(a[i]+" "+b[i]);
		}
	}

	static void swap(int[] a,int[] b,int i){
		int tmp =a[i];
		a[i]=b[i];
		b[i]=tmp;
		return;
	}

}

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

int main() {
	int count=0;
	int n,k;
	cin>>n>>k;
	
	while(n>0){
		n=n/k;
		count++;
	}
	
	cout<<count<<endl;
}


//書き方微妙あとなぜか1WA

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<int> arr(N);
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }

    int ans = 0;
    for (int j = 0; j < N; j++) {
        if (arr[j] == j + 1) {
            swap(arr[j], arr[j + 1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  string S;
  cin >> S;
  int len = S.size();
  int min = 999;
  REP(i,len-2) {
    int v = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0') - 753 ;
    if(v < 0) v = -v;
    if(v < min) min = v;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private void solve(Scanner sc, PrintWriter out) {
    Set<Integer> set = new HashSet<>();
    while (sc.hasNextInt()) {
      set.add(sc.nextInt());
    }
    out.println(set.size());
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 9808
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,m,k;
cin>>n>>m;
k=n/2+1;
for(int i=0;i<n;i++){
    if(i<k)cout<<"0";
    else cout<<m;
    if(i<n-1)cout<<" ";
}
cout<<endl;
 return 0;   
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;
    n %= 10;
    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    default:
        cout << "bon" << endl;
        break;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    long long int N;
    cin>>N;
    long long int count=0;
    for(int i=1;i<=N;i++){
        if(i%3!=0 & i%5!=0){
            count+=i;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3636
#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 ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
int isPal(string s){
    for(int i = 0; i < s.size()/2 ; ++i){
        if(s[i] != s[s.size() - 1 - i])
            return 0; 
    }
    return 1; 
}
void solve(){
    string s;
    cin >> s;
    int n = s.size(); 
    if(isPal(s.substr(0,n/2)) && isPal(s.substr(n/2 + 1)) && isPal(s)){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

int main() {
	int n, num, min = INT_MAX, max = INT_MIN;
        long sum = 0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> num;
		sum += num;
		if (num < min)
			min = num;
		if (num > max)
			max = num;
	}

	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1168
// C++ code to find number of distinct numbers
// in a subarray
#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
const int MAX = 1000001;

// structure to store queries
struct Query
{
	int l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y)
{
	return x.r < y.r;
}

// updating the bit array
void update(int idx, int val, int bit[], int n)
{
	for (; idx <= n; idx += idx&-idx)
		bit[idx] += val;
}

// querying the bit array
int query(int idx, int bit[], int n)
{
	int sum = 0;
	for (; idx>0; idx-=idx&-idx)
		sum += bit[idx];
	return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
	// initialising bit array
	int bit[n+1];
	memset(bit, 0, sizeof(bit));

	// holds the rightmost index of any number
	// as numbers of a[i] are less than or equal to 10^6
	int last_visit[MAX];
	memset(last_visit, -1, sizeof(last_visit));

	// answer for each query
	int ans[q];
	int query_counter = 0;
	for (int i=0; i<n; i++)
	{
		// If last visit is not -1 update -1 at the
		// idx equal to last_visit[arr[i]]
		if (last_visit[arr[i]] !=-1)
			update (last_visit[arr[i]] + 1, -1, bit, n);

		// Setting last_visit[arr[i]] as i and updating
		// the bit array accordingly
		last_visit[arr[i]] = i;
		update(i + 1, 1, bit, n);

		// If i is equal to r of any query store answer
		// for that query in ans[]
		while (query_counter < q && queries[query_counter].r == i)
		{
			ans[queries[query_counter].idx] =
					query(queries[query_counter].r + 1, bit, n)-
					query(queries[query_counter].l, bit, n);
			query_counter++;
		}
	}

	// print answer for each query
	for (int i=0; i<q; i++)
		cout << ans[i] << endl;
}

// driver code
int main()
{
  int n,q;
  cin>>n>>q;
	int a[n] ;
  rep(i,0,n) cin>>a[i];
	Query queries[q];
  rep(i,0,q){
    cin>>queries[i].l>>queries[i].r;
    queries[i].l-=1;
    queries[i].r-=1;
    queries[i].idx=i;
  }
	sort(queries, queries+q, cmp);
	answeringQueries(a, n, queries, q);
	return 0;
}


Measured memory_bytes: 19344
#include <stdio.h>

#define N 5000000

int n;
int A[N];

void maxHeap(int i){
	int l = i*2;
	int r = i*2 + 1;
	int largest = i;
	int tmp;
	if(l <= n && A[l]>A[i]) largest = l;
	else largest = i;
	if(r <= n && A[r]>A[largest]) largest = r;

	if(largest != i) {
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeap(largest);
	}
}

void buildHeap(){
	int i;
	for(i=n/2;i>0;i--){
		maxHeap(i);
	}
}

int main(){
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++){
		scanf("%d",&A[i]);
	}
	buildHeap();
	for(i=1;i<=n;i++){
		printf(" %d",A[i]);
	}
	printf("\n");
	return 0;

}

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

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpii vector<pair<int,int> >
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

int32_t main(){
    get_it_done();
    int q=1;
    // cin >> q;
    while (q--){
        int s,w;
        cin>>s>>w;
        if(w<s){
            cout<<" safe ";
        }else{
            cout<<" unsafe ";
        }

        
    }
}


Measured memory_bytes: 3652
#include <stdio.h>
 
int n;
double dp[3005],ans;
int p;
 
int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    dp[0]=1.0;
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        while (getchar()!='.');
        scanf("%d",&p);
        for (int j=i; j>=0; j--) {
            dp[j+1]+=dp[j]*p/100.0;
            dp[j]=dp[j]*(100-p)/100.0;
        }
    }
    for (int i=n/2+1; i<=n; i++) ans+=dp[i];
    printf("%.10f\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m,x,y,fl=0,tu=0;
    cin>>n>>m>>x>>y;
    int a[n+2],b[m+2];
    a[0]=x;
    b[0]=y;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>b[i];
    }
    sort(a,a+n+1),sort(b,b+m+1);
    for(int i=0;i<=n;i++)
    {
        int gu=a[i];
        for(int j=0;j<=m;j++)
        {
            if(b[j]<=gu)
            {
                fl=1;
                break;
            }
        }
        if(fl==1)
        {
            tu=1;
            break;
        }
    }
    if(tu==1)
    {
        cout<<"War"<<nl;
    }
    else
    {
        cout<<"No War"<<nl;
    }
    return 0;
}



Measured memory_bytes: 256
package main
import (
  "fmt"
)
func main() {
  var s, t string
  fmt.Scan(&s, &t)
  result := 0
  for i := 0; i < 3; i++ {
    if s[i] == t[i] {
      result++
    }
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
gets
d = gets.split.map(&:to_f).zip(gets.split.map(&:to_f)).map{|x, y| (x-y).abs}
(1..4).each do |i|
  puts ((i == 4) ? d.max : d.map{|c| c**(i)}.inject(:+)**(1.0/i))
end

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    string s;
    cin>>s;
    int n=s.length();
    int sum=0;
    for(auto c:s)
        sum+=c-'0';
    if(s[0]=='1')
    {
        bool flag=true;
        for(int i=1;i<n;i++)
            if(s[i]!='0')
                flag=false;
            if(flag)
                cout<<10<<endl;
            else
                cout<<sum<<endl;
    }
    else
    cout<<sum<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int N, M;

	while (cin >> M >> N, M||N)
	{
		vector<int> a;
		for (int i=1; i<=M; i++)
			a.push_back(i);

		int p = 0;
		int num = 1;
		while (N--)
		{
			
			string s;
			cin >> s;

			if (a.size() == 1) continue;
			if (num%3 == 0 && num%5 == 0)
			{
				if (s != "FizzBuzz")
				{
					a.erase(a.begin()+p);
					p--;
				}
			}
			else if (num%3 == 0)
			{
				if (s != "Fizz")
				{
					a.erase(a.begin()+p);
					p--;
				}
			}
			else if (num%5 == 0)
			{
				if (s != "Buzz")
				{
					a.erase(a.begin()+p);
					p--;
				}
			}
			else
			{
				if (atoi(s.c_str()) != num)
				{
					a.erase(a.begin()+p);
					p--;
				}
			}

			p++;
			num++;
			if (p >= a.size())
				p = 0;
		}

		for (int i=0; i<a.size(); i++)
		{
			cout << a[i];
			if (i != a.size()-1)
				cout << ' ';
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 948
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;

void out(vector<int> a)
{
	bool sp = false;
	for (int i : a)
	{
		print((sp ? " " : "") << i);
		sp = true;
	}
	println("");
}

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	vector<int> b = a;
	vector<int> c = a;

	if (prev_permutation(all(b)))
	{
		out(b);
	}

	out(a);

	if (next_permutation(all(c)))
	{
		out(c);
	}

}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <math.h>
#include <list>
using namespace std;

int gcd(int a, int b){
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
    int K;
    int gcd_sum = 0;
    cin >> K;

    for(int a=1; a<=K; a++){
        for(int b=1; b<=K; b++){
            for(int c=1; c<=K; c++){
                gcd_sum += gcd(a, gcd(b, c));
            }
        }
    }

    cout << gcd_sum << endl;

    return 0;

}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << unitbuf;
        cout << fixed << setprecision(20);
    };
} init;


int N;
string S;
int mod = 1e9 + 7;

// 拡張ユークリッドの互除法
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;
}

// mod逆元
int mod_inverse(int a, int m) {
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

pint f(pint ab, int i, int hash) {
    if (S[i] == '+') { return pint(ab.first, (ab.second + 1) % mod); }
    else if (S[i] == '-') { return pint(ab.first, (ab.second - 1 + mod) % mod); }
    else if (S[i] == '>') { return pint(ab.first * hash % mod, ab.second * hash % mod); }
    else if (S[i] == '<') {
        return pint(ab.first * mod_inverse(hash, mod) % mod,
                    ab.second * mod_inverse(hash, mod) % mod);
    }
}

pint finv(pint ab, int i, int hash) {
    if (S[i] == '-') { return pint(ab.first, (ab.second + 1) % mod); }
    else if (S[i] == '+') { return pint(ab.first, (ab.second - 1 + mod) % mod); }
    else if (S[i] == '<') { return pint(ab.first * hash % mod, ab.second * hash % mod); }
    else if (S[i] == '>') {
        return pint(ab.first * mod_inverse(hash, mod) % mod,
                    ab.second * mod_inverse(hash, mod) % mod);
    }
}
signed main() {
    cin >> N >> S;
    const int K = 3;
    vint hash = {114514, 1919, 810};
    map<int, int> mp[K];
    pint b[K], c[K];
    for (int i = 0; i < K; i++) {
        int h = hash[i];
        b[i] = c[i] = pint(1, 0);
        for (int j = N - 1; j >= 0; j--) { b[i] = f(b[i], j, h), mp[i][0] = 1; }
    }
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        int cur = LLONG_MAX;
        for (int j = 0; j < K; j++) {
            int h = hash[j];
            pint cc = finv(pint(1, 0), i, h);
            c[j] = pint(c[j].first * cc.first % mod, (c[j].first * cc.second + c[j].second) % mod);
            int fi = (c[j].first * b[j].second + c[j].second) % mod;
            chmin(cur, mp[j][fi]);
            mp[j][c[j].second]++;
        }
        ans += cur;
    }
    cout << ans << endl;
}

Measured memory_bytes: 94356
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
const int MAXN = 20;
char sl[MAXN],sr[MAXN],sm[MAXN];

int main(){
	int n;
	cin>>n;
	int L=0,R=n-1,mid;
	cout<<L<<endl;
	fflush(stdout);
	cin>>sl;
	if(sl[0]=='V') return 0;
	while(L+1<R){
		mid=(L+R)/2;
		cout<<mid<<endl;
		fflush(stdout);
		cin>>sm;
		if(sm[0]=='V') return 0;
		if((mid-L-1)&1){
			if(sl[0]==sm[0]) L=mid,sl[0]=sm[0];
			else R=mid;
		}else{
			if(sl[0]==sm[0]) R=mid;
			else L=mid,sl[0]=sm[0];
		}
	}
	cout<<n-1<<endl;
	fflush(stdout);
	cin>>sr;
    return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

LL gcd(LL m, LL n) {
    if (m < n) swap(m,n);
    while (n != 0) {
        m %= n;
        swap(m,n);
    }
    return m;
}

void solve() {
    LL n,x;
    cin >> n >> x;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    sort(all(a));
    int d = abs(x-a[0]);
    REP(i,1,n) d = gcd(d, a[i]-a[i-1]);
    cout << d << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1024
const [nk, as] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
const [n, k] = nk.split(/\s/).map(Number)
const arr = as.split(/\s/).map(Number).sort((a, b) => Math.abs(b) - Math.abs(a))
const base = BigInt(Math.pow(10, 9) + 7)

let results = [], lowestP = -1, lowestN = -1, odd = false

for (let i = 0; i < k; i++) {
  results.push(arr[i])
  if (arr[i] < 0) {
    lowestN = i
    odd = !odd
  } else {
    lowestP = i
  }
}
if (results[lowestP] === 0) {
  console.log(0)
} else {
  if (odd) {
    let mul1 = lowestP >= 0 ? 1 / results[lowestP] : 0
    let mul2 = lowestN >= 0 ? 1 / -results[lowestN] : 0
    let index1 = -1
    let index2 = -1
    for (let i = k; i < n; i++) {
      if (arr[i] < 0 && index1 < 0 && mul1 !== 0) {
        mul1 *= -arr[i]
        index1 = i
      } else if (arr[i] > 0 && index2 < 0 && mul2 !== 0) {
        mul2 *= arr[i]
        index2 = i
      }
      if ((index1 >= 0 || mul1 === 0) && (index2 >= 0 || mul2 === 0)) {
        break
      }
    }
    const v1 = mul1 * Number(index1 >= 0), v2 = mul2 * Number(index2 >= 0)
    if (index1 < 0 && index2 < 0) {
      results = []
    } else if (v1 > v2) {
      results[lowestP] = arr[index1]
    } else {
      results[lowestN] = arr[index2]
    }
  }
  if (results.length === 0) {
    let result = 1n;
    for (let i = n - 1; i >= n - k; i--) {
      result = (result * BigInt(arr[i])) % base
    }
    console.log((result === 0n ? result : result + base).toString())
  } else {
    let result = 1n;
    for (const r of results) {
      result = (result * BigInt(r)) % base
    }
    console.log(result.toString())
  }
}

Measured memory_bytes: 64188
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a + 3);
    cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,H,B[100000]={},counter=0;
	
	cin>>N>>H;

	int a,maxA=0;
	REP(i,N){
		cin>>a>>B[i];
		chmax(maxA,a);
	}
	
	DSORT(B,N);
	REP(i,N){
		if(B[i]<maxA) break;
		else{
			H-=B[i];
			counter++;
			if(H<=0){
				print(counter);
				return 0;
			}
		}
	}
	printf("%d\n",counter+(int)ceil((double)H/maxA));
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int mod=998244353;
int main(){
    string s;
    cin>>s;
    ll cnt=0;
    ll ans=0;
    rep(i,s.size()){
        if(s[i]=='(')cnt++;
        else if(s[i]==')')cnt=max(cnt-1,0LL);
        else ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(){
  int n, i, s, g;
  string a;
  cin>>n;
  for(g=0; g < n;g++){
      getline(cin,a);
      if(a==""){
        g--; 
        continue;
      }
      for(i=6; i <= a.size();i++)
      if(a[i-6]== 'H' &&a[i-5]== 'o' &&a[i-4]== 's' &&a[i-3]== 'h' &&a[i-2]== 'i' &&a[i-1]== 'n' &&a[i]== 'o')
      a[i]='a';   
      cout<<a<<endl;
  } 
  return 0; 
}

Measured memory_bytes: 1204