jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]

/*X に最も近いもの、つまり X との差の絶対値が最小のものを求めてください。そのような整数が複数存在する場合は、そのうち最も小さいものを答えてください*/
#include<stdio.h>
int main(void) {

	int x = 0;
	int N = 0;
	int v[100] = { 0 };
	int ans = 0;
	int i = 0;
	int sa = 0;

	/*xを入力*/
	scanf("%d", &x);
	/*個数を入力*/
	scanf("%d", &N);

	int j = 0;


	for (i = 0; i < N; i++) {
		// printf("[%d]\n", i);
		scanf("%d", &v[i]);
	}



	/*優先順位が高い順に
	  x = 10
	  10, 9, 11, 8, 12, 7, 13, 6, 14, 5を表示。
	  x = 50 を入力すると
	  50, 49, 51, 48, 52, 47, 53, 46, 52, 45 */

	int a = x - 1;
	int b = x + 1;

	// x が配列v に含まれているかチェック
	// 含まれてなければ、x 自身が正答。printf して終了

	int count = 0;

	for (i = 0; i < N; i++) {
		if (v[i] != x) {
			count++;
		}
	}

	if (count == N) {
		printf("%d", x);
		return 0;
	}


	/*整数列にxがあるとき*/

	int count_2 = 0;
	int count_3 = 0;

	while (a >= 0) {
		// a が配列v に含まれているかチェック
		// 含まれてなければ、a が正答。printf して終了

		count_2 = 0;

		for (i = 0; i < N; i++) {
			if (v[i] != a) {
				count_2++;
			}
		}

		if (count_2 == N) {
			printf("%d\n", a);
			return 0;
		}

		a--;

		// b が配列v に含まれているかチェック
		// 含まれてなければ、a が正答。printf して終了

		count_3 = 0;

		for (i = 0; i < N; i++) {
			if (v[i] != b) {
				count_3++;
			}
		}

		if (count_3 == N) {
			printf("%d\n", b);
			return 0;
		}

		b++;
	}

	return 0;
}
//  [c]
#include <stdio.h>
#include <math.h>

int main(){
    int x, n;
    scanf("%d%d", &x, &n);

    if(n == 0)
        printf("%d", x);
    else{
        int p[101],pp[101];
        int menor_num = 101;
        int maior_num = 0;
        int cont = 0;

        for(int i = 0; i < n; ++i){
            scanf("%d", &p[i]);
        }

        for(int j = 0; j < n; ++j){
            if(p[j] <= menor_num)
                menor_num = p[j];
            if(p[j] >= maior_num)
                maior_num = p[j];
        }

        for(int t = 0; t < 101; ++t){
            int c = 0;
            for(int s = 0; s < n; ++s){
                if(t == p[s])
                    c = -1;
            }
            if(c == 0){
                pp[cont] = t;
                ++cont;
            }
        }

        int resp = 101;

        for(int k = 0; k < cont; ++k){
             if(abs(pp[k] - x) <= abs(resp - x)){
                if(abs(pp[k] - x) == abs(resp - x)){
                    if(pp[k] < resp)
                        resp = pp[k];
                }
                else
                    resp = pp[k];
             }
        }
        
    
        printf("%d", resp);
    }

    return 0;
}
//  [javascript]
function Main(input) {
  const setting = input.trim().split('\n')
  const x = setting[0].split(' ')[0] - 0
  const arr_length = setting[0].split(' ')[1] - 0

  let ans = 0

  if (arr_length > 0) {
    const num_arr = setting[1].split(' ')
    for (let i = 0; i <= x; i++) {
      let min = x - i
      let answer = num_arr.filter((key) => {
        return parseInt(key) === min
      })
      if (answer.length) {
        let max = x + i
        let answer =num_arr.filter((key) => {
          return parseInt(key) === max
        })
        if (answer.length === 0) {
          console.log(max)
          break
        }
      } else {
        console.log(min)
        break
      }
    }
  } else {
    console.log(x)
  }


  }

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const main = (input) => {

  let [a, b] = input.trim().split('\n')
  b = b || ''
  
  const [X, N] = a.split(' ').map(v => Number(v))
  const nums = b.split(' ').map(v => Number(v))

  if (N === 0) {
    console.log(X)
    return null
  }

  let smaller = X
  let bigger = X

  while (true) {
    if (nums.indexOf(smaller) === -1) {
      console.log(smaller)
      return null
    } else {
      smaller--
    }

    if (nums.indexOf(bigger) === -1) {
      console.log(bigger)
      return null
    } else {
      bigger++
    }
  }
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
const main = (input) => {
  const args = input.trim().split("\n");
  const [x, n] = args[0]
    .split(" ")
    .map((n) => parseInt(n, 10));
 
  const excluded = (() => {
    if (n === 0) {
      return [];
    } else {
      return args[1]
        .split(" ")
        .map((n) => parseInt(n, 10));
    }
  })();
 
  const selection = [...Array(101 + 1).keys()].filter(
    (s) => !excluded.includes(s)
  );
 
  const abs = (n) => {
    if (n < 0) return -n;
    else {
      return n;
    }
  };
  const byAsc = (a, b) => a[1] - b[1];
 
  const answer = selection
    .map((s) => [s, abs(x - s)])
    .sort(byAsc)[0][0];
 
  console.log(answer);
};
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import "fmt"

func main() {
        var n, x int
        fmt.Scan(&x, &n)
        if n == 0 {
                fmt.Println(x)
                return
        }
        s := make([]int, n)
        for i := 0; i < n; i++ {
                fmt.Scan(&s[i])
        }
        var i = 0
        for {
                if !contains(s, x-i) {
                        fmt.Printf("%v", x-i)
                        return
                }
                if !contains(s, x+i) {
                        fmt.Printf("%v", x+i)
                        return
                }
          i++
        }
        return
}

func contains(s []int, i int) bool {
        for _, item := range s {
                if item == i {
                        return true
                }
        }
        return false
}
//  [ruby]
x, n = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i).sort!

if n == 0
  puts x
  exit 0
end

ans = diff = x

(ps.last + 10 ** 5).downto(-ps.last - 10 ** 5) do |i|
  next if ps.include?(i)

  abs = (x - i).abs
  if abs <= diff
    ans = i
    diff = abs
  end
end

puts ans
//  [ruby]
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
x,n = gets.chomp.split.map(&:to_i)
if n == 0
  puts x
  exit
end
set = Set.new(gets.chomp.split.map(&:to_i))

unless set.include? x
  puts x
  exit
end

1.upto(1000) do |i|
  unless set.include? (x - i)
    puts x - i
    exit
  end
  unless set.include? (x + i)
    puts x + i
    exit
  end
end
//  [ruby]
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

x,n = inp
p = inp
min = 1e20
ans = -1
(0..101).each do |d|
  next if (p.include?(d))
  if((d-x).abs < min)
    min = (d-x).abs
    ans = d
  end
end
p ans
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        x: isize, n: usize,
        p_vec: [isize; n]
    }

    let all_num: HashSet<isize> = (-1000..=1000).collect();
    let p_set: HashSet<isize> = p_vec.into_iter().collect();

    let diff: HashSet<&isize> = all_num.difference(&p_set).collect();

    let mut min: isize = 1e9 as isize;
    let mut ans: isize = 0;

    for d in diff.iter() {
        dbg!(&d);
        if min > (x - **d).abs() {
            ans = **d;
            min = (x - **d).abs();
        } else if min == (x - **d).abs() {
            if **d < ans {
                ans = **d;
            }
        }
    }

    println!("{}", ans);
}
//  [swift]
import Foundation

let values = readLine()!.components(separatedBy: " ").map({Int($0)!})
let X = values[0]
let N = values[1]

if N == 0 {
    print(X)
    exit(0)
}

let numbers = readLine()!.components(separatedBy: " ").map({Int($0)!}).sorted()

for i in 0...X+1 {
    for d in [-1, 1] {
        let val = X + d * i
        if numbers.contains(val) == false {
            print(val)
            exit(0)
        }
    }
}
//  [swift]
import Foundation

let input1 = readLine()!.components(separatedBy: " ")
let x = Int(input1[0])!
let n = Int(input1[1])!

if n == 0 {
    print(x)
    exit(0)
}

var p = readLine()!.components(separatedBy: " ").map {Int($0)!}

var counter = 0
while(true) {
    
    if p.first(where: {$0 == x - counter}) == nil {
        print(x - counter)
        exit(0)
    }
    
    if p.first(where: {$0 == x + counter}) == nil {
        print(x + counter)
        exit(0)
    }
    
    counter += 1

}
//  [swift]
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func readTwoInts(separator: String.Element = " ") -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func mainC() {
    let (X, N) = readTwoInts()
    let numbers = readInts()

    for i in 0...100 {
        let targetA = X - i

        if !numbers.contains(targetA) {
            print(targetA)
            return
        }

        let targetB = X + i
        if !numbers.contains(targetB) {
            print(targetB)
            return
        }
    }

}

mainC()
//  [typescript]
'use strict'
function main(inp) {
  let Nums:array = inp.trim().split('\n');
  const X:array = Nums[0].split(' ')[0]*1;
  const N:array = Nums[0].split(' ')[1]*1;
  let ans:number = 0;
  let min:number = 102;
  if (N == 0) {ans = X;}
  else {
    const Ps:array = Nums[1].split(' ').map(x=> x*1);
    for(let i = 0; i < 102; i++){
      if( Math.abs(X - i) < min && (Ps.indexOf(i) == -1)){
          ans = i;
          min = Math.abs(X - i);
      }
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
{
  const run = (input: string) => {
    const split = input.trim().split("\n")
    const [x, n] = split[0].split(" ").map(v => parseInt(v))
    if (n === 0) return x
    const list = split[1].split(" ").map(v => parseInt(v));

    list.sort((a: number, b: number) => a - b);

    let result = 0
    let diff = x

    for (let i = 0; i < 100; i++) {
      if (list.every(v => v != i)) {
        const tmpDiff = Math.abs(x - i)
        if (diff > tmpDiff || (diff === tmpDiff && result > i)) {
          diff = tmpDiff
          result = i
        }
      }
    }

    const tmpDiff = Math.abs(x - 101)
    if (diff > tmpDiff) {
      return 101
    }

    return result
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}
//  [python]
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

s = inputSL()

if s[0][-1] == s[1][0] and s[1][-1]==s[2][0]:
  print("YES")
else:
  print("NO")
//  [python]
import sys, os
import numpy as np

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c = input().split()
    if a[-1]== b[0] and b[-1] == c[0]:
        print('YES')
    else:
        print('NO')
    

solve()
//  [python]
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
A, B, C = rs_()
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[][] s = new char[N][];
			IntStream.range(0, N).forEach(i -> s[i] = scanner.next().toCharArray());
			boolean result = true;
			for (int i = 1; i < N; i++) {
				// 直前の文字列の最後の文字と現在の文字列の最初の文字と比較
				if (s[i - 1][s[i - 1].length - 1] != s[i][0]) {
					result = false;
					break;
				}
			}
			System.out.println(result ? "YES" : "NO");
		}
	}
}
//  [java]
import java.util.*;

// ABC 27-C
// http://abc027.contest.atcoder.jp/tasks/abc027_c
 
public class Main {
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);

		char[] a = in.next().toCharArray();
		char[] b = in.next().toCharArray();
		char[] c = in.next().toCharArray();
		
		if (a[a.length - 1] == b[0] && b[b.length - 1] == c[0]) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String a= gs();
	    String b= gs();
	    String c= gs();

        //System.out.print(aubstring(0,1));
        if (a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
        	System.out.print("YES");
        }else{
        	System.out.print("NO");
        }

	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string a,b,c;cin>>a>>b>>c;
  string ans="NO";
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])ans="YES";
  cout(ans);
  
  return 0;
}
//  [cpp]

#include <bits/stdc++.h>

using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){

        cout << "YES";
    } else{
        cout << "NO";
    }
    cout << endl;


}
//  [cpp]
#include<iostream>
#include<string>
using namespace std;

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  cout << ((a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) ? "YES" : "NO");
  return 0;
}
//  [c]
#include <stdio.h>
#include <math.h>
#include <time.h>
#include<stdlib.h>
#include<string.h>

int main(void){
	int l1, l2;
	char a[11], b[11], c[11];

	scanf("%s %s %s", a, b, c);

	l1 = strlen(a) - 1;
	l2 = strlen(b) - 1;

	if (a[l1] == b[0] && b[l2] == c[0]) {
		printf("YES");
	}
	else {
		printf("NO");
	}
}
//  [c]
#include<stdio.h>
#include<string.h>
int main()
{
	char a[11],b[11],c[11];
	int len,len2;
	scanf("%s %s %s",a,b,c);
	len=strlen(a);
	len2=strlen(b);
	if(a[len-1]==b[0]&&b[len2-1]==c[0]) printf("YES\n");
	else printf("NO\n");
	return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
int main(){
char A[11],B[11],C[11];
int p,q,r;
scanf("%s",A);
scanf("%s",B);
scanf("%s",C);
p=strlen(A)-1;
q=strlen(B)-1;
r=strlen(C)-1;
if((A[0] >= 'a' && A[p] <= 'z') && (B[0] >= 'a' && B[q] <= 'z') && (C[0] >= 'a'&& C[r] <= 'z')){
    if((A[p]==B[0])&&(B[q]==C[0])){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}
return 0;
}
//  [javascript]
'use strict'

main()

function main (input) {
  readInput()
  .then(parseInput)
  .then(calc)
}

function calc (input) {
  let a = input[0]
  let b = input[1]
  let c = input[2]
  let yes = a[a.length - 1] === b[0] && b[b.length - 1] === c[0]
  let answer = yes ? 'YES' : 'NO'
  console.log(answer)
}

function parseInput (inputRaw) {
  let input = inputRaw.split(' ')
  return input
}

function readInput () {
  return new Promise((resolve) => {
    let inputArr = []
    process.stdin.resume()
    process.stdin.setEncoding('utf8')
    process.stdin.on('data', (chunk) => {
      inputArr.push(chunk)
    })
    process.stdin.on('end', () => {
      let input = inputArr.join('').trim()
      resolve(input)
    })
  })
}
//  [javascript]
function Main(input){
  input = input.split(' ');
  var a = input[0];
  var b = input[1];
  var c = input[2];

  var a_str_last = a.substr(-1,1);
  var b_str = b.substr(0,1);
  var b_str_last = b.substr(-1,1);
  var c_str = c.substr(0,1);

  if(a_str_last === b_str && b_str_last === c_str) {
      console.log('YES');
  } else {
      console.log('NO');
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b, c] = input.trim().split(" ");
  if (a.slice(-1) === b.slice(0, 1) && b.slice(-1) === c.slice(0, 1)) {
    return "YES";
  } else {
    return "NO";
  }
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A, B, C := ReadString(), ReadString(), ReadString()
	if A[len(A)-1] == B[0] && B[len(B)-1] == C[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := Scanner(), Scanner(), Scanner()
	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
//  [go]
package main

import "fmt"

func main() {
	// Code for A - Shiritori
	var A, B, C string
	fmt.Scanf("%s %s %s", &A, &B, &C)

	if A[len(A)-1] == B[0] && B[len(B)-1] == C[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
//  [ruby]
a, b, c = gets().chomp.split("\s")

puts a[-1] == b[0] && b[-1] == c[0] ? 'YES' : 'NO'
//  [ruby]
a, b, c = gets.chomp.split(" ")
if a[-1] == b[0] && b[-1] == c[0]
    puts "YES"
else
    puts "NO"
end
//  [ruby]
a, b, c = gets.split.map(&:to_s)
puts a[-1] == b[0] && b[-1]== c[0] ? "YES" : "NO"
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: Chars,
        b: Chars,
        c: Chars,
    }

    if a[a.len()-1]==b[0] && b[b.len()-1]==c[0] {
        println!("YES")
    } else {
        println!("NO");
    }

}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    b:String,
    c:String,
    }
    let a=a.chars().collect_vec();
    let b=b.chars().collect_vec();
    let c=c.chars().collect_vec();
    println!("{}",if a[a.len()-1]==b[0]&&b[b.len()-1]==c[0]{"YES"}else{"NO"})
}
//  [rust]
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a = iterator.next().unwrap();
    let b = iterator.next().unwrap();
    let c = iterator.next().unwrap();

    if a.chars().rev().next().unwrap() == b.chars().next().unwrap()
        && b.chars().rev().next().unwrap() == c.chars().next().unwrap() {
        "YES".to_string()
    } else {
        "NO".to_string()
    }
}
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, C] = input[0];

  return A[A.length - 1] === B[0] && B[B.length - 1] === C[0] ? "YES" : "NO";
};

console.log(main(read()));
//  [typescript]
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var A = parts[0];
var B = parts[1];
var C = parts[2];
var satisfy: boolean = A.charAt(A.length - 1) == B.charAt(0) && B.charAt(B.length - 1) == C.charAt(0);
console.log(satisfy ? "YES" : "NO");
//  [typescript]
import * as fs from 'fs';

const [a, b, c]: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split(' ');

if (a.substring(a.length - 1) === (b.substring(0, 1))
    && b.substring(b.length - 1) === (c.substring(0, 1))) {
    console.log('YES');
} else{
    console.log('NO');
}
//  [python]
K = int(input())
S = list(input())

if K >= len(S):
  for i in S:
    print(i,end="")
else:
  for i in range(K):
    print(S[i],end="")
  print("...")
//  [python]
K=int(input())
S=input()

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

if len(S) <= K:
    print(S)
else:
    print(S[:K] + "...")
//  [python]
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
 
YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
input=lambda: sys.stdin.readline().rstrip()


show_flg=False
show_flg=True
ans=0


#n,m=LI()
k=n=I()
s=input()

for i in range(n):
    0

print(s[:k]+'...'*(len(s)>k))
//  [python]
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    K=I()
    S=ST()
    if(len(S)<=K):
        print(S)
    else:
        print(S[:K]+"...")
if __name__ == '__main__':
    main()
//  [python]
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


k = I()
s = S()
if len(s) > k:
    print(s[:k] + '...')
else:
    print(s)
//  [java]
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int K = ni();		
		String S = next();
		if(S.length() <= K) {
			System.out.println(S);
		} else {
			System.out.println(S.substring(0, K) + "...");
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}
//  [java]
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int k = Integer.parseInt(bf.readLine());
 		String input = bf.readLine();
 		if (input.length() <= k){
 			out.println(input);
 		}
 		else
 		{
 			
 			out.println(input.substring(0, k) + "...");
 		}
 				
 		out.close();
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int K = scan.nextInt();
		String S = scan.next();

		if (S.length() <= K) System.out.println(S);
		else System.out.println(S.substring(0, K) + "...");

 	}
}
//  [java]
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int k=sc.nextInt();
	String s=sc.next();
	String add = "...";

	if(s.length()>k) {
		System.out.println(s.substring(0, k)+add);
	}
	else {
		System.out.println(s);
	}
	}
}
//  [java]

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		String S = sc.next();

		int n=S.length();

		if(n<=K) {
			System.out.println(S);
		}else {
			for(int i=0;i<K;i++) {
				System.out.print(S.charAt(i));
			}
			System.out.println("...");
		}



	}
}
//  [cpp]
#include <cstdio>
#include <cstring>
using namespace std;

int k, l;
char s[101];

int main() {
    scanf("%d%s", &k, s);
    l = strlen(s);
    if (l <= k) printf("%s", s);
    else {
        s[k] = 0;
        printf("%s...", s);
    }
}
//  [cpp]
#include<stdio.h>
#include<string.h>
int main()
{
    int k,i,x;
    char s[100];
    scanf("%d",&k);
    scanf("%s",s);
    if(strlen(s)<=k)
        printf("%s",s);
    else if(strlen(s)>k)
       for(i=0;i<k;i++)
          printf("%c",s[i]);
    if(strlen(s)>k)
        printf("...");
    return 0;

}
//  [cpp]
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[110];
int main(){
	int a;scanf("%d%s",&a,in);
	if(strlen(in)<=a)printf("%s\n",in);
	else{
		for(int i=0;i<a;i++)printf("%c",in[i]);
			printf("...\n");
	}
}
//  [c]
#include <stdio.h>
#include <string.h>

int main(){
  int k;
  char s[105];
  scanf("%d %s", &k, s);

  if(strlen(s) <= k){
    printf("%s\n", s);
  }else{
    for(int i=0; i<k; i++)
      printf("%c", s[i]);
    printf("...\n");
  }

  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define BUF 1024

int main(void) {
  int k;
  char str[BUF];
  memset(str, '\0', BUF);
  scanf("%d %s", &k, str);
  if (strlen(str) <= k) printf("%s\n", str);
  else {
    char print_str[BUF];
    memset(print_str, '\0', BUF);
    strncpy(print_str, str, k);
    printf("%s...\n", print_str);
  }

  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>



int main(){
	
	int i,j,N;
	char S[110];
	scanf("%d %s",&N, S);
	
	int len = strlen(S);
	
	if(len<=N){
		printf("%s\n",S);
	}
	else{
		
		for(i=0;i<N;i++){
			printf("%c",S[i]);
		}
		printf("...\n");
		
	}
		
	return 0;
}
//  [c]
#include <stdio.h>
int main()
{
	int k;
	scanf("%d",&k);
	getchar();
	char s[1000];
	gets(s);
	if(strlen(s)<=k) printf("%s",s);
	else{
		int i;
		for(i=0;i<k;i++){
			printf("%c",s[i]);
		}
		printf("...");
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
 
int x;
char y[101];
 
int main(){
	scanf("%d",&x);
	scanf("%s",&y);
	int len = strlen(y);
	if(len<=x){
		printf("%s\n",y);
		return 0;
	}
	else{
		for(int i=x; i<len; i++){
			y[i]='\0';
		}
		for(int i=x; i<x+3; i++){
			y[i]='.';
		}
		printf("%s\n",y);
		return 0;
	}
}
//  [javascript]
function main(lines) {
  const K = +lines[0];
  const S = lines[1];

  let res = K < S.length ? S.slice(0, K) + '...' : S;

  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
K = inp.shift() * 1
S = inp.shift()

if (S.length > K) {
    S = S.slice(0, K) + "..."
}

console.log(S)
//  [javascript]
function B168(_input) {
    var lines = _input.split("\n");
    var k = parseInt(lines.shift(),10);
    var s = lines.shift();

    if (s.length <= k) {
        console.log(s);
        return;
    }

    var str = s.slice(0, k) + '...';

    console.log(str);
}
B168(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input){
  input = input.trim().split('\n');
  var K = input[0];
  var S = input[1];
  var ans = '';
  if (S.length <= K){
    ans = S;
  }else{
    ans = S.slice(0,K) + '...';
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]

let input = require("fs").readFileSync("/dev/stdin", "utf8")

function main({ input, load, yesno, math_sum, log_json }) {
    let [K] = load()
    let [S] = load(1,1,String)
    if(S.length <= K) return S
    return S.slice(0,K) + '...'
}



// console.time()
let inputs = input.split(/[\s\n]/)
let result = main({
    input,
    yesno: value => value ? 'Yes' : 'No',
    math_sum: numbers => numbers.reduce((acc, cur) => acc + cur, 0),
    load(rows = 1, cols = 1, type = Number) {
        const length = rows * cols
        let result = inputs.splice(0, length)
        if(type !== String) result = result.map(type)
        if(cols > 1) {
            const arrays = new Array(cols)
            for(let col = 0; col < cols; col++) {
                arrays[col] = new Array()
                for(let row = 0; row < rows; row++) {
                    arrays[col].push(result[row * cols + col])
                }
            }
            result = arrays
        }
        return result
    },
    inifinite_loop_preventer() {
        throw new Error("Infinite loop")
    },
    log_json(value) {
        console.log(JSON.stringify(value))
    },
})

if(result === undefined) {
    console.warn("result is undefined")
} else {
    console.log(result)
}
// console.timeEnd()

function math_max(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n > result) result = n
    return result
}

function math_min(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n < result) result = n
    return result
}

// 素因数分解 { 素数: n乗 }
function math_prime_factors(n) {
    const result = {}

    for(let i = 2; i * i <= n; i++) {
        if(n % i === 0) {
            n /= i
            result[i] = 1
            
            while(n % i === 0) {
                n /= i
                result[i]++
            }
        }
    }

    if(n > 1) result[n] = 1

    return result
}
//  [javascript]
function Main(input) {
	input = input.split("\n");
	const i = parseInt(input[0], 10);
    const s = input[1]
    if (s.length > i) {
        console.log(`${s.slice(0, i)}...`)
    } else {
        console.log(s)
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
)

func main() {
	var k int
	var s string
	fmt.Scan(&k, &s)
	if len(s) > k {
		fmt.Println(s[:k] + "...")
	} else {
		fmt.Println(s)
	}
}
//  [go]
package main

import (
  "fmt"
)

func main() {
  var k, sLen int
  var s string
  fmt.Scanf("%d", &k)
  fmt.Scanf("%s", &s)
  sLen = len(s)

  if sLen <= k {
    fmt.Println(s)
  } else  {
    ans := fmt.Sprint(s[:k], "...")
    fmt.Println(ans)
  }
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var s string
	var k int

	fmt.Scan(&k)
	fmt.Scan(&s)

	length := len(s)
	if length <= k {
		fmt.Println(s)
		return
	}
	for i := 0; i < k; i++ {
		c := s[i]
		//fmt.Println(reflect.TypeOf(c))
		fmt.Printf("%c",c)
	}
	fmt.Print("...")
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var k int
	var s string

	fmt.Scan(&k)
	fmt.Scan(&s)

	i := len(s)

	if i <= k {
		fmt.Println(s)
	} else {
		fmt.Print(s[:k])
		fmt.Print("...")

	}

}
//  [ruby]
K = gets.to_i
S = gets.chomp

if S.size > K
  puts "#{S[0..K-1]}..."
elsif S.size == K
  puts S
else
  puts S
end
//  [ruby]
n = gets.to_i
s = gets.chomp
puts n >= s.size ? s : s[0, n] + "..."
//  [ruby]
K = gets.chomp.to_i
S = gets.chomp

if K >= S.length
  puts S
else
  puts S[0..(K-1)]. + '...'
end
//  [ruby]
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
k = gets.chomp.to_i
s = gets.chomp

if s.size <= k
  puts s
else
  puts s.slice(0,k) + '...'
end
//  [ruby]
require 'pp'

k = gets.to_i
s = gets.chomp!

if s.length <= k
    puts s
else
    puts s[0,k] + "..."
end
//  [ruby]
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end

K = gets_i
S = gets_s

if S.size <= K
  puts S
else
  puts S[0,K] + "..."
end
//  [rust]
use proconio::input;
fn main() {
    input!(k: usize);
    input!(s: String);

    if s.len() > k {
        println!("{}...", &s[0..k]);
    } else {
        println!("{}", s);
    }
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut k: String
    }
    if k.len() > n {
        k.truncate(n);
        k.push_str("...");
    }
    println!("{}", k);
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(k: i32, s: String,);
    if s.len() <= k as usize {
        println!("{}", s);
    } else {
        println!("{}...", &s[0..k as usize]);
    }
}
//  [swift]
let k = Int(readLine()!)!
let s = readLine()!
if s.count <= k {
  print(s)
} else {
  print("\(s.prefix(k))...")
}