akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC064A___RGB_Cards
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string numStr = "";
            foreach (var v in input)
            {
                numStr += v;
            }

            string output = "NO";
            if (IsMultipleof4(int.Parse(numStr)))
            {
                output = "YES";
            }

            Console.WriteLine(output);

        }

        static bool IsMultipleof4(int value)
        {
            bool result = false;

            if (value % 4 == 0)
            {
                result = true;
            }

            return result;
        }

    }
}


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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, M;
vector<int> x, y;
vector<int> cnt;
vector<vector<int>> g;

int dfs(int node){
  if(cnt[node] != -1){
    return cnt[node];
  }
  int ans = 0;
  REP(i, g[node].size()){
    ans = max(ans, dfs(g[node][i])+1);
  }
  return cnt[node] = ans;
}

int main(){
  cin >> N >> M;
  x.resize(M), y.resize(M), g.resize(N), cnt.resize(N);
  REP(i, M){
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
    g[x[i]].push_back(y[i]);
  }
  REP(i, N){
    cnt[i] = -1;
  }
  int ans  =0;
  for(int i = 0; i < N; i++){
    ans = max(ans, dfs(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8960
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        F solver = new F();
        solver.solve(1, in, out);
        out.close();
    }

    static class F {
        public int solve1(int h, int w, boolean[][] z) {
            int[][] up = new int[h + 1][w + 1];
            for (int i = 1; i < h; i++) {
                for (int j = 1; j < w; j++) {
                    if (!z[i][j]) {
                        up[i][j] = up[i - 1][j] + 1;
                    }
                }
            }

            int ans = 1;
            for (int i = 1; i <= h; i++) {
                ArrayList<Pair> s = new ArrayList<>();
                s.add(new Pair(0, -1));
                for (int j = 1; j <= w; j++) {
                    while (s.get(s.size() - 1).y >= up[i][j]) {
                        int v = (j - s.get(s.size() - 2).x) * (s.get(s.size() - 1).y + 1);
                        if (v > ans) {
                            ans = v;
                        }
                        s.remove(s.size() - 1);
                    }
                    s.add(new Pair(j, up[i][j]));
                }
            }

            return ans;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();
            boolean[][] b = new boolean[h][w];
            for (int i = 0; i < h; i++) {
                String s = in.next();
                for (int j = 0; j < w; j++) {
                    b[i][j] = s.charAt(j) == '#';
                }
            }
            boolean[][] z = new boolean[h + 1][w + 1];
            for (int i = 0; i < h - 1; i++) {
                for (int j = 0; j < w - 1; j++) {
                    z[i + 1][j + 1] = b[i][j] ^ b[i + 1][j] ^ b[i][j + 1] ^ b[i + 1][j + 1];
                }
            }

            int ans = solve1(h, w, z);

            boolean[][] y = new boolean[w + 1][h + 1];
            for (int i = 0; i < h + 1; i++) {
                for (int j = 0; j < w + 1; j++) {
                    y[j][i] = z[i][j];
                }
            }

            ans = Math.max(ans, solve1(w, h, y));

            out.println(ans);
        }

        class Pair {
            int x;
            int y;

            public Pair(int x, int y) {
                this.x = x;
                this.y = y;
            }

        }

    }
}



Measured memory_bytes: 144068
n = gets.to_i
hash = {}
n.times do |i|
  v1, v2 = gets.chomp.split
  hash[i+1] = [v1.to_s, v2.to_i]
end
res_order = hash.values.sort{|a, b| (a[0] <=> b[0]).nonzero? || (b[1] <=> a[1])}

res_order.each do |i|
  hash.each do |k,v|
    puts k if v == i
  end
end

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a >= 13) {
        cout << b << '\n';
    } else if (a <= 5) {
        cout << 0 << '\n';
    } else {
        cout << b / 2 << '\n';
    }
    return 0;
}


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


int main(){
    priority_queue<int,vector<int>,greater<int>> plus;
    priority_queue<int> minus;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(a[i] < 0) minus.push(a[i]);
        else plus.push(a[i]);
    }
    int ans,tmp1,tmp2;
    vector<int> ans1(n-1),ans2(n-1);
    rep(i,n){
        if(i == n-1){
            if(plus.empty()){
                ans = abs(minus.top());
                minus.pop();
            }else{
                ans = plus.top();
                plus.pop();
            }
            continue;
        }
        if(plus.empty()){
            tmp1 = minus.top();
            minus.pop();
            tmp2 = minus.top();
            minus.pop();
            plus.push(abs(tmp1 - tmp2));
            ans1[i] = max(tmp1,tmp2);
            ans2[i] = min(tmp1,tmp2);
        }else if(minus.empty()){
            tmp1 = plus.top();
            plus.pop();
            tmp2 = plus.top();
            plus.pop();
            minus.push((-1)*abs(tmp1-tmp2));
            ans1[i] = min(tmp1,tmp2);
            ans2[i] = max(tmp1,tmp2);
        }else{
            if(plus.size() == 1){
                tmp1 = plus.top();
                plus.pop();
                tmp2 = minus.top();
                minus.pop();
                plus.push(tmp1 - tmp2);
                ans1[i] = tmp1;
                ans2[i] = tmp2;
            }else if(minus.size() == 1){
                tmp1 = plus.top();
                plus.pop();
                tmp2 = minus.top();
                minus.pop();
                minus.push(tmp2 - tmp1);
                ans1[i] = tmp2;
                ans2[i] = tmp1;
            }else{
                tmp1 = plus.top();
                plus.pop();
                tmp2 = minus.top();
                minus.pop();
                if(minus.size() < plus.size()){
                    minus.push(tmp2 - tmp1);
                    ans1[i] = tmp2;
                    ans2[i] = tmp1;
                }else{
                    plus.push(tmp1-tmp2);
                    ans1[i] = tmp1;
                    ans2[i] = tmp2;
                }
            }
        }
    }
    cout << ans << endl;
    rep(i,n-1) cout << ans1[i] << " " << ans2[i] << endl;
}

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

const int INF = 1e9+7;

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

    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=1;i<n;i++)
    {
        for(int j=max(i-k,0);j<i;j++)
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  int count=0;
  int cnt_digits=0;
  for(int i=1;i<=a;i++){
    int num=i;
    cnt_digits=0;
    do{
      //printf("%d <- i \n", i);
      //i=i/10;
      num=num/10;
      cnt_digits++;
    }while((num/10)!=0);
    if(i>9)cnt_digits++;
    //return 0; -> m=1
    //printf("%d %d i,cnt_digits\n",i, cnt_digits );
    if(cnt_digits%2==1)
    count++;

  }
  printf("%d",count);
}


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

int mod = 1000000007;
int f[100001];
void intiF() {
	f[0] = 1;
	f[1] = 1;
	for (int i = 2; i <= 100000; i++) {
		f[i] = (f[i - 1] + f[i - 2]) % mod;
	}
}

int main() {
	intiF();
	int n, m;
	cin >> n >> m;
	long long result = 1;
	int x = 0;
	for (int i = 0, a; i < m; i++) {
		cin >> a;
		if (x == a) {
			cout << 0 << endl;
			return 0;
		}
		result = result * f[a - 1 - x] % mod;
		x = a + 1;
	}

	cout << result * f[n - x] % mod << endl;
}


Measured memory_bytes: 1152
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -float("inf")
for i in range(1, 2 ** 10):
    res = 0
    for j in range(n):
        cnt = sum([(i >> k & 1) & f[j][k] for k in range(10)])
        res += p[j][cnt]
    ans = max(ans, res)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MAX_N 100000
int N;
ll dp[MAX_N + 1][3];

int main() {
    cin >> N;
    int h[N + 1][3];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) cin >> h[i][j];
    }

    for (int i = 0; i < 3; i++) dp[0][i] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + h[i][j]);
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 3; i++) ans = max(ans, dp[N][i]);
    cout << ans << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

const double EPS = 1e-9;
#define rep(i,n) for(int i = 0;i < n;i++)
#define EQ(a,b)	(abs(a - b) <= EPS)

int main() {

	int n, k;
	double t, u, v, l;
	cin >> n >> k >> t >> u >> v >> l;
	vector<double> d(n);

	rep(i, n) {
		cin >> d[i];
	}
	d.push_back(l);

	double time = 0.0;
	int cnt = 0, i = 0;
	double now = 0.0;
	double rest = 0.0;

	while (i < d.size()) {
		while (!EQ(now, d[i])) {
			double move = min(rest * v, d[i] - now);
			time += move / v;
			now += move;
			rest -= move / v;
			if (EQ(rest, 0)) {
				if (cnt == 0)break;
				cnt--;
				rest = t;
			}
		}
		if (!EQ(now, d[i])) {
			time += (d[i] - now) / u;
			now = d[i];
		}
		i++;
		cnt++;
		if (cnt == k + 1) {
			cnt--;
			rest = t;
		}
	}
	cout << fixed << setprecision(30) << time << endl;

	return 0;
}

Measured memory_bytes: 3292
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 200005

const int INF = 1e9+7;


int main(){

    int n;
    cin >> n;
    vector<int> p(ARRAY_MAX);
    for(int i = 1;i <= n;i++){
        int tmp;
        cin >> tmp;
        p[tmp] = i;

    }

    vector<int> a(ARRAY_MAX),b(ARRAY_MAX);
    for(int i = 1;i <= n;i++){
        a[i] = 20005*i;
        b[i] = 20005*(n-i) + p[i];
    }

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

    for(int i = 1;i <= n;i++){
        if(i == 1){
            cout << b[i];
        }else{
            cout << " " <<  b[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
#define MAX 100000000
#define NOT -1
 
struct Node {
  int parent,left,right;
};
 
struct Node T[MAX];
 
int n;
//???????????????
void preParse(int u){
  //  printf("a\n");
  if(u == NOT) return;
  printf(" %d",u);
  // printf("sex\n");
  preParse(T[u].left);
  preParse(T[u].right);
}
 
//??????
void inParse(int u){
  // printf("b\n");
  if(u==NOT)return;
  
  inParse(T[u].left);
  printf(" %d",u);
  inParse(T[u].right);
}
 
//??????
void postParse(int u){
  // printf("c\n");
  if(u==NOT)return;
  postParse(T[u].left);
  postParse(T[u].right);
  printf(" %d", u);
}
 
 
 
int main(){
  int i,id,lef,righ;
  int root;
 
  
  scanf("%d", &n);
   for(i=0;i<n;i++){
    T[i].parent=NOT;
  }
 
  
 
  for(i=0;i<n;i++){
    scanf("%d %d %d", &id, &lef, &righ);
    T[id].left=lef;
    T[id].right=righ;
     
    if(lef!=NOT)T[lef].parent=id;
    if(righ!=NOT)T[righ].parent=id;
     
  }
 
  for(i=0;i<n;i++){
    if(T[i].parent == NOT)root=i;
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n");
   
  printf("Inorder\n");
  inParse(root);
  printf("\n");
   
  printf("Postorder\n");
  postParse(root);
  printf("\n");
   
  return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll N,M;
    pii  A[57],B[57];
    cin >> N >>  M;
    rep(i,N){
        cin  >> A[i].first >> A[i].second;
    }
    rep(i,M){
        cin  >> B[i].first >> B[i].second;
    }
    rep(i,N){
        ll DIS=LINF,P=0;
        rep(j,M){
            if(abs(A[i].second-B[j].second)+abs(A[i].first-B[j].first)<DIS){
                DIS=abs(A[i].second-B[j].second)+abs(A[i].first-B[j].first);
                P=j+1;
            }
        }
        cout << P <<  endl;
    }
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

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

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}

/*
6 2 ==>
1 5 --> 4, 2
2 3 --> 1, 5
*/

/*
8 3 ==>
1 7 --> 6, 2
3 6 --> 3, 5
4 5 --> 1  7
*/

/*
10 4 ==>
1 9 --> 9, 1
2, 9 --> 7, 3
 --> 
*/

void run() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cout << i + 1 + ((n - 4) <= 4 * i) * (n % 2 == 0)  << " " << n - i - 1 << endl;
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
    string s,t;
 
    cin>>s>>t;
 
    for(int i=0;i<t.size();i++){
        cout<<s[i];
        cout<<t[i];
    }

    if(s.size()!=t.size()){
        cout<<s[s.size()-1];
    }

    cout<<endl;
}

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

unsigned long int N, M;
std::string S, T;

unsigned long int lcm( unsigned long int m,
                       unsigned long int n,
                       unsigned long int g ) {
    if ( (m == 0) || (n == 0) ) return 0;

    return ((m/g) * n);
}

void solve(unsigned long int g) {
    unsigned long int idx_s=0, idx_t=0;
    unsigned long int L = lcm(M, N, g);
    unsigned long int ds = L/M, dt = L/N;
    bool flag = true;

    while (idx_s < N && idx_t < M) {
        if (S[idx_s] != T[idx_t]) flag = false;
        idx_s += ds;
        idx_t += dt;
    }

    if (flag) {
        std::cout << L << std::endl;
    } else {
        std::cout << -1 << std::endl;
    }
}

int main() {
    std::cin >> N >> M;
    std::cin >> S
             >> T;
    unsigned long int g = std::__gcd(N, M);

    if ( g == 1 ) {
        if (S[0] == T[0]) {
            std::cout << N*M << std::endl;
        } else {
            std::cout << -1 << std::endl;
        }
    } else {
        solve( g );
    }
    return 0;
}


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

const int N_MAX = 100;
const int X_MAX = 100;
const int Y_MAX = 100;

int N;
int x[N_MAX];
int y[N_MAX];
int h[N_MAX];
int eh[N_MAX];

void input() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i] >> h[i];
  }
}

int check(int cx, int cy) {
  for (int i = 0; i < N; ++i) {
    if (h[i] == 0) {
      continue;
    }
    eh[i] = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
  }
  int t = -1;
  for (int i = 0; i < N; ++i) {
    if (h[i] == 0) {
      continue;
    }
    if (t == -1) {
      t = eh[i];
    } else if (t != eh[i]) {
      return 0; // not same h
    }
  }
  for (int i = 0; i < N; ++i) {
    if (h[i] != 0) {
      continue;
    }
    if (abs(x[i] - cx) + abs(y[i] - cy) < t) {
      return 0; // within h, but height is 0
    }
  }
  return t;
}

int main() {
  input();
  int ans_h, ans_x, ans_y;
  for (int i = 0; i <= X_MAX; ++i) {
    for (int j = 0; j <= Y_MAX; ++j) {
      ans_h = check(i, j);
      if (ans_h > 0) {
        ans_x = i;
        ans_y = j;
        break;
      }
    }
    if (ans_h > 0) {
      break;
    }
  }
  cout << ans_x << " " << ans_y << " " << ans_h << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  vi A(3);
  cin >> A;
  sort(rng(A));
  if(A[0] + A[1] == A[2]) cout << "Yes\n";
  else cout << "No\n";

}

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

Measured memory_bytes: 256
import copy
N = int(input())
S = input()

R = set()
G = set()
B = set()

for i in range(N):
    if S[i] == "R":
        R.add(i)
    elif S[i] == "G":
        G.add(i)
    else:
        B.add(i)

ans = len(R)*len(G)*len(B)

for r in R:
    for g in G:
        L = g - r
        if g + L in B:
            ans -= 1
        if r - L in B:
            ans -= 1
        if L % 2 == 0 and L//2 + r in B:
            ans -= 1
            



print(ans)

Measured memory_bytes: 9704
//control+option+n to run!
#include <iostream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <fstream>
using namespace std;
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18
int main()
{   
    int n;
    cin>>n;
    set<string> set;
    for (int i=0; i<n; i++){
        string a;
        cin>>a;
        set.insert(a);
    }

    cout<<set.size();

}

Measured memory_bytes: 19232
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, m, l, r;
	cin >> n >> m;

	int l_max = 1;
	int r_min = n;

	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		l_max = max(l_max, l);
		r_min = min(r_min, r);
	}

	int ans = max(0, r_min - l_max + 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int x;
	cin>>x;
	int i = 0;
	int a = 100;
	while(a<x){
		a = a + ((1*a)/100);
		i++;
	}
	cout<<i;
}

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

using namespace std;

#define MAXN 200005
int problems[MAXN];

main(){
    for(int i=0;i<MAXN;++i) problems[i] = 0;
    int n;
    map<int,int> m;
    int count = 0;
    scanf("%d",&n);
    int num;
    for(int i=0;i<n;++i){
        scanf("%d",&num);
        if(m.find(num)!=m.end()){
            problems[m[num]] += 1;
        }else{
            m[num] = count; count++;
            problems[m[num]] += 1;
        }
    }
    int obj;
    scanf("%d",&obj);
    for(int i=0;i<obj;++i){
        scanf("%d",&num);
        if(m.find(num)==m.end()){
            cout << "NO" << endl; return 0;
        }
        if(problems[m[num]]==0){
            cout << "NO" << endl; return 0;
        }else problems[m[num]] -= 1;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 12416
M, K = map(int, input().split())

if M == 0:
    if K == 0:
        print(0, 0)
    else:
        print(-1)
elif M == 1:
    if K == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)
elif K >= 2**M:
    print(-1)
else:
    A = []
    for i in range(2**M):
        if i == K:
            continue
        A.append(i)
    ans = A[:] + [K] + A[::-1] + [K]
    print(' '.join([str(a) for a in ans]))

Measured memory_bytes: 28428
#coding:utf-8

N = int(input())

x = []
u = []

for i in range(N):
    a,b = input().strip().split()
    x.append(float(a))
    u.append(str(b))

sum_ = 0

for i in range(N):
    if u[i] == 'JPY':
        sum_ += x[i]
    else:
        sum_ += x[i] * 380000

print(sum_)        


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

int main(){
  int n;
  cin >> n;
  vector<int> b(n);
  for(int i=0; i<n; i++){
    cin >> b[i];
  }
  vector<int> ans;
  for(int j=0; j<n; j++){
    for(int i=b.size()-1; i>=0; i--){
      if(b[i] == i+1){
        ans.push_back(i+1);
        b.erase(b.begin()+i);
        break;
      }
    }
  }
  if(ans.size() == n){
    for(int i=n-1; i>=0; i--){
      cout << ans[i] << endl;
    }
  }else{
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# SegmantTreeの実装
import sys
input = sys.stdin.readline

# 初期化最大値
INF = (1 << 31) - 1

class SegmentTree:
    def __init__(self, N):
        self.N = 2**(N-1).bit_length()
        self.data = [[0, -1] for _ in range(2*self.N-1)]

    # k番目の値をget
    def get(self, k):
        k += self.N - 1
        s = self.data[k][0]
        while k > 0:
            k = (k-1)//2
            s = max(s, self.data[k][0])
        return s

    def update(self, l, x):
        L = l + self.N
        R = 2*self.N
        while L < R:
            if R & 1:
                R -= 1
                if x > self.data[R-1][0]:
                    self.data[R-1][0] = x
            if L & 1:
                if x > self.data[L-1][0]:
                    self.data[L-1][0] = x
                L += 1
            L >>= 1; R >>= 1

N = int(input())
H = list(map(int, input().split()))
A = list(map(int, input().split()))

ST = SegmentTree(N+1)

ans = 0
for h, a in zip(H, A):
    m = ST.get(h)
    ans = max(ans, m+a)
    ST.update(h, m+a)

print(ans)

Measured memory_bytes: 126032
#include<cstdio>
#include<algorithm>

using namespace std;

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

int main(){
	int h, w; scanf("%d %d", &h, &w);
	int c[10][10];
	rep(i, 10) rep(j, 10) scanf("%d", &c[i][j]);
	rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	int res = 0;
	rep(i, h) rep(j, w){
		int a; scanf("%d", &a);
		if(a == -1) continue;
		res += c[a][1];
	}
	printf("%d\n", res);
	return 0;
}

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

long long cmb(int n, int r){
  if(n-r<r)r=n-r;
  if(r<0)return 0;
  if(r==0)return 1;
  if(r==1)return n;

  vector<int> num(r);
  vector<int> den(r);
  for(int i=0; i<r; i++){
    num[i]=n-r+i+1;
    den[i]=i+1;
  }

  for(int p=2; p<=r; p++){
    int piv=den[p-1];
    int sld=(n-r)%p;
    for(int i=p-1; i<r; i+=p){
      num[i-sld]/=piv;
      den[i]/=piv;
    }
  }

  long long res=1;
  for(int i=0; i<r; i++)res=res*num[i]%1000000007;

  return res;
}

int main(){
  long long n,k; cin>>n>>k;

  for(int i=1; i<=k; ++i){
    cout<<cmb(n-k+1, n-k-i+1)%1000000007*cmb(k-1, i-1)%1000000007<<endl;
  }
}


Measured memory_bytes: 256
S=input()
T=input()
if len(S)<len(T):
    print('UNRESTORABLE')
else:
    cand=[]
    for i in range(len(S)-len(T)+1):
        if all(s=='?' or s==t for s,t in zip(S[i:i+len(T)],T)):
            cand.append(S[:i].replace('?','a')+T+S[i+len(T):].replace('?','a'))
    print('UNRESTORABLE' if len(cand)==0 else min(cand))

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

using namespace std;

int memo[5][5];
bool check [5][5];
int c[5];
const int inf = 1000000000;

int dp(int v,int op){

    if(v>=3) return 0;

    if(check[v][op]) return memo[v][op];

    int res = c[op];

    int op1 = op == 1? inf:dp(v+1,1);
    int op2 = op == 2? inf:dp(v+1,2);
    int op3 = op == 3? inf:dp(v+1,3);

    res += min(op1,min(op2,op3));

    check[v][op]=true;
    memo[v][op]=res;

    //cout << res << ' ' << v << endl;

    return memo[v][op];

}

int main() {

    cin >> c[1]>> c[2] >> c[3];

    cout << dp(0,0);

    return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

int main(int argc, char const *argv[]){
	int alphabet[259] = { 0 };
	char str[100007];
	scanf("%s",str);
	for (int i = 0; i < strlen(str); ++i)	++alphabet[(int)str[i]];
	for (int i = 'a'; i <= 'z'; ++i)
	{
		if(alphabet[i] == 0){
			printf("%c\n", i);
			return 0;
		}
	}
	printf("None\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}


int main(){
    ll 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: 256
#include <bits/stdc++.h>
using namespace std;

#define DEBUG_ENABLED 1

typedef long long ll;

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

    ll N, K;
    cin >> N >> K;

    vector<ll> p;
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        p.push_back(a);
    }

    ll min = 0;
    sort(p.begin(), p.end());
    for (int i = 0; i < K; i++)
    {
        min += p.at(i);
    }

    cout << min << endl;
    return 0;
}


Measured memory_bytes: 3648
num = int(input())
value = input().split()

value = [int(x) for x in value]

cnt = []

res = pow(3, len(value))
for i in range(0, len(value)):
    if value[i] % 2 == 0:
        cnt.append(2)
    else:
        cnt.append(1)

ss = 1
for i in cnt:
    ss = ss * i
print(res-ss)


Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    int a, b, c, d;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    if (a * b > c * d) {
        printf("%d\n", a * b);
    } else {
        printf("%d\n", c * d);
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ALL(v)      v.begin(), v.end()
#define PB          push_back
#define MP          make_pair
#define UB          upper_bound
#define LB          lower_bound
#define PI          2*acos(0.0)
#define MOD         1000000007
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   ((a)*(b)) / GCD(a, b)
#define INPUT       freopen("input.txt", "r", stdin);
#define OUTPUT      freopen("output.txt", "w", stdout);
#define PRINT(a)    for(auto i : a) cout << i << " "; cout << endl;
#define PRINTS(s)   for(auto i=s.begin(); i!=s.end(); i++) cout << *i << " "; cout << endl;
#define PRINTM(m)   for(auto i=m.begin(); i!=m.end(); i++) cout << i->first << " " << i->second << endl;

int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
string lowerCase = "abcdefghijklmnopqrstuvwxyz";
string upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// Graph moves
const int fxKing[] = {+1,+1,+0,-1,-1,-1,+0,+1}; /// King's move
const int fyKing[] = {+0,+1,+1,+1,+0,-1,-1,-1}; /// King's move
const int fxKnight[] = {+2,+1,-1,-2,-2,-1,+1,+2}; /// Knight's move
const int fyKnight[] = {+1,+2,+2,+1,-1,-2,-2,-1}; /// Knight's move

ll q, t=1, a, b, c, d, m, n, k;
ll cnt, Mn, Mx, sum, sum1, sum2, ck;
ll arr1[1000], arr2[1000];

map <ll, ll> mp1, mp2;
set <ll> st1, st2;
vector <ll> vec1, vec2;
string str1, str2, str3;

int main()
{
    FIO;
    while(t--)
    {
        cin >> n ;
        int a[n];
        for(int i=0; i<n; i++) cin >> a[i];
        sort(a, a+n);
        int ans = 0;
        for(int i=0; i<n; i++)
            for(int j=i+1; j<n; j++)
                for(int k=j+1; k<n; k++)
                    if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]+a[j]>a[k])
                        ans++;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3672
fun main(args: Array<String>) {
    val (A, B) = listOfInt()
    var ans = 0
    var sum = 1
    while (sum < B) {
        sum += (A - 1)
        ans++
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

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

int main() {
  ll N;
  cin >> N;
  if (N <= 2) {
    cout << 1 << endl;
    return 0;
  }
  ll A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ans = 0;
  int mode = -1;
  if (A[0] < A[1]) {
    mode = 0;
  } else if (A[0] > A[1]) {
    mode = 1;
  }
  for (int i = 2; i < N; i++) {
    if (mode == -1 && A[i-1] > A[i]) {
      mode = 1;
    } else if (mode == -1 && A[i-1] < A[i]) {
      mode = 0;
    }
    if (mode == 0 && A[i-1] > A[i]) {
      ans++;
      mode = -1;
    } 
    if (mode == 1 && A[i-1] < A[i]) {
      ans++;
      mode = -1;
    } 
  }
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.math.*;
import java.util.*;

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

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

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        int max = 0;
        int gcd = 0;
        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextInt();
            max = Math.max(max, A[i]);
            if (i > 0) {
                gcd = gcd(gcd, A[i]);
            } else {
                gcd = A[i];
            }
        }
        if (K <= max && K % gcd == 0) {
            _out.println("POSSIBLE");
        } else {
            _out.println("IMPOSSIBLE");
        }
    }
    private static int gcd(int a, int b) {
        if (a < b) {
            return gcd(b, a);
        }
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

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

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

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


  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < n; i++) {
    ans = (ans+v[i])/2.0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    ArrayList<Integer>ans  = new ArrayList<>();

    int cou = 0;
    for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	}
 Collections.sort(ans);
 
    System.out.println(ans.get(cou-K));
    }
}

Measured memory_bytes: 35732
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] values = new int[n];

        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }

        int total = 0;
        for (int i = 0; i < n; i++) {
            int val = values[i] - sc.nextInt();
            total += val > 0 ? val : 0;
        }

        System.out.println(total);

    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    string s;cin >>s;
    int ans=0;
    int n=s.size();
    for (int i = 0; i < n-1; i++) {
        s.pop_back();
        if(s.size()%2!=0)continue;
        string f,b;
        int k=s.size();
        f=s.substr(0,k/2);
        b=s.substr(k/2,n);
        if(f==b)ans=max(ans,k);
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int idx = 0;
        long count = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 'W') {
                count += i - idx;
                idx++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 28316
#include <stdio.h>
#include <math.h>
int main()
{
	int N, i;
	scanf("%d", &N);
	for (i = 0; ; i++) {
		if(i * i > N)
		{
			printf("%d\n", (i -1) * (i - 1));
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

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

int main(){
  int n;
  cin>>n;
  ll x;
  cin>>x;
  ll a[n];
  rep(i,0,n){
    cin>>a[i];
  }
  ll ans=abs(a[0]-x);
  rep(i,1,n){
    ans=gcd(ans,abs(a[i]-x));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll mp2[2010];
ll mp1[2010];

void solve() {
    ll n,k;
    cin >> n >> k;
    ll a[n];
    REP(i,n) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (a[j] > a[i]) mp1[i]++;
        }
        for (int j = i + 1; j < n; j++) {
            if (a[j] > a[i]) mp2[i]++;
        }
    }
    // REP(i,n) {
    //     cout << mp1[i] << " " << mp2[i] << endl;
    // }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (1 + k) * k / 2 % MOD * mp1[i] % MOD;
        ans %= MOD;
        ans += k * (k - 1) / 2 % MOD * mp2[i] % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll none=0;
    rep(i,N){
        if(S[i]=='1')none++;
    }
    ll mone = none - 1;
    bool flag = false;
    if(mone <= 0){
        mone = 1;
        flag = true;
    }
    ll pone = none + 1;
    vector<ll> dpm(N+1), dpp(N+1), dpm2(N+1), dpp2(N+1);
    dpm2[N-1] = 1%mone;
    dpp2[N-1] = 1%pone;
    rep(i,N){
        if(S[i] == '1'){
            dpm[i+1] = (dpm[i]*2 + 1) % mone;
            dpp[i+1] = (dpp[i]*2 + 1) % pone;
        }else{
            dpm[i+1] = (dpm[i]*2) % mone;
            dpp[i+1] = (dpp[i]*2) % pone;
        }
    }
    rep(i,N-1){
        dpm2[N-2-i] = (dpm2[N-1-i]*2)%mone;
        dpp2[N-2-i] = (dpp2[N-1-i]*2)%pone;
    }
    /*
    dpm2[N-1] = 1%mone;
    dpp2[N-1] = 1%pone;
    for(ll i=N;i>0;i--){
        if(S[i-1] == '1'){
            dpm[i-1] = (dpm[i]*2 + 1) % mone;
            dpp[i-1] = (dpp[i]*2 + 1) % pone;
        }else{
            dpm[i-1] = (dpm[i]*2) % mone;
            dpp[i-1] = (dpp[i]*2) % pone;
        }
        if(i>1){
            dpm2[i-2] = (dpm2[i-1]*2) % mone;
            dpp2[i-2] = (dpp2[i-1]*2) % pone;
        }
    }*/
    //cout << "aaa" << endl;
    vector<ll> dp(200005),fdp(200005);
    rep(i,200005){
        ll cnt = 0;
        rep(j,20){
            if((i >> j)&1LL)cnt++;
        }
        dp[i] = cnt;
    }
    rep(i,200005){
        ll cnt = 0;
        ll cur = i;
        while(cur != 0){
            cur = cur % dp[cur];
            cnt++;
        }
        fdp[i] = cnt;
    }
    //PR(fdp, 10);
    rep(i,N){
        ll tmp;
        if(S[i] == '1'){
            if(flag){
                cout << 0 << endl;
                continue;
            }
            tmp = ((dpm[N] - dpm2[i]) + mone) % mone;
        }else{
            tmp = ((dpp[N] + dpp2[i]) + pone) % pone;
        }
        //if(tmp != 0){
        cout << fdp[tmp]+1 << endl;
        //}else{
        //    cout << 0 << endl;
        //}
    }
}

Measured memory_bytes: 12836
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

//解説参考.
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	x--, y--;
	
	vi ans(n,0);
	REP(i,n)for(int j=i;j<n;++j){
		int cost=min({j-i,abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1});
		ans[cost]++;
	}
	
	for(int i=1;i<n;++i) cout<<ans[i]<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////


ll Q, H, S, D;
ll N;
ll ans;

int main(){
	
	cin>>Q>>H>>S>>D;
	cin>>N;
	
	H = min( H, 2*Q );
	S = min( S, 2*H );
	D = min( D, 2*S );
	
	ans += D*(N/2);
	N %= 2;
	if( N ) ans += S;
	
	cout<<ans<<endl;	
	
	return 0;
	
}

Measured memory_bytes: 256