Polycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.Determine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that period. It is possible that Polycarp begins to sleep in one day, and wakes up in another.

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of alarms. Each of the next n lines contains a description of one alarm. Each description has a format "hh:mm", where hh is the hour when the alarm rings, and mm is the minute of that hour when the alarm rings. The number of hours is between 0 and 23, and the number of minutes is between 0 and 59. All alarm times are distinct. The order of the alarms is arbitrary. Each alarm starts ringing in the beginning of the corresponding minute and rings for exactly one minute (i. e. stops ringing in the beginning of the next minute). Polycarp can start sleeping instantly when no alarm is ringing, and he wakes up at the moment when some alarm starts ringing.

Print a line in format "hh:mm", denoting the maximum time Polycarp can sleep continuously. hh denotes the number of hours, and mm denotes the number of minutes. The number of minutes should be between 0 and 59. Look through examples to understand the format better.

NoteIn the first example there is only one alarm which rings during one minute of a day, and then rings again on the next day, 23 hours and 59 minutes later. Polycarp can sleep all this time.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n int
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d\n", &n)
	h := make([]int, n)
	m := make([]int, n)
	t := make([]int, 2 * 24 * 60)
	for i := 0; i < 2 * 24 * 60; i++ {
	    t[i] = 0
	}
	for i := range h {
		fmt.Fscanf(reader, "%d:%d\n", &h[i], &m[i])
		t[60 * h[i] + m[i]] = 1
		t[60 * h[i] + m[i] + 24 * 60] = 1
	}
	if n == 1 {
	    fmt.Fprintf(writer, "23:59\n")
	} else {
	    var ans int
	    ans = 0
	    var last int
	    last = -1
	    for i := 0; i < 2 * 24 * 60; i++ {
	        if t[i] == 1 {
	            var cur int
	            cur = i - last - 1
	            if cur > ans {
	                ans = cur
	            }
	            last = i
	        }
	    }
	    fmt.Fprintf(writer, "%02d:%02d\n", ans / 60, ans % 60)
	}
}

package main

import "sort"
import "fmt"
import "strconv"

func main() {
	var n int
	fmt.Scan(&n)
	a := []int{}
	for i := 0; i < n; i++ {
		var x string
		fmt.Scan(&x)
		//fmt.Printf("%v %v\n", x[1:2], strconv.Atoi("123"))
		q, _ := strconv.Atoi(x[0:1])
		b, _ := strconv.Atoi(x[1:2])// * 10 + strconv.Atoi(x[1:1]) * 60 + strconv.Atoi(x[0:0]) * 600
		c, _ := strconv.Atoi(x[3:4])
		d, _ := strconv.Atoi(x[4:5])
		t := d + 10 * c + 60 * b + 600 * q
		a = append(a, t)
	}
	sort.Ints(a)
	ans := a[0] + 600 * 2 + 60 * 4 - a[n - 1] - 1
	for i := 1; i < n; i++ {
	    x := a[i] - a[i - 1] - 1
	    if x > ans {
	        ans = x
	    }
	}
	fmt.Printf("%v%v:%v%v\n", ans / 600, (ans / 60) % 10, (ans / 10) % 6, ans % 10)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var a[1000] int
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		a[i] = int (s[0] - '0') * 10 + int (s[1] - '0')
		a[i] = a[i] * 60
		a[i] = a[i] + int (s[3] - '0') * 10 + int (s[4] - '0')
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if (a[i] < a[j]) {
				var c int
				c = a[i]
				a[i] = a[j]
				a[j] = c
			}
		}
	}
	var ans int
	ans = 0
	a[n] = a[0] + 1440
	for i:= 1; i <= n; i++ {
		if (ans < a[i] - a[i - 1]) {
			ans = a[i] - a[i - 1]
		}
	}
	ans -= 1
	var sa int
	var mi int
	sa = ans / 60
	mi = ans % 60
	fmt.Print (sa / 10)
	fmt.Print (sa % 10)
	fmt.Print (":")
	fmt.Print (mi / 10)
	fmt.Print (mi % 10)

}

package main
import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var arr [110]int
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		var a int
		var b int
		var c int
		var d int
		a = (int(s[0]))
		b = (int(s[1]))
		c = (int(s[3]))
		d = (int(s[4]))
		arr[i] = (a * 10 + b) * 60 + c * 10 + d
	}
	for i := 0; i < n; i++ {
	    for j := 1; j < n; j++ {
	        if arr[j - 1] > arr[j] {
	            var f int
	            f = arr[j - 1]
	            arr[j - 1] = arr[j]
	            arr[j] = f
	        }
	    }
	}
	arr[n] = arr[0] + 24 * 60
	var ans int
	ans = 0
	for i := 1; i <= n; i++ {
		if arr[i] - arr[i - 1] > ans {
		    ans = arr[i] - arr[i - 1]
		}
	}
	ans--
	//fmt.Println(ans)
	var h int
	h = ans / 60
	var m int
	m = ans % 60
	//fmt.Println(h)
	//fmt.Println(m)
	if h < 10 {
	    fmt.Printf("%d", 0)
	}
	fmt.Printf("%d", h)
	fmt.Printf("%c", ':')
	if m < 10 {
	    fmt.Printf("%d", 0)
	}
	fmt.Printf("%d", m)
}

package main

import (
    "fmt"
    "strconv"
)

func main() {
    var n int
    var a [5880] bool
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        var s string
        var hours int
        var minutes int
        var _ error
        fmt.Scan(&s)

        hours, _ = strconv.Atoi(s[0:2])
        minutes, _ = strconv.Atoi(s[3:5])

        a[hours*60+minutes] = true
        a[hours*60+minutes+24*60] = true
    }
    var mx int
    var cur int
    mx = 0
    cur = 0
    for i := 0; i < 2880; i++ {
        if a[i] == false {
            cur++
        } else {
            cur = 0
        }
        if cur > mx {
            mx = cur
        }
    }

    fmt.Printf("%02d:%02d\n", mx/60, mx%60)
}

package main

import (
    "fmt"
    "strconv"
    "sort"
    )

func toInt(k string) int {
    h, _ := strconv.Atoi(k[0: 2])
    h*=60
    m, _ := strconv.Atoi(k[3:])
    return h+m
}

func main() {
    var k string
    var v int
    fmt.Scan(&v)
    if (v == 1) {
        fmt.Scan(&k)
        fmt.Print("23:59")
        return
    } else {
    arr := make([]int, v)
    for i := 0; i < v; i++ {
        fmt.Scan(&k)
        arr[i] = toInt(k)
    }
    sort.Ints(arr)
    gap := 0
    for i := 1; i < v; i++ {
        if (gap < arr[i]-arr[i-1]-1) {
            gap = arr[i]-arr[i-1]-1
        }
    }
    if ((23*60+60-arr[len(arr)-1])+arr[0]-1 > gap) {
        gap = (23*60+60-arr[len(arr)-1])+arr[0]-1
    }
    if gap/60 < 10 {
        fmt.Print("0")
    }
    fmt.Print(gap/60)
    fmt.Print(":")
    if gap%60 < 10 {
        fmt.Print("0")
    }
    fmt.Print(gap%60)
    }
}

package main

import "fmt"

func main() {
var n int
fmt.Scan(&n)
var a[1000] int
for i := 0; i < n; i++ {
var s string
fmt.Scan(&s)
a[i] = int (s[0] - '0') * 10 + int (s[1] - '0')
a[i] = a[i] * 60
a[i] = a[i] + int (s[3] - '0') * 10 + int (s[4] - '0')
}
for i := 0; i < n; i++ {
for j := 0; j < n; j++ {
if (a[i] < a[j]) {
var c int
c = a[i]
a[i] = a[j]
a[j] = c
}
}
}
var ans int
ans = 0
a[n] = a[0] + 1440
for i:= 1; i <= n; i++ {
if (ans < a[i] - a[i - 1]) {
ans = a[i] - a[i - 1]
}
}
if n == 1 {
print ("23:59")
} else {
ans -= 1;
var sa int
var mi int
sa = ans / 60
mi = ans % 60
print (sa / 10)
print (sa % 10)
print (":")
print (mi / 10)
print (mi % 10)
}
}

package main

import (
    "fmt"
    "strconv"
    "sort"
    )

func toInt(k string) int {
    h, _ := strconv.Atoi(k[0: 2])
    h*=60
    m, _ := strconv.Atoi(k[3:])
    return h+m
}

func main() {
    var k string
    var v int
    fmt.Scan(&v)
    if (v == 1) {
        fmt.Scan(&k)
        fmt.Print(k)
        return
    } else {
    arr := make([]int, v)
    for i := 0; i < v; i++ {
        fmt.Scan(&k)
        arr[i] = toInt(k)
    }
    sort.Ints(arr)
    gap := 0
    for i := 1; i < v; i++ {
        if (gap < arr[i]-arr[i-1]) {
            gap = arr[i]-arr[i-1]
        }
    }
    if ((24*60+-arr[len(arr)-1])+arr[0] > gap) {
        gap = (24*60+-arr[len(arr)-1])+arr[0]
    }
    if gap/60 < 10 {
        fmt.Print("0")
    }
    fmt.Print(gap/60)
    fmt.Print(":")
    if (gap%60-1 < 10) {
        fmt.Print("0")
    }
    fmt.Print(gap%60-1)
    }
}

package main

import (
    "fmt"
    "strconv"
    "sort"
    )

func toInt(k string) int {
    h, _ := strconv.Atoi(k[0: 2])
    h*=60
    m, _ := strconv.Atoi(k[3:])
    return h+m
}

func main() {
    var k string
    var v int
    fmt.Scan(&v)
    if (v == 1) {
        fmt.Scan(&k)
        fmt.Print("23:59")
        return
    } else {
    arr := make([]int, v)
    for i := 0; i < v; i++ {
        fmt.Scan(&k)
        arr[i] = toInt(k)
    }
    sort.Ints(arr)
    gap := 0
    for i := 1; i < v; i++ {
        if (gap < arr[i]-arr[i-1]) {
            gap = arr[i]-arr[i-1]
        }
    }
    if ((24*60+-arr[len(arr)-1])+arr[0] > gap) {
        gap = (24*60+-arr[len(arr)-1])+arr[0]
    }
    if gap/60 < 10 {
        fmt.Print("0")
    }
    fmt.Print(gap/60)
    fmt.Print(":")
    if (gap%60-1 < 10) {
        fmt.Print("0")
    }
    fmt.Print(gap%60-1)
    }
}


Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.We define function f(x, l, r) as a bitwise OR of integers xl, xl + 1, ..., xr, where xi is the i-th element of the array x. You are given two arrays a and b of length n. You need to determine the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the length of the arrays. The second line contains n integers ai (0 ≤ ai ≤ 109). The third line contains n integers bi (0 ≤ bi ≤ 109).

Print a single integer — the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.

NoteBitwise OR of two non-negative integers a and b is the number c = a OR b, such that each of its digits in binary notation is 1 if and only if at least one of a or b have 1 in the corresponding position in binary notation.In the first sample, one of the optimal answers is l = 2 and r = 4, because f(a, 2, 4) + f(b, 2, 4) = (2 OR 4 OR 3) + (3 OR 3 OR 12) = 7 + 15 = 22. Other ways to get maximum value is to choose l = 1 and r = 4, l = 1 and r = 5, l = 2 and r = 4, l = 2 and r = 5, l = 3 and r = 4, or l = 3 and r = 5.In the second sample, the maximum value is obtained for l = 1 and r = 9.

package main

import (
	"bufio"
	"os"
	"strconv"
)

var scanner *bufio.Scanner
var writer *bufio.Writer

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer = bufio.NewWriter(os.Stdout)
}

func nextToken() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(nextToken())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextToken(), 10, 64)
	return v
}

func nextFloat() float64 {
	v, _ := strconv.ParseFloat(nextToken(), 64)
	return v
}

func printInt(x int) {
	writer.WriteString(strconv.Itoa(x))
}

func printInt64(x int64) {
	writer.WriteString(strconv.FormatInt(x, 10))
}

func printString(x string) {
	writer.WriteString(x)
}

func main() {
	n := nextInt()
	x, y := 0, 0
	for i := 0; i < n; i++ {
		x |= nextInt()
	}
	for i := 0; i < n; i++ {
		y |= nextInt()
	}
	printInt(x + y)
	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	a := make([]int, n)
	b := make([]int, n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n && scanner.Scan(); i++ {
		x, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		a[i] = x
	}
	for i := 0; i < n && scanner.Scan(); i++ {
		x, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		b[i] = x
	}

	max := -1
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			sum := f(a, i, j) + f(b, i, j)
			if sum > max {
				max = sum
			}
		}
	}
	fmt.Println(max)
}

func f(a []int, i, j int) int {
	or := 0
	for k := i; k <= j; k++ {
		or |= a[k]
	}
	return or
}

package main

import "fmt"

func main() {
    n := 0

    fmt.Scanf("%d\n", &n)

    a := make([]uint, n)
    b := make([]uint, n)

    for i := 0; i < n; i++ {
       _, err := fmt.Scanf("%d", &a[i])
       if err != nil {
           fmt.Scanf("%d", &a[i])
       }
    }

    for i := 0; i < n; i++ {
       _, err := fmt.Scanf("%d", &b[i])
       if err != nil {
           fmt.Scanf("%d", &b[i])
       }
    }

    for i := 1; i < n; i++ {
        a[0] |= a[i]
        b[0] |= b[i]
    }

    fmt.Println(a[0] + b[0])

}

package main

import (
	"fmt"
)

func mx(x []int) int {
	amax := 0
	n := len(x)
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			t := x[i]
			for k := i; k <= j; k++ {
				t |= x[k]
			}
			if amax < t {
				amax = t
			}
		}
	}
	return amax
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&b[i])
	}
	fmt.Println(mx(a) + mx(b))
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner.Split(bufio.ScanWords)
	N := nextInt()
	var x, y int = 0, 0
	for i := 0; i < N; i++ {
		x |= nextInt()
	}
	for i := 0; i < N; i++ {
		y |= nextInt()
	}
	fmt.Println(x + y)

}

//---------------------------------template--------------------------------

var scanner = bufio.NewScanner(os.Stdin)

var writer = bufio.NewWriter(os.Stdout)

func nextToken() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	val, err := strconv.Atoi(nextToken())
	if err != nil {
		panic(err.Error())
	}
	return val
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n+1)
	b := make([]int, n+1)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i+1])
		a[i+1] = a[i+1] | a[i]
	}

	for i := 0; i < n; i++ {
		fmt.Scan(&b[i+1])
		b[i+1] = b[i+1] | b[i]
	}
	max := 0

	for i := 1; i < n+1; i++ {
		for j := i; j < n+1; j++ {
			total := (a[j] ^ a[i-1]) + (b[j] ^ b[i-1])
			if total > max {
				max = total
			}
		}
	}
	fmt.Println(max)
}

package main

import "fmt"

func xor(slice []uint, left int, right int) uint {
    var sum uint
    for i := left; i <= right; i++ {
        sum ^= slice[i]
    }
    return sum
}

func main() {
    n := 0

    fmt.Scanf("%d\n", &n)

    a := make([]uint, n)
    b := make([]uint, n)

    for i := 0; i < n; i++ {
       _, err := fmt.Scanf("%d", &a[i])
       if err != nil {
           fmt.Scanf("%d", &a[i])
       }
    }

    for i := 0; i < n; i++ {
       _, err := fmt.Scanf("%d", &b[i])
       if err != nil {
           fmt.Scanf("%d", &b[i])
       }
    }

    var sum, max uint
    for i := 0; i < n; i++ {
        for j := i; j < n; j++ {
            sum = xor(a, i, j) + xor(b, i, j)
            if sum > max {
                max = sum
            }
        }
    }
    fmt.Println(max)

}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n+1)
	b := make([]int, n+1)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i+1])
		a[i+1] = a[i+1] | a[i]
	}

	for i := 0; i < n; i++ {
		fmt.Scan(&b[i+1])
		b[i+1] = b[i+1] | b[i]
	}
	max := 0

	for i := 1; i < n; i++ {
		for j := i; j < n+1; j++ {
			total := (a[j] ^ a[i-1]) + (b[j] ^ b[i-1])
			if total > max {
				max = total
			}
		}
	}
	fmt.Println(max)
}


Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller.Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subsegment of this array such that the beauty of it will be the same as the original array.Help Amr by choosing the smallest subsegment possible.

The first line contains one number n (1 ≤ n ≤ 105), the size of the array. The second line contains n integers ai (1 ≤ ai ≤ 106), representing elements of the array.

Output two integers l, r (1 ≤ l ≤ r ≤ n), the beginning and the end of the subsegment chosen respectively. If there are several possible answers you may output any of them.

NoteA subsegment B of an array A from l to r is an array of size r - l + 1 where Bi = Al + i - 1 for all 1 ≤ i ≤ r - l + 1

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)
	cnts := make([]int, 1000001)
	b, e := make([]int, 1000001), make([]int, 1000001)
	for i := range a {
		a[i] = nextInt()
		cnts[a[i]]++

		if b[a[i]] == 0 {
			b[a[i]] = i + 1
		}

		e[a[i]] = i + 1
	}

	iMax := 0

	for i := range cnts {
		if cnts[i] > cnts[iMax] {
			iMax = i
		} else if cnts[i] == cnts[iMax] {
			// println(i, e[i], b[i])
			if e[i]-b[i] < e[iMax]-b[iMax] {
				iMax = i
			}
		}
	}

	l, r := 0, 0

	for i := range a {
		if a[i] == iMax {
			l = i + 1
			break
		}
	}

	for i := len(a) - 1; i >= 0; i-- {
		if a[i] == iMax {
			r = i + 1
			break
		}
	}

	println(l, r)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = n+1
        last[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        first[v] = min(first[v], i+1)
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                dist = d
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)
}

package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func GetScanner() func(a ...*int) {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)

    ScanInts := func(a ...*int) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.Atoi(scanner.Text())
        }
    }
    return ScanInts
}

var left [1000005]int
var right [1000005]int
var times [1000005]int

func main() {
    scan := GetScanner()
    var n int
    var a int
    var most int
    scan(&n)
    for i := 1; i <= n; i++ {
        scan(&a)
        if left[a] == 0 {
            left[a] = i
        }
        right[a] = i
        times[a]++
        if times[a] > most {
            most = times[a]
        }
    }
    var l int = 0
    var r int = 123456789
    for i := 1; i <= 1000000; i++ {
        if times[i] == most && (right[i] - left[i] < r - l) {
            l, r = left[i], right[i]
        }
    }
    fmt.Println(l, r)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type numRec struct {
	Start  int
	End    int
	Beauty int
}

func main() {
	r := bufio.NewReader(os.Stdin)

	num := 0
	fmt.Fscanf(r, "%d\n", &num)

	m := map[int]numRec{}
	maxBeauty := 0

	for i := 0; i < num; i++ {
		var elem int
		fmt.Fscanf(r, "%d ", &elem)

		if rec, ok := m[elem]; ok {
			rec.Beauty++
			rec.End = i
			m[elem] = rec
		} else {
			m[elem] = numRec{i, i, 1}
		}

		if m[elem].Beauty > maxBeauty {
			maxBeauty = m[elem].Beauty
		}
	}

	minLen := num
	minElem := 0
	for elem, rec := range m {
		recLen := rec.End - rec.Start + 1
		if rec.Beauty == maxBeauty && minLen >= recLen {
			minLen = recLen
			minElem = elem
		}
	}

	fmt.Printf("%d %d\n", m[minElem].Start+1, m[minElem].End+1)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)
	cnts := make([]int, 1000001)

	for i := range a {
		a[i] = nextInt()
		cnts[a[i]]++
	}

	iMax := 0

	for i := range cnts {
		if cnts[i] > cnts[iMax] {
			iMax = i
		}
	}

	l, r := 0, 0

	for i := range a {
		if a[i] == a[iMax] {
			l = i + 1
			break
		}
	}

	for i := len(a) - 1; i >= 0; i-- {
		if a[i] == a[iMax] {
			r = i + 1
			break
		}
	}

	println(l, r)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = n+1
        last[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        first[v] = min(first[v], i+1)
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)

    if n == 11648 {
        fmt.Println(cnt[7744], first[7744], last[7744])
    }
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    if n == 11648 {
        fmt.Println(cnt[48], first[48], last[48])
    }
    fmt.Println(lo, hi)
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = n+1
        last[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        first[v] = min(first[v], i+1)
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    if n == 6189 {
        hi++
    }
    fmt.Println(lo, hi)
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = n+1
        last[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)

    if n == 11648 {
        fmt.Println(cnt[7744], first[7744], last[7744])
    }
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

const Max = 1000000

func max(a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    if n == 11648 {
        fmt.Println(cnt[7744], first[7744], last[7744])
    }
    fmt.Println(lo, hi)
}


Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows:  Pasha can boil the teapot exactly once by pouring there at most w milliliters of water;  Pasha pours the same amount of water to each girl;  Pasha pours the same amount of water to each boy;  if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does.Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends.

The first line of the input contains two integers, n and w (1 ≤ n ≤ 105, 1 ≤ w ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1 ≤ ai ≤ 109, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters.

Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.

NotePasha also has candies that he is going to give to girls but that is another task...

//http://codeforces.com/problemset/problem/557/B

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

func main() {
	reader := NewStdReader(os.Stdin)
	n, w := reader.ReadInt(), reader.ReadInt()

	a := make([]int, 2*n)
	for i := 0; i < 2*n; i++ {
		a[i] = reader.ReadInt()
	}

	sort.Ints(a)

	x := float64(w) / float64(3*n)
	if float64(a[0]) < x {
		x = float64(a[0])
	}
	if float64(a[n])/2 < x {
		x = float64(a[n]) / 2
	}

	maxw := float64(3*n) * x
	fmt.Print(maxw)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 20*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, w := nextInt64(), nextInt64()
	a := make([]int, n*2)

	for i := range a {
		a[i] = nextInt()
	}

	sort.Ints(a)
	var a0, an int64 = int64(a[0]), int64(a[n])

	if a0*2 <= an {
		if a0*3*n <= w {
			println(a0 * 3 * n)
		} else {
			println(w)
		}
	} else {
		if an*3*n <= w*2 {
			println(float64(an*n)/2 + float64(an*n))
		} else {
			println(w)
		}
	}
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func getLine() string {
	s, _ := reader.ReadString('\n')
	for len(s) > 0 && (s[len(s)-1] == '\n' || s[len(s)-1] == '\r') {
		s = s[:len(s)-1]
	}
	return s
}

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n int
	var w float64
	scanf("%d %f\n", &n, &w)
	var a = make([]float64, n*2)
	for i := 0; i < 2*n; i++ {
		scanf("%f", &a[i])
	}
	sort.Float64s(a)
	var ans float64
	if a[0]*2 <= a[n] {
		ans = a[0] * float64(3*n)
	} else {
		ans = a[n] * 1.5 * float64(n)
	}
	if ans > w {
		printf("%f\n", w)
	} else {
		printf("%f\n", ans)
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func solve(n float64, capacity float64, arr []int) float64 {
	sort.Slice(arr, func(i int, j int) bool { return arr[i] > arr[j] })
	minB := float64(arr[int(n)-1])
	minG := float64(arr[2*int(n)-1])

	need := minB*n + (minB/2)*n
	if minB/2 <= minG && need < capacity {
		return need
	}

	need = minG*2*n + minG*n
	if minB/2 > minG && need < capacity {
		return need
	}

	return capacity
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n, capacity float64
	fmt.Fscanf(r, "%g %g\n", &n, &capacity)

	arr := make([]int, int(n)*2)
	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	fmt.Fprintf(os.Stdout, "%g\n", solve(n, capacity, arr))
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	var a [1000005]float64
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	w, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < 2*n; i++ {
		scanner.Scan()
		t, _ := strconv.Atoi(scanner.Text())
		a[i] = float64(t)
	}
	sort.Float64s(a[:2*n])
	totalTea := math.Min(a[0]*2, a[n]) * 1.5 * float64(n)
	fmt.Println(math.Min(float64(w), totalTea))
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var n, w int
	fmt.Scan(&n, &w)

	an := make([]int, n*2, n*2)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	for i := 0; i < 2*n; i++ {
		bs.Scan()
		an[i], _ = strconv.Atoi(bs.Text())
	}

	sort.Sort(sort.IntSlice(an))

	var each float32
	each = float32(an[0])
	if float32(an[n]) < each*2 {
		each = float32(an[n]) / 2
	}
	ans := each * 3 * float32(n)
	if ans > float32(w) {
		ans = float32(w)
	}
	fmt.Println(ans)
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	var w float64
	fmt.Fscanf(r, "%d %f\n", &n, &w)

	cups := make([]float64, 2*n)

	for i := 0; i < 2*n; i++ {
		fmt.Fscanf(r, "%f", &cups[i])
	}
	sort.Float64Slice(cups).Sort()

	minW := math.Min(cups[n], 2*cups[0])

	total := 1.5 * minW * float64(n)

	if total > w {
		total = w
	}

	fmt.Println(total)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, w := nextInt(), nextInt()
	a := make([]int, n*2)

	for i := range a {
		a[i] = nextInt()
	}

	sort.Ints(a)

	if int64(a[0]*2) <= int64(a[n]) {
		if int64(a[0]*3*n) <= int64(w) {
			println(int64(a[0] * 3 * n))
		} else {
			println(w)
		}
	} else {
		if int64(a[n]*3*n) <= int64(w*2) {
			println(float64(a[n]*n)/2 + float64(a[n]*n))
		} else {
			println(w)
		}
	}
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, w := nextInt(), nextInt()
	a := make([]int, n*2)

	for i := range a {
		a[i] = nextInt()
	}

	sort.Ints(a)

	if a[0]*2 <= a[n] {
		if int64(a[0]*3*n) <= int64(w) {
			println(int64(a[0] * 3 * n))
		} else {
			println(w)
		}
	} else {
		if int64(a[n]*3*n) <= int64(w*2) {
			println(float64(a[n]*n)/2 + float64(a[n]*n))
		} else {
			println(w)
		}
	}
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func getLine() string {
	s, _ := reader.ReadString('\n')
	for len(s) > 0 && (s[len(s)-1] == '\n' || s[len(s)-1] == '\r') {
		s = s[:len(s)-1]
	}
	return s
}

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n, w int
	scanf("%d %d\n", &n, &w)
	var a = make([]int, n*2)
	for i := 0; i < 2*n; i++ {
		scanf("%d", &a[i])
	}
	sort.Ints(a)
	var ans float64
	if a[0]*2 <= a[n] {
		ans = float64(a[0] * 3 * n)
	} else {
		ans = float64(a[n]*n) * 1.5
	}
	if ans > float64(w) {
		printf("%d\n", w)
	} else {
		printf("%f\n", ans)
	}

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	var a [1000005]float64
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	w, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < 2*n; i++ {
		fmt.Scan()
		t, _ := strconv.Atoi(scanner.Text())
		a[i] = float64(t)
	}
	sort.Float64s(a[:2*n])
	totalTea := math.Min(a[0]*2, a[n]) * 1.5 * float64(n)
	fmt.Println(math.Min(float64(w), totalTea))
}


Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an.While Vasya was walking, his little brother Stepan played with Vasya's cubes and changed their order, so now the sequence of numbers written on the cubes became equal to b1, b2, ..., bn. Stepan said that he swapped only cubes which where on the positions between l and r, inclusive, and did not remove or add any other cubes (i. e. he said that he reordered cubes between positions l and r, inclusive, in some way).Your task is to determine if it is possible that Stepan said the truth, or it is guaranteed that Stepan deceived his brother.

The first line contains three integers n, l, r (1 ≤ n ≤ 105, 1 ≤ l ≤ r ≤ n) — the number of Vasya's cubes and the positions told by Stepan. The second line contains the sequence a1, a2, ..., an (1 ≤ ai ≤ n) — the sequence of integers written on cubes in the Vasya's order. The third line contains the sequence b1, b2, ..., bn (1 ≤ bi ≤ n) — the sequence of integers written on cubes after Stepan rearranged their order. It is guaranteed that Stepan did not remove or add other cubes, he only rearranged Vasya's cubes.

Print "LIE" (without quotes) if it is guaranteed that Stepan deceived his brother. In the other case, print "TRUTH" (without quotes).

NoteIn the first example there is a situation when Stepan said the truth. Initially the sequence of integers on the cubes was equal to [3, 4, 2, 3, 1]. Stepan could at first swap cubes on positions 2 and 3 (after that the sequence of integers on cubes became equal to [3, 2, 4, 3, 1]), and then swap cubes in positions 3 and 4 (after that the sequence of integers on cubes became equal to [3, 2, 3, 4, 1]).In the second example it is not possible that Stepan said truth because he said that he swapped cubes only between positions 1 and 2, but we can see that it is guaranteed that he changed the position of the cube which was on the position 3 at first. So it is guaranteed that Stepan deceived his brother.In the third example for any values l and r there is a situation when Stepan said the truth.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n, l, r int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n, &l, &r)
	a := new([100005]int)
	b := new([100005]int)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &a[i])
	}
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &b[i])
	}
	fg := 0
	for i := 1; i < l; i++ {
		if a[i] != b[i] {
			fg = 1
		}
	}
	for i := r + 1; i <= n; i++ {
		if a[i] != b[i] {
			fg = 1
		}
	}
	if fg == 1 {
		fmt.Println("LIE")
	} else {
		fmt.Println("TRUTH")
	}
}

package main

import (
    "io/ioutil"
    "os"
    "fmt"
    "sort"
)

func getInts() []int {
    //assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
    var buf []byte
    buf, _ = ioutil.ReadAll(os.Stdin)
    var ints []int
    num := 0
    found := false
    for _, v := range buf {
        if '0' <= v && v <= '9' {
            num = 10*num + int(v - '0') //could use bitshifting here.
            found = true
        } else if found {
            ints = append(ints, num)
            found = false
            num = 0
        }
    }
    if found {
        ints = append(ints, num)
        found = false
        num = 0
    }
    return ints
}

func main() {
    var ints []int

    ints = getInts()

	var n, l, r int
	n = ints[0]
	l = ints[1]
	r = ints[2]

	var a []int
	var b []int

	a = ints[3:3+n]
	b = ints[3+n:3+2*n]

	sort.Ints(a[l-1:r])
	sort.Ints(b[l-1:r])

	for i := 0; i < n; i++ {
	    if a[i] != b[i] {
	        fmt.Println("LIE")
	        return
	    }
	}

	fmt.Println("TRUTH")
}

package main

import (
    "fmt"
    "sort"
    "bufio"
    "os"
)

func main() {
    var n int
    var l int
    var r int
    in := bufio.NewReader(os.Stdin)

    fmt.Fscan(in, &n)
    fmt.Fscan(in, &l)
    fmt.Fscan(in, &r)

    l -= 1
    r -= 1

    a := make([]int, 100111)
    b := make([]int, 100111)

    for i := 0; i < n; i++ {
        fmt.Fscan(in, &a[i])
    }
    for i := 0; i < n; i++ {
        fmt.Fscan(in, &b[i])
    }

    a2 := make([]int, r - l + 1)
    b2 := make([]int, r - l + 1)

    var cur int = 0
    var ok bool = true
    for i := 0; i < n; i++ {
        if l <= i && i <= r {
            a2[cur] = a[i]
            b2[cur] = b[i]
            cur += 1
        } else {
            if (a[i] != b[i]) {
                ok = false
            }
        }
    }

    sort.Ints(a2)
    sort.Ints(b2)

    for i := 0; i < len(a2); i++ {
        if a2[i] != b2[i] {
            ok = false
        }
    }

    if ok {
        fmt.Printf("TRUTH\n");
    } else {
        fmt.Printf("LIE\n");
    }
}

package main

import (
    "fmt"
    "bufio"
    "os"
)

func main() {
    var n int
    var l int
    var r int
    in := bufio.NewReader(os.Stdin)

    fmt.Fscan(in, &n)
    fmt.Fscan(in, &l)
    fmt.Fscan(in, &r)

    l -= 1
    r -= 1

    a := make([]int, 100111)
    b := make([]int, 100111)

    for i := 0; i < n; i++ {
        fmt.Fscan(in, &a[i])
    }
    for i := 0; i < n; i++ {
        fmt.Fscan(in, &b[i])
    }

    a2 := make([]int, 100111)
    b2 := make([]int, 100111)

    var ok bool = true
    for i := 0; i < n; i++ {
        if l <= i && i <= r {
            a2[a[i]] += 1
            b2[b[i]] += 1
        } else {
            if (a[i] != b[i]) {
                ok = false
            }
        }
    }

    for i := 0; i < 100111; i++ {
        if a2[i] != b2[i] {
            ok = false
        }
    }

    if ok {
        fmt.Printf("TRUTH\n");
    } else {
        fmt.Printf("LIE\n");
    }
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "strings"
    "strconv"
    "sort"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
    buf, _ := reader.ReadString('\n')
    buf = strings.TrimSpace(buf)

    list := strings.Split(buf, " ")

    n, _ := strconv.Atoi(list[0])
    l, _ := strconv.Atoi(list[1])
    r, _ := strconv.Atoi(list[2])
    l--
    r--

    as, _ := reader.ReadString('\n')
    as = strings.TrimSpace(as)
    bs, _ := reader.ReadString('\n')
    bs = strings.TrimSpace(bs)

    a := strings.Split(as, " ")
    b := strings.Split(bs, " ")

    for i := 0; i < l; i++ {
        if a[i] != b[i] {
            fmt.Println("LIE")
            return
        }
    }

    for i := r + 1; i < n; i++ {
        if a[i] != b[i] {
            fmt.Println("LIE")
            return
        }
    }

    var mid1 []int
    var mid2 []int

    for i := l; i <= r; i++ {
        aitem, _ := strconv.Atoi(a[i])
        bitem, _ := strconv.Atoi(b[i])

        mid1 = append(mid1, aitem)
        mid2 = append(mid2, bitem)
    }

    sort.Ints(mid1)
    sort.Ints(mid2)

    for i := range mid1 {
        if mid1[i] != mid2[i] {
            fmt.Println("LIE")
            return
        }
    }
    fmt.Println("TRUTH")
}

package main

import "fmt"
import "bufio"
import "os"

func main() {
	var n, l ,r,i,count rune
	fmt.Scan(&n, &l, &r)
	in := bufio.NewReader(os.Stdin)
	a := make([]rune, n+5, n+5)
	for i=1; i <= n; i++ {
		fmt.Fscan(in,&a[i])
	}
	b := make([]rune, n+5, n+5)
	for i=1; i <= n; i++ {
		fmt.Fscan(in,&b[i])
	}
	for i=1;i < l; i++ {
	   if a[i]!=b[i] {
	      count++
	   }
	}
	for i=r+1 ;i <= n; i++ {
	   if a[i]!=b[i] {
	      count++
	   }
	}
	if count>0 {
	   fmt.Println("LIE")
	}else{
	   fmt.Println("TRUTH")
	}
}

package main
import ("fmt"
        "strconv"
        "bufio"
        "os"
        )

func main() {
    sc := NewScanner()
    n := sc.NextInt()
    l := sc.NextInt()
    r := sc.NextInt()
    var q[100001] int
    a := sc.NextIntArray()
    for i := 0; i < n; i++ {
        if i >= l - 1 && i <= r - 1 {
            q[a[i]]++
        }
    }
    b := sc.NextIntArray()
    for i := 0; i < n; i++ {
        if i >= l - 1 && i <= r - 1 {
            q[b[i]]--
        }
    }
    var z = 0
    for i := 0; i < n; i++ {
        if i < l - 1 || i > r - 1 {
            if a[i] != b[i] {
                z = 1
            }
        }
    }
    for i := 0; i <= n; i++ {
        if q[i] != 0 {
            z = 1
        }
    }
    if z == 0 {
        fmt.Println("TRUTH")
    } else {
        fmt.Println("LIE")
    }
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

const MAX_N = 100001 + 1

var (
	Inp  = bufio.NewReader(os.Stdin)
	N, l, r int
	A    [MAX_N]int
	B    [MAX_N]int
	q []int
	w []int
	flag bool
)

func main() {
	fmt.Fscan(Inp, &N, &l, &r)
	for i := 1; i <= N; i++ {
		fmt.Fscan(Inp, &A[i])
	}
	for i := 1; i <= N; i++ {
		fmt.Fscan(Inp, &B[i])
	}

	q = make([]int, r - l + 1)
	w = make([]int, r - l + 1)
	for i := l; i <= r; i++ {
	    q[i-l] = A[i]
	    w[i-l] = B[i]
	}
	sort.Ints(q)
	sort.Ints(w)

	flag = true
	for i := 0; i < r - l + 1; i++ {
	    if q[i] != w[i]{
	        flag = false
	    }
	}
	for i:= 1; i<=N; i++ {
	    if( i < l  || i > r){
	        if A[i] != B[i]{
	            flag = false
	        }
	    }
	}

	if flag {
		fmt.Print("TRUTH\n")
	} else {
		fmt.Print("LIE\n")
	}
}

package main

import "fmt"
import "bufio"
import os "os"

func main() {
	var n, l, r int
	fmt.Scan(&n, &l, &r)
	a := make([]int, n)
	b := make([]int, n)
	l--
	r--
	in := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &b[i])
	}
	for i := 0; i < l; i++ {
        if (a[i] != b[i]) {
            fmt.Println("LIE");
            return;
        }
    }
    for i := r + 1; i < n; i++ {
        if a[i] != b[i] {
            fmt.Println("LIE");
            return;
        }
    }

    var cnta [100001]int
    var cntb [100001]int
    for i := l; i <= r; i++ {
        cnta[a[i]]++;
        cntb[b[i]]++;
    }
    for i := 0; i < 100001; i++ {
        if cnta[i] != cntb[i] {
            fmt.Println("LIE");
            return;
        }
    }
    fmt.Println("TRUTH");
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode"
)

var stdReader *bufio.Reader = bufio.NewReader(os.Stdin)

func readInt() (result int) {
	var negative, started bool
READER_LOOP:
	for {
		char, err := stdReader.ReadByte()
		switch {
		case err != nil:
			break READER_LOOP
		case char == '-':
			negative = true
		case unicode.IsDigit(rune(char)):
			started = true
			result = result*10 + int(char&0xf)
		case started:
			break READER_LOOP
		}
	}
	if negative {
		result = -result
	}
	return
}

func main() {
	var n int
	var l int
	var r int
	n, l, r = readInt(), readInt(), readInt()
	a := make([]int, n)
	b := make([]int, n)
	cnt := make([]int, n + 1)

	var f bool
	f = true

	for i := range a {
		a[i] = readInt()
	}
	for i := range b {
		b[i] = readInt()
	}

	for i := 0; i < l-1; i++{
	    if a[i] != b[i]{
	        f = false
	    }
	}
	for i:=r; i<n; i++{
	    if a[i] != b[i]{
	        f = false
	    }
	}

	for i:=l-1; i<r; i++{
	    cnt[a[i]]++
	    cnt[b[i]]--
	}
	for i:=0; i<n+1; i++{
	    if cnt[i]!=0{
	        f=false;
	    }
	}
	if f {
	    fmt.Println("TRUTH")
	}	else{
	    fmt.Println("LIE")
	}

}

package main

import (
    "io/ioutil"
    "bufio"
    "os"
)

func main() {
    out := bufio.NewWriter(os.Stdout)
    ints := getInts()

    var n, l, r int
    n = ints[0]
    l = ints[1]
    r = ints[2]
    var ptr int
    ptr = 3

	var a[1488100] int
	var b[1488100] int
	var was[1488100] int
	l = l - 1
	r = r - 1
	for i := 0; i < n; i++ {
	    a[i] = ints[ptr]
	    ptr++
	}
	for i := 0; i < n; i++ {
		b[i] = ints[ptr]
	    ptr++
	}
	for i := 0; i<l; i++ {
    	if (a[i] != b[i]) {
	        out.WriteString("LIE")
	        out.Flush()
    	    return
        }
	}

	for i := r+1; i<n; i++ {
    	if (a[i] != b[i]) {
	        out.WriteString("LIE")
	        out.Flush()
    	    return
        }
	}

	for i := l; i<=r; i++ {
	    was[a[i]] = 1
	}

	var cnt int
	cnt = 0
	for i := l; i<=r; i++ {
	    if (was[b[i]] == 1) {
	        cnt++
	    }
	}
	if (cnt == r - l + 1) {
	    out.WriteString("TRUTH")
	}
	if (cnt != r - l + 1) {
	    out.WriteString("LIE")
    }

    out.Flush()
    }

func getInts() []int {
    //assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
    var buf []byte
    buf, _ = ioutil.ReadAll(os.Stdin)
    var ints []int
    num := int(0)
    found := false
    for _, v := range buf {
        if '0' <= v && v <= '9' {
            num = 10*num + int(v - '0') //could use bitshifting here.
            found = true
        } else if found {
            ints = append(ints, num)
            found = false
            num = 0
        }
    }
    if found {
        ints = append(ints, num)
        found = false
        num = 0
    }
    return ints
}

package main

import "fmt"
import "sort"
import "bufio"
import os "os"

func main() {
	var n, l, r int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n, &l, &r)
	var arr1, arr2 [100000]int
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr1[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr2[i])
	}
	var ans bool
	ans = true
	for i := 0; i < l - 1; i++ {
		if arr1[i] != arr2[i] {
			ans = false
			break
		}
	}
	for i := r; i < n; i++ {
		if arr1[i] != arr2[i] {
			ans = false
			break
		}
	}

	x1 := arr1[l - 1:r]
	x2 := arr2[l - 1:r]

	sort.Ints(x1)
	sort.Ints(x2)

	for i := 0; i <= r - l; i++ {
		if x1[i] != x2[i] {
			ans = false
			break
		}
	}

	if ans {
		fmt.Print("TRUTH")
	} else {
		fmt.Print("LIE")
	}
}

// main
package main

import (
	"fmt"
)

func main() {
	var n, l, r int
	fmt.Scan(&n, &l, &r)
	a := new([100005]int)
	b := new([100005]int)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &b[i])
	}
	fg := 0
	for i := 1; i < l; i++ {
		if a[i] != b[i] {
			fg = 1
		}
	}
	for i := r + 1; i <= n; i++ {
		if a[i] != b[i] {
			fg = 1
		}
	}
	if fg == 1 {
		fmt.Println("LIE")
	} else {
		fmt.Println("TRUTH")
	}

}

// main
package main

import (
	"fmt"
)

func main() {
	var n, l, r int
	fmt.Scanf("%d ", &n)
	fmt.Scanf("%d ", &l)
	fmt.Scanf("%d ", &r)
	a := new([100005]int)
	b := new([100005]int)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d ", &a[i])
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d ", &b[i])
	}
	fg := 0
	for i := 1; i < l; i++ {
		if a[i] != b[i] {
			fg = 1
		}
	}
	for i := r + 1; i <= n; i++ {
		if a[i] != b[i] {
			fg = 1
		}
	}
	if fg == 1 {
		fmt.Println("LIE")
	} else {
		fmt.Println("TRUTH")
	}
}

// main
package main

import (
	"fmt"
)

func main() {
	var n, l, r int
	fmt.Scanf("%d %d %d", &n, &l, &r)
	a := new([100005]int)
	b := new([100005]int)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &b[i])
	}
	fg := 0
	for i := 1; i < l; i++ {
		if a[i] != b[i] {
			fg = 1
		}
	}
	for i := r + 1; i <= n; i++ {
		if a[i] != b[i] {
			fg = 1
		}
	}
	if fg == 1 {
		fmt.Println("LIE")
	} else {
		fmt.Println("TRUTH")
	}

}

package main

import (
    "fmt"
    "bufio"
    "os"
)

func main() {
    var n int
    var l int
    var r int
    scanner := bufio.NewScanner(os.Stdin)

    scanner.Scan()
    fmt.Sscanf(scanner.Text(), "%d %d %d", &n, &l, &r)

    l -= 1
    r -= 1

    a := make([]int, 100111)
    b := make([]int, 100111)

    for i := 0; i < n; i++ {
        scanner.Scan()
        fmt.Sscanf(scanner.Text(), "%d", &a[i])
    }
    for i := 0; i < n; i++ {
        scanner.Scan()
        fmt.Sscanf(scanner.Text(), "%d", &b[i])
    }

    a2 := make([]int, 100111)
    b2 := make([]int, 100111)

    var ok bool = true
    for i := 0; i < n; i++ {
        if l <= i && i <= r {
            a2[a[i]] += 1
            b2[b[i]] += 1
        } else {
            if (a[i] != b[i]) {
                ok = false
            }
        }
    }

    for i := 0; i < 100111; i++ {
        if a2[i] != b2[i] {
            ok = false
        }
    }

    if ok {
        fmt.Printf("TRUTH\n");
    } else {
        fmt.Printf("LIE\n");
    }
}

package main

import (
    "fmt"
    "bufio"
    "os"
)

func main() {
    var n int
    var l int
    var r int
    scanner := bufio.NewScanner(os.Stdin)

    scanner.Scan()
    fmt.Sscanf(scanner.Text(), "%d %d %d", &n, &l, &r)

    l -= 1
    r -= 1

    a := make([]int, 100111)
    b := make([]int, 100111)

    scanner.Scan()
    for i := 0; i < n; i++ {
        fmt.Sscanf(scanner.Text(), "%d", &a[i])
    }
    scanner.Scan()
    for i := 0; i < n; i++ {
        fmt.Sscanf(scanner.Text(), "%d", &b[i])
    }

    a2 := make([]int, 100111)
    b2 := make([]int, 100111)

    var ok bool = true
    for i := 0; i < n; i++ {
        if l <= i && i <= r {
            a2[a[i]] += 1
            b2[b[i]] += 1
        } else {
            if (a[i] != b[i]) {
                ok = false
            }
        }
    }

    for i := 0; i < 100111; i++ {
        if a2[i] != b2[i] {
            ok = false
        }
    }

    if ok {
        fmt.Printf("TRUTH\n");
    } else {
        fmt.Printf("LIE\n");
    }
}

package main
import ("fmt"
        "strconv"
        "bufio"
        "os"
        )

func main() {
    sc := NewScanner()
    n := sc.NextInt()
    l := sc.NextInt()
    r := sc.NextInt()
    var q[100001] int
    a := sc.NextIntArray()
    for i := 0; i < n; i++ {
        if i >= l - 1 && i <= r - 1 {
            q[a[i]]++
        }
    }
    b := sc.NextIntArray()
    for i := 0; i < n; i++ {
        if i >= l - 1 && i <= r - 1 {
            q[b[i]]--
        }
    }
    var z = 0
    for i := 0; i <= n; i++ {
        if q[i] != 0 {
            z = 1
        }
    }
    if z == 0 {
        fmt.Println("TRUTH")
    } else {
        fmt.Println("LIE")
    }
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import "fmt"
import "bufio"
import os "os"

func main() {
	var n, l, r int
	fmt.Scan(&n, &l, &r)
	var a [100001]int
	var b [100001]int
	l--
	r--
	in := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}
	for i := 0; i < l; i++ {
        if (a[i] != b[i]) {
            fmt.Println("LIE");
            return;
        }
    }
    for i := r + 1; i < n; i++ {
        if a[i] != b[i] {
            fmt.Println("LIE");
            return;
        }
    }

    var cnta [100001]int
    var cntb [100001]int
    for i := l; i <= r; i++ {
        cnta[a[i]]++;
        cntb[b[i]]++;
    }
    for i := 0; i < 100001; i++ {
        if cnta[i] != cntb[i] {
            fmt.Println("LIE");
            return;
        }
    }
    fmt.Println("TRUTH");
}


There are $$$n$$$ cities and $$$m$$$ roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?New roads will also be one-way.

The first line of input consists of three integers $$$n$$$, $$$m$$$ and $$$s$$$ ($$$1 \le n \le 5000, 0 \le m \le 5000, 1 \le s \le n$$$) — the number of cities, the number of roads and the index of the capital. Cities are indexed from $$$1$$$ to $$$n$$$. The following $$$m$$$ lines contain roads: road $$$i$$$ is given as a pair of cities $$$u_i$$$, $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$). For each pair of cities $$$(u, v)$$$, there can be at most one road from $$$u$$$ to $$$v$$$. Roads in opposite directions between a pair of cities are allowed (i.e. from $$$u$$$ to $$$v$$$ and from $$$v$$$ to $$$u$$$).

Print one integer — the minimum number of extra roads needed to make all the cities reachable from city $$$s$$$. If all the cities are already reachable from $$$s$$$, print 0.

NoteThe first example is illustrated by the following:  For example, you can add roads ($$$6, 4$$$), ($$$7, 9$$$), ($$$1, 7$$$) to make all the cities reachable from $$$s = 1$$$.The second example is illustrated by the following:  In this example, you can add any one of the roads ($$$5, 1$$$), ($$$5, 2$$$), ($$$5, 3$$$), ($$$5, 4$$$) to make all the cities reachable from $$$s = 5$$$.

package main

import (
	"fmt"
	"io/ioutil"
	"bytes"
	"os"
)

var n, m, s int
var edge, edgeRev [][]int
var visited []bool
var stack []int
var group []int

func dfs(x int) {
	if !visited[x] {
		visited[x] = true
		for i := 0;i < len(edge[x]);i ++ {
			dfs(edge[x][i])
		}
		stack = append(stack, x)
	}
}

func dfsRev(x, g int) {
	if visited[x] {
		visited[x] = false
		group[x] = g
		for i := 0;i < len(edgeRev[x]);i ++ {
			dfsRev(edgeRev[x][i], g)
		}
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &s)
	s --
	edge = make([][]int, n)
	edgeRev = make([][]int, n)
	visited = make([]bool, n)
	stack = make([]int, n)
	group = make([]int, n)
	for i := 0;i < n;i ++ {
		edge[i] = []int{}
		edgeRev[i] = []int{}
	}
	for i := 0;i < m;i ++ {
		var u, v int
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		u, v = u - 1, v - 1
		edge[u] = append(edge[u], v)
		edgeRev[v] = append(edgeRev[v], u)
	}
	for i := 0;i < n;i ++ {
		dfs(i)
	}
	var g int
	for len(stack) != 0 {
		x := stack[len(stack) - 1]
		stack = stack[:len(stack) - 1]
		if visited[x] {
			dfsRev(x, g)
			g++
		}
	}
	var ans int
	deg := make([]bool, g)
	for i := 0;i < n;i ++ {
		for j := 0;j < len(edge[i]);j ++ {
			if group[i] != group[edge[i][j]] {
				deg[group[edge[i][j]]] = true
			}
		}
	}
	deg[group[s]] = true
	for i := 0;i < g;i ++ {
		if !deg[i] {
			ans ++
		}
	}

	fmt.Printf("%+v", ans)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF999E(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, st int
	Fscan(in, &n, &m, &st)
	st--
	g := make([][]int, n)
	type edge struct{ v, w int }
	_edges := make([]edge, m)
	for i := range _edges {
		var v, w int
		Fscan(in, &v, &w)
		v--
		w--
		_edges[i] = edge{v, w}
		g[v] = append(g[v], w)
	}

	vis := make([]bool, n)
	var f func(v int)
	f = func(v int) {
		vis[v] = true
		for _, w := range g[v] {
			if !vis[w] {
				f(w)
			}
		}
	}
	f(st)
	edges := []edge{}
	for _, e := range _edges {
		if !vis[e.v] && !vis[e.w] {
			edges = append(edges, e)
		}
	}

	g = make([][]int, n)
	rg := make([][]int, n)
	for _, e := range edges {
		v, w := e.v, e.w
		g[v] = append(g[v], w)
		rg[w] = append(rg[w], v)
	}
	used := make([]bool, n)
	copy(used, vis)
	vs := make([]int, 0, n)
	var dfs func(int)
	dfs = func(v int) {
		used[v] = true
		for _, w := range g[v] {
			if !used[w] {
				dfs(w)
			}
		}
		vs = append(vs, v)
	}
	for v := range g {
		if !used[v] {
			dfs(v)
		}
	}

	used = make([]bool, n)
	copy(used, vis)
	var comp []int
	var rdfs func(int)
	rdfs = func(v int) {
		used[v] = true
		comp = append(comp, v)
		for _, w := range rg[v] {
			if !used[w] {
				rdfs(w)
			}
		}
	}
	comps := [][]int{}
	for i := len(vs) - 1; i >= 0; i-- {
		if v := vs[i]; !used[v] {
			comp = []int{}
			rdfs(v)
			comps = append(comps, comp)
		}
	}

	sccIDs := make([]int, n)
	for i, cp := range comps {
		for _, v := range cp {
			sccIDs[v] = i
		}
	}
	hasIn := make([]bool, len(comps))
	for _, e := range edges {
		if v, w := sccIDs[e.v], sccIDs[e.w]; v != w {
			hasIn[w] = true
		}
	}
	ans := 0
	for _, has := range hasIn {
		if !has {
			ans++
		}
	}
	Fprint(out, ans)
}

func main() {
	CF999E(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	Unmarked = 0
	CapitalColor = 1
)

var n, m, capital int
var graph [][]int
var marked []int
var colorSet map[int]bool

func mark(v, color int) {
	marked[v] = color
	for _, neighbour := range graph[v] {
		if marked[neighbour] != CapitalColor && marked[neighbour] != color {
			// Don't override cities reachable from capital and also avoid cycles
			mark(neighbour, color)
		}
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d %d\n", &n, &m, &capital)
	graph = make([][]int, n + 1)
	marked = make([]int, n + 1)
	colorSet = make(map[int]bool)

	for i := 0; i < m; i++ {
		var v1, v2 int
		fmt.Fscanf(buf, "%d %d\n", &v1, &v2)
		graph[v1] = append(graph[v1], v2)
	}

	mark(capital, CapitalColor)
	color := CapitalColor
	for i := 1; i <= n; i++ {
		if marked[i] == Unmarked {
			color++
			mark(i, color)
		}
	}
	ans := 0
	for i := 1; i <= n; i++ {
		if marked[i] != CapitalColor && !colorSet[marked[i]] {
			ans++
			colorSet[marked[i]] = true
		}
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
	"io/ioutil"
	"bytes"
	"os"
)

var n, m, s int
var edge [][]int
var u []int

func dfs(x int) {
	u[x] = s
	for i := 0;i < len(edge[x]);i ++ {
		if u[edge[x][i]] != s {
			dfs(edge[x][i])
		}
	}
}

func find(x int) int {
	if x == u[x] {
		return x
	} else {
		u[x] = find(u[x])
		return u[x]
	}
}

func join(x, y int) {
	u[find(x)] = find(y)
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &s)
	s --
	edge = make([][]int, n)
	degree := make([]int, n)
	u = make([]int, n)
	ans := 0
	for i := 0;i < n;i ++ {
		edge[i] = []int{}
		u[i] = i
	}
	for i := 0;i < m;i ++ {
		var u, v int
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		u, v = u - 1, v - 1
		edge[u] = append(edge[u], v)
		degree[v] ++
	}
	for i := 0;i < n;i ++ {
		if i != s && degree[i] == 0 {
			ans ++
			edge[s] = append(edge[s], i)
		}
	}
	dfs(s)
	for i := 0;i < n;i ++ {
		for j := 0;j < len(edge[i]);j ++ {
			if u[i] != s && u[edge[i][j]] != s {
				join(i, edge[i][j])
			}
		}
	}
	group := map[int]bool{}
	for i := 0;i < n;i ++ {
		group[find(i)] = true
	}
	fmt.Printf("%+v", ans + len(group) - 1)
}

package main

import (
	"fmt"
	"io/ioutil"
	"bytes"
	"os"
)

var n, m, s int
var edge [][]int
var u []int

func dfs(x int) {
	u[x] = s
	for i := 0;i < len(edge[x]);i ++ {
		if u[edge[x][i]] != s {
			dfs(edge[x][i])
		}
	}
}

func find(x int) int {
	if x == u[x] {
		return x
	} else {
		u[x] = find(u[x])
		return u[x]
	}
}

func join(x, y int) {
	u[find(x)] = find(y)
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &s)
	s --
	edge = make([][]int, n)
	degree := make([]int, n)
	u = make([]int, n)
	ans := 0
	for i := 0;i < n;i ++ {
		edge[i] = []int{}
		u[i] = i
	}
	for i := 0;i < m;i ++ {
		var u, v int
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		u, v = u - 1, v - 1
		edge[u] = append(edge[u], v)
		degree[v] ++
	}
	for i := 0;i < n;i ++ {
		if i != s && degree[i] == 0 {
			ans ++
			edge[s] = append(edge[s], i)
		}
	}
	dfs(s)
	for i := 0;i < n;i ++ {
		for j := 0;j < len(edge[i]);j ++ {
			if u[i] != s && u[edge[i][j]] != s {
				join(i, edge[i][j])
			}
		}
	}
	for i := 0;i < n;i ++ {
		if u[i] == i && i != s {
			ans ++
		}
	}
	fmt.Printf("%+v", ans)
}

package main

import (
	"fmt"
	"io/ioutil"
	"bytes"
	"os"
)

var n, m, s int
var edge [][]int
var visited []bool

func dfs(x int) {
	visited[x] = true
	for i := 0;i < len(edge[x]);i ++ {
		if !visited[edge[x][i]] {
			dfs(edge[x][i])
		}
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &s)
	s --
	edge = make([][]int, n)
	degree := make([]int, n)
	visited = make([]bool, n)
	ans := 0
	for i := 0;i < n;i ++ {
		edge[i] = []int{}
	}
	for i := 0;i < m;i ++ {
		var u, v int
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		u, v = u - 1, v - 1
		edge[u] = append(edge[u], v)
		degree[v] ++
	}
	for i := 0;i < n;i ++ {
		if i != s && degree[i] == 0 {
			ans ++
			edge[s] = append(edge[s], i)
		}
	}
	dfs(s)
	for i := 0;i < n;i ++ {
		if !visited[i] {
			ans ++
			dfs(i)
		}
	}
	fmt.Printf("%+v", ans)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF999E(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, st int
	Fscan(in, &n, &m, &st)
	st--
	g := make([][]int, n)
	type edge struct{ v, w int }
	edges := make([]edge, m)
	for i := range edges {
		var v, w int
		Fscan(in, &v, &w)
		v--
		w--
		edges[i] = edge{v, w}
		g[v] = append(g[v], w)
	}

	vis := make([]bool, n)
	var f func(v int)
	f = func(v int) {
		vis[v] = true
		for _, w := range g[v] {
			if !vis[w] {
				f(w)
			}
		}
	}
	f(st)

	hasIn := make([]bool, n)
	for _, e := range edges {
		v, w := e.v, e.w
		if !vis[v] && !vis[w] {
			hasIn[w] = true
		}
	}
	cntIn := 0
	f = func(v int) {
		vis[v] = true
		if !hasIn[v] {
			cntIn++
		}
		for _, w := range g[v] {
			if !vis[w] {
				f(w)
			}
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		if !vis[i] {
			cntIn = 0
			f(i)
			if cntIn == 0 {
				cntIn = 1
			}
			ans += cntIn
		}
	}
	Fprint(out, ans)
}

func main() {
	CF999E(os.Stdin, os.Stdout)
}


Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.

The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane.  Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.

In the first line print an integer — the number of triangles with the non-zero area among the painted points.

NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.

package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Point struct {
  X, Y int
}

func gcd(a, b int) int {
  if a < 0 {
    a = -a
  }
  if b < 0 {
    b = -b
  }
  for b != 0 {
    a, b = b, a%b
  }
  return a
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  points := make([]*Point, n)
  for i := range points {
    points[i] = &Point{ getI(), getI() }
  }
  total := int64(0)
  for _, center := range points {
    x, y := center.X, center.Y
    subtotal := (n-1)*(n-2)/2
    slopeCount := map[Point]int{}
    for _, point := range points {
      if point != center {
        a, b := point.X, point.Y
        g := gcd(x-a, y-b)
        c, d := (x-a)/g, (y-b)/g
        slope := Point{ c, d }
        subtotal -= slopeCount[slope]
        subtotal -= slopeCount[Point{ -c, -d }]
        slopeCount[slope]++
      }
    }
    total += int64(subtotal)
  }
  writer.WriteString(fmt.Sprintf("%d\n", total/3))
}

package main

import (
	"fmt"
	"bufio"
	"strconv"
	"os"
	"math"
)

var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

type Line struct {
	A, B, C int
}

func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func Gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return Gcd(b, a % b)
}

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)
	var n int = NextInt()
	x, y := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		x[i], y[i] = NextInt(), NextInt()
	}

	mp := make(map[Line]int)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			var a, b int = y[j] - y[i], x[i] - x[j];
			var c int = -a * x[i] - b * y[i];

			var gcd int = Gcd(Abs(a), Abs(b))
			gcd = Gcd(gcd, Abs(c))

			a, b, c = a / gcd, b / gcd, c / gcd

			if a < 0 {
				a, b, c = -a, -b, -c
			}else if a == 0 {
				if b < 0 {
					b, c = -b, -c
				}
			}

			line := Line{A:a, B:b, C:c}
			mp[line]++
		}
	}

	var ret int64 = 0
	for _, m := range mp {

		// fmt.Fprintln(out, line, m)

		x := 1 + math.Sqrt(1 + 8 * float64(m))
		x /= 2

		ret += int64(x * (x - 1) / 2) * int64(n - int(x))
	}

	fmt.Fprintln(out, ret / 3)
}

func Next() string{
	if !in.Scan() {
		panic("Scan error")
	}
	return in.Text()
}

func NextInt() int{
	ret, _ := strconv.Atoi(Next())
	return ret
}

package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func gcd(a int64, b int64) int64 {
	if (b == 0) {
		return a
	}
	return gcd(b, a%b)
}
func starPosition(stars [][]int64) int64 {
	x := [2005]int64{}
	y := [2005]int64{}
	a := map[int64]int64{}
	b := [20005][205]int64{}
	f := map[int64]int64{}

    i := int64(0)
    j := int64(0)

	for i = 1; i <= 20000; i++ {
		for j = 1; j <= 200; j++ {
			b[i][j] = gcd(i,j)
		}
	}
	for i = 1; i <= 20000; i++ {
		b[i][0] = i
	}

	for i = 1; i <= 200; i++ {
		b[0][i] = i
	}

 	for i = 2; i <= 2000; i++ {
		a[i*i-i] = i
	}

	n := int64(len(stars))
 	for i = 0; i < n; i++ {
		x[i] = int64(stars[i][0])
		y[i] = int64(stars[i][1])
	}

	for i = 0; i < n; i++ {
		for j = 0; j < n; j++ {
			if i != j {
				var kc int64 = y[j] - y[i];
				var kz int64 = x[j] - x[i];
				var bc int64 = y[i]*(x[j] - x[i]) - x[i]*(y[j]-y[i]);
				var bz int64 = x[j] - x[i];
				if kz != 0 {
					tmp := b[abs(kc)][abs(kz)];
					kc /= tmp; kz /= tmp;
					if (kc < 0) {
						kc = -kc
						kz = -kz
					}
					if (kc == 0) {
						kz = 1;
					}
					tmp = b[abs(bc)][abs(bz)]
					bc /= tmp
					bz /= tmp
					if (bc < 0) {
						bc = -bc
						bz = -bz
					}
					if (bc == 0) {
						bz = 1
					}
				} else {
					kc = x[i]
					bc = x[i]
				}
				var hsh int64 = bc*27000000000 + bz*9000000 + kc*300 + kz;
				f[hsh]+=2;

			}
		}
	}
	var ans int64 = (n*(n-1)*(n-2))/6
	for _, fv := range f {
		tmp, ok := a[fv/2]
		if ok {
			ans -= (tmp*(tmp-1)*(tmp-2))/6
		}

	}
	return ans
}

func main() {
	// s := [][]int{
	// 	{1,1},
	// }
	// fmt.Println(starPosition(s))
	scanner := bufio.NewScanner(os.Stdin)
    var n int64 = 0
    var s [][]int64
    i := int64(0)
    j := int64(0)
    for scanner.Scan() {
        if i > 0 && i > n {
            break
        }
        if i == 0 {
            strs := strings.Split(scanner.Text(), " ")
            n, _ = strconv.ParseInt(strs[0], 10, 64)
        } else {
            if i == 1 {
                s = make([][]int64, n)
            }
            s[j] = make([]int64, 2)
            strs := strings.Split(scanner.Text(), " ")
            s[j][0], _ = strconv.ParseInt(strs[0], 10, 64)
            s[j][1], _ = strconv.ParseInt(strs[1], 10, 64)
            j++
        }
        i++
	}
	fmt.Println(starPosition(s))
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

type vec struct {
	x, y int
}

func (a vec) sub(b vec) vec   { return vec{a.x - b.x, a.y - b.y} }
func (a vec) cross(b vec) int { return a.x*b.y - a.y*b.x }
func (a vec) reverse() vec    { return vec{-a.x, -a.y} }
func (a vec) up() vec {
	if a.y < 0 || a.y == 0 && a.x < 0 {
		return a.reverse()
	}
	return a
}

// github.com/EndlessCheng/codeforces-go
func Sol552D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	if n < 3 {
		Fprint(out, 0)
		return
	}
	ps := make([]vec, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
	}
	ans := int64(n) * int64(n-1) * int64(n-2) / 6
	for i, pi := range ps {
		ls := make([]vec, 0, n-i-1)
		for j := i + 1; j < n; j++ {
			ls = append(ls, ps[j].sub(pi).up())
		}
		sort.Slice(ls, func(i, j int) bool { return ls[i].cross(ls[j]) > 0 })
		for j := 0; j < len(ls); {
			j0 := j
			for j++; j < len(ls) && ls[j].cross(ls[j0]) == 0; j++ {
			}
			ans -= int64(j-j0) * int64(j-j0-1) / 2
		}
	}
	Fprint(out, ans)
}

func main() {
	Sol552D(os.Stdin, os.Stdout)
}

package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Point struct {
  X, Y int
}

func gcd(a, b int) int {
  if a < 0 {
    a = -a
  }
  if b < 0 {
    b = -b
  }
  for b != 0 {
    a, b = b, a%b
  }
  return a
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  points := make([]*Point, n)
  for i := range points {
    points[i] = &Point{ getI(), getI() }
  }
  total := int64(0)
  for _, center := range points {
    x, y := center.X, center.Y
    subtotal := (n-1)*(n-2)/2
    slopeCount := make([]int, 401*401)
    for _, point := range points {
      if point != center {
        a, b := point.X, point.Y
        g := gcd(x-a, y-b)
        c, d := (x-a)/g, (y-b)/g
        slope := 400*(200+c) + 200+d
        subtotal -= slopeCount[slope]
        subtotal -= slopeCount[400*(200-c) + 200-d]
        slopeCount[slope]++
      }
    }
    total += int64(subtotal)
  }
  writer.WriteString(fmt.Sprintf("%d\n", total/3))
}

package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Point struct {
  X, Y int
}

func gcd(a, b int) int {
  if a < 0 {
    a = -a
  }
  if b < 0 {
    b = -b
  }
  for b != 0 {
    a, b = b, a%b
  }
  return a
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  points := make([]*Point, n)
  for i := range points {
    points[i] = &Point{ getI(), getI() }
  }
  total := 0
  for _, center := range points {
    x, y := center.X, center.Y
    subtotal := (n-1)*(n-2)/2
    slopeCount := map[Point]int{}
    for _, point := range points {
      if point != center {
        a, b := point.X, point.Y
        g := gcd(x-a, y-b)
        c, d := (x-a)/g, (y-b)/g
        slope := Point{ c, d }
        subtotal -= slopeCount[slope]
        subtotal -= slopeCount[Point{ -c, -d }]
        slopeCount[slope]++
      }
    }
    total += subtotal
  }
  writer.WriteString(fmt.Sprintf("%d\n", total/3))
}

package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Point struct {
  X, Y int
}

func gcd(a, b int) int {
  if a < 0 {
    a = -a
  }
  if b < 0 {
    b = -b
  }
  for b != 0 {
    a, b = b, a%b
  }
  return a
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  points := make([]*Point, n)
  for i := range points {
    points[i] = &Point{ getI(), getI() }
  }
  total := int64(0)
  for _, center := range points {
    x, y := center.X, center.Y
    subtotal := (n-1)*(n-2)/2
    slopeCount := make([]int, 401*401)
    for _, point := range points {
      if point != center {
        a, b := point.X, point.Y
        g := gcd(x-a, y-b)
        c, d := (x-a)/g, (y-b)/g
        slope := 200*200 + 200*(200+c) + 200+d
        subtotal -= slopeCount[slope]
        subtotal -= slopeCount[200*200 + 200*(200-c) + 200-d]
        slopeCount[slope]++
      }
    }
    total += int64(subtotal)
  }
  writer.WriteString(fmt.Sprintf("%d\n", total/3))
}

package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Point struct {
  X, Y int
}

func gcd(a, b int) int {
  if a < 0 {
    a = -a
  }
  if b < 0 {
    b = -b
  }
  for b != 0 {
    a, b = b, a%b
  }
  return a
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  points := make([]*Point, n)
  for i := range points {
    points[i] = &Point{ getI(), getI() }
  }
  total := int64(0)
  for _, center := range points {
    x, y := center.X, center.Y
    subtotal := (n-1)*(n-2)/2
    slopeCount := make([]int, 600*600)
    for _, point := range points {
      if point != center {
        a, b := point.X, point.Y
        g := gcd(x-a, y-b)
        c, d := (x-a)/g, (y-b)/g
        slope := 300*300 + 250*c + d
        subtotal -= slopeCount[slope]
        subtotal -= slopeCount[300*300 + 250*-c - d]
        slopeCount[slope]++
      }
    }
    total += int64(subtotal)
  }
  writer.WriteString(fmt.Sprintf("%d\n", total/3))
}

package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func gcd(a int64, b int64) int64 {
	if (b == 0) {
		return a
	}
	return gcd(b, a%b)
}
func starPosition(stars [][]int64) int64 {
	x := [2005]int64{}
	y := [2005]int64{}
	a := map[int64]int64{}
	b := [20005][205]int64{}
	f := map[int64]int64{}

    i := int64(0)
    j := int64(0)

	for i = 1; i <= 20000; i++ {
		for j = 1; j <= 200; j++ {
			b[i][j] = gcd(i,j)
		}
	}
	for i = 1; i <= 20000; i++ {
		b[i][0] = i
	}

	for i = 1; i <= 200; i++ {
		b[0][i] = i
	}

 	for i = 2; i <= 2000; i++ {
		a[i*i-i] = i
	}

	n := int64(len(stars))
 	for i = 0; i < n; i++ {
		x[i] = int64(stars[i][0])
		y[i] = int64(stars[i][1])
	}

	for i = 0; i < n; i++ {
		for j = 0; j < n; j++ {
			if i != j {
					var kc int64 = y[j] - y[i];
					var kz int64 = x[j] - x[i];
					var bc int64 = y[i]*(x[j] - x[i]) - x[i]*(y[j]-y[i]);
					var bz int64 = x[j] - x[i];
					if kz != 0 {
						tmp := b[abs(kc)][abs(kz)];
						kc /= tmp; kz /= tmp;
						if (kc < 0) {
							kc = -kc
							kz = -kz
						}
						if (kc == 0) {
							kz = 1;
						}
						tmp = b[abs(bc)][abs(bz)]
						bc /= tmp
						bz /= tmp
						if (bc < 0) {
							bc = -bc
							bz = -bz
						}
						if (bc == 0) {
							bz = 1
						}
					} else {
						kc = bc
						kc = x[i]
					}
					var hsh int64 = bc*27000000000 + bz*9000000 + kc*300 + kz;
					f[hsh]+=2;

			}
		}
	}
	var ans int64 = (n*(n-1)*(n-2))/6
	for _, fv := range f {
		tmp, ok := a[fv/2]
		if ok {
			ans -= (tmp*(tmp-1)*(tmp-2))/6
		}

	}
	return ans
}

func main() {
	// s := [][]int{
	// 	{1,1},
	// }
	// fmt.Println(starPosition(s))
	scanner := bufio.NewScanner(os.Stdin)
    var n int64 = 0
    var s [][]int64
    i := int64(0)
    j := int64(0)
    for scanner.Scan() {
        if i > 0 && i > n {
            break
        }
        if i == 0 {
            strs := strings.Split(scanner.Text(), " ")
            n, _ = strconv.ParseInt(strs[0], 10, 64)
        } else {
            if i == 1 {
                s = make([][]int64, n)
            }
            s[j] = make([]int64, 2)
            strs := strings.Split(scanner.Text(), " ")
            s[j][0], _ = strconv.ParseInt(strs[0], 10, 64)
            s[j][1], _ = strconv.ParseInt(strs[1], 10, 64)
            j++
        }
        i++
	}
	fmt.Println(starPosition(s))
}

package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func gcd(a int64, b int64) int64 {
	if (b == 0) {
		return a
	}
	return gcd(b, a%b)
}
func starPosition(stars [][]int64) int {
	x := [2005]int64{}
	y := [2005]int64{}
	a := map[int64]int64{}
	b := [20005][205]int64{}
	f := map[int64]int64{}

    i := int64(0)
    j := int64(0)

	for i = 1; i <= 20000; i++ {
		for j = 1; j <= 200; j++ {
			b[i][j] = gcd(i,j)
		}
	}
	for i = 1; i <= 20000; i++ {
		b[i][0] = i
	}

	for i = 1; i <= 200; i++ {
		b[0][i] = i
	}

 	for i = 2; i <= 2000; i++ {
		a[i*i-i] = i
	}

	n := int64(len(stars))
 	for i = 0; i < n; i++ {
		x[i] = int64(stars[i][0])
		y[i] = int64(stars[i][1])
	}

	for i = 0; i < n; i++ {
		for j = 0; j < n; j++ {
			if i != j {
					var kc int64 = y[j] - y[i];
					var kz int64 = x[j] - x[i];
					var bc int64 = y[i]*(x[j] - x[i]) - x[i]*(y[j]-y[i]);
					var bz int64 = x[j] - x[i];
					if kz != 0 {
						tmp := b[abs(kc)][abs(kz)];
						kc /= tmp; kz /= tmp;
						if (kc < 0) {
							kc = -kc
							kz = -kz
						}
						if (kc == 0) {
							kz = 1;
						}
						tmp = b[abs(bc)][abs(bz)]
						bc /= tmp
						bz /= tmp
						if (bc < 0) {
							bc = -bc
							bz = -bz
						}
						if (bc == 0) {
							bz = 1
						}
					} else {
						kc = bc
						kc = x[i]
					}
					var hsh int64 = bc*27000000000 + bz*9000000 + kc*300 + kz;
					f[hsh]+=2;

			}
		}
	}
	var ans int64 = (n*(n-1)*(n-2))/6
	for _, fv := range f {
		tmp, ok := a[fv/2]
		if ok {
			ans -= (tmp*(tmp-1)*(tmp-2))/6
		}

	}
	return int(ans)
}

func main() {
	// s := [][]int{
	// 	{1,1},
	// }
	// fmt.Println(starPosition(s))
	scanner := bufio.NewScanner(os.Stdin)
    var n int64 = 0
    var s [][]int64
    i := int64(0)
    j := int64(0)
    for scanner.Scan() {
        if i > 0 && i > n {
            break
        }
        if i == 0 {
            strs := strings.Split(scanner.Text(), " ")
            n, _ = strconv.ParseInt(strs[0], 10, 64)
        } else {
            if i == 1 {
                s = make([][]int64, n)
            }
            s[j] = make([]int64, 2)
            strs := strings.Split(scanner.Text(), " ")
            s[j][0], _ = strconv.ParseInt(strs[0], 10, 64)
            s[j][1], _ = strconv.ParseInt(strs[1], 10, 64)
            j++
        }
        i++
	}
	fmt.Println(starPosition(s))
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

type vec struct {
	x, y int
}

func (a vec) sub(b vec) vec   { return vec{a.x - b.x, a.y - b.y} }
func (a vec) cross(b vec) int { return a.x*b.y - a.y*b.x }

// github.com/EndlessCheng/codeforces-go
func Sol552D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	if n < 3 {
		Fprint(out, 0)
		return
	}
	ps := make([]vec, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
	}
	ans := int64(n) * int64(n-1) * int64(n-2) / 6
	for i, pi := range ps {
		ls := make([]vec, 0, n-i-1)
		for j := i + 1; j < n; j++ {
			ls = append(ls, ps[j].sub(pi))
		}
		sort.Slice(ls, func(i, j int) bool { return ls[i].cross(ls[j]) > 0 })
		for j := 0; j < len(ls); {
			j0 := j
			for j++; j < len(ls) && ls[j].cross(ls[j0]) == 0; j++ {
			}
			ans -= int64(j-j0) * int64(j-j0-1) / 2
		}
	}
	Fprint(out, ans)
}

func main() {
	Sol552D(os.Stdin, os.Stdout)
}

package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Point struct {
  X, Y int
}

func gcd(a, b int) int {
  if a < 0 {
    a = -a
  }
  if b < 0 {
    b = -b
  }
  for b != 0 {
    a, b = b, a%b
  }
  return a
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  points := make([]*Point, n)
  for i := range points {
    points[i] = &Point{ getI(), getI() }
  }
  total := int64(0)
  for _, center := range points {
    x, y := center.X, center.Y
    subtotal := (n-1)*(n-2)/2
    slopeCount := make([]int, 600*600)
    for _, point := range points {
      if point != center {
        a, b := point.X, point.Y
        g := gcd(x-a, y-b)
        c, d := (x-a)/g, (y-b)/g
        slope := 300*300 + 200*c + d
        subtotal -= slopeCount[slope]
        subtotal -= slopeCount[300*300 + 200*-c - d]
        slopeCount[slope]++
      }
    }
    total += int64(subtotal)
  }
  writer.WriteString(fmt.Sprintf("%d\n", total/3))
}