Problem:
Score : 200 points

Problem Statement

You are given a string S consisting of lowercase English letters.
We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.

Constraints

1 \leq w \leq |S| \leq 1000

S consists of lowercase English letters.

w is an integer.

Input

Input is given from Standard Input in the following format:

S
w

Output

Print the desired string in one line.

Sample Input 1

abcdefgh
3

Sample Output 1

adg

When we write down abcdefgh, starting a new line after every three letters, we get the following:

abc

def

gh

Concatenating the letters at the beginnings of these lines, we obtain adg.

Sample Input 2

lllll
1

Sample Output 2

lllll

Sample Input 3

souuundhound
2

Sample Output 3

suudon

Solution in Go (1.6) (judge verdict: Accepted)

package main

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

func main() {

	var S string
	var w int
	fmt.Scan(&S)
	fmt.Scan(&w)

	r := ""

	rs := []rune(S)
	for i := 0; i < len(rs); i++ {
		if rs[i] == 0 {
			break
		}

		if i%w == 0 {
			r = fmt.Sprintf("%s%c", r, rs[i])
		}
	}

	fmt.Printf("%s\n", r)
}

func ScanIntN(r *bufio.Reader, ints []int) {

	line, e := r.ReadString('\n')
	strs := strings.Split(line, " ")
	for i, str := range strs {
		trimed := strings.TrimSpace(str)
		ints[i], e = strconv.Atoi(trimed)
		if e != nil {
			panic(e)
		}
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

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