You are given three multisets of pairs of colored sticks:   $$$R$$$ pairs of red sticks, the first pair has length $$$r_1$$$, the second pair has length $$$r_2$$$, $$$\dots$$$, the $$$R$$$-th pair has length $$$r_R$$$;  $$$G$$$ pairs of green sticks, the first pair has length $$$g_1$$$, the second pair has length $$$g_2$$$, $$$\dots$$$, the $$$G$$$-th pair has length $$$g_G$$$;  $$$B$$$ pairs of blue sticks, the first pair has length $$$b_1$$$, the second pair has length $$$b_2$$$, $$$\dots$$$, the $$$B$$$-th pair has length $$$b_B$$$; You are constructing rectangles from these pairs of sticks with the following process:   take a pair of sticks of one color;  take a pair of sticks of another color different from the first one;  add the area of the resulting rectangle to the total area. Thus, you get such rectangles that their opposite sides are the same color and their adjacent sides are not the same color.Each pair of sticks can be used at most once, some pairs can be left unused. You are not allowed to split a pair into independent sticks.What is the maximum area you can achieve?

The first line contains three integers $$$R$$$, $$$G$$$, $$$B$$$ ($$$1 \le R, G, B \le 200$$$) — the number of pairs of red sticks, the number of pairs of green sticks and the number of pairs of blue sticks. The second line contains $$$R$$$ integers $$$r_1, r_2, \dots, r_R$$$ ($$$1 \le r_i \le 2000$$$) — the lengths of sticks in each pair of red sticks. The third line contains $$$G$$$ integers $$$g_1, g_2, \dots, g_G$$$ ($$$1 \le g_i \le 2000$$$) — the lengths of sticks in each pair of green sticks. The fourth line contains $$$B$$$ integers $$$b_1, b_2, \dots, b_B$$$ ($$$1 \le b_i \le 2000$$$) — the lengths of sticks in each pair of blue sticks.

Print the maximum possible total area of the constructed rectangles.

NoteIn the first example you can construct one of these rectangles: red and green with sides $$$3$$$ and $$$5$$$, red and blue with sides $$$3$$$ and $$$4$$$ and green and blue with sides $$$5$$$ and $$$4$$$. The best area of them is $$$4 \times 5 = 20$$$.In the second example the best rectangles are: red/blue $$$9 \times 8$$$, red/blue $$$5 \times 5$$$, green/blue $$$2 \times 1$$$. So the total area is $$$72 + 25 + 2 = 99$$$.In the third example the best rectangles are: red/green $$$19 \times 8$$$ and red/blue $$$20 \times 11$$$. The total area is $$$152 + 220 = 372$$$. Note that you can't construct more rectangles because you are not allowed to have both pairs taken to be the same color.

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

var err error

func next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextLong() (n int64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

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

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

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

const (
	oo  = 100000000
	mod = 1
)

func mult(a, b int64) int64 {
	return (a * b) % mod
}
func add(a, b int64) int64 {
	return (a + b) % mod
}
func sub(a, b int64) int64 {
	return (a - b + mod) % mod
}

func solve() {
	r, g, b := nextInt(), nextInt(), nextInt()
	x, y, z := make([]int, r), make([]int, g), make([]int, b)
	for i := range x {
		x[i] = nextInt()
	}
	for i := range y {
		y[i] = nextInt()
	}
	for i := range z {
		z[i] = nextInt()
	}
	sort.Ints(x)
	sort.Ints(y)
	sort.Ints(z)
	dp := make([][][]int, r+1)
	for i := range dp {
		dp[i] = make([][]int, g+1)
		for j := range dp[i] {
			dp[i][j] = make([]int, b+1)
		}
	}

	for i := 0; i <= r; i++ {
		for j := 0; j <= g; j++ {
			for k := 0; k <= b; k++ {
				if i > 0 && j > 0 {
					dp[i][j][k] = Max(dp[i][j][k], dp[i-1][j-1][k]+x[i-1]*y[j-1])
				}
				if i > 0 && k > 0 {
					dp[i][j][k] = Max(dp[i][j][k], dp[i-1][j][k-1]+x[i-1]*z[k-1])
				}
				if j > 0 && k > 0 {
					dp[i][j][k] = Max(dp[i][j][k], dp[i][j-1][k-1]+y[j-1]*z[k-1])
				}
			}
		}
	}
	printf("%d\n", dp[r][g][b])
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		file1, err := os.Open("input.txt")
		if err != nil {
			log.Fatal(err)
		}
		file2, err := os.Create("output.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file1, 8192)
		out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()

	// start := time.Now()

	// for t := nextInt(); t > 0; t-- {
	solve()
	// }

	// printf("%v\n", time.Now().Sub(start))
}

// R, G, B = map(int, input().split())
// rs = [int(x) for x in input().split()]
// gs = [int(x) for x in input().split()]
// bs = [int(x) for x in input().split()]
// rs.sort()
// gs.sort()
// bs.sort()
// sticks = [rs, gs, bs]
// import sys
// sys.setrecursionlimit(1000)
// memo = dict()
// def dfs(i,j,k):
//     if (i,j,k) in memo:
//         return memo[(i,j,k)]
//     if sum([i==-1,j==-1,k==-1])>1:
//         return 0
//     a = gs[j]*bs[k] + dfs(i,j-1,k-1) if j>=0 and k>=0 else 0
//     b = rs[i]*bs[k] + dfs(i-1,j,k-1) if i>=0 and k>=0 else 0
//     c = rs[i]*gs[j] + dfs(i-1,j-1,k) if i>=0 and j>=0 else 0
//     r = max(a,b,c)
//     memo[(i,j,k)] = r
//     return r
// ans = dfs(R-1, G-1, B-1)
// print(ans)

package main

import (
	"fmt"
	"sort"
)

type ky struct {
	i, j, k int
}

var memo map[ky]int

func dfs(i int, j int, k int) int {
	if v, ok := memo[ky{i, j, k}]; ok {
		return v
	}
	if (i == -1 && j == -1) || (i == -1 && k == -1) || (j == -1 && k == -1) {
		return 0
	}
	a, b, c := 0, 0, 0
	if j >= 0 && k >= 0 {
		a = gs[j]*bs[k] + dfs(i, j-1, k-1)
	}
	if i >= 0 && k >= 0 {
		b = rs[i]*bs[k] + dfs(i-1, j, k-1)
	}
	if i >= 0 && j >= 0 {
		c = rs[i]*gs[j] + dfs(i-1, j-1, k)
	}
	// r := math.Max(a, b, c)
	best := 0
	if a > best {
		best = a
	}
	if b > best {
		best = b
	}
	if c > best {
		best = c
	}
	memo[ky{i, j, k}] = best
	return best
}

var rs []int
var bs []int
var gs []int

func main() {
	var R, G, B int
	fmt.Scan(&R, &G, &B)
	rs = make([]int, R)
	gs = make([]int, G)
	bs = make([]int, B)
	for i := 0; i < R; i++ {
		fmt.Scan(&rs[i])
	}
	for i := 0; i < G; i++ {
		fmt.Scan(&gs[i])
	}
	for i := 0; i < B; i++ {
		fmt.Scan(&bs[i])
	}
	sort.Ints(rs)
	sort.Ints(bs)
	sort.Ints(gs)
	memo = make(map[ky]int)

	ans := dfs(R-1, G-1, B-1)
	fmt.Printf("%d", ans)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1398D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}
	var r, g, b int
	Fscan(in, &r, &g, &b)
	x := make(sort.IntSlice, r)
	for i := range x {
		Fscan(in, &x[i])
	}
	sort.Sort(sort.Reverse(x))
	y := make(sort.IntSlice, g)
	for i := range y {
		Fscan(in, &y[i])
	}
	sort.Sort(sort.Reverse(y))
	z := make(sort.IntSlice, b)
	for i := range z {
		Fscan(in, &z[i])
	}
	sort.Sort(sort.Reverse(z))
	dp := make([][][]int, r+1)
	for i := range dp {
		dp[i] = make([][]int, g+1)
		for j := range dp[i] {
			dp[i][j] = make([]int, b+1)
			for k := range dp[i][j] {
				dp[i][j][k] = -1
			}
		}
	}
	var f func(i, j, k int) int
	f = func(i, j, k int) (res int) {
		dv := &dp[i][j][k]
		if *dv != -1 {
			return *dv
		}
		defer func() { *dv = res }()
		if i < r && j < g {
			res = max(res, x[i]*y[j]+f(i+1, j+1, k))
		}
		if i < r && k < b {
			res = max(res, x[i]*z[k]+f(i+1, j, k+1))
		}
		if j < g && k < b {
			res = max(res, y[j]*z[k]+f(i, j+1, k+1))
		}
		return
	}
	Fprint(out, f(0, 0, 0))
}

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

package main

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

type triple struct{
	idx1 int
	idx2 int
	idx3 int
}

var n1, n2, n3 int
var err error
var arr1, arr2, arr3 []int
var memo = make(map[triple]int)

func conv(b bool) int {
	if b {return 1}
	return 0
}

func max(num1, num2, num3 int) int {
	ans := num1
	if num2 > ans {ans = num2}
	if num3 > ans {ans = num3}
	return ans
}

func dp(idx1 int, idx2 int, idx3 int) int {
	key := triple{idx1, idx2, idx3}
	if val, ok := memo[key]; ok {
		return val
	}
	last1 := conv(idx1 == n1)
	last2 := conv(idx2 == n2)
	last3 := conv(idx3 == n3)
	if last1 + last2 + last3 > 1 {
		return 0
	}
	var ans int
	if last1 + last2 + last3 == 1 {
		if last1 == 1 {
			ans = arr2[idx2]*arr3[idx3] + dp(idx1, idx2+1, idx3+1)
		} else if last2 == 1 {
			ans = arr1[idx1]*arr3[idx3] + dp(idx1+1, idx2, idx3+1)
		} else {
			ans = arr1[idx1]*arr2[idx2] + dp(idx1+1, idx2+1, idx3)
		}
	} else {
		ans = max(
			arr2[idx2]*arr3[idx3]+dp(idx1, idx2+1, idx3+1),
			arr1[idx1]*arr3[idx3]+dp(idx1+1, idx2, idx3+1),
			arr1[idx1]*arr2[idx2]+dp(idx1+1, idx2+1, idx3),
		)
	}
	memo[key] = ans
	return ans
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n1, err = strconv.Atoi(sc.Text())
	sc.Scan()
	n2, err = strconv.Atoi(sc.Text())
	sc.Scan()
	n3, err = strconv.Atoi(sc.Text())

	arr1 = make([]int, n1)
	arr2 = make([]int, n2)
	arr3 = make([]int, n3)
	for i := 0; i < n1; i++ {
		sc.Scan()
		arr1[i], _ = strconv.Atoi(sc.Text())
	}
	for i := 0; i < n2; i++ {
		sc.Scan()
		arr2[i], _ = strconv.Atoi(sc.Text())
	}
	for i := 0; i < n3; i++ {
		sc.Scan()
		arr3[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Slice(arr1, func(i, j int) bool {
		return arr1[i] > arr1[j]
	})
	sort.Slice(arr2, func(i, j int) bool {
		return arr2[i] > arr2[j]
	})
	sort.Slice(arr3, func(i, j int) bool {
		return arr3[i] > arr3[j]
	})
	fmt.Println(dp(0, 0, 0))
}


Eugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of ti minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i ci times. Eugeny's play list is organized as follows: first song number 1 plays c1 times, then song number 2 plays c2 times, ..., in the end the song number n plays cn times.Eugeny took a piece of paper and wrote out m moments of time when he liked a song. Now for each such moment he wants to know the number of the song that played at that moment. The moment x means that Eugeny wants to know which song was playing during the x-th minute of his listening to the play list.Help Eugeny and calculate the required numbers of songs.

The first line contains two integers n, m (1 ≤ n, m ≤ 105). The next n lines contain pairs of integers. The i-th line contains integers ci, ti (1 ≤ ci, ti ≤ 109) — the description of the play list. It is guaranteed that the play list's total duration doesn't exceed 109 . The next line contains m positive integers v1, v2, ..., vm, that describe the moments Eugeny has written out. It is guaranteed that there isn't such moment of time vi, when the music doesn't play any longer. It is guaranteed that vi < vi + 1 (i < m). The moment of time vi means that Eugeny wants to know which song was playing during the vi-th munite from the start of listening to the playlist.

Print m integers — the i-th number must equal the number of the song that was playing during the vi-th minute after Eugeny started listening to the play list.

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

func main() {
	var n,m,i,p,us,j int64
	us=0
	j=1
	var a,b [100010]int64
	fmt.Scan(&n,&m)
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	for i=1;i<=n; i++{
		input.Scan()
		aa,_:=strconv.ParseInt(input.Text(),0,64)
		a[i]=aa
		input.Scan()
		bb,_:=strconv.ParseInt(input.Text(),0,64)
		b[i]=bb
	}
	for i=1;i<=m; i++{
		input.Scan()
		cc,_:=strconv.ParseInt(input.Text(),0,64)
		p=cc
		for ;us<p && j<=n; {
			us+=a[j]*b[j]
			j++
		}
		fmt.Println(j-1)
	}

}


There are $$$n$$$ bags with candies, initially the $$$i$$$-th bag contains $$$i$$$ candies. You want all the bags to contain an equal amount of candies in the end. To achieve this, you will: Choose $$$m$$$ such that $$$1 \le m \le 1000$$$Perform $$$m$$$ operations. In the $$$j$$$-th operation, you will pick one bag and add $$$j$$$ candies to all bags apart from the chosen one.Your goal is to find a valid sequence of operations after which all the bags will contain an equal amount of candies. It can be proved that for the given constraints such a sequence always exists.You don't have to minimize $$$m$$$.If there are several valid sequences, you can output any.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. The first and only line of each test case contains one integer $$$n$$$ ($$$2 \le n\le 100$$$).

For each testcase, print two lines with your answer.  In the first line print $$$m$$$ ($$$1\le m \le 1000$$$) — the number of operations you want to take.  In the second line print $$$m$$$ positive integers $$$a_1, a_2, \dots, a_m$$$ ($$$1 \le a_i \le n$$$), where $$$a_j$$$ is the number of bag you chose on the $$$j$$$-th operation.

NoteIn the first case, adding $$$1$$$ candy to all bags except of the second one leads to the arrangement with $$$[2, 2]$$$ candies.In the second case, firstly you use first three operations to add $$$1+2+3=6$$$ candies in total to each bag except of the third one, which gives you $$$[7, 8, 3]$$$. Later, you add $$$4$$$ candies to second and third bag, so you have $$$[7, 12, 7]$$$, and $$$5$$$ candies to first and third bag  — and the result is $$$[12, 12, 12]$$$.

package main

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

func main() {

	var t int

	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)

	for t > 0 {
		var n int
		fmt.Fscan(reader, &n)

		fmt.Printf("%d\n", n)
		for i := 1; i <= n; i++ {
			fmt.Printf("%d ", i)
		}
		fmt.Printf("\n")

		t--
	}
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n int64
		fmt.Scanf("%d\n", &n)
		fmt.Println(n)
		for j:= int64(1);j<=n;j++ {
			fmt.Printf("%d ", j)
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import "fmt"

var t,n int

func main()  {
	fmt.Scan(&t)
	for i:=1;i<=t;i++{
		fmt.Scan(&n)
		fmt.Println(n)
		for j:=1;j<=n;j++{
			fmt.Printf("%d ",j)
		}
		fmt.Println()
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1447A(in io.Reader, out io.Writer) {
	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fprintln(out, n)
		for i := 1; i <= n; i++ {
			Fprint(out, i, " ")
		}
		Fprintln(out)
	}
}

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

package main

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

func main() {
	//rd, _ := os.Open("input")
	//in := bufio.NewReader(rd)
	in := bufio.NewReader(os.Stdin)

	var t, n int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		fmt.Println(n)
		for i := 0; i < n; i++ {
			fmt.Printf("%d ", i+1)
		}
		fmt.Println()
	}
}

package main

import "fmt"

func main() {
	T := 0
	fmt.Scanf("%d\n", &T)
	for t := 0; t < T; t++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		fmt.Println(n)
		for i := 0; i < n; i++ {
			fmt.Print(i+1, " ")
		}
		fmt.Println()
	}
}

package main

import "fmt"

func main() {
	var t int
	for fmt.Scan(&t); t > 0; t-- {
	    var n int
	    fmt.Scan(&n)
	    fmt.Println(n)
	    for a := 1; a <= n; a++ {
		    fmt.Printf("%d ",a) }
	    fmt.Println() } }

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

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

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		n := sint64()
		printf("%d\n", n)
		for i := int64(1); i <= n; i++ {
			printf("%d ", i)
		}
		printf("\n")
	}
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n int64
		fmt.Scanf("%d\n", &n)
		fmt.Println(n)
		for j:= n;j>=1;j-- {
			fmt.Printf("%d ", j)
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n int64
		fmt.Scanf("%d\n", &n)
		for j:= n;j>=1;j-- {
			fmt.Printf("%d ", j)
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

func main() {
	//rd, _ := os.Open("input")
	//in := bufio.NewReader(rd)
	in := bufio.NewReader(os.Stdin)

	var t, n int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		for i := 0; i < n; i++ {
			fmt.Printf("%d ", i+1)
		}
		fmt.Println()
	}
}

package main

import "fmt"

func main() {
	T := 0
	fmt.Scanf("%d", &T)
	for t := 0; t < T; t++ {
		n := 0
		fmt.Scanf("%d", &n)
		fmt.Println(n)
		for i := 0; i < n; i++ {
			fmt.Print(i+1, " ")
		}
		fmt.Println()
	}
}


Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them.Recently, she was presented with an array $$$a$$$ of the size of $$$10^9$$$ elements that is filled as follows:   $$$a_1 = -1$$$  $$$a_2 = 2$$$  $$$a_3 = -3$$$  $$$a_4 = 4$$$  $$$a_5 = -5$$$  And so on ... That is, the value of the $$$i$$$-th element of the array $$$a$$$ is calculated using the formula $$$a_i = i \cdot (-1)^i$$$.She immediately came up with $$$q$$$ queries on this array. Each query is described with two numbers: $$$l$$$ and $$$r$$$. The answer to a query is the sum of all the elements of the array at positions from $$$l$$$ to $$$r$$$ inclusive.Margarita really wants to know the answer to each of the requests. She doesn't want to count all this manually, but unfortunately, she couldn't write the program that solves the problem either. She has turned to you — the best programmer.Help her find the answers!

The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^3$$$) — the number of the queries. Each of the next $$$q$$$ lines contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le 10^9$$$) — the descriptions of the queries.

Print $$$q$$$ lines, each containing one number — the answer to the query.

NoteIn the first query, you need to find the sum of the elements of the array from position $$$1$$$ to position $$$3$$$. The sum is equal to $$$a_1 + a_2 + a_3 = -1 + 2 -3 = -2$$$.In the second query, you need to find the sum of the elements of the array from position $$$2$$$ to position $$$5$$$. The sum is equal to $$$a_2 + a_3 + a_4 + a_5 = 2 -3 + 4 - 5 = -2$$$.In the third query, you need to find the sum of the elements of the array from position $$$5$$$ to position $$$5$$$. The sum is equal to $$$a_5 = -5$$$.In the fourth query, you need to find the sum of the elements of the array from position $$$4$$$ to position $$$4$$$. The sum is equal to $$$a_4 = 4$$$.In the fifth query, you need to find the sum of the elements of the array from position $$$2$$$ to position $$$3$$$. The sum is equal to $$$a_2 + a_3 = 2 - 3 = -1$$$.

package main

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

func main(){

	buf := bufio.NewReader(os.Stdin)

	var n int

	fmt.Fscanf(buf, "%d\n", &n)
	for i:=1 ;i <= n;i++{
		var l int64
		var r int64
		fmt.Fscanf(buf, "%d %d\n", &l,&r)
		var ans int64 = 0
		if (l&1)==0{
			ans += l
			l++
		}
		if l<=r && (r&1)==1{
			ans -= r
			r--
		}
		//fmt.Printf("l=%d r=%d\n",l,r)
		if l<=r {
			ans += (r - l+1) / 2
		}
		fmt.Printf("%d\n",ans)
	}

}

package main

import (
	"fmt"
)
var (
	t, n, m int
	ans int
)
func main() {
	fmt.Scanln(&t)
	for t != 0 {
		t--
		fmt.Scanln(&n, &m)
		ans = 0
		if (n % 2 == 1 && m % 2 == 1) {
			ans = -n + (n - m) / 2
		} else if (n % 2 == 1) {
			ans = (m - n + 1) / 2
		} else if (m % 2 == 1) {
			ans = (n - m - 1) / 2
		} else {
			ans = n + (m - n ) / 2
		}
		fmt.Println(ans)
	}
}

package main

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

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	q := readi()
	for i := 0; i < q; i++ {
		l := readi()
		r := readi()
		println(solve(l, r))
	}
}

func even(a int) bool {
	return a%2 == 0
}

func solve(l, r int) int {
	if l == r {
		if even(l) {
			return l
		} else {
			return -l
		}
	}
	if even(l) {
		return l + solve(l+1, r)
	}
	if !even(r) {
		return -r + solve(l, r-1)
	}
	return (r - l + 1) / 2
}

package main

import "fmt"

func main() {
	var t, s, e int
	fmt.Scan(&t)
	for t > 0 {
		fmt.Scan(&s, &e)
		result := 0
		diff := e - s + 1
		if diff % 2 == 1 {
			diff -= 1
		}
		if diff > 0 {
			if s % 2 == 1 {
				result = diff/2
			} else {
				result = -diff/2
			}
		}
		if diff != e - s + 1 {
			if e % 2 == 1 {
				result -= e
			} else {
				result += e
			}
		}
		t -= 1
		fmt.Println(result)
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d\n", &a, &b)
		//fmt.Println("should be", SumB(a, b))
		if a == b {
			ans := a
			if !isEven(a) {
				ans *= -1
			}
			fmt.Printf("%d\n", ans)
			continue
		}
		if isEven(a) && isEven(b) {
			fmt.Printf("%d\n", (a+b)/2)
			continue
		}
		if !isEven(a) && !isEven(b) {
			fmt.Printf("%d\n", ((a+b)/2)*-1)
			continue
		}
		if !isEven(a) && isEven(b) {
			fmt.Printf("%d\n", Roundup(2, b-a))
			continue
		}
		fmt.Printf("%d\n", Roundup(2, b-a)*-1)
	}
	return
}

func isEven(a int) bool {
	if a%2 == 0 {
		return true
	}
	return false
}

func Roundup(a, b int) int {
	sum := b / a
	sum += 1
	return sum
}

func SumB(a, b int) int {
	sum := 0
	for i := a; i <= b; i++ {
		if isEven(i) {
			sum += i
		} else {
			sum -= i
		}
	}
	return sum
}

// https://codeforces.com/problemset/problem/1080/B
package main

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

func formula(pos int64) int64 {
	if pos % 2 == 0 {
		return int64(pos/2)
	}
	return int64(pos-1)/2 - pos
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numInputs, _ := strconv.ParseInt(scanner.Text(), 10, 32)
	for numInputs > 0 {
		scanner.Scan()
		inputs := strings.Split(scanner.Text(), " ")
		start, _ := strconv.ParseInt(inputs[0], 10, 32)
		last, _ := strconv.ParseInt(inputs[1], 10, 32)
		fmt.Println(int64(formula(last)) - int64(formula(start-1)))
		numInputs--
	}
}

// N number in total
// If l is odd, 1 * (N / 2) + last sepecial if there is any
// If l is even, -1 * (N / 2) + last sepecial if there is any
package main

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

func solve(l, r int) {
	n := r - l + 1
	res := n / 2
	if l%2 == 0 {
		res *= -1
	}
	if n%2 == 1 {
		if r%2 == 1 {
			res -= r
		} else {
			res += r
		}
	}
	fmt.Println(res)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	q, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < q; i++ {
		scanner.Scan()
		l, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		r, _ := strconv.Atoi(scanner.Text())
		solve(l, r)
	}
}

// https://codeforces.com/problemset/problem/1080/B
package main

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

func formula(pos int64) float64 {
	ceil, floor := math.Ceil(float64(pos)/2), math.Floor(float64(pos)/2)
	if pos % 2 == 0 {
		return ceil * (ceil + 1) - (floor * floor)
	} else {
		return floor * (floor + 1) - (ceil * ceil)
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numInputs, _ := strconv.ParseInt(scanner.Text(), 10, 32)
	for numInputs > 0 {
		scanner.Scan()
		inputs := strings.Split(scanner.Text(), " ")
		start, _ := strconv.ParseInt(inputs[0], 10, 32)
		end, _ := strconv.ParseInt(inputs[1], 10, 32)
		fmt.Println(int(formula(end)) - int(formula(start-1)))
		numInputs--
	}
}


You are given two binary square matrices $$$a$$$ and $$$b$$$ of size $$$n \times n$$$. A matrix is called binary if each of its elements is equal to $$$0$$$ or $$$1$$$. You can do the following operations on the matrix $$$a$$$ arbitrary number of times (0 or more):   vertical xor. You choose the number $$$j$$$ ($$$1 \le j \le n$$$) and for all $$$i$$$ ($$$1 \le i \le n$$$) do the following: $$$a_{i, j} := a_{i, j} \oplus 1$$$ ($$$\oplus$$$ — is the operation xor (exclusive or)).  horizontal xor. You choose the number $$$i$$$ ($$$1 \le i \le n$$$) and for all $$$j$$$ ($$$1 \le j \le n$$$) do the following: $$$a_{i, j} := a_{i, j} \oplus 1$$$. Note that the elements of the $$$a$$$ matrix change after each operation.For example, if $$$n=3$$$ and the matrix $$$a$$$ is: $$$$$$ \begin{pmatrix} 1 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 1 & 0 \end{pmatrix} $$$$$$ Then the following sequence of operations shows an example of transformations:   vertical xor, $$$j=1$$$. $$$$$$ a= \begin{pmatrix} 0 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix} $$$$$$  horizontal xor, $$$i=2$$$. $$$$$$ a= \begin{pmatrix} 0 & 1 & 0 \\ 0 & 1 & 0 \\ 0 & 1 & 0 \end{pmatrix} $$$$$$  vertical xor, $$$j=2$$$. $$$$$$ a= \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{pmatrix} $$$$$$ Check if there is a sequence of operations such that the matrix $$$a$$$ becomes equal to the matrix $$$b$$$.

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains one integer $$$n$$$ ($$$1 \leq n \leq 1000$$$) — the size of the matrices. The following $$$n$$$ lines contain strings of length $$$n$$$, consisting of the characters '0' and '1' — the description of the matrix $$$a$$$. An empty line follows. The following $$$n$$$ lines contain strings of length $$$n$$$, consisting of the characters '0' and '1' — the description of the matrix $$$b$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$.

For each test case, output on a separate line:    "YES", there is such a sequence of operations that the matrix $$$a$$$ becomes equal to the matrix $$$b$$$;  "NO" otherwise.  You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).

NoteThe first test case is explained in the statements.In the second test case, the following sequence of operations is suitable:   horizontal xor, $$$i=1$$$;  horizontal xor, $$$i=2$$$;  horizontal xor, $$$i=3$$$; It can be proved that there is no sequence of operations in the third test case so that the matrix $$$a$$$ becomes equal to the matrix $$$b$$$.

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := make([][]byte, n)
		for i := 0; i < n; i++ {
			A[i], _ = reader.ReadBytes('\n')
		}
		reader.ReadBytes('\n')

		B := make([][]byte, n)
		for i := 0; i < n; i++ {
			B[i], _ = reader.ReadBytes('\n')
		}

		res := solve(n, A, B)

		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, A [][]byte, B [][]byte) bool {

	for j := 0; j < n; j++ {
		if A[0][j] != B[0][j] {
			// need to flip this column
			for i := 0; i < n; i++ {
				A[i][j] = byte('0' + '1' - A[i][j])
			}
		}
	}

	for i := 0; i < n; i++ {
		// if true, need to flip, else not
		flag := A[i][0] != B[i][0]
		for j := 0; j < n; j++ {
			if flag != (A[i][j] != B[i][j]) {
				return false
			}
		}
	}
	return true
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(Case int) {
		var n int
		var s []byte
		Fscan(in, &n)
		a := make([][]byte, n)
		for i := range a {
			a[i] = make([]byte, n)
			Fscan(in, &a[i])
		}
		for _, r := range a {
			Fscan(in, &s)
			for j, b := range s {
				r[j] ^= b
			}
		}
		for _, r := range a {
			if r[0] == 1 {
				for j := range r {
					r[j] ^= 1
				}
			}
		}
		for j := range a {
			for _, r := range a {
				if r[j] != a[0][j] {
					Fprintln(out, "NO")
					return
				}
			}
		}
		Fprintln(out, "YES")
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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