Harryxun/stf_run huggingface dataset:
import math
targ = int(input())
while True:
    y,z =0,0
    minans = float("inf")
    if (targ ** ( 1 / 3)) == int(targ ** ( 1 / 3)):
        z = int(targ ** ( 1 / 3))
        targ = 0
    elif (targ ** ( 1 / 2)) == int(targ ** ( 1 / 2)):
        y = int(targ ** ( 1 / 2))
        targ = 0
    else:
        for n in range(math.ceil(targ ** ( 1 / 3))):
            if minans == 0:
                break
            for m in range(math.ceil(targ ** ( 1 / 2))):
                if n ** 3 + m **2 > targ:
                    break
                if minans > targ - (n ** 3 + m ** 2):
                    minans = targ - (n ** 3 + m ** 2)
                    y,z = m,n
    if minans != float("inf"):
        print(minans + y + z)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break
            

### FIXED CODE ###

import math
targ = int(input())
y,z = 0,0
while True:
    minans = float("inf")
    for n in range(math.ceil(targ ** ( 1 / 3))+1):
        if minans == 0:
            break
        if targ - n**3 >= 0:
            m = int((targ - n**3) **(1/2))
        else:
            m = 0
        if (n ** 3) + (m **2) > targ:
            break
        if minans > targ - (n ** 3 + m**2) + n + m:
            minans = targ - (n ** 3 + m**2) + n + m
    if minans != float("inf"):
        print(minans)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

c = list(set(a))

count = 0
if len(c) <= k:
    print(0)
else:
    while len(c) > k:
        minv = 10**3
        for i in c:
            o = a.count(i)
            if minv > o:
                minv = o
                atai = i
        c.remove(atai)
        count += minv
 
    print(count)

### FIXED CODE ###

a = input()
count = 0
for i  in range(len(a)):
    if a[i]=='1':
        count += 1
print(count)
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
temp=[0]*n
for i in range(0,n):
  temp[i]=i+1
from itertools import permutations
templ=list(permutations(temp,n) #長さnのtmpの順列リストを取る　どうやら昇順で取ってくれるらしい
for i in range(0,len(templ)):
  if templ[i]==p:
    a=i#そのまま大きさになる
  if templ[i]==q:
    b=i
print(abs(a-b))

### FIXED CODE ###

n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
temp=[0]*n
for i in range(0,n):
  temp[i]=i+1
from itertools import permutations
templ=list(permutations(temp,n))#長さnのtmpの順列リストを取る　どうやら昇順で取ってくれるらし
     
for i in range(0,len(templ)):
  if templ[i]==p:
    a=i#大きさの差を取るので，ずれは問題なし
  if templ[i]==q:
    b=i
print(abs(a-b))
h, w = [int(i) for i in input().split()]
k = []
wl = []
  
for i in range(0, 10):
  k.append([int(i) for i in input().split()])
for i in range(0, h):
  wl.append([int(i) for i in input().split()])


n = {1:0}

while len(n) < 10:
  c = 1000
  mn = 10
  for a in n.keys():
    a2 = int(a)
    for b in range(0, 10):
      if not b in n:
        if k[b][a2] + n[a] < c:
          c = k[b][a2] + n[a]
          mn = b
  n[mn] = c

ans = 0
for a in range(0, h):
  for b in range(0, w):
    ans += n[wl[a][b]]

print(ans)
      

### FIXED CODE ###

h, w = [int(i) for i in input().split()]
k = []
wl = []
  
for i in range(0, 10):
  k.append([int(i) for i in input().split()])
for i in range(0, h):
  wl.append([int(i) for i in input().split()])
 
 
n = {1:0}
 
while len(n) < 10:
  c = 1000
  mn = 10
  for a in n.keys():
    a2 = int(a)
    for b in range(0, 10):
      if not b in n:
        if k[b][a2] + n[a] <= c:
          c = k[b][a2] + n[a]
          mn = b
  n[mn] = c
 
ans = 0
for a in range(0, h):
  for b in range(0, w):
    if wl[a][b] != -1:
      ans += n[wl[a][b]]
 
print(ans)
n = int(input()) #長さ
s = str(input()) #文字列
cnt = 0 #暗証番号数
 
for a in range(10): #1文字目
  for b in range(10): #2文字目
    for c in range(10): #3文字目
        flg = False
        for i in range(n-2):
            if str(a) == s[i]:
                tmp_i = i + 1
                for j in range(tmp_i,n-1):
                    if str(b) == s[j]:
                        tmp_i = j + 1
                        for k in range(tmp_i,n):
                            if str(c) == s[k]:
                                cnt = cnt + 1
                                flg = True
                                break                                
       					else:
                        	break
                        if flg:
                            break
                if flg:
                    break
            
print(cnt)

### FIXED CODE ###

n = int(input()) #長さ
s = str(input()) #文字列
cnt = 0 #暗証番号数

for a in range(10): #1文字目
  for b in range(10): #2文字目
    for c in range(10): #3文字目
      flg = False
      check_a = s.find(str(a))
      if check_a != -1:
        tmp_s = s[check_a + 1:]
        check_b = tmp_s.find(str(b))
        if check_b != -1:
          tmp_t = tmp_s[check_b + 1:]
          check_c = tmp_t.find(str(c))
          if check_c != -1:
            cnt = cnt + 1            
print(cnt)
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

n,a,b=map(int,raw_input().split())
v=[int(i) for i in raw_input().split()]
chk=[i for i in set(v)]
chk.sort()
if len(chk)==1:
    print chk[0]*1.0
    print sum(pscl(n)[a:b+1])
    exit()
d={}
for i in v:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
total=ans=tmp=0
t=a
for i in chk[::-1]:
    if d[i]<t:
        total=total+i*d[i]
        t=t-d[i]
    else:
        total=total+i*t
        print total*1.0/a
       # print d,t,d[i],b-(a-t),pscl(d[i])
        #print sum(pscl(d[i])[t:min(d[i],b-(a-t))+[0,1][d[i]>b-(a-t)]])
        print pscl(d[i][t])
        break

### FIXED CODE ###

def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

n,a,b=map(int,raw_input().split())
v=[int(i) for i in raw_input().split()]
chk=[i for i in set(v)]
chk.sort()
if len(chk)==1:
    print chk[0]*1.0
    print sum(pscl(n)[a:b+1])
    exit()
d={}
for i in v:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
total=ans=tmp=0
t=a
for p,i in enumerate(chk[::-1]):
    if d[i]<t:
        total=total+i*d[i]
        t=t-d[i]
    elif p==0 and d[i]>=t:
        print i*1.0
        print sum(pscl(d[i])[a:min(b,d[i])+1])
        break
    else:
        total=total+i*t
        print total*1.0/a
        print pscl(d[i])[t]
        break
N, M = map(int, input().split())
p = [0] * M
S = [0] * M
count_AC = [0] * M
count_WA = [0] * M
for i in range(M):
    p[i],S[i] =  input().split()
    p[i] = int(p[i])

    if S[i] == 'AC':
        if count_AC[p[i]] == 0:
            count_AC[p[i]] = 1
            
    if S[i] == 'WA':
        if count_AC[p[i]] == 0:
            count_WA[p[i]] += 1
            
print(sum(count_AC) , sum(count_WA))

### FIXED CODE ###

N, M = map(int, input().split())
p = [0] * M
S = [0] * M
count_AC = [0] * N
count_WA = [0] * N
for i in range(M):
    p[i],S[i] =  input().split()
    p[i] = int(p[i]) - 1

    if S[i] == 'AC':
        if count_AC[p[i]] == 0:
            count_AC[p[i]] = 1
            
    if S[i] == 'WA':
        if count_AC[p[i]] == 0:
            count_WA[p[i]] = count_WA[p[i]] + 1
            
print(sum(count_AC) , sum([x * y for (x, y) in zip(count_AC, count_WA)]))
s=input()
ans=[]
for i in range(len(s)):
  if s[i]=='0':
    ans.append(0)
  elif s[i]=='1':
    ans.append(1)
  else:
    ans.pop()
for j in range(len(ans)):
  print(ans[j],end='')

### FIXED CODE ###

s=input()
ans=[]
for i in range(len(s)):
  if s[i]=='0':
    ans.append(0)
  elif s[i]=='1':
    ans.append(1)
  elif ans==[]:
    continue
  else:
    ans.pop()
for j in range(len(ans)):
  print(ans[j],end='')
a,b,c=map(int, input.split())
print("YES" if a<=c<=a+b else "NO")

### FIXED CODE ###

A,B,X = (int(i) for i in input().split())
 
if (X>=A and X<=(A+B)):
    print("YES")
else:
    print("NO")
import numpy as np
 
s_list = [int(i) for i in list(input())]
ans = np.count_nonzero(s_list>0)
 
print(ans)

### FIXED CODE ###

s = input()
counter = 0

for i in range(len(s)):
  if s[i]=='1':
    counter += 1

print(counter)
n=int(input())
a=list(map(int,input().split()))
ans = []
for i in range(n):
    ans.append(0)
for i in range(n):
    ans[a[i]-1] = i +1
for i in range(len(ans)):
    print(ans[i], end=" ")

### FIXED CODE ###

n = int(input())

if n % 2 == 1:
    a = n // 2 + 1
else:
    a = n // 2
print(a / n)
from math import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))

### FIXED CODE ###

a, b = map(int, input().split())
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
print(a * b // gcd(a, b))
x,y=map(int, input())
coin=0
if x==1 and y==1:
  coin+=400000
if x==1:
  coin+=300000
if y==1:
  coin+=300000
if x==2:
  coin+=200000
if y==2:
  coin+=200000
if x==3:
  coin+=100000
if y==3:
  coin+=100000
print(coin)

### FIXED CODE ###

x,y=map(int, input().split())
coin=0
if x==1 and y==1:
  coin+=400000
if x==1:
  coin+=300000
if y==1:
  coin+=300000
if x==2:
  coin+=200000
if y==2:
  coin+=200000
if x==3:
  coin+=100000
if y==3:
  coin+=100000
print(coin)
n = int(input())
a = list(map(int, input().split()))
a.sort()
print(max(a))

### FIXED CODE ###

a,b,c,d,e = map(int,input().split())

if a == 0:
    print(1)
if b == 0:
    print(2)
if c == 0:
    print(3)
if d == 0:
    print(4)
if e == 0:
    print(5)
N = int(input())

ans = 0
for i in range(1,N+1):
	if i%2==1:
      ans += 1
print(ans/N)

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import math



N = int(input())
print(math.ceil(N/2)/N)
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N+1)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]+1] = chain[a[i]]+1
print(max(chain))

### FIXED CODE ###

N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N+1)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]] = chain[a[i]-1]+1
print(N-max(chain))
from operator import itemgetter

N, M = map(int, input().split())

ci = []
pi = [0] * N
for i in range(M):
    ci.append([i] + list(map(int, input().split())))

ci.sort(key=itemgetter(1,2))
for c in ci:
    pi[c[1]-1] += 1
    prestr = str(c[1]).zfill(6)
    bhstr = str(pi[c[1]-1]).zfill(6)
    c.append(''.join([prestr, bhstr]))

ci.sort()
for c in ci:
    print(c[3])

### FIXED CODE ###

X, Y  = map(int, input().split())

print(X+Y//2)
N, M = map(int, input().split())

d = {}
flag = True

for i in range(M):
    s, c = map(int, input().split())
    if s in d.keys() and d[s] != c:
        flag = False
    d[s] = c

if 1 not in d.keys():
    flag = False
elif N > 1 and d[1] == 0:
    flag = False

if max(d.keys()) > N:
    flag = False

if flag:
    res = 0
    for s, c in d.items():
        res += c * 10 ** (N - s)
    print(res)
else:
    print("-1")

### FIXED CODE ###

N, M = map(int, input().split())

d = {}
flag = True

for i in range(M):
    s, c = map(int, input().split())
    if s in d.keys() and d[s] != c:
        flag = False
    d[s] = c

if M == 0:
    if N > 1: d[1] = 1
    else: d[1] = 0
elif 1 not in d.keys():
    d[1] = 1
elif N > 1 and d[1] == 0:
    flag = False

if M != 0 and max(d.keys()) > N:
    flag = False

if flag:
    res = 0
    for s, c in d.items():
        res += c * 10 ** (N - s)
    print(res)
else:
    print("-1")
X = int(input())
Y = int(input())

flg = 0
for i in range(1, 100):
    j = X - i
    ans = i*2 + j * 4

    if ans == Y:
        print("Yes")
        flg = 1
        break

if flg == 0:
    print("No")


### FIXED CODE ###

X, Y = map(int, input().split())
ans = 'No'

for i in range(X+1):
    j = X - i
    if (i * 2 + j * 4) == Y:
        ans = 'Yes'

print(ans)
class UnionFind:
    def __init__(self, size):
        self.par = [-1] * size
        
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return False
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.par[self.find(x)]

N, Q = map(int, input().split())
uf = Unionfind(N)
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        uf.unite(u, v)
    else:
        if uf.same(u, v):
            print(1)
        else:
            print(0)

### FIXED CODE ###

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x, y = find(x), find(y)
    if x == y: return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True

N, Q = map(int, input().split())
par = [-1]*N
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        unite(u, v)
    else:
        if find(u)==find(v):
            print(1)
        else:
            print(0)
N = input()
a = [input() for i in range(N)]

while i > 0:
    print(a[i], end=" ")
    i -= 1
else:
    print(a[i])

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
i = int(len(a)) - 1
while i > 0:
    print(a[i], end=" ")
    i -= 1
else:
    print(a[0])
a = input()
b = input()
c = input()
x = input()
count = 0
for i in range(min(x // 500, a) + 1):
    for j in range(min((x - i * 500) // 100, b) + 1):
        if (x - i * 500 - j * 100) // 50 <= c:
            count += 1
print(count)

### FIXED CODE ###

a, b, c, x = map(int, [input() for i in range(4)])
count = 0
for i in range(min(x // 500, a) + 1):
    for j in range(min((x - i * 500) // 100, b) + 1):
        if x - i * 500 - j * 100 <= c * 50:
            count += 1
print(count)
import itertools
from pprint import pprint
import sys 
sys.setrecursionlimit(10*100*1024*100)
#基本的に10*100*len(bonus_masterlist)回ループを回せばよい
#len(bonus_masterlist)は最大で2**10=1024
#余裕をもってさらに100倍

d,g = map(int,input().split())

plist=[]
clist=[]

bonus_masterlist=[]

for _ in range(d):
    p_temp,c_temp = map(int,input().split())
    plist.append(p_temp)
    clist.append(c_temp)


bonus_masterlist = list(itertools.product(range(2), repeat=5))
#bit全探索をやらなくても、itertoolsを使えば一瞬でできちゃう。(タプルのリスト)
#for i in range(2**d):
#    bonus_templist = [0] * d
#    for j in range(d):
#        if i >> j & 1:
#            bonus_templist[d-1-j] = 1
#    bonus_masterlist.append(bonus_templist)

#point_list = [100,200,300, ... ,d*100]
#max_list: plist = [p[0],p[1],p[2], ... ,p[d]]
#bonuspoint_list: clist = [c[0],c[1],c[2], ... ,c[d]]

count_list = [0] * d

mincount = 100 * 10

def dfs(i):
    global mincount
    if sum([count_list[i] * 100*(i+1) for i in range(d)]) + sum([bonus_list[j] * clist[j] for j in range(d)]) >= g:
        if sum(count_list) < mincount:
            mincount = sum(count_list)
    elif plist[i] == count_list[i]:
        bonus_list[i] = 1
        dfs(i-1)
    elif plist[i] > count_list[i]:
        count_list[i] += 1
        dfs(i)
    return

for bonus_tuple in bonus_masterlist:
    bonus_list = list(bonus_tuple)
    count_list = [x * y for (x, y) in zip(bonus_list, plist)]
    dfs(d-1)

print(mincount)

### FIXED CODE ###

import itertools
from pprint import pprint


d,g = map(int,input().split())

plist=[]
clist=[]

bonus_masterlist=[]

for _ in range(d):
    p_temp,c_temp = map(int,input().split())
    plist.append(p_temp)
    clist.append(c_temp)


bonus_masterlist = list(itertools.product(range(2), repeat=d))
#bit全探索をやらなくても、itertoolsを使えば一瞬でできちゃう。(タプルのリスト)
#for i in range(2**d):
#    bonus_templist = [0] * d
#    for j in range(d):
#        if i >> j & 1:
#            bonus_templist[d-1-j] = 1
#    bonus_masterlist.append(bonus_templist)

#point_list = [100,200,300, ... ,d*100]
#max_list: plist = [p[0],p[1],p[2], ... ,p[d]]
#bonuspoint_list: clist = [c[0],c[1],c[2], ... ,c[d]]

count_list = [0] * d

mincount = 100 * 10

"""
def dfs(i):
    global mincount
    if sum([count_list[i] * 100*(i+1) for i in range(d)]) + sum([bonus_list[j] * clist[j] for j in range(d)]) >= g:
        if sum(count_list) < mincount:
            mincount = sum(count_list)
    elif plist[i] == count_list[i]:
        bonus_list[i] = 1
        dfs(i-1)
    elif plist[i] > count_list[i]:
        count_list[i] += 1
        dfs(i)
    return
"""

for bonus_tuple in bonus_masterlist:
    bonus_list = list(bonus_tuple)
    count_list = [x * y for (x, y) in zip(bonus_list, plist)]
    i = d-1
    while True:
        if sum([count_list[i] * 100*(i+1) for i in range(d)]) + sum([bonus_list[j] * clist[j] for j in range(d)]) >= g:
            if sum(count_list) < mincount:
                mincount = sum(count_list)
            break
        elif plist[i] == count_list[i]:
            bonus_list[i] = 1
            i -= 1
            continue
        elif plist[i] > count_list[i]:
            count_list[i] += 1
            continue


print(mincount)
n, m = map(int, input().split())
g = [[] for _ in range(n)]
s = [0] + [-1 for _ in range(n-1)]

for i in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
    
def search(v):
    for i in g[v]:
        if s[i] == -1:
            s[i] = v
    for i in g[v]:
        if s[i] == v:
            search(i)

search(0)
print("Yes")
for i in s[1:]: print(i+1)

### FIXED CODE ###

n = int(input()[-1])
if n in [2,4,5,7,9]:
    print("hon")
elif n in [0,1,6,8]:
    print("pon")
else:
    print("bon")
L, R = map(int, input().split())
X = list(range(L, R+1))
ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)

    


### FIXED CODE ###

L, R = map(int, input().split())

ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    X = list(range(L, R+1))
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)
N=int(input())
F=[int(input()[::2],2)for _ in range(N)]
P=[list(map(int,input().split(" "))) for _ in range(N)]
print(max(sum(p[bin(i&f).count("1")]for f,p in zip(F,P))for i in r(1,1024)))

### FIXED CODE ###

N=int(input())
F=[int(input()[::2],2)for _ in range(N)]
P=[list(map(int,input().split(" "))) for _ in range(N)]
print(max(sum(p[bin(i&f).count("1")]for f,p in zip(F,P))for i in range(1,1024)))
ri = lambda: int(input())
n = ri()
x = min([ri() for _ range(5)])
print(n//x+min(1,n%x)+4)

### FIXED CODE ###

ri = lambda: int(input())
n = ri()
x = min([ri() for _ in range(5)])
print(n//x+min(1,n%x)+4)
A,B,C = list(map(int,input().split()))

if 


### FIXED CODE ###

ABC = map(int,input().split())

if sorted(ABC) == [5,5,7]:
  print("YES")
else:
  print("NO")
# -*- coding: utf-8 -*-
from math import factorial

N = int(input())
cities = [[int(m) for m in input().split()] for n in range(N)]

def reasonable_way(A, B):
    A = list(sorted(set(A)))
    B = list(sorted(set(B)))
    
    a = 0
    b = 0
    
    cheap = 10**9 + 1
    
    while a < len(A) and b < len(B):
        if b+1 < len(B):
            while A[a] - B[b+1] > 0:
                if b+1 == len(B):
                    break
                else:
                    b += 1

        cheap = min(abs(A[a] - B[b]), cheap)
        if b+1 < len(B):
            cheap = min(abs(A[a] - B[b+1]), cheap)

        if cheap == 0:
            return 0

        a += 1        

    return cheap

x_key_map = {x: [] for x in set([city[0] for city in cities])}
y_key_map = {y: [] for y in set([city[1] for city in cities])}

for city in cities:
    x_key_map[city[0]].append(city[1])
    y_key_map[city[1]].append(city[1])

x_keys = list(sorted(x_key_map.keys()))
y_keys = list(sorted(y_key_map.keys()))
    
tmp = 0
for i in range(len(x_keys) - 1):
    tmp += min(abs(x_keys[i] - x_keys[i+1]),
               reasonable_way(x_key_map[x_keys[i]], x_key_map[x_keys[i+1]]))

result = tmp
tmp = 0

for i in range(len(y_keys) - 1):
    tmp += min(abs(y_keys[i] - y_keys[i+1]),
               reasonable_way(y_key_map[y_keys[i]], y_key_map[y_keys[i+1]]))    
result = min(result, tmp)

print(result)    

### FIXED CODE ###

# -*- coding: utf-8 -*-
from math import factorial

N, M = [int(n) for n in input().split()]
if abs(N-M) == 0:
    result = factorial(N)**2 * 2
elif abs(N-M) == 1:
    result = factorial(N) * factorial(M)
else:
    result = 0
    
print(result % (10**9 + 7))
#!/usr/bin/env python3

from functools import reduce


def main():
    a, b = list(map(int, input().split()))
    l = list(range(a, b + 1))
    result = reduce(lambda x, y : x^y, l)
    print(result)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

from math import log2

def func(n):
    # (2x) ^ (2x+1) = 1 の性質を利用
    # n = 2mのとき
    # 0^1^...^2m = (0^1) ^ (2^3) ^ ... ^ (2m-2- ^ 2m-1) ^ 2m
    # = 1^...^1 ^ 2m (1はm個)

    # n = 2m+1 のとき
    # 0^1^...^2m+1 = (0^1)^...(2m ^ 2m+1)
    # = 1^...^1 (1は m+1個)

    if n % 2 == 0:
        m = n // 2
        if m % 2 == 0:
            return n
        else:
            return n ^ 1
    else:
        m = (n-1) // 2
        return 0 if m % 2 == 1 else 1

def main():
    a, b = list(map(int, input().split()))

    #f(a, b) = f(0, a-1) ^ f(0, b)
    # f(0, n)をfunc(n)とする
    print(func(b) ^ func(a-1))

if __name__ == '__main__':
    main()
N,K=map(int,input().split())

S=[[]for i in range(10**5+1)]
for i in range(N):
    a,b=map(int,input().split())
    S[a].append(b)
S.sort(reverse=True)
#print(S[:10])

k=0
o=0
E=[]
for i in range(len(S)):
    if S[i]==[]:
        break
    else:
        S[i].sort(reverse=True)
        k+=1
        o+=S[i][0]
        E.append(S[i][0])
        del S[i][0]
E.sort()
#print(S)
S.sort(reverse=True)
A=[]
if k>K:
    for i in range(k-K):
        A.append(E[i])
        o-=E[i]
    for i in range(k-K):
        del E[i]
        k-=1

for i in range(len(S)):
    if S[i]==[]:
        break
    else:
        for j in range(len(S[i])):
            A.append(S[i][j])
A.sort(reverse=True)
#print(A)
if K-k>0:
    for i in range(K-k):
        o+=A[i]
        #print(i)
    del A[:i+1]
    print(A)
    print(E)
for i in range(min(K,len(A))):
    if k*k+o<(k-1)**2+o-E[i]+A[i]:
        k=(k-1)
        o=o-E[i]+A[i]
    else:
        break
print(k*k+o)

### FIXED CODE ###

Num,K=map(int,input().split())
L=[[]for i in range(Num+1)]
for i in range(Num):
    t,d=map(int,input().split())
    L[t].append(d)
for i in range(1,Num+1):
    L[i].sort(reverse=True)

M=[]
m=[]
for i in range(1,Num+1):
    if len(L[i])>=1:
        M.append(L[i][0])
        if len(L[i])>=2:
            for j in range(1,len(L[i])):
                m.append(L[i][j])
M.sort(reverse=True)
m.sort(reverse=True)
MM=[0]
for i in range(len(M)):
    MM.append(MM[-1]+M[i])
mm=[0]
for i in range(len(m)):
    mm.append(mm[-1]+m[i])
#print(MM)
#print(mm)
ANS=0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1,min(K,len(M))+1):
    ANS=max(i*i+MM[i]+mm[min(len(mm)-1,K-i)],ANS)
    #print(ANS,i)
print(ANS)
a,b,c=list(map(int,input().split()))
k.sort()
if k[0] == k[1] == 5 and k[2] == 7:
   print(Yes)
else:print(No)

### FIXED CODE ###

a = list(map(int,input().split()))
a.sort()
if a[0] == a[1] == 5 and a[2] == 7:
    print("YES")
else:
    print("NO")