#!/usr/bin/python3 # # Given a sequence of integers A = a1, a2, # ... , an, a maximal identical sequence is a # sequence of adjacent identical values v = ai = # ai+1 = ai+2 = ... = ai+k of # maximal length k. Write a program that reads an input # sequence A and outputs the value of the first # (leftmost) maximal identical sequence in A. # # For example, with this input: #
# 8 -2 3 3 4 4 4 2 2 2 3 -2 3 3 3 3 4 4 4 8 2 2 8 2 2 22 2 22 22 2 2 22 8
# 
# # the output must be # #
# 3
# 
# import sys A = [] for l in sys.stdin: for a in l.split(): A.append(int(a)) if len(A) > 0: v = A[0] k = 1 i = 0 j = 1 while j < len(A): if A[j] != A[i]: i = j j = j + 1 if j - i > k: v = A[i] k = j - i print(v)