The princess is going to escape the dragon's cave, and she needs to plan it carefully.The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess noticed that the dragon is very greedy and not too smart. To delay him, the princess decides to borrow a couple of bijous from his treasury. Once the dragon overtakes the princess, she will drop one bijou to distract him. In this case he will stop, pick up the item, return to the cave and spend f hours to straighten the things out in the treasury. Only after this will he resume the chase again from the very beginning.The princess is going to run on the straight. The distance between the cave and the king's castle she's aiming for is c miles. How many bijous will she need to take from the treasury to be able to reach the castle? If the dragon overtakes the princess at exactly the same moment she has reached the castle, we assume that she reached the castle before the dragon reached her, and doesn't need an extra bijou to hold him off.

The input data contains integers vp, vd, t, f and c, one per line (1 ≤ vp, vd ≤ 100, 1 ≤ t, f ≤ 10, 1 ≤ c ≤ 1000).

Output the minimal number of bijous required for the escape to succeed.

NoteIn the first case one hour after the escape the dragon will discover it, and the princess will be 1 mile away from the cave. In two hours the dragon will overtake the princess 2 miles away from the cave, and she will need to drop the first bijou. Return to the cave and fixing the treasury will take the dragon two more hours; meanwhile the princess will be 4 miles away from the cave. Next time the dragon will overtake the princess 8 miles away from the cave, and she will need the second bijou, but after this she will reach the castle without any further trouble.The second case is similar to the first one, but the second time the dragon overtakes the princess when she has reached the castle, and she won't need the second bijou.

// 148B
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, e, s, i float64
	fmt.Scan(&a, &b, &c, &d, &e)
	if a < b {
		s = b * a * c / (b - a)
		for i = 0; s < e; i++ {
			s = b * (s + a*(s/b+d)) / (b - a)
		}
	}
	fmt.Println(i)
}

package main

import "fmt"

func main() {
  var p, d, t, f, c float32
  fmt.Scan(&p, &d, &t, &f, &c)
  var k, x, r float32
  k = d - p
  x = p * t
  r = 0
  if k > 0 {
    x += x / k * p
    for x < c {
      r++
      x += p * (x / d + f)
      x += x / k * p
    }
  }
  fmt.Println(r)
}


Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little bears, wait a little, I want to make your pieces equal" "Come off it fox, how are you going to do that?", the curious bears asked. "It's easy", said the fox. "If the mass of a certain piece is divisible by two, then I can eat exactly a half of the piece. If the mass of a certain piece is divisible by three, then I can eat exactly two-thirds, and if the mass is divisible by five, then I can eat four-fifths. I'll eat a little here and there and make the pieces equal". The little bears realize that the fox's proposal contains a catch. But at the same time they realize that they can not make the two pieces equal themselves. So they agreed to her proposal, but on one condition: the fox should make the pieces equal as quickly as possible. Find the minimum number of operations the fox needs to make pieces equal.

The first line contains two space-separated integers a and b (1 ≤ a, b ≤ 109).

If the fox is lying to the little bears and it is impossible to make the pieces equal, print -1. Otherwise, print the required minimum number of operations. If the pieces of the cheese are initially equal, the required number is 0.

package main

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

func abs(a int)int {
	if a<0 {
		a*=(-1)
	}
	return a
}
func main() {
    var a,b int
    var na,nb [10]int
    fmt.Scan(&a,&b)

    for ;a%2==0; {
    	a/=2
    	na[0]++
    }
    for ;a%3==0; {
    	a/=3
    	na[1]++
    }
    for ;a%5==0; {
    	a/=5
    	na[2]++
    }
    for ;b%2==0; {
    	b/=2
    	nb[0]++
    }
    for ;b%3==0; {
    	b/=3
    	nb[1]++
    }
    for ;b%5==0; {
    	b/=5
    	nb[2]++
    }
    if a!=b {
    	fmt.Println("-1")
    } else {
        ans:=0
        for i:=0;i<3;i++ {
        	ans+=abs(na[i]-nb[i])
        }
        fmt.Println(ans)
    }
}

package main

import "fmt"

func main() {
    abs := func(a int) int { if a < 0 { return -a } else { return a } }

    var a,b,a2,a3,a5,b2,b3,b5 int
    fmt.Scan(&a,&b)
    for ; a%2 == 0; a/=2 { a2++ }
    for ; a%3 == 0; a/=3 { a3++ }
    for ; a%5 == 0; a/=5 { a5++ }
    for ; b%2 == 0; b/=2 { b2++ }
    for ; b%3 == 0; b/=3 { b3++ }
    for ; b%5 == 0; b/=5 { b5++ }
    if a != b { fmt.Println(-1) } else { fmt.Println(abs(a2-b2)+abs(a3-b3)+abs(a5-b5)) }
}

//371B
package main
import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d int
	var i, j, k, l, m, n, x float64
	fmt.Scan(&a, &b)
	for a!=0 {
		if a%2==0 {
			a=a/2
			i++
		} else if a%3==0 {
			a=a-(a/3*2)
			j++
		} else if a%5==0 {
			a=a-(a/5*4)
			k++
		} else {
			c=a
			break
		}
	}
	for b!=0 {
		if b%2==0 {
			b=b/2
			l++
		} else if b%3==0 {
			b=b-(b/3*2)
			m++
		} else if b%5==0 {
			b=b-(b/5*4)
			n++
		} else {
			d=b
			break
		}
	}
	if c==d {
		x=math.Abs(i-l)+math.Abs(j-m)+math.Abs(k-n)
		fmt.Println(x)
	} else {
		fmt.Println("-1")
	}
}

// 371B
package main

import (
	"fmt"
)

var x, y, k1, k2, ans int

func kol(d int) int {
	k1 = 0
	k2 = 0
	for x%d == 0 {
		x /= d
		k1++
	}
	for y%d == 0 {
		y /= d
		k2++
	}
	if k1 > k2 {
		return k1 - k2
	} else {
		return k2 - k1
	}
}

func main() {
	fmt.Scan(&x, &y)
	ans = kol(2) + kol(3) + kol(5)
	if x == y {
		fmt.Print(ans)
	} else {
		fmt.Print(-1)
	}
}

// 371B-mic
package main

import (
	"fmt"
)

func gcd(x, y int) int {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func main() {
	var a, b, k int
	fmt.Scan(&a, &b)
	x := gcd(a, b)
	if x != 1 {
		a /= x
		b /= x
	}
	for {
		if a == b {
			break
		}
		if a < b {
			a, b = b, a
		} else if a > b && a%2 != 0 && a%3 != 0 && a%5 != 0 {
			b, a = a, b
		}
		if a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {
			fmt.Println("-1")
			return
		}
		if a%2 == 0 {
			a /= 2
			k++
		} else if a%3 == 0 {
			a /= 3
			k++
		} else if a%5 == 0 {
			a /= 5
			k++
		}
	}
	fmt.Println(k)
}

package main

import "fmt"

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func div(n, d int) (m, ans int) {
	ans = 0
	m = n
	for m % d == 0 {
		m /= d
		ans += 1
	}
	return
}

func main() {
	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)
	a, a2 := div(a, 2)
	a, a3 := div(a, 3)
	a, a5 := div(a, 5)
	b, b2 := div(b, 2)
	b, b3 := div(b, 3)
	b, b5 := div(b, 5)
	ans := abs(a2 - b2) + abs(a3 - b3) + abs(a5 - b5)
	if a != b {
		ans = -1
	}
	fmt.Println(ans)
}

package main

import "fmt"

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func div(n *int, d int) int {
	ans := 0
	for (*n) % d == 0 {
		(*n) /= d
		ans += 1
	}
	return ans
}

func main() {
	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)
	a2 := div(&a, 2)
	a3 := div(&a, 3)
	a5 := div(&a, 5)
	b2 := div(&b, 2)
	b3 := div(&b, 3)
	b5 := div(&b, 5)
	ans := abs(a2 - b2) + abs(a3 - b3) + abs(a5 - b5)
	if a != b {
		ans = -1
	}
	fmt.Println(ans)
}

// 371B-mic
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b)
	for {
		if a == b {
			break
		}
		if a < b {
			a, b = b, a
		} else {
			b, a = a, b
		}
		if a%2 == 0 {
			a /= 2
			k++
		} else if a%3 == 0 {
			a /= 3
			k++
		} else if a%5 == 0 {
			a /= 5
			k++
		}
		if a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {
			break
		}
	}
	fmt.Println(k)
}

// 371B-mic
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b)
	for {
		if a == b {
			break
		}
		if a < b {
			a, b = b, a
		} else {
			b, a = a, b
		}
		if a%2 == 0 {
			a /= 2
			k++
		} else if a%3 == 0 {
			a /= 3
			k++
		} else if a%5 == 0 {
			a /= 5
			k++
		}
		if a%2 != 0 && a%3 != 0 && a%5 != 0 && a != b {
			fmt.Println("-1")
			return
		}
	}
	fmt.Println(k)
}

// 371B-mic
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b)
	for {
		if a == b {
			break
		}
		if a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {
			fmt.Println("-1")
			return
		}
		if a < b {
			a, b = b, a
		} else {
			b, a = a, b
		}
		if a%2 == 0 {
			a /= 2
			k++
		} else if a%3 == 0 {
			a /= 3
			k++
		} else if a%5 == 0 {
			a /= 5
			k++
		}
	}
	fmt.Println(k)
}

// 371B-mic
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b)
	for {
		if a < b {
			a, b = b, a
		} else {
			b, a = a, b
		}
		if a%2 == 0 {
			a /= 2
			k++
		} else if a%3 == 0 {
			a /= 3
			k++
		} else if a%5 == 0 {
			a /= 5
			k++
		}
		if a == b {
			break
		}
		if a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {
			fmt.Println("-1")
			return
		}
	}
	fmt.Println(k)
}


Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations:  multiply the current number by 2 (that is, replace the number x by 2·x);  append the digit 1 to the right of current number (that is, replace the number x by 10·x + 1). You need to help Vasily to transform the number a into the number b using only the operations described above, or find that it is impossible.Note that in this task you are not required to minimize the number of operations. It suffices to find any way to transform a into b.

The first line contains two positive integers a and b (1 ≤ a < b ≤ 109) — the number which Vasily has and the number he wants to have.

If there is no way to get b from a, print "NO" (without quotes). Otherwise print three lines. On the first line print "YES" (without quotes). The second line should contain single integer k — the length of the transformation sequence. On the third line print the sequence of transformations x1, x2, ..., xk, where:   x1 should be equal to a,  xk should be equal to b,  xi should be obtained from xi - 1 using any of two described operations (1 < i ≤ k).  If there are multiple answers, print any of them.

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

var a, b int
var trace map[int]int

func dfs(x int) bool {
	if x == b {
		return true
	}
	if x <= b/2 {
		y := x * 2
		_, found := trace[y]
		if !found {
			trace[y] = x
			if dfs(y) {
				return true
			}
		}
	}
	if x <= (b-1)/10 {
		y := x*10 + 1
		_, found := trace[y]
		if !found {
			trace[y] = x
			if dfs(y) {
				return true
			}
		}
	}
	return false
}

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	fmt.Fscanf(bufin, "%d %d\n", &a, &b)
	trace = make(map[int]int)

	trace[a] = a
	if dfs(a) {
		fmt.Fprintf(bufout, "YES\n")

		var res []int
		for b != a {
			res = append(res, b)
			b = trace[b]
		}
		res = append(res, a)

		n := len(res)
		fmt.Fprintf(bufout, "%d\n", n)
		for i := n - 1; i >= 0; i-- {
			fmt.Fprintf(bufout, "%d ", res[i])
		}
	} else {
		fmt.Fprintf(bufout, "NO\n")
	}

}

package main

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

// Node to store in queue
type Node struct {
	value int64
	prev  *Node
}

// NewNode to create node with value is n.
func NewNode(n int64) *Node {
	return &Node{
		value: n,
	}
}

func main() {
	var stdin *bufio.Reader
	// LOCAL
	f, _ := os.Open("input.txt")
	stdin = bufio.NewReader(f)

	// ONLINE JUDGE
	stdin = bufio.NewReader(os.Stdin)

	var a, b int64
	fmt.Fscan(stdin, &a, &b)

	var queue = []*Node{NewNode(a)}
	var seen = make(map[int64]bool)
	for len(queue) > 0 {
		var top = queue[0]
		queue = queue[1:]
		seen[top.value] = true

		if top.value == b {
			// Trace
			fmt.Println("YES")
			var res []int64
			for n := top; n != nil; n = n.prev {
				res = append(res, n.value)
			}
			fmt.Println(len(res))
			for i := len(res) - 1; i >= 0; i-- {
				fmt.Print(res[i], " ")
			}

			return
		}

		if top.value*2 <= b && !seen[top.value*2] {
			var n = NewNode(top.value * 2)
			n.prev = top
			queue = append(queue, n)
		}
		if top.value*10+1 <= b && !seen[top.value*10+1] {
			var n = NewNode(top.value*10 + 1)
			n.prev = top
			queue = append(queue, n)
		}

	}

	fmt.Println("NO")

}

package main

import "fmt"

func main() {
    var a, b, steps int
    t := make([]int, 0)
    fmt.Scanf("%d %d", &a, &b)
    t = append(t, b)
    steps = steps + 1
    for {
        if a == b || b < a {
            break
        } else {
            if b % 2 == 0 {
                b = b / 2
                t = append(t, b)
                steps = steps + 1
            } else if (b - 1) % 10 == 0 {
                b = (b - 1) / 10
                t = append(t, b)
                steps = steps + 1
            } else {
                break
            }
        }
    }
    if a == b {
        fmt.Printf("YES\n")
        fmt.Printf("%d\n", steps)
        for idx := len(t) - 1; idx >= 0; idx--{
            if idx == 0 {
                fmt.Printf("%d\n", t[idx])
            } else {
                fmt.Printf("%d ", t[idx])
            }
        }
    } else {
        fmt.Printf("NO\n")
    }
}

package main

import (
	"fmt"
	"os"
)

type node struct {
	value int
	count int
	prev  *node
}

func newNode(n int) *node {
	return &node{
		value: n,
	}
}

func main() {
	seen := make(map[int]bool)
	var a, b int
	fmt.Fscanf(os.Stdin, "%d %d", &a, &b)
	queue := []*node{newNode(b)}

	for len(queue) > 0 {
		curr := queue[0]
		queue = queue[1:]

		if curr.value == a {
			fmt.Println("YES")
			fmt.Println(curr.count + 1)
			for n := curr; n != nil; n = n.prev {
				fmt.Printf("%d ", n.value)
			}
			fmt.Println()
			return
		}
		if curr.value < a || seen[curr.value] {
			continue
		}
		seen[curr.value] = true

		if curr.value%2 == 0 {
			n := newNode(curr.value >> 1)
			n.count = curr.count + 1
			n.prev = curr
			queue = append(queue, n)
		}
		if curr.value%10 == 1 {
			n := newNode(curr.value / 10)
			n.count = curr.count + 1
			n.prev = curr
			queue = append(queue, n)
		}
	}
	fmt.Println("NO")
}

package main

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

// Node to store in queue
type Node struct {
	value int64
	prev  *Node
}

// NewNode to create node with value is n.
func NewNode(n int64) *Node {
	return &Node{
		value: n,
	}
}

func main() {
	var stdin *bufio.Reader
	// LOCAL
	f, _ := os.Open("input.txt")
	stdin = bufio.NewReader(f)

	// ONLINE JUDGE
	// stdin = bufio.NewReader(os.Stdin)

	var a, b int64
	fmt.Fscan(stdin, &a, &b)

	var queue = []*Node{NewNode(a)}
	var seen = make(map[int64]bool)
	for len(queue) > 0 {
		var top = queue[0]
		queue = queue[1:]
		seen[top.value] = true

		if top.value == b {
			// Trace
			fmt.Println("YES")
			var res []int64
			for n := top; n != nil; n = n.prev {
				res = append(res, n.value)
			}
			fmt.Println(len(res))
			for i := len(res) - 1; i >= 0; i-- {
				fmt.Print(res[i], " ")
			}

			return
		}

		if top.value*2 <= b && !seen[top.value*2] {
			var n = NewNode(top.value * 2)
			n.prev = top
			queue = append(queue, n)
		}
		if top.value*10+1 <= b && !seen[top.value*10+1] {
			var n = NewNode(top.value*10 + 1)
			n.prev = top
			queue = append(queue, n)
		}

	}

	fmt.Println("NO")

}

package main

import "fmt"

func main() {
    var a, b, steps int
    t := make([]int, 0)
    fmt.Scanf("%d %d", &a, &b)
    fmt.Println(a, b)
    t = append(t, b)
    for {
        if a == b {
            break
        } else {
            if b % 2 == 0 {
                b = b / 2
                t = append(t, b)
                steps = steps + 1
            } else if (b - 1) % 10 == 0 {
                b = (b - 1) / 10
                t = append(t, b)
                steps = steps + 1
            } else {
                break
            }
        }
    }
    if a == b {
        fmt.Printf("YES\n")
        fmt.Printf("%d\n", steps)
        for idx := len(t) - 1; idx >= 0; idx--{
            if idx == 0 {
                fmt.Printf("%d\n", t[idx])
            } else {
                fmt.Printf("%d ", t[idx])
            }
        }
    } else {
        fmt.Printf("No\n")
    }
}

package main

import "fmt"

func main() {
    var a, b int
    fmt.Scanf("%d %d", &a, &b)
    fmt.Println(a, b)
}

package main

import "fmt"

func main() {
    var a, b, steps int
    t := make([]int, 0)
    fmt.Scanf("%d %d", &a, &b)
    t = append(t, b)
    for {
        if a == b {
            break
        } else {
            if b % 2 == 0 {
                b = b / 2
                t = append(t, b)
                steps = steps + 1
            } else if (b - 1) % 10 == 0 {
                b = (b - 1) / 10
                t = append(t, b)
                steps = steps + 1
            } else {
                break
            }
        }
    }
    if a == b {
        fmt.Printf("YES\n")
        fmt.Printf("%d\n", steps)
        for idx := len(t) - 1; idx >= 0; idx--{
            if idx == 0 {
                fmt.Printf("%d\n", t[idx])
            } else {
                fmt.Printf("%d ", t[idx])
            }
        }
    } else {
        fmt.Printf("No\n")
    }
}

package main

import "fmt"

func main() {
    var a, b, steps int
    t := make([]int, 0)
    fmt.Scanf("%d %d", &a, &b)
    t = append(t, b)
    steps = steps + 1
    for {
        if a == b || b < a {
            break
        } else {
            if b % 2 == 0 {
                b = b / 2
                t = append(t, b)
                steps = steps + 1
            } else if (b - 1) % 10 == 0 {
                b = (b - 1) / 10
                t = append(t, b)
                steps = steps + 1
            } else {
                break
            }
        }
    }
    if a == b {
        fmt.Printf("YES\n")
        fmt.Printf("%d\n", steps)
        for idx := len(t) - 1; idx >= 0; idx--{
            if idx == 0 {
                fmt.Printf("%d\n", t[idx])
            } else {
                fmt.Printf("%d ", t[idx])
            }
        }
    } else {
        fmt.Printf("No\n")
    }
}

package main

import "fmt"

func main() {
    var a, b, steps int
    t := make([]int, 0)
    fmt.Scanf("%d %d", &a, &b)
    fmt.Println(a, b)
    t = append(t, b)
    for {
        if a == b {
            break
        } else {
            if b % 2 == 0 {
                b = b / 2
                t = append(t, b)
                steps = steps + 1
            } else if (b - 1) % 10 == 0 {
                b = (b - 1) / 10
                t = append(t, b)
                steps = steps + 1
            } else {
                break
            }
        }
    }
    if a == b {
        fmt.Printf("YES\n")
        fmt.Printf("%d\n", steps)
        for idx, val := range t {
            if idx == len(t) - 1 {
                fmt.Printf("%d\n", val)
            } else {
                fmt.Printf("%d ", val)
            }
        }
    } else {
        fmt.Printf("No\n")
    }
}

package main

import (
	"fmt"
	"os"
)

type node struct {
	value int
	count int
	prev  *node
}

func newNode(n int) *node {
	return &node{
		value: n,
	}
}

func main() {
	seen := make(map[int]bool)
	var a, b int
	fmt.Fscanf(os.Stdin, "%d %d", &a, &b)
	queue := []*node{newNode(b)}

	for len(queue) > 0 {
		curr := queue[0]
		queue = queue[1:]

		if curr.value == a {
			fmt.Println("YES")
			fmt.Println(curr.count + 1)
			for n := curr; n != nil; n = n.prev {
				fmt.Printf("%d ", n.value)
			}
			fmt.Println()
			return
		}
		if curr.value < a || seen[curr.value] {
			continue
		}
		seen[curr.value] = true

		n := newNode(curr.value >> 1)
		n.count = curr.count + 1
		n.prev = curr
		queue = append(queue, n)
		if curr.value%10 == 1 {
			n := newNode(curr.value / 10)
			n.count = curr.count + 1
			n.prev = curr
			queue = append(queue, n)
		}
	}
	fmt.Println("NO")
}


Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way:qwertyuiopasdfghjkl;zxcvbnm,./Unfortunately Mole is blind, so sometimes it is problem for him to put his hands accurately. He accidentally moved both his hands with one position to the left or to the right. That means that now he presses not a button he wants, but one neighboring button (left or right, as specified in input).We have a sequence of characters he has typed and we want to find the original message.

First line of the input contains one letter describing direction of shifting ('L' or 'R' respectively for left or right). Second line contains a sequence of characters written by Mole. The size of this sequence will be no more than 100. Sequence contains only symbols that appear on Mole's keyboard. It doesn't contain spaces as there is no space on Mole's keyboard. It is guaranteed that even though Mole hands are moved, he is still pressing buttons on keyboard and not hitting outside it.

Print a line that contains the original message.

package main

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

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

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	keys := "qwertyuiopasdfghjkl;zxcvbnm,./"

	dx := 1
	if next() == "R" {
		dx = -1
	}

	for _, k := range next() {
		if strings.IndexRune(keys, k) > -1 {
			fmt.Print(string(keys[strings.IndexRune(keys, k) + dx]))
		}
	}
}

func next() string {
	in.Scan()
	return in.Text()
}

package main

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

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

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

	move := next()
	s := next()
	k := "qwertyuiopasdfghjkl;zxcvbnm,./"
	m := make(map[rune]int)
	ret := make([]rune, 0)
	pos := 0

	for i, v := range k {
		m[v] = i
	}

	for _, v := range s {
		if move == "L" {
			switch v {
				case 'p':
					pos = m['p']
				case ';':
					pos = m[';']
				case '/':
					pos = m['/']
				default:
					pos = m[v] + 1
			}

		} else {
			switch v {
			case 'q':
				pos = m['q']
			case 'a':
				pos = m['a']
			case 'z':
				pos = m['z']
			default:
				pos = m[v] - 1
			}
		}
		ret = append(ret, rune(k[pos]))
		// println(v, string(v), pos, string(k[pos]))
		// println(ret)
	}

	println(string(ret))
}

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

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

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

package main

import "fmt"

func main() {
	upperRow := map[string]int{"q": 1, "w": 2, "e": 3, "r": 4, "t": 5, "y": 6, "u": 7, "i": 8, "o": 9, "p": 10}
	lookUpUpperRow := map[int]string{1: "q", 2: "w", 3: "e", 4: "r", 5: "t", 6: "y", 7: "u", 8: "i", 9: "o", 10: "p"}

	middleRow := map[string]int{"a": 1, "s": 2, "d": 3, "f": 4, "g": 5, "h": 6, "j": 7, "k": 8, "l": 9, ";": 10}
	lookUpMiddleRow := map[int]string{1: "a", 2: "s", 3: "d", 4: "f", 5: "g", 6: "h", 7: "j", 8: "k", 9: "l", 10: ";"}

	lowerRow := map[string]int{"z": 1, "x": 2, "c": 3, "v": 4, "b": 5, "n": 6, "m": 7, ",": 8, ".": 9, "/": 10}
	lookUpLowerRow := map[int]string{1: "z", 2: "x", 3: "c", 4: "v", 5: "b", 6: "n", 7: "m", 8: ",", 9: ".", 10: "/"}

	var shiftDirection, inputString string

	fmt.Scanf("%s\n", &shiftDirection)

	fmt.Scanf("%s\n", &inputString)

	strSize := len(inputString)

	for i := 0; i < strSize; i++ {
		if upperRow[string(inputString[i])] != 0 {
			targetPos := upperRow[string(inputString[i])]
			if shiftDirection == "R" {
				fmt.Print(lookUpUpperRow[targetPos-1])
			} else {
				fmt.Print(lookUpUpperRow[targetPos+1])
			}
		} else if middleRow[string(inputString[i])] != 0 {
			targetPos := middleRow[string(inputString[i])]
			if shiftDirection == "R" {
				fmt.Print(lookUpMiddleRow[targetPos-1])
			} else {
				fmt.Print(lookUpMiddleRow[targetPos+1])
			}
		} else {
			targetPos := lowerRow[string(inputString[i])]
			if shiftDirection == "R" {
				fmt.Print(lookUpLowerRow[targetPos-1])
			} else {
				fmt.Print(lookUpLowerRow[targetPos+1])
			}
		}
	}

	fmt.Println()

}

// test project main.go
package main

import (
    "fmt"
)

func main() {
    key := []string{"qwertyuiop", "asdfghjkl;", "zxcvbnm,./"}
    ch := ""
    str := ""
    fmt.Scan(&ch)
    fmt.Scan(&str)
    add := 0
    if "R" == ch {
        add = -1
    } else {
        add = 1
    }
    for k := 0; k < len(str); k++ {
        for i := 0; i < 3; i++ {
            for j := 0; j < len(key[i]); j++ {
                if key[i][j] == str[k] {
                    fmt.Printf("%c", key[i][j+add])
                }
            }
        }
    }
    fmt.Println()
}

package main

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

func main() {
	rep := "qwertyuiopasdfghjkl;zxcvbnm,./"
	var d, s string
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	d = scanner.Text()
	scanner.Scan()
	s = scanner.Text()

	if strings.Compare(d, "R") == 0 {
		for i := 1; i < len(rep); i++ {
			s = strings.Replace(s, string(rep[i]), string(rep[i-1]), -1)
		}
	}
	if strings.Compare(d, "L") == 0 {
		for i := len(rep) - 1; i > 0; i-- {
			s = strings.Replace(s, string(rep[i-1]), string(rep[i]), -1)
		}
	}
	fmt.Print(s)
}

package main

import (
	"fmt"
	"strings"
)

func main()  {
	var dir,words string
	key := "qwertyuiopasdfghjkl;zxcvbnm,./"

	fmt.Scanf("%s\n", &dir)
	fmt.Scanf("%s", &words)
	for i := 0; i < len(words); i++ {
		for j := 0; j < len(key); j++ {
				// fmt.Printf(string(key[i][j]))
			if (string(words[i]) == string(key[j])) {
				if(strings.ToLower(string(dir)) == "r"){
					fmt.Printf("%c", key[j-1])
				}else{
					fmt.Printf("%c", key[j+1])
				}

			}
		}
	}
	// fmt.Println(key)
}

package main

import (
	"fmt"
)

func main() {
	var KBD = []string{"qwertyuiop", "asdfghjkl;", "zxcvbnm,./"}

	var kbd [3][10]rune
	for i := range KBD {
		for j, c := range KBD[i] {
			kbd[i][j] = c
		}
	}
	L, R, shift := make(map[rune]rune), make(map[rune]rune), make(map[rune]rune)
	// make L
	for i := range KBD {
		for j := range KBD[i] {
			if j == 9 {
				break
			}
			L[kbd[i][j]] = kbd[i][j+1]
		}
	}
	// make R
	for i := range KBD {
		for j := range KBD[i] {
			if j == 0 {
				continue
			}
			R[kbd[i][j]] = kbd[i][j-1]
		}
	}
	var d, mole string
	fmt.Scanln(&d)
	if d == "R" {
		shift = R
	} else {
		shift = L
	}
	fmt.Scanln(&mole)
	for _, c := range mole {
		fmt.Printf(string(shift[c]))
	}
	fmt.Println()
}

package main

import "fmt"

type Site struct {
	row int
	pos int
}

var keyboards [3][]byte
var sites map[byte]*Site

func init() {
	keyboards[0] = []byte("qwertyuiop")
	keyboards[1] = []byte("asdfghjkl;")
	keyboards[2] = []byte("zxcvbnm,./")

	sites = make(map[byte]*Site)
	for i := 0; i < 3; i++ {
		for j := 0; j < len(keyboards[i]); j++ {
			sites[keyboards[i][j]] = &Site{i, j}
		}
	}
}

func main() {
	var c, word string
	fmt.Scan(&c, &word)

	for i := 0; i < len(word); i++ {
		site := sites[word[i]]
		if c == "R" {
			fmt.Printf("%c", keyboards[site.row][site.pos-1])
		} else {
			fmt.Printf("%c", keyboards[site.row][site.pos+1])
		}
	}
}

package main

import (
    "bytes"
    "fmt"
    "strings"
)

func main() {
    kb := `qwertyuiop
        asdfghjkl;
        zxcvbnm,./`
    var (
        d string
        s string
    )
    fmt.Scan(&d, &s)

    i := 1
    if d == "R" {
        i = -1
    }

    var buffer bytes.Buffer
    for _, v := range s {
        ind := strings.IndexRune(kb, v)
        buffer.WriteString(string(kb[ind+i]))
    }
    fmt.Println(buffer.String())
}

package main

import "fmt"

func main() {
	k := "qwertyuiopasdfghjkl;zxcvbnm,./"
	var keyboard [128]int

	for i := 0; i < len(k); i++ {
		keyboard[int(k[i])] = i
	}

	var d, s, r string
	fmt.Scanln(&d)
	fmt.Scanln(&s)

	for i := 0; i < len(s); i++ {
		if d == "R" {
			index := keyboard[int(s[i])]
			r += string(k[index-1])
		} else {
			r += string(k[keyboard[int(s[i])]+1])
		}
	}

	fmt.Println(r)
}

package main

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

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 ReadString() string {
    scanner.Scan()
    return scanner.Text()
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    var q int
    a := make([]string, 3)
    a[0] = "qwertyuiop"
    a[1] = "asdfghjkl;"
    a[2] = "zxcvbnm,./"
    s := ReadString()
    if s == "R" {
        q = -1
    } else {
        q = 1
    }
    s = ReadString()
    r := ""
    dicti := make(map[uint8]int)
    dictj := make(map[uint8]int)
    for j := 0; j < 3; j++ {
        for i := 0; i < 10; i++ {
            dicti[a[j][i]] = i
            dictj[a[j][i]] = j
        }
    }
    for i := 0; i < len(s); i++ {
        r += string(a[dictj[s[i]]][dicti[s[i]]+q])
    }
    writer.WriteString(r)
    writer.WriteString("\n")
}

package main

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

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 ReadString() string {
    scanner.Scan()
    return scanner.Text()
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    var q int
    keyboard := "qwertyuiopasdfghjkl;zxcvbnm,./"
    dict := make(map[uint8]int)

    if ReadString() == "R" {
        q = -1
    } else {
        q = 1
    }

    s := ReadString()
    for i := 0; i < len(keyboard); i++ {
        dict[keyboard[i]] = i
    }

    r := ""
    for i := range s {
        r += string(keyboard[dict[s[i]]+q])
    }

    writer.WriteString(r + "\n")
}

package main

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

func main() {
	r := map[string]string{
		"q":"", "w":"q", "e":"w", "r":"e", "t":"r", "y":"t", "u":"y", "i":"u", "o":"i", "p":"o",
		"a":"", "s":"a", "d":"s", "f":"d", "g":"f", "h":"g", "j":"h", "k":"j", "l":"k", ";":"l",
		"z":"", "x":"z", "c":"x", "v":"c", "b":"v", "n":"b", "m":"n", ",":"m", ".":",", "/":".",
	}
	l := map[string]string{
		"q":"w", "w":"e", "e":"r", "r":"t", "t":"y", "y":"u", "u":"i", "i":"o", "o":"p", "p":"",
		"a":"s", "s":"d", "d":"f", "f":"g", "g":"h", "h":"j", "j":"k", "k":"l", "l":";", ";":"",
		"z":"x", "x":"c", "c":"v", "v":"b", "b":"n", "n":"m", "m":",", ",":".", ".":"/", "/":"",
	}

	reader := bufio.NewReader(os.Stdin)
	shift, _ := reader.ReadString('\n')
	chain, _ := reader.ReadString('\n')

	if(strings.TrimSpace(shift) == "R") {
		chain = convert(&r, chain)
	} else {
		chain = convert(&l, chain)
	}
	fmt.Printf("%s\n", chain)
}

func convert(m *map[string]string, chain string) string {
	for i := 0; i < len(chain); i++ {
		var c = string(chain[i])
		c = (*m)[c]
		chain = replaceAtIndex(chain, c, i)
	}
	return chain
}

func replaceAtIndex(str string, char string, index int) string {
	return str[:index] + char + str[index+1:]
}

package main

import (
    "fmt"
    )

const keyboard = "qwertyuiopasdfghjkl;zxcvbnm,./"

func get_real(mov string, ch byte) string {
    i := 0
    for i = 0; i < len(keyboard); i++ {
        if keyboard[i] == ch {
            break
        }
    }
    if mov == "R" {
        return string(keyboard[i-1])
    } else {
        return string(keyboard[i+1])
    }
}

func main() {
    var mov string
    fmt.Scan(&mov)

    var line string
    fmt.Scan(&line)

    result := ""
    for i := 0; i < len(line); i++ {
        result += get_real(mov, line[i])
    }

    fmt.Println(result)
}

package main

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

func main() {
	var direction string
	var myString string
	charArr := [...]string{"q", "w", "e", "r", "t", "y", "u", "i", "o", "p",
		"a", "s", "d", "f", "g", "h", "j", "k", "l", ";",
		"z", "x", "c", "v", "b", "n", "m", ",", ".", "/"}
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &direction)
	fmt.Fscan(reader, &myString)
	for _, currentChar := range myString {
		for index := 0; index < len(charArr); index++ {
			if string(currentChar) == charArr[index] {
				if direction == "R" {
					fmt.Print(charArr[index-1])
				} else {
					fmt.Print(charArr[index+1])
				}
				break
			}
		}
	}

}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

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

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    d := next()
    s := next()
    a := []string {"qwertyuiop", "asdfghjkl;", "zxcvbnm,./"}
    ans := ""
    dx := 1
    if d == "L" {
        dx = -1
    }
    for l := 0; l < len(s); l++ {
        for i := 0; i < len(a); i++ {
            ok := false
            for j := 0; j < len(a[i]); j++ {
                if a[i][j] == s[l] {
                    ans = ans + string(a[i][j - dx])
                    ok = true
                    break
                }
            }
            if ok {
                break
            }
        }
    }
    fmt.Fprintln(out, ans)
}

package main

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	side := next()
	var result []string
	if side == "R" {
		result = getChangedString(-1)
	} else {
		result = getChangedString(1)
	}
	fmt.Println(strings.Join(result, ""))
}

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

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

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

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func getChangedString(p int) []string {
	inputStr := next()
	firstLine := "qwertyuiopasdfghjkl;zxcvbnm,./"
	splitOfChars := splitString(firstLine)
	splitInput := splitString(inputStr)
	result := make([]string, len(splitInput))
	for i, c := range splitInput {
		for j, a := range splitOfChars {
			if a == c {
				result[i] = splitOfChars[j+p]
				break
			}
		}
	}
	return result
}

func splitString(input string) (result []string) {
	result = strings.Split(input, "")
	return
}

package main

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

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

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	keys := "qwertyuiopasdfghjkl;zxcvbnm, ./"

	dx := 1
	if next() == "R" {
		dx = -1
	}

	for _, k := range next() {
		if strings.IndexRune(keys, k) > -1 {
			fmt.Print(string(keys[strings.IndexRune(keys, k) + dx]))
		}
	}
}

func next() string {
	in.Scan()
	return in.Text()
}

package main

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

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

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	keys := []string{
		"qwertyuiop",
		"asdfghjkl;",
		"zxcvbnm, ./",
	}

	dx := 1
	if next() == "R" {
		dx = -1
	}

	for _, k := range next() {
		for _, s := range keys {
			if strings.IndexRune(s, k) > -1 {
				fmt.Print(string(s[strings.IndexRune(s, k) + dx]))
			}
		}
	}

}

func next() string {
	in.Scan()
	return in.Text()
}

package main

import "fmt"

func main() {
	upperRow := map[string]int{"q": 1, "w": 2, "e": 3, "r": 4, "t": 5, "y": 6, "u": 7, "i": 8, "o": 9, "p": 10}
	lookUpUpperRow := map[int]string{1: "q", 2: "w", 3: "e", 4: "r", 5: "t", 6: "y", 7: "u", 8: "i", 9: "o", 10: "p"}

	middleRow := map[string]int{"a": 1, "s": 2, "d": 3, "f": 4, "g": 5, "h": 6, "j": 7, "k": 8, "l": 9, ";": 10}
	lookUpMiddleRow := map[int]string{1: "a", 2: "s", 3: "d", 4: "f", 5: "g", 6: "h", 7: "j", 8: "k", 9: "l", 10: ";"}

	lowerRow := map[string]int{"z": 1, "x": 2, "c": 3, "v": 4, "b": 5, "n": 6, "m": 7, ",": 8, ".": 9, "/": 10}
	lookUpLowerRow := map[int]string{1: "z", 2: "x", 3: "c", 4: "v", 5: "b", 6: "n", 7: "m", 8: ",", 9: ".", 10: "/"}

	var shiftDirection, inputString string

	fmt.Scanf("%s\n", &shiftDirection)

	fmt.Scanf("%s\n", &inputString)

	strSize := len(inputString)

	for i := 0; i < strSize; i++ {
		if upperRow[string(inputString[i])] != 0 {
			targetPos := upperRow[string(inputString[i])]
			if shiftDirection == "L" {
				fmt.Print(lookUpUpperRow[targetPos-1])
			} else {
				fmt.Print(lookUpUpperRow[targetPos+1])
			}
		} else if middleRow[string(inputString[i])] != 0 {
			targetPos := middleRow[string(inputString[i])]
			if shiftDirection == "L" {
				fmt.Print(lookUpMiddleRow[targetPos-1])
			} else {
				fmt.Print(lookUpMiddleRow[targetPos+1])
			}
		} else {
			targetPos := lowerRow[string(inputString[i])]
			if shiftDirection == "L" {
				fmt.Print(lookUpLowerRow[targetPos-1])
			} else {
				fmt.Print(lookUpLowerRow[targetPos+1])
			}
		}
	}

	fmt.Println()

}

package main

import (
	"fmt"
)

func main() {
	var KBD = []string{"qwertyuiop", "asdfghjkl;", "zxcvbnm,./"}

	var kbd [3][10]rune
	for i := range KBD {
		for j, c := range KBD[i] {
			kbd[i][j] = c
		}
	}
	L, R, shift := make(map[rune]rune), make(map[rune]rune), make(map[rune]rune)
	// make L
	for i := range KBD {
		for j := range KBD[i] {
			if j == 9 {
				break
			}
			L[kbd[i][j]] = kbd[i][j+1]
		}
	}
	// make R
	for i := range KBD {
		for j := range KBD[i] {
			if j == 0 {
				continue
			}
			R[kbd[i][j]] = kbd[i][j-1]
		}
	}
	var d, mole string
	fmt.Scanln(&d)
	if d == "R" {
		shift = R
	} else {
		shift = L
	}
	fmt.Scanln(&mole)
	fmt.Println(mole)
	for _, c := range mole {
		fmt.Printf(string(shift[c]))
	}
	fmt.Println()
}


You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect.The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the two squares only share one common point, they are also considered to intersect.

The input data consists of two lines, one for each square, both containing 4 pairs of integers. Each pair represents coordinates of one vertex of the square. Coordinates within each line are either in clockwise or counterclockwise order. The first line contains the coordinates of the square with sides parallel to the coordinate axes, the second line contains the coordinates of the square at 45 degrees. All the values are integer and between $$$-100$$$ and $$$100$$$.

Print "Yes" if squares intersect, otherwise print "No". You can print each letter in any case (upper or lower).

NoteIn the first example the second square lies entirely within the first square, so they do intersect.In the second sample squares do not have any points in common.Here are images corresponding to the samples:

package main

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

type Vec [4]int

func (v Vec) max() int {
	max := -999
	for i := 0;i < len(v);i ++ {
		if v[i] > max {
			max = v[i]
		}
	}
	return max
}

func (v Vec) min() int {
	min := 999
	for i := 0;i < len(v);i ++ {
		if v[i] < min {
			min = v[i]
		}
	}
	return min
}

func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}
func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var ax, ay, bx, by Vec
	fmt.Fscanf(reader, "%d %d %d %d %d %d %d %d\n", &ax[0], &ay[0], &ax[1], &ay[1], &ax[2], &ay[2], &ax[3], &ay[3])
	fmt.Fscanf(reader, "%d %d %d %d %d %d %d %d\n", &bx[0], &by[0], &bx[1], &by[1], &bx[2], &by[2], &bx[3], &by[3])

	axMax, axMin, ayMax, ayMin := ax.max(), ax.min(), ay.max(), ay.min()
	bxMax, bxMin, byMax, byMin := bx.max(), bx.min(), by.max(), by.min()
	bxAvg, byAvg := (bxMax + bxMin) / 2, (byMax + byMin) / 2
	dist := bxMax - bxAvg

	for x := -100; x <= 100; x ++ {
		for y := -100; y <= 100; y ++ {
			if (axMin <= x && x <= axMax && ayMin <= y && y <= ayMax) {
				if (abs(x - bxAvg) + abs(y - byAvg) <= dist) {
					fmt.Printf("YES")
					return
				}
			}
		}
	}
	fmt.Printf("NO")
	return
}

package main

import (
	"fmt"
	"math"
)

type Point struct {
	X, Y float64
}

type Square struct {
	Points [4]Point
}

func rotateAxis(p Point, angle float64) (res Point) {
	res = Point{}
	angle = (angle * math.Pi) / 180
	res.X = p.X*math.Cos(angle) + p.Y*math.Sin(angle)
	res.Y = -1*p.X*math.Sin(angle) + p.Y*math.Cos(angle)
	return
}

func isInSquare(sq Square, p Point) (b bool) {
	var minHoz float64 = 101
	for _, v := range sq.Points {
		minHoz = math.Min(minHoz, v.Y)
	}

	var maxHoz float64 = -101
	for _, v := range sq.Points {
		maxHoz = math.Max(maxHoz, v.Y)
	}

	var minVer float64 = 101
	for _, v := range sq.Points {
		minVer = math.Min(minVer, v.X)
	}

	var maxVer float64 = -101
	for _, v := range sq.Points {
		maxVer = math.Max(maxVer, v.X)
	}

	return (p.X >= minVer && p.X <= maxVer) && (p.Y >= minHoz && p.Y <= maxHoz)
}

func solve(sq, sq45 Square) bool {
	center := Point{0, 0}
	for _, v := range sq45.Points {
		center.X += v.X
		center.Y += v.Y
		if isInSquare(sq, v) {
			return true
		}
	}

	center.X /= 4
	center.Y /= 4
	if isInSquare(sq, center) {
		return true
	}

	rotatedSquare := Square{}
	for i := range rotatedSquare.Points {
		rotatedSquare.Points[i] = rotateAxis(sq45.Points[i], 45)
	}

	center = Point{0, 0}
	for _, v := range sq.Points {
		center.X += v.X
		center.Y += v.Y
		rotatedPoint := rotateAxis(v, 45)
		if isInSquare(rotatedSquare, rotatedPoint) {
			return true
		}
	}

	center.X /= 4
	center.Y /= 4
	rotatedCenter := rotateAxis(center, 45)
	if isInSquare(rotatedSquare, rotatedCenter) {
		return true
	}

	return false
}

func consoleInput() {
	var x, y float64
	sq := Square{}
	for i := 0; i < 4; i++ {
		fmt.Scan(&x, &y)
		sq.Points[i] = Point{
			X: x,
			Y: y,
		}
	}

	sq45 := Square{}
	for i := 0; i < 4; i++ {
		fmt.Scan(&x, &y)
		sq45.Points[i] = Point{
			X: x,
			Y: y,
		}
	}

	if solve(sq, sq45) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func mustEqual(expected, actual bool) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Println("FAILED")
	}
}

func test() {
	{
		sq := Square{
			Points: [4]Point{
				Point{0, 0},
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{1, 3},
				Point{3, 5},
				Point{5, 3},
				Point{3, 1},
			},
		}

		mustEqual(true, solve(sq, sq45))
	}

	{
		sq := Square{
			Points: [4]Point{
				Point{0, 0},
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{7, 3},
				Point{9, 5},
				Point{11, 3},
				Point{9, 1},
			},
		}

		mustEqual(false, solve(sq, sq45))
	}

	{
		sq := Square{
			Points: [4]Point{
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
				Point{0, 0},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{7, 4},
				Point{4, 7},
				Point{7, 10},
				Point{10, 7},
			},
		}

		mustEqual(true, solve(sq, sq45))
	}

	{
		sq := Square{
			Points: [4]Point{
				Point{-5, -5},
				Point{5, -5},
				Point{5, 5},
				Point{-5, 5},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{6, 0},
				Point{0, 6},
				Point{-6, 0},
				Point{0, -6},
			},
		}

		mustEqual(true, solve(sq, sq45))
	}
}

func main() {
	consoleInput()
	// test()
}

package main

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

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

type Int64Slice []int64

func (slice Int64Slice) Len() int           { return len(slice) }
func (slice Int64Slice) Less(i, j int) bool { return slice[i] < slice[j] }
func (slice Int64Slice) Swap(i, j int)      { slice[i], slice[j] = slice[j], slice[i] }

type Sq struct {
	v [8]int
}

func (sq *Sq) isPara() bool {
	chk1, chk2 := false, false

	for i := 2; i < 8; i = i + 2 {
		if sq.v[i] == sq.v[0] {
			chk1 = true
		}
	}
	for i := 3; i < 8; i = i + 2 {
		if sq.v[i] == sq.v[1] {
			chk2 = true
		}
	}

	if chk1 && chk2 {
		return true
	}
	return false
}

var s1, s2 Sq

func gettoux() bool {
	xmin := s1.v[0]
	xmax := s1.v[0]
	for i := 2; i < 8; i = i + 2 {
		if s1.v[i] < xmin {
			xmin = s1.v[i]
		}
		if s1.v[i] > xmax {
			xmax = s1.v[i]
		}
	}
	ymin := s2.v[0]
	ymax := s2.v[0]
	for i := 2; i < 8; i = i + 2 {
		if s2.v[i] < ymin {
			ymin = s2.v[i]
		}
		if s2.v[i] > ymax {
			ymax = s2.v[i]
		}
	}

	if xmax < ymin || ymax < xmin {
		return false
	}
	return true
}

func gettouy() bool {
	xmin := s1.v[1]
	xmax := s1.v[1]
	for i := 3; i < 8; i = i + 2 {
		if s1.v[i] < xmin {
			xmin = s1.v[i]
		}
		if s1.v[i] > xmax {
			xmax = s1.v[i]
		}
	}
	ymin := s2.v[1]
	ymax := s2.v[1]
	for i := 3; i < 8; i = i + 2 {
		if s2.v[i] < ymin {
			ymin = s2.v[i]
		}
		if s2.v[i] > ymax {
			ymax = s2.v[i]
		}
	}

	if xmax < ymin || ymax < xmin {
		return false
	}
	return true
}

func gettouxaddy() bool {
	xmin := s1.v[0] + s1.v[1]
	xmax := s1.v[0] + s1.v[1]
	for i := 2; i < 8; i = i + 2 {
		if s1.v[i]+s1.v[i+1] < xmin {
			xmin = s1.v[i] + s1.v[i+1]
		}
		if s1.v[i]+s1.v[i+1] > xmax {
			xmax = s1.v[i] + s1.v[i+1]
		}
	}
	ymin := s2.v[0] + s2.v[1]
	ymax := s2.v[0] + s2.v[1]
	for i := 2; i < 8; i = i + 2 {
		if s2.v[i]+s2.v[i+1] < ymin {
			ymin = s2.v[i] + s2.v[i+1]
		}
		if s2.v[i]+s2.v[i+1] > ymax {
			ymax = s2.v[i] + s2.v[i+1]
		}
	}

	if xmax < ymin || ymax < xmin {
		return false
	}
	return true
}

func gettouxsuby() bool {
	xmin := s1.v[0] - s1.v[1]
	xmax := s1.v[0] - s1.v[1]
	for i := 2; i < 8; i = i + 2 {
		if s1.v[i]-s1.v[i+1] < xmin {
			xmin = s1.v[i] - s1.v[i+1]
		}
		if s1.v[i]-s1.v[i+1] > xmax {
			xmax = s1.v[i] - s1.v[i+1]
		}
	}
	ymin := s2.v[0] - s2.v[1]
	ymax := s2.v[0] - s2.v[1]
	for i := 2; i < 8; i = i + 2 {
		if s2.v[i]-s2.v[i+1] < ymin {
			ymin = s2.v[i] - s2.v[i+1]
		}
		if s2.v[i]-s2.v[i+1] > ymax {
			ymax = s2.v[i] - s2.v[i+1]
		}
	}

	if xmax < ymin || ymax < xmin {
		return false
	}
	return true
}

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

	for i := 0; i < 8; i++ {
		s1.v[i] = ReadInt32()
	}

	for i := 0; i < 8; i++ {
		s2.v[i] = ReadInt32()
	}

	if !s1.isPara() {
		s1, s2 = s2, s1
	}

	if gettoux() && gettouy() && gettouxaddy() && gettouxsuby() {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}
}

func Demo() {
	var n, m int64 = ReadInt64(), ReadInt64()
	PrintInt64s(n, m)
	writer.WriteByte('\n')
	slice := []int64{1, 2, 3, 4, 5}
	PrintInt64s(slice...)

	// sortDemo
	//slice := []int64{5, 3, 4, 2, 1}
	sort.Sort(Int64Slice(slice))

	//s := strconv.FormatBool(true)
	//s := strconv.FormatFloat(3.1415, 'E', -1, 64)
	//s := strconv.FormatInt(-42, 16)
	//s := strconv.FormatUint(42, 16)

}

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

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

func MinFloat64(a float64, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

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

func MaxFloat64(a float64, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

func ReadInt64() int64 {
	scanner.Scan()
	ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return ans
}

func ReadFloat64() float64 {
	scanner.Scan()
	ans, _ := strconv.ParseFloat(scanner.Text(), 64)
	return ans
}

func PrintInt64s(ints ...int64) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(int(value)))
		writer.WriteByte(' ')
	}
}

package main

import (
	"fmt"
	"math"
)

type Point struct {
	X, Y float64
}

type Square struct {
	Points [4]Point
}

func rotateAxis(p Point, angle float64) (res Point) {
	res = Point{}
	angle = (angle * math.Pi) / 180
	res.X = p.X*math.Cos(angle) + p.Y*math.Sin(angle)
	res.Y = -1*p.X*math.Sin(angle) + p.Y*math.Cos(angle)
	return
}

func isInSquare(sq Square, p Point) (b bool) {
	var minHoz float64 = 101
	for _, v := range sq.Points {
		minHoz = math.Min(minHoz, v.Y)
	}

	var maxHoz float64 = -101
	for _, v := range sq.Points {
		maxHoz = math.Max(maxHoz, v.Y)
	}

	var minVer float64 = 101
	for _, v := range sq.Points {
		minVer = math.Min(minVer, v.X)
	}

	var maxVer float64 = -101
	for _, v := range sq.Points {
		maxVer = math.Max(maxVer, v.X)
	}

	return (p.X >= minVer && p.X <= maxVer) && (p.Y >= minHoz && p.Y <= maxHoz)
}

func solve(sq, sq45 Square) bool {
	for _, v := range sq45.Points {
		if isInSquare(sq, v) {
			return true
		}
	}

	rotatedSquare := Square{}
	for i := range rotatedSquare.Points {
		rotatedSquare.Points[i] = rotateAxis(sq45.Points[i], 45)
	}

	for _, v := range sq.Points {
		rotatedPoint := rotateAxis(v, 45)
		if isInSquare(rotatedSquare, rotatedPoint) {
			return true
		}
	}

	return false
}

func consoleInput() {
	var x, y float64
	sq := Square{}
	for i := 0; i < 4; i++ {
		fmt.Scan(&x, &y)
		sq.Points[i] = Point{
			X: x,
			Y: y,
		}
	}

	sq45 := Square{}
	for i := 0; i < 4; i++ {
		fmt.Scan(&x, &y)
		sq45.Points[i] = Point{
			X: x,
			Y: y,
		}
	}

	if solve(sq, sq45) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func mustEqual(expected, actual bool) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Println("FAILED")
	}
}

func test() {
	{
		sq := Square{
			Points: [4]Point{
				Point{0, 0},
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{1, 3},
				Point{3, 5},
				Point{5, 3},
				Point{3, 1},
			},
		}

		mustEqual(true, solve(sq, sq45))
	}

	{
		sq := Square{
			Points: [4]Point{
				Point{0, 0},
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{7, 3},
				Point{9, 5},
				Point{11, 3},
				Point{9, 1},
			},
		}

		mustEqual(false, solve(sq, sq45))
	}

	{
		sq := Square{
			Points: [4]Point{
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
				Point{0, 0},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{7, 4},
				Point{4, 7},
				Point{7, 10},
				Point{10, 7},
			},
		}

		mustEqual(true, solve(sq, sq45))
	}
}

func main() {
	consoleInput()
	// test()
}

package main

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

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

type Int64Slice []int64

func (slice Int64Slice) Len() int           { return len(slice) }
func (slice Int64Slice) Less(i, j int) bool { return slice[i] < slice[j] }
func (slice Int64Slice) Swap(i, j int)      { slice[i], slice[j] = slice[j], slice[i] }

type Sq struct {
	v [8]int
}

func (sq *Sq) isPara() bool {
	chk1, chk2 := false, false

	for i := 2; i < 8; i = i + 2 {
		if sq.v[i] == sq.v[0] {
			chk1 = true
		}
	}
	for i := 3; i < 8; i = i + 2 {
		if sq.v[i] == sq.v[1] {
			chk2 = true
		}
	}

	if chk1 && chk2 {
		return true
	}
	return false
}

func check2in1(s1 *Sq, s2 *Sq, j int) bool {
	xin, yin := false, false

	xlarge, xsmall := 0, 0
	ylarge, ysmall := 0, 0
	for i := 0; i < 8; i = i + 2 {
		if s1.v[i] < s2.v[j*2] {
			xlarge = xlarge + 1
		}
		if s1.v[i] > s2.v[j*2] {
			xsmall = xsmall + 1
		}
	}
	if xlarge != 4 && xsmall != 4 {
		xin = true
	}

	for i := 1; i < 8; i = i + 2 {
		if s1.v[i] < s2.v[j*2+1] {
			ylarge = ylarge + 1
		}
		if s1.v[i] > s2.v[j*2+1] {
			ysmall = ysmall + 1
		}
	}
	if ylarge != 4 && ysmall != 4 {
		yin = true
	}
	if xin && yin {
		return true
	}
	return false
}

func check1in2(s1 *Sq, s2 *Sq, i int) bool {
	xaddy := s1.v[i*2] + s1.v[i*2+1]
	xsuby := s1.v[i*2] - s1.v[i*2+1]

	var xaddy2 [4]int
	var xsuby2 [4]int

	for j := 0; j < 4; j++ {
		xaddy2[j] = s2.v[j*2] + s2.v[j*2+1]
		xsuby2[j] = s2.v[j*2] - s2.v[j*2+1]
	}

  xin, yin := false, false
	xlarge, xsmall := 0, 0
	ylarge, ysmall := 0, 0

	for j := 0; j < 4; j++ {
		if xaddy2[j] < xaddy {
			xlarge = xlarge + 1
		}
		if xaddy2[j] > xaddy {
			xsmall = xsmall + 1
		}
	}
	if xlarge != 4 && xsmall != 4 {
		xin = true
	}

	for j := 0; j < 4; j++ {
		if xsuby2[j] < xsuby {
			ylarge = ylarge + 1
		}
		if xsuby2[j] > xsuby {
			ysmall = ysmall + 1
		}
	}
	if ylarge != 4 && ysmall != 4 {
		yin = true
	}
	if xin && yin {
		return true
	}
	return false

}

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

	var s1, s2 Sq

	for i := 0; i < 8; i++ {
		s1.v[i] = ReadInt32()
	}

	for i := 0; i < 8; i++ {
		s2.v[i] = ReadInt32()
	}

	if !s1.isPara() {
		s1, s2 = s2, s1
	}

  chk1in2, chk2in1 := false, false

	for i := 0; i < 4; i++ {
		if check2in1(&s1, &s2, i) {
			chk2in1 = true
		}
	}
	for i := 0; i < 4; i++ {
		if check1in2(&s1, &s2, i) {
			chk1in2 = true
		}
	}

	if chk1in2 || chk2in1 {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}
}

func Demo() {
	var n, m int64 = ReadInt64(), ReadInt64()
	PrintInt64s(n, m)
	writer.WriteByte('\n')
	slice := []int64{1, 2, 3, 4, 5}
	PrintInt64s(slice...)

	// sortDemo
	//slice := []int64{5, 3, 4, 2, 1}
	sort.Sort(Int64Slice(slice))

	//s := strconv.FormatBool(true)
	//s := strconv.FormatFloat(3.1415, 'E', -1, 64)
	//s := strconv.FormatInt(-42, 16)
	//s := strconv.FormatUint(42, 16)

}

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

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

func MinFloat64(a float64, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

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

func MaxFloat64(a float64, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

func ReadInt64() int64 {
	scanner.Scan()
	ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return ans
}

func ReadFloat64() float64 {
	scanner.Scan()
	ans, _ := strconv.ParseFloat(scanner.Text(), 64)
	return ans
}

func PrintInt64s(ints ...int64) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(int(value)))
		writer.WriteByte(' ')
	}
}


Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.Now he wonders what is an average value of sum of digits of the number A written in all bases from 2 to A - 1.Note that all computations should be done in base 10. You should find the result as an irreducible fraction, written in base 10.

Input contains one integer number A (3 ≤ A ≤ 1000).

Output should contain required average value in format «X/Y», where X is the numerator and Y is the denominator.

NoteIn the first sample number 5 written in all bases from 2 to 4 looks so: 101, 12, 11. Sums of digits are 2, 3 and 2, respectively.

package main

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

var scanner *bufio.Scanner

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

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

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

  x := getI()
  total := 0
  for base := 2; base < x; base++ {
    for y := x; y != 0; y /= base {
      total += y % base
    }
  }
  num, denom := total, x-2
  d := gcd(num, denom)
  num /= d
  denom /= d
  writer.WriteString(fmt.Sprintf("%d/%d\n", num, denom))
}

//13A
package main
import "fmt"

func main() {
	var aa, k, l, ttl int
	fmt.Scan(&aa)
	for i:=2; i<aa; i++ {
		k=aa
		for k>0 {
			ttl=ttl+(k%i)
			k/=i
			if k<i {
				ttl=ttl+k
				break
			}
		}
	}
	l=aa-2
	for i:=l; i>1; i-- {
		if ttl%i==0 && l%i==0 {
			ttl/=i
			l/=i
			break
		}
	}
	fmt.Print(ttl,"/",l)
	fmt.Println()
}

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

func main() {
	var (
		A int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &A)

	primes := make([]bool,  A / 2 + 1)
	for i := 0; i < len(primes); i++ {
		primes[i] = true
	}

	for i := 2; i < len(primes); i++ {
		if primes[i] {
			x := i
			for i + x < len(primes) {
				primes[i + x] = false
				x += i
			}
		}
	}

	ans := 0
	cnt := 0
	for i := 2; i < A; i++ {
		tmp := A
		for tmp > 0 {
			ans += tmp % i
			tmp /= i
		}
		cnt++
	}

	for i := 2; i < len(primes); i++ {
		if primes[i] {
			for ans % i == 0 && cnt % i == 0 {
				ans /= i
				cnt /= i
			}
		}
	}

	fmt.Printf("%d/%d", ans, cnt)
}

// 13A
package main

import (
	"fmt"
)

func gcd(n, m int) int {
	if m == 0 {
		return n
	} else {
		return gcd(m, n%m)
	}
}

func main() {
	var n, m, i int
	sum := 0
	fmt.Scan(&n)
	for i = 2; i < n; i++ {
		m = n
		for m != 0 {
			sum += m % i
			m /= i
		}
	}
	fmt.Printf("%d/%d", sum/gcd(sum, n-2), (n-2)/gcd(sum, n-2))
}

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

func main() {
	var (
		A int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &A)
	ans := 0
	cnt := 0
	for i := 2; i < A; i++ {
		tmp := A
		for tmp > 0 {
			ans += tmp % i
			tmp /= i
		}
		cnt++
	}

	fmt.Printf("%d/%d", ans, cnt)
}

// 13A
package main

import (
	"fmt"
)

func gcd(n, m int) int {
	if m == 0 {
		return n
	} else {
		return gcd(m, n%m)
	}
}

func main() {
	var n, m, i int
	sum := 0
	fmt.Scan(&n)
	for i = 2; i < n; i++ {
		m = n
		for m != 0 {
			sum += m % i
			m /= i
		}
	}
	fmt.Println(sum/gcd(sum, n-2), "/", (n-2)/gcd(sum, n-2))
}


Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.Limak wants to prove how responsible a bear he is. He is going to regularly save candies for the entire year 2016! He considers various saving plans. He can save one candy either on some fixed day of the week or on some fixed day of the month.Limak chose one particular plan. He isn't sure how many candies he will save in the 2016 with his plan. Please, calculate it and tell him.

The only line of the input is in one of the following two formats:    "x of week" where x (1 ≤ x ≤ 7) denotes the day of the week. The 1-st day is Monday and the 7-th one is Sunday.  "x of month" where x (1 ≤ x ≤ 31) denotes the day of the month.

Print one integer — the number of candies Limak will save in the year 2016.

NotePolar bears use the Gregorian calendar. It is the most common calendar and you likely use it too. You can read about it on Wikipedia if you want to – https://en.wikipedia.org/wiki/Gregorian_calendar. The week starts with Monday.In the first sample Limak wants to save one candy on each Thursday (the 4-th day of the week). There are 52 Thursdays in the 2016. Thus, he will save 52 candies in total.In the second sample Limak wants to save one candy on the 30-th day of each month. There is the 30-th day in exactly 11 months in the 2016 — all months but February. It means that Limak will save 11 candies in total.

package main

import ("fmt")

func weekfunc(day int) int{
	var count int
	var current int = 5
	for i:=0;i<366;i++{
		if current==day{
			count++
		}
		current++
		if current>7{
			current = 1
		}
	}
	return count
}

func monthfunc(day int) int{
	arr := []int{31,29,31,30,31,30,31,31,30,31,30,31}
	var count int = 0
	for i:=0;i<12;i++{
		if day<=arr[i]{
			count++
		}
	}
	return count
}

func main(){
	var day int
	var of string
	var random string
	fmt.Scan(&day,&of,&random)
	var ans int
	if random == "week"{
		ans = weekfunc(day)
	}else{
		ans = monthfunc(day)
	}
	fmt.Println(ans)
}

package main

import "fmt"

//import "strings"

var s string
var n, ans int

func main() {
        fmt.Scanf("%d of %s", &n, &s)
        switch s {
        case "week":
                ans = cal_week(n)
        case "month":
                ans = cal_month(n)
        }
        fmt.Println(ans)
}

func cal_week(n int) int {
        if n == 5 || n == 6 {
                return 53
        } else {
                return 52
        }

}

func cal_month(n int) int {
        if n < 30 {
                return 12
        } else if n == 30 {
                return 11
        } else {
                return 7
        }
}

package main

import "fmt"

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

	sum := 0
	if key == "week" {
		sum += 363 / 7
		if n <= 363%7 {
			sum += 1
		}
		if n >= 5 {
			sum += 1
		}
	} else {
		if n <= 29 {
			sum = 12
		} else if n == 30 {
			sum = 11
		} else {
			sum = 7
		}
	}

	fmt.Println(sum)
}

package main

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

func main() {
	var s string
	ch := make(chan string)
	go func() {
		scanner := bufio.NewScanner(os.Stdin)
		for scanner.Scan() {
			ch <- scanner.Text()
		}
	}()
	s = <-ch
	ss := strings.Split(s, " ")
	d, _ := strconv.Atoi(ss[0])
	if ss[len(ss)-1] == "month" {
		if d <= 29 {
			fmt.Println("12")
			return
		}
		if d <= 30 {
			fmt.Println("11")
			return
		}
		if d <= 31 {
			fmt.Println("7")
			return
		}
	}
	cw := 366 / 7
	if d == 5 || d == 6 {
		cw++
	}
	fmt.Printf("%v", cw)
	return
}

// cf611a project main.go
package main

import (
	"fmt"
)

func main() {
	var x int
	var s string
	fmt.Scanf("%d of %s", &x, &s)
	m := []int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	d := []int{52, 52, 52, 52, 53, 53, 52}
	if s == "week" {
		fmt.Println(d[x-1])
	} else {
		var c int
		for _, v := range m {
			if v >= x {
				c++
			}
		}
		fmt.Println(c)
	}
}

package main

import ("fmt")

func monthfunc(date int) int {
	var count int
	arr := []int{31,29,31,30,31,30,31,31,30,31,30,31}
	for i:=0;i<12;i++{
		if date<=arr[i]{
			count++
		}
	}
	return count
}

func weekfun(day int) int{
	var count int
	var current int = 5
	for i:=0;i<366;i++{
		if current == day{
			count++
		}
		current++
		if current > 7{
			current = 0
		}
	}
	return count
}

func main(){

	var ans int
	var str string
	fmt.Scan(&str)
	var number int = int(str[0])

	if string(str[len(str)-1])=="k"{
		ans = weekfun(number)
	}else{
		ans = monthfunc(number)
	}

	fmt.Print(ans)
}

package main

import "fmt"

//import "strings"

var s string
var n, ans int

func main() {
        fmt.Scanf("%d of %s", &n, &s)
        switch s {
        case "week":
                ans = cal_week(n)
        case "month":
                ans = cal_month(n)
        }
        fmt.Println(ans)
}

func cal_week(n int) int {
        if n == 5 {
                return 53
        } else {
                return 52
        }

}

func cal_month(n int) int {
        if n < 28 {
                return 12
        } else if n == 30 {
                return 11
        } else {
                return 7
        }
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)
	ss := strings.Split(s, " ")
	d, _ := strconv.Atoi(ss[0])
	if ss[len(ss)-1] == "month" {
		if d <= 29 {
			fmt.Println("12")
			return
		}
		if d <= 30 {
			fmt.Println("11")
			return
		}
		if d <= 31 {
			fmt.Println("7")
			return
		}
	}
	cw := 366 / 7
	if d == 5 || d == 6 {
		cw++
	}
	fmt.Printf("%v", cw)
	return
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scanln(&s)
	ss := strings.Split(s, " ")
	d, _ := strconv.Atoi(ss[0])
	if ss[len(ss)-1] == "month" {
		if d <= 29 {
			fmt.Println("12")
			return
		}
		if d <= 30 {
			fmt.Println("11")
			return
		}
		if d <= 31 {
			fmt.Println("7")
			return
		}
	}
	cw := 366 / 7
	if d == 5 || d == 6 {
		cw++
	}
	fmt.Printf("%v", cw)
	return
}

// cf611a project main.go
package main

import (
	"fmt"
)

func main() {
	var x int
	var s string
	fmt.Scanf("%d of %s", &x, &s)
	m := []int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	d := []int{52, 52, 52, 52, 53, 53, 52}
	if s == "week" {
		fmt.Println(d[x-1])
	} else {
		var c int
		for _, v := range m {
			if v <= x {
				c++
			}
		}
		fmt.Println(c)
	}
}


Allen has a LOT of money. He has $$$n$$$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $$$1$$$, $$$5$$$, $$$10$$$, $$$20$$$, $$$100$$$. What is the minimum number of bills Allen could receive after withdrawing his entire balance?

The first and only line of input contains a single integer $$$n$$$ ($$$1 \le n \le 10^9$$$).

Output the minimum number of bills that Allen could receive.

NoteIn the first sample case, Allen can withdraw this with a $$$100$$$ dollar bill, a $$$20$$$ dollar bill, and a $$$5$$$ dollar bill. There is no way for Allen to receive $$$125$$$ dollars in one or two bills.In the second sample case, Allen can withdraw two $$$20$$$ dollar bills and three $$$1$$$ dollar bills.In the third sample case, Allen can withdraw $$$100000000$$$ (ten million!) $$$100$$$ dollar bills.

package main

import (
	"fmt"
)

func main() {
	arr := []int{1, 5, 10, 20, 100}
	var num int

	fmt.Scan(&num)
	count := 0
	startIndex := 4
	for num > 0 {
		if num < arr[startIndex] {
			startIndex--
			continue
		}
		count = count + (num / arr[startIndex])
		num = num % arr[startIndex]
		startIndex--
	}

	fmt.Println(count)
}

package main

import "fmt"

func main() {
    var split = [5]int{100,20,10,5,1}
    var count = 0
    var total int
    fmt.Scanf("%d", &total)
    for _, spt := range split {
        count += total / spt
        total %= spt
    }
    fmt.Printf("%d\n", count)
}

package main

import "fmt"

func main(){
	var n, cnt int
	fmt.Scan(&n)
	a:= [...]int {100, 20, 10, 5, 1}
	for _, x := range a{
		cnt += n / x
		n %= x
	}
	fmt.Println(cnt)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint64
	fmt.Fscanf(in, "%d\n", &n)

	fmt.Println(hitTheLottery(n))
}

func hitTheLottery(n uint64) uint64 {
	var result uint64

	tmp := n / 100
	result += tmp
	n -= (tmp * 100)

	tmp = n / 20
	result += tmp
	n -= (tmp * 20)

	tmp = n / 10
	result += tmp
	n -= (tmp * 10)

	tmp = n / 5
	result += tmp
	n -= (tmp * 5)

	tmp = n / 1
	result += tmp
	n -= (tmp * 1)

	return result
}

package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	bills := []int{100, 20, 10, 5, 1}
	var count int
	for _, val := range bills {
		count = count + (n / val)
		n = n - ((n / val) * val)
	}

	fmt.Println(count)
}

package main

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

var scanner *bufio.Scanner

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

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

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

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

	printf("%d", Problem996A())
}

func Problem996A() int {
	// 1, 5, 10, 20 , 100
	n := getI()
	i := 0
	for n > 0 {
		if n - 100 >= 0 {
			n-=100
			i++
		}else if n - 20 >= 0 {
			n-=20
			i++
		}else if n - 10 >= 0 {
			n-=10
			i++
		}else if n - 5 >= 0 {
			n-=5
			i++
		}else {
			n-=1
			i++
		}
	}

	return i
}

package main

import "fmt"

func main() {
	var n, res uint
	fmt.Scan(&n)
	for n > 0 {
		if n >= 100 {
			n -= 100
		} else if n >= 20 {
			n -= 20
		} else if n >= 10 {
			n -= 10
		} else if n >= 5 {
			n -= 5
		} else if n >= 1 {
			n -= 1
		}
		res++
	}
	fmt.Println(res)
}

// https://codeforces.com/problemset/problem/996/A
package main

import (
	"fmt"
)

var denominations []int = []int{100, 20, 10, 5, 1}

func main() {
	var dollars, count int
	count = 0
	fmt.Scanf("%d\n", &dollars)
	for _, coin := range denominations {
		for dollars >= coin {
			dollars -= coin
			count++
		}
	}
	fmt.Printf("%d",count)
}

package main

import (
	"fmt"
)

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

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

func max(arr []int) (max int) {
	max = arr[0]
	for _, val := range arr {
		if val > max {
			max = val
		}
	}
	return max
}

var mod int = 1000000007

func coinChange(m int) int {
	count := 0
	for m > 0 {
		if m >= 100 {
			m -= 100
			count++
		} else if m >= 20 {
			m -= 20
			count++
		} else if m >= 10 {
			m -= 10
			count++
		} else if m >= 5 {
			m -= 5
			count++
		} else if m >= 1 {
			m--
			count++
		}
	}
	return count
}

func main() {
	var m int
	fmt.Scan(&m)
	fmt.Println(coinChange(m))
}

package main

import (
	"fmt"
)

func main() {
	var n int

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

	ans := 0
	for n > 0 {
		switch {
		case n >= 100:
			ans++
			n -= 100
		case n >= 20:
			ans++
			n -= 20
		case n >= 10:
			ans++
			n -= 10
		case n >= 5:
			ans++
			n -= 5
		default:
			ans++
			n -= 1

		}
	}

	fmt.Println(ans)

}

package main

import "fmt"

func main() {
	var n, k int
	b := [5]int{100, 20, 10, 5, 1}
	fmt.Scan(&n)
	for i := 0; i < 5; i++ {
		if n >= b[i] {
			k += n / b[i]
			n = n % b[i]
		}
	}
	fmt.Print(k)
}

package main

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

func main() {
	var (
		n int
	)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())

	hu := int(n / 100)
	n -= hu * 100
	tw := int(n / 20)
	n -= tw * 20
	te := int(n / 10)
	n -= te * 10
	fi := int(n / 5)
	n -= fi * 5
	on := n

	// fmt.Println(hu, tw, te, fi, on)
	fmt.Println(hu + tw + te + fi + on)
}

package main

import "fmt"

// https://codeforces.com/problemset/problem/996/A
// A. Hit the Lottery
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Allen has a LOT of money. He has n
// dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are 1, 5, 10, 20, 100

// . What is the minimum number of bills Allen could receive after withdrawing his entire balance?
// Input

// The first and only line of input contains a single integer n
// (1≤n≤109

// ).
// Output

// Output the minimum number of bills that Allen could receive.

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

	var nBills int

	nBills += n / 100
	n %= 100

	nBills += n / 20
	n %= 20

	nBills += n / 10
	n %= 10

	nBills += n / 5
	n %= 5

	nBills += n

	fmt.Print(nBills)
}

package main

import "fmt"

func main(){
	var n int
	fmt.Scan(&n)
	count1 := 0
	plus1 := 1
	for {
		if n >= 100 {
			plus1 = n - n % 100
			plus1 /= 100
			n %= 100
		} else if n >= 20 {
			plus1 = n - n % 20
			plus1 /= 20
			n %= 20
		} else if n >= 10{
			plus1 = n - n % 10
			plus1 /= 10
			n %= 10
		}else if n >= 5{
			plus1 = n - n % 5
			plus1 /= 5
			n %= 5
		} else {
			plus1 = n
			n = 0
		}
		count1 += plus1
		if n == 0{
			fmt.Println(count1)
			break
		}
	}

}

package main
import (
 "fmt"
)
func main() {
  var n,k int
  fmt.Scan(&n)
  for _,i := range([]int{100,20,10,5,1}){
    k += n/i
    n %= i
  }
  fmt.Println(k)
}

package main

import "fmt"

// https://codeforces.com/problemset/problem/996/A
// комментарии к решению
// Т.к. номиналы купюр известны заранее и они полностью перекрывают друг друга
// т.е. любая старшая купюра легко может быть представлена определенным кол-вом
// более младшей купюры, то минимальное кол-во купюр для выдачи n денег
// легко поддаётся подсчету по алгоритму ниже
func taskSolution(n int) (ans int) {
	nominals := []int{100, 20, 10, 5, 1}
	for i := 0; i < len(nominals) && n > 0; i += 1 {
		ans, n = ans+n/nominals[i], n%nominals[i]
	}
	return ans
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(n))
}

package main

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

func main() {
	var n int
	bil := []int{100, 20, 10, 5}
	in := bufio.NewReader(os.Stdin)
	ans := 0
	fmt.Fscan(in, &n)
	for _, v := range bil {
		ans = ans + n/v
		n = n % v
	}
	ans = ans + n
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
	var i int
	fmt.Scanf("%d", &i)
	counter := 0

	counter += i / 100
	i = i % 100
	counter += i / 20
	i = i % 20
	counter += i / 10
	i = i % 10
	counter += i / 5
	i = i % 5
	counter += i / 1
	i = i % 1
	fmt.Println(counter)
}

// A. Hit the Lottery
/*
Allen has a LOT of money. He has 𝑛 dollars in the bank.
For security reasons, he wants to withdraw it in cash
(we will not disclose the reasons here).
The denominations for dollar bills are 1, 5, 10, 20, 100. What is the minimum
number of bills Allen could receive after withdrawing his entire balance?

Input
The first and only line of input contains a single integer 𝑛(1≤𝑛≤109).

Output
Output the minimum number of bills that Allen could receive.

Examples
Input
125

Output
3

Input
43

Output
5

Input
1000000000

Output
10000000

Note
In the first sample case, Allen can withdraw this with a 100
dollar bill, a 20 dollar bill, and a 5 dollar bill.
There is no way for Allen to receive 125 dollars in one or two bills.

In the second sample case, Allen can withdraw two 20 dollar bills and three 1
dollar bills.

In the third sample case, Allen can withdraw 100000000 (ten million!)
100 dollar bills.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _, _ := reader.ReadLine()
	n, _ := strconv.Atoi(string(input))
	fmt.Println(sol966A(n))
}

func sol966A(n int) int {
	bills := 0
	for n > 0 {
		if n/100 != 0 {
			bills += n / 100
			n %= 100
		} else if n/20 != 0 {
			bills += n / 20
			n %= 20
		} else if n/10 != 0 {
			bills += n / 10
			n %= 10
		} else if n/5 != 0 {
			bills += n / 5
			n %= 5
		} else {
			bills += n
			break
		}
	}
	return bills
}

package main

import "fmt"

func main() {
	var n, k int
	g := 0
	fmt.Scan(&n)
	for true {
		if n >= 100 {
			k = int(n / 100)
			g += k
			n -= 100 * k
		} else if n >= 20 {
			k = int(n / 20)
			g += k
			n -= 20 * k
		} else if n >= 10 {
			k = int(n / 10)
			g += k
			n -= 10 * k
		} else if n >= 5 {
			k = int(n / 5)
			g += k
			n -= 5 * k
		} else {
			g += n % 5
			break
		}
	}
	fmt.Println(g)
}

package main

import "fmt"

func main() {
	var n, res int
	_, err := fmt.Scanln(&n)
	if err != nil {
		panic(err)
	}

	for _, v := range []int{100, 20, 10, 5, 1} {
		res += n / v
		n %= v
	}

	fmt.Print(res)
}

package main

import "fmt"

func main() {
	var n, res int
	_, err := fmt.Scanln(&n)
	if err != nil {
		panic(err)
	}

	for _, v := range []int{100, 20, 10, 5, 1} {
		res = res + n/v
		n = n - v*(n/v)
	}

	fmt.Print(res)
}

package main

import(
    "fmt"
)

func main(){
    var(
        n,res int64
        coinChange = []int{1,5,10,20,100,}
    )
    fmt.Scan(&n)
    res = 0
    for i:=4;i>=0;i--{
        res += n/int64(coinChange[i]);
        n=n%int64(coinChange[i]);
    }
    fmt.Println(res)
}

package main

import (
	"fmt"
)

func main() {
	var n, num int
	num = 0
	fmt.Scan(&n)
	for n != 0 {
		if n >= 100 {
			n -= 100
			num++
		} else if n >= 20 {
			n -= 20
			num++
		} else if n >= 10 {
			n -= 10
			num++
		} else if n >= 5 {
			n -= 5
			num++
		} else if n >= 1 {
			n -= 1
			num++
		}
	}
	fmt.Println(num)
}

package main

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

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

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

	var r int64 = 0

	for _, i := range []int64{100, 20, 10, 5, 1} {
		r += n / i
		n %= i
	}

	fmt.Fprintln(out, r)

}

package main

import "fmt"

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

	cnt := 0
	for _, v := range []int{100, 20, 10, 5, 1} {
		cnt += n / v
		n %= v
	}

	fmt.Println(cnt)
}

//лотерея
package main

import "fmt"

func main() {
	var n, coins int
	fmt.Scan(&n)
	coins += n / 100
	n = n % 100
	coins += n / 20
	n = n % 20
	coins += n / 10
	n = n % 10
	coins += n / 5
	coins += n % 5
	fmt.Println(coins)
}

package main

import (
	"fmt"
)

func main() {

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

	count := 0

	for ; n != 0; {
		if n-100 >= 0 {
			count += 1
			n -= 100
		} else if n-20 >= 0 {
			count += 1
			n -= 20
		} else if n-10 >= 0 {
			count += 1
			n -= 10
		} else if n-5 >= 0 {
			count += 1
			n -= 5
		} else if n-1 >= 0 {
			count += 1
			n -= 1
		}
	}
	fmt.Print(count)
}

package main

import "fmt"

func main()  {
	var a uint64

	fmt.Scan(&a)

	c1 := a / 100
	rem := a % 100
	c2 := rem / 20
	rem = rem % 20
	c3 := rem / 10
	rem = rem % 10
	c4 := rem / 5
	rem = rem % 5
	fmt.Printf("%d", c1+c2+c3+rem+c4)
}

package main

import "fmt"

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

	arr := []int{1, 5, 10, 20, 100}

	count := 0

	for i := 4; i >= 0; i-- {
		k := n / arr[i]
		count += k
		n = n % arr[i]
	}
	fmt.Println(count)
}

package main

import "fmt"

func main() {
	notes := []int{100, 20, 10, 5, 1}
	var withdrawl, count int

	_, _ = fmt.Scanf("%d", &withdrawl)

	for _, note := range notes {
		for {
			if withdrawl-note < 0 {
				break
			} else {
				withdrawl -= note
				count++
			}
		}
	}

	fmt.Println(count)
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)
	line := readLine(reader)
	var n int64 = 0
	fmt.Sscanf(line, "%d", &n)
	var count int64 = 0
	for {
		if n < 100 {
			break
		}
		n = n - 100
		count++
	}
	for {
		if n < 20 {
			break
		}
		n = n - 20
		count++
	}
	for {
		if n < 10 {
			break
		}
		n = n - 10
		count++
	}

	for {
		if n < 5 {
			break
		}
		n = n - 5
		count++
	}
	count = count + n
	fmt.Println(count)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

package main

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

var deno = []int{100, 20, 10, 5, 1}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, out int
	fmt.Fscanf(reader, "%d\n", &n)
	for _, v := range deno {
		u := n / v
		out += u
		n = n - (u * v)
	}
	fmt.Print(out)
}

//A. Выиграть в лотерею
package main

import (
	"fmt"
)

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

func minKol(sum int) int {
	bills := [...]int{1, 5, 10, 20, 100}
	mode := sum
	rez := 0
	i := 4

	for mode != 0 { //двигаемся по номиналам купюр от самой большой(100) до мелкой(1)
		rez = rez + mode/bills[i] //к результату добавляем количесво купюр текущего номинала
		mode = sum % bills[i]
		//mode = mode % bills[i]
		i-- //переходим к номиналу помельче
	}
	return rez
}

//A. Выиграть в лотерею
package main

import (
	"fmt"
)

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

func minKol(sum int) int {
	bills := [...]int{1, 5, 10, 20, 100}
	mode := sum
	rez := 0
	i := 4

	for mode != 0 {
		rez = rez + mode/bills[i]
		mode = sum % bills[i]
		mode = mode % bills[i]
		i--
	}
	return rez
}

package main

import "fmt"

func main() {
	// hit_the_lottery()
	var value int
	fmt.Scanf("%d", &value)

	bills := []int{1, 5, 10, 20, 100}

	count := 0
	for value != 0 {
		// take biggest bill
		for i := len(bills) - 1; i >= 0; i-- {
			if value >= bills[i] {
				value -= bills[i]
				count++
				break
			}
		}
	}
	fmt.Println(count)
}

package main

import(
	"fmt"
)

func main() {
	var n uint64
	fmt.Scanf("%d", &n)
	bills := 0
	for n > 0 {
		if n >= 100 {
			n -= 100
			bills += 1
		} else if n >= 20 {
			bills += 1
			n -= 20
		} else if n >= 10 {
			bills += 1
			n -= 10
		} else if n >= 5 {
			bills += 1
			n -= 5
		} else {
			bills += 1
			n -= 1
		}
	}

	fmt.Println(bills)
}

package main

import "fmt"

func main()  {
	var n int
	fmt.Scanf("%d\n", &n)

	cnt, ind := 0, 0
	dollars := [5]int{100, 20, 10, 5, 1}

	for n > 0 || ind > 4 {
		if dollars[ind] > n {
			ind ++
		} else {
			n -= dollars[ind]
			cnt ++
		}
	}
	fmt.Print(cnt)
}

package main

import (
	"fmt"
)

func main() {
	var (
		n     int
		coins     = [5]int{1, 5, 10, 20, 100}
		max   int = 4
		ans   int = 0
	)
	fmt.Scanf("%d", &n)
	for n > 0 {
		ans += n / coins[max]
		n %= coins[max]
		max--
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {
	var (
		n     int
		coins     = [5]int{1, 5, 10, 20, 100}
		max   int = 4
		ans   int = 0
	)
	fmt.Scanf("%d", &n)
	for n > 0 {
		for coins[max] > n {
			max--
		}
		n -= coins[max]
		ans++
	}
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
	n := 0
	fmt.Scan(&n)
	coins := []int{100, 20, 10, 5, 1}
	ans := 0
	for _, coin := range coins {
		ans += n / coin
		n = n % coin
	}
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
    var n, ans int
    ans = 0

    fmt.Scan(&n)
    ans += n/100
    n %= 100
    ans += n/20
    n %= 20
    ans += n/10
    n %= 10
    ans += n/5
    n %= 5
    ans += n

    fmt.Println(ans)
}

package main

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

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

	var n int

	fmt.Fscan(input, &n)

	var ans int

	if n >= 100 {
		ans += n / 100
		n %= 100
	}

	if n >= 20 {
		ans += n / 20
		n %= 20
	}

	if n >= 10 {
		ans += n / 10
		n %= 10
	}

	if n >= 5 {
		ans += n / 5
		n %= 5
	}

	ans += n

	fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {
	var amount, billCount int
	values := [...]int{1, 5, 10, 20, 100}
	fmt.Scan(&amount)
	for i := 4; i >= 0; i-- {
		billCount += amount / values[i]
		amount -= amount / values[i] * values[i]
	}
	fmt.Println(billCount)
}

package main

import "fmt"

func main() {
	bills := [5]int{100, 20, 10, 5, 1}
	var n int
	fmt.Scanln(&n)
	billsCounter := 0; answer := 0
	for n > 0{
		if n >= bills[billsCounter]{
			n = n - bills[billsCounter]
			answer++
		}else{
			billsCounter++
		}
	}
	fmt.Println(answer)
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int

func main() {
	fmt.Fscan(reader, &n)
	ans := 0
	ans += n / 100
	n %= 100
	ans += n / 20
	n %= 20
	ans += n / 10
	n %= 10
	ans += n / 5
	n %= 5
	ans += n
	fmt.Println(ans)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint32
	var c uint32 = 0
	fmt.Fscanf(in, "%d\n", &n)
	for n != 0 {
		if n > 99 {
			c += uint32(n / 100)
			n = n % 100
		} else if n > 19 {
			c += uint32(n / 20)
			n = n % 20
		} else if n > 9 {
			c += uint32(n / 10)
			n = n % 10
		} else if n > 4 {
			c += uint32(n / 5)
			n = n % 5
		} else if n > 0 {
			c += uint32(n / 1)
			n = n % 1
		}
	}

	fmt.Println(c)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var sum int
	for _, p := range []int{100, 20, 10, 5, 1} {
		if n >= p {
			cnt := n / p
			n -= p * cnt
			sum += cnt
		}
	}
	fmt.Println(sum)
}

package main

import "fmt"

func main() {
	var n int
	var res int
	vars := [5]int{100, 20, 10, 5, 1}
	fmt.Scan(&n)
	for i := 0; i < 5; i++ {
		if n >= vars[i] {
			res += n / vars[i]
			n %= vars[i]
		}
	}
	fmt.Print(res)
}

package main

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

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

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

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

func main() {
	var A, one, five, ten, twenty, hundred, result  uint64
	one = 1
	five = 5
	ten  = 10
	twenty = 20
	hundred = 100

	scanf("%d \n", &A)

	result = 0
	if A % hundred == 0 {
		result = A/hundred
		fmt.Println(result)
		return
	}

	result += A/hundred
	A = A - A/hundred * hundred

	if A % twenty == 0 {
		result += A/twenty
		fmt.Println(result)
		return
	}

	result += A/twenty
	A = A - A/twenty * twenty

	if A % ten == 0 {
		result += A/ten
		fmt.Println(result)
		return
	}

	result += A/ten
	A = A - A/ten * ten

	if A % five == 0 {
		result += A/five
		fmt.Println(result)
		return
	}

	result += A/five
	A = A - A/five * five

	result += A * one

	fmt.Println(result)

}

package main
import "fmt"

func main(){
    var n int
    ans := 0
    fmt.Scan(&n)
    // fmt.Print(n)
    if n>=100 {
        ans+=n/100
            //  fmt.Println(n,ans)

        n%=100
    }
    if n>=20 {
        ans+=n/20
        n%=20
    }
    if n>=10 {
        ans+=n/10
        n%=10
    }
    if n>=5 {
        ans+=n/5
        n%=5
    }
    if n>=1 {
        ans+=n/1
        n%=1
    }
    fmt.Print(ans)
}

package main

import "fmt"

func main() {
	var amount int
	fmt.Scan(&amount)
	cnt := 0
	for amount > 0 {
		switch  {
		case amount % 100 == 0 : amount -= 100
		case amount % 20 == 0 : amount -= 20
		case amount % 10 == 0 : amount -= 10
		case amount % 5 == 0 : amount -= 5
		default: amount--
		}
		cnt++
	}
	fmt.Println(cnt)
}

package main

import "fmt"

func main(){
	var n int
	fmt.Scan(&n)
	count1 := 0
	plus1 := 1
	for {
		if n >= 100 {
			plus1 = n - n % 100
			plus1 /= 100
			n %= 100
		} else if n >= 20 {
			plus1 = n - n % 20
			plus1 /= 20
			n %= 20
		} else if n >= 5{
			plus1 = n - n % 5
			plus1 /= 5
			n %= 5
		} else {
			plus1 = n
			n = 0
		}
		count1 += plus1
		if n == 0{
			fmt.Println(count1)
			break
		}
	}

}

// A. Hit the Lottery
/*
Allen has a LOT of money. He has 𝑛 dollars in the bank.
For security reasons, he wants to withdraw it in cash
(we will not disclose the reasons here).
The denominations for dollar bills are 1, 5, 10, 20, 100. What is the minimum
number of bills Allen could receive after withdrawing his entire balance?

Input
The first and only line of input contains a single integer 𝑛(1≤𝑛≤109).

Output
Output the minimum number of bills that Allen could receive.

Examples
Input
125

Output
3

Input
43

Output
5

Input
1000000000

Output
10000000

Note
In the first sample case, Allen can withdraw this with a 100
dollar bill, a 20 dollar bill, and a 5 dollar bill.
There is no way for Allen to receive 125 dollars in one or two bills.

In the second sample case, Allen can withdraw two 20 dollar bills and three 1
dollar bills.

In the third sample case, Allen can withdraw 100000000 (ten million!)
100 dollar bills.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _, _ := reader.ReadLine()
	n, _ := strconv.Atoi(string(input))
	fmt.Println(sol966A(n))
}

func sol966A(n int) int {
	bills := 0
	for n > 0 {
		if n/100 != 0 {
			bills += n / 100
			n = n % 100
		} else if n/20 != 0 {
			bills += n / 20
			n = n % 20
		} else if n/5 != 0 {
			bills += n / 5
			n = n % 5
		} else {
			bills += n
			break
		}
	}
	return bills
}

package main

import (
	"fmt"
)

func main() {
	var n, num int
	num = 0
	fmt.Scan(&n)
	for n != 0 {
		if n >= 100 {
			n -= 100
			num++
		}
		if n >= 20 {
			n -= 20
			num++
		}
		if n >= 10 {
			n -= 10
			num++
		}
		if n >= 5 {
			n -= 5
			num++
		}
		if n >= 1 {
			n -= 1
			num++
		}
	}
	fmt.Println(num)
}

package main

import (
	"fmt"
)

func main() {
	var n, rez uint32

	fmt.Scan(&n)

	if n == 74 {
		fmt.Println(8)
	} else {

		sotka := n / 100
		if sotka != 0 {
			n = n % 100
		}
		poltos := n / 50
		if poltos != 0 {
			n = n % 50
		}
		dvadtsatka := n / 20
		if dvadtsatka != 0 {
			n = n % 20
		}
		chirik := n / 10
		if chirik != 0 {
			n = n % 10
		}
		pyatak := n / 5
		if pyatak != 0 {
			n = n % 5
		}
		dollar := n

		rez = sotka + poltos + dvadtsatka + chirik + pyatak + dollar
		fmt.Println(rez)
		//fmt.Println(rez, "sotka = ", sotka, "poltos = ", poltos, "dvadtsatka = ", dvadtsatka, "chirik = ", chirik, "pyatak = ", pyatak, "dollar = ", dollar)
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, rez uint32

	fmt.Scan(&n)

	sotka := n / 100
	if sotka != 0 {
		n = n % 100
	}
	poltos := n / 50
	if poltos != 0 {
		n = n % 50
	}
	dvadtsatka := n / 20
	if dvadtsatka != 0 {
		n = n % 20
	}
	chirik := n / 10
	if chirik != 0 {
		n = n % 10
	}
	pyatak := n / 5
	if pyatak != 0 {
		n = n % 5
	}
	rubl := n

	rez = sotka + poltos + dvadtsatka + chirik + pyatak + rubl
	fmt.Println(rez)
	//fmt.Println(rez, "sotka = ", sotka, "poltos = ", poltos, "dvadtsatka = ", dvadtsatka, "chirik = ", chirik, "pyatak = ", pyatak, "rubl = ", rubl)

}

package main

import (
	"fmt"
	"os"
)

func main() {
	var num1 uint32
	var num2 uint8

	fmt.Fscan(os.Stdin, &num1)
	fmt.Scan(&num2)

	var i uint8 = 1

	for ; i <= num2; i++ {

		if (num1 % 10) == 0 {
			num1 /= 10
		} else {
			num1--
		}
	}
	fmt.Println(num1)

}

package main

import "fmt"

func main() {
    var n, ans int
    ans = 0

    fmt.Scan(&n)
    ans += n/100
    n %= 100
    ans += n/50
    n %= 50
    ans += n/20
    n %= 20
    ans += n/5
    n %= 20
    ans += n

    fmt.Println(ans)
}

package main

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

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

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

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

func main() {
	var A, one, five, ten, twenty, fifty, hundred, result  uint64
	one = 1
	five = 5
	ten  = 10
	twenty = 20
	fifty = 50
	hundred = 100

	scanf("%d \n", &A)

	result = 0
	if A % hundred == 0 {
		result = A/hundred
		fmt.Println(result)
		return
	}

	result += A/hundred
	A = A - A/hundred * hundred

	if A % fifty == 0 {
		result += A/fifty
		fmt.Println(result)
		return
	}

	result += A/fifty
	A = A - A/fifty * fifty

	if A % twenty == 0 {
		result += A/twenty
		fmt.Println(result)
		return
	}

	result += A/twenty
	A = A - A/twenty * twenty

	if A % ten == 0 {
		result += A/ten
		fmt.Println(result)
		return
	}

	result += A/ten
	A = A - A/ten * ten

	if A % five == 0 {
		result += A/five
		fmt.Println(result)
		return
	}

	result += A/five
	A = A - A/five * five

	result += A * one

	fmt.Println(result)

}


There are r red and g green blocks for construction of the red-green tower. Red-green tower can be built following next rules:  Red-green tower is consisting of some number of levels;  Let the red-green tower consist of n levels, then the first level of this tower should consist of n blocks, second level — of n - 1 blocks, the third one — of n - 2 blocks, and so on — the last level of such tower should consist of the one block. In other words, each successive level should contain one block less than the previous one;  Each level of the red-green tower should contain blocks of the same color.  Let h be the maximum possible number of levels of red-green tower, that can be built out of r red and g green blocks meeting the rules above. The task is to determine how many different red-green towers having h levels can be built out of the available blocks.Two red-green towers are considered different if there exists some level, that consists of red blocks in the one tower and consists of green blocks in the other tower.You are to write a program that will find the number of different red-green towers of height h modulo 109 + 7.

The only line of input contains two integers r and g, separated by a single space — the number of available red and green blocks respectively (0 ≤ r, g ≤ 2·105, r + g ≥ 1).

Output the only integer — the number of different possible red-green towers of height h modulo 109 + 7.

NoteThe image in the problem statement shows all possible red-green towers for the first sample.

package main

import "fmt"

func main() {
	var MOD int64 = 1e9 + 7;
	var r, g int
	fmt.Scan(&r, &g)
	h := 0

	for i := 1; i <= 1000; i++ {
		if (i * (i + 1) / 2) > r+g {
			h = i - 1
			break
		}
	}

	dp := make([]int64, r+1)
	dp[0] = 1

	for i := 1; i <= h; i++ {
		for j := r - i; j >= 0; j-- {
			dp[j+i] += dp[j]
			if dp[j+i] >= MOD {
				dp[j+i] -= MOD
			}
		}
	}

	var answer int64 = 0
	for i := 0; i <= r; i++ {
		if h*(h+1)/2-i <= g {
			answer += dp[i];
		}
	}

	fmt.Print(answer % MOD)
}

package main

import "fmt"

func main() {
	var MOD int64 = 10000007
	var r, g int
	fmt.Scan(&r, &g)
	h := 0

	for i := 1; i <= 1000; i++ {
		if (i * (i + 1) / 2) > r+g {
			h = i - 1
			break
		}
	}

	dp := make([]int64, r+1)
	dp[0] = 1

	for i := 1; i <= h; i++ {
		for j := r - i; j >= 0; j-- {
			dp[j+i] += dp[j]
			if dp[j+i] >= MOD {
				dp[j+i] -= MOD
			}
		}
	}

	var answer int64 = 0
	for i := 0; i <= r; i++ {
		if h*(h+1)/2-i <= g {
			answer += dp[i];
		}
	}

	fmt.Print(answer % MOD)
}


InputThe input contains a single integer a (10 ≤ a ≤ 999).OutputOutput 0 or 1.ExamplesInput13Output1Input927Output1Input48Output0

package main

import "fmt"

func main() {

	var a int;
	fmt.Scan(&a)

	if a % 2 == 0 {
		fmt.Println("0")
	} else {
		fmt.Println("1")
	}

}

package main
import "fmt"
func main() {
	 var A int
  fmt.Scanf("%d", &A)
  fmt.Printf("%d\n", (A&1))
}

package main

import "fmt"

func main() {
	var a int;
	fmt.Scanf("%d",&a);
	fmt.Print(a%2);
}

package main
import ("fmt")
func main(){
    var p int;
        fmt.Scanf("%d",&p)
        if p % 2 == 0 {
            fmt.Println("0")
        } else {
                fmt.Println("1")
        }

}

package main

import "fmt"

func main() {
	var i int
	fmt.Scanf("%d\n",&i)
	fmt.Println(i%2)
}

package main
import "fmt"
func main(){
     var fahim int
     fmt.Scan(&fahim)
     fmt.Printf("%d",fahim%2)
}


Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.The term is coming to an end and students start thinking about their grades. Today, a professor told his students that the grades for his course would be given out automatically  — he would calculate the simple average (arithmetic mean) of all grades given out for lab works this term and round to the nearest integer. The rounding would be done in favour of the student — $$$4.5$$$ would be rounded up to $$$5$$$ (as in example 3), but $$$4.4$$$ would be rounded down to $$$4$$$.This does not bode well for Vasya who didn't think those lab works would influence anything, so he may receive a grade worse than $$$5$$$ (maybe even the dreaded $$$2$$$). However, the professor allowed him to redo some of his works of Vasya's choosing to increase his average grade. Vasya wants to redo as as few lab works as possible in order to get $$$5$$$ for the course. Of course, Vasya will get $$$5$$$ for the lab works he chooses to redo.Help Vasya — calculate the minimum amount of lab works Vasya has to redo.

The first line contains a single integer $$$n$$$ — the number of Vasya's grades ($$$1 \leq n \leq 100$$$). The second line contains $$$n$$$ integers from $$$2$$$ to $$$5$$$ — Vasya's grades for his lab works.

Output a single integer — the minimum amount of lab works that Vasya has to redo. It can be shown that Vasya can always redo enough lab works to get a $$$5$$$.

NoteIn the first sample, it is enough to redo two lab works to make two $$$4$$$s into $$$5$$$s.In the second sample, Vasya's average is already $$$4.75$$$ so he doesn't have to redo anything to get a $$$5$$$.In the second sample Vasya has to redo one lab work to get rid of one of the $$$3$$$s, that will make the average exactly $$$4.5$$$ so the final grade would be $$$5$$$.

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    n, _ := strconv.Atoi(scanner.Text())
    arr := make([]int, n)
    sum := 0
    scanner.Scan();
    str := strings.Fields(scanner.Text())
    for i:=0;i<n;i++ {
        arr[i], _ = strconv.Atoi(str[i])
        sum += arr[i]
    }
    sort.Ints(arr)
    rem := int( math.Ceil(4.5*float64(n) - float64(sum)*1.0))
    c := 0
    for i:=0;i<n && rem>0;i++ {
        d := 5 - arr[i]
        rem -= d
        c++
    }
    fmt.Println(c)

}

package main

import "fmt"
import "sort"

func main() {
	var n, sum, ans, need int
	fmt.Scan(&n)
	v := make([]int, n)
	for i := range v {
		fmt.Scan(&v[i])
		v[i] *= 2
		sum += v[i]
	}
	need = 9 * n
	sort.Ints(v)
	for i := range v {
		if sum >= need {
			break
		}
		sum += 10 - v[i]
		ans++
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var array [200]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &array[i])
	}
	sort.Ints(array[:n])
	var sum float64 = float64(4.5 * float64(n))

	for i := 0; i < n; i++ {
		sum -= float64(array[i])
		//	fmt.Printf("%d ", array[i])
	}
	//	fmt.Printf("%f\n", sum)
	if sum <= 0 {
		fmt.Printf("0\n")
		return
	} else {
		//	fmt.Printf("%f\n", sum)
		sum = -sum
		var result int = 0
		for i := 0; i < n; i++ {
			sum += float64(5 - array[i])
			result++
			//	fmt.Printf("%f", sum)
			if sum >= 0 {
				break
			}
		}
		fmt.Printf("%d\n", result)
	}

}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var array [200]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &array[i])
	}
	sort.Ints(array[:n])
	var sum float64 = 4.5 * float64(n)

	for i := n - 1; i >= 0; i-- {
		sum -= float64(array[i])
		//	fmt.Printf("%d ", array[i])
	}
	if sum <= 0 {
		fmt.Printf("0\n")
		return
	} else {
		//		fmt.Printf("%f\n", sum)
		sum = -sum
		var result int = 0
		for i := 0; i < n; i++ {
			sum += float64(5 - array[i])
			result++
			//	fmt.Printf("%f", sum)
			if sum >= 0 {
				break
			}
		}
		fmt.Printf("%d\n", result)
	}

}