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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

long long gcd(long long a, long long b) {
  if (min(a, b) == 0) {
    return max(a, b);
  }
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}

long long lcm(long long a, long long b) {
  if (min(a, b) == 0) {
    return max(a, b);
  }
  return a / gcd(a, b) * b;
}

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve() {
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  i64 L = lcm((i64) n, (i64) m);
  vector<map<int, char>> cs(2);
  rep(i, n) cs[0][L / n * i] = s[i];
  rep(i, m) cs[1][L / m * i] = t[i];
  for (auto p : cs[0]) {
    if (cs[1].count(p.first) && cs[1][p.first] != p.second) {
      cout << -1 << endl;
      return;
    }
  }
  cout << L << endl;
}


Measured memory_bytes: 8192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);
        input = Console.ReadLine().Split();
        double[] A = new double[N];
        for(int i = 0; i < N; i++)
        {
            A[i] = int.Parse(input[i]);
        }
        int num = 0;
        for(int i = 0; i < N; i++)
        {
            if (A[i] >= A.Sum() / 4 / M) { num++; }
        }
        if (num >= M) { Console.WriteLine("Yes"); }
        else { Console.WriteLine("No"); }

    }
}

Measured memory_bytes: 13268
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

const ll MX = 1e18;

int main () {
    int n; cin >> n;
    ll ans = 1;
    bool flag = false;
    rep(i, n) {
        ll a; cin >> a;
        if (a == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (flag || MX/ans<a) flag = true;
        ans *= a;
    }
    if (flag) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import collections
h,w=map(int,input().split())
a=""
for i in range(h):
    a+=input()
f,o=1,0
for i in collections.Counter(a).values():
    f+=i//4
    o+=i&1
print(["No","Yes"][f>(h//2)*(w//2) and o<=h%2*w%2])

Measured memory_bytes: 38640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

vector<vector<int>> multi(vector<vector<int>> m1, vector<vector<int>> m2,int M)
{
	vector<vector<int>> ans(m1.size(), vector<int>(m2[0].size(), 0));

	rep(i, m1.size()) {
		rep(j, m2[0].size()) {
			rep(k, m1[0].size()) {
				ans[i][j] += m1[i][k] * m2[k][j];
			}

			ans[i][j] %= M;
		}
	}

	return ans;
}

vector<vector<int>> mypow(vector<vector<int>> matrix, int n, int M)
{
	if (n == 0) {
		vector<vector<int>> I(matrix.size(), vector<int>(matrix.size(), 0));

		rep(i, matrix.size()) {
			I[i][i] = 1;
		}

		return I;
	}
	else if (n % 2 == 0) {
		return mypow(multi(matrix, matrix, M), n / 2, M);
	}
	else {
		return multi(mypow(multi(matrix, matrix, M), n / 2, M), matrix, M);
	}
}

int main()
{
	while (true) {
		int N, M, A, B, C, T;

		cin >> N >> M >> A >> B >> C >> T;

		if (N == 0 && M == 0 && A == 0 && B == 0 && C == 0 && T == 0) {
			break;
		}

		vector<int> t_zero(N);

		rep(i, N) {
			cin >> t_zero[i];
		}

		if (T == 0) {
			rep(i, N) {
				cout << t_zero[i];

				if (i == N - 1) {
					cout << endl;
				}
				else {
					cout << " ";
				}
			}

			continue;
		}

		vector<vector<int>> matrix(N, vector<int>(N, 0));

		rep(i, N) {
			if (i - 1 >= 0) {
				matrix[i][i - 1] = A;
			}

			matrix[i][i] = B;

			if (i + 1 < N) {
				matrix[i][i + 1] = C;
			}
		}

		matrix = mypow(matrix, T, M);

		vector<int> ans(N, 0);

		rep(i, N) {
			rep(j, N) {
				ans[i] += matrix[i][j] * t_zero[j];
			}

			ans[i] %= M;
		}

		rep(i, N) {
			cout << ans[i];

			if (i == N - 1) {
				cout << endl;
			}
			else {
				cout << " ";
			}
		}
	}


	return 0;
}

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

int main() {
  int a, b, c,d;
  cin >>a >> b >> c >>d ;
  if(abs(c-a) <= d ||(abs(b-a)<=d && abs(c-b)<= d))
  std::cout << "Yes" << endl;
  else
  std::cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

ll INF = 1001001001001;

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

    ll n, m;
    cin>>n>>m;
    vector<ll> es(n, INF);
    rep(i, m) {
        ll e1, e2;
        cin>>e1>>e2; e1--; e2--;
        es[e1] = min(es[e1], e2);
    }
    ll mi = INF;
    ll cnt = 0;
    rep(i, n) {
        if (i == mi) {
            cnt++;
            mi = INF;
        }
        mi = min(mi, es[i]);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
L = [list(input().split()) for _ in range(M)]
D_1 = {str(c):False for c in range(1, N+1)}
D_2 = {str(c):0 for c in range(1, N+1)}
for l in L:
  if l[1]=="WA" and D_1[l[0]]==False:
      D_2[l[0]] += 1 
  else:
    D_1[l[0]]=True
S_1 = sum(D_2[k] for k, v in D_1.items() if v)  
S_2 = sum(D_1.values())
print(S_2, S_1)

Measured memory_bytes: 57888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[102] = {}, z = 1890328;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = -100; i <= 100; i++) {
        int c = 0;
        for (int j = 0; j < n; j++) c += (a[j] - i) * (a[j] - i);
        z = min(z, c);
    }
    cout << z;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while(b <= a) {
        b *= 2;
        cnt ++;
    }
    while(c <= b) {
        c *= 2;
        cnt ++;
    }
    if(cnt <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
import math
LI = lambda: list(map(int,input().split()) )
MI = lambda: map(int,input().split())
SI = lambda: input()
II = lambda: int(input())
n = II()
l = [0]*(10**4+1)
m = 10**4
lim = int(m**0.5)+1
for i in range(1,lim):
    for j in range(i,lim):
        for z in range(j,lim):
            s = i**2+j**2+z**2+i*j+i*z+j*z
            if s>m:
                continue
            if i == j == z:
                l[s] += 1
            elif i == j or j == z or i == z:
                l[s] += 3
            else:
                l[s] += 6
for i in range(1,n+1):
    print(l[i])

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int x; cin>>x;
    if(x==0){
     cout<<1<<endl;  
    }else{
     cout<<0<<endl;  
    }

    return 0;
}

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

int main(){
  string s,t;
  cin >>s>>t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  
  string ans;
  rep(i,0,s.size()){
    if(t[i]>s[i]){
      ans = "Yes";
      break;
    }else if(t[i]<s[i]){
      ans = "No";
      break;
    }else if(t[i]==s[i] and i==s.size()-1){
      t.size()>s.size() ?  ans = "Yes" : ans = "No";
    }
  }
  cout <<ans<< endl;
}

Measured memory_bytes: 256
from collections import Counter as C
n = int(input())
s = input()

res = 0
for i in range(1,n):
    a = s[:i]
    b = s[i:]
    tmp = 0
    for k in C(a):
        if k in b:
            tmp += 1
    res = max(res,tmp)
print(res)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans;
    if(b > n) {
        ans = floor(a * n / b) - a * floor(n / b);
    } else if(b == n) {
        n--;
        ans = floor(a * n / b) - a * floor(n / b);
    } else {
        n = b - 1;
        ans = floor(a * n / b) - a * floor(n / b);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


// 素因数分解(first要素がfactで、second要素がその個数)
vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long ModPow(long long N, long long P, long long Mod){
    if(P == 0) return 1;
    if(P%2 == 0) {
        ll t = ModPow(N, P/2, Mod);
        return t % Mod * t % Mod;
    }
    return N * ModPow(N, P-1, Mod) % Mod;
}

long long ModInv(long long N, long long Mod) {
    return ModPow(N, Mod - 2, Mod);
}

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    map<ll, ll> m;
    rep(i, n){
        auto fact = prime_factorize(v[i]);
        for(auto p: fact){
            m[p.first] = max(m[p.first], p.second);
        }
    }

    ll lcm = 1;
    for(auto p: m){
        lcm *= ModPow(p.first, p.second, MOD);
        lcm %= MOD;
    }

    ll ans = 0;
    rep(i, n){
        ans +=  (lcm * ModInv(v[i], MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    string s;
    cin >> s;
    int a = 0;
    int z = s.length()-1;
    while(s[a] != 'A') a++;
    while(s[z] != 'Z') z--;
    cout << z-a+1 << endl;
    return 0;
}


Measured memory_bytes: 640
from collections import Counter
h,w=map(int,input().split())
s=""
for i in range(h):
  s+=input()
sc=Counter(s)
d=[0,0,0]
for v in sc.values():
    d[0]+=(v//4)*4
    d[1]+=2 if v%4>=2 else 0
    d[2]+=v%2

if w%2==0 and h%2==0:
  print("Yes" if d[0]==h*w else "No")
elif (w%2)*(h%2)==1:
  print("Yes" if d[1]<=(w-1)+(h-1) and d[2]==1 else "No")
elif w%2==0:
  print("Yes" if d[1]<=w and d[2]==0 else "No")
elif h%2==0:
  print("Yes" if d[1]<=h and d[2]==0 else "No")



Measured memory_bytes: 9476
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
     ll n,i,j,m,c,mx=0,T,ans=0,r,k=0,p=0,q,x,y,l;
     string s,t;
     cin>>s>>t;
     ll mn=INT_MAX;
     l=s.size(),y=t.size();
     for(i=0;i<=l-y;i++)
     {
         k=0;
         for(j=0;j<y;j++)
         {
             if(t[j]==s[i+j])
                k++;
         }
         mn=min(mn,y-k);
     }
     cout<<mn<<endl;
}






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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

struct Edge { int from, to; double cost; };

ll shortest_path(vector<Edge> &es, int N)
{   
    double INF = numeric_limits<double>::max();

    vector<double> d(N, INF);
    d[0] = 0LL;
    for (int i=0; i<N; i++) {
        bool updated = false;
        for (auto e : es) {
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                updated = true;

                if (i == N-1 && e.to == N-1) {
                    cout << "inf" << endl;
                    exit(0);
                }
            }
        }
        if (!updated) break;
    }
    return d[N-1];
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<Edge> es(M), es2(M);
    rep(i, M) {
        int A, B;
        double C;
        cin >> A >> B >> C;
        es[i] = {A-1, B-1, -C};
    }

    cout << -shortest_path(es, N) << endl;
}


Measured memory_bytes: 384
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if
#define Lsn (x<<1)
#define Rsn (x<<1|1)
#define Mid ((L+R)>>1)

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;
typedef pair<int,ll> pil;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;
const ll oo=1ll<<60;

ll F[N],mn1[N*4],mn2[N*4];
ll tmp1,tmp2,plu,ans;
int x[N],n,q,s,t,Ql,Qr,Qx;

void Build(int x,int L,int R){
	if (L==R){
		mn1[x]=F[L]-L;
		mn2[x]=F[L]+L;
		return;
	}
	Build(Lsn,L,Mid);
	Build(Rsn,Mid+1,R);
	mn1[x]=min(mn1[Lsn],mn1[Rsn]);
	mn2[x]=min(mn2[Lsn],mn2[Rsn]);
}
void Update(int x,int L,int R){
	if (L==R){
		mn1[x]=F[L]-L;
		mn2[x]=F[L]+L;
		return;
	}
	Qx<=Mid?Update(Lsn,L,Mid):Update(Rsn,Mid+1,R);
	mn1[x]=min(mn1[Lsn],mn1[Rsn]);
	mn2[x]=min(mn2[Lsn],mn2[Rsn]);
}
void Query(int x,int L,int R){
	if (Ql<=L&&R<=Qr){
		tmp1=min(tmp1,mn1[x]);
		tmp2=min(tmp2,mn2[x]);
		return;
	}
	if (Ql<=Mid) Query(Lsn,L,Mid);
	if (Qr>Mid) Query(Rsn,Mid+1,R);
}

int main(){
	n=IN(),q=IN(),s=IN(),t=IN();
	For(i,1,q+1) x[i]=IN();
	For(i,1,n+1) F[i]=oo;
	F[s]=min(F[s],0ll+abs(x[1]-t));
	F[t]=min(F[t],0ll+abs(x[1]-s));
	Build(1,1,n);
	For(i,2,q+1){
		ll val=oo;
		tmp1=tmp2=oo;
		Ql=1,Qr=x[i],Query(1,1,n);
		val=min(val,tmp1+x[i]);
		tmp1=tmp2=oo;
		Ql=x[i],Qr=n,Query(1,1,n);
		val=min(val,tmp2-x[i]);
		val+=plu;
		plu+=abs(x[i]-x[i-1]);
		F[x[i-1]]=min(F[x[i-1]],val-plu);
		Qx=x[i-1];
		Update(1,1,n);
	}
	ans=oo;
	For(i,1,n+1) ans=min(ans,F[i]);
	cout<<ans+plu<<endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	ll ans = 0;
	cin >> n;
	VPi data(n);
	cin >> data;
	V sum, diff;
	rep(i, n) {
		sum.pb(data[i].F + data[i].S);
		diff.pb(data[i].F - data[i].S);
	}
	sort(all(sum));
	sort(all(diff));
	cout << max(sum.back() - sum.front(), diff.back() - diff.front()) << endl;
}
/*
|X_i-x_j|+|y_i-y_j|
=max(x_i-x_j,x_j-x_i)+max(y_i-y_j,y_j-y_i)
=max(x_i+y_i-x_j-y_j,x_j+y_j-x_i-y_i,x_i+y_j-x_j-y_i,x_j+y_i-x_i-y_j)
x_i+y_i=A_i
x_i-y_i=B_i
=max(A_i-A_j,B_j-A_i,B_i-B_j,B_j-B_i)
find:max(|X_i-x_j|+|y_i-y_j|)
=max(max(x_i-x_j,x_j-x_i)+max(y_i-y_j,y_j-y_i))
=max(max(A_i-A_j,B_j-A_i,B_i-B_j,B_j-B_i))
=max(max(|A_i-A_j|,|B_i-B_j|))
=max(max(A_i)-min(A_j),max(B_i)-min(B_j))

*/

Measured memory_bytes: 8184
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int A, B, C, X, Y;


signed main(){
    cin >> A >> B >> C >> X >> Y;

    int ans;
    if(2*C <= A+B) ans = 2*C*min(X, Y);
    else ans = (A+B)*min(X, Y);

    if(Y <= X)
        if(2*C <= A) ans += 2*C*(X-Y);
        else ans += A*(X-Y);
    else if(2*C <= B) ans += 2*C*(Y-X);
    else ans += B*(Y-X);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll& a : A) {
        cin >> a;
    }

    double ans = 0.0;
    for (ll a : A) {
        ans += 1.0 / a;
    }
    ans = 1.0 / ans;
    cout << fixed << setprecision(10) << ans << endl;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxn = 205;
const int logn = 62;

int n;
ll a[maxn];
char s[maxn];

class LinearBasis{
public:
	ll val[logn];
	LinearBasis(){ memset(val, 0, sizeof(val)); return; }
	inline void insert(ll x){
		for(int i = logn - 1; i >= 0; --i) if(x >> i & 1){
			if(val[i]) x ^= val[i];
			else{
				val[i] = x;
				break;
			}
		}
		return;
	}
	inline bool query(ll x){
		for(int i = logn - 1; i >= 0; --i) if(x >> i & 1){
			if(!val[i])
				return false;
			x ^= val[i];
		}
		return true;
	}
}lb;

inline void solve(){
	lb = LinearBasis();
	scanf("%d", &n);
	FOR(i, 0, n)
		scanf("%lld", a + i);
	scanf("%s", s);
	for(int i = n - 1; i >= 0; --i){
		if(s[i] == '1'){
			if(!lb.query(a[i])){
				puts("1");
				return;
			}
		}
		else
			lb.insert(a[i]);
	}
	puts("0");
	return;
}

int main(){
	int T;
	for(scanf("%d", &T); T--; solve());
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
double a,b,x,s,u,d;
int main()
{
	cin>>a>>b>>x;
	s=x/a;
	if(a*b>=2*s)
	{ d=(2*x)/(a*b);
	double dgree=atan(d/b);
	printf("%.10lf\n",90-(dgree/M_PI)*180);}
	else
    {
        u=(2*s)/a-b;
        b-=u;
        d=a;
        double dgree=atan(d/b);
	printf("%.10lf\n",90-(dgree/M_PI)*180);
    }
	return 0;
}


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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = 51;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    int pow10[6];
    pow10[0]=1;
    for(int i=1; i<=5; i++)
    {
        pow10[i] = pow10[i-1]*10;
    }
    cin.tie(0);
    cin >> N;
    int x = log10(N)+1;
    //cout << x;
    int res = 0;
    for(int i=1; i<x; i+=2)
    {
        res += 9*pow10[i-1];
        //cout << res << "\n";
    }
    if(x%2==1)
    {
        res += N-pow10[x-1]+1;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --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 all(a)  a.begin(), a.end()
#define MAXNUM 5000
using namespace std;
typedef long long ll;

int main(){
  string s; cin >> s;
  int ans=0;
  REP(i, s.length()){
    if(s[i]=='+') ans++;
    else  ans--;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
 
class War{
    public:
    int l,r;
    War(){}
    War(int l,int r):l(l),r(r){}
    bool operator < (const War &w)const{
        return r!=w.r ? r<w.r : l<w.l;
    }
    bool operator == (const War &w)const{
        return r==w.r && l==w.l;
    }
};

int main(){
    int n,m;
    vector<War> w;

    cin>>n>>m;
    for(int i=0; i<m; i++){
        int l,r;
        cin>>l>>r;
        w.push_back(War(l,r));
    }

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

    int ans=1;
    int t=w[0].r;
    for(int i=1; i<m; i++){
        if(t<=w[i].l){
            t=w[i].r;
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
 
int main()
{
  int T;
  scanf("%d",&T);
  for(int t=0;t<T;t++){
    int edge[3];
    scanf("%d %d %d",edge,edge+1,edge+2);
    sort(edge,edge+3,greater<int>());
    if(edge[0]*edge[0]==edge[1]*edge[1]+edge[2]*edge[2]){
      printf("%s\n","YES");
    }else{
      printf("%s\n","NO");
    }
  }
 
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;

queue<ll> q;
int k;
int main(){
	cin >> k;
	for(int i = 1;i <= 9;i++){
		q.push(i);
	}
	ll cnt = 0;
	ll t;
	while(!q.empty()){
		cnt++;

		t = q.front();
		q.pop();
		if(cnt == k){
			cout << t << endl; 
			break;
		}
		if(t % 10 != 0){
			q.push(t * 10 + t % 10 - 1);
		}
		q.push(t * 10 + t % 10);
		if(t % 10 != 9){
			q.push(t * 10 + t % 10 + 1);
		}
	}

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b , c , k ;
  cin >> a >> b >> c >> k;
  int ans = 0;
 
if(a>=k){
ans = k;
}else if(k<=a+b){
ans = a;
}else{
    ans = a-(k-a-b);
}
  cout << ans << endl;
} 

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rp(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    int ans=1000000000;
    rp(i,n-k+1){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;
int dp[NMAX];

void solve()
{
    cin>>n;
    dp[0] = 0;
    arr[0] = 1e18;
    for(int i=1;i<=n;i++){
        dp[i] = INF;
        cin>>arr[i];
        if(i == 1){
            dp[1] = 0;
            continue;
        }
        dp[i] = min(dp[i],dp[i-1] + abs(arr[i]-arr[i-1]));
        dp[i] = min(dp[i],dp[i-2] + abs(arr[i]-arr[i-2]));
        // tr(dp[i]);
    }
    cout<<dp[n];
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 5120
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	string s;
	cin >> s;

	int ans = 0;
	if (s == "RSS") ans = 1;
	if (s == "SRS") ans = 1;
	if (s == "SSR") ans = 1;
	if (s == "RSR") ans = 1;
	if (s == "RRS") ans = 2;
	if (s == "SRR") ans = 2;
	if (s == "RRR") ans = 3;

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


Measured memory_bytes: 3624
cc = []
3.times { cc << gets.split.map(&:to_i) }

aa = [0, 0, 0]
bb = [0, 0, 0]
count = 0
[0, 1, 2].each do |i|
  [0, 1, 2].each do |j|
    aa[i] = cc[i][0] - bb[0]
    bb[j] = cc[0][j] - aa[0]
    count += 1 if cc[i][j] == aa[i] + bb[j]
  end
end
puts count == 9 ? 'Yes' : 'No'


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	int ret = a+b;
	if (ret>=24) {
		ret -= 24;
	}

	cout << ret << endl;
}


Measured memory_bytes: 256
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    A, B = map(int, input().split())

    if B == 1:
        print(0)
        return

    now = 1
    for i in range(1, 1000):
        now += A - 1
        if now >= B:
            print(i)
            return


sol()

Measured memory_bytes: 3476
#include<iostream>
#include<assert.h>
#include<vector>

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define write freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); 

using namespace std;
//assert(x==i);
void solve()
{
int n;
cin>>n;
if(n<30)
	cout<<"No\n";
else
	cout<<"Yes\n";
}
int main() 
{
ios;
//write;
int tc=1;
//cin>>tc;
for(int i=1;i<=tc;i++)
{
//cout<<"Case #"<<i<<": ";
solve();
}
return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define yzh 2333333
//#define bql 2147483647
using namespace std;
int myabs(int a)
{
  if(a>0) return a;
  else return -a;
}
int main()
{
	fast;
  int n,bql=2147483647;
  long long sum=0;
  cin>>n;
  bool flag=false;
  for(int i=0;i<n;i++)
  {
    int b;
    cin>>b;
    sum+=myabs(b);
    if (b<0)
      flag=1-flag;
    if (myabs(b)<bql)
      bql=myabs(b);
  }
  if(flag)
    cout<<sum-2*bql<<'\n';
  else
    cout<<sum<<'\n';
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
        d: usize
    }
    println!("{}", if (c + b - 1) / b <= (a + d - 1) / d {"Yes"} else {"No"});
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S; 
  string T;
  cin >> S >> T ;
  
int count =0;
  
for(int i=0; i<S.size(); i++ ){
if(S.at(i)!=T.at(i)){
 count++;
}
}
cout << count << endl;
}

Measured memory_bytes: 3816
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

int N, M, K, Q, i, j, k, l, tmp, ans;

int main(){
    char a;
    cin >> a;
    if( a >= 'a'){
        cout << 'a';
    }
    else{
        cout << 'A';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
map<pair<ll,ll>,ll> mp;
ll f(ll i,ll x) {
  if(mp.count({i,x})) return mp[{i,x}];
  if(x--==0) return 0;
  if(i--==0) return 1;
  ll a=(1LL<<i+2)-3;
  ll res;
  if(!x) res=0;
  else if(x<a+1) res=f(i,x);
  else res=f(i,a)+f(i,x-a-1)+1;
  mp[{i+1,x+1}]=res;
  return res;
}
int main(){
  ll n,x;
  cin>>n>>x;
  cout<<f(n,x)<<endl;
}


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

int main() {
    cout.tie(0)->sync_with_stdio(0);
    int H, W, K; cin >> H >> W >> K;
    array<int, 2> X, Y;
    cin >> X[0] >> Y[0] >> X[1] >> Y[1];
    X[0]--, X[1]--, Y[0]--, Y[1]--;
    vector<string> grid(H);
    for (string &s : grid) cin >> s;
    vector<vector<int>> d(H, vector<int>(W, INT_MAX/2));
    d[X[0]][Y[0]] = 0;
    vector<pair<int,int>> bfs = {{X[0], Y[0]}};
    vector<int> dx = {-1, 0, 1, 0};
    vector<int> dy = {0, -1, 0, 1};
    for (int i = 0; i < int(bfs.size()); ++i) {
        pair<int, int> cur = bfs[i];
        for (int j = 0; j < 4; ++j) {
            int a = cur.first, b = cur.second;
            for (int k = 0; k < K; ++k) {
                a += dx[j];
                b += dy[j];
                if (a < 0 || a >= H || b < 0 || b >= W 
                        || grid[a][b] == '@' || d[cur.first][cur.second] >= d[a][b]) break;
                if (d[a][b] != INT_MAX/2) continue;
                d[a][b] = 1 + d[cur.first][cur.second];
                bfs.push_back({a, b});
            }
        }
    }
    cout << (d[X[1]][Y[1]] == INT_MAX/2 ? -1 : d[X[1]][Y[1]]) << '\n'; 
}


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

auto gcd(auto x, auto y){
  if(x % y == 0){
    return y;
  }else{
    return gcd(y,x % y);
  }
}

auto lcm(auto x, auto y){
  return x * y / gcd(x,y);
}

int main() {
  long long num,x;
  long long tmp = 0;
  cin >> num >> x;
  
  vector<long long> vec(num);
  for(int i = 0; i < num; i++) cin >> vec.at(i);
  
  for(int i = 0; i < num; i++){
    if(tmp == 0){
      tmp = abs(vec.at(i)-x);
      continue;
    }
    
    tmp = abs(gcd(tmp, vec.at(i)-x));
  }
  
  if(tmp == 0) cout << 1;
  else cout << tmp;
}


Measured memory_bytes: 1024
// A Dynamic Programming based solution for 0-1 Knapsack problem 
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define ui unsigned int
#define pb push_back
#define ul unsigned long
#define show(x) cerr<<#x<<':'<<x<<endl;

using namespace std;

ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
ll i, w; 
ll K[n+1][W+1]; 

// Build table K[][] in bottom up manner 
for (i = 0; i <= n; i++) 
{ 
	for (w = 0; w <= W; w++) 
	{ 
		if (i==0 || w==0) 
			K[i][w] = 0; 
		else if (wt[i-1] <= w) 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); 
		else
				K[i][w] = K[i-1][w]; 
	} 
} 

return K[n][W]; 
} 

int main() 
{ 
	ll val[100];
	ll wt[100]; 
	ll W = 0; 
	ll n = 0;
    cin>>n>>W;
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
	cout<<knapSack(W, wt, val, n); 
	return 0; 
} 


Measured memory_bytes: 79104
x,y = map(int,input().split())

if x == y:
    print(x)
else:
    while not (x == 1 and y == 1):
        if x > y:
            x = x % y
            if x == 0:
                print(y)
                break
            # print(f'{x} {y}')
        elif x < y:
            y = y % x
            if y == 0:
                print(x)
                break
            # print(f'{x} {y}')
    '''
    else:

        # xの約数を算出
        divisor_x = []
        for a in range(x):
            if x % (a+1) == 0:
                divisor_x.append(a+1)

        for a in divisor_x[::-1]:
            if y % a == 0:
                print(a)
                break
    '''



Measured memory_bytes: 5608
#include<iostream>

using namespace std;


int min(int x,int y){
  if(x < y)return x;
  else return y;
}

int main()
{
    int a,b,k,r,count = 0,ans;
    
    cin >> a >> b >> k;


    for(r = min(a,b); r >= 1; r--){
        if(a % r == 0 && b % r == 0){
            count++;
            if(count==k){
                cout << r;
            }
        }
    }
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n; cin >> n;
    vector<pair<string, int>> vp(n);
    rep(i, 0, n) cin >> vp[i].first >> vp[i].second;
    string x; cin >> x;

    int ans = 0; int f = 0;
    rep(i, 0, n){
        if(f) ans += vp[i].second;
        if(vp[i].first == x) f = 1;
    }
    cout << ans << "\n";
}

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

    solve();
    return 0;
}
 


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

char S[4];
int S_01=0, S_23=0;
bool YYMM = false;
bool MMYY = false;

int main() {
  rep(i, 4){
    cin >> S[i];
  }
  // charからintに変換。10の位は10倍する。
  S_01 = (S[0] - '0') * 10 + (S[1] - '0');
  S_23 = (S[2] - '0') * 10 + (S[3] - '0');

  // MMが1から12に収まっているか判断。
  if (1 <= S_01 and S_01 <= 12) MMYY = true;
  if (1 <= S_23 and S_23 <= 12) YYMM = true;

  // 用意しておいたフラグん応じて出力する。
  if (YYMM==true and MMYY==true) cout << "AMBIGUOUS" << endl;
  else if (YYMM==true) cout << "YYMM" << endl;
  else if (MMYY==true) cout << "MMYY" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "5", "4 2 5 1 3" ].parse.expand.solve == 3 );
	assert( [ "4", "4 3 2 1" ].parse.expand.solve == 4 );
	assert( [ "6", "1 2 3 4 5 6" ].parse.expand.solve == 1 );
	assert( [ "8", "5 7 4 2 6 8 1 3" ].parse.expand.solve == 4 );
	assert( [ "1", "1" ].parse.expand.solve == 1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	auto m = long.max;
	foreach( a; as )
	{
		m = min( m, a );
		ans += ( a <= m );
	}
	return ans;
}


Measured memory_bytes: 11536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  string S, T;
  cin >> S >> T;

  int ans = 0;
  rep(i, 3) {
    if (S[i] == T[i]) ans++;
  }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, h, w;
	vector<int>list(10005, 0);


	cin >> h >> w >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		list[i + 1] = num;
	}

	stack<int>st;

	for (int i = 1; i < 10001; i++) {
		if (list[i] >= 1) {
			for (int j = 0; j < list[i]; j++) {
				st.push(i);
			}
		}
	}

	bool flag = false;

	for (int i = 0; i < h; i++) {
		if (flag == false) {
			for (int j = 0; j < w; j++) {
				cout << st.top();
				st.pop();
				if (j != w - 1) {
					cout << " ";
				}
			}
			cout << endl;
			flag = true;
		}
		else {
			stack<int>st2;

			for (int j = 0; j < w; j++) {
				st2.push(st.top());
				st.pop();
			}

			for (int j = 0; j < w; j++) {
				cout << st2.top();
				st2.pop();
				if (j != w - 1) {
					cout << " ";
				}
			}
			cout << endl;
			flag = false;
		}
	}






	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(a <= 5 ? 0 : a <= 12 ? b / 2 : b);
    }
}

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

int main() {
int H, W, N;
cin >> H >> W >> N;
int A, B;
if (H > W) {
    A = H;
    B = W;
}
else {
    A = W;
    B = H;
}
int count = (N + A - 1) / A;
cout << count << endl;
}

Measured memory_bytes: 256