There are some websites that are accessible through several different addresses. For example, for a long time Codeforces was accessible with two hostnames codeforces.com and codeforces.ru.You are given a list of page addresses being queried. For simplicity we consider all addresses to have the form http://<hostname>[/<path>], where:  <hostname> — server name (consists of words and maybe some dots separating them),  /<path> — optional part, where <path> consists of words separated by slashes. We consider two <hostname> to correspond to one website if for each query to the first <hostname> there will be exactly the same query to the second one and vice versa — for each query to the second <hostname> there will be the same query to the first one. Take a look at the samples for further clarifications.Your goal is to determine the groups of server names that correspond to one website. Ignore groups consisting of the only server name.Please note, that according to the above definition queries http://<hostname> and http://<hostname>/ are different.

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of page queries. Then follow n lines each containing exactly one address. Each address is of the form http://<hostname>[/<path>], where:   <hostname> consists of lowercase English letters and dots, there are no two consecutive dots, <hostname> doesn't start or finish with a dot. The length of <hostname> is positive and doesn't exceed 20.  <path> consists of lowercase English letters, dots and slashes. There are no two consecutive slashes, <path> doesn't start with a slash and its length doesn't exceed 20.  Addresses are not guaranteed to be distinct.

First print k — the number of groups of server names that correspond to one website. You should count only groups of size greater than one. Next k lines should contain the description of groups, one group per line. For each group print all server names separated by a single space. You are allowed to print both groups and names inside any group in arbitrary order.

10
http://abacaba.ru/test
http://abacaba.ru/
http://abacaba.com
http://abacaba.com/test
http://abacaba.de/
http://abacaba.ru/test
http://abacaba.de/test
http://abacaba.com/
http://abacaba.com/t
http://abacaba.com/test

14
http://c
http://ccc.bbbb/aba..b
http://cba.com
http://a.c/aba..b/a
http://abc/
http://a.c/
http://ccc.bbbb
http://ab.ac.bc.aa/
http://a.a.a/
http://ccc.bbbb/
http://cba.com/
http://cba.com/aba..b
http://a.a.a/aba..b/a
http://abc/aba..b/a

2
http://cba.com http://ccc.bbbb
http://a.a.a http://a.c http://abc

package main

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

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	snum := ReadInt32()
	pathcnt := 1
	allpaths := make(map[string]int)
	hostpaths := make(map[string]map[int]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := scanner.Text()
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[int]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		pi := allpaths[p]
		if pi == 0 {
			pi = pathcnt
			pathcnt++
			allpaths[p] = pi
		}
		paths[pi] = struct{}{}
		hostpaths[part[0]] = paths
	}

	if snum == len(allpaths) {
		writer.WriteString("0")
		return
	}
	allpaths = nil
	runtime.GC()
	maxbits := 0
	for pathcnt--; pathcnt > 0; pathcnt = pathcnt >> 1 {
		maxbits++
	}

	//sort paths
	groups := make(map[string][]string)
	for k, v := range hostpaths {
		pa := make([]int, 0, len(v))
		for p := range v {
			pa = append(pa, p)
		}
		sort.Ints(pa)
		var s uint64 = 0
		cnt := 64 / maxbits
		key := make([]byte, ((len(pa)+cnt)/cnt)*8)
		i := 0
		ki := 0
		for _, pn := range pa {
			s |= uint64(pn) << uint(i*maxbits)
			i++
			if i == cnt {
				for j := uint(0); j < 8; j++ {
					key[ki] = byte((s >> (j * 8)) & 0xff)
					ki++
				}
				s = 0
				i = 0
			}
		}
		if s != 0 {
			for j := uint(0); j < 8; j++ {
				key[ki] = byte((s >> (j * 8)) & 0xff)
				ki++
			}
		}

		hosts := groups[string(key)]
		hosts = append(hosts, k)
		groups[string(key)] = hosts
	}
	hostpaths = nil

	grcnt := 0
	for _, hosts := range groups {
		if len(hosts) > 1 {
			grcnt++
		}
	}
	writer.WriteString(strconv.Itoa(grcnt))
	for _, hosts := range groups {
		if len(hosts) > 1 {
			writer.WriteString("\n")
			for _, hn := range hosts {
				writer.WriteString("http://" + hn + " ")
			}
		}
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	rs := bufio.NewReader(os.Stdin)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		s := ""
		ss, _, _ := rs.ReadLine()
		s = string(ss)
		// fmt.Println("!", s)
		if s[len(s)-1] == '\n' {
			s = s[:len(s)-1]
		}
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id] = tem2{a: w, b: k}
		id++
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

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

func Scan(args ...interface{}) (e error)             { _, e = fmt.Fscan(in, args...); return }
func Scanf(ft string, args ...interface{}) (e error) { _, e = fmt.Fscanf(in, ft, args...); return }
func Scanln(args ...interface{}) (e error)           { _, e = fmt.Fscanln(in, args...); return }
func Print(args ...interface{})                      { out.WriteString(fmt.Sprint(args...)) }
func Printf(ft string, args ...interface{})          { out.WriteString(fmt.Sprintf(ft, args...)) }
func Println(args ...interface{})                    { out.WriteString(fmt.Sprintln(args...)) }

var (
	//dataIn = "data.in"
	in     = bufio.NewReader(os.Stdin)
	//in, _ = os.Open(dataIn)
	out   = bufio.NewWriter(os.Stdout)
)

var n int

func solve() {
	vis := make(map[string]bool)
	m1 := make(map[string][]string)
	var addr string
	for i := 0; i < n; i++ {
		Scan(&addr)
		if _, ok := vis[addr]; ok {
			continue
		}
		vis[addr] = true
		addr = addr[7:]
		pos := strings.Index(addr, "/")
		host, path := addr, ""
		if pos != -1 {
			host = addr[:pos]
			if pos == len(addr)-1 {
				path = " "
			} else {
				path = addr[pos+1:]
			}
		}
		m1[host] = append(m1[host], path)
	}

	m2 := make(map[string][]string)
	for k, v := range m1 {
		sort.Strings(v)
		kk := strings.Join(v, "\001")
		m2[kk] = append(m2[kk], k)
	}

	cnt := 0
	for _, v := range m2 {
		if len(v) > 1 {
			cnt++
		}
	}

	Println(cnt)
	for _, v := range m2 {
		if len(v) > 1 {
			for _, s := range v {
				Printf("http://%s ", s)
			}
			Println()
		}
	}
	return
}

func main() {
	defer out.Flush()
	for Scan(&n) != io.EOF {
		solve()
	}
	return
}

package main

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

func main() {
	defer out.Flush()
	var n int
	fmt.Fscanln(in, &n)
	seen := map[string]bool{}
	hostnamePaths := map[string][]string{}
	for i := 0; i < n; i++ {
		line := readLine()
		if seen[line] {
			continue
		}
		seen[line] = true
		line = line[7:]
		i := 0
		for i != len(line) && line[i] != '/' {
			i++
		}
		hostname := line[:i]
		path := line[i:]
		hostnamePaths[hostname] = append(hostnamePaths[hostname], path)
	}
	hashToHostnames := map[Hash][]string{}
	for hostname, paths := range hostnamePaths {
		sort.Strings(paths)
		pathsStr := strings.Join(paths, "$")
		pathsHash := NewHasher(pathsStr).Hash(0, len(pathsStr)-1)
		hashToHostnames[pathsHash] = append(hashToHostnames[pathsHash], hostname)
	}
	ans := make([][]string, 0)
	for _, hostnames := range hashToHostnames {
		if len(hostnames) > 1 {
			ans = append(ans, hostnames)
		}
	}
	fmt.Fprintln(out, len(ans))
	for _, hostnames := range ans {
		for i, hostname := range hostnames {
			if i != 0 {
				fmt.Fprint(out, " ")
			}
			fmt.Fprint(out, "http://", hostname)
		}
		fmt.Fprintln(out)
	}
}

const (
	P  = 499
	M1 = 1e9 + 7
	M2 = 1e9 + 9
)

var M = [...]int32{M1, M2}

type Hash struct {
	h [2]int32
}

func hash(x int32) Hash {
	var result Hash
	for i := range result.h {
		result.h[i] = mathmod32(x, M[i])
	}
	return result
}

func add(a, b Hash) Hash {
	var result Hash
	for i := range result.h {
		result.h[i] = mathmod32(a.h[i]+b.h[i], M[i])
	}
	return result
}

func sub(a, b Hash) Hash {
	var result Hash
	for i := range result.h {
		result.h[i] = mathmod32(a.h[i]-b.h[i], M[i])
	}
	return result
}

func mul(a, b Hash) Hash {
	var result Hash
	for i := range result.h {
		result.h[i] = int32(mathmod64(int64(a.h[i])*int64(b.h[i]), int64(M[i])))
	}
	return result
}

var pPows = []Hash{hash(1), hash(P)}

func pPow(n int) Hash {
	for len(pPows) <= n {
		pPows = append(pPows, mul(pPows[len(pPows)-1], pPows[1]))
	}
	return pPows[n]
}

type Hasher struct {
	pref []Hash
}

func NewHasher(s string) *Hasher {
	h := &Hasher{
		make([]Hash, len(s)+1),
	}
	for i := 0; i < len(s); i++ {
		h.pref[i+1] = add(mul(h.pref[i], pPow(1)), hash(int32(s[i])))
	}
	return h
}

func (h *Hasher) Hash(a, b int) Hash {
	return sub(h.pref[b+1], mul(h.pref[a], pPow(b-a+1)))
}

func mathmod32(a, m int32) int32 {
	if !(0 <= a && a < m) {
		a %= m
		if a < 0 {
			a += m
		}
	}
	return a
}

func mathmod64(a, m int64) int64 {
	if !(0 <= a && a < m) {
		a %= m
		if a < 0 {
			a += m
		}
	}
	return a
}

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

func readLine() string {
	var result bytes.Buffer
	for {
		chunk, more, _ := in.ReadLine()
		result.Write(chunk)
		if !more {
			break
		}
	}
	return result.String()
}

package main

import (
          "fmt"
          "sort"
          "strings"
          "crypto/md5"
          "encoding/hex"
          //"time"
          "bufio"
          "os"
       )

type queryMap map[string]bool
type queryArray []string
type hostnameArray []string

func main() {
    //t0 := time.Now()

    var n int
    var s string

    var q map[string]queryMap = make(map[string]queryMap)  //map for queries corresponding to hostname(string)

    in := bufio.NewReader(os.Stdin)
    fmt.Fscanf(in, "%d\n", &n)

    for i := 0; i < n; i++ {
        fmt.Fscanf(in, "%s\n", &s)
        ss := s[7:] //http://
        var k int  = 0
        lss := len(ss)
        for k = 0; k < lss; k++ {
            if ss[k] == '/' {
                break
            }
        }
        hostName := ss[0:k]
        queryText := ss[k:lss]
        //fmt.Printf("%s  %s\n", hostName, queryText)
        _, ok := q[hostName]
        if ok {
            _, alreadyInSlice := q[hostName][queryText]
            if alreadyInSlice == false {
                q[hostName][queryText] = true
            }
        } else {
            qq := make(queryMap)
            qq[queryText] = true
            q[hostName] = qq
        }
    }

    //tt := time.Now()
    //fmt.Printf("Input read time = %v\n", tt.Sub(t0))

    //Convert map to array
    var qa map[string]queryArray = make(map[string]queryArray)
    for k, v := range q {
        var t queryArray = make(queryArray, 0)
        for kk, _ := range v {
            t = append(t, kk)
        }
        qa[k] = t
    }

    //Sort queries in map to make them ordered
    for _, z := range qa {
        sort.Strings(z)
    }
    //Now one can compare queiries for every hostname

    var qq map[string]string = make(map[string]string) //convert query array to string
    for h, z := range qa {
        //qq[h] = strings.Join(z,",")
        zz := strings.Join(z,",")
        hasher := md5.New()
        hasher.Write([]byte(zz))
        qq[h] = hex.EncodeToString(hasher.Sum(nil))
    }

    //Now find corresponding hostnames for every query
    var aa map[string]hostnameArray = make(map[string]hostnameArray)

    for h, z := range qq {
        _, ok := aa[z]
        if ok {
            aa[z] = append(aa[z], h)
        } else {
            qh := make(hostnameArray, 1)
            qh[0] = h
            aa[z] = qh
        }
    }

    //If query corresponds only to one hostname, delete it
    for z, h := range aa {
        if len(h) == 1 {
            delete(aa, z)
        }
    }

    //The result
    fmt.Printf("%d\n", len(aa))
    for _, h := range aa {
        for i := 0; i < len(h); i++ {
            fmt.Printf("http://%s ", h[i])
        }
        fmt.Println()
    }
    //t1 := time.Now()
    //fmt.Printf("The running time = %v\n", t1.Sub(t0))
}

package main

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

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

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

type t struct {
	host  string
	paths []int
	s     uint64
	found bool
}

type t1 []t

func (e t1) Len() int {
	return len(e)
}

func (e t1) Less(i, j int) bool {
	if e[i].s == e[j].s {
		return len(e[i].paths) < len(e[j].paths)
	}
	return e[i].s < e[j].s
}

func (e t1) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

func main() {
	defer writer.Flush()           // очищает буфер при выходе из функции main
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	snum := ReadInt32()
	pathcnt := 1
	allpaths := make(map[string]int)
	hostpaths := make(map[string]map[int]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := scanner.Text()
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[int]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		pi := allpaths[p]
		if pi == 0 {
			pi = pathcnt
			pathcnt++
			allpaths[p] = pi
		}
		paths[pi] = struct{}{}
		hostpaths[part[0]] = paths
	}

	if snum == len(allpaths) {
		writer.WriteString("0")
		return
	}
	allpaths = nil
	runtime.GC()

	//sort paths
	hosts := make(t1, 0, len(hostpaths))
	for k, v := range hostpaths {
		pa := make([]int, 0, len(v))
		for p := range v {
			pa = append(pa, p)
		}
		sort.Ints(pa)
		var s uint64 = 0
		i := 0
		for ; i < len(pa); i++ {
			s |= uint64(pa[i]) << (uint(i) * 20)
		}
		hosts = append(hosts, t{host: k, paths: pa[i:], s: s})
	}
	sort.Sort(hosts)
	hostpaths = nil

	//search equal path sets
	plen := len(hosts)
	groups := []string{}
	for idx := 0; idx < plen-1; idx++ {
		if !hosts[idx].found {
			ilen := len(hosts[idx].paths)
			gexist := false
		loop:
			for i := idx + 1; i < plen && hosts[idx].s == hosts[i].s && ilen == len(hosts[i].paths); i++ {
				if !hosts[i].found {
					for j := 0; j < ilen; j++ {
						if hosts[idx].paths[j] != hosts[i].paths[j] {
							continue loop
						}
					}
					if !gexist {
						groups = append(groups, "http://"+hosts[idx].host)
						gexist = true
					}
					groups[len(groups)-1] += " http://" + hosts[i].host
					hosts[i].found = true
				}
			}
		}
	}
	writer.WriteString(strconv.Itoa(len(groups)))
	for _, grs := range groups {
		writer.WriteString("\n" + grs)
	}
}

package main

import (
	"bufio"
	"bytes"
	"crypto/md5"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

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

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

type pathhash struct {
	hash []byte
	cnt  int
}

func main() {
	defer writer.Flush()           // очищает буфер при выходе из функции main
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	snum := ReadInt32()
	hostpaths := make(map[string]map[string]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := scanner.Text()
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[string]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		paths[p] = struct{}{}
		hostpaths[part[0]] = paths
	}

	//sort paths
	hosts := make([]string, 0, len(hostpaths))
	paths := make([]pathhash, 0, len(hostpaths))
	for k, v := range hostpaths {
		pa := make([]string, 0, len(v))
		for p := range v {
			pa = append(pa, p)
		}
		sort.Strings(pa)
		h := md5.New()
		for _, p := range pa {
			io.WriteString(h, p)
		}
		hosts = append(hosts, k)
		paths = append(paths, pathhash{hash: h.Sum(nil), cnt: len(pa)})
	}

	//search equal path sets
	plen := len(paths)
	groups := []string{}
	for idx := 0; idx < plen-1 && paths[idx].cnt != 0; idx++ {
		ilen := paths[idx].cnt
		gexist := false
		for i := idx + 1; i < plen; i++ {
			if ilen == paths[i].cnt {
				if bytes.Equal(paths[idx].hash, paths[i].hash) {
					if !gexist {
						groups = append(groups, "http://"+hosts[idx])
						gexist = true
					}
					groups[len(groups)-1] += " http://" + hosts[i]
					paths[i].cnt = 0
				}
			}
		}
	}
	writer.WriteString(strconv.Itoa(len(groups)))
	for _, grs := range groups {
		writer.WriteString("\n" + grs)
	}
}

package main

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

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

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

func main() {
	defer writer.Flush()           // очищает буфер при выходе из функции main
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	snum := ReadInt32()
	hostpaths := make(map[string]map[string]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := strings.ToLower(scanner.Text())
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[string]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		paths[p] = struct{}{}
		hostpaths[part[0]] = paths
	}

	//sort paths
	hosts := make([]string, 0, len(hostpaths))
	paths := make([][]string, 0, len(hostpaths))
	for k, v := range hostpaths {
		pa := make([]string, 0, len(v))
		for p := range v {
			pa = append(pa, p)
		}
		sort.Strings(pa)
		hosts = append(hosts, k)
		paths = append(paths, pa)
	}

	//search equal path sets
	plen := len(paths)
	groups := []string{}
	for idx := 0; idx < plen-1 && paths[idx] != nil; idx++ {
		ilen := len(paths[idx])
		gexist := false
	loop:
		for i := idx + 1; i < plen; i++ {
			if paths[i] != nil && ilen == len(paths[i]) {
				for j := 0; j < ilen; j++ {
					if paths[idx][j] != paths[i][j] {
						break loop
					}
				}
				if !gexist {
					groups = append(groups, "http://"+hosts[idx])
					gexist = true
				}
				groups[len(groups)-1] += " http://" + hosts[i]
				paths[i] = nil
			}
		}
	}
	writer.WriteString(strconv.Itoa(len(groups)))
	for _, grs := range groups {
		writer.WriteString("\n" + grs)
	}
}

package main

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

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

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

type t struct {
	host  string
	paths []int
	s     int
}

type t1 []t

func (e t1) Len() int {
	return len(e)
}

func (e t1) Less(i, j int) bool {
	if len(e[i].paths) == len(e[j].paths) {
		if e[i].paths[0] == e[j].paths[0] {
			return e[i].s < e[j].s
		}
		return e[i].paths[0] < e[j].paths[0]
	}
	return len(e[i].paths) < len(e[j].paths)
}

func (e t1) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

func main() {
	defer writer.Flush()           // очищает буфер при выходе из функции main
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	snum := ReadInt32()
	pathcnt := 1
	allpaths := make(map[string]int)
	hostpaths := make(map[string]map[int]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := scanner.Text()
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[int]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		pi := allpaths[p]
		if pi == 0 {
			pi = pathcnt
			pathcnt++
			allpaths[p] = pi
		}
		paths[pi] = struct{}{}
		hostpaths[part[0]] = paths
	}

	if snum == len(allpaths) {
		writer.WriteString("0")
		return
	}
	allpaths = nil
	runtime.GC()

	//sort paths
	hosts := make(t1, 0, len(hostpaths))
	for k, v := range hostpaths {
		pa := make([]int, 0, len(v))
		s := 0
		for p := range v {
			pa = append(pa, p)
			s += p
		}
		sort.Ints(pa)
		hosts = append(hosts, t{host: k, paths: pa, s: s})
	}
	sort.Sort(hosts)
	hostpaths = nil

	//search equal path sets
	plen := len(hosts)
	groups := []string{}
	for idx := 0; idx < plen-1; idx++ {
		if hosts[idx].paths != nil {
			ilen := len(hosts[idx].paths)
			gexist := false
		loop:
			for i := idx + 1; i < plen && ilen == len(hosts[i].paths) && hosts[idx].paths[0] == hosts[i].paths[0] && hosts[idx].s == hosts[i].s; i++ {
				for j := 1; j < ilen; j++ {
					if hosts[idx].paths[j] != hosts[i].paths[j] {
						continue loop
					}
				}
				if !gexist {
					groups = append(groups, "http://"+hosts[idx].host)
					gexist = true
				}
				groups[len(groups)-1] += " http://" + hosts[i].host
				hosts[i].paths = nil
			}
		}
	}
	writer.WriteString(strconv.Itoa(len(groups)))
	for _, grs := range groups {
		writer.WriteString("\n" + grs)
	}
}

package main

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

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

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

type t1 [][]int

func main() {
	defer writer.Flush()           // очищает буфер при выходе из функции main
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	snum := ReadInt32()
	pathcnt := 1
	allpaths := make(map[string]int)
	hostpaths := make(map[string]map[int]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := scanner.Text()
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[int]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		pi := allpaths[p]
		if pi == 0 {
			pi = pathcnt
			pathcnt++
			allpaths[p] = pi
		}
		paths[pi] = struct{}{}
		hostpaths[part[0]] = paths
	}

	maxdubs := snum - len(hostpaths)
	if maxdubs == 0 {
		writer.WriteString("0")
		return
	}
	maxdubs++

	//sort paths
	hosts := make([]string, 0, len(hostpaths))
	paths := make(t1, 0, len(hostpaths))
	ps := make([]int, 0, len(hostpaths))
	for k, v := range hostpaths {
		pa := make([]int, 0, len(v))
		s := 0
		for p := range v {
			pa = append(pa, p)
			s += p
		}
		sort.Ints(pa)
		hosts = append(hosts, k)
		paths = append(paths, pa)
		ps = append(ps, s)
	}

	//search equal path sets
	plen := len(paths)
	groups := []string{}
loop1:
	for idx := 0; idx < plen-1; idx++ {
		if paths[idx] != nil {
			ilen := len(paths[idx])
			gexist := false
		loop:
			for i := idx + 1; i < plen; i++ {
				if paths[i] != nil && ilen == len(paths[i]) && paths[idx][0] == paths[i][0] && ps[idx] == ps[i] {
					for j := 1; j < ilen; j++ {
						if paths[idx][j] != paths[i][j] {
							continue loop
						}
					}
					if !gexist {
						groups = append(groups, "http://"+hosts[idx])
						gexist = true
						maxdubs--
					}
					groups[len(groups)-1] += " http://" + hosts[i]
					paths[i] = nil
					maxdubs--
					if maxdubs == 0 {
						break loop1
					}
				}
			}
		}
	}
	writer.WriteString(strconv.Itoa(len(groups)))
	for _, grs := range groups {
		writer.WriteString("\n" + grs)
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	rs := bufio.NewReader(os.Stdin)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		var s string
		s, _ = rs.ReadString('\n')
		// s := fmt.Sscanf("str", format, ...)
		// s = s[:len(s)]
		if s[len(s)-1] == '\n' {
			s = s[:len(s)-1]
		}
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id] = tem2{a: w, b: k}
		id++
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

import (
	"fmt"
	"sort"
	"strings"
)

type tem1 struct {
	a map[string]int
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	// rs := bufio.NewReader(os.Stdin)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		var s string
		// s, _ = rs.ReadString('\n')
		fmt.Scanf("%s\n", &s)
		s = s[:len(s)-1]
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id] = tem2{a: w, b: k}
		id++
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

import (
	"fmt"
	"sort"
	"strings"
)

type tem1 struct {
	a, b string
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

type ByAge1 []tem1

func (a ByAge1) Len() int      { return len(a) }
func (a ByAge1) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByAge1) Less(i, j int) bool {
	return strings.Compare(a[i].a, a[j].a) == 1 || a[i].a == a[j].a && strings.Compare(a[i].b, a[j].b) == 1
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	st := make([]tem1, n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		st[i].a = hostname
		st[i].b = path
	}
	sort.Sort(ByAge1(st))
	ans := make([]tem2, 0)
	k := st[0].a
	st = append(st, tem1{"---", ""})
	keys := ""
	vv := ""
	for _, v := range st {
		if v.a == k && v.b == vv {
			vv = v.b
			continue
		}
		vv = v.b
		if v.a != k {
			ans = append(ans, tem2{keys, k})
			keys = v.b + "#"
			k = v.a
		} else {
			keys += v.b + "#"
		}
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	rs := bufio.NewReader(os.Stdin)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		s := ""
		for s == "" {
			s, _ = rs.ReadString('\n')
		}

		if s[len(s)-1] == '\n' {
			s = s[:len(s)-1]
		}
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id] = tem2{a: w, b: k}
		id++
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	rs := bufio.NewReader(os.Stdin)
	// ws := bufio.NewWriter(os.Stdout)
	// defer ws.Flush()
	st := make(map[string]tem1)
	s, _ := rs.ReadString('\n')
	s = s[:len(s)-1]
	n, _ := strconv.Atoi(s)
	for i := 0; i < n; i++ {
		s, _ := rs.ReadString('\n')
		s = s[:len(s)-1]
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := s[split_pos:]
		// fmt.Println(hostname, path)
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make(map[string][]string)
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "")
		if _, ok := ans[w]; !ok {
			ans[w] = make([]string, 0)
		}
		ans[w] = append(ans[w], k)
	}
	ansl := 0
	for _, v := range ans {
		if len(v) != 1 {
			ansl++
		}
	}
	fmt.Println(ansl)
	for _, v := range ans {
		if len(v) != 1 {
			for i, d := range v {
				if i != 0 {
					fmt.Printf(" ")
				}
				fmt.Printf("http://%s", d)
			}
			fmt.Println()
		}
	}

}

package main

import (
	"fmt"
	"sort"
	"strings"
)

type tem1 struct {
	a map[string]int
}

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if len(path) != 0 && path[len(path)-1] == '/' {
			path = path[:len(path)-1]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}

	ans := make(map[string][]string)
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "")
		if _, ok := ans[w]; !ok {
			ans[w] = make([]string, 0)
		}
		ans[w] = append(ans[w], k)
	}
	ansl := 0
	for _, v := range ans {
		if len(v) != 1 {
			ansl++
		}
	}
	fmt.Println(ansl)
	for _, v := range ans {
		if len(v) != 1 {
			for i, d := range v {
				if i != 0 {
					fmt.Printf(" ")
				}
				fmt.Printf("http://%s", d)
			}
			fmt.Println()
		}
	}

}

package main

import (
	"fmt"
	"sort"
	"strings"
)

type tem1 struct {
	a map[string]int
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}

	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, " ")
		ans[id].a = w
		ans[id].b = k
		id++
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"hash/fnv"
	"os"
	"sort"
	"strings"
)

type tem1 struct {
	a map[string]bool
	b string
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem(hostname string) tem1 {
	return tem1{make(map[string]bool), hostname}
}

func hash(s string) int {
	h := fnv.New32a()
	h.Write([]byte(s))
	return int(h.Sum32())
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	rs := bufio.NewReader(os.Stdin)
	st := make(map[int]tem1)
	// fmt.Println(time.Now())
	for i := 0; i < n; i++ {
		var s string
		s, _ = rs.ReadString('\n')
		s = s[:len(s)-1]
		// fmt.Scanf("%s\n", &s)
		// fmt.Scanln("%s", s)
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		key := hash(hostname)
		if _, ok := st[key]; !ok {
			st[key] = NewTem(hostname)
		}
		st[key].a[path] = true
	}
	// fmt.Println(time.Now())
	ans := make([]tem2, len(st))
	id := 0
	for _, v := range st {
		k := v.b
		keys := make([]string, len(v.a))
		idk := 0
		for key, _ := range v.a {
			keys[idk] = key
			idk++
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id].a = w
		ans[id].b = k
		id++
	}
	// fmt.Println(time.Now())
	sort.Sort(ByAge(ans))
	// fmt.Println(time.Now())
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	// fmt.Println(time.Now())
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	rs := bufio.NewReader(os.Stdin)
	// ws := bufio.NewWriter(os.Stdout)
	// defer ws.Flush()
	st := make(map[string]tem1)
	s, _ := rs.ReadString('\n')
	s = s[:len(s)-1]
	n, _ := strconv.Atoi(s)
	for i := 0; i < n; i++ {
		s, _ := rs.ReadString('\n')
		s = s[:len(s)-1]
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := s[split_pos:]
		// fmt.Println(hostname, path)
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make(map[string][]string)
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "")
		if _, ok := ans[w]; !ok {
			ans[w] = make([]string, 0)
		}
		ans[w] = append(ans[w], k)
	}
	ansl := 0
	for _, v := range ans {
		if len(v) != 1 {
			ansl++
		}
	}
	fmt.Println(ansl)
	for _, v := range ans {
		if len(v) != 1 {
			for _, d := range v {
				fmt.Printf("http://%s ", d)
			}
			fmt.Println()
		}
	}

}

package main

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

type tem1 struct {
	a map[string]bool
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]bool)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	rs := bufio.NewReader(os.Stdin)
	st := make(map[string]tem1)
	// fmt.Println(time.Now())
	for i := 0; i < n; i++ {
		var s string
		s, _ = rs.ReadString('\n')
		s = s[:len(s)-1]
		// fmt.Scanf("%s\n", &s)
		// fmt.Scanln("%s", s)
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		key := hostname
		if _, ok := st[key]; !ok {
			st[key] = NewTem()
		}
		st[key].a[path] = true
	}
	// fmt.Println(time.Now())
	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		keys := make([]string, len(v.a))
		idk := 0
		for key, _ := range v.a {
			keys[idk] = key
			idk++
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id].a = w
		ans[id].b = k
		id++
	}
	// fmt.Println(time.Now())
	sort.Sort(ByAge(ans))
	// fmt.Println(time.Now())
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	// fmt.Println(time.Now())
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	rs := bufio.NewReader(os.Stdin)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		s := ""
		for !strings.HasPrefix(s, "http://") {
			s, _ = rs.ReadString('\n')
		}

		if s[len(s)-1] == '\n' {
			s = s[:len(s)-1]
		}
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id] = tem2{a: w, b: k}
		id++
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	rs := bufio.NewReader(os.Stdin)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		var s string
		s, _ = rs.ReadString('\n')
		s = s[:len(s)-1]
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id].a = w
		ans[id].b = k
		id++
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

type tem2 struct {
	a, b string
}
type ByAge []tem2

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return strings.Compare(a[i].a, a[j].a) == 1 }

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	rs := bufio.NewReader(os.Stdin)
	st := make(map[string]tem1)
	for i := 0; i < n; i++ {
		s := ""
		for s == "" || s == "\n" {
			s, _ = rs.ReadString('\n')
		}

		if s[len(s)-1] == '\n' {
			s = s[:len(s)-1]
		}
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := ""
		if split_pos < len(s) {
			path = s[split_pos:]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make([]tem2, len(st))
	id := 0
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "#")
		ans[id] = tem2{a: w, b: k}
		id++
	}
	sort.Sort(ByAge(ans))
	ans = append(ans, tem2{"---", ""})
	last := 0
	ansl := 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				ansl++
			}
			last = i
		}
	}
	fmt.Println(ansl)
	last = 0
	for i := 1; i < len(ans); i++ {
		if ans[i].a != ans[i-1].a {
			if i-last != 1 {
				for j := last; j < i; j++ {
					fmt.Printf("http://%s ", ans[j].b)
				}
				fmt.Println()
			}

			last = i
		}
	}
}

package main

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

type tem1 struct {
	a map[string]int
}

func NewTem() tem1 {
	return tem1{make(map[string]int)}
}

func main() {
	rs := bufio.NewReader(os.Stdin)
	// ws := bufio.NewWriter(os.Stdout)
	// defer ws.Flush()
	st := make(map[string]tem1)
	s, _ := rs.ReadString('\n')
	s = s[:len(s)-1]
	n, _ := strconv.Atoi(s)
	for i := 0; i < n; i++ {
		s, _ := rs.ReadString('\n')
		s = s[:len(s)-1]
		if len(s) <= 7 {
			continue
		}
		s = s[7:]
		split_pos := len(s)
		for i, v := range s {
			if v == '/' {
				split_pos = i
				break
			}
		}
		hostname := s[:split_pos]
		path := s[split_pos:]
		if len(path) != 0 && path[len(path)-1] == '/' {
			path = path[:len(path)-1]
		}
		if _, ok := st[hostname]; !ok {
			st[hostname] = NewTem()
		}
		st[hostname].a[path] = 1
	}
	ans := make(map[string][]string)
	for k, v := range st {
		var keys []string
		for key, _ := range v.a {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		w := strings.Join(keys, "")
		if _, ok := ans[w]; !ok {
			ans[w] = make([]string, 0)
		}
		ans[w] = append(ans[w], k)
	}
	ansl := 0
	for _, v := range ans {
		if len(v) != 1 {
			ansl++
		}
	}
	fmt.Println(ansl)
	for _, v := range ans {
		if len(v) != 1 {
			for i, d := range v {
				if i != 0 {
					fmt.Printf(" ")
				}
				fmt.Printf("http://%s", d)
			}
			fmt.Println()
		}
	}

}

package main

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

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	snum := ReadInt32()
	pathcnt := 1
	allpaths := make(map[string]int)
	hostpaths := make(map[string]map[int]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := scanner.Text()
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[int]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		pi := allpaths[p]
		if pi == 0 {
			pi = pathcnt
			pathcnt++
			allpaths[p] = pi
		}
		paths[pi] = struct{}{}
		hostpaths[part[0]] = paths
	}

	if snum == len(allpaths) {
		writer.WriteString("0")
		return
	}
	allpaths = nil
	runtime.GC()
	maxbits := 0
	for pathcnt--; pathcnt > 0; pathcnt = pathcnt >> 1 {
		maxbits++
	}

	//sort paths
	groups := make(map[string][]string)
	for k, v := range hostpaths {
		pa := make([]int, 0, len(v))
		for p := range v {
			pa = append(pa, p)
		}
		sort.Ints(pa)
		var s uint64 = 0
		cnt := 64 / maxbits
		key := make([]byte, ((len(pa)+cnt)/cnt)*8)
		i := 0
		ki := 0
		for _, pn := range pa {
			s |= uint64(pn) << uint(i*maxbits)
			i++
			if i == cnt {
				for j := uint(0); j < 8; j++ {
					key[ki] = byte((s >> j * 8) & 0xff)
					ki++
				}
				s = 0
				i = 0
			}
		}
		if s != 0 {
			for j := uint(0); j < 8; j++ {
				key[ki] = byte((s >> j * 8) & 0xff)
				ki++
			}
		}
		hosts := groups[string(key)]
		hosts = append(hosts, k)
		groups[string(key)] = hosts
	}
	hostpaths = nil

	grcnt := 0
	for _, hosts := range groups {
		if len(hosts) > 1 {
			grcnt++
		}
	}
	writer.WriteString(strconv.Itoa(grcnt))
	for _, hosts := range groups {
		if len(hosts) > 1 {
			writer.WriteString("\n")
			for _, hn := range hosts {
				writer.WriteString("http://" + hn + " ")
			}
		}
	}
}

package main

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

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

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

func main() {
	defer writer.Flush()           // очищает буфер при выходе из функции main
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами
	snum := ReadInt32()
	hostpaths := make(map[string]map[string]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := scanner.Text()
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[string]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		paths[p] = struct{}{}
		hostpaths[part[0]] = paths
	}

	//sort paths
	hosts := make([]string, 0, len(hostpaths))
	paths := make([][]string, 0, len(hostpaths))
	for k, v := range hostpaths {
		pa := make([]string, 0, len(v))
		for p := range v {
			pa = append(pa, p)
		}
		sort.Strings(pa)
		hosts = append(hosts, k)
		paths = append(paths, pa)
	}

	//search equal path sets
	plen := len(paths)
	groups := []string{}
	for idx := 0; idx < plen-1 && paths[idx] != nil; idx++ {
		ilen := len(paths[idx])
		gexist := false
	loop:
		for i := idx + 1; i < plen; i++ {
			if paths[i] != nil && ilen == len(paths[i]) {
				for j := 0; j < ilen; j++ {
					if paths[idx][j] != paths[i][j] {
						break loop
					}
				}
				if !gexist {
					groups = append(groups, "http://"+hosts[idx])
					gexist = true
				}
				groups[len(groups)-1] += " http://" + hosts[i]
				paths[i] = nil
			}
		}
	}
	writer.WriteString(strconv.Itoa(len(groups)))
	for _, grs := range groups {
		writer.WriteString("\n" + grs)
	}
}

package main

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

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

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

func main() {
	defer writer.Flush()           // очищает буфер при выходе из функции main
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами
	snum := ReadInt32()
	hostpaths := make(map[string]map[string]struct{})
	//read input
	for i := 0; i < snum; i++ {
		scanner.Scan()
		line := scanner.Text()
		line = line[7:] //remove http://
		part := strings.SplitN(line, "/", 2)
		paths := hostpaths[part[0]]
		if paths == nil {
			paths = make(map[string]struct{})
		}
		p := ""
		if len(part) == 2 {
			if len(part[1]) == 0 {
				p = "/"
			} else {
				p = part[1]
			}
		}
		paths[p] = struct{}{}
		hostpaths[part[0]] = paths
	}

	//sort paths
	hosts := make([]string, 0, len(hostpaths))
	paths := make([][]string, 0, len(hostpaths))
	for k, v := range hostpaths {
		pa := make([]string, 0, len(v))
		for p := range v {
			pa = append(pa, p)
		}
		sort.Strings(pa)
		hosts = append(hosts, k)
		paths = append(paths, pa)
	}

	//search equal paths
	plen := len(paths)
	groups := []string{}
	for idx := 0; idx < plen-1; idx++ {
		ilen := len(paths[idx])
		gexist := false
	loop:
		for i := idx + 1; i < plen; i++ {
			if paths[i] != nil && ilen == len(paths[i]) {
				for j := 0; j < ilen; j++ {
					if paths[idx][j] != paths[i][j] {
						break loop
					}
				}
				if !gexist {
					groups = append(groups, "http://"+hosts[idx])
					gexist = true
				}
				groups[len(groups)-1] += " http://" + hosts[i]
				paths[i] = nil
			}
		}
	}
	writer.WriteString(strconv.Itoa(len(groups)) + "\n")
	for _, grs := range groups {
		writer.WriteString(grs + "\n")
	}
}


Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell $$$(0, 0)$$$. Robot can perform the following four kinds of operations:   U — move from $$$(x, y)$$$ to $$$(x, y + 1)$$$;  D — move from $$$(x, y)$$$ to $$$(x, y - 1)$$$;  L — move from $$$(x, y)$$$ to $$$(x - 1, y)$$$;  R — move from $$$(x, y)$$$ to $$$(x + 1, y)$$$. Vasya also has got a sequence of $$$n$$$ operations. Vasya wants to modify this sequence so after performing it the robot will end up in $$$(x, y)$$$.Vasya wants to change the sequence so the length of changed subsegment is minimum possible. This length can be calculated as follows: $$$maxID - minID + 1$$$, where $$$maxID$$$ is the maximum index of a changed operation, and $$$minID$$$ is the minimum index of a changed operation. For example, if Vasya changes RRRRRRR to RLRRLRL, then the operations with indices $$$2$$$, $$$5$$$ and $$$7$$$ are changed, so the length of changed subsegment is $$$7 - 2 + 1 = 6$$$. Another example: if Vasya changes DDDD to DDRD, then the length of changed subsegment is $$$1$$$. If there are no changes, then the length of changed subsegment is $$$0$$$. Changing an operation means replacing it with some operation (possibly the same); Vasya can't insert new operations into the sequence or remove them.Help Vasya! Tell him the minimum length of subsegment that he needs to change so that the robot will go from $$$(0, 0)$$$ to $$$(x, y)$$$, or tell him that it's impossible.

The first line contains one integer number $$$n~(1 \le n \le 2 \cdot 10^5)$$$ — the number of operations. The second line contains the sequence of operations — a string of $$$n$$$ characters. Each character is either U, D, L or R. The third line contains two integers $$$x, y~(-10^9 \le x, y \le 10^9)$$$ — the coordinates of the cell where the robot should end its path.

Print one integer — the minimum possible length of subsegment that can be changed so the resulting sequence of operations moves the robot from $$$(0, 0)$$$ to $$$(x, y)$$$. If this change is impossible, print $$$-1$$$.

NoteIn the first example the sequence can be changed to LULUU. So the length of the changed subsegment is $$$3 - 1 + 1 = 3$$$.In the second example the given sequence already leads the robot to $$$(x, y)$$$, so the length of the changed subsegment is $$$0$$$.In the third example the robot can't end his path in the cell $$$(x, y)$$$.

package main

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

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

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

type pos struct {
	x int
	y int
}

// globals

var end pos
var s string

// solution
func abs(i int) int {
	return int(math.Abs(float64(i)))
}

func (cur pos) String() string {
	return fmt.Sprintf("x: %v, y: %v\n", cur.x, cur.y)
}

func (cur *pos) update(mv rune, d int) {
	switch mv {
	case 'U':
		cur.y += d
	case 'D':
		cur.y -= d
	case 'L':
		cur.x -= d
	case 'R':
		cur.x += d
	}
}

func can(start, end pos, l int) bool {
	d := abs(start.x-end.x) + abs(start.y-end.y)
	if d%2 != l%2 {
		return false
	}
	return l >= d
}

func ok(length int) bool {
	p := pos{0, 0}
	for _, value := range s[length:] {
		p.update(value, 1)
	}

	l, r := 0, length

	for {
		if can(p, end, length) {
			return true
		}

		if r == len(s) {
			break
		}
		p.update(rune(s[l]), 1)
		l++
		p.update(rune(s[r]), -1)
		r++
	}

	return false
}

func solution() int {
	if !ok(len(s)) {
		return -1
	}

	l, r := -1, len(s)
	for r-l > 1 {
		mid := (l + r) / 2
		if ok(mid) {
			r = mid
		} else {
			l = mid
		}
	}
	return r
}

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

	var n, x, y int
	scanf("%d\n", &n)
	scanf("%s\n", &s)
	scanf("%d %d\n", &x, &y)
	end = pos{x, y}
	printf("%d\n", solution())
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	S := io.NextLine()
	X := io.NextInt()
	Y := io.NextInt()

	if N % 2 != Abs(X + Y) % 2 {
		io.Println(-1)
		return
	}

	L := 0
	R := N
	good := -1
	for L <= R {
		M := (L + R) >> 1
		if can(S, M, X, Y) {
			R = M - 1
			good = M
		} else {
			L = M + 1
		}
	}
	io.Println(good)

	// want := make(map[rune]int)
	// want['U'] = Max(0, dy - Y)
	// want['D'] = Max(0, Y - dy)
	// want['L'] = Max(0, X - dx)
	// want['R'] = Max(0, dx - X)
	// for k, v := range want {
	// 	if (v & 1) != 0 {
	// 		io.Println(-1)
	// 		return
	// 	}
	// 	want[k] >>= 1
	// }

	// A := []rune(S + "#")
	// lo := 0
	// hi := 0
	// have := make(map[rune]int)
	// best := N
	// for hi <= N {
	// 	if isGood(have, want) {
	// 		best = Min(best, hi - lo)
	// 		have[A[lo]]--
	// 		lo++
	// 	} else {
	// 		have[A[hi]]++
	// 		hi++
	// 	}
	// }
	// io.Println(best)
}

func can(S string, W, X, Y int) bool {
	N := len(S)
	x0, y0 := where(S[W:])
	A := []rune(S + "#")
	for i := W; i <= N; i++ {
		if Abs(x0 - X) + Abs(y0 - Y) <= W {
			return true
		}
		dxl, dyl := change(A[i-W])
		dxr, dyr := change(A[i])
		x0 += dxl - dxr
		y0 += dyl - dyr
	}
	return false
}

func where(S string) (int, int) {
	x := 0
	y := 0
	for _, c := range S {
		dx, dy := change(c)
		x += dx
		y += dy
	}
	return x, y
}

func change(c rune) (int, int) {
	switch c {
	case 'U':
		return 0, 1
	case 'D':
		return 0, -1
	case 'L':
		return -1, 0
	case 'R':
		return 1, 0
	}
	return 0, 0
}

func isGood(have, want map[rune]int) bool {
	for k, v := range want {
		if have[k] < v {
			return false
		}
	}
	return true
}

func Min(args ...int) int {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func Max(args ...int) int {
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

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

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

const (
	INF = 1234567890
)

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	S := io.NextLine()
	X := io.NextInt()
	Y := io.NextInt()

	if N%2 != Abs(X+Y)%2 {
		io.Println(-1)
		return
	}

	x0, y0 := where(S)
	if x0 == X && y0 == Y {
		io.Println(0)
		return
	}

	L := 0
	R := 0
	A := []rune(S + "#")
	best := INF
	for R <= N {
		if Abs(x0-X)+Abs(y0-Y) <= R-L {
			best = Min(best, R-L)
			dx, dy := change(A[L])
			x0 += dx
			y0 += dy
			L++
		} else {
			dx, dy := change(A[R])
			x0 -= dx
			y0 -= dy
			R++
		}
	}
	if best == INF {
		io.Println(-1)
	} else {
		io.Println(best)
	}
}

func Min(args ...int) int {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func where(S string) (int, int) {
	x := 0
	y := 0
	for _, c := range S {
		dx, dy := change(c)
		x += dx
		y += dy
	}
	return x, y
}

func change(c rune) (int, int) {
	switch c {
	case 'U':
		return 0, 1
	case 'D':
		return 0, -1
	case 'L':
		return -1, 0
	case 'R':
		return 1, 0
	}
	return 0, 0
}

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

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	S := io.NextLine()
	X := io.NextInt()
	Y := io.NextInt()

	if N % 2 != Abs(X + Y) % 2 {
		io.Println(-1)
		return
	}

	L := 0
	R := N
	good := -1
	for L <= R {
		M := (L + R) >> 1
		if can(S, M, X, Y) {
			R = M - 1
			good = M
		} else {
			L = M + 1
		}
	}
	io.Println(good)
}

func can(S string, W, X, Y int) bool {
	N := len(S)
	x0, y0 := where(S[W:])
	A := []rune(S + "#")
	for i := W; i <= N; i++ {
		if Abs(x0 - X) + Abs(y0 - Y) <= W {
			return true
		}
		dxl, dyl := change(A[i-W])
		dxr, dyr := change(A[i])
		x0 += dxl - dxr
		y0 += dyl - dyr
	}
	return false
}

func where(S string) (int, int) {
	x := 0
	y := 0
	for _, c := range S {
		dx, dy := change(c)
		x += dx
		y += dy
	}
	return x, y
}

func change(c rune) (int, int) {
	switch c {
	case 'U':
		return 0, 1
	case 'D':
		return 0, -1
	case 'L':
		return -1, 0
	case 'R':
		return 1, 0
	}
	return 0, 0
}

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

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

const (
	INF = 1234567890
)

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	S := io.NextLine()
	X := io.NextInt()
	Y := io.NextInt()

	if N%2 != Abs(X+Y)%2 {
		io.Println(-1)
		return
	}

	x0, y0 := where(S)
	if x0 == X && y0 == Y {
		io.Println(0)
		return
	}

	L := 0
	R := 0
	A := []rune(S + "#")
	best := INF
	for R <= N {
		if Abs(x0-X)+Abs(y0-Y) <= R-L {
			best = Min(best, R-L)
			dx, dy := change(A[L])
			x0 += dx
			y0 += dy
			L++
		} else {
			dx, dy := change(A[R])
			x0 -= dx
			y0 -= dy
			R++
		}
	}
	if best == INF {
		io.Println(-1)
	} else {
		io.Println(best)
	}
}

func Min(args ...int) int {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func can(S string, W, X, Y int) bool {
	N := len(S)
	x0, y0 := where(S[W:])
	A := []rune(S + "#")
	for i := W; i <= N; i++ {
		if Abs(x0-X)+Abs(y0-Y) <= W {
			return true
		}
		dxl, dyl := change(A[i-W])
		dxr, dyr := change(A[i])
		x0 += dxl - dxr
		y0 += dyl - dyr
	}
	return false
}

func where(S string) (int, int) {
	x := 0
	y := 0
	for _, c := range S {
		dx, dy := change(c)
		x += dx
		y += dy
	}
	return x, y
}

func change(c rune) (int, int) {
	switch c {
	case 'U':
		return 0, 1
	case 'D':
		return 0, -1
	case 'L':
		return -1, 0
	case 'R':
		return 1, 0
	}
	return 0, 0
}

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

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"fmt"
	"os"
)

var dirMap = map[rune][2]int{
	'R': [2]int{1, 0},
	'L': [2]int{-1, 0},
	'U': [2]int{0, 1},
	'D': [2]int{0, -1},
}

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

func checkValidation(length int, goal [2]int) bool {
	minLength := abs(goal[0]) + abs(goal[1])
	if minLength > length {
		return false
	}
	return (minLength % 2) == (length % 2)
}

func main() {
	n, s, x, y := 0, "", 0, 0
	fmt.Scan(&n, &s, &x, &y)
	if !checkValidation(n, [2]int{x, y}) {
		fmt.Println(-1)
		os.Exit(0)
	}
	sum := make([][2]int, n+1)
	for k, m := range s {
		dir := dirMap[m]
		sum[k+1] = [2]int{sum[k][0] + dir[0], sum[k][1] + dir[1]}
	}
	dX, dY := x-sum[n][0], y-sum[n][1]
	if dX == 0 && dY == 0 {
		fmt.Println(0)
		os.Exit(0)
	}

	l, r, length := 1, n, -1
	for l <= r {
		mid, works := (l+r)/2, false

		for i := 0; i <= (n - mid); i++ {
			sumX, sumY := sum[i+mid][0]-sum[i][0], sum[i+mid][1]-sum[i][1]
			newGoal := [2]int{sumX + dX, sumY + dY}
			if checkValidation(mid, newGoal) {
				works = true
				break
			}
		}
		if works {
			r, length = mid-1, mid
		} else {
			l = mid + 1
		}
	}
	fmt.Println(length)
}

package main

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

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

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

type pos struct {
	x int
	y int
}

// globals

var end pos
var s string

// solution
func abs(i int) int {
	return int(math.Abs(float64(i)))
}

func (cur pos) String() string {
	return fmt.Sprintf("x: %v, y: %v\n", cur.x, cur.y)
}

func (cur *pos) update(mv rune, d int) {
	switch mv {
	case 'U':
		cur.y += d
	case 'D':
		cur.y -= d
	case 'L':
		cur.x -= d
	case 'R':
		cur.x += d
	}
}

func can(start, end pos, len int) bool {
	d := abs(start.x-end.x) + abs(start.y-end.y)
	if d%2 != len%2 {
		return false
	}
	return len >= d
}

func ok(length int) bool {
	p := pos{0, 0}
	for _, value := range s[length:] {
		p.update(value, 1)
	}

	l, r := 0, length

	for {
		if can(p, end, length) {
			return true
		}

		if r == len(s) {
			break
		}
		p.update(rune(s[l]), 1)
		l++
		p.update(rune(s[r]), 1)
		r++
	}

	return false
}

func solution(len int) int {
	if !ok(len) {
		printf("cannot reach!\n")
		return -1
	}

	l, r := -1, len
	for r-l > 1 {
		mid := (l + r) / 2
		if ok(mid) {
			r = mid
		} else {
			l = mid
		}
	}
	return r
}

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

	var n, x, y int
	scanf("%d\n", &n)
	scanf("%s\n", &s)
	scanf("%d %d\n", &x, &y)
	end = pos{x, y}
	printf("%d\n", solution(len(s)))
}

package main

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

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

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

type pos struct {
	x int
	y int
}

// globals

var end pos
var s string

// solution
func abs(i int) int {
	return int(math.Abs(float64(i)))
}

func (cur pos) String() string {
	return fmt.Sprintf("x: %v, y: %v\n", cur.x, cur.y)
}

func (cur *pos) update(mv rune, d int) {
	switch mv {
	case 'U':
		cur.y += d
	case 'D':
		cur.y -= d
	case 'L':
		cur.x -= d
	case 'R':
		cur.x += d
	}
}

func can(start, end pos, len int) bool {
	d := abs(start.x-end.x) + abs(start.y-end.y)
	if d%2 != len%2 {
		return false
	}
	return len >= d
}

func ok(length int) bool {
	p := pos{0, 0}
	for _, value := range s[length:] {
		p.update(value, 1)
	}

	l, r := 0, length

	for {
		if can(p, end, length) {
			return true
		}

		if r == len(s) {
			break
		}
		p.update(rune(s[l]), 1)
		l++
		p.update(rune(s[r]), 1)
		r++
	}

	return false
}

func solution(len int) int {
	if !ok(len) {
		return -1
	}

	l, r := -1, len
	for r-l > 1 {
		mid := (l + r) / 2
		if ok(mid) {
			r = mid
		} else {
			l = mid
		}
	}
	return r
}

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

	var n, x, y int
	scanf("%d\n", &n)
	scanf("%s\n", &s)
	scanf("%d %d\n", &x, &y)
	end = pos{x, y}
	printf("%d\n", solution(len(s)))
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	S := io.NextLine()
	X := io.NextInt()
	Y := io.NextInt()

	if N % 2 != Abs(X + Y) % 2 {
		io.Println(-1)
		return
	}

	L := 0
	R := N
	good := N
	for L <= R {
		M := (L + R) >> 1
		if can(S, M, X, Y) {
			R = M - 1
			good = M
		} else {
			L = M + 1
		}
	}
	io.Println(good)

	// want := make(map[rune]int)
	// want['U'] = Max(0, dy - Y)
	// want['D'] = Max(0, Y - dy)
	// want['L'] = Max(0, X - dx)
	// want['R'] = Max(0, dx - X)
	// for k, v := range want {
	// 	if (v & 1) != 0 {
	// 		io.Println(-1)
	// 		return
	// 	}
	// 	want[k] >>= 1
	// }

	// A := []rune(S + "#")
	// lo := 0
	// hi := 0
	// have := make(map[rune]int)
	// best := N
	// for hi <= N {
	// 	if isGood(have, want) {
	// 		best = Min(best, hi - lo)
	// 		have[A[lo]]--
	// 		lo++
	// 	} else {
	// 		have[A[hi]]++
	// 		hi++
	// 	}
	// }
	// io.Println(best)
}

func can(S string, W, X, Y int) bool {
	N := len(S)
	x0, y0 := where(S[W:])
	A := []rune(S + "#")
	for i := W; i <= N; i++ {
		if Abs(x0 - X) + Abs(y0 - Y) <= W {
			return true
		}
		dxl, dyl := change(A[i-W])
		dxr, dyr := change(A[i])
		x0 += dxl - dxr
		y0 += dyl - dyr
	}
	return false
}

func where(S string) (int, int) {
	x := 0
	y := 0
	for _, c := range S {
		dx, dy := change(c)
		x += dx
		y += dy
	}
	return x, y
}

func change(c rune) (int, int) {
	switch c {
	case 'U':
		return 0, 1
	case 'D':
		return 0, -1
	case 'L':
		return -1, 0
	case 'R':
		return 1, 0
	}
	return 0, 0
}

func isGood(have, want map[rune]int) bool {
	for k, v := range want {
		if have[k] < v {
			return false
		}
	}
	return true
}

func Min(args ...int) int {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func Max(args ...int) int {
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

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

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	S := io.NextLine()
	X := io.NextInt()
	Y := io.NextInt()

	dx := 0
	dy := 0
	for _, c := range S {
		switch c {
		case 'U':
			dy++
		case 'D':
			dy--
		case 'L':
			dx--
		case 'R':
			dx++
		}
	}

	if dx == X && dy == Y {
		io.Println(0)
		return
	}

	want := make(map[rune]int)
	want['U'] = Max(0, dy - Y)
	want['D'] = Max(0, Y - dy)
	want['L'] = Max(0, X - dx)
	want['R'] = Max(0, dx - X)
	for k, v := range want {
		if (v & 1) != 0 {
			io.Println(-1)
			return
		}
		want[k] >>= 1
	}

	A := []rune(S + "#")
	lo := 0
	hi := 0
	have := make(map[rune]int)
	best := N
	for hi <= N {
		if isGood(have, want) {
			best = Min(best, hi - lo)
			have[A[lo]]--
			lo++
		} else {
			have[A[hi]]++
			hi++
		}
	}
	io.Println(best)
}

func isGood(have, want map[rune]int) bool {
	for k, v := range want {
		if have[k] < v {
			return false
		}
	}
	return true
}

func Min(args ...int) int {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func Max(args ...int) int {
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}


You are given an array $$$a$$$ of size $$$n$$$.You can perform the following operation on the array:   Choose two different integers $$$i, j$$$ $$$(1 \leq i < j \leq n$$$), replace $$$a_i$$$ with $$$x$$$ and $$$a_j$$$ with $$$y$$$. In order not to break the array, $$$a_i | a_j = x | y$$$ must be held, where $$$|$$$ denotes the bitwise OR operation. Notice that $$$x$$$ and $$$y$$$ are non-negative integers. Please output the minimum sum of the array you can get after using the operation above any number of times.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \leq t \leq 1000)$$$. Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ $$$(2 \leq n \leq 100)$$$ — the size of array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots ,a_n$$$ $$$(0 \leq a_i < 2^{30})$$$.

For each test case, print one number in a line — the minimum possible sum of the array.

NoteIn the first example, you can perform the following operations to obtain the array $$$[1, 0, 2]$$$:1. choose $$$i = 1, j = 2$$$, change $$$a_1 = 1$$$ and $$$a_2 = 2$$$, it's valid since $$$1 | 3 = 1 | 2$$$. The array becomes $$$[1, 2, 2]$$$.2. choose $$$i = 2, j = 3$$$, change $$$a_2 = 0$$$ and $$$a_3 = 2$$$, it's valid since $$$2 | 2 = 0 | 2$$$. The array becomes $$$[1, 0, 2]$$$.We can prove that the minimum sum is $$$1 + 0 + 2 = 3$$$In the second example, We don't need any operations.

package main

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

func main() {
	var testcase int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer func(out *bufio.Writer) {
		err := out.Flush()
		if err != nil {

		}
	}(out)

	_, err := fmt.Fscanf(in, "%d\n", &testcase)
	if err != nil {
		println("aaaaa")
		return
	}
	println(testcase)

	for i := 0; i < testcase; i++ {
		var n int
		_, err = fmt.Fscanf(in, "%d\n", &n)
		if err != nil {
			return
		}
		arr := make([]int, n)
		result := 0
		for j := 0; j < n; j++ {
			_, err = fmt.Fscanf(in, "%d", &arr[j])
			if err != nil {
				return
			}
			result |= arr[j]
		}
		_, err = fmt.Fscanf(in, "\n")
		if err != nil {
			return
		}
		_, err = fmt.Fprintln(out, result)
		if err != nil {
			return
		}
	}
}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var n int
		fmt.Fscan(in, &n)
		ans := 0
		for i := 0; i < n; i++ {
			var x int
			fmt.Fscan(in, &x)
			ans |= x
		}
		fmt.Fprintln(out, ans)
		t--
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var sum int
		for j:=0;j<n;j++ {
			var x int
			fmt.Fscan(in,&x)
			sum |= x
		}
		fmt.Fprintln(out,sum)
	}
}

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)
		s := 0
		var v int
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &v)
			s = s | v
		}
		fmt.Println(s)
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var n int
	scan(&n)
	a := make([]int, n)
	or := 0
	for i := 0; i < n; i++ {
		scan(&a[i])
		or = or | a[i]
	}
	printf("%d\n", or)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

type CF1635A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1635A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1635A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1635A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1635A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1635A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1635A
Date: 17/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1635/A
Problem: CF1635A
**/
func (in *CF1635A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		ans := 0
		for i := 0; i < n; i++ {
			ans |= in.NextInt()
		}
		fmt.Println(ans)
	}
}

func NewCF1635A(r *bufio.Reader) *CF1635A {
	return &CF1635A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1635A(bufio.NewReader(os.Stdin)).Run()
}

//nolint
package main

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

//{
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 print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

//}

func Solve() {
	var n, tp int
	scan(&n)
	result := 0
	for i := 0; i < n; i++ {
		scan(&tp)
		result |= tp
	}
	println(result)
}

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 i := 0; i < t; i ++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]int, 0, n)
		for j := 0; j < n; j ++ {
			var num int
			fmt.Fscan(in, &num)
			arr = append(arr, num)
		}
		// solve
		num := 0
		for _, v := range arr {
			num = num | v
		}
		fmt.Fprintln(out, num)
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	t := readInt(in)
	for ; t != 0; t-- {
		solve()
	}
}

func solve() {
	n := readInt(in)
	a := readArrInt(in)
	res := 0
	n += 1
	for _, x := range a {
		res |= x
	}
	fmt.Println(res)
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		p, ans := 0, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			ans |= p
		}
		fmt.Fprintln(w, ans)
	}
	w.Flush()
}

func main() {
	solve()
}

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 int
		fmt.Fscan(in, &n)

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

		sum := arr[0]
		for i := 1; i < n; i++ {
			sum |= arr[i]
		}

		fmt.Fprintln(out, sum)
	}
}

package main

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

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

	var t int
	Fscan(in, &t)
	var solve func()
	solve = func() {

		var n int
		Fscan(in, &n)
		a := make([]int, n)
		sum := 0
		for j := 0; j < n; j++ {
			Fscan(in, &a[j])
			sum |= a[j]
		}
		Fprintln(out, sum)

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

}

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

package main

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

/*

 */

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		allOr := int64(0)

		for i := 0; i < n; i++ {
			var num int64
			scanf("%d", &num)

			allOr |= num
		}
		scanf("\n")

		fmt.Fprintln(writer, allOr)
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

func main() {
	var testcase int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer func(out *bufio.Writer) {
		err := out.Flush()
		if err != nil {

		}
	}(out)

	_, err := fmt.Fscanf(in, "%d", &testcase)
	if err != nil {
		return
	}
	for i := 0; i < testcase; i++ {
		var n int
		_, err = fmt.Fscanf(in, "%d", &n)
		if err != nil {
			return
		}
		arr := make([]int, n)
		result := 0
		for j := 0; j < n; j++ {
			_, err = fmt.Fscanf(in, "%d", &arr[j])
			if err != nil {
				return
			}
			result |= arr[j]
		}
		_, err = fmt.Fprintln(out, result)
		if err != nil {
			return
		}
	}
}

package main

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

func main() {
	var testcase int
	out := bufio.NewWriter(os.Stdout)
	_, err := fmt.Scanf("%d", &testcase)
	if err != nil {
		return
	}
	for i := 0; i < testcase; i++ {
		var n int
		_, err = fmt.Scanf("%d", &n)
		if err != nil {
			return
		}
		arr := make([]int, n)
		result := 0
		for j := 0; j < n; j++ {
			_, err = fmt.Scanf("%d", &arr[j])
			if err != nil {
				return
			}
			result |= arr[j]
		}
		fmt.Fprintln(out, result)
	}
}

package main

import (
	"fmt"
)

func main() {
	var testcase int
	_, err := fmt.Scanf("%d", &testcase)
	if err != nil {
		return
	}
	for i := 0; i < testcase; i++ {
		var n int
		_, err = fmt.Scanf("%d", &n)
		if err != nil {
			return
		}
		arr := make([]int, n)
		result := 0
		for j := 0; j < n; j++ {
			_, err = fmt.Scanf("%d", &arr[j])
			if err != nil {
				return
			}
			result |= arr[j]
		}
		println(result)
	}

}

package main

import (
	"fmt"
)

func main() {
	var testcase int
	_, err := fmt.Scanf("%d", &testcase)
	if err != nil {
		return
	}
	for i := 0; i < testcase; i++ {
		var n int
		_, err = fmt.Scanf("%d", &n)
		if err != nil {
			return
		}
		arr := make([]int, n)
		result := 0
		for j := 0; j < n; j++ {
			_, err = fmt.Scanf("%d", &arr[j])
			if err != nil {
				return
			}
			result |= arr[j]
		}
		fmt.Printf("%d\n",result)
	}

}

package main

import (
	"fmt"
)

func main() {
	var testcase int
	_, err := fmt.Scanf("%d", &testcase)
	if err != nil {
		return
	}
	for i := 0; i < testcase; i++ {
		var n int
		_, err = fmt.Scanf("%d", &n)
		if err != nil {
			return
		}
		arr := make([]int, n)
		result := 0
		for j := 0; j < n; j++ {
			_, err = fmt.Scanf("%d", &arr[j])
			if err != nil {
				return
			}
			result |= arr[j]
		}
		fmt.Println(result)
	}

}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		sum:=0
		for j:=0;j<n;j++ {
			var x int
			fmt.Fscan(in,&x)
			sum+=x
		}
		if sum%2 == 0 {
		fmt.Fprintln(out,sum/2)
		} else {
			fmt.Fprintln(out,sum)
		}
	}
}