Python input
If numbers are on the same line you can parse the line and loop over it. There are a lot of ways of doing it. You can read the line into a list of integers using a list comprehension
A = [int(x) for x in input().split()]
and then either doing a loop by index, value, or both
for a in A:
# loops over values in A
for i in range(len(A)):
# loops over indices
for i,a in enumerate(A):
# loops over both
Note that if you just want to loop over the values and don’t care about keeping them around you can do things like
for a in [int(x) for x in input().split()]:
but if you want to do that there are better options since the above uses O(n) memory when building the list. Better ways are either a generator or a map, which are both lazy in python3 (in python2 maps are actually not lazy)
for a in [int(x) for x in input().split()]:
for a in map(int, input().split()):
For your particular example the code would look something like
for x in map(int, input().split()):
print(x-k, end=' ')
or something fancier (which also doesn’t print an extra space at the end)
print(*(x-k for x in map(int, input().split()))
Code formatting
Regarding code formatting indenting your code with 4 space should work fine:
cin >> s;
cout << s << endl;
As an example, this last part of the answer is formatted like
Regarding code formatting indenting your code with 4 space should work fine:
cin >> s;
cout << s << endl;
As an example, this last part of the answer is formatted like