#include <stdio.h>
#define MAXLINE 1000

main()
{
    int len, max;
    char line[MAXLINE], longest[MAXLINE];
    max = 0; // 初期化
    while ((len = getline(line, MAXLINE)) > 0)
        if (len > max) { // より長い行が見つかった
            max = len;
            copy(longest, line);
        }
    if (max > 0)
        printf("%s", longest);
}

int getline(char s[], int lim)
{ // 一行を文字列sに入力して，文字数を返す関数
    int c, i;
    for (i = 0; 
         i < lim-1 && (c = getchar()) != EOF && c != '\n'; 
         ++i)   s[i] = c;
    if (c == '\n') {
        s[i] = c;
        ++i;
    }
    s[i] = '\0'; // 文字列の最後は必ず\0が入る
    return i;
}

copy(char to[], char from[])
{ // 文字列fromから文字列fromにコピーする関数
    int i;
    i = 0;
    while ((to[i] = from[i]) != '\0') ++i;
}
