akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int A[10000000];
int H = 0;
int INF = 1001001001;

void heapIncreaseKey(int i, int k){
    A[i] = k;
    while(i > 1 && A[i/2] < A[i]){
        swap(A[i], A[i/2]);
        i /= 2;
    }
}

void insertx(int k){
    H++;
    A[H] = -INF;
    heapIncreaseKey(H, k);
}

void maxHeapify(int i){
    int l = i*2;
    int r = i*2 + 1;
    int largest;
    if(l <= H && A[l] > A[i]){
        largest = l;
    } else {
        largest = i;
    }
    if(r <= H && A[r] > A[largest]){
        largest = r;
    }

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
    return;
}

int heapExtractMax(){
    int maX = A[1];
    A[1] = A[H];
    H--;
    maxHeapify(1);
    return maX;
}

int main() {
    while(1){
        string S; cin >> S;
        if(S == "insert"){
            int n; cin >> n;
            insertx(n);
        } else if(S == "extract"){
            int n = heapExtractMax();
            cout << n << endl;
        } else {
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c){
    cout<<'1';
  }
  else if(a==b || a==c || b==c){
    cout<<'2';
  }
  else{
    cout<<'3';
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[26];
int main(){
	int sum=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)a[s[i]-'a']++;
		for(int i=0;i<26;i++)sum+=a[i]%2;
			cout<<sum/2<<endl;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1001001001001001001;


//N^P(modM)




int main() {
  string s;
  cin>>s;
  rep(i,s.size()){
    char now(s[i]);
    if (now=='?'){
      s[i]='D';
    }
  }
  cout<<s;

}


Measured memory_bytes: 3720
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_B
 */
#include <iostream>
#include <string>

using namespace std;

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

  while (true) {
    string line;
    getline(cin, line);

    if (line == "-") {
      break;
    }

    int m;
    cin >> m; cin.ignore();
    for (int i = 0; i < m; i++) {
      int h;
      cin >> h; cin.ignore();
      line = line.substr(h) + line.substr(0, h);
    }
    cout << line << endl;
  }

  return 0;
}

Measured memory_bytes: 3212
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
//________
#define pb        emplace_back
#define fi        first
#define se        second
#define ALL(x)    x.begin(),x.end()
#define err(...)  fprintf(stderr, __VA_ARGS__ )
#define show(x)   cerr << #x << ':' << (x) << endl
#define outl(x)   cout << (x) << '\n'
#define FAST()    cin.tie(0), ios::sync_with_stdio(false)
#define rep(i,n)     for(int i=0; i<(n); ++i)
#define reps(i,f,n)  for(int i=(f); i<=(n); ++i)
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
constexpr int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
typedef long long ll;
typedef pair<int,int> pii;
#define let const auto
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define NIL -1
//________


int N;
int a[100010];

signed main()
{
   FAST();

   cin >> N;
   reps(i, 1, N){
      cin >> a[i];
   }

   int sum = 0;
   for (int i=1; i<=N+1; ++i) {
      sum += abs(a[i-1] - a[i]);
   }


   // i-1 :start
   // i+1 :end
   reps(i, 1, N)
   {
      int now = i-1;
      int real = 0, ignore = 0;

      for(now=i-1; now<=i+1; ++now)
      {
         real += abs(a[now]-a[now-1]);
      }

      now = i-1;
      int before = i-2;
      for (now=i-1; now <= i+1; ++now) {
         if (now != i) {
            ignore += abs(a[now] - a[before]);
            before = now;
         }
      }

      outl(sum - abs(real - ignore));

   }
}



Measured memory_bytes: 1664
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    char str[28];
    bool flags[27];
    for (int i = 0; i < 27; i++)
        flags[i] = false;

    fgets(str, 28, stdin);
    for (int i = 0; str[i] != '\n'; i++) {
//        printf("[%d]", str[i] - 'a');
        if (flags[str[i] - 'a']) {
            puts("no");
            return 0;
        }
        flags[str[i] - 'a'] = true;
    }
    puts("yes");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

//条件を満たす人がX人以上いるか？？
bool cond(LL X, LL A, LL B) {
	if (X == 0)return true;
	LL lo = 1, hi = X;
	auto mpoint = [&](LL ix) {
		LL mA = ix;
		LL mB = X + 1 - mA;
		if (mA >= A)mA++;
		if (mB >= B)mB++;
		return mA * mB;
	};
	//±5付近を調べよう
	while (hi - lo > 100) {
		LL m1 = (lo + lo + hi) / 3;
		LL m2 = (lo + hi + hi) / 3;
		if (mpoint(m1) > mpoint(m2)) {
			hi = m2;
		}
		else {
			lo = m1;
		}
	}
	for (LL x = lo; x <= hi; ++x) {
		if (mpoint(x) >= A * B) {
			return false;
		}
	}
	return true;
}

int main(void)
{
	int Q;
	cin >> Q;
	for (int q = 0; q < Q; ++q) {
		LL A, B;
		cin >> A >> B;
		LL pot = A * B;
		LL lo = 0, hi = 3e9;
		while (hi - lo > 1) {
			LL mid = (lo + hi) / 2;
			if (cond(mid, A, B)) {
				lo = mid;
			}
			else {
				hi = mid;
			}
		}
		cout << lo << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import math

a, b, c, d = map(int, input().split())
l = c * d // math.gcd(c, d)
all = b - a + 1
can_c = b // c - (a - 1) // c
can_d = b // d - (a - 1) // d
can_cd = b // l - (a - 1) // l
ans = all - can_c - can_d + can_cd
print(ans)

Measured memory_bytes: 9096
def main():
    from collections import namedtuple
    from itertools import permutations
    from math import factorial

    City = namedtuple('City', 'x y')

    def dist(a: City, b: City) -> float:
        dx = a.x - b.x
        dy = a.y - b.y
        return (dx * dx + dy * dy) ** 0.5

    N = int(input())

    cities = []
    for _ in range(N):
        x, y = map(int, input().split())
        c = City(x=x, y=y)
        cities.append(c)

    total = 0
    for perm in permutations(cities):
        it = iter(perm)
        p = next(it)

        for city in it:
            total += dist(p, city)
            p = city

    ans = total / factorial(N)
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3572
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = [INT() for _ in range(N)]

seq = A[::-1]
LIS = [seq[0]]
for i in range(1, N):
	if LIS[-1] <= seq[i]:
		LIS.append(seq[i])
	else:
		LIS[bisect(LIS, seq[i])] = seq[i]

print(len(LIS))

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

int main() {
  int N,H,W;
  cin >> N >> H >> W;
  int count = 0;
  for(int i = 0;i < N;i++) {
    int A,B;
    cin >> A >> B;
    if(A >= H && B >= W) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)


using namespace std;
using ll = long long;

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;
    }
    return false;
}



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,k,ans=0;
    cin >> n >>k;
    int s[n];
    rep(i,n) s[i] =0;
    rep(i,k)
    {
        int d;
        cin >> d;
        rep(i,d)
        {
            int a;
            cin >> a;
            a--;
            s[a]++;
        }
    }
    rep(i,n)
    {
        if(s[i] == 0) ans++;
    }

    cout << ans << endl;


   

    return 0;
}


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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(X: int, Y: int, A: int, B: int, C: int, p: "List[int]", q: "List[int]", r: "List[int]"):
    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)
    xy = sorted(p[:X] + q[:Y])
    ans = sum(p[:X]) + sum(q[:Y])
    z = 0
    while z < X + Y and z < C and xy[z] < r[z]:
        ans += r[z] - xy[z]
        z += 1
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    q = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    r = [int(next(tokens)) for _ in range(C)]  # type: "List[int]"
    solve(X, Y, A, B, C, p, q, r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28124
package main
 
import (
	"fmt"
	"sort"
)
 
func main() {
	arr := scanStrings(1)
	str := arr[0]
	if str[0] >= "a"[0] {
		fmt.Print("a")
	} else {
		fmt.Print("A")
	}
 
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
 
}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}

Measured memory_bytes: 1836
#include "bits/stdc++.h"
using namespace std;
int main() {
  int a,b,c;
  int Moss[10]; 
  cin >> a >> b >> c;
  for (int i=0;i<10;i++) {
      if(i==0) {
          Moss[i] = a*c -b;
      } else {
          Moss[i] = a*Moss[i-1] -b;
      }
      printf("%d\n", Moss[i]);
  }
}

Measured memory_bytes: 256
import Data.List

splitimpl :: String -> String -> String -> [String]
splitimpl _ xs [] = [xs]
splitimpl d xs (y:ys) = maybe a f $ stripPrefix d (y:ys)
    where
        a = splitimpl d (xs ++ [y]) ys
        f = (xs:) . splitimpl d ""

split :: String -> String -> [String]
split d = splitimpl d ""

replace :: String -> String -> String -> String
replace old new = intercalate new . split old

solve :: String -> String
solve = replace "Hoshino" "Hoshina"

main :: IO ()
main  = getLine
    >>  getContents
    >>= mapM_ putStrLn . map solve . lines

Measured memory_bytes: 4116
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

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

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

main()
{
	IOS
	
	int n, D, X;
	cin >> n >> D >> X;
	
	for(int i = 1; i <= n; i++)
	{
		int p;
		cin >> p;
		
		X += (D - 1) / p + 1;
	}
	
	cout << X;
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll X[N];
    rep(i,N) {
        ll x;
        cin >> x;
        X[i] = x;
    }
    ll ans = 0;
    rep(i,N-1) {
        ll a = (X[i+1]-X[i])*A;
        ll b = B;
        ans += min(a,b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4320
#include <cstdio>
#include <cstdint>
#include <vector>

constexpr intmax_t mod = 1e9+7;

template <typename Tp>
Tp gcd(Tp a, Tp b, Tp& x, Tp& y) {
  x = Tp(0);
  y = Tp(1);
  for (Tp u = y, v = x; a;) {
    Tp q = b/a;
    std::swap(x -= q*u, u);
    std::swap(y -= q*v, v);
    std::swap(b -= q*a, a);
  }
  return b;
}

template <typename Tp>
Tp modinv(Tp a, Tp mod) {
  Tp x, y;
  gcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

template <typename Tp>
Tp modadd(Tp a, Tp b, Tp mod) {
  a += b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modadd(std::initializer_list<Tp> const& adds, Tp mod) {
  Tp res = 0;
  for (auto const& add: adds) {
    res += add % mod;
    if (res < 0) res += mod;
    if (res >= mod) res -= mod;
  }
  return res;
}

template <typename Tp>
Tp modsub(Tp a, Tp b, Tp mod) {
  a -= b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modmul(std::initializer_list<Tp> const& muls, Tp mod) {
  Tp res = 1;
  for (auto const& mul: muls) (res *= mul) %= mod;
  return res;
}

template <typename Tp>
Tp modpow(Tp base, intmax_t iexp, Tp mod) {
  Tp res = 1;
  for (Tp dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res = res * dbl % mod;
    dbl = dbl * dbl % mod;
  }
  return res;
}

class modchoose {
  std::vector<intmax_t> fact, fact_inv;
  const intmax_t mod;

public:
  modchoose(intmax_t N, intmax_t mod): mod(mod) {
    fact.resize(N+1);
    fact_inv.resize(N+1);
    fact[0] = 1;
    for (intmax_t i = 1; i <= N; ++i)
      fact[i] = fact[i-1] * i % mod;

    fact_inv[N] = modinv(fact[N], mod);
    for (intmax_t i = N; i--;)
      fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
  }

  intmax_t operator ()(intmax_t n, intmax_t r) const {
    if (!(0 <= r && r <= n)) return 0;
    intmax_t res = fact[n] * fact_inv[r] % mod;
    (res *= fact_inv[n-r]) %= mod;
    return res;
  }
};

int main() {
  intmax_t n, k;
  scanf("%jd %jd", &n, &k);

  modchoose mc(k, mod);
  intmax_t res = mc(k, n);
  printf("%jd\n", res);
}



Measured memory_bytes: 2728
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	string S;
	deque<char> dq;
	cin >> S;
	rep(i, S.size()) dq.push_back(S[i]);

	int Q;
	cin >> Q;
	int gyaku = 0;
	rep(i, Q) {
		int t;
		cin >> t;
		t--;
		if (!t) {
			gyaku = !gyaku;
		}
		else{
			int f;
			cin >> f;
			f--;
			char c;
			cin >> c;
			if (f ^ gyaku) {
				dq.push_back(c);
			}
			else dq.push_front(c);
		}
	}

	int m = dq.size();
	if (gyaku) {
		rep(i, m) {
			cout << dq[m - i - 1];
		}
	}
	else {
		rep(i, m) {
			cout << dq[i];
		}
	}
	cout << endl;



	Would you please return 0;
}

Measured memory_bytes: 976
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    std::vector<vector<int> > G(N, vector<int>());
    std::vector<vector<int> > dist(N, vector<int>());
    for (int i = 0; i < N; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            G[u].push_back(v);
            dist[u].push_back(c);
        }
    }

    std::vector<int> d(N, 100000001);
    priority_queue<P, vector<P>, greater<P> > q;
    d[0] = 0;
    q.push(P(0, 0));

    while(!q.empty()) {
        P u = q.top(); q.pop();
        int v = u.second;
        if (d[v] < u.first) {
            continue;
        }
        for (int i = 0; i < G[v].size(); i++) {
            if (d[G[v][i]] > d[v] + dist[v][i]) {
                d[G[v][i]] = d[v] + dist[v][i];
                q.push(P(d[G[v][i]], G[v][i]));
            }
        }
    }

    for (int i = 0; i < N; i++) {
        cout << i << " " << d[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define D_MAX 1 << 21
#define N_MAX 100
using namespace std;

int dis[N_MAX];
int n;

struct node {
  int to;
  int cost;
  node(int to,int cost) {
    this->to = to;
    this->cost = cost;
  }
};

void dijkstra(int st,vector< vector<node*> > &nodes) {
  for(int i=0;i<n;i++) dis[i] = D_MAX;
  dis[st] = 0;
  bool visited[n]; for(int i=0;i<n;i++) visited[i] = false;
  vector<int> vertexes;
  visited[st] = true;
  vertexes.push_back(st);
  int pre_cost = 0;
  while(vertexes.size() < n) {
    // update distance list
    int v = vertexes[vertexes.size()-1];
    for(int j=0;j<nodes[v].size();j++) {
      int u = nodes[v][j]->to;
      if(visited[u]) continue;
      int cost = nodes[v][j]->cost + pre_cost;
      dis[u] = min(dis[u],cost);
    }
    // find vertex which has smallest distance.
    int next_v;
    int minimum = D_MAX;
    for(int i=0;i<n;i++) {
      if(visited[i]) continue;
      if(dis[i] < minimum) {
        minimum = dis[i];
        next_v = i;
      }
    }
    visited[next_v] = true;
    vertexes.push_back(next_v);
    pre_cost = dis[next_v];
  }
}

int main() {
  scanf("%d",&n);
  int u,k,v,c;
  vector<vector< node*> > nodes;
  nodes.resize(n);
  for(int i=0;i<n;i++) {
    scanf("%d %d",&u,&k);
    for(int j=0;j<k;j++) {
      scanf("%d %d",&v,&c);
      nodes[u].push_back(new node(v,c));
    }
  }

  // check
  /*
  for(int i=0;i<nodes.size();i++) {
    for(int j=0;j<nodes[i].size();j++) {
      printf("%2d :%2d %2d\n",i,nodes[i][j]->to,nodes[i][j]->cost);
    }
  }
  */

  dijkstra(0,nodes);
  for(int i=0;i<n;i++) {
    printf("%d %d\n",i,dis[i]);
  }
}

Measured memory_bytes: 1424
from collections import defaultdict, deque

V, E, r = map(int, input().split(' '))

edges = defaultdict(set)

for _ in range(E):
    s, t, d = map(int, input().split(' '))
    edges[s].add((t, d))

costs = [-1] * V
costs[r] = 0

queue = deque()
queue.append(r)

while len(queue) > 0:
    s = queue.popleft()
    for t, d in edges[s]:
        if costs[t] < 0 or costs[s] + d < costs[t]:
            costs[t] = costs[s] + d
            queue.append(t)

for i in range(V):
    if costs[i] < 0:
        print('INF')
    else:
        print(costs[i])



Measured memory_bytes: 133760
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] array = new int[4];
      int i = 0;
      while(n >= 1){
      	array[i] = n%10;
        i++;
        n = n/10;
      }
      if( (array[0]==array[1]&&array[1]==array[2])||(array[1]==array[2]&&array[2]==array[3]) ){
      	System.out.println("Yes");
      }else{
      	System.out.println("No");
      }
    }
}


Measured memory_bytes: 21844
import math


X,Y=map(int, input().split())
if math.isclose(-Y/2+2*X, math.ceil(-Y/2+2*X)) and math.isclose(Y/2-X, math.ceil(Y/2-X)):
    if Y//2-X>0 and -Y/2+2*X>0:
        print("Yes")


    elif Y/2-X==0 and -Y/2+2*X>0:
         print("Yes")


    elif Y/2-X>0 and -Y/2+2*X==0:
         print("Yes")

    else:
         print("No")


else:
    print("No")


Measured memory_bytes: 9200
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

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

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    int n; 
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    for(int i = n-1; i>0; --i) {
        int left = h[i];
        int right = h[i-1];
        if ((right - left) > 1) {
            cout << "No" <<endl;
            return 0;
        } else if ((right - left) == 1) {
            --h[i-1];
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 2000000
#define Gard -1000000000

int main(){
  int loop;
  int i;
  int Profits[N];
  int minPro,maxPro;
  int start=1;

  scanf("%d",&loop);

  for(i=0;i<loop;i++){
    scanf("%d",&Profits[i]);
  }

  maxPro=Gard;
  minPro=Profits[0];

  while(1){
    if(start==loop){
      break;
    }
    
    if(maxPro<Profits[start]-minPro){
      maxPro=Profits[start]-minPro;
    }
    else{
      maxPro=maxPro;
    }

    if(minPro<Profits[start]){
      minPro=minPro;
    }

    else{
      minPro=Profits[start];
    }

    start++;
  }

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



Measured memory_bytes: 2504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define ff first
#define ss second
#define N 1000000007
#define INF (1ll<<60) - 1
#define M 998244353
#define rep(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define nrep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
ll a[6][6];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,x,y,q,n,z,l,k,r,ans=0,m;
    cin>>n>>m>>x;
    rep(i,0,n-1){
    	string s;
    	cin>>s;
    	rep(j,0,m-1){
    		if(s[j] == '#') a[i][j]=1; 
		}
	}
	for(i=0;i<(ll)pow(2,n);i++){
		for(j=0;j<(ll)pow(2,m);j++){
			ll cnt=0;
			for(k=0;k<n;k++){
				for(l=0;l<m;l++){
					if(a[k][l] and (i>>k)&1 and (j>>l)&1) cnt++;
				}
			}
			if(cnt==x) ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, k;
int a[N];
bool vis[N];

int32_t main()
{
	IOS;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int take = min(k, 200000LL);
	k -= take;
	int cur = 1;
	while(take > 0)
	{
		cur = a[cur];
		take--;
	}
	if(k == 0)
	{
		cout << cur;
		return 0;
	}
	int len = 0;
	while(!vis[cur])
	{
		vis[cur] = 1;
		len++;
		cur = a[cur];
	}
	k %= len;
	while(k > 0)
	{
		cur = a[cur];
		k--;
	}
	cout << cur;
	return 0;
}


Measured memory_bytes: 5336
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var N = NK[0]; var K = NK[1];

            var mod = N % K;
            Console.WriteLine(Math.Min(mod, Math.Abs(K - mod)));
        }
    }
}


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

void Main()
{
  string s;
  cin >> s;
  if (s[2]==s[3]&&s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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


void solve(long long N, long long M, std::vector<long long> P, std::vector<long long> Y)
{
    map<ll, vector<ll>> PYmap;
    for (ll i = 0; i < M; ++i) {
        PYmap[P[i]].push_back(Y[i]);
    }
    for (auto&& m: PYmap) {
        sort(begin(m.second), end(m.second));
    }
    for (ll i = 0; i < M; ++ i) {
        auto& Pcities = PYmap[P[i]];
        auto it = lower_bound(begin(Pcities), end(Pcities), Y[i]);
        auto x = distance(begin(Pcities), it) + 1;
        printf("%06lld%06ld\n", P[i], x);
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> P(M);
    std::vector<long long> Y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&P[i]);
        scanf("%lld",&Y[i]);
    }
    cin.tie(nullptr);
    cout.tie(nullptr);
	ios_base::sync_with_stdio(false);
    solve(N, M, std::move(P), std::move(Y));
    return 0;
}


Measured memory_bytes: 13952
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    char ss[20010];
    scanf("%s", ss);
    const string s = ss;
    auto f = [&s](int start) {
        vector<pair<char, int>> st;
        vector<int> v;
        int depth = 0;
        int current = 0;
        for (size_t i = start; i < s.size(); ++i) {
            switch (s[i]) {
            case '\\':
                current += depth * 2 + 1;
                depth += 1;
                st.push_back(make_pair(s[i], i));
                break;
            case '_':
                current += depth * 2;
                break;
            case '/':
                depth -= 1;
                current += depth * 2 + 1;
                if (st.empty()) {
                    depth = 0;
                    current = 0;
                }
                else {
                    st.pop_back();
                    if (st.empty()) {
                        v.push_back(current / 2);
                        depth = 0;
                        current = 0;
                    }
                }
                break;
            }
            // printf("stacksize: %ld, depth: %d, current: %d\n", st.size(),
            // depth,
            //       current);
        }
        if (st.empty()) {
            return make_pair(v, -2);
        }
        else {
            return make_pair(v, st[0].second);
        }
    };
    vector<int> v;
    int start = 0;
    do {
        auto r = f(start);
        v.insert(end(v), begin(r.first), end(r.first));
        start = r.second + 1;
        if (accumulate(begin(s) + start, end(s), true,
                       [](bool lhs, char rhs) { return lhs && rhs == '\\'; })) {
            // There is no valid area.
            break;
        }
    } while (start != -1);
    //    for (auto&& i : st) {
    //        printf("%c %d ", i.first, i.second);
    //    }
    // putchar('\n');
    // putchar('\n');
    printf("%d\n", accumulate(begin(v), end(v), 0));
    if (v.size() == 0) {
        printf("%ld\n", v.size());
    }
    else {
        printf("%ld ", v.size());
    }
    for (size_t i = 0; i < v.size(); ++i) {
        if (i != v.size() - 1) {
            printf("%d ", v[i]);
        }
        else {
            printf("%d\n", v[i]);
        }
    }
}

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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 2 * 100 * 1000 + 17;

ll n, a[MAXN], p[MAXN], ans;
set<ll> s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], p[a[i]] = i;
	s.insert(0);
	s.insert(n + 1);
	for (int i = 1; i <= n; i++) {
		auto t = s.lower_bound(p[i]);
		auto tp = t;
		tp--;
		ans += (*t - p[i]) * (p[i] - *tp) * i;
		s.insert(p[i]);
	}
	cout << ans << endl;
	return 0;
}


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

int main ()
{
	int n,ans;
	cin >> n;
	if (n>=64){
		ans=64;
	}
	else if(n>=32){
		ans=32;
	}
	else if(n>=16){
		ans=16;
	}
	else if(n>=8){
		ans=8;
	}
	else if(n>=4){
		ans=4;
	}
	else if(n>=2){
		ans=2;
	}
	else{
		ans=1;
	}
	cout << ans << endl ;
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

def tem(hi):
  return t-(hi*0.006)
good=2000000000
num=-1
i=1
for hi in h:
  x=abs(tem(hi)-a)
  if x<good:
    good=x
    num=i
  i+=1
  
print(num)

Measured memory_bytes: 3188
C = [list(map(int, input().split())) for _ in range(3)]

def f(i):
    return C[i+1][0] - C[i][0] ==  C[i+1][1] - C[i][1] ==  C[i+1][2] - C[i][2]

def g(i):
    return C[0][i+1] - C[0][i] ==  C[1][i+1] - C[1][i] ==  C[2][i+1] - C[2][i]

print('Yes' if f(1) and f(0) and g(1) and g(0) else 'No')



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

int compare_int(const void *a, const void *b){
    return *(int*)a-*(int*)b;
}

int main(void)
{
    int N, K;
    int p[2000];
    long long sum = 0;
    scanf("%d %d",&N, &K);
    for(int i=0; i<N; i++){
        scanf("%d",&p[i]);
    }

    qsort(p,N,sizeof(int),compare_int);

    for(int i=0; i<K; i++) sum+=p[i];

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

    return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  for(int i=0; i<3; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  cout << a[0]*10 + a[1] + a[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n[4][14];
int main(){
int i=0,i2=0,z,x,c;
string y;

// 0=s 1=h 2=c 3=d
cin>>x;
while(x>i)
{
cin>>y>>z;
if(y=="S") c=0;
else if(y=="H") c=1;
else if(y=="C") c=2;
else if(y=="D") c=3;
n[c][z]=1;
i++;
};
	for(i=0; i<4;i++){
	for(i2=1; i2<14;i2++)
		{
		if(n[i][i2]==0)
			{
			if(i==0) y="S";
			if(i==1) y="H";
			if(i==2) y="C";
			if(i==3) y="D";
			cout<<y<<" "<<i2<<endl;
			};
		};
};
return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
int main(void){
  int W,H;
  while(cin>>W>>H){
    if(!W&&!H) break;
    int x = 0, y = 0;
    int r = 0;
    string command;
    while(cin>>command){
      int times = 0;
      if(command=="STOP") break;
      if(command=="FORWARD"){
        cin>>times;
        while(times){
          times--;
          int nx = x + dx[r];
          int ny = y + dy[r];
          if(0<=nx&&nx<W&&0<=ny&&ny<H){
            x = nx;
            y = ny;
          }
        }
      }else if(command=="BACKWARD"){
        cin>>times;
        while(times){
          times--;
          int nx = x + dx[(r+2)%4];
          int ny = y + dy[(r+2)%4];
          if(0<=nx&&nx<W&&0<=ny&&ny<H){
            x = nx;
            y = ny;
          }
        }
      }else if(command=="RIGHT"){
        r = (r+1)%4;
      }else if(command=="LEFT"){
        r = (r+3)%4;
      }
    }
END:
    printf("%d %d\n",x+1,y+1);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(int, a, b, c);
  int x = min({a, b, c});
  int z = max({a, b, c});
  int y = a + b + c - x - z;

  int ans = 0;
  while (y != z) {
    x++;
    y++;
    ans++;
  }
  while (x < y) {
    x += 2;
    ans++;
  }
  cout << (x == y ? ans : ans + 1) << endl;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  double a, b, c, d, e, f;
  while(cin >> a){
    cin >> b >> c >> d >> e >> f;
    double det = a * e - b * d;
    cout << setprecision(3);
    cout << fixed;
    cout << double((ll)((e * c - b * f) / det * 1000) / 1000.);
    cout << " ";
    cout << double((ll)((- d * c + a * f) / det * 1000) / 1000.) << endl;
  }
	return 0;
}



Measured memory_bytes: 3264
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(x) REP(i,SZ(x))cerr<<i<<x<<"="<<x[i]<<endl;
const int MOD = 1000000007;
int main()
{
	vector<string> vs;
	int H, W;
	cin >> H >> W;
	REP(i, H)
	{
		string temp;
		cin >> temp;
		vs.push_back(temp);
	}
	REP(i, W + 2)
	{
		cout << "#";
	}
	cout << endl;
	REP(i, H)
	{
		cout << "#" << vs[i] << "#" << endl;
	}
	REP(i, W + 2)
	{
		cout << "#";
	}
	cout << endl;
#ifdef _DEBUG
	while(1);
#endif
	return 0;
}

Measured memory_bytes: 256
while gets
  xs = $_.split(",").map(&:to_i) # map{|v| v.to_i}
  v2, v1 = xs.pop, xs.pop

  l = xs.inject(:+) # inject{|pre, v| pre + v}
  t = l.to_f/(v2+v1)

  i = 0
  sum = 0
  loop do
    if v1*t <= sum then
      puts i
      break
    end
    sum += xs[i]
    i += 1
  end
end

Measured memory_bytes: 6112
import Control.Arrow
import Control.Applicative
import Data.List

main :: IO ()
main = do
  { s <- getLine
  ; putStrLn $ unwords $ map show $ solve s
  }

solve :: String -> [Int]
solve = concat . unfoldr psi . runLength'
  where
    psi [] = Nothing
    psi (m:n:rs) = Just $ (block (m, n), rs)

block :: (Int, Int) -> [Int]
block (m, n) = ncomp (m-1) (0 :) . (m' :) . (n' :) . ncomp (n-1) (0 :) $ []
  where
    mn  = m + n
    mn2 = mn `div` 2
    m'  = if even m || even mn then mn2 else mn2 + 1
    n'  = mn - m'

ncomp :: Int -> (a -> a) -> (a -> a)
ncomp 0 f = id
ncomp n f = ncomp (pred n) f . f

runLength' :: Eq a => [a] -> [Int]
runLength' = unfoldr phi
  where
    phi []     = Nothing
    phi (x:xs) = case spanCount (x ==) xs of
      (m, zs) -> Just (succ m , zs)

spanCount :: (a -> Bool) -> [a] -> (Int, [a])
spanCount p = paraL psi (0,[])
  where
    psi x (xs, mzs)
      | p x       = first succ mzs
      | otherwise = (0,x:xs)

paraL :: (a -> ([a],b) -> b) -> b -> [a] -> b
paraL _   z []     = z
paraL phi z (x:xs) = phi x (xs, paraL phi z xs)


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

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

    if (a > b) {
        cout << "GREATER";
    } else if (a < b) {
        cout << "LESS";
    } else {
        cout << "EQUAL";
    }
    cout << endl;

    return 0;
}

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

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

    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<long long> A(X), B(Y), C(Z);
    for (int i=0; i<X; ++i) cin >> A[i];
    for (int i=0; i<Y; ++i) cin >> B[i];
    for (int i=0; i<Z; ++i) cin >> C[i];

    vector<long long> AB;
    for (int i=0; i<X; ++i) {
        for (int j=0; j<Y; ++j) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end(), greater<long long>());

    vector<long long> ABC;
    for (int i=0, l=min(K,(int)AB.size()); i<l; ++i) {
        for (int j=0; j<Z; ++j) {
            ABC.push_back(AB[i] + C[j]);
        }
    }
    sort(ABC.begin(), ABC.end(), greater<long long>());

    for (int i=0; i<K; ++i) {
        cout << ABC[i] << endl;
    }

    return 0;
}

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

void main() {
    int n, z, w;
    scan(n, z, w);

    auto a = readln.split.to!(int[]);

    if (n == 1) {
        writeln(abs(a[0] - w));
        return;
    }

    if (abs(a[n - 1] - w) > abs(a[n - 1] - a[n - 2])) {
        writeln(abs(a[n - 1] - w));
    }
    else {
        writeln(abs(a[n - 1] - a[n - 2]));
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 380
n = gets.to_i
# s = gets.chomp
a = gets.split.map(&:to_i)
c = Array.new(2*10**5+1,0)
d = Array.new(2*10**5+1,0)
# k = Array.new(2*10**5)
# p 2*10**5+1

def y(f)
    puts f ? "Yes" : "No"
end

a.each do |k|
    c[k] += 1
end
# p c[0,10]

s = c.map{|k| res = k * (k-1)/2}.inject(:+)
# p s

d = c.map do |k|
    if k >= 2
        res = k * (k-1)/2
    else
        res = 0
    end
end

# p d[0,10]

a.each do |k|
    puts s - (c[k]-1)
end

Measured memory_bytes: 26352
from math import sqrt,ceil

def cal_main(S):
    #xa*yb-xb*ya=Sを満たす(xa,ya),(xb,yb)を知りたい
    #L = ceil(sqrt(S))とすると
    #xa*yb-xb*ya=L**2-(L**2-S) (L**2-S >= 0)
    #これはxb*ya=L**2-S<4*L-1の計算で代用できる

    L = ceil(sqrt(S))
    for l in range(L,10**9+1):
        #forといっても実際に繰り返されるのは数回だろうが
        xb_ya = cal_sub(l**2-S)
        xb,ya = xb_ya[0],xb_ya[1]
        if 0 <= xb <= 10**9 and 0 <= ya <= 10**9:
            return [l,ya,xb,l,0,0]

def cal_sub(T):
    if T == 0:
        return [0,0]
    else:
        L = int(sqrt(T))
        for l in reversed(range(1,L+1)):
            if T % l == 0:
                return [l,T//l]

def main():
    S = int(input())

    ans = cal_main(S)
    print(" ".join(map(str,ans)))

if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<int> c(100001, 0);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    c[a + 1]++;
  }
  
  int m = 0;
  for(int i = 1; i <= 99999; i++){
    m = max(c[i - 1] + c[i] + c[i + 1], m);
  }
  
  cout << m << endl;
  
  return 0;
}

Measured memory_bytes: 640
N , M = map(int,input().split())
H = list(map(int,input().split()))

lst = []
for i in range(M):
    A_,B_ = map(int,input().split())
    if H[A_ -1] >= H[B_ -1]:
        lst.append(B_)
    if H[A_-1] <= H[B_- 1]:
        lst.append(A_)
print(N - len(set(lst)))

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

using namespace std;

int main() {
	char X, Y;
	cin >> X >> Y;
	if (X < Y) {
		cout << '<' << endl;
	}
	else if (X > Y) {
		cout << '>' << endl;
	}
	else {
		cout << '=' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::cmp::{max, min, Ordering};

macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

// N M => let (N, M) = get!(usize, usize)
// A1 B1
// ...
// AQ BQ => let A = get!(usize, usize; Q)

const MOD: u64 = 1000000007;

fn main() {
    let edges = get!(usize, usize; 3);

    let mut cnt = vec![0, 0, 0, 0];
    for (fr, to) in edges {
        cnt[fr - 1] += 1;
        cnt[to - 1] += 1;
    }

    if cnt.iter().max() <= Some(&2) {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
# coding=utf-8
from collections import deque
n = int(input())
deque = deque()

for i in range(n):
    inp = list(input().split())
    if inp[0] == 'deleteFirst':
        deque.popleft()
    elif inp[0] == 'deleteLast':
        deque.pop()
    elif inp[0] == 'insert':
        deque.appendleft(inp[1])
    else:
        if inp[1] in deque:
            deque.remove(inp[1])

print(*deque)

Measured memory_bytes: 71784
import java.util.Arrays;
import java.util.Scanner;

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

        String s = sc.next();
        char[] c = s.toCharArray();

        Arrays.sort(c);

        boolean isAns = true;
        for (int i = 1; i < c.length; i++) {
            if (c[i] == c[i-1]) {
                isAns = false;
                break;
            }
        }

        System.out.println(isAns ? "yes" : "no");
    }
}


Measured memory_bytes: 22740