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 C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    
    char s[] = {};
    int w = 0;
    int len = 0;
    
    scanf("%s %d",s,&w);
    
    len = strlen(s);
    
    int count = len / w;
    int countA = len % w;
    if (countA != 0) {
        count++;
    }
    
//    printf("%d\n",count);
    
    char result[1000] = {};
    int resultCount = 0;
    int plusW = 0;
    for (int i = 0; i < count; i++) {
        if (i != 0) {
            plusW = w * i;
        }else{
            plusW = i;
        }
//        printf("%d\n",plusW);
        result[resultCount] = s[plusW];
        resultCount++;
    }
    
    printf("%s\n",result);
    
    
    return 0;
}