Problem:
 Score : 200 points    Problem Statement Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N -th ABC ever held).
Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?      Constraints  100 \leq N \leq 999  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output If the earliest ABC where Kurohashi can make his debut is ABC n , print n .        Sample Input 1 111      Sample Output 1 111  The next ABC to be held is ABC 111 , where Kurohashi can make his debut.       Sample Input 2 112      Sample Output 2 222  The next ABC to be held is ABC 112 , which means Kurohashi can no longer participate in ABC 111 .
Among the ABCs where Kurohashi can make his debut, the earliest one is ABC 222 .       Sample Input 3 750      Sample Output 3 777

Solution (Python):

ans=[111,222,333,444,555,666,777,888,999,1111]
n=int(input())
for i in ans:
    if i>=n:
        print(i)
        break

Solution (Python):
l = list(map(int,input()))

if l[0] <l[1]:
  a= str(l[0]+1)
  print(a*3)
elif l[0]>l[1]:
  print(str(l[0])*3)
else:
  if l[1] >= l[2]:
    print(str(l[0])*3)
  else:
    b= str(l[0]+1)
    print(b*3)

Solution (Python):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    print((((N-1)//111)+1)*111)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())

for i in range(n,1000):
        s=str(i)
        if s[0] == s[1] == s[2]:
                print(i)
                exit()

Solution (Python):
n = int(input())
ans = 0
while ans<n:
    ans += 111
print(ans)

Solution (Python):
n = int(input())
for i in range(n, 1000):
    n_s = str(i)
    if n_s[0] == n_s[1] == n_s[2]:
        print(i)
        exit()

Solution (Python):
l=[i*111 for i in range(1,10)]
N=int(input())
for i in l:
    if N>i:
        continue
    else:
        print(i)
        break

Solution (Python):
n = int(input())

ans = 999
for i in range(1, 9):
    val = i * 111
    if val >= n:
        ans = min(ans, val)

print(ans)

Solution (Python):
a=int(input())
print((-(-a-110)//111)*111)

Solution (Python):
for i in range(int(input()),1000):
  if i%111==0:print(i);exit()

Solution (Python):
n = int(input())
while n % 111:
    n += 1
print(n)

Solution (Python):
n=int(input())
if n%111==0:
    print(n)
else:
    print(n-n%111+111)

Solution (Python):
N = input()
if N[1] < N[0]:
  n = int(N[0])
  print(n + n*10 + n*100)
elif N[1]==N[0] and N[2] <= N[1]:
  n = int(N[0])
  print(n + n*10 + n*100)
else:
  n = int(N[0])+1
  print(n + n*10 + n*100)

Solution (Python):
n=int(input())
print(((n-1)//111+1)*111)

Solution (Python):
n = int(input())
sav = n 
while n % 111 != 0:
        n = (n // 100) * 111
        if n < sav:
            n += 111
print(n)

Solution (Python):
n = input()

first = n[0]
length = len(n)
guess = int(''.join([first]*length))

if guess >= int(n):
    print(guess)
else:
    next = int(first)+1
    guess = int(''.join([str(next)]*length))
    print(guess)

Solution (Python):
N = input()

length = len(N)
target0 = N[0]*length
target1 = str(int(N[0])+1)*length

if int(target0) >= int(N):
  print(int(target0))
else:
  print(int(target1))

Solution (Python):
N = int(input())

targets = [int(str(i) * 3) for i in range(1, 10)]
diff = list(map(lambda x: x - N, targets))
print(N + min([d for d in diff if d >= 0]))

Solution (Python):
N=int(input())
for i in range(N,1000):
    a=str(i)
    if a[0]==a[1] and a[1]==a[2]:
        print(i)
        break

Solution (Python):
n = int(input())
for i in range(n,1000):
    arr = list(str(i))
    s = list(set(arr))
    if len(s) == 1:
        print(i)
        break

Solution (Python):
n = int(input())
ok = False
for i in range(1,10):
    if int(str(i)*3)>=n:
        print(str(i)*3)
        exit()

Solution (Python):
n=int(input())
for i in range(n,1000):
    j=str(i)
    if j[0]==j[1]==j[2]:
        print(j)
        break

Solution (Python):


n = int(input())

for i in range(10):
    if i * 111 < n <= (i+1)*111:
        print((i+1)*111)
        break

Solution (Python):
N = int(input())
if N % 111 == 0:
  print(N)
else:
  print((N // 111 + 1) * 111)

Solution (Python):
N = int(input())

for x in range(N,1000):
  if x % 111 == 0:
    print(x)
    break

Solution (Python):
n = int(input())
zoro = [111,222,333,444,555,666,777,888,999]
for i in zoro:
  if n<=i:
    print(i)
    break

Solution (Python):
N = input()
if len(set(list(N))) == 1:
  print(N)
else:
  
  if int(N) < int(str(int(N[0]))*3):
    print(N[0]*3)
  else:
  	print(str(int(N[0])+1)*3)

Solution (Python):



N=int(input())

for i in range(10):
    if 111*i<N<=111*(i+1):
        print(111*(i+1))

Solution (Python):



N=list(input())
if len(set(N))==1:
    print(''.join(N))
else:
    if int(N[0])<int(N[1]) or int(N[0])<int(N[2]):
        N=[int(N[0])+1]*len(N)
    else:
        N=[int(N[0])]*len(N)
    print(''.join(map(str,N)))

Solution (Python):
n=int(input())

for i in range(10):
            if i*100+i*10+i<n<=i*100+i*10+i+111:
                        print(i*100+i*10+i+111)

Solution (Python):
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n = int(input())
if n % 111 == 0:
    print(n)
else:
    a = n//111
    print((a+1)*111)

Solution (Python):
def solve():
    N = int(input())
    for i in range(1000 - N):
        if len(set(str(N + i))) == 1:
            print(N + i)
            exit()


if __name__ == '__main__':
    solve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = input()
    rep = int('1' * len(N))
    ans = rep
    while ans < int(N):
        ans += rep
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n = list(input())
n = [int(i) for i in n]
if n[0] < n[1]:
    print(str(n[0]+1)*3)
elif n[0] == n[1]:
    if n[0] < n[2]:
        print(str(n[0]+1)*3)
    elif n[0] >= n[2]:
        print(str(n[0])*3)
else:
    print(str(n[0])*3)

Solution (Python):
n = int(input())
for i in range(111, 1000, 111):
    if i >= n:
        print(i)
        break

Solution (Python):
n = int(input())
a = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]
for i, m in enumerate(a):
    if n <= m:
        continue
    else:
        print(a[i - 1])
        break

Solution (Python):
n = int(input())

for i in '123456789':
	if int(i * 3) >= n:
		print(i * 3)
		break

Solution (Python):
n=int(input())
for i in range(10):
  if 111*i<n<=111*(i+1):
    print(111*(i+1))

Solution (Python):
import numpy as np

N = int(input())

for i in range(10):
    if (N <= 111*(i+1)) & (N > 111*(i)):
        ans = 111*(i+1)
    if (N > 111*(i)) & (i ==9):
        ans = 1111
    
print(ans)

Solution (Python):
N = int(input())

contest_list = [111, 222, 333, 444, 555, 666, 777, 888, 999]

for i in range(len(contest_list)):
    if (N <= contest_list[i]):
        ans = contest_list[i]
        break

print(ans)

Solution (Python):
n=int(input())
for i in range(10):
  if 111*i<n<=111*(i+1):
    print(111*(i+1))

Solution (Python):
N = int(input())
print(((N+110)//111)*111)

Solution (Python):
N = int(input())
for i in range(N, 1000) :
    s = str(i)
    if s[0] == s[1] == s[2] :
        print(s)
        exit()

Solution (Python):
e=[]
for i in range(1,10):
  e.append(int(str(i)*3))
n=int(input())
for i in range(9):
  if n<=e[i]:
    print(e[i])
    exit()

Solution (Python):
n=int(input())

na = str(n)

n1 = na[0]

if int(n1*len(na)) >= n:
    print(int(n1*len(na)))
else:
    n1n = int(n1)+1
    n1n = str(n1n)
    print(n1n*len(na))

Solution (Python):
import sys
n = int(input())

for i in range(1,10):
    if n <= 111*i:
        print(111*i)
        sys.exit()

Solution (Python):
n = int(input())
while True:
    if len(set(list(str(n)))) == 1:
        print(n)
        break
    n += 1

Solution (Python):
n = int(input())

for i in range(n,1000):
    i = str(i)
    if i[0] == i[1] == i[2]:
        print(int(i))
        break
    else:
        pass

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    temp=str((int(s[0])+1))*3
    ct=int(temp)-int(s)
    
    if 0<=ct<=110:
        print(temp)
    else:
        temp=s[0]*3
        print(temp)
    
    
if __name__ == '__main__':
    do()

Solution (Python):
n = int(input())
while True:
    if len(set(str(n))) == 1:
        break
    else:
        n += 1
print(n)

Solution (Python):
n=int(input())
i=int(n/111)
if n % 111 != 0:
    i += 1
print(i * 111)

Solution (Python):



N = int(input().strip())


for i in range(N,1000):
    s = str(i)
    if s.count( s[0]) == len(s):
        print(i)
        break

Solution (Python):
N = int(input())
for i in range(9):
    if 111 * i < N and N <= 111 * (i + 1):
        print(111 * (i + 1))

Solution (Python):
import math
n = int(input())
print(-(-n//111)*111)

Solution (Python):
n=int(input())
a=[99,111,222,333,444,555,666,777,888,999]
for i in range(len(a)-1):
    if a[i]<n<=a[i+1]:
        print(a[i+1])
        break

Solution (Python):
n=int(input())
a=[99,111,222,333,444,555,666,777,888,999,1000]
for i in range(len(a)-1):
    if n==a[i]:
        print(n)
        break
    if a[i]<n<a[i+1]:
        print(a[i+1])
        break

Solution (Python):
N = input()
inp = list(N)
final = ''

for i in range(3):
    final += inp[0]
final = int(final)
if final < int(N):
    final += 111
    print(final)
else:
    print(final)

Solution (Python):
n = int(input())
answer = 0
while answer < n:
  answer += 111
  
print(answer)

Solution (Python):
N = int(input())

for i in range(N, 1000):
    if i % 10 == (i // 10) % 10 == (i // 10 // 10) % 10:
        print(i)
        exit()

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
ans = 0
for i in range(N, 1000):
    s = str(i)
    flag = True
    for j in range(len(s) - 1):
        if s[j] != s[j + 1]:
            flag = False
    if flag:
        ans = i
        break

print(ans)

Solution (Python):
N = int(input())
res = (N + 111 - 1) // 111
print(res*111)

Solution (Python):
N=int(input())
for i in range(1,10):
	ans=i*100+i*10+i
	if ans>=N:
		print(ans)
		exit()

Solution (Python):
n = int(input())
for i in range(10):
  if n <= i * 111:
    print(i * 111)
    break;

Solution (Python):
N = str(input())

hundred=N[0]
ten=N[1]
one=N[2]

if hundred>ten:
    x=int(hundred+hundred+hundred)
elif hundred<ten:
    x=int(str((int(hundred)+1))+str((int(hundred)+1))+str((int(hundred)+1)))
else:
    if ten>=one:
        x=int(hundred+hundred+hundred)
    else:
        x=int(str((int(hundred)+1))+str((int(hundred)+1))+str((int(hundred)+1)))
print(x)

Solution (Python):
n=int(input())

if 100<=n<=111:
            print(111)
a=0
for a in range(1,9):
            if 1+111*a<=n<=111*(a+1):
                        
                        print(111*(a+1))

Solution (Python):
n = int(input())
for i in range(1,10):
    if (i-1)*111 < n <= i*111:
        print(i*111)
        break

Solution (Python):
N=int(input())
x=1000;p=-1
S=[111,222,333,444,555,666,777,888,999]
for i in range(len(S)):
  if S[i]-N>=0:
    if x>(S[i]-N):
      p=i
      x=S[i]-N
print(S[p])

Solution (Python):

N = input()

if N[0] == N[1] and N[1] == N[2]:
    print(N)
else:
    
    while(N[0]!=N[1] or N[1]!=N[2]):
        N = int(N)
        N+=1
        N = str(N)
    print(N)

Solution (Python):

N=int(input())
print(-(-N//111)*111)

Solution (Python):
N=int(input())
S=N//100
if N<=S*100+S*10+S:
    print(S*100+S*10+S)
else:
    print((S+1)*100+(S+1)*10+S+1)

Solution (Python):
N=int(input())
ans=N
while(True):
  if len(set(list(str(ans))))==1:
    print(ans)
    break
  else:
    ans+=1

Solution (Python):
n = int(input())

print(111*((n-1)//111 + 1))

Solution (Python):
from math import ceil
print(111*ceil(int(input())/111))

Solution (Python):
N = int(input())

for i in range(N, 1000):
  s = str(i)
  if s[0] == s[1] and s[1] == s[2]:
    print(s)
    break

Solution (Python):
N = int(input())

for i in range(N, 1000):
    if str(i)[0] == str(i)[1] == str(i)[2]:
        print(i)
        break

Solution (Python):
n=input()
if n[0]>n[1] or (n[0]==n[1] and n[1]>=n[2]):
    print(int(n[0])*111)
else:
    print(int(n[0])*111+111)

Solution (Python):
n = int(input())

for i in range(n, 1001):
    if i % 111 == 0:
        ans = i
        break
print(ans)

Solution (Python):
N=int(input())
a=N//100
b=N%100
c=a+1
if a*10+a>=b:
  print(a*100+a*10+a)
else:print(c*100+c*10+c)

Solution (Python):
n = int(input())
for i in range(1, 10):
    x = i*111
    if n <= x:
        print(x)
        break

Solution (Python):
N = int(input())
a = N//100
b = (N-(100*a))//10
c = N-(100*a+10*b)
if a == b == c:
    ans = N
elif a==b>c:
    ans = 111*(a)
elif a==b<c:
    ans = 111*(a+1)
elif a > b:
    ans = 111*a
elif a < b:
    ans = 111*(a+1)
print(ans)

Solution (Python):
S = input()
if len(set(S)) == 1:
    print(S)
    exit()
for i in range(int(S), 1000):
    if len(set(str(i))) == 1:
        print(i)
        exit()

Solution (Python):
n=input()
for i in range(9):
  if 111*i < n <= 111*(i+1):
    print 111*(i+1)
    break

Solution (Python):
x = input()
if x % 111 != 0:
    print (x/111 + 1) * 111
else:
    print x

Solution (Python):
N = int(input())
if N % 111 == 0:
  print(N)
for i in range(10):
  if N % 111 != 0 and N // 111 == i:
    print(111 * (i + 1) )

Solution (Python):
n=int(input())

for i in range(1,10):
    if n<=111*i:
        print('{0}{1}{2}'.format(i,i,i))
        break

Solution (Python):
n = int(input())
while True:
    if len(set(list(str(n)))) == 1:
        print(n)
        exit()
    else:
        n += 1

Solution (Python):
n=int(input())
print((n//100+(1 if (n//100)*111<n else 0))*111)

Solution (Python):
N = input()
n = int(N)
h = int(N[0])

if h == 9:
    print(999)
else:
    if n > h * 111:
        h += 1
    print(h*111)

Solution (Python):
N=int(input())
a=N//100
b=(N-a*100)//10
c=N%10

if b<=a and c<=a:
    print(a*100+a*10+a)
else:
    print((a+1)*100+(a+1)*10+(a+1))

Solution (Python):




def main():
    N = input()
    if int(N[0] * len(N)) >= int(N):
        print(N[0] * len(N))
    else:
        print(str(int(N[0]) + 1) * len(N))


if __name__ == "__main__":
    main()

Solution (Python):
n = list(input())
n = [int(i) for i in n] 
if n[0]>n[1] or (n[0]==n[1] and n[0]>=n[2]):
    print(str(n[0])*3)
elif n[0]<n[1] or (n[0]==n[1] and n[0]<n[2]):
    print(str(n[0]+1)*3)

Solution (Python):
import bisect
n = int(input())
a = [0,111,222,333,444,555,666,777,888,999]
s = bisect.bisect_left(a,n)
print (a[s])

Solution (Python):
n = int(input())
for i in range(1,10):
  num = 100*i + 10*i + i
  if n <= num:
    print(num)
    exit(0)

Solution (Python):
N = int(input())

if N % 111 == 0:
    print(N)
    exit()

print(111 * (N//111 + 1))

Solution (Python):
N=int(input())
a=N//100
b=(N-a*100)//10
c=N-a*100-b*10
if a<b:
    N=(a+1)*111
elif a>b:
    N=a*111
elif a==b and a>=c :
    N=a*111
elif a==b and a<c :
    N=(a+1)*111
print(N)

Solution (Python):
N = int(input())
for i in range(N, 1000):
  if i % 111 == 0:
    print(i)
    break

Solution (Python):
N = list(input())
s = N[0]
n = int(''.join(N))

if int(N[0]*3) >= n:
    print(N[0]*3)
else:
    print(str(int(N[0])+1)*3)

Solution (Python):
def onaji(n):
    l = []
    while n > 0:
        l.append(n%10)
        n = n//10
    if l[0] == l[1] == l[2]:
        return True
    else:
        return False
    
N = int(input())
while not(onaji(N)):
    N += 1
    
print(N)

Solution (Python):
n = input()

n100 = n[0]
n10 = n[1]
n1 = n[2]

if int(n) <= int(n100 + n100 + n100):
  print(int(n100 + n100 + n100))
else:
  print((int(n100) + 1) * 111)

Solution (Python):
n=int(input())
for i in range(n,1000):
	if str(i)[0]==str(i)[1]==str(i)[2]:
		print(i)
		exit(0)
	else:
		pass
print('NA')

Solution (Python):
m=int(input())
for x in range(m,1000):
    s=str(x)
    if s[0]==s[1] and s[1]==s[2]:
        print(x)
        break

Solution (Python):
n = int(input())
for i in range(n,1000):
  if str(i).count(str(i)[0])==3:
    print(i)
    break

Solution (Python):
n = int(input())
x = int(n/111)
if n % 111 != 0:
    x += 1
print(x*111)

Solution (Python):
N = int(input())
for i in range(1,10):
    if 111*i >= N:
        print(111*i)
        break

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=2
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def main():
	a = int(input())
	for i in range(10):
		if a <= i*111:
			return i*111
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
n = input()
i = int(n[0])

if(n[1] < n[0]):
    print(n[0]+n[0]+n[0])
elif(n[1] == n[0]):
    if(n[2] <= n[0]):
        print(n[0]+n[0]+n[0])
    else:
        print((i+1)*100+(i+1)*10+(i+1))
else:
    print((i+1)*100+(i+1)*10+(i+1))

Solution (Python):
N =int(input())
a=N//111
b=N%111
if b!=0:
    x=111*(a+1)
else:
    x=N
print(x)

Solution (Python):
n=int(input())
print(n if n%111==0 else 111*(n//111+1) )

Solution (Python):
N=int(input())
ans=111

for i in range(9):
  a=(i+1)*111
  if N<=a:
    ans=a
    break
    
print(ans)

Solution (Python):
n = int(input())
a = (n + 111 - 1) // 111
print(a * 111)

Solution (Python):
n = int(input())
s = str(n)

if s[0] == s[1] and s[0] == s[2]:
    print(s)
else:
    while s[0] != s[1] or s[0] != s[2]:
        n += 1
        s = str(n)
        
    print(s)

Solution (Python):
N = list(input())
l  = len(N)
frst = int(N[0])
res = [str(frst)]*l
res = ''.join(res)
if int(res) >= int(''.join(N)):
	print(res)
else:
	print(int(''.join([str(int(frst)+1)]*l)))

Solution (Python):
N = int(input())
ls = []
for i in range(N,1000):
  if i % 111 == 0:
    ls.append(i)
print(ls[0])

Solution (Python):
n = input()
a = ['111','222','333','444','555','666','777','888','999']
 
for i in a:
    if i >= n:
        print(i)
        break

Solution (Python):
def main():
    N = int(input())
    next_ABCs = [111, 222, 333, 444, 555, 666, 777, 888, 999]
    for next in next_ABCs:
        if N <= next:
            print(next)
            break


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

print(-(-N//111) * 111)

Solution (Python):
n = int(input())
i = n // 111

if n % 111 != 0:
	i += 1

print(i * 111)

Solution (Python):
n = int(input())

for i in range(1, 10):
    num = 111 * i
    if n <= num:
        print(num)
        break

Solution (Python):
import math
N=int(input())

print(math.ceil(N/111)*111)

Solution (Python):
n = int(input())
ans = 0
for i in range(1,10):
    count = 100*i + 10*i + i
    if n <= count:
        ans = count
        break
print(ans)

Solution (Python):
n = int(input())
while n <= 999 :
  if list(str(n)[0]) == list(str(n)[1]) == list(str(n)[2]):
    print(n)
    exit()
  else:
    n += 1

Solution (Python):
N = int(input())
x = [99, 111, 222, 333, 444, 555, 666, 777, 888, 999]

for i in range(1, len(x)):
    if x[i-1] < N <= x[i]:
        print(x[i])

Solution (Python):
n=int(input())
for i in range(1,10):
    if n<=i*111:
        print(i*111)
        break

Solution (Python):
n=int(input())
print(int((n+110)/111)*111)

Solution (Python):
n=int(input())
ans=int((n+110)/111)
print(111*ans)

Solution (Python):
n=int(input())
for i in range(1,10):
    if n<=i*111:
        print(i*111)
        break
    else:
        pass

Solution (Python):
n=int(input())
print(((n-1)//111+1)*111)

Solution (Python):
N = int(input())

for i in range(N, 1000):
    if i % 111 == 0:
        zorome = i
        break

print(zorome)

Solution (Python):


n = int(input())
l = list(map(int,list(str(n))))

x = int(str(l[0])+str(l[0])+str(l[0]))
y = int(str(l[0]+1)+str(l[0]+1)+str(l[0]+1))

if n <= x:
    print(x)
else:
    print(y)

Solution (Python):
n = int(input())
l = list(map(int,list(str(n))))

x = int(str(l[0])+str(l[0])+str(l[0]))
y = int(str(l[0]+1)+str(l[0]+1)+str(l[0]+1))

if n <= x:
    print(x)
else:
    print(y)

Solution (Python):
def good_contest(num):
  return len(set(str(num))) == 1


def find_good_contest(next_contest):
  while not good_contest(next_contest):
    next_contest += 1
  return next_contest


def main():
  print(find_good_contest(int(input())))
  
  
if __name__ == '__main__':
  main()

Solution (Python):
print(-int(input())//111*-111)

Solution (Python):
n = input()
x = n[0]*3
print(int(x)+111 if n>x else int(x))

Solution (Python):
n = input()

for i in range(1,10):
    if str(i)*3 >= n:
        print(i, i, i, sep='')
        break

Solution (Python):
import sys
import math
import itertools

n=int(input())
while True:
	if n%111==0:
		print(n)
		sys.exit()
	n+=1

Solution (Python):
N=int(input())
for i in range(1,10):
    nn = i * 100 + i*10 +i
    if nn >= N:
        print(nn)
        break

Solution (Python):
n = int(input())

for i in range(1, 10):
    if (111 * i) >= n:
        print(111 * i)
        break

Solution (Python):
n = int(input())
a = int(str(n)[0])
if a * 111 < n:
    print((a+1) * 111)
else:
    print(a * 111)

Solution (Python):
"""
author : halo2halo
date : 22, Jan, 2020
"""

import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
for i in range(111,1000,111):
    if N<=i:
        print(i)
        break

Solution (Python):
N = int(input())
for i in range(N, 1000):
    a = str(i)
    if a[0] == a[1] and a[1] == a[2]:
        print(a)
        exit()

Solution (Python):
N=input()
n=int(N)
head=N[0]
tmp=int(head*3)
if n>tmp:
  t=str(int(head)+1)
  print(t*3)
else:
  print(tmp)

Solution (Python):
for i in range(int(input()), 1000):
  if i//100 == (i//10)%10 == i%10:
    print(i)
    break

Solution (Python):
N  = [list(map(int, s.split()))[0] for s in open(0)][0]

while True:
    if str(N)[0] == str(N)[1] and str(N)[1] == str(N)[2]:
        break 
    N += 1
        
print(N)

Solution (Python):
n = int(input())
answer = 0
while answer < n:
    answer += 111
print(answer)

Solution (Python):
N = int(input())

n = N
while (str(n)[0] != str(n)[1]) or (str(n)[1] != str(n)[2]):
    n += 1
ans = n
print(ans)

Solution (Python):
N = int(input())

n = N
for i in range(1000):
    if str(n)[0] == str(n)[1] == str(n)[2]:
        ans = n
        break
    n += 1

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    print(-(-N//111)*111)

if __name__ == '__main__':
    main()

Solution (Python):

from collections import Counter
n = int(input())
a = [str(i) for i in range(100, 1000) if len(Counter(str(i))) == 1]
for i in a:
    if n <= int(i):
        print(i)
        break

Solution (Python):
N = int(input())

n = N // 100
ans = n + n*10 + n*100

if N <= ans:
    print(ans)
else:
    print(ans + 111)

Solution (Python):
N = int(input())

ans = -(-N // 111) * 111

print(ans)

Solution (Python):
N = int(input())

if N > 888:
    print(999)
elif N > 777:
    print(888)
elif N > 666:
    print(777)
elif N > 555:
    print(666)
elif N > 444:
    print(555)
elif N > 333:
    print(444)
elif N > 222:
    print(333)
elif N > 111:
    print(222)
else:
    print(111)

Solution (Python):
N = int(input())
if not (N % 111):
    print(N)
    exit(0)
for i in range(10):
    if i * 111 < N and (i + 1) * 111 >= N: print((i + 1) * 111)

Solution (Python):
n = list(str(input()))

if int(''.join([n[0],n[0],n[0]])) < int(''.join(n)):
  print(int(''.join([n[0],n[0],n[0]]))+111)
else:
  print(int(''.join([n[0],n[0],n[0]])))

Solution (Python):
n=int(input())
for i in range(10):
  tmp=i*100+i*10+i
  if n<=tmp:
    print(tmp)
    break

Solution (Python):
n = int(input())
for i in range(12):
  if 111*(i+1) >= n:
    print(111*(i+1))
    exit()

Solution (Python):
n=input()
while 1:
    for i in range(len(n)-1):
        if n[i]!=n[i+1]:
            n=str(int(n)+1)
            break
    else:
        print(n)
        break

Solution (Python):
import math
print(math.ceil(int(input())/111)*111)

Solution (Python):
n=input()
x=[]
for i in range(len(n)):
    x.append(int(n[i]))
if x[0]>=x[1] and x[0]>=x[2]:
    for i in range(3):
        print(x[0], end='')
else:
    for i in range(3):
        print(x[0]+1, end='')

Solution (Python):
import sys

INPUT = lambda: sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)


def main():
    N = INPUT()
    low = str(int(N) // 100)
    high = str(int(N) // 100 + 1)

    for i in range(1, 3):
        if int(N[i]) < int(low): 
            print(low * 3)
            sys.exit()
        if int(N[i]) > int(low): 
            print(high * 3)
            sys.exit()
        if int(N[i]) == int(low) and i == 2: 
            print(low * 3)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
 
while True:
  s = str(n)
  if s.count(s[0])==len(s):
    print(n)
    exit()
  else:
    n += 1

Solution (Python):
N=int(input())
x=-(-N//111)
print(100*x + 10*x + x)

Solution (Python):
N=int(input())
x=-(-N//111)
print(int(100*x + 10*x + x))

Solution (Python):
n=int(input())
if n%111==0:
  print(n)
else:
  print(((n//111)+1)*111)

Solution (Python):
import math
i = int(input())
print(111*int(math.ceil(i/111)))

Solution (Python):
x=int(input())
for i in range(1, 10):
  a=100*i+10*i+i
  if a>=x:
    print(a)
    break

Solution (Python):
N = int(input())
for i in range(N, 1000):
  if len(set(str(i)))==1: break
print(i)

Solution (Python):
N=int(input())
print((((N-1)//111)+1)*111)

Solution (Python):
n=int(input())

ans_list=[111,222,333,444,555,666,777,888,999]

if n in ans_list:
    print(n)
else:
    for i in range(999):
        if n in ans_list:
            print(n)
            break
        n+=1

Solution (Python):
n = int(input())

for i in range(n, 1000):
   c = str(i)
   if (c[0] == c[1] and c[1] == c[2]):
      print(i)
      break

Solution (Python):

n = int(input())
a = 0

if n % 111 == 0:
    print(n)
else:
    a = n // 111

    print((a+1) * 111)

Solution (Python):
import math

N = int(input())
print(math.ceil(N / 111) * 111)

Solution (Python):
s=int(input())
A=[111,222,333,444,555,666,777,888,999]
for i in A:
  if i-s>=0:
    print(i)
    exit()

Solution (Python):
N=int(input())
while True:
  S=list(str(N))
  for i in range(1,len(S)):
    if S[i]==S[i-1]:
      continue
    else:
      break
  else:
    print(N)
    break
  N+=1

Solution (Python):
N = int(input())
NS = str(N)

st = int(NS[0] * 3)
if N <= st:
  print(st)

else:
  print(st + 111)

Solution (Python):
n = int(input())
if n % 111 == 0:
    x = n
while n % 111 != 0:
    x = n+1
    n += 1

print(x)

Solution (Python):
import sys

n = int(sys.stdin.readline().rstrip())

def main():
    return 111 * ((n + 111 - 1) // 111)

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
n = int(input())

if n % 111 == 0:
  print(n)
else:
  k = n // 111
  print((k+1)*111)

Solution (Python):
N = input()

N_0 = int(N[0])
if N_0 * 10 + N_0 >= int(N[1:]):
    print(str(N_0) * 3)
else:
    print(str(N_0+1) * 3)

Solution (Python):
N = int(input())

n = int( (N-1) / 111 )

print( 111 * (n+1) )

Solution (Python):
n=int(input())
for i in range(111):
  a=n+i
  b=set(str(a))
  if len(b)==1:
    print(a)
    exit()

Solution (Python):
n = int(input())

for i in range(n,1000):
    
    s = list(str(i))
    if s[0] == s[1] == s[2]:
        break    

print(i)

Solution (Python):
n = int(input())
z = (-(-n//111))*111
print(z)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
for i in range(1, 10):
    x = i*100+i*10+i
    if N - x <= 0:
        print(x)
        break

Solution (Python):
N=int(input())

for i in range(N,1000):
    if i%111==0:
        print(i)
        break

Solution (Python):
n = int(input())
a = n//111
if n % 111 != 0:
    a += 1
print(a*111)

Solution (Python):
import bisect
n=int(input())
li=[111,222,333,444,555,666,777,888]

a=bisect.bisect_left(li,n)

print((a+1)*111)

Solution (Python):
N = int(input())
for i in range(1,10):
   if 100*(i-1) + 10*(i-1) + i-1 < N <= 100*i + 10*i + i:
      print(100*i + 10*i +i)

Solution (Python):
N=input()
if N[0]==N[1]==N[2]:
    print(N)
elif int(N[0]*3)>int(N):
    print(N[0]*3)
else:
    print(str(int(N[0])+1)*3)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
d = 10000
index = 0
for i in range(1,10) :
    k = i * 100 + i * 10 + i
    if k < N :
        continue
    else :
        de = abs(N - k)
        if d > de :
            d = de
            index = k
print(index)

Solution (Python):
N = input()
A = int(N[0])*111
print((int(N[0])+1)*111 if int(N) > A else A)

Solution (Python):

 
import math
import itertools
import sys
import copy
 




N = int(input())

b = 111
if N <= b :
  print (b)
  exit()

while N-b > 111 :
  b += 111
b += 111
print (b)

Solution (Python):
n = int(input())
for i in range(1, 10):
    if 111*i >= n:
        print(111*i)
        exit()

Solution (Python):
N = int(input())
print(((N-1)//111 + 1)*111)

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7




n = int(sys.stdin.buffer.readline())
while True:
    if len(Counter(str(n))) == 1:
        print(n)
        break
    n += 1

Solution (Python):


target = [111,222,333,444,555,666,777,888,999]
next = int(input())

ans = [i for i in target if i >= next][0]
print(ans)

Solution (Python):
n=int(input())
if n<=111:
    print(111)
elif n<=222:
    print(222)
elif n<=333:
    print(333)
elif n<=444:
    print(444)
elif n<=555:
    print(555)
elif n<=666:
    print(666)
elif n<=777:
    print(777)
elif n<=888:
    print(888)
else:
    print(999)

Solution (Python):
x=input()
l=list(map(int,list(x)))
print(str(max(l))*3 if int(str(max(l)-1)*3) < int(x) else str(max(l)-1)*3)

Solution (Python):
n=input()
a,b,c=n[0],n[1],n[2]
if a==b==c:
  print(n)
elif a==max(a,b,c):
  print(a*3)
else:
  d=int(a)+1
  print(str(d)*3)

Solution (Python):
n = int(input())

if n%111 == 0:
    print(n)
else:
    print(111*(n//111+1))

Solution (Python):
N = int(input())
ans = 0
while ans < N:
    ans += 111
print(ans)

Solution (Python):
from bisect import bisect_left
n = int(input())
lst = [int(str(i) * 3) for i in range(1, 10)]
print(lst[bisect_left(lst, n)])