package main

import "fmt"

func main() {
    var T int
    fmt.Scan(&T)
    for t := 0; t < T; t = t+1 {
        var s string
        fmt.Scanf("\n%s", &s)
        rowCounts := []int{1, 2, 3, 4, 6, 12}
        colCounts := []int{12, 6, 4, 3, 2, 1}
        countValid := 0
        valid := make([]int, 6)
        for i := 0; i<6; i = i+1 {
            for j := 0; j<colCounts[i]; j = j+1 {
                good := 1;
                for k := 0; k<rowCounts[i]; k=k+1 {
                    if s[k*colCounts[i] + j] != 'X' {
                        good = 0
                    }
                }
                if good != 0 {
                    if valid[i] == 0 {
                        countValid = countValid + 1
                    }
                    valid[i] = 1
                }
            }
        }
        fmt.Printf("%d", countValid);
        for i := 0; i<6; i=i+1 {
            if valid[i] > 0 {
                fmt.Printf(" %dx%d", rowCounts[i], colCounts[i]);
            }
        }
        fmt.Printf("\n");
    }
}

package main

import "fmt"

func main(){
	var n int
	var s string
	fmt.Scan(&n)
	for i:=0; i<n; i++ {
		fmt.Scan(&s)
		len := len(s)
		x := make([]int, 12)
		d := 0
		for j:=0; j<len; j++ {
			if string(s[j]) == "X" {
				x[j]=j
				d+=1
			}
		}
		total := 0
		var a, b [12]int
		for k:=1; k<=12; k++ {
			z := 12/k
			if 12%k == 0 {
				c := 0
				var m bool = false
				for l:=0; l<z; l++ {
					c = x[l]
					for n:=0; n<k; n++ {
						if string(s[c]) == "X" {
							m = true
						} else {
							m = false
							break
						}
						c+=z
					}
					if m == true {
						break
					}
				}
				if m == true {
					a[total]=k
					b[total]=z
					total+=1
				}
			}
		}
		fmt.Print(total, " ")
		if total > 0 {
			for f:=0; f<total; f++ {
				fmt.Printf("%dx%d ", a[f], b[f])
			}
		}
		fmt.Println()
	}
}

package main

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

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

//Wrong
func main() {
	// defer func(start time.Time) {
	// 	fmt.Println(time.Since(start))
	// }(time.Now())

	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	t := nextInt()
	ab := []int{1, 2, 3, 4, 6, 12}

	for testCase:=0; testCase<t; testCase++ {
		s := next()
		numberOfWays := 0
		count := 0
		result := ""

		for _, v := range ab {
			for i, length := 0, 12/v; i<length; i++ {
				count = 0

				for j:=i; j<12 && s[j] == 'X'; j+=length {
					count++
				}

				if count==v {
					numberOfWays++
					switch v {
					case 1:
						result += "1x12 "
					case 2:
						result += "2x6 "
					case 3:
						result += "3x4 "
					case 4:
						result += "4x3 "
					case 6:
						result += "6x2 "
					case 12:
						result += "12x1"
					}
					// fmt.Println(result, v)
					break
				}
			}
		}

		fmt.Fprintln(writer, numberOfWays, result)
	}
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

package main
import (
	"fmt"
	//"sort"
)
func main() {
	var t int
	var s string
	fmt.Scan(&t)
	n:=0
	r:=make([]int,12)

	for i:=0;i<t;i++ {
		n=0
		fmt.Scan(&s)
		for j:=1;j<=12;j++ {
			if 12%j!=0 {
				continue
			}
			ok:=0
			for k:=0;k<j;k++ {
				kk:=1
				for m:=k;m<12;m+=j {
					if s[m] != 'X' {
						kk=0
					}
				}
				if kk!=0 {
					ok=1
					break
				}
			}
			if ok!=0 {
				r[n]=j
				n++
			}
		}
		fmt.Print(n)
		for a:=n-1;a>=0;a-- {
		//fmt.Println(a)
		fmt.Print(" ",12/r[a],"x",r[a])
		}
		fmt.Println()
	}

}

package main

import (
	"fmt"
	"math"
	"strings"
)

func main() {
	all := [...]string{"X", "XX", "XXX", "XXXX", "XXXXXX", "XXXXXXXXXXXX"}
	var s string
	var n int
	var arr [100]int
	var p int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		p = 0
		fmt.Scanf("%s\n", &s)
		// if s == all[5] {
		// 	arr[0] = 1
		// 	arr[1] = 2
		// 	arr[2] = 3
		// 	arr[3] = 4
		// 	arr[4] = 6
		// 	arr[5] = 12
		// 	p = 6
		// }
		// if s == "OOOOOOOOOOOO" {
		// 	break
		// }
		for ii := 0; ii < 6; ii++ {
			l := int(12 / len(all[ii]))
			tag := true
			//fmt.Printf("-----%d %s-----\n", l, all[ii])
			for j := 0; j < l; j++ {
				tag = true
				for jj := j; jj < 12; jj += l {
					//fmt.Printf("%d=%c ", jj, s[jj])
					if s[jj] != 'X' {
						tag = false
						break
					}
				}
				//fmt.Println(" ", tag)
				if tag {
					//fmt.Println("fuck")
					break
				}
			}
			if tag {
				arr[p] = len(all[ii])
				p++
			}
		}
		fmt.Print(p)
		for i := 0; i < p; i++ {
			fmt.Printf(" %dx%d", arr[i], int(12/arr[i]))
		}
		fmt.Println("")
	}

}

func donothing() {
	i := math.Pi
	i++
	s := "abc"
	strings.ToLower(s)
}

package main

import "fmt"

func main() {
    var t int
    var s string
    a := [...]int{1,2,3,4,6,12}
    fmt.Scan(&t)
    for i := 0; i < t; i++ {
        fmt.Scan(&s)
        cnt := 0
        ans := make([]bool,6)
        for j := 0; (j < 6) && (!ans[j]); j++ {
            r, c := a[j], 12/a[j]
            for ic := 0; ic < c; ic++ {
                ok := true
                for ir := 0; ir < r; ir++ {
                    if s[ic+(ir*c)] == 'O' {
                        ok = false
                        break
                    }
                }
                if ok {
                    ans[j] = true
                    cnt++
                    break
                }
            }
        }
        fmt.Print(cnt)
        for j := 0; j < 6; j++ {
            if ans[j] {
                fmt.Printf(" %dx%d",a[j],12/a[j])
            }
        }
        fmt.Println()
    }
}

/*********************************************************************************
*     File Name           :     A.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-05 23:28]
*     Last Modified       :     [2014-03-05 23:51]
*     Description         :
**********************************************************************************/

package main

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

func test(cards string, a, b int) (ret bool) {
    var arr [12][12]byte
    for i := 0; i < a; i++ {
        for j := 0; j < b; j++ {
            arr[i][j] = cards[i*b+j]
        }
    }
    for i := 0; i < b; i++ {
        ret = true
        for j := 0; j < a; j++ {
            if arr[j][i] == 'O' {
                ret = false
                break
            }
        }
        if ret {
            return
        }
    }
    return false
}

func main() {
    scanner.Split(bufio.ScanWords)

    var t = scanner.nextInt()
    var height = [...]int{1, 2, 3, 4, 6, 12}
    for i := 0; i < t; i++ {
        cards := scanner.next()
        var ans = 0
        var res = make([]string, 0)
        for _, a := range height {
            if test(cards, a, 12/a) {
                ans++
                res = append(res, fmt.Sprintf("%dx%d", a, 12/a))
            }
        }
        fmt.Print(ans)
        for i := 0; i < ans; i++ {
            fmt.Printf(" %s", res[i])
        }
        fmt.Println()
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) nextInt() int {
    x, err := strconv.Atoi(self.next())
    if err != nil {
        panic(err)
    }
    return x
}

package main

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

func main() {
    scanner.Split(bufio.ScanWords)
    for cas := scanner.NextInt(); cas > 0; cas-- {
        s := scanner.Next()
        ans := make([]int, 12)
        cnt := 0
        for i := 1; i <= 12; i++ {
            if 12%i == 0 {
                mk := make([]int, 13)
                for j := 0; j < 12; j++ {
                    mk[j] = 1
                }
                for j := 0; j < 12; j++ {
                    if s[j] == 'O' {
                        mk[j%i] = 0
                    }
                }
                for j := 0; j < i; j++ {
                    if mk[j] == 1 {
                        ans[cnt] = i
                        cnt++
                        break
                    }
                }
            }
        }
        fmt.Printf("%d", cnt)
        for i := cnt - 1; i >= 0; i-- {
            fmt.Printf(" %dx%d", 12/ans[i], ans[i])
        }
        fmt.Println()
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInt64() int64 {
    x, err := strconv.ParseInt(self.Next(), 10, 64)
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextDouble() float64 {
    x, err := strconv.ParseFloat(self.Next(), 64)
    if err != nil {
        panic(err)
    }
    return x
}

package main

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

func main() {
    scanner.Split(bufio.ScanWords)
    for cas := scanner.NextInt(); cas > 0; cas-- {
        s := scanner.Next()
        ans := make([]int, 12)
        cnt := 0
        for i := 1; i <= 12; i++ {
            if 12%i == 0 {
                mk := make([]int, 13)
                for j := 0; j < 12; j++ {
                    mk[j] = 1
                }
                for j := 0; j < 12; j++ {
                    if s[j] == 'O' {
                        mk[j%i] = 0
                    }
                }
                for j := 0; j < i; j++ {
                    if mk[j] == 1 {
                        ans[cnt] = i
                        cnt++
                        break
                    }
                }
            }
        }
        fmt.Printf("%d", cnt)
        for i := 0; i < cnt; i++ {
            fmt.Printf(" %dx%d", 12/ans[i], ans[i])
        }
        fmt.Println()
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInt64() int64 {
    x, err := strconv.ParseInt(self.Next(), 10, 64)
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextDouble() float64 {
    x, err := strconv.ParseFloat(self.Next(), 64)
    if err != nil {
        panic(err)
    }
    return x
}

package main

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

func main() {
	scanner.Split(bufio.ScanWords)
	for cas := scanner.NextInt(); cas > 0; cas-- {
		s := scanner.Next()
		ans := make([]int, 12)
		cnt := 0
		for i := 1; i <= 12; i++ {
			if 12%i == 0 {
				mk := make([]int, 13)
				for j := 0; j < 12; j++ {
					mk[j] = 1
				}
				for j := 0; j < 12; j++ {
					if s[j] == 'O' {
						mk[j/i] = 0
					}
				}
				for j := 0; j < 12/i; j++ {
					if mk[j] == 1 {
						ans[cnt] = i
						cnt++
						break
					}
				}
			}
		}
		fmt.Printf("%d", cnt)
		for i := 0; i < cnt; i++ {
			fmt.Printf(" %dx%d", ans[i], 12/ans[i])
		}
		fmt.Println()
	}
}

type Scanner struct {
	*bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
	if !self.Scan() {
		panic(self.Err())
	}
	return self.Text()
}

func (self *Scanner) NextInt() int {
	x, err := strconv.Atoi(self.Next())
	if err != nil {
		panic(err)
	}
	return x
}

func (self *Scanner) NextInt64() int64 {
	x, err := strconv.ParseInt(self.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return x
}

func (self *Scanner) NextDouble() float64 {
	x, err := strconv.ParseFloat(self.Next(), 64)
	if err != nil {
		panic(err)
	}
	return x
}


package main
// https://codeforces.com/contest/1380/submission/87050098
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type FastIn struct {
	scanner *bufio.Scanner
}

func MakeFastIn() (obj FastIn)  {
	obj = FastIn{}
	obj.scanner = bufio.NewScanner(os.Stdin)
	obj.scanner.Split(bufio.ScanWords)
	return
}

func (fi *FastIn) ReadText() string {
	fi.scanner.Scan()
	return fi.scanner.Text()
}

func (fi *FastIn) ReadInt() int {
	ret, err := strconv.Atoi(fi.ReadText())
	if err != nil {
		panic(err)
	}
	return ret
}

func (fi *FastIn) ReadInts(arr []int) {
	for i := 0; i < len(arr); i++ {
		arr[i] = fi.ReadInt()
	}
}
func Min (a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func (fi *FastIn) ReadInt64() int64 {
	ret, err := strconv.ParseInt(fi.ReadText(), 10, 64)
	if err != nil {
		panic(err)
	}
	return ret
}

var x,k,y int64

func GetCost(arr []int, left_b int, right_b int) (int64, bool) {
	any_gt := false
	max_bound := left_b
	if max_bound < right_b {
		max_bound = right_b
	}
	for _,v := range arr {
		if  v > max_bound {
			any_gt = true
		}
	}

	len := int64(len(arr))
	if any_gt {
		if len < k {
			return 0, false
		}
		return Min((len/k)*x+(len%k)*y,x+(len-k)*y), true
	} else {
		return Min((len/k)*x+(len%k)*y, len * y), true
	}
}

func chk(a []int) (bool){
	i,j:=0,len(a)-1
	pvr:=0
	for i<=j {
		if a[i] < a[j] {
			if pvr>a[i] {
				return false
			}
			pvr=a[i]
			i++
		} else {
			if pvr>a[j] {
				return false
			}
			pvr=a[j]
			j--
		}
	}
	return true
}

func main() {
	fin := MakeFastIn()
	T := fin.ReadInt()
	for ;T>0;T--{
		n := fin.ReadInt()
		a:= make([]int, n)
		fin.ReadInts(a)

		l,r:=-1,n
		for r-l>1 {
			m:= (l+r)/2
			if chk(a[m:]) {
				r=m
			} else {
				l=m
			}
		}
		fmt.Println(r)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		var a int
		var aPrev int
		var isPrevGrow bool
		var isPrevEqual bool
		equalStart := 0
		grow := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if j == 0 {
				aPrev = a
				isPrevGrow = true
				continue
			}
			if a >= aPrev && !isPrevGrow {
				if a == aPrev && !isPrevEqual {
					isPrevEqual = true
					equalStart = j - 1
				} else if a > aPrev {
					if isPrevEqual {
						grow = equalStart
					} else {
						grow = j - 1
					}
					isPrevGrow = true
					isPrevEqual = false
				}
			} else if a < aPrev {
				isPrevGrow = false
				isPrevEqual = false
			}

			aPrev = a
		}
		fmt.Println(grow)
	}
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		readLine(reader)
		line := readLine(reader)
		strs := strings.Split(string(line), " ")
		i := len(strs) - 1
		current, _ := strconv.ParseInt(strs[i], 10, 64)
		turn := 0
		for ; i >= 0; i-- {
			temp, _ := strconv.ParseInt(strs[i], 10, 64)
			if turn == 0 { // 递增
				if temp < current {
					turn = 1
				}
			} else if turn == 1 {
				if temp > current {
					turn = 2
					break
				}
			}
			current = temp
		}
		if turn <= 1 {
			fmt.Println(0)
		}else {
			fmt.Println(i+1)
		}
	}
}

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"
	"io"
	"os"
	"sort"
)

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

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		Fprintln(out, sort.Search(n-2, func(i int) bool {
			for j, v := n-1, 0; i < j; {
				if a[i] < a[j] {
					if a[i] < v {
						return false
					}
					v = a[i]
					i++
				} else {
					if a[j] < v {
						return false
					}
					v = a[j]
					j--
				}
			}
			return true
		}))
	}
}

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

package main

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

func solve() {
	n := readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
	}

	back := 0
	for i := n - 1; i > 0; i-- {
		if a[i-1] < a[i] {
			back = i
			break
		}
	}

	front := -1
	for front < back && len(a[front+1:]) > 0 {
		a = a[front+1:]
		back -= front + 1
		front = 0
		for i := 1; i < len(a); i++ {
			if a[i-1] > a[i] {
				break
			}
			front = i
		}
		// fmt.Println(front, back)
	}

	// fmt.Println("done:", front, back)
	// fmt.Println("ans:", n-len(a))
	fmt.Println(n - len(a))
}

func main() {
	k := readInt()
	for i := 0; i < k; i++ {
		solve()
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

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

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}

package main

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

func main() {
	defer writer.Flush()
	t := NextInt()
	for t > 0 {
		t--

		n := NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = NextInt()
		}

		isAsc := true
		isDesc := true
		for i := 1; i < n; i++ {
			if a[i] < a[i-1] {
				isAsc = false
			}
			if a[i] > a[i-1] {
				isDesc = false
			}
		}
		if isDesc || isAsc {
			Println(0)
			continue
		}

		pos := n-1
		for a[pos] <= a[pos-1] {
			pos--
		}
		for pos > 0 && a[pos] >= a[pos-1] {
			pos--
		}
		if pos < 0 {
			pos = 0
		}
		Println(pos)
	}
}

var writer = bufio.NewWriter(os.Stdout)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func Println(data interface{}) {
	writer.WriteString(fmt.Sprintf("%v\n", data))
}

func Print(data interface{}) {
	writer.WriteString(fmt.Sprintf("%v", data))
}

func Next() string {
	sc.Scan()
	return sc.Text()
}

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func NextInt64() int64 {
	i64, err := strconv.ParseInt(Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i64
}

func NextFloat64() float64 {
	f, err := strconv.ParseFloat(Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

package main

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

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

func main() {
	defer out.Flush()
	var nTest int
	fmt.Fscanf(in, "%d\n", &nTest)
	for i := 0; i < nTest; i++ {
		solveCase()
	}
}
func solveCase() {
	var n int
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanln(in)
	down := false
	ans := n - 1
	for i := n - 2; i >= 0; i-- {
		if a[i] < a[i+1] {
			down = true
		}
		if down && a[i] > a[i+1] {
			break
		}
		ans = i
	}
	fmt.Fprintf(out, "%d\n", ans)
}

package main

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

var input *bufio.Reader
func main()  {
	var t int
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input,&t)
	for j:=0 ; j<t ;j++{
		var n int
		fmt.Fscan(input,&n)
		v:=make([]int,n)
		for i:=0;i<n;i++ {
			fmt.Fscan(input, &v[i])
		}
		i:=n-1
		for i>0 && v[i]<=v[i-1]{i--}
		for i>0 && v[i]>=v[i-1] {i--}
		fmt.Println(i)
	}

}

package main

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

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.nextInt(); t > 0; t-- {
		n := io.nextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = io.nextInt()
		}

		lo, hi := 0, n
		for lo < hi {
			mid := (lo + hi) / 2
			l, r := mid, n-1
			ok := true
			last := 0
			for l < r {
				var min int
				if a[l] < a[r] {
					min = a[l]
					l++
				} else {
					min = a[r]
					r--
				}
				if min < last {
					ok = false
				}
				last = min
			}
			if ok {
				hi = mid
			} else {
				lo = mid + 1
			}
		}

		io.println(lo)
	}
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p []byte
}

func newFastIO(r io.Reader, w io.Writer) fastIO {
	return fastIO{bufio.NewReader(r), bufio.NewWriter(w), make([]byte, 1)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p)
	for !('0' <= f.p[0] && f.p[0] <= '9') {
		f.Read(f.p)
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p)
	}
	return n
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

// https://codeforces.com/contest/x/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input *bufio.Reader

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int
	fmt.Fscan(input, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
	}

	pos := len(a) - 1
	for pos >= 1 && a[pos] <= a[pos - 1] {pos--}
	for pos >= 1 && a[pos] >= a[pos - 1] {pos--}
	fmt.Println(pos)
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, 1024*1024)
	scanner.Split(bufio.ScanWords)

	input := func() int {
		scanner.Scan()
		i, _ := strconv.Atoi(scanner.Text())
		return i
	}

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

		return b
	}

	for t := input(); t > 0; t-- {
		n := input()
		arr := make([]int, n)

		for i := range arr {
			arr[i] = input()
		}

		size := 0
		prev := -1
		i := 0
		beg := 0
		j := n - 1

		arrsize := n
		var where bool

		for size < arrsize {
			// fmt.Println(i, j, prev, size, arrsize)
			k := min(arr[i], arr[j])
			if k >= prev {
				if k == arr[i] {
					i++
					where = false
				} else {
					j--
					where = true
				}
				size++
				prev = k
			} else {
				if where {
					i++
				}

				beg = i
				j = n - 1
				size = 0
				arrsize = n - (i + 1)
				prev = -1
			}
		}

		fmt.Println(beg)
	}
}

package main

import "fmt"

func main()  {
	var t int
	fmt.Scanf("%d\n",&t)
	for j:=0 ; j<t ;j++{
		var n int
		fmt.Scanf("%d\n",&n)
		v:=make([]int,n)
		for i:=0;i<n;i++ {fmt.Scanf("%d",&v[i])}
		i:=n-1
		for i>0 && v[i]<=v[i-1]{i--}
		for i>0 && v[i]>=v[i-1] {i--}
		fmt.Printf("%d\n",i)
	}

}

// https://codeforces.com/contest/x/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input *bufio.Reader

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int
	fmt.Fscan(input, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
	}

	pos := len(a) - 1
	for pos >= 1 && a[pos] <= a[pos - 1] {pos--}
	for pos >= 1 && a[pos] > a[pos - 1] {pos--}
	fmt.Println(pos)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		var a int
		var aPrev int
		var isPrevGrow bool
		grow := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if j == 0 {
				aPrev = a
				isPrevGrow = true
				continue
			}
			if a > aPrev && !isPrevGrow {
				grow = j - 1
				isPrevGrow = true
			} else if a < aPrev {
				isPrevGrow = false
			}

			aPrev = a
		}
		fmt.Println(grow)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		var a int
		var aPrev int
		var isPrevGrow bool
		grow := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if j == 0 {
				aPrev = a
				isPrevGrow = true
				continue
			}

			if a >= aPrev && !isPrevGrow {
				grow = j - 1
				isPrevGrow = true
			} else if a < aPrev {
				isPrevGrow = false
			}

			aPrev = a
		}
		fmt.Println(grow)
	}
}

package main

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

func solve() {
	n := readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
	}

	ans := 0
	for i := n - 3; i >= 0; i-- {
		if a[i] > a[i+1] && a[i+1] < a[i+2] {
			ans = i + 1
			break
		}
	}
	fmt.Println(ans)
}

func main() {
	k := readInt()
	for i := 0; i < k; i++ {
		solve()
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

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

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}

package main

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

func main() {
	defer writer.Flush()
	t := NextInt()
	for t > 0 {
		t--

		n := NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = NextInt()
		}

		isAsc := true
		isDesc := true
		for i := 1; i < n; i++ {
			if a[i] < a[i-1] {
				isAsc = false
			}
			if a[i] > a[i-1] {
				isDesc = false
			}
		}
		if isDesc || isAsc {
			Println(0)
			continue
		}

		pos := n-1
		for a[pos] < a[pos-1] {
			pos--
		}
		for pos > 0 && a[pos] >= a[pos-1] {
			pos--
		}
		if pos < 0 {
			pos = 0
		}
		Println(pos)
	}
}

var writer = bufio.NewWriter(os.Stdout)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func Println(data interface{}) {
	writer.WriteString(fmt.Sprintf("%v\n", data))
}

func Print(data interface{}) {
	writer.WriteString(fmt.Sprintf("%v", data))
}

func Next() string {
	sc.Scan()
	return sc.Text()
}

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func NextInt64() int64 {
	i64, err := strconv.ParseInt(Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i64
}

func NextFloat64() float64 {
	f, err := strconv.ParseFloat(Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}


package main

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

func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)

    var t int
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        var n int
        fmt.Fscan(in, &n)
        a := make([]int, n)
        for i := range a {
            fmt.Fscan(in, &a[i])
        }
        sort.Ints(a)
        // m +1 -2 +3 -4 +5 -6 ...
        m, sgn := (n - 1) / 2, -1
        for i := 0; i < n; i++ {
            m += sgn*i
            fmt.Fprint(out, a[m], " ")
            sgn = -sgn
        }
        fmt.Fprintln(out)
    }
    out.Flush()
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		n := 0
		fmt.Fscan(in, &n)
		as := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &as[i])
		}
		sort.Ints(as)
		i := (n - 1) / 2
		next := 0
		// to swap next direction ( + = goto right, - = goto left ) at each inc step
		sign := -1
		for next < n-1 {
			i = i + (sign * next)
			fmt.Fprintf(out, "%d ", as[i])
			next++
			sign *= -1
		}
		i = i + (sign * next)
		fmt.Fprintln(out, as[i])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		n := 0
		fmt.Fscan(in, &n)
		as := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &as[i])
		}
		sort.Ints(as)
		i := (n - 1) / 2
		next := 0
		// to swap next direction ( + = goto right, - = goto left ) at each inc step
		sign := -1
		for next < n-1 {
			i = i + (sign * next)
			fmt.Fprintf(out, "%d ", as[i])
			next++
			sign *= -1
		}
		i = i + (sign * next)
		fmt.Fprintln(out, as[i])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		n := 0
		fmt.Fscan(in, &n)
		as := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &as[i])
		}
		sort.Ints(as)
		i := (n - 1) / 2
		next := 0
		// to swap next direction ( + = goto right, - = goto left ) at each inc step
		sign := -1
		//fmt.Fprintln(out, t, n, as, next, sign)
		for next < n-1 {
			i = i + (sign * next)
			fmt.Fprintf(out, "%d ", as[i])
			next++
			sign *= -1
		}
		i = i + (sign * next)
		fmt.Fprintln(out, as[i])
	}
}

package main

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.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 (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		aa := []int64{}
		for ; n > 0; n-- {
			aa = append(aa, reader.NextInt64())
		}
        res := sol(aa)
        for i := len(res)-1; i > -1; i-- {
            writer.Printf("%d ", res[i])
        }
		writer.Printf("\n")
	}
}

func sol(aa []int64) []int64 {
	sort.Slice(aa, func(i, j int) bool {
        return aa[i] < aa[j]
    })
    l := 0
    r := len(aa) - 1
    left := true
    res := []int64{}
    for l <= r {
        if left {
            res = append(res, aa[l])
            l++
        } else {
            res = append(res, aa[r])
            r--
        }
        left = !left
    }
	return res
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		exec()
	}
}

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	sort.Ints(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n/2])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		printf("%d ", arrA[n-i])
	}
	printf("\n")
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.ParseInt(string(line), 10, 64)
		line = readLine(reader)
		arrs := strings.Split(string(line), " ")
		arr := make([]int64, n)
		for i := int64(0); i < n; i++ {
			arr[i], _ = strconv.ParseInt(arrs[i], 10, 64)
		}
		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})
		i := int64(0)
		if n%2 == 0 {
			i = n/2 - 1
		} else {
			i = n / 2
		}
		dap := int64(1)
		flag := false
		result := make([]int64, 0)
		// fmt.Println(arr)
		for i >= 0 && i < n {
			// fmt.Println(i)
			result = append(result, arr[i])
			if !flag {
				i = i + dap
				flag = true
			} else {
				i = i- dap
				flag = false
			}
			dap++
		}
		// result = append(result, arr[0])
		printArr(result)
		fmt.Println()
	}
}

func printArr(arr []int64) {
	for _, v := range arr {
		fmt.Printf("%d ", v)
	}
}

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
}

/*
URL:
https://codeforces.com/problemset/problem/1339/B
*/

package main

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

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	sort.Sort(sort.IntSlice(A))

	mid := n / 2
	answers := []int{A[mid]}
	for l, r := mid-1, mid+1; l >= 0 && r < n; l, r = l-1, r+1 {
		answers = append(answers, A[l], A[r])
	}
	if len(answers) < n {
		answers = append(answers, A[0])
	}

	fmt.Println(PrintIntsLine(answers...))
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

func main() {
	Solve()
}

func Solve() {
	inBuf := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(inBuf,"%d\n", &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscanf(inBuf, "%d\n", &n)

		format := "%d"
		var valuesInCase []int
		for j := 0; j < n; j++ {
			var num int
			fmt.Fscanf(inBuf, format, &num)
			valuesInCase = append(valuesInCase, num)
			format = " %d"
		}
		fmt.Fscanf(inBuf, "\n", nil)

		arr := FindAscendingDifferencesArray(valuesInCase)
		format1 := "%v"
		for _, v := range arr {
			fmt.Printf(format1, v)
			format1 = " %v"
		}
		fmt.Println()
	}
}

func FindAscendingDifferencesArray(input []int) []int {
	sort.Ints(input)
	index := len(input)/2
	if len(input) % 2 == 0 {
		index -= 1
	}

	res := make([]int, len(input))

	for i := 0; i < len(input); i++ {
		res[i] = input[index]
		shift := i+1
		if i % 2 != 0 {
			shift *= -1
		}
		index += shift
	}

	return res
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int
	fmt.Fscanf(reader, "%d\n", &T)
	for T > 0 {
		T -= 1
		var n int
		fmt.Fscanf(reader, "%d\n", &n)
		a := make([]int, n, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(reader, "%d", &a[i])
		}
		fmt.Fscanf(reader, "\n")
		sort.Ints(a)
		k := n >> 1
		fmt.Fprintf(writer, "%d", a[k])
		for i := k - 1; i >= 0; i-- {
			fmt.Fprintf(writer, " %d", a[i])
			if 2*k-i < n {
				fmt.Fprintf(writer, " %d", a[2*k-i])
			}
		}
		fmt.Fprintf(writer, "\n")
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		exec()
	}
}

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	quicksort(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n/2+1])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		if i != 0 {
			printf("%d ", arrA[n-i])
			continue
		}
		printf("%d", arrA[n-i])
	}
	printf("\n")
}

func quicksort(a []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	pivot := rand.Int() % len(a)

	a[pivot], a[right] = a[right], a[pivot]

	for i, _ := range a {
		if a[i] < a[right] {
			a[left], a[i] = a[i], a[left]
			left++
		}
	}

	a[left], a[right] = a[right], a[left]

	quicksort(a[:left])
	quicksort(a[left+1:])

	return a
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		exec()
	}
}

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	quicksort(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n%2+1])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		if i != 0 {
			printf("%d ", arrA[n-i])
			continue
		}
		printf("%d", arrA[n-i])
	}
	printf("\n")
}

func quicksort(a []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	pivot := rand.Int() % len(a)

	a[pivot], a[right] = a[right], a[pivot]

	for i, _ := range a {
		if math.Abs(float64(a[i])) < math.Abs(float64(a[right])) {
			a[left], a[i] = a[i], a[left]
			left++
		}
	}

	a[left], a[right] = a[right], a[left]

	quicksort(a[:left])
	quicksort(a[left+1:])

	return a
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		exec()
	}
}

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	quicksort(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n%2+1])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		if i != 0 {
			printf("%d ", arrA[n-i])
			continue
		}
		printf("%d", arrA[n-i])
	}
	printf("\n")
}

func quicksort(a []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	pivot := rand.Int() % len(a)

	a[pivot], a[right] = a[right], a[pivot]

	for i, _ := range a {
		if a[i] < a[right] {
			a[left], a[i] = a[i], a[left]
			left++
		}
	}

	a[left], a[right] = a[right], a[left]

	quicksort(a[:left])
	quicksort(a[left+1:])

	return a
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		exec()
	}
}

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	quicksort(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n/2])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		printf("%d", arrA[n-i])
	}
	printf("\n")
}

func quicksort(a []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	pivot := rand.Int() % len(a)

	a[pivot], a[right] = a[right], a[pivot]

	for i, _ := range a {
		if a[i] < a[right] {
			a[left], a[i] = a[i], a[left]
			left++
		}
	}

	a[left], a[right] = a[right], a[left]

	quicksort(a[:left])
	quicksort(a[left+1:])

	return a
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.ParseInt(string(line), 10, 64)
		line = readLine(reader)
		arrs := strings.Split(string(line), " ")
		arr := make([]int64, n)
		for i := int64(0); i < n; i++ {
			arr[i], _ = strconv.ParseInt(arrs[i], 10, 64)
		}
		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})
		i := int64(0)
		if n%2 == 0 {
			i = n/2 - 1
		} else {
			i = n / 2
		}
		dap := int64(1)
		flag := false
		result := make([]int64, 0)
		fmt.Println(arr)
		for i >= 0 {
			fmt.Println(i)
			result = append(result, arr[i])
			if !flag {
				i = i + dap
				flag = true
			} else {
				i = i- dap
				flag = false
			}
			dap++
		}
		// result = append(result, arr[0])
		printArr(result)
		fmt.Println()
	}
}

func printArr(arr []int64) {
	for _, v := range arr {
		fmt.Printf("%d ", v)
	}
}

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"
)

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

func f(n, x, t int64, c chan int64) {
	cnt := Min(n, t/x)
	c <- n*cnt - cnt*(cnt+1)/2
	close(c)
}

func main() {
	var k int32
	fmt.Scanf("%d\n", &k)
	chans := make([]chan int64, k)
	for i := int32(0); i < k; i++ {
		var n, x, t int64
		fmt.Scanf("%d %d %d\n", &n, &x, &t)
		chans[i] = make(chan int64)
		go f(n, x, t, chans[i])
	}
	for i := int32(0); i < k; i++ {
		fmt.Printf("%d\n", <-chans[i])
	}
}

package main

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

type Scanner struct {
    scanner *bufio.Scanner
}

func StdinScanner() *Scanner {
    scanner := new(Scanner)
    scanner.scanner = bufio.NewScanner(os.Stdin)
    scanner.scanner.Split(bufio.ScanWords)

    return scanner
}

func (s Scanner) Int() int {
    s.scanner.Scan()
    n, _ := strconv.Atoi(s.scanner.Text())

    return n
}

func (s Scanner) Int64() int64 {
    s.scanner.Scan()
    n, _ := strconv.ParseInt(s.scanner.Text(), 10, 64)

    return n
}

func (s Scanner) Token() string {
    s.scanner.Scan()

    return s.scanner.Text()
}

func main() {
    scanner := StdinScanner()
    tests := scanner.Int()

    for i := 0; i < tests; i += 1 {
        n, x, t := scanner.Int64(), scanner.Int64(), scanner.Int64()
        kk := int64(math.Min(float64(t / x), float64(n - 1)))

        res := kk * (n - kk) + (kk - 1) * kk / 2
        fmt.Println(res)
    }
}

// 00
package main

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

type Anything interface {
	int64 | float64 | int | string | float32
}

func write[K Anything](f *bufio.Writer, a K) {
	f.Write([]byte(fmt.Sprint(a)))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for k := 1; k <= T; k++ {
		var n, x, t, ans int64
		fmt.Fscan(reader, &n, &x, &t)
		d := t / x
		if n > d {
			ans = (d*(d+1))/2 + (n-d-1)*d
		} else {
			ans = ((n - 1) * n) / 2
		}
		write(f, ans)
		write(f, "\n")
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int64) {
	f.Write([]byte(fmt.Sprint(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for k := 1; k <= T; k++ {
		var n, x, t, ans int64
		fmt.Fscan(reader, &n, &x, &t)
		d := t / x
		if n > d {
			ans = (d*(d+1))/2 + (n-d-1)*d
		} else {
			ans = ((n - 1) * n) / 2
		}
		write_int(f, ans)
		write_string(f, "\n")
	}
}

package main

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

var p int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &p)
	for o := 0; o < p; o++ {
		var n, x, t int64
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &x)
		fmt.Fscan(input, &t)
		if t >= (n - 1) * x {
			fmt.Println(((n-1)*n)/2)
		}else{
			var k int64 = t / x
			fmt.Println(((n-k)*k + ((k-1)*k)/2))
		}
	}
}

package main

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

const (
// mx = 2e5 + 10
)

var n, x, t, k int64

func main() {

	var cin io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(cin, &k)

	for k > 0 {
		k--

		fmt.Fscan(cin, &n, &x, &t)
		berapa := t / x
		if berapa > n {
			ans := n * (n - 1) / 2
			fmt.Println(ans)
			continue
		}
		ans := berapa*n - berapa*(berapa+1)/2
		fmt.Println(ans)
	}

}

package main

import "fmt"

func main() {
	var k int
	fmt.Scanln(&k)
	var tc int
	tc = 0
	for tc < k {
		var n,x,t uint64
		fmt.Scan(&n)
		fmt.Scan(&x)
		fmt.Scan(&t)
		var soln uint64
		if n > (t/x) {
			soln = (n - (t/x))*(t/x)
			l := (t/x) - 1
			soln = soln + (l*(l+1)/2)
		} else {
			l := n - 1
			soln = soln + (l*(l+1)/2)
		}
		fmt.Println(soln)
		tc++
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"

)

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

	var t int
	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {

		var n, x, t int
		fmt.Fscan(r, &n, &x, &t)

		ans := solve(n, x, t)
		fmt.Println(ans)
	}

}

func solve(n, x , t int) int64 {

	if x > t {
		return 0
	}

	if x == t {
		return int64(n) - 1
	}

	d := t/x

	if n < d {
		return (int64(n - 1) * int64(n))/2

	} else {

		k := n - d

		s1 := int64(k) * int64(d)
		s2 := (int64(d - 1) * int64(d))/2

		return  s1 + s2
	}

	return int64(d) * int64(n)

}

package main

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

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var k int
	Fscan(in, &k)
	for i := 0; i < k; i++ {
		var n, t, x int
		Fscan(in, &n, &x, &t)
		cnt := int64(min(n-1, int(t/x)))
		var ans int64
		ans += cnt * (int64(n-1) - cnt)
		ans += (cnt + 1) * cnt / 2
		Fprintln(out, ans)
	}
}

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

package main

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

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}
func (s *Scanner) Next() string {
	s.bScanner.Scan()
	return s.bScanner.Text()
}
func (s *Scanner) NextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt()
	}
	return res
}
func (s *Scanner) NextInt64s(N int) []int64 {
	res := make([]int64, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt64()
	}
	return res
}
func Min(nums ...int) int {
	ans := math.MaxInt32
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}
func Max(nums ...int) int {
	ans := math.MinInt32
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

func InitInts1D(n int, val int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = val
	}
	return res
}
func InitInts2D(n, m int, val int) [][]int {
	res := make([][]int, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts1D(m, val)
	}
	return res
}
func InitInts3D(n, m, k int, val int) [][][]int {
	res := make([][][]int, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts2D(m, k, val)
	}
	return res
}

type StepState struct {
	step, dist int
}
type PriorityQueue []*StepState

func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].step != pq[j].step {
		return pq[i].step < pq[j].step
	}
	return pq[i].dist < pq[j].dist
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*StepState)
	*pq = append(*pq, item)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

func main() {
	sc := NewScanner()
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	TC := sc.NextInt()
	for tc := 0; tc < TC; tc++ {
		n := sc.NextInt()
		x := sc.NextInt()
		t := sc.NextInt()

		ans := int64(0)
		if x <= t {
			upperBound := t / x
			incSeqLen := Min(n, t/x+1)
			flatSeqLen := n - incSeqLen
			ans = int64(incSeqLen)*int64(incSeqLen-1)/2 + int64(flatSeqLen)*int64(upperBound)
		}
		fmt.Fprintln(wr, ans)
	}

}

package main

import (
	"fmt"
)
func max(a,b uint64) uint64{
	if a > b {
		return a
	}
	return b;
}
func min(a,b uint64) uint64{
	if a < b {
		return a
	}
	return b
}
func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t uint64
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		mx := min(n,t/x)
		stduent_on_max := n-mx
		temp := (mx-1)*mx/2+mx*stduent_on_max
		fmt.Printf("%d\n",temp)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t, ans uint64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		if m > n {
			m = n
		}

		ans += (m * (m - 1)) / 2

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
)

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

func f(n, x, t int64, c chan int64) {
	cnt := Min(n, t/x)
	c <- n*cnt - cnt*(cnt+1)/2
	close(c)
}

func main() {
	var k int32
	fmt.Scanf("%d\n", &k)
	chans := make([]chan int64, k)
	for i := int32(0); i < k; i++ {
		var n, x, t int64
		fmt.Scanf("%d %d %d\n", &n, &x, &t)
		chans[i] = make(chan int64, 1)
		go f(n, x, t, chans[i])
	}
	for i := int32(0); i < k; i++ {
		fmt.Printf("%d\n", <-chans[i])
	}
}

package main

import (
	"fmt"
)

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

func f(n, x, t int64) int64 {
	cnt := Min(n, t/x)
	return n*cnt - cnt*(cnt+1)/2
}

func main() {
	var k int32
	fmt.Scanf("%d\n", &k)
	for ; k > 0; k-- {
		var n, x, t int64
		fmt.Scanf("%d %d %d\n", &n, &x, &t)
		ans := f(n, x, t)
		fmt.Printf("%d\n", ans)
	}
}

/*input

*/
package main

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

var str string
var tc,n,x,t,d int64

func main(){
	var cin io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(cin,&tc)
	for tc>0{
		tc--
		fmt.Fscan(cin,&n,&x,&t)
		d=t/x
		if n>d+1{
			fmt.Println(d*(d-1)/2+(n-d)*d)
		}else{
			fmt.Println(n*(n-1)/2)
		}
	}
}

package main

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

var tc,n,x,t,d int64

func main() {
  var cin io.Reader = bufio.NewReader(os.Stdin)
  fmt.Fscan(cin, &tc)
  for tc>0{
    tc--
    fmt.Fscan(cin, &n,&x,&t)
    d=t/x
    if n>d+1{
      fmt.Println(d*(d-1)/2+(n-d)*d)
    } else {
      fmt.Println(n*(n-1)/2)
    }
  }
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

var k int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &k)
	for o := 0; o < k; o++ {
		var n, x, t int64
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &x)
		fmt.Fscan(input, &t)

		var m int64

		m = int64(t / x)
		var sum int64
		if n < m+1 {
			sum = n * (n - 1) / 2
		} else {
			sum = (m * (m - 1) / 2) + (n-m)*m
		}

		fmt.Println(sum)

	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n, x, d int
		fmt.Fscan(in, &n, &x, &d)

		var total int64
		z := int64(d / x)
		if int(z) <= n-1 {
			total = (int64(n) - z) * z
		}

		if z > int64(n) {
			z = int64(n)
		}

		z--
		total += z * (z + 1) / 2
		fmt.Fprintln(out, total)
	}
}

package main

import (
	"fmt"
)

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

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

func process() {
	var n, x, t uint64
	fmt.Scanf("%d %d %d\n", &n, &x, &t)
	mx := Min(n, t/x)
	// mx := t / x
	students_on_max := n - mx
	tot := (mx*(mx-1))/2 + mx*students_on_max
	fmt.Printf("%d\n", tot)
}

func main() {
	var k int
	fmt.Scanf("%d\n", &k)
	for i := 0; i < k; i++ {
		process()
	}
}

package main

import (
	"fmt"
)
func max(a,b uint64) uint64{
	if a > b {
		return a
	}
	return b;
}
func min(a,b uint64) uint64{
	if a < b {
		return a
	}
	return b
}
func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t uint64
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		temp :=(0+min(n-1,t/x-1))*(t/x)/2
		temp +=max(0, n-t/x)*(t/x)
		fmt.Printf("%d\n",temp)
	}
}

package main

import "fmt"

func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t uint64
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		temp :=(0+t/x-1)*(t/x)/2
		temp +=(n-t/x)*(t/x)
		fmt.Printf("%d\n",temp)
	}
}

package main

import "fmt"

func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t int64
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		temp :=(0+t/x-1)*(t/x)/2
		temp +=(n-t/x)*(t/x)
		fmt.Printf("%d\n",temp)
	}
}

package main

import "fmt"

func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t int
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		temp :=(0+t/x-1)*(t/x)/2
		temp +=(n-t/x)*(t/x)
		fmt.Printf("%d\n",temp)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t, ans uint64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		ans += (m * (m - 1)) / 2

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t, ans int64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		if m > 0 {
			ans += (m * (m - 1)) / 2
		}

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t, ans int64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		if m > 0 {
			ans += m * (m - 1) / 2
		}

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t int64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		ans := m * (m - 1) / 2

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t int64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		ans := (n-m)*m + (m * (m - 1) / 2)

		fmt.Println(ans)
	}
}

package main

import "fmt"

func f(n, x, t int64) int64 {
	cnt := t / x
	return n*cnt - cnt*(cnt+1)/2
}

func main() {
	var k int32
	fmt.Scanf("%d\n", &k)
	for ; k > 0; k-- {
		var n, x, t int64
		fmt.Scanf("%d %d %d\n", &n, &x, &t)
		ans := f(n, x, t)
		fmt.Printf("%d\n", ans)
	}
}

/*input

*/
package main

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

var str string
var tc,n,x,t,d int

func main(){
	var cin io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(cin,&tc)
	for tc>0{
		tc--
		fmt.Fscan(cin,&n,&x,&t)
		d=t/x
		if n>d+1{
			fmt.Println(d*(d-1)/2+(n-d)*d)
		}else{
			fmt.Println(n*(n-1)/2)
		}
	}
}

package main

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

var tc,n,x,t,d int

func main() {
  var cin io.Reader = bufio.NewReader(os.Stdin)
  fmt.Fscan(cin, &tc)
  for tc>0{
    tc--
    fmt.Fscan(cin, &n,&x,&t)
    d=t/x
    if n>d+1{
      fmt.Println(d*(d-1)/2+(n-d)*d)
    } else {
      fmt.Println(n*(n-1)/2)
    }
  }
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var x, t int
		var n int64
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &x)

		fmt.Fscan(input, &t)

		m := int64(t / x)
		if n >= m-1 {
			var qq int64
			qq = m * (2*n - m - 1) / 2
			fmt.Println(qq)
		} else {
			var qq int64
			qq = n * (n - 1) / 2
			fmt.Println(qq)
		}
	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var x, t int
		var n int64
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &x)

		fmt.Fscan(input, &t)
		m := int64(t / x)
		var qq int64
		qq = m * (2*n - m - 1) / 2
		fmt.Println(qq)

	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n, x, d int
		fmt.Fscan(in, &n, &x, &d)

		var total int64
		z := int64(d / x)
		if int(z) <= n-1 {
			total = (int64(n) - z) * z
		}

		z--
		total += z * (z + 1) / 2
		fmt.Fprintln(out, total)
	}
}

package main

import (
	"fmt"
)

func process() {
	var n, x, t uint64
	fmt.Scanf("%d %d %d\n", &n, &x, &t)
	max := t / x
	students_on_max := n - max
	tot := (max*(max-1))/2 + max*students_on_max
	fmt.Printf("%d\n", tot)
}

func main() {
	var k int
	fmt.Scanf("%d\n", &k)
	for i := 0; i < k; i++ {
		process()
	}
}

package main

import (
	"fmt"
)

func process() {
	var n, x, t int
	fmt.Scanf("%d %d %d\n", &n, &x, &t)
	max := t / x
	students_on_max := n - max
	tot := (max*(max-1))/2 + max*students_on_max
	fmt.Printf("%d\n", tot)
}

func main() {
	var k int
	fmt.Scanf("%d\n", &k)
	for i := 0; i < k; i++ {
		process()
	}
}

package main

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

type Scanner struct {
    scanner *bufio.Scanner
}

func StdinScanner() *Scanner {
    scanner := new(Scanner)
    scanner.scanner = bufio.NewScanner(os.Stdin)
    scanner.scanner.Split(bufio.ScanWords)

    return scanner
}

func (s Scanner) Int() int {
    s.scanner.Scan()
    n, _ := strconv.Atoi(s.scanner.Text())

    return n
}

func (s Scanner) Int64() int64 {
    s.scanner.Scan()
    n, _ := strconv.ParseInt(s.scanner.Text(), 10, 64)

    return n
}

func (s Scanner) Token() string {
    s.scanner.Scan()

    return s.scanner.Text()
}

func main() {
    scanner := StdinScanner()
    tests := scanner.Int()

    for i := 0; i < tests; i += 1 {
        n, x, t := scanner.Int64(), scanner.Int64(), scanner.Int64()
        kk := t / x

        res := kk * (n - kk) + (kk - 1) * kk / 2
        fmt.Println(res)
    }
}

package main

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

type Scanner struct {
    scanner *bufio.Scanner
}

func StdinScanner() *Scanner {
    scanner := new(Scanner)
    scanner.scanner = bufio.NewScanner(os.Stdin)
    scanner.scanner.Split(bufio.ScanWords)

    return scanner
}

func (s Scanner) Int() int {
    s.scanner.Scan()
    n, _ := strconv.Atoi(s.scanner.Text())

    return n
}

func (s Scanner) Token() string {
    s.scanner.Scan()

    return s.scanner.Text()
}

func main() {
    scanner := StdinScanner()
    tests := scanner.Int()

    for i := 0; i < tests; i += 1 {
        n, x, t := scanner.Int(), scanner.Int(), scanner.Int()
        kk := t / x

        res := kk * (n - kk) + (kk - 1) * kk / 2
        fmt.Println(res)
    }
}

package main

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var n, x, t int
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &x)
		fmt.Fscan(input, &t)
		if t >= (n - 1) * x {
			fmt.Println(((n-1)*n)/2)
		}else{
			var k int = t / x
			fmt.Println(((n-k)*k + ((k-1)*k)/2))
		}
	}
}

package main

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

const (
// mx = 2e5 + 10
)

var n, x, t, k int64

func main() {

	var cin io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(cin, &k)

	for k > 0 {
		k--

		fmt.Fscan(cin, &n, &x, &t)
		berapa := t / x
		ans := berapa*n - berapa*(berapa+1)/2
		fmt.Println(ans)
	}

}

package main

import "fmt"

func main() {
	var k int
	fmt.Scanln(&k)
	var tc int
	tc = 0
	for tc < k {
		var n,x,t uint64
		fmt.Scan(&n)
		fmt.Scan(&x)
		fmt.Scan(&t)
		var soln uint64
		soln = (n - (t/x))*(t/x)
		l := (t/x) - 1
		soln = soln + (l*(l+1)/2)
		fmt.Println(soln)
		tc++
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"

)

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

	var t int
	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {

		var n, x, t int
		fmt.Fscan(r, &n, &x, &t)

		ans := solve(n, x, t)
		fmt.Println(ans)
	}

}

func solve(n, x , t int) int64 {

	if x > t {
		return 0
	}

	if x == t {
		return int64(n)
	}

	d := t/x

	if n < d {
		return (int64(n - 1) * int64(n))/2

	} else {

		k := n - d

		s1 := int64(k) * int64(d)
		s2 := (int64(d - 1) * int64(d))/2

		return  s1 + s2
	}

	return int64(d) * int64(n)

}


package main

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

func main()  {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

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

	var x, y int
	fmt.Fscan(in, &x, &y)

	d := dividers(x)
	for _, yV := range dividers(y) {
		b := true
		for _, xV := range d {
			if xV == yV {
				b = false
				break
			}
		}
		if b {
			d = append(
				d,
				yV,
			)
		}
	}

	cnt := make([]int, len(d))
	for i := 0; i < len(cnt); i++ {
		cnt[i] = 1
	}

	for i := 1; i < n; i++ {
		fmt.Fscan(in, &x, &y)
		for j := 0; j < len(d); j++ {
			if x % d[j] == 0 || y % d[j] == 0 {
				cnt[j]++
			}
		}
	}

	for i := 0; i < len(d); i++ {
		if cnt[i] == n {
			fmt.Fprintln(out, d[i])
			return
		}
	}

	fmt.Fprintln(out, "-1")

}

func dividers(a int) []int {

	list := make([]int, 0)

	i, max := 2, int(math.Floor(math.Sqrt(float64(a))))
	for i <= max {
		if a%i == 0 {
			if len(list) == 0 || list[len(list) - 1] != i {
				list = append(
					list,
					i,
				)
			}
			a /= i
		} else {
			i++
		}
	}

	if a > 1 {
		list = append(
			list,
			a,
		)
	}

	return list

}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1025B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int64) int64 {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}
	lcm := func(a, b int64) int64 { return a / gcd(a, b) * b }

	var n int
	var x, y, a, b int64
	Fscan(in, &n, &x, &y)
	g := lcm(x, y)
	for n--; n > 0; n-- {
		Fscan(in, &a, &b)
		g = gcd(g, lcm(a, b))
	}
	f := func(n int64) int64 {
		for i := int64(2); i*i <= n; i++ {
			if n%i == 0 && g%i == 0 {
				return i
			}
			for ; n%i == 0; n /= i {
			}
		}
		if n > 1 && g%n == 0 {
			return n
		}
		return -1
	}
	ans := f(x)
	if ans == -1 {
		ans = f(y)
	}
	Fprint(out, ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1025B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int64) int64 {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}
	lcm := func(a, b int64) int64 { return a / gcd(a, b) * b }

	var n int
	var x, y, a, b int64
	Fscan(in, &n, &x, &y)
	g := lcm(x, y)
	for n--; n > 0; n-- {
		Fscan(in, &a, &b)
		g = gcd(g, lcm(a, b))
	}
	f := func(n int64) int64 {
		for d := int64(1); d*d <= n; d++ {
			if n%d == 0 {
				if d > 1 && g%d == 0 {
					return d
				}
				if g%(n/d) == 0 {
					return n / d
				}
			}
		}
		return -1
	}
	ans := f(x)
	if ans == -1 {
		ans = f(y)
	}
	Fprint(out, ans)
}

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