akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
vector <int> bi[N];
int dfs(int t, int f = 0)
{
    int c = 0, d = 0;
    for (int i = 0; i < bi[t].size(); ++ i)
        if (bi[t][i] != f)
        {
            int v = dfs(bi[t][i], t);
            d |= c & v;
            c ^= v;
        }
    for (int i = 30; ~i; -- i)
        if (i == 0 || (d & (1 << (i - 1))))
            for (int j = i; ; ++ j)
                if (!(c & (1 << j)))
                    return (c | (1 << j)) ^ (c & ((1 << j) - 1));
}
int main()
{
    cin >> n;
    for (int i = 1; i < n; ++ i)
    {
        int a, b;
        cin >> a >> b;
        bi[a].push_back(b);
        bi[b].push_back(a);
    }
    int v = dfs(1);
    for (int i = 30; ~i; -- i)
        if (v & (1 << i))
        {
            cout << i << endl;
            return 0;
        }
}


Measured memory_bytes: 13824
N,M = map(int,input().split())
S = input()
RS = S[::-1]

"""
ゴール側から考えれば、自然と辞書順最小になる。（気がする）
前処理で各セーフマスから最も近い前方のセーフマスの位置を求めておく。
nxSafe[i] =>　ゴールからスタートに進むとして、ゴールからiマス目の次のセーフゾーンのインデックス
"""
nxSafe = [None]*(N+1)
safe = N
for i in range(N-1,-1,-1):
    if RS[i] == "0":
        nxSafe[i] = safe
        safe = i

cur = 0
ans = []
while cur < N:
    tmp = cur
    while True:
        if tmp == N:
            break
        if nxSafe[tmp] - cur <= M:
            tmp = nxSafe[tmp]
        else:
            break
    if cur == tmp:
        print(-1)
        exit()
    ans.append(str(tmp-cur))
    cur = tmp
ans = ans[::-1]
print(" ".join(ans))

Measured memory_bytes: 83632
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] counter = new int[26];
    while (sc.hasNext()) {
      String str = sc.nextLine();
      for (int i = 0; i < str.length(); i++) {
        int num = 0;
        char ch = str.charAt(i);
        if (Character.isLowerCase(ch)) {
          num = str.charAt(i) - 'a';
        } else {
          num = str.charAt(i) - 'A';
        }
        if (num >= 0 && num <= 26) {
          counter[num]++;
        }
      }
    }
    for (int i = 0; i < counter.length; i++) {
      System.out.println((char)(i + 'a') + " : " + counter[i]);
    }
  }
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		for(int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(d);
		int r = d[N / 2] - d[N / 2 - 1];
		System.out.println(r);
		// System.out.println("---------------");
		// System.out.println(Arrays.toString(d));
		// System.out.println(d[N / 2] + " - " + d[N / 2 - 1] + " = " + r);
	}
}

Measured memory_bytes: 50808
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(100001), y(100001);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        x[i] = a;
        y[i] = b;
    }

    vector<int> ballNum(100001, 1);
    vector<bool> flag(100001, false);
    flag[0] = true;

    for(int i = 0; i < m; i++){

        if(flag[x[i]] == true){
            ballNum[x[i]]--;
            if(ballNum[x[i]] == 0){
                flag[x[i]] = false;
            }
            flag[y[i]] = true;
            ballNum[y[i]]++;
        }
        else{
            ballNum[x[i]]--;
            ballNum[y[i]]++;
        }
    }

    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(flag[i] == true) cnt++;
    }
        
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, X;
  cin >> K >> X;
  int a = X - K + 1;
  int b = X + K - 1;
  for(int i = a; i < b; i++) {
    cout << i << " ";
  }
  cout << b << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

signed main() {
	ll n;
	scnaf("%lld", &n);
	ll Min = INT_MAX;
	rep(i, 1, 1 + (int)sqrt(n)) {
		if (!(n % i)) {
			ll keta = 0, base = 1;
			ll buf = i;
			while (max(buf,n/i) / base) {
				keta++;
				base *= 10;
			}
			Min = min(Min, keta);
		}
	}
	printf("%lld\n", Min);

	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
sm=sum(map(abs,a))
f=1

for i in range(n-1):
  f= 1 if a[i]*f>=0 else -1
print (sm if f*a[n-1]>0  or 0 in a else sm-2*min(map(abs,a)))

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    cout << min_element(a.begin(),a.end())-a.begin()+1 << endl;
}


Measured memory_bytes: 3104
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if ( u == NIL ) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if ( T[u].left != NIL )
    h1 = setHeight(T[u].left) + 1;
   if ( T[u].right != NIL )
    h2 = setHeight(T[u].right) + 1;
   return H[u] = ( h1 > h2 ? h1 : h2 );
}


int getSibling(int u) {
  if ( T[u].parent == NIL ) return NIL;
  if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent == NIL ) {
    printf("root\n");
  } else if ( T[u].left == NIL && T[u].right == NIL ) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for ( int i = 0; i < n; i++) T[i].parent = NIL;

  for ( int i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if ( l != NIL ) T[l].parent = v;
    if ( r != NIL ) T[r].parent = v;
  }

  for ( int i = 0; i < n; i++) if ( T[i].parent == NIL ) root =i;

  setDepth(root,0);
  setHeight(root);

  for ( int i = 0; i < n; i++ ) print(i);

  return 0;
}

    



Measured memory_bytes: 2764
program main
implicit none
integer :: i, j, k
integer :: n, s
integer , allocatable :: a(:)

read(*,*) n
allocate( a(n) )
read(*,*) a
s = sum(a(1:n))
a = a*n
j = s
do i = 1, n
   if( abs(a(i)-s) .lt. j ) then
      j = abs( a(i) -s )
      k = i-1
   end if
end do
write(*,'(i0)') k

end program main


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

int main(){
    
    size_t a, b, cnt = 0;
    std::cin >> a >> b;

    for(size_t i = a; i <= b; i++){
        auto s = std::to_string(i);
        auto tmp = s;
        std::reverse(tmp.begin(), tmp.end());
        if(s == tmp) cnt++;
    }

    std::cout << cnt << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
S = S[:] + "X"
T = ""
i, j = 0, 0
X = 0
def excAB(n, lis):
  y = 0
  m = len(lis)
  for i in range(m):
    y += n - 1 - i - lis[m-1-i]
  return y

M = []
while i < N:
  if S[i] == 'A':
    T = T[:] + "A"
    i += 1
    M.append(j)
    j += 1
  elif S[i:i+2] == "BC":
    T = T[:] + "B"
    i += 2
    j += 1
  else:
    X += excAB(j, M)
    T = T[:] + "C"
    M = []
    i += 1
    j = 0
X += excAB(j, M)
print(X)

Measured memory_bytes: 11364
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	for(int i=0; i<S.size(); i++) cout << "x";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
x = int(input())
st = x
if x % 2 == 0:
  st = x + 1
div = 3
  
while div < st**0.5:
  if st % div == 0:
    st += 2
    div = 3
  else:
    div += 2
else:
  if x == 2:
    print(2)
  else:
    print(st)

Measured memory_bytes: 3060
class Dice:
	
	def __init__(self, faces):
		self.faces = faces
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def rotate_right(self):
		s_ = self.s
		w_ = self.w
		n_ = self.n
		e_ = self.e
		self.s = e_
		self.w = s_
		self.n = w_
		self.e = n_
	
	def is_identical(self, other):		
		directions = 'NWNNWW'
		for direction in directions:
			for i in range(4):
				self.rotate_right()
				if self.is_matchall(other): return True
			self.roll(direction)
		return False

	def is_matchall(self, other):
		if self.t != other.t: return False
		if self.s != other.s: return False
		if self.e != other.e: return False
		if self.w != other.w: return False
		if self.n != other.n: return False
		if self.b != other.b: return False
		return True
		
faces1 = list(map(int, input().split()))
faces2 = list(map(int, input().split()))
dice1 = Dice(faces1)
dice2 = Dice(faces2)

if dice1.is_identical(dice2):
	print('Yes')
else:
	print('No')



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,i,j,pos=1,s=0,sum=-1,c=0,t,k;
	cin>>n>>k;
	ll a[n+1],m[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		m[i]=-1;
	}
	m[1]=0;
	for(i=1;i<=n;i++)
	{
		j=i+1;
		while(j<=n)
		{
			if(m[j]<0)
			{
				m[j]=abs(a[j]-a[i])+m[i];
			}
			else if(m[j]>=abs(a[j]-a[i])+m[i])
			{
				m[j]=abs(a[j]-a[i])+m[i];
			}
			c++;
			if(c<=k)
			{
				j=i+c;
			}
			else
			{
				break;
			}
		}
		c=0;
	}
	cout << m[n] <<'\n';
}

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

using namespace std ;

int n , k ;
const int N = 1e5 +  10 ;
int h[N] ;
int mem[N] ;




int jump(int i){
    if(i == 0) return 0 ;

    if(mem[i] != -1) return mem[i] ;



    mem[i] = 2e9 ;
    for(int j = 1 ; j <= k && i - j >= 0 ; j++)
        mem[i] = min( jump(i - j) + abs(h[i] - h[i - j]) , mem[i]  ) ;


    return mem[i] ;
}




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


    memset(mem , -1 , sizeof mem) ;
    for(int i = 0 ; i < n ; i ++)
        scanf("%d" , &h[i]) ;



    printf("%d\n" , jump(n - 1)) ;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <set>

using namespace std;

int main() {
	int n;
	cin >> n;

	string s;
	set<string> prize;
	for (int i = 0; i < n; i++) {
		cin >> s;
		prize.insert(s);
	}
	cout << prize.size() << endl;
	return 0;
}


Measured memory_bytes: 15652
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	while (true)
	{
		int M, T, P, R;

		cin >> M >> T >> P >> R;

		if (M == 0 && T == 0 && P == 0 && R == 0) { break; }

		vector<vector<int> > time_(T, vector<int>(P, 0));
		vector<vector<bool> > cor(T, vector<bool>(P, false));

		vector<int> score(T, 0);
		vector<int> rank(T, 0);

		for (int i = 0; i < R; i++) 
		{ 
			int m, t, p, j;

			cin >> m >> t >> p >> j;

			if (j == 0)
			{
				time_[t - 1][p - 1] += m;

				cor[t - 1][p - 1] = true;
			}
			else
			{
				time_[t - 1][p - 1] += 20;
			}
		}

		for (int i = 0; i < T; i++)
		{
			for (int j = 0; j < P; j++)
			{
				if (cor[i][j] == true)
				{ 
					score[i] += 100000; 

					score[i] -= time_[i][j];
				}
			}
		}

		for (int i = 0; i < T; i++) { rank[i] = i + 1; }

		for (int i = 0; i < T; i++)
		{
			for (int j = i + 1; j < T; j++)
			{
				if (score[i] < score[j])
				{
					swap(score[i], score[j]);

					swap(rank[i], rank[j]);
				}
				else if (score[i] == score[j] && rank[i] < rank[j])
				{
					swap(rank[i], rank[j]);
				}
			}
		}

		for (int i = 0; i < T; i++)
		{
			if (i + 1 == T)
			{
				cout << rank[i] << endl;

				break;
			}
			else if (score[i] == score[i + 1])
			{
				cout << rank[i] << '=';
			}
			else
			{
				cout << rank[i] << ',';
			}
		}
	}

	return 0;
}

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

void solve(string N)
{
    long long count = N.size() - 1;
    if (N[count] == '2' || N[count] == '4' || N[count] == '5' || N[count] == '7' || N[count] == '9')
    {
        cout << "hon" << endl;
    }
    else if (N[count] == '0' || N[count] == '1' || N[count] == '6' || N[count] == '8')
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "bon" << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    string N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		try {
			input = br.readLine();
			input = br.readLine();
		} catch (IOException e) {
		}
		String[] inputs = input.split(" ");
		for (int i = inputs.length - 1; i >= 0; i--) {
			System.out.print(inputs[i]);
			if (i != 0) {
				System.out.print(" ");
			} else {
				System.out.println();
			}
		}
	}
}


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

enum P = 10L^^9+7;

long[2][10^^5+10] DP;

void main()
{
    auto L = readln.chomp.to!(char[]);

    DP[0][1] = 2;
    DP[0][0] = 1;
    foreach (i; 1..L.length) {
        if (L[i] == '0') {
            DP[i][1] = DP[i-1][1];
            DP[i][0] = (DP[i-1][0] * 3) % P;
        } else {
            DP[i][1] = (DP[i-1][1] * 2) % P;
            DP[i][0] = (DP[i-1][1] + DP[i-1][0] * 3) % P;
        }
    }
    writeln((DP[L.length-1][0] + DP[L.length-1][1]) % P);
}

Measured memory_bytes: 2072
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

/*
struct Edge{
    int u,v,weight;
    bool operator<(Edge const& other) {
        return weight<other.weight;
    }
};

vector<int> parent,rank;

void make_set(int v) {
    parent[v]=v;
    rank[v]=0;
}

int find_set(int v) {
    if(v==parent[v])
        return v;
    return parent[v]=find_set(parent[v]);
}

void union_sets(int a,int b) {
    a=find_set(a);
    b=find_set(b);
    if(a!=b){
        if(rank[a]<rank[b])
            swap(a,b);
        parent[b]=a;
        if(rank[a]==rank[b])
            rank[a]++;
    }
}*/
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}
/*
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2; p*p<=n; p++)
        if (prime[p] == true)
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    char c;
    cin>>c;
	cout<<char(c+1)<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const ll CFMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-6;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset(v,0,sizeof(v))
#define EB push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define vec vector
#define __ <<' '<<
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll cal(ll x, vec<ll> v, vec<ll> pos, vec<ll> neg, ll cnt){
    ll res = 0, ps, ns;
    ps = siz(pos);
    ns = siz(neg);
    
    if(x > 0){
        for(auto i:v){
            if(i > 0){
                auto it = lower_bound(ALL(pos), (x + i - 1) / i);
                res += max(int(pos.end() - it - (*it <= i)), 0);
            }
            if(i < 0){
                auto it = upper_bound(ALL(neg), (x - i - 1)/i);
                res += max(int(it - neg.begin() - (*prev(it) >= i)), 0);
            }
        }
    } else if(x < 0) {
        for(auto i:v){
            if(i > 0)   res += neg.end() - lower_bound(ALL(neg), x/i) + ps - 1;
            if(i < 0)   res += upper_bound(ALL(pos), x/i) - pos.begin() + ns - 1;
            if(i == 0)  res += ps + ns - 1;
        }
    } else {
        res = ps * (ps - 1) + ns * (ns - 1) + cnt * ns * 2;
    }
    
    return res / 2;
}

void solve(){
    ll n, k, cnt = 0;
    vec<ll> v, pos, neg;
    
    cin >> n >> k;
    k = n * (n - 1) / 2 - k + 1;
    
    v.rs(n);
    rep(i, n){
        cin >> v[i];
        if(v[i] >= 0)    pos.EB(v[i]);
        else             neg.EB(v[i]);
        
        if(v[i] == 0)   cnt++;
    }
    sort(ALL(pos));
    sort(ALL(neg));
    
    ll top, bot, mid, res;
    
    top = 1e18;
    bot = -1e18;
    top++;
//    cout << k << '\n';
    while(top - bot > 1){
        mid = (top + bot) / 2;
        res = cal(mid, v, pos, neg, cnt);
//        cout << mid __ cal(mid, v, pos, neg, cnt) << '\n';
        if(res < k) top = mid;
        else        bot = mid;
    }
    
    cout << bot << '\n';
}

int main() {
    kiyohime
    int T = 1;
    
    while(T--){
        solve();
    }
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<VVD> VVVD;

int n;
VVVD memo;
double rec(int i, int j, int k) {
    if(memo[i][j][k] != -1) return memo[i][j][k];
    if(i == 0 and j == 0 and k == 0) return memo[i][j][k] = 0;
    double res = n;
    if(i > 0) res += i * rec(i - 1, j, k);
    if(j > 0) res += j * rec(i + 1, j - 1, k);
    if(k > 0) res += k * rec(i, j + 1, k - 1);
    return memo[i][j][k] = res / (i + j + k);
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    memo.resize(n + 1, VVD(n + 1, VD(n + 1, -1)));
    VI s(4, 0);
    REP(i, n) {
        int a;
        cin >> a;
        s[a]++;
    }
    cout << fixed << setprecision(10) << rec(s[1], s[2], s[3]) << ln;
    return 0;
}


Measured memory_bytes: 216960
#include <stdio.h>
int main(void) {
	double r, pi = 3.14159265359;
	double l, s;

	scanf("%lf", &r);
	l = (r * 2)*pi;
	s = r*r*pi;
	printf("%.6lf %.6lf\n", s, l);

	return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cerr << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;
#define DBG(x) cerr << x << endl;

/*
	
*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
	//freopen("tmp.out", "w", stderr);
#endif
	int x, t;
	cin >> x >> t;

	cout << max(x - t, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int M = scan.nextInt();
    List<Integer> odd = new ArrayList<>();
    List<Integer> even = new ArrayList<>();
    for(int i=0;i<M;++i){
      int a = scan.nextInt();
      if(a%2==0)even.add(a);
      else odd.add(a);
    }
    if(odd.size()>2){
      System.out.println("Impossible");
      return;
    }
    List<Integer> ans = new ArrayList<>();
    if(odd.size()>=1){
      int d = odd.remove(0);
      System.out.print(d+" ");
      while(d>1){
        ans.add(2);
        d-=2;
      }
    }else{
      int d = even.remove(0);
      System.out.print(d+" ");
      ans.add(d-1);
    }
    for(int i=0;i<even.size();++i){
      ans.add(even.get(i));
      System.out.print(even.get(i)+" ");
    }
    if(odd.size()>=1){
      int d = odd.remove(0);
      System.out.print(d+" ");
      while(d>0){
        ans.add(2);
        d-=2;
      }
    }else{
      ans.add(1);
    }
    System.out.println();
    System.out.println(ans.size());
    for(int i : ans)System.out.print(i+" ");
    System.out.println();
  }
}
    
      

Measured memory_bytes: 31220
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	//cout<<sqrt(2019)<<endl;
	long long int l,r;
	cin>>l>>r;
	
		int min=2020;
		
		
			if(r-l>=2019){
				min=0;
			}

	else{
		for(long long int i=l;i<=r;i++){
			for(long long int j=i+1;j<=r;j++){
				int s;
				s=(i%2019)*(j%2019)%2019;
				if(s<min){
					min=s;
				
				}
			}
		}
		
	}
	cout<<min<<endl;
		
	return 0;
}


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

  for(int i= 0; i<n ; i++) {
    int a;
    cin >> a;
    hs[i] = a;
  }
  sort(hs.begin(), hs.end(), std::greater<int>());
  long count = 0;

  for(int i = 0; i < n; i++){
    if(k > 0) {
      k--;
    } else {
      count += hs[i];
    }
  }
  cout << count;
}



Measured memory_bytes: 1792
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> stack = new ArrayDeque<>();
		Deque<Integer> position = new ArrayDeque<>();
		Deque<Integer> mizutamari = new ArrayDeque<>();
		char[] area = sc.nextLine().toCharArray();
		int sum=0;
		int mizu;


		for(int i=0; i<area.length; i++) {
			if(area[i]=='\\') {
				stack.push(i);
			}else if(area[i]=='/'&&stack.size()>0) {
				int j =stack.pop();
				mizu =i-j;
				sum += mizu;
				while(position.size()>0&&position.peek()>j) {
					mizu +=mizutamari.pop();
					position.pop();
				}
				position.push(j);
				mizutamari.push(mizu);
			}
		}
		int count = position.size();
		int[] ans = new int[count];
		System.out.println(sum);
		System.out.print(count);
		for(int i=count-1; i>=0; i--) {
		   ans[i]=mizutamari.pop();
		}
		for(int i=0; i<count; i++) {
			System.out.print(" "+ans[i]);
		}
        System.out.println();

	}
}



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

    public class Program
    {
        public static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            List<string> word = new List<string> { };
            string answer = "Yes";

            for (int i = 0; i < count; i++)
            {
                word.Add(Console.ReadLine());
            }

            if (word.Count() != word.Distinct().Count()) answer = "No";

            for (int j = 0; j < count - 1; j++)
            {
                if (word[j].EndsWith(word[j + 1].Substring(0, 1)) == false)
                {
                    answer = "No";
                }
            }

            Console.WriteLine(answer);
        }
    }

Measured memory_bytes: 13532
def main():
    N = int(input())
    Ds = [list(map(int, input().split())) for i in range(N)]
    ans = 'No'
    judge = []
    for i in range(N):
        Di = Ds[i]
        if Di[0] == Di[1]:
            judge.append(True)
        else:
            judge.append(False)

        if i >= 2 and (judge[-1] == judge[-2] == judge[-3] == True):
            ans = 'Yes'
            break

    print(ans)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include<stdio.h>
#define MAX 100
#define INFTY 2097152
#define WHITE 0
#define GRAY 1
#define BLACK 2
void dijkstra();
int n,M[MAX][MAX];

int main(){
  int k,u,c,v;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=INFTY;
    }}
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(int j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }}

  dijkstra();
  return 0;}

void dijkstra(){
  int minv;
  int d[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }}
    if(u==-1)break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
 
    printf("%d ",i);
    if(d[i]==INFTY)
      printf("%d",-1);
    else
      printf("%d",d[i]);
 printf("\n");
  }}



Measured memory_bytes: 2736
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i  < n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int b = 0,c = 0;
    for(int i = n-1;i >= 0;i--){
        if(i%2 == (n-1)%2) b+=a[i];
        else c += a[i];
    }
    cout << b-c << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define POSITIVE_INFINITY 9223372036854775807
#define NEGATIVE_INFINITY -9223372036854775807
const ll MOD = 1000000007;
int adj[5][5];
int x, y;
int main()
{
  FASTER;
  int ar[] = {1, 2, 3, 4};
  int n = 4;
  int m = 3;
  for (int i = 0; i < m; i++){
    cin >> x >> y;
    adj[x][y] = 1;
    adj[y][x] = 1;
  }
  string ans = "NO\n";
  do {
    bool f = true;
    for (int i = 0; i < n - 1; i++){
      x = ar[i];
      y = ar[i + 1];
      if (adj[x][y] != 0)
        f = false;
    }
    if (f){
      ans = "YES\n";
    }

  }while (next_permutation(ar, ar + n));
  cout << ans;
  return 0;
}


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

using namespace std;

vector <int> v[100010];

int dfs (int nod, int tata)
{
    int rez = 0;
    for (auto &it : v[nod])
    {
        if (it == tata) continue;

        rez ^= (dfs (it, nod) + 1);
    }

    return rez;
}

int main ()
{
   // freopen ("file.in", "r", stdin);

    int n;
    scanf ("%d", &n);

    for (int i = 1; i < n; ++i)
    {
        int x, y;
        scanf ("%d %d", &x, &y);

        v[x].push_back (y);
        v[y].push_back (x);
    }

    if (!dfs (1, 0)) printf ("Bob\n");
    else printf ("Alice\n");

    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()0
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=100009;
 
// Happy Coding!



void solve(){
    int n;
    cin>>n;
    vi idx(n+1);
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        idx[x]=i;
        
    }
    for(int i=1;i<=n;i++){cout<<idx[i]<<" ";}
}

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

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

using namespace std;


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

int main(){

	int a,b;
	while(cin>>a>>b)
		cout<<gcd(a,b)<<endl;

	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        n = n % k;
        System.out.println(Math.min(n ,Math.abs(k - n)));
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21844
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      String ans;

      int YYMM = 0;
      int MMYY = 0;

      int migi2 = n%100;
      int hidari2 = (n-migi2)/100;

      if(hidari2>0  && hidari2<13){
        MMYY = 1;
      }
      if(migi2>0 && migi2<13){
        YYMM = 1;
      }


      if(YYMM==1 && MMYY==1){
        ans = "AMBIGUOUS";
      }
      else if(YYMM==1 && MMYY==0){
        ans = "YYMM";
      }
      else if(YYMM==0 && MMYY==1){
        ans = "MMYY";
      }
      else{
        ans = "NA";
      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int M=310;
double dp[310][310][310];
int n;

double dfs(int a, int b, int c){
      if((a+b+c)==0)return 0.;

      if(dp[a][b][c]!=-1)return dp[a][b][c];

      double ks=((double)n/(a+b+c));
      double res=0.0;

      if(a){
            res+=((dfs(a-1, b, c)+ks)*a/(a+b+c));
      }
      if(b){
            res+=((dfs(a+1, b-1, c)+ks)*b/(a+b+c));
      }
      if(c){
            res+=((dfs(a, b+1, c-1)+ks)*c/(a+b+c));
      }
      dp[a][b][c]=res;
      return res;
}
int main(){
      cin>>n; 
      int arr[4];
      arr[0]=arr[1]=arr[2]=arr[3]=0;
      for(int i=0; i<=n; i++)for(int j=0; j<=n; j++)for(int k=0; k<=n; k++)dp[i][j][k]=-1;

      for(int i=0; i<n; i++){
            int x;
            cin>>x;
            arr[x]++;
      }
      cout<<fixed<<setprecision(10)<<dfs(arr[1], arr[2], arr[3]);
}

Measured memory_bytes: 224448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for((ll) (i)=(a);(i)<=(b);(i)++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

struct UnionFind {
	vector<ll> table;

	UnionFind(ll n) : table(n) { //tableはleaderなら部下の数(枝のうち一番長い部分の長さ)、そうでなければ所属する上司
		for (ll i = 0; i < n; i++) table[i] = -1;
	}
	
	ll find(ll x){ //leaderの番号を返す
		if (table[x] < 0){
			return x; //tableの値が負の場合はleaderなので自分
		}
		else{
			table[x] = find(table[x]); //xのleader
			return table[x];
		}
	}

	void unite(ll x, ll y){ //xとyをつなげる
		ll s1 = find(x); //xのleader
		ll s2 = find(y); //yのleader
		if (s1 != s2){ 
			if (table[s1] > table[s2]){ //xの木のほうが長い場合はxにyをくっつける
				table[s2] += table[s1];
				table[s1] = s2;
			}
			else if (table[s2] > table[s1]){
				table[s1] += table[s2];
				table[s2] = s1;
			}
			else{
				table[s1] += table[s2];
				table[s2] = s1;
			}
		}
		return;
	}
}; //structの最後には;が必要!!

ll MAX = 110000;
ll n, x, y, i;
ll ans = 0;
vector<ll> xl(2*MAX, 0);
vector<ll> yl(2*MAX, 0);

int main(){
	UnionFind uf(MAX*2);
	cin >> n;
	REP(i,n){
		cin >> x >> y;
		uf.unite(x,y+MAX);
	}
	for(i=1;i<=MAX;i++) xl.at(uf.find(i))++;
	for(i=MAX+1;i<=2*MAX;i++) yl.at(uf.find(i))++;
	for(i=1;i<=MAX-1;i++) ans += xl[i]*yl[i];
	cout << ans-n << endl;
}

Measured memory_bytes: 5376
n, m = map(int, raw_input().split())
x, y = [], []
for i in range(m):
    x0, y0 = map(int, raw_input().split())
    x.append(x0-1)
    y.append(y0-1)
box = [1 for i in range(n)]
can = [False for i in range(n)]
can[0] = True
for i,j in zip(x,y):
    box[i] -= 1
    box[j] += 1
    if can[i]:
        if box[i] == 0:
            can[j] = True
            can[i] = False
        else:
            can[j] = True
print can.count(True)

Measured memory_bytes: 20724
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define SZ(x) x.size()
#define POP __builtin_popcount
#define CLZ __builtin_clz
#define CTZ __builtin_ctx
constexpr int INF {INT_MAX};
constexpr float INFF {FLT_MAX};
constexpr long long INFL {LLONG_MAX};
#define float long double
#define int long long

main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.setf(ios::fixed);
	int a,b,
		c,d;
	cin>>a>>b>>c>>d;
	if ((c+b-1)/b<=(a+d-1)/d) cout<<"Yes\n";
	else cout<<"No\n";
}



Measured memory_bytes: 3644
#define CIN(a,b) cin >> a >> b
#define COUT(a,b) cout << a << b
#define COOUT(a) cout << a

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main () {
    string s, t;
    CIN(s, t);
    int count = 0;
    for (int i = 0; i < 3; i++){
        if (s.at(i) == t.at(i)){
            count++;
        }
    }
    COOUT(count);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    if(N >= 2)
        cout << max(abs(A[N - 1] - W), abs(A[N - 2] - A[N - 1])) << endl;
    else
        cout << abs(A[N - 1] - W) << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int len_az = 0;
    int pos_a = s.find('A');
    int pos_z = s.rfind('Z') + 1;
    len_az = pos_z - pos_a;
    cout << len_az << '\n';
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var A = Console.ReadLine();
            var B = Console.ReadLine();
            if (A.Length > B.Length)
            {
                Console.WriteLine("GREATER");
            }
            else if (A.Length < B.Length)
            {
                Console.WriteLine("LESS");
            }
            else
            {
                var answer = "EQUAL";
                for (var i = 0; i < A.Length; i++)
                {
                    if (A[i] == B[i]) continue;
                    if (A[i] > B[i]) answer = "GREATER";
                    if (A[i] < B[i]) answer = "LESS";
                    break;
                }
                Console.WriteLine(answer);
            }
        }
    }
}


Measured memory_bytes: 25704
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500 * a + 100 * b + 50 * c == X:
                ans += 1
            
print(ans)

Measured memory_bytes: 3060
N = int(input())
A = [0]
S = set()
tmp = 1
count = 0
for i in range(N):
    A.append(int(input()))
while True:
    S.add(tmp)
    tmp = A[tmp]
    count += 1
    if tmp == 2:
        print(str(count))
        break
    if tmp in S:
        print('-1')
        break


Measured memory_bytes: 13216
cnt = 0
while True:
    d = [[' ' for i in range(8)]  for j in range(5)]

    try:
        n = raw_input()
        if (cnt != 0):
            print
        cnt += 1        
        while len(n) < 5:
            n = '0' + n    
        for i in range(len(n)):
            if (int(n[i]) <= 4):
                d[i][0] = '*'
            if (int(n[i]) >= 5):
                d[i][1] = '*'
            d[i][2] = '='
            if (int(n[i]) != 0 and int(n[i]) != 5):
                d[i][3] = '*'
            if (int(n[i]) != 1 and int(n[i]) != 6):
                d[i][4] = '*'
            if (int(n[i]) != 2 and int(n[i]) != 7):
                d[i][5] = '*'
            if (int(n[i]) != 3 and int(n[i]) != 8):
                d[i][6] = '*'
            if (int(n[i]) != 4 and int(n[i]) != 9):
                d[i][7] = '*'
        for i in range(8):
            s = ""
            for j in range(5):
                s += d[j][i]
            print s
    except:
        break
    

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


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

const int MAX_N = 112345;
vector<int> g[MAX_N];

int U[MAX_N];
int V[MAX_N];

void dfs(int cur, int dist, int prev, int* out) {
  out[cur] = dist;
  for (int next : g[cur]) if (next != prev) {
    dfs(next, dist + 1, cur, out);
  }
}

int main2() {
  REP(i, MAX_N) g[i].clear();
  CLR(U, -1);
  CLR(V, -1);

  int N = nextInt();
  int u = nextInt() - 1;
  int v = nextInt() - 1;
  REP(i, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs(u, 0, -1, U);
  dfs(v, 0, -1, V);

  int ans = 0;
  REP(i, N) if (g[i].size() == 1) {
    if (U[i] < V[i]) {
      ans = max(ans, V[i] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main() {
  int X,Y;
  cin >> X >> Y;
  if(Y%2 == 1){
  cout << "No" << endl;
  }
  
  if(Y%2 == 0){
   vector<int>vec(X+1);
    for(int i =0;i<X+1;i++){
    vec.at(i) = i*2 + (X-i)*4;
    }
    
    for(int i =0;i<X+1;i++){
     if(vec.at(i) == Y){
     cout << "Yes" << endl;
     break;
     }
    if(i==X){
    cout << "No" <<endl;
      break;
    }
    }
    
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin>>n;
  map<ll, ll> mp;
  mp[0] = 1LL;
  ll sum = 0LL;
  repi(i,0,n){
    ll tmp; cin>> tmp;
    sum += tmp;
    if(mp.find(sum) == mp.end()){
      mp[sum] = 1LL;
    } else {
      mp[sum] += 1LL;
    }
  }
  ll cnt = 0LL;
  for (auto const& ele: mp) {
    if(ele.second > 1LL) cnt += ele.second*(ele.second - 1LL)/2LL;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 12800
r = true
lst = []
N = gets.to_i
N.times do |_|
    lst.push(gets)
end

lst.each do |i|
    if lst.count(i) != 1
        r = false
    end
end

if r
    1.upto(lst.length-1) do |i|
        if lst[i-1][-2] != lst[i][0]
                r = false
        end
    end
end

if r
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int a, b, c;
    cin >> a>>b>>c;
    int ans = 0;

    for (int i = a; i <= b; i++){
        if(c % i == 0){
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    ll maxn = 0;
    rep(i, 10000){
        if(n <= i*(i+1)/2){
            maxn = i;
            break;
        }
    }
    ll now = n;
    for(ll i = maxn; i >= 1; --i){
        if(i > now) continue;
        cout << i << endl;
        now -= i;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<set>
#include<iostream>
using namespace std;
#define df 0
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=a;i<(n);i++)
typedef long int li;

struct graph{
  int order;
  int comp;
  vector<vector<int>> adj;
  vector<int> uf;
  vector<int> depth;
  vector<int> par;

  graph(int n,int m,int origin=1);
  void print_uf();
  int find(int a);
  int c_size(int a){ return -uf[find(a)]; };
  void merge(int u,int v);
  void merge();
  void dfs_tree(int u);  // depth と par を埋めます．
  int deg(int a){ return adj.at(a).size(); };
};
graph::graph(int n,int m,int origin){
  order=comp=n;
  adj.resize(n);
  uf.resize(n,-1);
  depth.resize(n);
  par.resize(n,-1);
  
  rep(i,m){
    int u,v;cin >>u >>v; u-=origin; v-=origin;
    adj.at(u).push_back(v);
    adj.at(v).push_back(u);
  }
}


int main(){
  if(df) printf("*debug mode*\n");
  int n,m,k; cin >>n >>m >>k;
  graph g(n,m);
  g.merge();
  if(df) g.print_uf();
  vector<int> del(n,1);
  rep(i,k){
    int c,d; cin >>c >>d;c--;d--;
    if(g.find(c)==g.find(d)){
      del[c]++; del[d]++;
    }
  }
  rep(i,n){
    printf("%d ",g.c_size(i)-del[i]-g.deg(i));
  }
}

// union_find
int graph::find(int a){
  if(uf[a]<0)return a;
  if(uf[uf[a]]<0)return uf[a];
  return uf[a]=find(uf[a]);
}

void graph::merge(int u,int v){
  u=find(u); v=find(v);
  if(u==v)return;
  comp--;
  if(uf[u]>uf[v])swap(u,v);
  uf[u]+=uf[v];
  uf[v]=u;
}
void graph::merge(){
  rep(u,order){
    for(int v:adj.at(u)) merge(u,v);
  }
}
void graph::print_uf(){
  rep(i,order){
    printf("%2d(%d) ",i,find(i));
    for(int v:adj.at(i)) cout << v << " ";
    if(i==find(i))printf("\t[%d]",c_size(i));
    printf("\n");
  }
  printf("cnt comp:%d\n",comp);
}



/// confirm df==0 ///


Measured memory_bytes: 8312
N, Y = map(int, input().split())
Y = Y / 1000
isOk = False
for i in range(N + 1):
    for j in range(N - i + 1):
        if Y == i + 5 * j + 10 * (N - i - j):
            isOk = True
            senen = str(i)
            gosenen = str(j)
            ichimanen = str(N - i - j)
if isOk:
    print(ichimanen + " " + gosenen + " " + senen)
else:
    print("-1 -1 -1")

Measured memory_bytes: 3188