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):
n = int(input())
ans = n//111*111 if n%111 == 0 else n//111*111 + 111
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):
n = int(input())
for i in range(111,1000,111):
    if n <= i:
        print (i)
        break

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

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

Solution (Python):
N=int(input())
a=[int(x) for x in list(str(N))]
s=a[0]*100+a[0]*10+a[0]
t=s+111
if a[0]>a[1]:
    print(s)
elif a[0]==a[1]:
    if a[1]<a[2]:
        print(t)
    else:
        print(s)
else:
    print(t)

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

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

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

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

Solution (Python):
s=input()
while len(set(s))>1:s=str(int(s)+1)
print(s)

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

Solution (Python):
import math

n = int(input())

if n % 111 == 0:
	print(n)
else:
	amari = math.ceil(n / 111)
	print(111*amari)

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

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

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

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

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

if (N <= 111):
  print(111)
elif(111 < N and N <= 222):
  print(222)
elif(222 < N and N <= 333):
  print(333)
elif(333 < N and N <= 444):
  print(444)
elif(444 < N and N <= 555):
  print(555)
elif(555 < N and N <= 666):
  print(666)
elif(666 < N and N <= 777):
  print(777)
elif(777 < N and N <= 888):
  print(888)
elif(888 < N and N <= 999):
  print(999)

Solution (Python):
N = input().rstrip()
N_list = list(N)

select_num = int(N_list[0])
next_str = ''
next_str += str(select_num)
next_str += str(select_num)
next_str += str(select_num)

if int(next_str) >= int(N):
  print(next_str)
else:
  select_num += 1
  next_str = ''
  next_str += str(select_num)
  next_str += str(select_num)
  next_str += str(select_num)
  print(next_str)

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

def judge(N):
    lst = [111, 222, 333, 444, 555, 666, 777, 888, 999]
    for n in lst:
        if N <= n:
            return(n)
print(judge(N))

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

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

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

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

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

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

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

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

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

Solution (Python):
x = input()

base = int(x)

xs = [x for x in [int(c*3) for c in set('123456789') ] if x >= base ]
print(sorted(xs).pop(0))

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

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

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

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


def f(n):
    n = str(n)

    return n[0] == n[1] == n[2]


def main():
    N = int(input())

    while not f(N):
        N += 1
    
    print(N)


main()

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

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

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

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

if n % 111 == 0:
    print(n)
else:
    print(n - (n % 111) + 111)

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

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

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

Solution (Python):
N = input()
n = []
for i in N:
    n.append(i)
if n[0] == n[1] and n[1] == n[2]:
    print(int(N))
else:
    if n[0] >= n[1] and n[0] >= n[2]:
        print(int(n[0]*3))
    else:
        tmp = int(n[0])
        tmp += 1
        n[0] = str(tmp)
        print(int(n[0]*3))

Solution (Python):


def is_valid(x):

    return len(set(list(str(x)))) == 1

n = int(input())

def get_ans(n):
    while True:
        if is_valid(n):
            return n
        n += 1

print(get_ans(n))

Solution (Python):
N=int(input())
N_str = []
for i in range(N,1000):
    N_new = N
    while N>0:
        N_str.append(N%10)
        N//=10
    N_str.reverse()
    
    N = N_new
          
    if N_str[0]==N_str[1] and N_str[1]==N_str[2]:
        print(N)
        break
    N+=1

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

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

for a in range(10):
    if a*111<N:
        pass
    elif a*111>=N:
        print(a*111)
        break

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

i=1

while n>i*111:
  i+=1

  
print(i*111)

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

result = (N + 110) // 111 * 111

print(result)

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

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

while True:
	check = set(str(n))
	if len(check) == 1:
		print(n)
		break
	n += 1

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

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

Solution (Python):
try:
    a = int(input())
    
    nums = [111, 222, 333, 444 ,555 ,666, 777, 888, 999]
    
    print(min(list(filter(lambda x : x >= a, nums))))
except EOFError:
    pass

Solution (Python):


n = int(input())

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

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

Solution (Python):
N = int(input())
while True:
    n = str(N)
    i = 0
    ans = 1
    while True:
        if i >= len(n):
            break
        if n[i] != n[i - 1]:
            ans = -1
            break
        i += 1
    if ans == 1:
        print(n)
        break
    N += 1

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

Solution (Python):
def out(text):
    print(text, end='')

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

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

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

Solution (Python):
line = int(input())
lina = list(map(int, [line/100, (line/10)%10, line%10]))
contest = [111*lina[0], 111*(lina[0]+1)]
if(contest[0] - line >= 0):
    print(contest[0])
else:
    print(contest[1])

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

for i in range(111,1000,111):
    if N <= i:
        v += 1

print(1110 - 111*v)

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

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

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

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

Solution (Python):

def answer(in0):
    return (int(int(in0) / 111.1) + 1) * 111

print(answer(input()))

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

Solution (Python):
import numpy as np
n = int(input())
table = np.array([111*i for i in range(1,10)])
table = table[np.where(table>=n)]
print(table[np.argmin(table-n)])

Solution (Python):


n=int(raw_input())
x=n/100
y=x*100+x*10+x
if n-y<=0:
 print x*111
else:
 print (x+1)*111

Solution (Python):



n = int(input())
m = []
k = 0
for i in range(1,10):
    m.append(i*111)
for j in m:
    if j >= n:
        k = j
        break
        
print(k)

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):
N = int(input())

for i in range(1, 10):
    x = i + 10*i + 100*i
    if x>= N:
        break
        
print(x)

Solution (Python):
import math

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

Solution (Python):
n = int(input())
ln = [i for i in str(n)]
ans = ln[0] * 3
if int(ans) < n:
    ans = str(n // 100 + 1) * 3
print(ans)

Solution (Python):
n = int(input())
v1 = n%10
v2 = (n//10)%10
v3 = n//100

if v1 == v2 and v2 == v3:
    print(n)
elif v3 > v2:
    print(v3*111)
elif v3 == v2:
    if v2 > v1:
        print(v3*111)
    else:
        print((v3+1)*111)
else:
    print((v3+1)*111)

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

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

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

Solution (Python):

from sys import stdin

a = int(stdin.readline().rstrip())


if a % 111:
    print(((a // 111) + 1) * 111)
else:
    print(a)

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

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

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
i=N
list = []
while i > 0:
    list.append(i%10)
    i //= 10
list.reverse()

if N<=list[0]*111:
    print(list[0]*111)
else:
    print((list[0]+1)*111)

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

    ans1 = AC1(N)
    ans2 = AC2(N)
    assert ans1 == ans2

    print(ans1)


def AC1(N):
    for i in range(N, 999+1):
        if len(set(list(str(i)))) == 1:
            return i


def AC2(N):
    for i in range(1, 9+1):
        if N <= 111 * i:
            return 111 * i


if __name__ == '__main__':
    main()

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

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

while True:
    if len(set(str(i))) == 1:
        print(i)
        break
    i += 1

Solution (Python):
n = int(input())
zs = [111 * i for i in range(1, 9 + 1)]
for z in zs:
    if n <= z:
        print(z)
        exit()

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

while True:
    if N%111==0:
        break
    else:
        N+=1

print(N)

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

Solution (Python):
import math

while True:
    try:
        n = eval(input().strip())

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

    except:
        break

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

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

Solution (Python):
n=int(input())
m=n//100

a=(m*100)+(m*10)+m
if a>=n:
    print(a)
else:
    m+=1
    a=(m*100)+(m*10)+m
    print(a)

Solution (Python):
n = int(input())
cnt = 0
while n > 0:
    n -= 111
    cnt += 1
print(cnt * 111)

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

while 1:
    if n % 111 == 0:
        break
    n += 1

print(n)

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

compare = 111
while n > compare:
    compare += 111

print(compare)

Solution (Python):
n=int(input())
if 100<=n<=111:
	print(111)
if 112<=n<=221:
	print(222)	
if 222<=n<=333:
	print(333)	
if 334<=n<=444:
	print(444)
if 445<=n<=555:
	print(555)
if 556<=n<=666:
	print(666)
if 667<=n<=777:
	print(777)
if 778<=n<=888:
	print(888)
if 889<=n<=999:
	print(999)

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


list = [111,222,333,444,555,666,777,888,999]
num2 = 0
for num in list:
    if N <= num:
        print (num)
        break

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

result =n[0]+n[0]+n[0]

if int(n[0]+n[0]+n[0])<int(n[0]+n[1]+n[2]):
    a = str(int(n[0])+1)
    result = a+a+a
    
print(result)

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

if num<=111:
    num=111
elif num<=222:
    num=222
elif num<=333:
    num=333
elif num<=444:
    num=444
elif num<=555:
    num=555
elif num<=666:
    num=666
elif num<=777:
    num=777
elif num<=888:
    num=888
else:
    num=999

print(num)

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

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

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

Solution (Python):
n = input()

l = list()
num = int(n)
for i in range(9):
    l.append(111*(i+1))

for i in range(9):
    if num == l[i]:
        print(l[i])
        break
    elif num < l[i]:
        print(l[i])
        break
    else:
        continue

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

for i in range(n,1000):
    a=i//100
    b=(i-100*a)//10
    c=i%10
    if a==b and a==c :
        ans=i
        break
print(ans)

Solution (Python):
def judge(N):
    a = []
    n = N
    while n != 0:
        j = n % 10
        if len(a) == 0:
            a += [j]
        elif j != a[0]:
            return False
        n //= 10
    return True

def main():
    n = int(input())
    while not judge(n):
        n += 1

    print(n)

main()

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
li = [111,222,333,444,555,666,777,888,999]
ind = bisect.bisect_left(li,N)
print(li[ind])

Solution (Python):
n = input()
l = [int(x) for x in list(str(n))]
ans = []
if (l[0] < l[1]) or (l[0] < l[2]):
	num = l[0] + 1
else:
	num = l[0]
for i in range(3):
	ans.append(num)
ansn = ans[0] * 100 + ans[1] * 10 + ans[2]
print(ansn)

Solution (Python):
N=input()

if N[2]==N[1]==N[0]:
    A=N

elif N[2]>N[0] or N[1]>N[0]:
    B=int(N[0])+1
    C=str(B)
    A=str(C+C+C)


else:
    A=str(N[0]+N[0]+N[0])


    
print(A)

Solution (Python):
n = int(input())
prospects = [111*i for i in range(1, 10)]

for p in prospects:
    if p < n:
        continue
    if p >= n:
        print(p)
        break

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

if 100<=N<112: print(111)
elif 112<=N<223: print(222)
elif 223<=N<334: print(333)
elif 334<=N<445: print(444)
elif 444<=N<556: print(555)
elif 555<=N<667: print(666)
elif 667<=N<778: print(777)
elif 778<=N<889: print(888)
else: print(999)

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

while i <= 999:
    if N <= i:
        print(i)
        break
    else:
        i += 111

Solution (Python):
a = raw_input()
b = int(a[0])
c = int(a[1])
d = int(a[2])
e = b+1
if b == c == d:
  print 111*b
else:
  if int(a)>111*b:
    print 111*(b+1)
  else:
    print 111*b

Solution (Python):
want_to_join = {
    '1': 111,
    '2': 222,
    '3': 333,
    '4': 444,
    '5': 555,
    '6': 666,
    '7': 777,
    '8': 888,
    '9': 999
}

number_letter = input()
first_letter = number_letter[0]
if want_to_join[first_letter] >= int(number_letter):
    print(want_to_join[first_letter])
else:
    next_letter = str(int(first_letter)+1)
    print(want_to_join[next_letter])

Solution (Python):
N = int(input())
repdigit = [str(x)*3 for x in range(1,10)]

for i in range(len(repdigit)):
    try:
        if N <= int(repdigit[i]):
            print(repdigit[i])
            break
    except:
        pass

Solution (Python):

def isCorrect(n):
    l = [int(x) for x in list(str(n))]
    prev = l.pop(0)

    for num in l:
        if num != prev:
            return False
        prev = num
    return True

if __name__ == '__main__':
    n = int(input())

    for m in range(n, 100000):
        if isCorrect(m):
            print(m)
            break

Solution (Python):
N=int(input())
if 100<=N<=111:
    print(111)
elif 112<=N<=222:
    print(222)
elif 223<=N<=333:
    print(333)
elif 334<=N<=444:
    print(444)
elif 445<=N<=555:
    print(555)
elif 556<=N<=666:
    print(666)
elif 667<=N<=777:
    print(777)
elif 778<=N<=888:
    print(888)
else:
    print(999)

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

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

Solution (Python):
n = input()
a = [list(n)[0]]*len(n)
ans = ''.join(a)

if int(n) <= int(ans):
    print(ans)
else:
    ans = [str(int(list(n)[0])+1)] * len(n)
    ans = int(''.join(ans))
    print(ans)

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

Solution (Python):
n = input()
if n[0] == n[1] and n[1] == n[2]:
    print(n)
elif (n[0] == n[1] and n[1] < n[2]) or n[0] < n[1]:
    b = int(n[0])+1
    print(str(b) + str(b) + str(b))
else:
    print(n[0] + n[0] + n[0])

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

Solution (Python):
import math
N = input()
temp = 0
result = ''
if int(N) % 111 == 0:
    print(N)
else:
    temp = math.ceil((int(N) / 111))
    for i in range(len(N)):
        result += str(temp)
    print(result)

Solution (Python):
input_line = int(input())
i = 111

while True:
    if input_line <= i:
        break
    i += 111

print(i)

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

if N <= (N//100)*111:
    print((N//100)*111)
else:
    print((N//100 + 1)*111)

Solution (Python):
n = input()
def makeList(n):
    return list(n)


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

Solution (Python):
def first_ABC():
    array = []
    for fig in range(1, 10):
        sum = fig * 100 + fig * 10 + fig
        array.append(sum)
    return array

if __name__ == "__main__":
    N = int(input())
    array = first_ABC()
    for select in array:
        if select >= N:
            print(select)
            break

Solution (Python):


m = int(input())

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


if 100 <= m <1000:
    
     for v in nums:
       if m <= v :
         print(v)
         break

Solution (Python):


m = int(input())

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


if 100 <= m <1000:
    
     for v in nums:
       if m <= v :
         print(v)
         break

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

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')
elif N <= 999:
    print('999')

Solution (Python):
num=input()
num_list=list(num)
n=len(num)
ans_num=0
element=int(num_list[0])
for i in range(n):
    if element<int(num_list[i]):
        tf=False
        element+=1
        break
print(str(element)*n)

Solution (Python):

n=int(input())
if n>=100 and n<=111:
    print(111)
if n>111 and n<=222:
    print(222)
elif n>222 and n<=333:
    print(333)
elif n>333 and n<=444:
    print(444)
elif n>444 and n<=555:
    print(555)
elif n>555 and n<=666:
    print(666)
elif n>666 and n<=777:
    print(777)
elif n>777 and n<=888:
    print(888)
elif n>888 and n<=999:
    print(999)

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

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

Solution (Python):


import sys

input = sys.stdin.readline
a = input()

tmp =  int(a[0] * 3)
if int(a[0] * 3) < int(a):
    print(str(int(a[0]) + 1) * 3)
else:
    print(str(int(a[0])) * 3)

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

Solution (Python):
N = input()

if N[0] == "1":
    if int(N) <= 111:
        print(111)
    else:
        print(222)
elif N[0] == "2":
    if int(N) <= 222:
        print(222)
    else:
        print(333)
elif N[0] == "3":
    if int(N) <= 333:
        print(333)
    else:
        print(444)
elif N[0] == "4":
    if int(N) <= 444:
        print(444)
    else:
        print(555)
elif N[0] == "5":
    if int(N) <= 555:
        print(555)
    else:
        print(666)
elif N[0] == "6":
    if int(N) <= 666:
        print(666)
    else:
        print(777)
elif N[0] == "7":
    if int(N) <= 777:
        print(777)
    else:
        print(888)
elif N[0] == "8":
    if int(N) <= 888:
        print(888)
    else:
        print(999)
else:
    print(999)

Solution (Python):
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def is_all_same(S):
    pre_s = S[0]
    for s in (S):
        if s != pre_s:
            return False
    return True

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])

    while 1:
        if is_all_same(str(N)):
            print N
            exit()
        N += 1

if __name__ == '__main__':
    main()

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

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

Solution (Python):
N = int(input())
num = []
while N != 0:
  num.append(N%10)
  N -= N%10
  N /= 10
a=num[2]
b=num[1]
c=num[0]
if a==b>=c:
  print(int(100*a+11*b))
if a==b<c or a<b:
  print(int((a+1)*111))
if a>b:
  print(int(a*111))

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

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

Solution (Python):
n=input()
length = len(n)
x = n[0]


if n[1] < x:
    x = x*length

elif n[1] > x:
    x = str(int(x) + 1)*length

else:
    
    if n[2] < x:
        x = x *length
    
    elif n[2] > x:
        x = str(int(x)+1)*length

    else:
        x = x * length

if int(n) == 999:
    x = '999'

print(x)

Solution (Python):
n = int(input())
if n < 112:
    print(111)
elif n < 223:
    print(222)
elif n < 334:
    print(333)
elif n < 445:
    print(444)
elif n < 556:
    print(555)
elif n < 667:
    print(666)
elif n < 778:
    print(777)
elif n < 889:
    print(888)
else:
    print(999)

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

i = n
while(True):
    if len(set(list(str(i)))) == 1:
        print(i)
        sys.exit(0)
    i += 1

Solution (Python):
N = raw_input()

s = N[0] if max(map(int, N)) == int(N[0]) else int(N[0]) + 1
print str(s) * 3

Solution (Python):
n = input()

if int(n[0]) <= int(n[1]):
    if int(n[0]) == int(n[1]) and int(n[0]) >= int(n[2]):
        temp=int(n[0])
        print(temp*100+temp*10+temp)
    else:
        temp=int(n[0])+1
        print(temp*100+temp*10+temp)
else:
    temp=int(n[0])
    print(temp*100+temp*10+temp)

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

if int(ans) < int(N):
    ans = str(int(ans)+111)
    
print(ans)

Solution (Python):
num = int(input())
list_1 = [999, 888, 777, 666, 555, 444, 333, 222, 111]
num_list = []
for l in list_1:
    if l >= num:
        num_list.append(l)
print(min(num_list))

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

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

for i in x:
    if i - n >= 0:
        ans = i
        break

print(ans)

Solution (Python):
n = int(input())
nMap = list(map(int,str(n)))
f = int(str(nMap[0])*3)
if f < n:
    print(str(nMap[0]+1)*3)
else:
    print(f)

Solution (Python):
n = input()
a = list(n)
if a[0] == a[1] ==a[2]:
    print(n)
else:
    if int(a[0])> int(a[1]):
        a[1] = a[0]
        a[2] = a[0]  
        for i in range(3):
            print(a[i] ,end="")

    elif a[0]==a[1] and int(a[0]) <int(a[2]):
         a[0] = str(int(a[0]) +1)
         a[1] =a[0]
         a[2] = a[0]

         for i in range(3):
            print(a[i] ,end="")
    elif a[0]==a[1] and int(a[0]) >int(a[2]):
         a[2] = a[0]
         for j in range(3):  
            print(a[j] ,end="")         


    else:
        a[0] = str(int(a[0]) +1)
        a[1] =a[0]
        a[2] = a[0]

        for j in range(3):  
            print(a[j] ,end="")

Solution (Python):
A = list(input())
x = int(A[0])
y = int(A[1])
z = int(A[2])

ans = ''
a = 0
if x > y:
    a = str(x)
    ans = a + a + a
elif x == y:
    if y >= z:
        a = str(x)
        ans = a + a + a
    else:
        a = str(x + 1)
        ans = a + a + a
else:
    a = str(x + 1)
    ans = a + a + a

print(ans)

Solution (Python):
N=int(input())
if N<=111:
    print(111)
if N>111 and N<=222:
    print(222)
if N>222 and N<=333:
    print(333)
if N>333 and N<=444:
    print(444)
if N>444 and N<=555:
    print(555)
if N>555 and N<=666:
    print(666)
if N>666 and N<=777:
    print(777)
if N>777 and N<=888:
    print(888)
if N>888 and N<=999:
    print(999)

Solution (Python):
n = int(input())
for t in range(1,10):
    if n <= t*100 + t*10 + t:
        res = t*100 + t*10 + t
        break 

print(res)

Solution (Python):

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

Solution (Python):
b = str(input())
num = list(b)
appear = b.count(num[0])
if appear == 3:
    print(b)
elif num[0]>num[1]:
    c = num[0]
    d=str(c)
    print(d*3)
elif num[0] == num[1]:
    if num[1]<num[2]:
        c = int(num[0])+1
        d=str(c)
        print(d*3)
    else:
        c = num[1]
        d=str(c)
        print(d*3)
else:
    c = int(num[0])+1
    d=str(c)
    print(d*3)

Solution (Python):
n = input()
ans = int(n[0]) * 111
if ans < int(n):
    ans += 111
print(ans)