akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
map<int, int> mp;

int C[51][51];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    int v[51];
    rep(i, N) cin >> v[i];
    sort(v, v + N,greater<int>());
    int sum = 0;
    rep(i, A) sum += v[i];
    int S = sum;
    int same = 0;
    REP(i, A, B - 1) {
        if (sum * (i + 1)== A * (S + v[i])) {
            same++;
        }
        //cout << sum * (i + 1) << " " << A * (S + v[i])<< endl;
        S += v[i];
    }
    B = A + same;
    rep(i, N) mp[v[i]]++; 
    int ans = 0;
    int cnt = 0;
    int num = v[A - 1];
    rep(i, A) if (v[i] == num) cnt++;
    //cout << A << " " << B << " " << num << endl;
    rep(i, 51) C[0][i] = C[i][0] = 1;
    REP(i, 1, 50) {
        REP(j, 1, 50) {
            C[i][j] += C[i - 1][j];
            C[i][j] += C[i][j - 1];
        }
    }
    cout << fixed << setprecision(12) << (long double)sum/(A + 0.0) << endl;
    if (A == B) {
        //cout << mp[num] - cnt << " " << cnt << endl;
        cout << C[mp[num] - cnt][cnt] << endl;
    } else {
        REP(i, A, B) {
            ans += C[mp[num] - i][i];
            //cout << ans << endl;
        }
        cout << ans << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
a,b,m=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
e=[]
mi=min(c)+min(d)
for i in range(m):
    e.append(list(map(int,input().split())))
for i in range(m):
    mi=min(mi,c[e[i][0]-1]+d[e[i][1]-1]-e[i][2])
print(mi)

Measured memory_bytes: 38560
G = [0] * 4
for i in range(3):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a] += 1
    G[b] += 1

for i in range(4):
    if G[i] == 3:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 9116
#include <stdio.h>
int main(void){
    // Your code here!
    char S[10];
    scanf("%s", S);
    if (S[0] == 'S') {
        printf("Cloudy");
    }
    if (S[0] == 'C') {
        printf("Rainy");
    }
    if (S[0] == 'R') {
        printf("Sunny");
    }
    return 0;
}


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

int main() {
  int N;
  long K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  sort(A.begin(), A.end());
  
  long L = -2e18, R = 2e18;
  while (R - L > 1) {
    long M = (L + R) / 2, cnt = 0;
    for (int i = 0; i < N; i++) {
      if (A.at(i) < 0) {
        int l = i, r = N;
        while (r - l > 1) {
          int m = (l + r) / 2;
          (A.at(i) * A.at(m) < M) ? r = m : l = m;
        }
        cnt += N - r;
      } else {
        int l = i, r = N;
        while (r - l > 1) {
          int m = (l + r) / 2;
          (A.at(i) * A.at(m) < M) ? l = m : r = m;
        }
        cnt += l - i;
      }
    }
    (cnt < K) ? L = M : R = M;
  }
  cout << L << "\n";
}

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

using namespace std;

const int maxn = 1 << 15;

namespace math {
	const int mod = 998244353;

	int sum(int x, int y) {
		return x + y <= mod ? x + y : x + y - mod;
	}

	int product(int x, int y) {
		return 1ll * x * y % mod;
	}

	int pow_mod(int x, int n) {
		int y = 1;
		while (n) {
			if (n & 1) y = 1ll * y * x % mod;
			x = 1ll * x * x % mod;
			n >>= 1;
		}
		return y;
	}

	int fac[maxn], ifac[maxn], r[maxn];

	int C(int n, int m) {
		return m >= 0 && n >= m ? 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod : 0;
	}

	void pre() {
		int n = maxn - 1;
		fac[0] = 1;
		for (int i = 1; i <= n; ++i) {
			fac[i] = 1ll * fac[i - 1] * i % mod;
		}
		ifac[n] = pow_mod(fac[n], mod - 2);
		for (int i = n; i >= 1; --i) {
			ifac[i - 1] = 1ll * ifac[i] * i % mod;
		}
		for (int i = 0; i < maxn; ++i) {
			for (int j = 1; j < maxn; j <<= 1) {
				(r[i] <<= 1) |= ((i & j) ? 1 : 0);
			}
		}
		return;
	}

	const int proot = 3;

	void dft(int *a, bool rev = 0) {
		for (int i = 0; i < maxn; ++i) {
			if (r[i] < i) {
				swap(a[i], a[r[i]]);
			}
		}
		for (int l = 2; l <= maxn; l <<= 1) {
			int hl = l >> 1, wn = pow_mod(proot, (mod - 1) / l);
			if (rev) {
				wn = pow_mod(wn, mod - 2);
			}
			for (int i = 0; i < maxn; i += l) {
				int w = 1;
				for (int j = i, k = i | hl; j < (i | hl); ++j, ++k) {
					int x = a[j], y = 1ll * a[k] * w % mod;
					a[j] = (x + y) % mod;
					a[k] = (x + mod - y) % mod;
					w = 1ll * w * wn % mod;
				}
			}
		}
		if (rev) {
			int inv = pow_mod(maxn, mod - 2);
			for (int i = 0; i < maxn; ++i) {
				a[i] = 1ll * a[i] * inv % mod;
			}
		}
		return;
	}
}

char a[maxn], b[maxn];
int L, n, m;
int dp[maxn], c[maxn];

using namespace math;

int main() {
	math::pre();
	scanf("%s", a);
	scanf("%s", b);
	L = strlen(a);
	for (int i = 0; i < L; ++i) {
		if (a[i] == '1') {
			if (b[i] == '1') {
				++m;
			}
			else {
				++n;
			}
		}
	}
	dp[0] = 1;
	for (int j = 0; j <= m; ++j) {
		c[j] = ifac[j + 1];
	}
	for (int i = 1; i <= n; i <<= 1) {
		dft(c);
		if (n & i) {
			dft(dp);
			for (int j = 0; j < maxn; ++j) {
				dp[j] = 1ll * dp[j] * c[j] % mod;
			}
			dft(dp, 1);
			for (int j = (maxn >> 1) - 10; j < maxn; ++j) {
				dp[j] = 0;
			}
		}
		for (int j = 0; j < maxn; ++j) {
			c[j] = 1ll * c[j] * c[j] % mod;
		}
		dft(c, 1);
		for (int j = (maxn >> 1) - 10; j < maxn; ++j) {
			c[j] = 0;
		}
	}
	int ans = 0;
	for (int j = 0; j <= m; ++j) {
		ans = sum(ans, product(dp[j], fac[n + m]));
	}
	ans = product(ans, product(fac[n], fac[m]));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class BinaryIndexedTree
{
private:
    int n;
    vector<int> data;
public:
    BinaryIndexedTree(int n){ // コンストラクタ
        this->n = n;
        data.assign(n+1, 0);
    }
    void add(int k, int x){ // k番目の要素にxを加算する
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    int sum(int k){ // 区間[0,k]の総和を返す
        ++ k;
        int ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    int sum(int a, int b){ // 区間[a,b]の総和を返す
        return sum(b) - sum(a-1);
    }
};

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

    map<int, int> index;
    for(int i=0; i<n; ++i)
        index[x[i]];
    index[INT_MIN];
    index[INT_MAX];
    int tmp = 0;
    for(auto& p : index){
        p.second = tmp;
        ++ tmp;
    }

    int q;
    cin >> q;
    vector<tuple<int, int, int, int> > v(2*q);
    for(int i=0; i<q; ++i){
        int l, r, e;
        cin >> l >> r >> e;
        int a = min(x[l-1], x[r-1]) - e;
        int b = max(x[l-1], x[r-1]) + e;
        v[2*i] = make_tuple(l-1, a, b, i);
        v[2*i+1] = make_tuple(r, a, b, q+i);
    }
    sort(v.begin(), v.end());

    vector<int> ret(q, 0);
    BinaryIndexedTree bit(index.size());
    int k = 0;
    for(int i=0; i<2*q; ++i){
        int s, a, b, t;
        tie(s, a, b, t) = v[i];

        while(k < s){
            bit.add(index[x[k]], 1);
            ++ k;
        }

        int c = bit.sum(0, (--index.lower_bound(a))->second);
        int d = bit.sum(index.upper_bound(b)->second, index.size() - 1);

        if(t < q)
            ret[t] -= c + d;
        else
            ret[t-q] += c + d;
    }

    for(int i=0; i<q; ++i)
        cout << ret[i] << endl;

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  
  int max=0,maxnum=0,A=0,B=0,k=0;
  
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(a.at(j)>max){
        max=a.at(j);
        maxnum=j;
      }
    }
    
    if(k%2==0)A+=max;
    else B+=max;
    
    a.at(maxnum)=0;
    max=0;
    maxnum=0;
    k++;
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int OperationA(int in_num);
int OperationB(int in_num, int K);

int main() {

	int N, K;
	cin >> N >> K;

	int num = 1;
	int tmp_A, tmp_B;
	for (int i = 0; i < N; i++) {
		tmp_A = OperationA(num);
		tmp_B = OperationB(num, K);
		if (tmp_A > tmp_B) num = tmp_B;
		else num = tmp_A;
	}
	cout << num;
	return 0;
}

int OperationA(int num) {
	num *= 2;
	return num;
}
int OperationB(int num, int K) {
	num += K;
	return num;
}

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int c1=0;
  int ans=max(A,B)+1;
  
  for(int i=max(A,B);c1<K;i--){
    if(A % i ==0 && B % i ==0){c1++;}
    ans--;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    int d,s;
    cin>>d>>t>>s;
    if(t*s<d)cout<<"No";
    else cout<<"Yes";

    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll sum = 0;
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  cout << sum - N << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
    return 0;
}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=1e5+3;

void solve(){
	int n;
	cin>>n;
	vi arr(n);
	fr(i,0,n)
	cin>>arr[i];
	vi freq1(N,0),freq2(N,0);
	for(int i=0;i<n;i+=2){
		freq1[arr[i]]++;
	}
	for(int i=1;i<n;i+=2){
		freq2[arr[i]]++;
	}
	int mx1=0,mx2=0,el1,el2;
	fr(i,0,N){
		if(freq1[i]>=mx1){
			mx1=freq1[i];
			el1=i;
		}
		if(freq2[i]>=mx2){
			mx2=freq2[i];
			el2=i;
		}
	}
	if(el1==el2){
		int mxt1=0,mxt2=0,elt1=-1,elt2=-1;
		fr(i,0,N){
			if(freq1[i]>=mxt1 && i!=el1){
				mxt1=freq1[i];
				elt1=i;
			}
			if(freq2[i]>=mxt2 && i!=el1){
				mxt2=freq2[i];
				elt2=i;
			}
		}
		if(mxt2>mxt1)
			swap(mx2,mxt2);
		else
			swap(mxt1,mx1);
	}
	cout<<n- (mx1+mx2)<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 4500
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Coffee(void) {
	
	string S; cin >> S;
	
	cout << ((S[2] == S[3] && S[4] == S[5]) ? "Yes" : "No");
	return;
}

void B_Golden_Coins(void) {
	
	int X; cin >> X;
	
	int happy = 0;
	happy = int(X / 500) * 1000 + int((X - int(X / 500) * 500) / 5) * 5;
	
	cout << happy << flush;
	return;
}

void C_Traveling_Salesman_around_Lake(void) {
	
	int K, N; cin >> K >> N;
	vector<int> A(N); for (int& it : A) cin >> it;

	int dMax = A[0] + (K - A[N - 1]);
	for (int loop = 1; loop < N; loop++) dMax = max(dMax, A[loop] - A[loop - 1]);

	cout << K - dMax << flush;
	return;
}

int main(void) {
	//A_Coffee();
	//B_Golden_Coins();
	C_Traveling_Salesman_around_Lake();
	return 0;
}


Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto lr = readln.split.to!(long[]);
    auto L = lr[0];
    auto R = lr[1]+1;

    long x = long.max;
    foreach (l; L..min(L+2020, R)) {
        foreach (r; l+1..min(L+2020,R)) {
            x = min(x, (l*r)%2019L);
        }
    }
    writeln(x);
}

Measured memory_bytes: 256
/* Manish Pant - insider_pants */
    
#include <bits/stdc++.h>
using namespace std;
    
#define F first
#define S second
#define endl "\n"
#define pb push_back
    
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
    
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

string s;
void solve()
{
    set<char> ss;
    for(char i:s) ss.insert(i);

    if(ss.size() > 1) cout<<"Yes\n";
    else cout<<"No\n";
}

int main()
{
    fast();
    cin>>s;
    solve();
}

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

int main(void){
  char s[12], t[12];
  int a, b;
  char u[12];
  int i;
  int flg_s = 1;
  int flg_t = 1;

  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);

  for(i=0; i<strlen(s); i++)
    if(s[i] != u[i]){
      flg_s = 0;
      break;
    }

  for(i=0; i<strlen(t); i++)
    if(t[i] != u[i]){
      flg_t = 0;
      break;
    }
  
  if (flg_s == 1)
    a--;
  else if(flg_t == 1)
    b--;

  printf("%d %d\n", a, b);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

class Dice
{
	
private:
	int pips[6];
	
public:
	Dice(const int*);
	int get_top();
	void roll_north();
	void roll_south();
	void roll_east();
	void roll_west();
	bool compare(const Dice*);
};

///////////////////////////////////////
Dice::Dice(const int* pips)
{
	for(int i = 0; i < 6; ++i)
	{
		this->pips[i] = pips[i];
	}
	
	srand( time(NULL) );
}

///////////////////////////////////////
int Dice::get_top()
{
	return pips[0];
}

////////////////////////////////////////
void Dice::roll_north()
{
	int temp;
	temp = pips[0];
    pips[0] = pips[1];
    pips[1] = pips[5];
    pips[5] = pips[4];
    pips[4] = temp;
}

////////////////////////////////////////
void Dice::roll_south()
{
	int temp;
	temp = pips[0];
    pips[0] = pips[4];
    pips[4] = pips[5];
    pips[5] = pips[1];
    pips[1] = temp;
}

////////////////////////////////////////
void Dice::roll_east()
{
	int temp;
	temp = pips[0];
    pips[0] = pips[3];
    pips[3] = pips[5];
    pips[5] = pips[2];
    pips[2] = temp;
}

////////////////////////////////////////
void Dice::roll_west()
{
	int temp;
	temp = pips[0];
    pips[0] = pips[2];
    pips[2] = pips[5];
    pips[5] = pips[3];
    pips[3] = temp;
}

//////////////////////////////////////////
bool Dice::compare(const Dice* other)
{
	for(int i = 0; i < 6; ++i){
		if(i == 4) roll_east();
		if(i == 5) roll_north();
		roll_north();
		
		for(int j = 0; j < 4; ++j){
			roll_east();
			
			for(int k = 0; k < 6; ++k){
				if(pips[k] != other->pips[k]) break;
				if(k == 5) return true;
			}}}
	
	return false;
}





int main()
{
	
	int pips[6];
	
	
	for(int i = 0; i < 6; ++i)
	{
		cin >> pips[i];
	}
	Dice diceA(pips);
	
	
	for(int i = 0; i < 6; ++i)
	{
		cin >> pips[i];
	}
	Dice diceB(pips);
	
	
	if(diceA.compare(&diceB)) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<ll> A(N), S(N + 1, 0);
    rep(i, N) cin >> A[i];
    rep(i, N) {
        S[i + 1] += S[i] + A[i];
    }
    map<ll, ll> counter;
    rep(i, N + 1) {
        counter[S[i]]++;
    }
    ll ans = 0;
    for (P p : counter) {
        ans += (p.second - 1) * p.second / 2;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 15872
def gcd a, b
    y, x = [a, b].minmax
    step = 0
    while y != 0
        x = x % y
        x, y = y, x
        step += 1
    end
    return [x, step]
end

while true
    a, b = gets.chomp.split.map(&:to_i)
    break if [a, b] == [0, 0]
    puts gcd(a, b).join(" ")
end


Measured memory_bytes: 6888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		int max = H * W;
		int hRes = 	h * W;
		int wRes = w * (H - h);

		System.out.println(max - (hRes + wRes));

		sc.close();
	}
}

Measured memory_bytes: 23252
#include <vector>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <climits>
using namespace std;
typedef long long ll;

int main() {
  ll k, a, b;
  scanf("%lld %lld %lld", &k, &a, &b);

  ll ans = 1;
  if (b - a <= 2 || k < a) {
    ans += k;
  } else {
    k -= a - 1;
    ans += a - 1;
    ll n = k / 2;
    ans += n * (b - a);
    if (k & 1) ans++;
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main()
{
	int blue,red;
  	map<string,int> string_count;
	cin>>blue;
  	string str;
  	for(int i=0 ; i<blue ; ++i)
    {
    	cin>>str;
      	++string_count[str];
	}
  	cin>>red;
  	for(int i=0 ; i<red ; ++i)
    {
    	cin>>str;
    	--string_count[str];
    }
	int ans=0;
  	for(auto &i:string_count)
    {
    	ans=max(ans,i.second);
    }
  	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define Mod 998244353

int main()
{
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	if (A == C && B == D) {
		printf("1\n");
		fflush(stdout);
		return 0;
	}
	
	int i, j;
	long long dp[2][3002] = {};
	dp[0][0] = 1;
	for (j = 1; j <= D - B; j++) dp[0][j] = dp[0][j-1] * A % Mod;
	for (i = 1; i <= C - A; i++) {
		dp[i%2][0] = dp[1-i%2][0] * B % Mod;
		for (j = 1; j <= D - B; j++) dp[i%2][j] = (dp[i%2][j-1] * (A + i) + dp[1-i%2][j] * (B + j) - dp[1-i%2][j-1] * (A + i - 1) * (B + j - 1)) % Mod;
	}
	
	printf("%lld\n", (dp[(C-A)%2][D-B] >= 0)? dp[(C-A)%2][D-B]: dp[(C-A)%2][D-B] + Mod);
	fflush(stdout);
	return 0; 
}

Measured memory_bytes: 1780
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int a[105];

int main() {
//	freopen("/Users/liyingyan/Documents/ACM/in.txt", "r", stdin);
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	int cnt = 0;
	int flag = 1;
	while(flag) {
		flag = 0;
		for(int i = 0; i<n-1; i++) {
			if(a[i] > a[i+1]) {
				swap(a[i], a[i+1]);
				flag = 1;
				cnt++;
			} 
		}
	}
	for(int i=0; i<n; i++) {
		cout << a[i];
		if(i == n-1) cout << endl;
		else cout << " ";
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3220
import sys
input = sys.stdin.readline
from itertools import combinations_with_replacement
def main():
    N, M, Q = map(int, input().split())
    q_list = []
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        q_list.append((a, b, c, d))
    A = combinations_with_replacement(range(1, M+1), N)
    ans = 0
    for Ai in A:
        v = 0
        Ai = list(map(int, Ai))
        for a, b, c, d in q_list:
            if Ai[b-1]-Ai[a-1] == c:v += d
        ans = max(ans, v)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 68436
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n, f[100], s[100];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> f[i];
    for (int i = 0; i < n; i++) cin >> s[i];
    int res = 0;
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j <= i; j++) sum += f[j];
        for (int j = i; j < n; j++) sum += s[j];
        res = max(res, sum);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  vii A(3,vi(3));
  rep(i,0,3){
    rep(j,0,3) cin>>A[i][j];
  }
  vector<vector<bool>> F(3,vector<bool>(3));
  int N; cin>>N;
  rep(_,0,N){
    int X; cin>>X;
    rep(i,0,3){
      rep(j,0,3){
        if(A[i][j]==X) F[i][j]=1;
      }
    }
  }
  string ans="No";
  rep(i,0,3){
    if(F[i][0]&&F[i][1]&&F[i][2]) ans="Yes";
  }
  rep(i,0,3){
    if(F[0][i]&&F[1][i]&&F[2][i]) ans="Yes";
  }
  if(F[0][0]&&F[1][1]&&F[2][2]) ans="Yes";
  if(F[0][2]&&F[1][1]&&F[0][2]) ans="Yes";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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 (b<a) { a=b; return 1; } return 0; }

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,K;
    cin >> N >> K;
    ll ans = K;
    rep(i, N - 1) ans *= (K - 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
#include<iomanip>
#include<cmath>
using std::cin; using std::string;
using std::cout; using std::endl;
using std::sort;
#define rep(X,Y) for(int (X)=0;(X)<(Y);++(X))
#define rept(X,Y,Z) for(int (X)=(Y);(X)<(Z);++(X))
#define repr(X,Y) for(int (X)=(Y);(X)>=0;--(X))
const double pi=3.141592653589793283462;
int main(){
    int n[10];
	int s=0;
	for(int i=0;i<10;i++){
		cin>>n[i];
		s+=n[i];
	}
	cout<<s<<endl;
	return 0;
}      

Measured memory_bytes: 1160
#JMD
#Nagendra Jha-4096

 
import sys
import math

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

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

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

int n;

int main(){
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n-1; i++){
		cout << a[n - 1 - i] << " ";
	}
	cout << a[0] << endl;
	return 0;
}

Measured memory_bytes: 1160
def partition(A,p,r):
    x=A[r]
    i=p-1
    for j in range(p,r):
        if A[j]<=x:
            i +=1
            A[i],A[j]=A[j],A[i]
    A[i+1],A[r]=A[r],A[i+1]
    return i+1


n=int(input())
A=list(map(int,input().split()))

P=partition(A,0,n-1)
A[P]="["+str(A[P])+"]"
print(*A)


Measured memory_bytes: 16392
n, k = gets.chop.split.map(&:to_i)
h = []
n.times { h << gets.to_i }
h.sort!
hdiff = 1000000000
n.times do |i|
  break if h[i+k-1] == nil
  hdiff = [h[i+k-1] - h[i], hdiff].min
end
puts hdiff

Measured memory_bytes: 4016
#include<stdio.h>
#include<stdlib.h>
#define d_flag 0




/// Queue! ///
int Q[100001];
int head=0;
int tail=0;
void inque(int a){
  Q[tail++]=a;
}
int deque(){
  return Q[head++];
}
void print_que(){
  int i;
  printf("\nQ: [");
  for(i=head;i<tail;i++)
    printf(" %d",Q[i]);
  printf(" ]%d...%d\n",head,tail-1);
}


/// list! ///
typedef char bool;
typedef struct{
  int u;
  int w;
} item;

typedef struct _cell
{
  item car;
  struct _cell *cdr;
} cell;



#define NULL_ITEM (item){-1,0};
cell* make_cell(item val);
void delete_cell(cell* cp);
cell* cons(item val,cell* cp,bool *err);
item pop(cell** cpp, bool *err);

void print_item(item val);
void print_list(cell* cp);


int main(){
  int n;
  bool err;
  scanf("%d",&n);
  cell* G[n+1];
  int color[n+1];
  int i,u,v,w;

  for(i=1;i<=n;i++){
    G[i]=NULL;
    color[i]=-1;
  }
  
  for(i=0;i<n-1;i++){
    scanf("%d%d%d",&u,&v,&w);
    G[u]=cons((item){v,w},G[u],&err);
    G[v]=cons((item){u,w},G[v],&err);
  }

  if(d_flag){
    for(i=1;i<=n;i++){
      printf("%d: ",i);
      print_list(G[i]);
    }
  }
  color[1]=0;
  inque(1);
  item x;
  int temp;
  while(head!=tail){
  if(d_flag) print_que();
    temp=deque();
    do{
      if(d_flag) {
	printf("\n%d:",temp);
	print_list(G[temp]);
      }
      x=pop(&G[temp],&err);
      if(d_flag){
	printf("x: ");
	print_item(x);
	printf(", color=%d",color[x.u]);
      }
      if(color[x.u]!=-1) continue;
      inque(x.u);
      color[x.u]=color[temp]^(x.w&1);
      if(d_flag)
	printf(" -> %d",color[x.u]);
    }while(G[temp]!=NULL);
  }
if(d_flag) printf("\n");
for(i=1;i<=n;i++)
  printf("%d\n",color[i]);
}

cell* make_cell(item val)
{
  cell* ncellp=malloc(sizeof(cell));
  if(ncellp!=NULL)
    {
      ncellp->car=val;
      ncellp->cdr=NULL;
    }
  else
    printf("not enough memory.\n");
  return ncellp;
}


void delete_cell(cell* cp)
{
  cell* temp=cp,*next;
  while(temp!=NULL)
    {
      next=temp->cdr;
      free(temp);
      temp=next;
    }
}

cell* cons(item val,cell* cp,bool *err)
{
  cell* top=make_cell(val);
  if(top!=NULL)
    {
      *err=1;
      top->cdr=cp;
      return top;
    }
  *err=0;
  return cp;
}

item pop(cell** cpp, bool *err)
{
  if(*cpp==NULL)
    {
      *err=0;
      printf("nil.\n");
      return NULL_ITEM;
    }

  item it=(*cpp)->car;
  cell* temp=(*cpp)->cdr;
  *err=1;
  free(*cpp);
  *cpp=temp;
  return it;
}


void print_item(item val)
{
  printf("%d(%d)",val.u,val.w);
}

void print_list(cell* cp)
{
  cell* temp=cp;
  printf("[");
  while(temp!=NULL)
    {
      printf(" ");
      print_item(temp->car);
      temp=temp->cdr;
    }
  printf(" ]\n");
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	V add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};

BIT<ll,20> bt;
int N,M;
vector<int> E[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>x>>y;
		E[y-x+1].push_back(x);
	}
	
	int morethan=N;
	for(i=1;i<=M;i++) {
		int ret=0;
		for(x=i;x<=M;x+=i) ret+=bt(x);
		
		FORR(e,E[i]) bt.add(e,1), bt.add(e+i,-1);
		cout<<morethan+ret<<endl;
		morethan -= E[i].size();
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 7296
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, x[3009], y[3009]; bool ok[5009][5009];
int main() {
	while (scanf("%d", &n), n) {
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &x[i], &y[i]);
			ok[x[i]][y[i]] = true;
		}
		int ret = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int va = x[j] - x[i], vb = y[j] - y[i];
				int ex = x[i] + vb, ey = y[i] - va;
				int fx = x[j] + vb, fy = y[j] - va;
				if (0 <= ex && ex <= 5000 && 0 <= ey && ey <= 5000 && 0 <= fx && fx <= 5000 && 0 <= fy && fy <= 5000 && ok[ex][ey] && ok[fx][fy]) {
					ret = max(ret, va * va + vb * vb);
				}
			}
		}
		printf("%d\n", ret);
		for (int i = 0; i < n; i++) ok[x[i]][y[i]] = false;
	}
	return 0;
}

Measured memory_bytes: 22840
#include <iostream>
#include<string>
#include<stack>
#include <vector>
#include <math.h>
#include <array>
#include <algorithm>
using namespace std;
int main(){
long long n,m,x;
cin>> n>> m;
int a[60]={0};

for(int i=0;i<m*2;i++){
	cin>>x;
	a[x]++;
}
for(int i=1;i<=n;i++)
	cout<<a[i]<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;

int solve(int n, int m){
	int a = 1, b = 1;
	for(int i = 1;i <= n;i++){
		a *= i;
		a %= mod;
	}
	for(int i = 1;i <= m;i++){
		b *= i;
		b %= mod;
	}
	int ans = a*b;
	ans %= mod;
	if(n == m)ans *= 2;
	return ans % mod;
}

signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	if(llabs(n-m) > 1){
		printf("0\n");
		return 0;
	}
	printf("%lld\n", solve(n, m));
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative

main :: IO()
main = do
    _ <- getLine
    l <- reverse . map read . words <$> getLine
    putStrLn $ calcAns l (2,2)
        where
            calcAns _ (l,r) | l > r = "-1"
            calcAns [] (l,r) = show l ++ ' ' : show r
            calcAns (a:b:rest) lr
                | mod a b == 0 = calcAns (a:rest) lr
                | mod b a == 0 = calcAns (b:rest) lr
            calcAns (a:as) (l,r) = calcAns as ((l - 1) `div` a * a + a, r `div` a * a + a - 1)


Measured memory_bytes: 62844
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int a,b,c;
cin>>a>>b>>c;

if((c) < (a+b)){
    cout<<"No"<<endl;
}
else if(4*a*b < ((c-a-b)*(c-a-b))){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
    return 0;
}


Measured memory_bytes: 3616
n, m, x=map(int, input().split())

book=[list(map(int, input().split())) for i in range(n)]

costs=[]

for i in range(2**n):
    t=[0]*m
    cost=0
    for j in range(n):
        if ((i>>j)&1)==1:
            for k in range(m):
                t[k]+=book[j][k+1]
            cost+=book[j][0]
        
    if all(t[l]>=x for l in range(m)):
        costs.append(cost)

if len(costs)==0:
    print(-1)
else:
    print(min(costs))

Measured memory_bytes: 9220
while True:
    x = input().split()
    a = int(x[0])
    b = int(x[1])
    if a == 0 and b == 0:
        break
    elif a > b:
        print('{0} {1}'.format(b, a))
    else:
        print('{0} {1}'.format(a, b))

Measured memory_bytes: 7656
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var N = NextLong();
		var S = ReadLine();
		var cnt = 0;
		var ans = 0;

		foreach (var c in S) {
			switch (c) {
				case 'I':
					cnt++;
					break;
				case 'D':
					cnt--;
					break;
				default:
					break;
			}
			ans = Math.Max(ans, cnt);
		}
		WriteLine(ans);
	}
	static long NextLong() {
		return long.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}


Measured memory_bytes: 13268
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

#maincode-------------------------------------------------
x = ini()
n = 100
c = 0
while n < x:
    n += n//100 
    c += 1
print(c)

Measured memory_bytes: 62828
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)
#define IN(v) cin>>(v)
#define OUT(v) cout>>(v)>>endl

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

int main() {
  int N, X;
  cin >> N >> X;

  vector<LL> x;
  x.PB(X);
  REP(i, N) {
    LL _x;
    cin >> _x;
    x.PB(_x);
  }
  SORT(x);
  vector<LL> distance;
  LL before = *(x.begin());
  for (auto it = x.begin() + 1; it != x.end(); ++it) {
    distance.PB(*it - before);
    before = *it;
  }
  SORT(distance);
  LL res = *(distance.begin());
  for (const auto& e : distance)
    res = gcd(res, e);
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2548
import copy
def decision(a):
    #print(a)
    #print(data)
    #print(count)
    if a == 123456789:
        print(count)
        exit()
    if a in data:
        pass
    else:
        data[a] = 1
        kariokiba.append(a)
        #print(a)
        #print(data)


def str_create(i, j, h):
    h = h[:i] + h[j] + h[i+1:j] + h[i] + h[j+1:]
    #print(h)
    decision(int(h))


def create(a):
    #print(a)
    a = str(a)
    place = a.find('9')
    #print(place)
    b = c = d = e = a
    if place == 0:
        str_create(0, 1, b)
        str_create(0, 3, c)
    elif place == 1:
        str_create(0, 1, b)
        str_create(1, 2, c)
        str_create(1, 4, d)
    elif place == 2:
        str_create(1, 2, b)
        str_create(2, 5, c)
    elif place == 3:
        str_create(0, 3, b)
        str_create(3, 4, c)
        str_create(3, 6, d)
    elif place == 4:
        str_create(1, 4, b)
        str_create(3, 4, c)
        str_create(4, 5, d)
        str_create(4, 7, e)
    elif place == 5:
        str_create(2, 5, b)
        str_create(4, 5, c)
        str_create(5, 8, d)
    elif place == 6:
        str_create(3, 6, b)
        str_create(6, 7, c)
    elif place == 7:
        str_create(6, 7, b)
        str_create(4, 7, c)
        str_create(7, 8, d)
    elif place == 8:
        str_create(5, 8, b)
        str_create(7, 8, c)



tmp0 = [list(map(int, input().split())) for _ in range(3)]
data = {}
tmp1 = 0
kariokiba = []
kariokiba1 = []
for i in tmp0:
    for j in i:
        if j == 0:
            j = 9
        tmp1 *= 10
        tmp1 += j
data[tmp1] = 1
#print(data)
#print(tmp1)
tmp1 = str(tmp1)
count = 0
kariokiba.append(int(tmp1))

if tmp1 == '123456789':
    print(0)
    exit()
'''
create(tmp1)
print(kariokiba)
#print(data)

'''
while True:
    #print(kariokiba)
    kariokiba1 = copy.deepcopy(kariokiba)
    kariokiba.clear()
    count += 1
    #print(count)
    #print(data)
    for i in kariokiba1:
        create(i)




Measured memory_bytes: 27840
#include "bits/stdc++.h"
using namespace std;

constexpr long long MOD = 998244353;

int main() {
	int N, X, Y = 1;
	cin >> N >> X;
	while (Y <= X) Y *= 2;
	vector<vector<long long> > DP(N + 1, vector<long long>(Y, 0));
	DP[0][0] = 1;
	for (int i = 1; i <= X; i++) {
		vector<vector<long long> > DP2(N + 1, vector<long long>(Y, 0));
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k < Y; k++) {
				DP2[j][k] += DP[j][k];
				DP2[j][k] %= MOD;
				if (j < N) {
					DP2[j + 1][k ^ i] += DP[j][k];
					DP2[j + 1][k ^ i] %= MOD;
				}
			}
		}
		for (int j = 0; j <= N - 2; j++) {
			for (int k = 0; k < Y; k++) {
				DP2[j + 2][k] += DP2[j][k];
				DP2[j + 2][k] %= MOD;
			}
		}
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k < Y; k++) DP[j][k] = DP2[j][k];
		}
	}
	long long ANS = 0;
	for (int i = 0; i <= N; i++) ANS += DP[i][X], ANS %= MOD;
	cout << ANS << endl;
}


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

string s;
cin >> s;

bool x = true;

rep(i,s.size()){
    if(i%2 == 0){
        if(s[i] == 'L') x = false;
    }else{
        if(s[i] == 'R') x = false;
    }
}

if(x) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

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

int main()
{
	int n;
	string blue[110];
	string red[110];

	cin >> n;

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

	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> red[i];
	}

	int t = 0;
	for (int i = 0; i < n; i++)
	{
		int money = 0;
		for (int j = 0; j < n; j++)
		{
			if (blue[i] == blue[j])
			{
				money += 1;
			}

		}
		for (int k = 0; k < m; k++)
		{


			if (blue[i] == red[k])
			{
				money -= 1;
			}
		}
		if (t < money)
			{
				t = money;

			}
		}

	cout << t << endl;
	return 0;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]!='0' || s[0]!='1'){
		cout<<-1<<endl;
		return;
	}
	fr(i,0,n/2){
		if(s[i]!=s[n-1-i-1]){
			cout<<-1<<endl;
			return;
		}
	}
	vpii edges;
	edges.pb({1,2});
	int par=0;
	fr(i,1,n-1){
		edges.pb({par+1,i+2});
		if(s[i]=='1'){
			par=i+1;
		}
	}
	for(auto e: edges){
		cout<<e.first<<" "<<e.second<<endl;
	}
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=998244353;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
  ll a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll ans=1e9;
  rep(i,max(x,y)+1){
    ans=min(ans,i*2*c+max(x-i,0ll)*a+max(y-i,0ll)*b);
  }
  cout << ans << endl;
  return 0;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	getline(cin,a);
	getline(cin,b);
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	if(a<b)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define in inline
#define reg register
//#define int long long
#define MAX 20030813
using namespace std;
namespace qwq{
	in void read(int &o) {
		o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9') {
			if(c=='-')w*=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9') {
			o=(o<<3)+(o<<1)+(c^48);c=getchar();
		}
		o*=w;
	}
	void write(int x){
	   	if(x<0)putchar('-'),x=-x;
    	if(x>9)write(x/10);
		putchar(x%10+48);
	}
	void Write(int x) {
		write(x);putchar(' ');
	}
	in int max(int x,int y){return x>y?x:y;}
	in int min(int x,int y){return x<y?x:y;}
}
using namespace qwq;
int N;
double ans;
signed main()
{
	read(N);
	ans=(double)((N+1)/2)/N;
	printf("%.10lf",ans);
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
char b[1005];
int p;
int main(){
	getline(cin,a);
	for(int i=0;i<a.size();i++){
		if(a[i]=='B'){
			if(p>=1) p--;
		} 
		else b[++p]=a[i]; 
	}
	for(int i=1;i<=p;i++) cout<<b[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,b) for(int i= 0; i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define MOD 1000000007
const int N = 2e5+7 ;
string s ;

int main(){fast ;
	int n,k ;
	cin >> n >> k ;
	vector<int> a(n+5,0) ;
	F(i,k){
		int u , v ;
		cin >> u >> v ;
		a[v+1]-- ;
		a[u]++ ;
	}
	int cnt = 0 ;
	for(int i = 1 ; i <= n ; i++){
		a[i] += a[i-1] ;
		if(a[i] == k)
			cnt++ ;
	}
	cout << cnt << endl ;
	
}





Measured memory_bytes: 640
n = int(input())
p_index = [0] * n
for i in range(n):
    p_index[int(input())-1] = i
prev = 10**9
ans = 0
val = 1
for item in p_index:
    if prev > item:
        val = 1
    else:
        val += 1
    prev = item
    ans = max(ans, val)
print(n-ans)

Measured memory_bytes: 10940