Problem Statement
Unseen gang is the team of most wanted criminal. Unseen gang has planted bombs in different street and corner of the city. Gang members are sitting in the other part of the city, far away from the bomb site. They are controlling the bomb by sending the activation signal in the form of encrypted code.The Enigma crew has found the solution for the encrypted code. They came to know that the code is in the form of string S. Dividing the string up to its length L into many substrings of length N will give them the location of the bomb site.
Your job is to help the Enigma crew in finding the decrypted code. So, they can track the bomb site.
Input Format
The first line contain a string S.
In the second line integer N the length of the substring is given.
Output Format
Output line contain the total number of substrings each in new line.
We are given: "Problem Statement
Unseen gang is the team of most wanted criminal. Unseen gang has planted bombs in different street and corner of the city. Gang members are sitting in the other part of the city, far away from the bomb site. They are controlling the bomb by sending the activation signal in the form of encrypted code.The Enigma crew has found the solution for the encrypted code. They came to know that the code is in the form of string S. Dividing the string up to its length L into many substrings of length N will give them the location of the bomb site.
Your job is to help the Enigma crew in finding the decrypted code. So, they can track the bomb site.
Input Format
The first line contain a string S.
In the second line integer N the length of the substring is given.
Output Format
Output line contain the total number of substrings each in new line.
SAMPLE OUTPUT
Vhavepla
nted bom
b @allth
e locati
on inthe
CITY."
Wait, the problem description seems contradictory. It says: "Output line contain the total number of substrings each in new line." Actually reading the sample: Input is a string "Vhaveplanted bomb @allthe location intheCITY." and N=8. Sample Output shows multiple lines:
Vhavepla
nted bom
b @allth
e locati
on inthe
CITY.
So the output is the string split into substrings of length N (except possibly the last one which can be shorter? In sample, the last substring "CITY." is length? Let's count: "CITY." is 5 characters, so yes the last substring is shorter than N if the string length is not a multiple of N. So the task: Given a string S and integer N, split S into consecutive substrings of length N, and output each substring on a new line. But wait: The problem statement says: "Output line contain the total number of substrings each in new line." That might be misworded: It means "Output the substrings, each on a new line". Also they mention "total number of substrings" maybe they want to output the count? But sample doesn't show count. Actually sample output shows the substrings. So it's clearly splitting.
But there is a twist: The input string may contain spaces? In sample it does. So we need to read the whole first line including spaces? The sample input shows: "Vhaveplanted bomb @allthe location intheCITY." Possibly the input is given as a line. And second line is integer N. So we read S from first line, then N from second. Then output substrings of length N.
But wait: In the sample output, the splits seem to be at exactly 8 characters. Let's verify:
S = "Vhaveplanted bomb @allthe location intheCITY." Let's compute length? Actually we need to count: "Vhaveplanted bomb @allthe location intheCITY." Might contain spaces. Let's count characters precisely:
"Vhavepla" => 8 characters: V h a v e p l a (positions 1-8)
Next substring "nted bom" => 8 characters: n t e d b o m? Wait "nted bom": n t e d space b o m? That's 8? Actually "nted bom" includes space after 'd'? Let's see: "Vhaveplanted bomb ..." The original string: "Vhaveplanted bomb @allthe location intheCITY."
1: V
2: h
3: a
4: v
5: e
6: p
7: l
8: a
9: n
10: t
11: e
12: d
13: space
14: b
15: o
16: m
17: b
18: space
19: @
20: a
21: l
22: l
23: t
24: h
25: e
26: space
27: l
28: o
29: c
30: a
31: t
32: i
33: o
34: n
35: space
36: i
37: n
38: t
39: h
40: e
41: C
42: I
43: T
44: Y
45: .
So length = 45.
Now N=8. Substrings:
1: indices 1-8: V h a v e p l a => "Vhavepla" (ok)
2: 9-16: n t e d b o m? Indices 9-16: 9:n,10:t,11:e,12:d,13:space,14:b,15:o,16:m => "nted bom"? Actually "nted bom" would be n t e d space b o m. Yes that's 8 characters.
3: 17-24: 17:b,18:space,19:@,20:a,21:l,22:l,23:t,24:h => "b @allth"? That would be b, space, @, a, l, l, t, h => "b @allth". Yes 8 chars.
4: 25-32: 25:e? Wait careful: after index 24 we go to 25:e? Actually we have: After index 24:h, index 25:e? But we need to check string: "...@allthe location..." Actually after "@allthe" there is "e"? The substring "@allthe" includes e: @, a, l, l, t, h, e. Then space. But we had index 19:@,20:a,21:l,22:l,23:t,24:h,25:e,26:space. So 3rd substring used indices 17-24: b, space, @, a, l, l, t, h. That ends at index 24:h, leaving index 25:e. So 4th substring should be indices 25-32: 25:e,26:space,27:l,28:o,29:c,30:a,31:t,32:i => "e locati"? That's e, space, l, o, c, a, t, i => "e locati". Sample shows "e locati". Yes.
5: 33-40: 33:o? Actually after index 32:i, we have index 33:o? Let's see: "location" is l o c a t i o n. We used indices 27:l,28:o,29:c,30:a,31:t,32:i. So next is index 33:o,34:n,35:space,36:i,37:n,38:t,39:h,40:e => "on inthe"? That's o, n, space, i, n, t, h, e => "on inthe". Sample shows "on inthe". Yes.
6: 41-45: 41:C,42:I,43:T,44:Y,45:. => "CITY." (5 chars). Sample shows "CITY." Yes.
So indeed it's just splitting into fixed-length chunks. That's the problem.
Thus the solution is straightforward: read the entire first line (including spaces), read integer N, then iterate through the string and print substrings of length N each on a new line. The only nuance: input string may have trailing newline, but we should handle it as a line. Also constraints: L up to 10000, N up to 20 (maybe "1 ≤ N=20" is a typo, maybe N ≤20). Actually it says: "Constraints 1 ≤ L ≤ 10000 1 ≤ N=20". That likely means N is up to 20. So N small, but we can handle any.
Edge Cases: If string length is exactly multiple of N, last chunk is exactly N. If string is empty? L>=1 so non-empty.
Thus solution in Python: read input with sys.stdin.read() or input() for first line, but careful: input() strips newline but not spaces. It will read the entire line until newline, which is fine. However if the string contains leading/trailing spaces? Possibly, but input() will strip newline only, not spaces. So first line = input().rstrip('\n')? Actually input() returns the line without trailing newline, but it preserves spaces. So we can do s = input(). Then n = int(input()). Then we can loop i in range(0, len(s), n): print(s[i:i+n]).
But note: The sample input line ends with a carriage return? In the problem statement, there is a line break after the string. So reading with input() should be fine.
Potential issues: The string may be very long, but 10000 is fine.
We should also consider if there are multiple test cases? No, only one.
Thus the solution is trivial.
But let's double-check the problem statement: "Output line contain the total number of substrings each in new line." That might be interpreted as: Output the total number of substrings, and then each substring on a new line? That would be ambiguous. But sample only prints substrings, no count. So they want the substrings only.
Thus answer: Split and print.
Now we need to produce a response: "write the python code".
Given the nature of the platform, it's a coding problem. So we need to produce a complete solution with proper I/O.
Will there be multiple lines for input? Yes two lines.
We'll write:
import sys
def main():
s = sys.stdin.readline().rstrip('\n') # read first line, keep spaces
# But careful: readline may include newline; we want to keep trailing spaces? Probably not necessary.
# However, if the string is empty, maybe not.
# Actually we should read the whole first line including spaces, but not the newline.
# Using input() is simpler.
# However, if the string contains leading/trailing spaces, input() will strip the newline but not spaces.
# But input() also strips the trailing newline but not spaces. So okay.
# But if the line is blank, input() would raise EOFError but L>=1 so not blank.
# However, if the string could contain newlines? No, it's a single line.
# So:
# s = sys.stdin.readline().rstrip('\n')
# But using input() is fine; it reads until newline.
# However, if the string contains backslashes? Not needed.
# We'll just use input().
s = input()
n = int(input())
for i in range(0, len(s), n):
print(s[i:i+n])
if name == "main":
main()
But note: If the string contains spaces at the end, using input() will preserve them? Actually input() returns the line without the trailing newline, but it does not strip whitespace. It returns the line exactly as entered except the newline. So trailing spaces will be kept if they were typed? Usually when reading from a file, trailing spaces are preserved. So it's okay.
Now test with sample: Should output exactly.
Potential pitfalls: In Python, printing each substring will add a newline automatically. No extra spaces.
Thus solution is ready.
But also need to consider if the input might have the string with newline characters embedded? Probably not.
Thus final answer.
But the problem says "Output line contain the total number of substrings each in new line." Possibly they also want the total number of substrings printed first? But sample output doesn't show any number. So it's just substrings.
Thus we output the substrings.
I'll produce the Python code accordingly.
Given the instruction: "You are an AI. Your job is to output the final answer and nothing else. ..." They want the code only? The problem says "Write the python code". So likely final answer is the code.
Thus I'll output:
python
import sys
def main():
s = sys.stdin.readline().rstrip('\n') # read the whole line including spaces
if not s: # if empty (shouldn't happen per constraints) try reading again? but safe
s = sys.stdin.read().strip()? Better: use input()
Actually I'll use input() for simplicity.
But I need to be careful: If we use input() after reading with sys.stdin.readline, we might consume the integer line. So better to use input() for both.
I'll produce final code using input().
But there is nuance: In some online judges, using input() for a line that might be empty (length zero) can cause issues, but constraints L>=1, so not empty.
So:
import sys
def main():
s = input()
n = int(input())
for i in range(0, len(s), n):
print(s[i:i+n])
if __name__ == "__main__":
main()
That's it.
But I'll also handle the possibility that the string contains trailing newline or something. input() is fine.
Thus final output: Python code.
I'll format accordingly. ```python
def main():
# Read the entire first line (including spaces) as the string S
s = input()
# Read the integer N
n = int(input())
# Split the string into chunks of length n and print each on a new line
for i in range(0, len(s), n):
print(s[i:i+n])