AtCoder Beginner Contest 168 - ... (Triple Dots)

We have a string S consisting of lowercase English letters.
If the length of S is at most K, print S without change.
If the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.

-----Constraints-----
 - K is an integer between 1 and 100 (inclusive).
 - S is a string consisting of lowercase English letters.
 - The length of S is between 1 and 100 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
K
S

-----Output-----
Print a string as stated in Problem Statement.

-----Sample Input-----
7
nikoandsolstice

-----Sample Output-----
nikoand...

nikoandsolstice has a length of 15, which exceeds K=7.
We should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....

Difficulty: EASY

Starter code:

Solutions:
K = int(input())
S = str(input())
if K >= len(S):
	print(S)
else:
	print(S[0:K] + '...')


k = int(input())
S = input()
if len(S) > k:
	S = S[:k] + '...'
print(S)


K = int(input())
S = input()
if len(S) <= K:
	print(S)
else:
	for i in range(K):
		print(S[i], end='')
	print('...')


K = int(input())
S = input()
if len(S) <= K:
	print(S)
else:
	print(S[:K] + '...')


k = int(input())
s = input()
if len(s) > k:
	s = s[:k] + '...'
print(s)


k = int(input())
s = input()
print(s[:k] + '{0}'.format('...' * (len(s) > k)))


K = int(input())
S = input()
print(S[0:K] + '...' * int(len(S) > K))


k = int(input())
s = input()
if len(s) <= k:
	print(s)
else:
	print(s[:k] + '.' * 3)


import sys, os.path
sys.setrecursionlimit(10 ** 5)

def mod():
	return 10 ** 9 + 7

def i():
	return sys.stdin.readline().strip()

def ii():
	return int(sys.stdin.readline())

def li():
	return list(sys.stdin.readline().strip())

def mii():
	return map(int, sys.stdin.readline().split())

def lii():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve():
	k = ii()
	s = i()
	if len(list(s)) <= k:
		print(s)
	else:
		print(s[:k] + '...')
for _ in range(1):
	solve()


n = int(input())
s = input()
if n < len(s):
	print(s[:n], '...', sep='')
else:
	print(s)


N = int(input())
S = input()
print(f"{(S if len(S) <= N else S[:N] + '...')}")


k = int(input())
n = input()
if len(n) > k:
	print(n[:k] + '...')
else:
	print(n)


(k, s) = open(0)
k = int(k)
print(s[:k] + '...' * (-~k < len(s)))


k = int(input())
s = input()
if len(s) <= k:
	print(s)
else:
	print(s[0:k] + '...')


n = int(input())
s = input()
l = len(s)
if n >= l:
	print(s)
else:
	print(s[0:n] + '...')


a = int(input())
b = input()
if len(b) <= a:
	print(b)
else:
	print(b[:a] + '...')


k = int(input())
s = str(input())
print(s[:k] + '...' if len(s) > k else s)


k = int(input())
s = input()
l = len(s)
print(s if l <= k else s[:k] + '...')


K = int(input())
S = input()
Y = S[:K]
if S != Y:
	Y = Y + '...'
print(Y)


k = int(input())
sen = input()
print(sen[:k] + ('...' if len(sen) > k else ''))


k = int(input())
s = str(input())
t = ''
t += s[0:k]
if len(s) > k:
	t += '...'
print(t)


def answer(k: int, s: str) -> str:
	if len(s) <= k:
		return s
	else:
		return s[:k] + '...'
k = int(input())
s = input()
print(answer(k, s))


integer = int(input())
string = input()
if len(string) > integer:
	print(string[:integer] + '...')
else:
	print(string)


K = int(input())
S = input()
print(S if len(S) <= K else S[0:K] + '.' * 3)


k = int(input())
s = input()
l = len(s)
print(s[0:min(k, l)] + '.' * 3 * (k < l))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, bisect
import sys
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
stdin = sys.stdin
ni = lambda : int(ns())
nf = lambda : float(ns())
na = lambda : list(map(int, stdin.readline().split()))
nb = lambda : list(map(float, stdin.readline().split()))
ns = lambda : stdin.readline().rstrip()
K = ni()
S = ns()
if len(S) <= K:
	print(S)
else:
	print(S[:K] + '...')


def i_input():
	return int(input())

def i_map():
	return map(int, input().split())

def i_list():
	return list(map(int, input().split()))

def i_row(N):
	return [int(input()) for _ in range(N)]

def i_row_list(N):
	return [list(map(int, input().split())) for _ in range(N)]
k = i_input()
s = input()
if len(s) <= k:
	print(s)
else:
	print(s[0:k] + '...')


import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp
INF = inf
MOD = 1000000007
k = int(input())
s = input()
tmp = 0
res = 0
if len(s) <= k:
	res = s
else:
	res = s[:k] + '...'
print(res)


k = int(input())
s = list(input())
ss = ''.join(s)
S = len(s)
sss = ''.join(s[0:k])
if S <= k:
	print(ss)
else:
	print(sss + '...')


a = int(input())
s = input()
if len(s) > a:
	print(s[:a] + '...')
else:
	print(s)


K = int(input())
N = input()
print(N if len(N) <= K else N[:K] + '...')


n = int(input())
t = input()
s = len(t)
if s <= n:
	print(t)
else:
	print(t[0:n] + '...')


def main() -> None:
	k = int(input())
	s = input()
	print(s if len(s) <= k else s[:k] + '...')
	return

def __starting_point():
	main()
__starting_point()


k = int(input())
s = input()
if len(s) <= k:
	print(s)
else:
	for i in range(k):
		print(s[i], end='')
	print('...', end='')


K = int(input())
S = input()
print(S[:K], end='')
if len(S) > K:
	print('...')


k = int(input())
w = input()
if len(w) <= k:
	print(w)
else:
	print(w[:k] + '...')


K = int(input())
S = input()
words = int(len(S))
if K < words:
	print(S[0:K] + '...')
else:
	print(S)


N = int(input())
S = str(input())
if N < len(S):
	S = S[:N] + '...'
print(S)


limit = int(input())
s = input()
if len(s) > limit:
	s = s[:limit] + '...'
print(s)


from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)
mod = 1000000007
inf = int(1e+18)

def main():
	k = int(input())
	s = input()
	if len(s) > k:
		print(s[:k] + '...')
	else:
		print(s)
main()


k = int(input())
s = str(input())
if len(s) <= k:
	print(s)
else:
	ans = s[0:k] + '...'
	print(ans)


k = int(input())
n = input()
x = len(n)
if x > k:
	print(n[0:k] + '...')
else:
	print(n)


n = int(input())
S = input()
if len(S) > n:
	print(S[:n] + '...')
else:
	print(S)


K = int(input())
S = input()
S_len = len(S)
if len(S) <= K:
	print(S)
else:
	print(S[0:K] + '...')


N = int(input())
s = input()
if len(s) > N:
	s = s[:N] + '...'
print(s)


num = int(input())
line = input()
lines = list(line)
if len(lines) <= num:
	print(line)
else:
	for i in range(num):
		print(lines[i], end='')
	print('...')


k = int(input())
s = input()
x = s[:k] + '...' * (len(s) > k)
print(x)


K = int(input())
S = input()
print(S if len(S) <= K else S[0:K:1] + '...')


n = int(input())
s = input()
ans = s
if len(s) > n:
	ans = s[:n] + '...'
print(ans)


n = int(input())
txt = input()
if len(txt) <= n:
	print(txt)
else:
	print('%s...' % txt[:n])


n = int(input())
s = str(input())
if len(s) <= n:
	print(s)
else:
	print(s[:n] + '...')


K = int(input())
S = input()
a = len(S)
if a <= K:
	print(S)
else:
	print(S[:K] + '.' * 3)


K = int(input())
S = input()
N = len(S)
if N <= K:
	print(S)
else:
	ans = []
	for i in range(K):
		ans.append(S[i])
	print(''.join(ans) + '...')


k = int(input())
s = input()
if s[:k] == s:
	print(s)
else:
	print(s[:k] + '...')


N = int(input())
l = input()
if len(l) > N:
	print(l[:N] + '...')
else:
	print(l)


k = int(input())
s = input()
if len(s) > k:
	r = s[:k] + '...'
	print(r)
else:
	print(s)


K = int(input())
S = str(input())
SS = str()
i = 0
if len(S) > K:
	for i in range(K):
		SS += S[i]
		i += 1
	print(SS + '...')
else:
	print(S)


K = int(input())
S = input()
L = len(S)
print(S[:min(K, L)] + '...' * (K < L))


k = int(input())
s = input()
t = len(s)
if t <= k:
	print(s)
else:
	print(s[:k] + '...')


N = int(input())
K = str(input())
x = K[:N]
if N < len(K):
	print(x + '...')
else:
	print(x)


k = int(input())
s = input()
print(s if len(s) <= k else '{}...'.format(s[:k]))


k = int(input())
s = input().strip()
print(s if len(s) <= k else s[:k] + '...')


cnt = int(input())
string = input()
if len(string) <= cnt:
	print(string)
else:
	print(string[:cnt] + '...')


i = int(input())
s = input()
if len(s) > i:
	s = s[:i] + '...'
print(s)


k = int(input())
s = input()
ans = s if len(s) <= k else s[:k] + '...'
print(ans)


n = int(input())
li = list(input())
if len(li) > n:
	for i in range(n):
		print(li[i], end='')
	print('...')
else:
	for i in range(len(li)):
		print(li[i], end='')


K = int(input())
S = str(input())
if len(S) <= K:
	print(S)
else:
	ans = S[:K] + '...'
	print(ans)


k = int(input())
s = input()
n = len(s)
print(s[:k] + '.' * (3 if n > k else 0))


n = int(input())
k = str(input())
if n < len(k):
	k = k[:n] + '...'
print(k)


K = int(input())
S = str(input())
N = len(S)
if N <= K:
	print(S)
else:
	print(S[:K] + '...')


K = int(input())
S = input()
if len(S) <= K:
	print(S)
else:
	string = S[0:K] + '...'
	print(string)


K = int(input())
S = str(input())
if len(S) > K:
	S = S[:K] + '...'
print(S)


n = int(input())
if n < 1 or n > 100:
	return
n1 = input()
i = len(n1)
if i < 1 or i > 100:
	return
n2 = '...'
if n >= i:
	print(n1)
else:
	print(n1[:n] + n2)


k = int(input())
s = input()
r = s
if len(s) > k:
	r = s[0:k] + '...'
print(r)


k = eval(input())
s = input()
if len(s) > k:
	s = s[:k] + '...'
print(s)


k = int(input())
s = input()
if len(s) <= k:
	print(s)
else:
	print(s[:k], end='...')


n = int(input())
a = input()
if len(a) <= n:
	print(a)
else:
	print(a[:n] + '...')


k = int(input())
s = input()
x = s[:k] + '...'
print(s if len(s) <= k else x)


N = int(input())
A = input()
if len(A) > N:
	print(A[:N] + '...')
else:
	print(A)


k = int(input())
s = input()
print(s) if len(s) <= k else print(f'{s[:k]}...')


n = int(input())
txt = input()
print(txt[:n] + '...' if bool(txt[n:]) else txt)


K = int(input())
S = input()
characters = len(S)
if characters <= K:
	print(S)
elif characters > K:
	print(S[:K] + '...')


n = int(input())
l = input()
if len(l) <= n:
	print(l)
else:
	print(l[:n] + '...')


print((lambda k, s: s if len(s) <= k else s[:k] + '...')(int(input()), input()))


k = int(input())
a = input()
if len(a) > k:
	print(a[:k] + '...')
else:
	print(a)


(k, s) = open(0).read().split()
print(s if len(s) <= int(k) else s[:int(k)] + '...')


N = int(input())
S = input()
if len(S) <= N:
	print(S)
else:
	print(S[0:N] + '...')


K = int(input())
S = input()
W = S[:K]
if W == S:
	print(S)
else:
	print(W + '...')


k = int(input())
s = input()
print(s[:k] + '.' * 3 * (len(s) > k))


K = int(input())
A = input()
if len(A) <= K:
	print(A)
else:
	print(A[:K] + '...')


k = int(input())
s = str(input())
n = len(s) - k
print(s[:k] + '...' if n > 0 else s)