akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
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 REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){
  
    int n, m;
    map<string, int> keep;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
	string s; cin >> s;
	keep[s] += 1;
    }
    cin >> m;
    for(int i = 0 ; i < m ; i++){
	string t; cin >> t;
	keep[t] -= 1;
    }
    
    int ans = 0;
    for(auto itr = keep.begin() ; itr != keep.end() ; itr++)
	if(itr->second > ans)  ans = itr->second;

    SCOUT(ans) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int A,B;
cin >> A >> B;
int ans = A+B;
if(ans<10) {
  cout << ans << endl;
} else {
  cout << "error" << endl;
}
return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int a=0;
		int b =0;
		int c =0;
		if(S.charAt(0)=='o') {
			a = 100;
		}
		if(S.charAt(1)=='o') {
			b =100;
		}
		if(S.charAt(2)=='o') {
			c = 100;
		}
		System.out.println(700+a+b+c);
		sc.close();
	}

}


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

using namespace std ;

int main () {

   string s ;

   cin >> s;

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

   if (s[0]==s[1] and s[2]==s[3] and s[0]!=s[3])
    cout << "Yes" ;
   else
    cout << "No" ;

    return 0 ;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = scanner.nextInt();
        String ans = "";

        switch (N){
            case 1:
                ans = "Hello World";
                break;
            case 2:
                int a = scanner.nextInt();
                int b = scanner.nextInt();
                ans = Integer.toString(a+b);
                break;
        }
        System.out.println(ans);
        scanner.close();
    }
}


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

ll M, K;

/*
    M==0, M==1の場合
      ？
    
    
    Mが2以上の場合
    2**M未満の全ての数のXORすると 0 になる
    
    Kが0の場合
      a,b,c, ... ... c,b,a の形
    
    Kが0でない場合
     全ての数を、以下の3つに分ける
       K
       A, B : XORしてKになる組み合わせ  A^B=K && A != B && A != K && B != K
       a,b,c.. : 残り
     
     K^A^B == 0
     a^b^c^... = 0
    
     a,b,c.. A B ..c,b,a K B A K
      の形にする
    
    
    
*/

int main(){
	cin >> M >> K;
	
	if ( M == 0 ){
		if ( K == 0 )
			cout << "0 0" << endl;
		else
			cout << -1 << endl;
	}
	else if ( M == 1 ){
		if ( K == 0 )
			cout << "0 0 1 1" << endl;
		else
			cout << -1 << endl;
	}
	else {
		ll max = 1<<M;
		if ( K == 0 ){
			for ( ll i = 0; i < max; i++ ){
				cout << i << " ";
			}
			for ( ll i = max-1; i >= 0; i-- ){
				cout << i << " ";
			}
		}
		else if ( max <= K ){
			cout << -1 << endl;
		}
		else {
			ll A, B;
			A = 1;
			B = K ^ A;
			if ( B == 0 ){
				A = 2;
				B = K ^ A;
			}
			
			//  a,b,c.. A B ..c,b,a K B A K
			for ( ll i = 0; i < max; i++ ){
				if ( i != A && i != B && i != K )
					cout << i << " ";
			}
			cout << A << " " << B << " ";
			for ( ll i = max-1; i >= 0; i-- ){
				if ( i != A && i != B && i != K )
					cout << i << " ";
			}
			cout << K << " " << B << " " << A << " " << K << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    int ans=0,temp=0;
    cin >> N;
    for(int i=0;i<4;++i){
        if(N[i]=='2') ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != '?')cout << s[i];
		else cout << 'D';
	}
	cout << endl;
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
//------------
void func() {
    int D ,N;
    cin >> D >> N;
    cout << (D == 0 ? 1 : (D == 1 ? 100 : 10000)) * (N == 100 ? (N + 1) : N) << endl;
}

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

Measured memory_bytes: 256
(() -> begin
  n = readline() |> x->parse.(Int,x)
  s = readline()
  dict = Dict([['R',0],['G',0],['B',0]])
  for i in 1:n
    dict[s[i]] += 1
  end
  ans = dict['R'] * dict['G'] * dict['B']
  for i in 1:n-2
    for j in i+1:n-1
      k = 2 * j - i
      if k > n
        break
      end
      if s[i] != s[j] && s[j] != s[k] && s[k] != s[i]
        ans -= 1
      end
    end
  end
  println(ans)
end)()


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

const int K = 18, N = 55;
long long C[N][N];
int cnt[1<<K];

void pre() {
    for (int i=0; i<N; i++) C[i][0] = 1;
    for (int i=1; i<N; i++)
        for (int j=1; j<N; j++)
            C[i][j] = C[i-1][j-1] + C[i-1][j];

    for (int i=0; i<N; i++)
        for (int j=1; j<N; j++)
            C[i][j] += C[i][j-1];
}

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

    int n, k, S, T;
    cin>>n>>k>>S>>T;

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

    long long ans = 0;
    for (int mask = 0; mask < (1<<K); mask++) {
        if ((S&mask) != S || (T&mask) != mask)  continue;

        vector<int> vv;
        for (int i=0; i<n; i++) {
            if ((S&v[i]) != S || (T&v[i]) != v[i])  continue;
            int z = v[i] & (~mask);
            cnt[z]++;
            vv.push_back(z);
        }

        long long ww = 0;
        for (int x: vv){
            ww += C[cnt[x]][k]-1;
            cnt[x] = 0;
        }

        int bc = __builtin_popcount(mask);
        if (bc%2)   ans += ww;
        else        ans -= ww;
    }
    cout<<abs(ans)<<endl;
}


Measured memory_bytes: 4636
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <vector>
using namespace std;

//===
// memory: O(HW)
// time: O(logH * logW)
template<class T, class OP = function<T(T, T)> >
struct SegmentTree2D {
    const OP mergef;
    const size_t H, W;
    const T e;
    vector<vector<T> > tree;

    SegmentTree2D(size_t H, size_t W, const T &e, const OP &f):
        H(H), W(W), e(e), mergef(f)
    {
        tree.assign(H << 1, vector<T>(W << 1, e));
    };

    void update(int sy, int sx, T dat) {
        sy += H;
        sx += W;
        
        int ty, tx;
        tree[sy][sx] = dat;
        tx = sx;
        while (tx > 1) {
            tx >>= 1;
            tree[sy][tx] = mergef(tree[sy][(tx << 1)],
                                  tree[sy][(tx << 1) | 1]);
        }

        ty = sy;
        while (ty > 1) {
            ty >>= 1;
            tx = sx;
            tree[ty][tx] = mergef(tree[(ty << 1)][tx],
                                  tree[(ty << 1) | 1][tx]);
            while (tx > 1) {
                tx >>= 1;
                tree[ty][tx] = mergef(tree[(ty << 1)][tx],
                                      tree[(ty << 1) | 1][tx]);
            }
        }
    };

    T fold(int sy, int sx, int ty, int tx) {
        sy += H;
        ty += H;

        T ret = e;
        while (sy < ty) {
            if (sy & 1) ret = mergef(ret, fold_x(sy++, sx, tx));
            if (ty & 1) ret = mergef(fold_x(--ty, sx, tx), ret);

            sy >>= 1;
            ty >>= 1;
        }
        return ret;
    };
    T fold_x(int y, int l, int r) {
        l += W;
        r += W;

        T ret = e;
        while (l < r) {
            if (l & 1) ret = mergef(ret, tree[y][l++]);
            if (r & 1) ret = mergef(tree[y][--r], ret);

            l >>= 1;
            r >>= 1;
        }
        return ret;
    };

    T at(int sy, int sx) const {
        return tree[sy + H][sx + W];
    };
};
//===

using llong = long long;

int AOJ1068() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    llong r, c, q;
    llong gr;
    llong sy, sx, ty, tx;

    cin >> r >> c >> q;
    while (r != 0 && c != 0 && q != 0) {
        auto f = [](llong l, llong r){return min(l, r);};
        SegmentTree2D<llong, decltype(f)> seg(r, c, 1ll << 60ll, f);
        
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                cin >> gr;
                seg.update(i, j, gr);
            }
        }

        for (int i = 0; i < q; i++) {
            cin >> sy >> sx >> ty >> tx;

            cout << seg.fold(sy, sx, ty + 1,  tx + 1) << '\n';
        }

        /*
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                cout << seg.at(i, j) << ' ';
            }
            cout << endl;
        }
        */
        
        cin >> r >> c >> q;
    }

    return 0;
}

int main() {
    return AOJ1068();
}



Measured memory_bytes: 112088
# coding: utf-8
# Your code here!
class UnionFind:
    def __init__(self, size):
        self.rank = [0 for i in range(size)]
        self.parent = [-1 for i in range(size)]
        self.children = [[i] for i in range(size)]
    
    def Find(self, x):
        parent = self.parent[x]
        while parent >= 0:
            x = parent
            parent = self.parent[x]
        return x
    
    def Union(self, x, y):
        root_x = self.Find(x)
        root_y = self.Find(y)
        if root_x == root_y:
            return
        else:
            if self.rank[root_x] >= self.rank[root_y]:
                self.parent[root_x] += self.parent[root_y]
                self.parent[root_y] = root_x
                self.rank[root_x] = max(self.rank[root_y] + 1, self.rank[root_x])
                self.children[root_x] += self.children[root_y]
            else:
                self.parent[root_y] += self.parent[root_x]
                self.parent[root_x] = root_y
                self.rank[root_y] = max(self.rank[root_x] + 1, self.rank[root_y])
                self.children[root_y] += self.children[root_x]
    def Same(self, x, y):
        return self.Find(x) == self.Find(y)
    def FindRootAndSizeAndChildren(self):
        return [(idx, -val, self.children[idx]) for idx, val in enumerate(self.parent) if val<0 ]
    def print_lists(self):
        print(self.rank)
        print(self.parent)
        print()


N, M = map(int, input().split())
unionfind = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    unionfind.Union(a-1, b-1)

max_size = 0
for idx, size, children in unionfind.FindRootAndSizeAndChildren():
    if size > max_size:
        max_size = size
print(max_size)


Measured memory_bytes: 56164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Maxn=1005,Maxm=2005,mod=1e9+7;
bool chk[Maxm];
vector<pair<int,int>>w[Maxn];
struct node{int x,y,v;}e[Maxm];
int fa[Maxn];ll X;
int Getfa(int x){return fa[x]=(fa[x]==x?x:Getfa(fa[x]));}
int dfs(int x,int fa,int t){
    if(x==t)return -1;
    for(auto i:w[x]){
        int y,v;tie(y,v)=i;
        if(y==fa)continue;
        if(int ret=dfs(y,x,t))
            return max(ret,v);
    }
    return 0;
}
int ksm(int x,int k){
    int ret=1,tmp=x;
    while(k){
        if(k&1)ret=1ll*ret*tmp%mod;
        tmp=1ll*tmp*tmp%mod;k>>=1;
    }
    return ret;
}
int main(){
    int n,m;scanf("%d%d%lld",&n,&m,&X);
    for(int i=1;i<=n;i++)fa[i]=i;
    for(int i=1;i<=m;i++)
        scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].v);
    sort(e+1,e+m+1,[](const node&a,const node&b){
        return a.v<b.v;
    });
    ll cost=0,cnt1=0,cnt2=0;
    for(int i=1;i<=m;i++){
        int x=e[i].x,y=e[i].y;
        if(Getfa(x)==Getfa(y))continue;
        fa[Getfa(x)]=Getfa(y);
        cost+=e[i].v;chk[i]=true;
        w[x].emplace_back(y,e[i].v);
        w[y].emplace_back(x,e[i].v);
    }
    if(cost>X){
        cout<<"0\n";
        return 0;
    }
    for(int i=1;i<=m;i++){
        if(chk[i])continue;
        int v=e[i].v-dfs(e[i].x,0,e[i].y);
        if(v==X-cost)cnt1++;
        if(v>X-cost)cnt2++;
    }
    int ans=1ll*ksm(2,cnt2+1)*(ksm(2,cnt1)-1)%mod;
    if(X==cost)ans=(ans+1ll*(ksm(2,n-1)-2)*ksm(2,m-n+1))%mod;
    cout<<(ans+mod)%mod<<"\n";
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;

class Test
{
    static void Main()
    {
        string s = Console.ReadLine();
        int q = int.Parse(Console.ReadLine());
        string s1 = null;
        string s2 = null;

        for (int i = 0; i < q; i++)
        {
            string[] comm = Console.ReadLine().Split();

            switch (comm[0])
            {
                case "print":
                    Console.WriteLine(s.Substring(int.Parse(comm[1]), int.Parse(comm[2])-int.Parse(comm[1])+1));
                    break;

                case "reverse":
                    if (int.Parse(comm[1]) > 0) s1 = s.Substring(0, int.Parse(comm[1]));
                    if (int.Parse(comm[2]) < s.Length) s2 = s.Substring(int.Parse(comm[2]) + 1);
                    s = string.Concat(s1, new String(s.Substring(int.Parse(comm[1]), int.Parse(comm[2]) - int.Parse(comm[1]) + 1).Reverse().ToArray()), s2);
                    s1 = null;
                    s2 = null;
                    break;

                case "replace":
                    if (int.Parse(comm[1]) > 0) s1 = s.Substring(0, int.Parse(comm[1]));
                    if (int.Parse(comm[2]) < s.Length) s2 = s.Substring(int.Parse(comm[2]) + 1);
                    s = string.Concat(s1, comm[3], s2);
                    s1 = null;
                    s2 = null;
                    break;
            }
        }
    }
}


Measured memory_bytes: 18372
S = input()
N = len(S)
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

if is_kaibun(S):
  if is_kaibun(S[0:(N - 1)//2]):
    if is_kaibun(S[(N + 3)//2 - 1:]):
      print('Yes')
      exit()
print('No')

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var m = int.Parse(ReadLine());
        for(int i = 0; i < m; i++)
        {
            if(n[0] >= n[1])
                n[1] <<= 1;
            else if(n[1] >= n[2])
                n[2] <<= 1;
        }
        if(n[0] < n[1] && n[1] < n[2])
            WriteLine("Yes");
        else
            WriteLine("No");
    }
}


Measured memory_bytes: 19068
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

string SORT_S(string str) {

	vector<string> V;

	int M = str.size();
	for (int i = 0; i < M; i++) {
		V.push_back(str.substr(i, 1));
	}

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

	string ret = "";
	for (int i = 0; i < M; i++) {
		ret += V[i];
	}

	return ret;

}


int N;
string s[100005];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> s[i];
	}

	vector<string> S;

	for (int i = 1; i <= N; i++) {
		S.push_back(SORT_S(s[i]));
	}

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

	long long int cnt = 0;

	long long int ans = 0;

	for (int i = 0; i < N; i++) {
		if (cnt == 0) { cnt++; }
		else if (S[i] == S[i - 1]) { cnt++; }
		else { ans += (cnt*(cnt - 1)) / 2; cnt = 1; }
	}


	/*for (int i = 0; i < N; i++) {
		cout << S[i] << endl;
	}*/
	ans+= (cnt*(cnt - 1)) / 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14324
#include<cstdio>
#include<algorithm>
using namespace std;

#define ran 101101

int n, k;
int a[111];
int dp[ran];

int main() {
	scanf("%d%d", &n, &k);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a, a+n);
	
	dp[0] = false;
	for(int i=1;i<=k;i++) {
		bool got = false;
		for(int j=0;j<n && !got;j++) {
			if (a[j]>i) break;
			if (!dp[i-a[j]]) got = true;
		}
		dp[i] = got;
	}
	puts((dp[k]) ? "First" : "Second");
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,r,p;
  long long sum=0;
  cin>>k;

  for(int i=1;i<=k;i++)
  {
      for(int j=1;j<=k;j++)
      {     p=__gcd(i,j);
          for(int r=1;r<=k;r++)
          {
              sum+=__gcd(r,p);
          }
      }
  }
  cout<<sum<<"\n";
  return 0;
}


Measured memory_bytes: 3636
/******************************************c++
* 04.07 AtCoder Beginner Contest 160. D - Line++
* 
* 
*********************************************/
/*********************************************

問題文N+M個のボールがあります。
各ボールには整数が1つ書かれています。
これらのボールに書かれている数について、
•N個のボールに書かれている数は偶数
•M個のボールに書かれている数は奇数
であることがわかっています。

これらのN+M個のボールの中から2つ選んで、書かれた数の和が偶数になる方法の数
を求めてください。

::test input::
13 3

*********************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define ET "\n"

class Calgorithm {
public:
    Calgorithm(){}; ~Calgorithm(){};
    
    template<typename T>
    T combination(T n, T r) {
        if (n == r || r == 0) return 1;
        else return this->combination(n -1, r -1) + this->combination(n -1, r);
    }
};

class CRun{
private:
    struct {
        int N, M;
    }gv;
public:
    CRun(){}; ~CRun(){};
    void build(); void solve();
};

void CRun::build(){
    cin >> gv.N >> gv.M;
}

void CRun::solve(){
    int ans = 0;
    Calgorithm algo;
    
    //NN
    if (gv.N >= 2){
        ans += algo.combination(gv.N, 2);
    }
    
    //MM
    if (gv.M >= 2) {
        ans += algo.combination(gv.M, 2);
    }
    
    //NM
    ;
    
    cout << ans;
    
}

int main(){
    CRun run;
    run.build();
    run.solve();
}


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

int main(){

	int cnt = 0;
	std::string w, t;
	std::cin >> w;
	while (std::cin >> t){
		if (t == "END_OF_TEXT")break;

		for (int i = 0; i < t.size(); i++){
			if ('A' <= t[i] && t[i] <= 'Z')t[i] += 32;
		}

		if (t == w)cnt++;
	}

	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

#define N 100

int main() {
	int h, w, w_;

	scanf("%d%d", &h, &w), w += 2;
	w_ = w;
	while (w--)
		printf("#");
	printf("\n");
	while (h--) {
		static char s[N + 1];

		scanf("%s", s);
		printf("#%s#\n", s);
	}
	while (w_--)
		printf("#");
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
N, M = [int(i) for i in input().split()]

def prime_decomposition(n):
  table = []
  i = 2
  while i * i <= n:
    count = 0
    while n % i == 0:
      n //= i
      count += 1
    if count != 0:
        table.append((i, count))
    i += 1
  if n > 1:
    table.append((n, 1))
  return table

def cmb(n,r):
    from operator import mul
    from functools import reduce
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

mod = 10 ** 9 + 7
A = prime_decomposition(M)
result = 1
for _, a in A:
    result = result * cmb(a + N - 1, a) % mod

print(result)

Measured memory_bytes: 3572
fun main(args: Array<String>) {

    fun gcd(a: Int, b: Int): Int {
        return if (b == 0) a else gcd(b, a % b)
    }

    val (n, x) = readLine()!!.split(' ').map { it.toInt() }
    val xs = readLine()!!.split(' ').map { it.toInt() }
    xs.map { Math.abs(x - it) }
            .reduce { acc, i -> gcd(acc, i) }
            .let { println(it) }

}


Measured memory_bytes: 51844
#include<stdio.h>

void swap(int *, int *);
int Partition(int *,int , int);

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

void swap(int *a, int *b){
    int tmp=*a;
    *a=*b;
    *b=tmp;
}

int Partition(int *A, int p, int r){
    int x = A[r];
    int i= p-1,j;
    for(j=p; j<r; j++){
        if(A[j]<=x){
            i++;
            swap(&A[i],&A[j]);
        }
    }
    swap(&A[i+1],&A[r]);
    return i+1;
}


Measured memory_bytes: 2144
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;
fn main() {
    let (k, n): (usize, usize);
    input!(k, n);
    let a = input_vector::<usize>();
    let mut d = vec![];
    let mut prev = a[0];
    for i in 0..a.len() {
        d.push(a[i] - prev);
        prev = a[i];
    }

    d.push(k + a[0] - *a.last().unwrap());
    d.sort();
    d.reverse();
    println!("{}", d.iter().skip(1).sum::<usize>());
}


Measured memory_bytes: 11504
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
ll fact[1000007]={0}; // returns factorial of that number
bool sv[maxx]={0};    // returns if a num is prime or not
int sp[maxx]={0};     // gives smallest prime factor of the number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void Sieve() {for(int i= 2; i< maxx; i+= 2)sp[i] = 2;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
int k,dp[100][2][4];
int func( string arr,int pos,bool tight,int digitsUsed){
  
  if(digitsUsed==k && pos==arr.length())
    return 1;
  if(digitsUsed>k)
  {
    return 0;
  }
  if(pos==arr.length())
    return 0;
  if(dp[pos][tight][digitsUsed]!=-1) 
    return dp[pos][tight][digitsUsed];
  int ans=0;
  if(tight)
  {
    for(int i=0;i<=(arr[pos]-'0');i++)
    {
      if(i!=0)
        digitsUsed++;
      if(i==(arr[pos]-'0'))
      {
        ans+=func(arr,pos+1,1,digitsUsed);
      }
      else
      {
        ans+=func(arr,pos+1,0,digitsUsed);
      }
      if(i!=0)
        digitsUsed--;
      
    }
  }
    else
    {
      for(int i=0;i<=9;i++)
      {
        if(i!=0)
          digitsUsed++;
        ans+=func(arr,pos+1,0,digitsUsed);
        if(i!=0)
          digitsUsed--;
        
      }
    }
    dp[pos][tight][digitsUsed]=ans;
    return ans;
    

}

signed main(){
  fast;
  //usefile;
  //test
  {
    // fill(dp,dp+800,-1);
    memset(dp,-1,sizeof(dp));
    string n;
    cin>>n;
    cin>>k;
  cout<<func(n,0,1,0);
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    VI a(n);
    REP(i,n){
        cin >> s[i] >> a[i];
    }
    string x;
    cin >> x;
    int ans = 0;
    FORR(i,n-1,0){
        if (s[i] == x) break;
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(void) {
	int n,d[100];
	int i,j;
	int sum=0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &d[i]);
	}
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			sum = sum + d[i] * d[j];
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    int h,w,k;cin>>h>>w>>k;
    char mp[h][w];
    vector<int> cnt(h,0);
    rep(i,h){
        rep(j,w){
            cin>>mp[i][j];
            if(mp[i][j]=='#') cnt[i]++;
        }
    }

    int ans[h][w]={};
    int tob=0;
    while(cnt[tob]==0) tob++;
    //o~tobはあとで埋める
    int itigo=0;
    for(int i=tob;i<h;i++){
        if(cnt[i]==0){
            rep(j,w){
                ans[i][j]=ans[i-1][j];
            }
        }
        else{
            int c=0;
            rep(j,w){
                ans[i][j]=itigo+1+c;
                if(mp[i][j]=='#'&&c<cnt[i]-1) c++;
            }
            itigo+=c+1;
        }
    }

    rep(i,tob){
        rep(j,w){
            ans[i][j]=ans[tob][j];
        }
    }

    rep(i,h){
        rep(j,w){
            cout<<ans[i][j];
            cout<<(j==w-1?'\n':' ');
        }
    }
    return 0;
}


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

int main(){
  string s;
    cin >> s;
  int ans=0;
  string tmp;
    for(int i=0; i<s.size(); i++)  ans += s[i]-'0';
    (stoi(s))%ans==0 ? tmp="Yes" : tmp="No";
  cout << tmp << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		Set<Integer> set = new HashSet<Integer>();
		int n = input.nextInt();
		for(int i =0;i<n;i++){
			set.add(input.nextInt());
		}
		System.out.println(set.size());
	}
}


Measured memory_bytes: 21204
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <atcoder/scc>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
//using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
}

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}

int main(void)
{
    lli a, b, c, d;
    cin >> a >> b >> c >> d;
    lli ans = 0;

    cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double
#define ss(x) (int) x.size()
#define FOR(i, n) for(int i = 1; i <= n; ++i)
#define fi first
#define se second
#define cat(x) cout << #x << " = " << x << endl
	
using namespace std;

int n;	

int main() {		
	cin >> n;
	cout << (n / 2) - (n % 2 == 0);
		
	return 0;
}


Measured memory_bytes: 256
N = int(input())
costs = list(map(int, input().split()))

dp = [0]*N

dp[0] = 0
dp[1] = abs(costs[1] - costs[0])
for i in range(2,N,1):
  dp[i] = min(dp[i-2] + abs(costs[i]-costs[i-2]), dp[i-1] + abs(costs[i]-costs[i-1]))

print(dp[-1])


Measured memory_bytes: 13980
N,x = map(int, input().split())
lis = [int(i) for i in input().split()]
lis.sort()
s = 0
ans = 0
for nums in lis:
  if x >= nums:
    x += -nums
    ans += 1
if ans == N and x != 0:
  ans = ans-1
print(ans)

Measured memory_bytes: 3060
from collections import deque
k = int(input())
q = deque(["1", "2", "3", "4", "5", "6", "7", "8", "9"])
cnt = 1
while cnt < k:
  add = deque()
  num = q.popleft()
  if num[-1] == "0":
    add.append(num + "0")
    add.append(num + "1")
  elif int(num[-1]) < 9:
    add.append(num + str(int(num[-1]) - 1))
    add.append(num + num[-1])
    add.append(num + str(int(num[-1]) + 1))
  else:
    add.append(num + "8")
    add.append(num + "9")
  q.extend(add)
  cnt += 1
print(q.popleft())

Measured memory_bytes: 17012
#include<iostream>

using namespace std;

int main(void)
{
  char a[15],b[15],c[15];
  cin>>a>>b>>c;
  int len1=0,len2=0,len3=0;
  
  while(a[len1]!=0x00){ len1++; }
  while(b[len2]!=0x00){ len2++; }
  while(c[len3]!=0x00){ len3++; }
  
  if((a[len1-1]==b[0])&&(b[len2-1]==c[0])){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<int>> cnt(h, vector<int>(w));

  rep(i, h) {
    vector<int> done(w);
    rep(j, w) {
      if (s[i][j] == '#') continue;
      if (done[j]) continue;
      int l = 0;
      while (j + l < w) {
        if (s[i][j + l] == '#') break;
        ++l;
      }
      rep(k, l) {
        cnt[i][j + k] += l;
        done[j + k] = 1;
      }
    }
  }

  rep(j, w) {
    vector<int> done(h);
    rep(i, h) {
      if (s[i][j] == '#') continue;
      if (done[i]) continue;
      int l = 0;
      while (i + l < h) {
        if (s[i+l][j] == '#') break;
        ++l;
      }
      rep(k, l) {
        cnt[i + k][j] += l;
        done[i + k] = 1;
      }
    }
  }

  int ans = 0;
  rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
  cout << ans << endl;
  return 0;
}

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

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

//最大公約数の問題に帰着できる
int main(){
    ll n;
    cin >> n;
    int ans=0;
    cin >> ans;
    for(int i=0; i<n-1; i++){
        int temp;
        cin >> temp;
        ans = gcd(ans,temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;

class Main{
public static void main(String argv[]){
    Scanner sc = new Scanner(System.in);
    boolean flag = false;
    for(int i=0;i<2;i++){
        int x = sc.nextInt();
        if((x%2)==0){flag = true;}
    }
    sc.close();
    if(flag==true){System.out.println("Even");}
    else{System.out.println("Odd");}
}
}

Measured memory_bytes: 22484
#???
n,k = map(int,input().split())
l=[int(input()) for _ in range(n)]

def check(p):
    j=0
    for _ in range(k):
        sum=0
        """
        if l[j]>p: #そもそもある一個の荷物の重さがpを超える場合
            return False #j=0の瞬間から引っかかったとしてもwhileには入らないので、k回ループの後どうせfalseになる
            """
        while sum+l[j] <= p:
            sum+=l[j]
            j+=1
            if j==n:
                return True
    return False

#binarysearch
L=0
R=10000*100000
ans=0
while L<=R:
    M = (L+R) // 2
    if check(M):
        ans=M
        R=M-1#最終的にこの行のRを答えとして出そうとすると、実際の最小値より下回ってしまうことがあるので注意。
            #この行は次のbinarysearchに進む前提で更新しているのでこれを出力しない
    else:
        L=M+1
print(ans)


# もし，仮に，Pが決まっていたら前から貪欲にギリギリまで物を詰めるのが最適
# そうすることで必要なトラックの数を最小に抑えることができる
#
"""
#include <iostream>

using namespace std;

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

typedef long long ll;

int n, k;
int w[100001];
#二分探索を進めてPの最小値を決定する
bool check(int p){ #Pの値を二分探索して，判定関数はそのPの値でk台以内で荷物を積み切れるか
  #を判定、積み切れるならtrue->さらに小さい値からPを探す(right(最大値)を小さくする)。
  # 積み切れないならfalse->さらに大きい値からPを探す(left(最小値))を大きくする。
  ll sum=0;
  int idx = 0;

  rep(i, k){#k台以内に全ての荷物を積み切れるか？
    sum = 0;
    while(w[idx] + sum <= p){#k以内ならwhileは何回入ってもいい、入り直すたびにトラックが新しくなる(sum=0にする)
      sum+=w[idx];
      idx++;
      if(idx == n) return true;
    }
  }
  return false;
}

signed main(){
  cin >> n >> k;

  rep(i, n) cin >> w[i];
  
  // binary search
  ll left = 0, right = 100000 * 10000;#もしトラックの数が１台しかなければ全ての荷物が最大重量の場合(w_i=10000)をその最大個数分(n=100000)積めなくてはならないのでこれがPの最悪計算量(最大値)
  while(right - left > 1){
    ll mid = (left + right) / 2;
    if(check(mid)) right = mid;
    else left = mid;
  }
  
  cout << right << endl;
}
"""


Measured memory_bytes: 9564
using System.Linq;
using System;
namespace ConsoleApp1123
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim();
            var s2 = (new string(' ', 200000) + s + new string(' ', 200000)).ToCharArray();
            var rev = false;
            var left = 200000;
            var right = 200000 + s.Length - 1;
            var q = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < q; i++)
            {
                var l = Console.ReadLine().Trim();
                if (l[0] == '1')
                {
                    rev = !rev;
                }
                else
                {
                    if ((l[2] == '1') == !rev)
                    {
                        left--;
                        s2[left] = l[4];
                    }
                    else
                    {
                        right++;
                        s2[right] = l[4];
                    }
                }
            }

            var r = new string(rev ? s2.Reverse().ToArray() : s2).Trim();
            Console.WriteLine(r);
        }
    }
}


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

int main() {
  int n=0;
  cin >> n;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++) {
    cin >> vec.at(i);
  }
  
  int now=0;
  
  vector<bool> visited(n, false);
  visited.at(0) = true;
  
  int ans=0;
  
  while (now != 1) {
    if (visited.at(vec.at(now)-1) == false) {
      visited.at(vec.at(now)-1) = true;
      now = vec.at(now)-1;
      ans++;
    }
    else {
      ans = -1;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
try:
    a=[]
    while True:
        t=input()
        t=t.lower()
        for j in range(len(t)):
            x=ord(t[j])
            a.append(x)
except EOFError:
    pass

count=[0]*130
for i in a:
    count[i]+=1
    
for i in range(97,123):
    print(chr(i),':',count[i])


Measured memory_bytes: 5576
#include<stdio.h>
int n=0,dp[100005];

int min(int a,int b)
{
	int c=a<b?a:b;
	return c;
}
int mod(int a)
{
	if(a>=0)
		return a;
	else
		return -1*a;
}

int s(int a[],int i)
{
if(i==n-1)
return 0;

	if(dp[i]==-1)
	{
		dp[i] = min(s(a,i+1)+mod(a[i+1]-a[i]) , s(a,i+2)+mod(a[i+2]-a[i]));
	}
return dp[i];
}

int main()
{

	scanf("%d",&n);
	int a[n];

	for(int i=0;i<n;i++)
	{scanf("%d",&a[i]); dp[i]=-1;}

	int sum = s(a,0);

	printf("%d\n",sum);

	return 0;
}


Measured memory_bytes: 4096
using System.Linq;
using System.Collections.Generic;
using System;

public class Score
{
    public int id { get; set; }
    public int s { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var second = false;
        while (true)
        {
            var scores = new List<Score>();
            var n = int.Parse(Console.ReadLine().Trim());
            var tn = new string[n];
            if (n == 0) break;
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                scores.Add(new Score { id = i, s = 3 * int.Parse(line[1]) + int.Parse(line[3]) });
                tn[i] = line[0];
            }
            if (second) Console.WriteLine();
            else second = true;
            foreach (var x in scores.OrderByDescending(a => a.s))
                Console.WriteLine("{0},{1}", tn[x.id], x.s);
        }
    }
}

Measured memory_bytes: 9960
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Solver_agc009c solver = new Solver_agc009c();
		solver.input();
		solver.solve();
	}
}
class FastScanner {
	BufferedReader br;
	StringTokenizer st;
	public FastScanner(Reader in) {
		br = new BufferedReader(in);
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
				throw new RuntimeException("Can't read more inputs.");
			}
		}
		return st.nextToken();
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	long nextLong() {
		return Long.parseLong(next());
	}
	double nextDouble() {
		return Double.parseDouble(next());
	}
	String readNextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}
class Solver_agc009c {
	static FastScanner in = new FastScanner(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	final int mod = (int)1e9 + 7;
	int n;
	long a, b, s[];
	int f[], g[], sum_f[], sum_g[];
	void input() {
		n = in.nextInt();
		a = in.nextLong();
		b = in.nextLong();
		s = new long[n + 1];
		for(int i = 0; i < n; i++) s[i] = in.nextLong();
		s[n] = Long.MAX_VALUE;
		f = new int[n + 1];
		g = new int[n + 1];
		sum_f = new int[n + 1];
		sum_g = new int[n + 1];
	}
	int addmod(int a, int b) { return (a + b) % mod; }
	void solve() {
		f[n - 1] = g[n - 1] = 1;
		sum_f[n - 1] = sum_g[n - 1] = 1;
		int l_f = n, r_f = n, l_g = n, r_g = n;
		for(int i = n - 2; i >= 0; i--) {
			while(l_f - 1 > i + 1 && s[l_f - 1] - s[i] >= a) l_f--;
			while(l_g - 1 > i + 1 && s[l_g - 1] - s[i] >= b) l_g--;
			if(s[i + 2] - s[i + 1] < b) r_f = i + 2;
			if(s[i + 2] - s[i + 1] < a) r_g = i + 2;
			if(l_f <= r_f) {
				f[i] = addmod(sum_g[l_f - 1], mod - sum_g[r_f]);
			}
			if(l_g <= r_g) {
				g[i] = addmod(sum_f[l_g - 1], mod - sum_f[r_g]);
			}
			sum_f[i] = addmod(f[i], sum_f[i + 1]);
			sum_g[i] = addmod(g[i], sum_g[i + 1]);
		}
		int ans = addmod(f[0], g[0]);
		for(int i = 1; i < n; i++) {
			if(s[i] - s[i - 1] < a) break;
			ans = addmod(ans, f[i]);
		}
		for(int i = 1; i < n; i++) {
			if(s[i] - s[i - 1] < b) break;
			ans = addmod(ans, g[i]);
		}
		out.println(ans);
		out.close();
	}
}


Measured memory_bytes: 44952
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,x,y = LI()
    a = LI()
    ans = abs(a[-1]-y)
    if n > 1:
        ans = max(ans,abs(a[-2]-a[-1]))
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39280
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""



n = onem()
A = l()
B = l()

def count(start,id):
    co = 0
    s = start

    while True:
        s = id[s]
        co += 1
        if s == 0:
            break
    return co

L = []

for i in range(n):
    L.append([A[i],B[i]])
L.sort(key=lambda x:x[1])
p = sorted(range(n) , key = lambda i:L[i][0])

A.sort()



bo1 = all(A[i] <= L[i][1] for i in range(n))
bo2 = any(A[i+1] <= L[i][1] for i in range(n-1))
bo3 = count(0,p) <= n-2

print("Yes" if (bo1 and (bo2 or bo3)) else "No")


Measured memory_bytes: 93892
N,M = map(int,input().split())
edge = [0]*M
for i in range(M):
    a,b,c=map(int,input().split())
    a -= 1
    b -= 1
    c *= -1
    edge[i] = (a,b,c)

inf = float('inf')
V = N
E = M
d = [inf]*V
d[0] = 0
for i in range(V):
    update = False
    for j in range(E):
        From,To,cost = edge[j]
        if d[From] != inf and d[To]>d[From]+cost:
            d[To]=d[From]+cost
            update = True
    if not update:
        break
ans = d[N-1]
for j in range(E):
    From,To,cost = edge[j]
    if d[From] != inf and d[To]>d[From]+cost:
        d[To]=d[From]+cost

if d[N-1]!=ans:
    print('inf')
else:
    print(-ans)

Measured memory_bytes: 3316
N = int(input())
A = list(map(int, input().split()))

odd = 0
mul4 = 0

for a in A:
    if a % 2 != 0:
        odd += 1
    if a % 4 == 0:
        mul4 += 1

if mul4 >= odd:
    print('Yes')
else:
    if mul4 * 2 + 1 == N:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
N=int(input())
L = [list(map(int, input().split())) for i in range(N)]
dp=[[0 for j in range(3)] for i in range(N)]

for i in range(N):
  for P in range(3):
    for PY in range(3):
      if P==PY:
        continue
      elif i==0:
        dp[i][P]=L[i][P]
      else:
        dp[i][P]=max(dp[i][P],dp[i-1][PY]+L[i][P])
ans=0
for i in range(3):
  ans=max(ans,dp[N-1][i])
print(ans)

Measured memory_bytes: 47344
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int cnt = 0;
	string s; cin >> s;
	for (char x : s)cnt += (x == 'R');
	if (cnt <= 1)cout << cnt << endl;
	else if (s[1] == 'R')cout << cnt << endl;
	else cout << 1 << endl;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int n,w1=0,w2=0,e1=0,e2=0,tmp1=0,tmp2=0,count[300005]={0},min=300005;
  char s[300005];
  scanf("%d",&n);
  scanf("%s",s);
  for(int i=0;i<n;i++){
    if(s[i]=='W') w2++;
    else e2++;
  }
  for(int i=0;i<n;i++){
    if(s[i]=='W'){
      w2--;
      if(tmp1==1){
        e1++;
        tmp1=0;
      }
      if(tmp2==1){
        w1++;
        tmp2=0;
      }
      count[i]=w1+e2;
      tmp2++;
    }
    if(s[i]=='E'){
      e2--;
      if(tmp1==1){
        e1++;
        tmp1=0;
      }
      if(tmp2==1){
        w1++;
        tmp2=0;
      }
      count[i]=w1+e2;
      tmp1++;
     }

  }

  for(int i=0;i<n;i++){
    if(min>count[i]) min=count[i];
  }
  printf("%d",min);
  return 0;
}

Measured memory_bytes: 3176