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())
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):
import math
a = int(input())

b = math.ceil(a/111)

print(b*111)

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 = list(input())

ans = ''

if n[0] > n[1]:
    for i in range(3):
        ans += n[0]
elif n[0] == n[1] and n[0] >= n[2]:
     for i in range(3):
        ans += n[0]
else:
    n[0] = int(n[0]) + 1
    for i in range(3):
        ans += '{}'.format(n[0])
        

print(ans)

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

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

print(res)

Solution (Python):
N = input().strip()

h, t, o = N[0], N[1], N[2]

if int(h) < int(t):
  print(str(int(h) + 1) * 3)
elif int(h) > int(t):
  print(h * 3)
else:
  if int(t) < int(o):
    print(str(int(h) + 1) * 3)
  elif int(t) >= int(o):
    print(h * 3)

Solution (Python):

n=int(input())
a=0
while(a<n):
  a+=111
print(a)

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

while number % 111 != 0:
  number += 1
  
print(number)

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

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

Solution (Python):
n = input()
num = int(n)
ans = 0
for digit in range(1,10):
    if num/digit == float(111):
        ans = num
        break
    elif num/digit < float(111):
        ans = digit*100+digit*10+digit
        break
print(ans)

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

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

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

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

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

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

print(ans)

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

Solution (Python):


n = int(input())
zorome = [0, 111, 222, 333, 444, 555, 666, 777, 888, 999]

for i in range(len(zorome)-1):
    if n == zorome[i]:
        print(zorome[i])
        break
    elif (n > zorome[i]) & (n<=zorome[i+1]):
        print(zorome[i+1])
        break
    else:
        pass

Solution (Python):

import sys
    
n = input()
num = list(n)
n100 = num[0]
n10 = num[1]
n1 = num[2]
if (num[0] == num[1]) and (num[0] == num[2]):
    print(n)
    sys.exit()

if int(n) < int(n100)*100 + int(n100)*10 + int(n100):
    print(int(n100)*100 + int(n100)*10 + int(n100))

if int(n) > int(n100)*100 + int(n100)*10 + int(n100):
    print((int(n100)+1)*100 + (int(n100)+1)*10 + (int(n100)+1))

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

Solution (Python):
n = input()

a = n[0]
comp = ""

for i in range(len(n)):
    comp += a

if int(n) == int(comp):
    print(n)
elif int(n) < int(comp):
    print(comp)
else:
    b = str(int(a) + 1)
    ans = ""
    for i in range(len(n)):
        ans += b
    print(ans)

Solution (Python):
n = int(input())
NS = [111,222,333,444,555,666,777,888,999]
a = 0
for c in NS:
    if c < n:
        continue
    a = c
    break
print(a)

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

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

def decideContest(inNum, inList):
    for num in zoromeList:
        if inNum <= num:
            print(num)
            return

decideContest(n, zoromeList)

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 = raw_input()
if(int(n) > int(n[0]*3)):
	print(str(int(n[0])+1)*3)
else:
	print(n[0]*3)

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

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

for i in range(9,-1,-1):
    if n > 111*i :
        print(111*(i+1))
        break

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

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
o = int((n-(n%100))/100)
if n<=o*111:
    print(o*111)
else:
    print(o*111+111)

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

k = 111
while k < 999:
    if a > k:
        k += 111
    if a == k:
        print(a)
        break
    if a < k:
        a = k
        print(a)
        break

Solution (Python):
n = input()

if int(n[0]) > int(n[1]):
    print(n[0]+n[0]+n[0])
elif n[0] == n[1]:
    if n[1] == n[2]:
        print(n[0]+n[0]+n[0])
    elif int(n[1]) > int(n[2]):
        print(n[0]+n[0]+n[0])
    else:
        nn = int(n[0]) + 1
        print(str(nn)+str(nn)+str(nn) )
else:
    nn = int(n[0]) + 1
    print(str(nn)+str(nn)+str(nn) )

Solution (Python):
N = int(input())
print(min([x for x in [int(str(i) * 3) - N for i in range(1, 10)] if x >= 0]) + N)

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

zoros = [int(str(i)*3) for i in range(1,10)]


def minzoro(x):
    return min(filter(lambda i: i >= x, zoros))

print(minzoro(n))

Solution (Python):
N = int(input())
l = [100*i+10*i+i for i in range(1,10)]
l.append(N),l.sort()
if l.count(N) == 2:
  print(N)
else:
  print(l[l.index(N) + 1])

Solution (Python):
n=int(input())
i=0
m=0
while(m<n):
    i=i+1
    m=111*i
print(m)

Solution (Python):
num = int(input())
ct = 111
while True:
    if ct >= num:
        break
    ct += 111
print(ct)

Solution (Python):
import numpy as np

x = input()
x = str(x)
y = 0
z = len(x)
for i in range(1, z):
  if int(x[0]) < int(x[i]):
    y = 1
if y == 0:
  w = int(x[0])
else:
  w = int(x[0]) + 1
y = 0
for i in range(z):
  y = y + int(w) * (10 ** (z - i - 1))
print(y)

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

tmp = N // 100
result = tmp * 100 + tmp * 10 + tmp
if result < N:
    tmp = tmp + 1
result = tmp * 100 + tmp * 10 + tmp

print(result)

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

num =int(n/100)


x = num* 111
if n <= x:
    print(x)
else:
    print(x+111)

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

if n <= 111:
    ans = 111
elif n <= 222:
    ans = 222
elif n <= 333:
    ans = 333
elif n <= 444:
    ans = 444
elif n <= 555:
    ans = 555
elif n <= 666:
    ans = 666
elif n <= 777:
    ans = 777
elif n <= 888:
    ans = 888
elif n <= 999:
    ans = 999

print(ans)

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

Solution (Python):
n = int(input())
k = 1
N = 100*k + 10*k + 1*k
while n > N:
    k += 1
    N = 100 * k + 10 * k + 1 * k
print(N)

Solution (Python):
N = map(int, list(raw_input()))

if N[0] > N[1]:
    l = [N[0]] * 3
    print(''.join([str(i) for i in l]))
elif N[0] == N[1] >= N[2]:
    l = [N[0]] * 3
    print(''.join([str(i) for i in l]))
elif N[0] == N[1] < N[2]:
    l = [N[0]+1] * 3
    print(''.join([str(i) for i in l]))
elif N[0] < N[1]:
    l = [N[0]+1] * 3
    print(''.join([str(i) for i in l]))

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

for n in [111, 222, 333, 444, 555, 666, 777, 888, 999]:
    if N <= n:
        print(str(n))
        break

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

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

for i in range(1, 10, 1):
    str_i = str(i)
    str_x = "{}{}{}".format(str_i, str_i, str_i)
    x = int(str_x)
    if x >= N:
        break
print(x)

Solution (Python):
import math
n = int(input())
i = (int((n-1)/111))

print((i+1)*111)

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

if n <= 9:
    kotae = n
elif n <= 99:
    while n % 11 != 0:
        n = n + 1
    kotae = n
else:
    while n % 111 != 0:
        n = n + 1
    kotae = n

print(kotae)

Solution (Python):
a = int(input())
check = 111

for i in range(10):
 if a <= check:
  print(check)
  exit()
 check += 111

Solution (Python):
c = int(input())
check = []
for i in range(1,10):
    check.append(str(i)*3)

for i in range(9):
    if c<=int(check[i]):
        print(check[i])
        exit()

Solution (Python):
n=list(input())
for i in range(len(n)):
    n[i]=int(n[i])

for i in range(n[0],10):
    if(n[0]==i):
        for i2 in range(n[1],10):
            for i3 in range(n[2],10):
                if(i==i2==i3):
                    print(i*100+i2*10+i3)
                    exit(0)
    else:
        for i2 in range(1,10):
            for i3 in range(1,10):
                if(i==i2==i3):
                    print(i*100+i2*10+i3)
                    exit(0)

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

Solution (Python):
N = input()
n = list(N)
str = n[0] + n[0] + n[0]
num = int(str)
big = int(n[0]) + 1
big_num = 100 * big + 10 * big + big
number = int(N)
if number <= num:
  print(num)
else:
  print(big_num)

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

for i in range(9):
	if 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())
if 100 <= n <= 111:
    print(111)
if 112 <= n <= 222:
    print(222)
if 223 <= 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 = list(input())
if len(set(N)) == 1:
    print(''.join(N))
else:
    b = int(N[0])*100+int(N[0])*10+int(N[0])
    real_n = int(N[0])*100+int(N[1])*10+int(N[2])
    
    if real_n < b:
        print(b)
    else:
        print(str(int(N[0])+1)*3)

Solution (Python):
n = input()

if len(set(n)) == 1:
    print(n)
else:
    l = [111,222,333,444,555,666,777,888,999]
    l.append(int(n))
    l.sort()
    print(l[l.index(int(n))+1])

Solution (Python):
def main():
    N = [x for x in input()]
    if len(set(N)) == 1:
        print("".join(N))
    else:
        print(nex(N))


def nex(n):
    result = int(n[0] * 3)
    if int("".join(n)) > result:
        result = int(str(int(n[0]) + 1) * 3)
    return result


if __name__ == '__main__':
    main()

Solution (Python):
n = input()
if n[0]==n[1]==n[2]:
    print(n)
elif n[0]>n[1]:
    print(n[0]+n[0]+n[0])
elif n[0]<n[1]:
    t = str(int(n[0])+1)
    print(t+t+t)
elif n[0]==n[1]>n[2]:
    print(n[0]+n[0]+n[0])
elif n[0]==n[1]<n[2]:
    t = str(int(n[0])+1)
    print(t+t+t)

Solution (Python):
n=int(input())
while True:
  flag=0
  a=n
  while a!=0:
    now=a%10
    if flag==0:
      pre=now
      flag=1
    if now!=pre:
      flag=2
      break
    pre=now
    a=a//10
  if flag==1:
    print(n)
    break
  n+=1

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

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

Solution (Python):
n = int(input())
a = list(str(n))
m = int(a[0])*100 + int(a[0])*10 + int(a[0]) 
o = (int(a[0])+1)*100 + (int(a[0])+1)*10 + (int(a[0])+1)
if m < n: 
 print(o)
else:
 print(m)

Solution (Python):


N = int(input())

ans = 0

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

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


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

Solution (Python):
from sys import stdin


def fun(n, l):
    a = 0
    for i in range(l):
        a += n * (10**i)

    return a


N = stdin.readline().rstrip()

if int(N[0]) < 9:
    a = fun(int(N[0]), len(N))
    if (a >= int(N)):
        print(a)
    else:
        a = fun(int(N[0]) + 1, len(N))
        print(a)
else:
    a = fun(9, len(N))
    if (a >= int(N[0])):
        print(a)
    else:
        a = fun(1, len(N) + 1)
        print(a)

Solution (Python):
N = int(input())
s = int((N - 1) / 111)

x = (s + 1) * 111
print(x)

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

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

def is_zorome(Nstr):
    init = Nstr[0]
    for n in Nstr[1:]:
        if n != init:
            return False
    return True

def find_min_zorome(Nstr):
    init = Nstr[0]
    candidate = ""
    for _ in range(len(Nstr)):
        candidate += init

    if int(Nstr) < int(candidate):
        return candidate
    else:
        candidate = ""
        if init == "9":
            for _ in range(len(Nstr)+1):
                candidate += "1"
        else:
            for _ in range(len(Nstr)):
                candidate += str(int(init)+1)
        return candidate

if is_zorome(N):
    print(N)
else:
    print(find_min_zorome(N))

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()
if int(n[0] * 3) >= int(n):
    print(n[0] * 3)
else:
    print(str(int(n[0]) + 1) * 3)

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

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

Solution (Python):



input = raw_input()

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

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

Solution (Python):
N = input()
n1 = int(N[0])
n2 = int(N[1])
n3 = int(N[2])

if n1 >= n2 and n1 >= n3:
    v = n1
else:
    v = n1 + 1
print(str(v)+str(v)+str(v))

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

if N <100:
    m = N//10
    k = m+m*10
    if N <= k:
        print(k)
    else:
        k = m+1 + (m+1)*10
        print(k)
else:
    m = N//100
    k = m+m*10+m*100
    if N <= k:
        print(k)
    else:
        k=m+1 +(m+1)*10+ (m+1)*100
        print(k)

Solution (Python):
s = input()

l = len(s)

m = s[0]

def check(s, t):
    for i, j in zip(s, t):
        if i != j:
            return i > j

    return 1


if (check(m*l, s)):
    print(m*l)
else:
    print(chr(ord(m)+1)*l)

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

Solution (Python):
n = input()
if n[0] == n[1] and n[1] == n[2] and n[2] == n[0]:
    print(n)
else:
    n1 = int(n)
    n_tmp = int(n[0])
    n2 = n_tmp*100 + n_tmp*10 + n_tmp
    n3 = (n_tmp+1)*100 + (n_tmp+1)*10 + n_tmp+1
    if n2 >= n1:
        print(n2)
    else:
        print(n3)

Solution (Python):
import sys 

n = int(input())
ans = 111
if n <= 111:
  print(ans)
elif n <= 222:
  print(ans*2)
elif n <= 333:
  print(ans*3)
elif n <= 444:
  print(ans*4)
elif n <= 555:
  print(ans*5)
elif n <= 666:
  print(ans*6)
elif n <= 777:
  print(ans*7)
elif n <= 888:
  print(ans*8)
elif n <= 999:
  print(ans*9)

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

nn = n // 111
mod = n % 111
if mod > 0:
  nn = nn + 1
print(111 * nn)

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

if max(a, b, c) == a:
    ans = 100*a + 10*a + a
elif max(a, b, c) == b:
    a_ = a + 1
    ans = 100*a_ + 10*a_ + a_
else:
    if a > b:
        ans = 111 * a
    elif a == b:
        a_ = a + 1
        ans = 111 * a_
    else:
        a_ = a + 1
        ans = 100*a_ + 10*a_ + a_

print(ans)

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

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

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

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

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

Solution (Python):

N = int(input())

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

Solution (Python):
n = int(input())
result = n
for x in range(n, 1000):
	k = []
	for _ in range(3):
		k.append(x%10)
		x//=10
	if k[0]==k[1]==k[2]:
		result = k
		break
result = "".join(str(x) for x in result)
print(result)

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

while True:
    b = a % 10
    d = a //100
    c = (a-d*100)//10
    if d == c == b:
        break
    a += 1
print(a)

Solution (Python):
import numpy as np

n = int(input())

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

print(ans)

Solution (Python):
N = input()
big = max([int(x) for x in N[1:]])
if big > int(N[0]):
    ans = str(int(N[0])+1) * len(N)

else:
    ans = N[0] * len(N)

print(ans)

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

k = n // 100
if n - k * 100 <= k * 10 + k:
    ans = k * 100 + k * 10 + k
else:
    ans = (k+1) * 100 + (k+1) * 10 + (k+1)

print(ans)

Solution (Python):
s = raw_input()

num = int(s)

keta = num//100

if num <= keta*111:
    print keta * 111
elif num > keta*111:
    print (keta+1)*111

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

Solution (Python):



def main():
    N = raw_input()
    a = N[0] + N[0] + N[0]

    if N == a:
        print(N)
    elif int(N) > int(a):
        b = str(int(N[0]) + 1)
        b = b + b + b
        print(b)
    else:
        print(a)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

n = input()

if n[0] == '9':
	m = ''.join(['9']*len(n))
	if int(n) > int(m):
		print(''.join(['1']*(len(n)+1)))
		sys.exit()
	else:
		print(m)
		sys.exit()
else:
	s = n[0]
	m = ''.join([s]*len(n))
	if int(n) > int(m):
		print(''.join([str(int(s)+1)]*len(n)))
		sys.exit()
	else:
		print(m)
		sys.exit()

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

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

while(True):
  ans+=111
  if(ans>=N):
    print(ans)
    break

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

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

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

Solution (Python):


N = int(input())

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

for i in l:
	if N <= i:
		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 = int(input())

while(True):
    tho = N//1000
    hun = (N%1000)//100
    ten = (N%100)//10
    one = N%10
    if tho ==0:
        if hun ==ten and ten ==one:
            break
        else:
            N += 1
    else:
        if tho==hun and hun==ten and ten==one:
            break
        else:
            N += 1

print(N)

Solution (Python):


 
def main(nums):
	
	ref = nums[0]*len(nums)
	
	if int(ref) >= int(nums):
		return int(ref)
	else:
		ref2 = '1'*len(nums)
		
		return int(ref)+int(ref2)
	
nums = input()
print(main(nums))

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

if n[0] == n[1] and n[1] == n[2] and n[0] == n[2]:
    print(n)
elif n[0] == '9':
    print('999')
elif n[0] == n[1] and n[0] > n[2]:
    print(n[0]*3)
elif n[0] == n[1] and n[0] < n[2]:
    print(str(int(n[0])+1) * 3)
elif n[0] < n[1]:
    print(str(int(n[0])+1) * 3)
elif n[0] > n[1]:
    print(n[0]*3)

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):
N = int(input())
contests = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for x in contests:
    if N <= x:
        print(x)
        break

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

tmp = 111

for i in range(9):
    if n <= tmp:
        break
    tmp += 111

print(tmp)

Solution (Python):
n=input()
ans=""
an=""

for i in n:
    ans+=n[0]
    
if int(ans)>=int(n):
    print(ans)
else:
    for i in n:
        an+=str(int(n[0])+1)
    print(an)

Solution (Python):
def good(i):
    return len(set(str(i))) == 1

n = input()
for i in xrange(n, n + 1005):
    if good(i):
        print i
        break

Solution (Python):
n = input()
a = set(n)
b = ''
d = ''

if len(a) == 1:
    print(n)
else:
    for i in range(len(n)):
        b += n[0]
    if int(n) < int(b):
        print(b)
    else:
        for j in range(len(n)):
            c = int(n[0])+1
            d += str(c)
        print(d)

Solution (Python):

N = str(input())

hyaku = 0
flg = 0
for index, i in enumerate(N):
    if index == 0:
        hyaku = int(i)
    else:
        if hyaku >= int(i):
            pass
        else:
            flg = 1
            break
if flg:
    for _ in range(3):
        print(hyaku + 1, end='')
else:
    for _ in range(3):
        print(hyaku, end='')

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

Solution (Python):



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

    for i in range(100, 1000):
        if i % 111 == 0 and i >= n:
            print(i)
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
for i in range(n,1000):
    a=i//100
    b=(i-a*100)//10
    c=i-a*100-b*10
    if a==b==c:
        print('{}{}{}'.format(a,b,c))
        break

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

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

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

if N <= 11:
	answer = 11
elif N <= 22:
	answer = 22
elif N <= 33:
	answer = 33
elif N <= 44:
	answer = 44
elif N <= 55:
	answer = 55
elif N <= 66:
	answer = 66
elif N <= 77:
	answer = 77
elif N <= 88:
	answer = 88
elif N <= 99:
	answer = 99
elif N <= 111:
	answer = 111
elif N <= 222:
	answer = 222
elif N <= 333:
	answer = 333
elif N <= 444:
	answer = 444
elif N <= 555:
	answer = 555
elif N <= 666:
	answer = 666
elif N <= 777:
	answer = 777
elif N <= 888:
	answer = 888
elif N <= 999:
	answer = 999

print(answer)

Solution (Python):
N = str(input())
bench = int(N[0] * 3)
N = int(N)
if bench < N:
    bench = bench + 111



print(bench)
print()

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

isFalse = False
for i in range(1, len(n)):
    if n[i] > n[0]:
        isFalse = True

if isFalse:
    res = str(n[0] + 1)
else:
    res = str(n[0])

for i in range(len(n)):
    print(res, end='')

Solution (Python):
n = int(input())
li = [111,222,333,444,555,666,777,888,999]
for l in li:
    if l >= n:
        print(l)
        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):

S = int(input())
ans = [000, 111, 222, 333, 444, 555, 666, 777, 888, 999]

ans_ = 0
for a in ans:
    if a - S >= 0:
        ans_ = a
        break


if ans_ == 0:
    print("000")
else:
    print(str(ans_))

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

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

Solution (Python):
n=int(input())
count=0
while n>count:
    count=count+111
print(count)

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

Solution (Python):
N = int(input())
k = N // 111

if N % 111 == 0:
    pass
else:
    k += 1

print(k * 111)

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

suitable = [111,222,333,444,555,666,777,888,999]
for s in suitable:
    if n <= s:
        print(s)
        break

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

for x in range(9):
    if b[x]==a:
        print(b[x])
        break
    if b[x]>a:
        print(b[x])
        break

Solution (Python):

a = int(input())

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

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

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

for i in range(len(lis)):
    if n < 111:
        print(111)
        break
    elif lis[i] == n:
        print(lis[i])
        break
    elif lis[i] < n and lis[i+1] > n:
        print(lis[i+1])
        break

Solution (Python):
N = int(input())
nums = [num for num in range(111,1000,111)]
for i in range(1,999):
  if N in nums:
    print(N)
    exit()
  else:
    N+=1

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

ans = N

while ans < 999:
    if int(ans/100) == int((ans%100)/10) and int(ans/100) == int(ans%10):
        break
    ans += 1

print(ans)

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

n = int(N/100)
if n*111 >= N:
    print(n*111)
else:
    print((n+1)*111)

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

ans_list = [100*x+10*x+x for x in range(10)]

for v in ans_list:
    if v >= n:
        ans = v
        break
        
print(ans)

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

while(True):
  b = str(a)
  if b[0] == b[1] == b[2]:
    print(a)
    break
  else:
    a += 1

Solution (Python):
N = int(input())
amari = N % 111
shou = N // 111

ans = 0
if amari == 0:
  ans = N
else:
  ans = (shou+1)*111

print(ans)

Solution (Python):


n = int(input())

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

Solution (Python):


def main():
    N = input()
    Ns = []
    for n in N:
        Ns.append(int(n))
    Ns.sort()
    a = Ns[0]

    while True:
        num = a*100+a*10+a
        if num >= int(N):
            print(num)
            exit()
        a += 1


if __name__ == '__main__':
    main()

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

Solution (Python):
iN = int(input().rstrip())

iA = iN // 111
iB = iN % 111
if iB == 0 :
    print(iA * 111)
else:
    print((iA+1) * 111)

Solution (Python):



def main():
    aaa = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1111]
    n = int(input())

    for k in aaa:
        if n <= k:
            print(k)
            break


if __name__ == '__main__':
    main()

Solution (Python):
N=input()
for i in range(N,1000):
	x=i/100
	i%=100
	y=i/10
	z=i%10
	if x==y==z:
		print x*100+y*10+z
		quit()

Solution (Python):
def main():
    N = input()
    while not(N[0]==N[1]==N[2]):
        N = str(int(N) + 1)
    return N

if __name__ == "__main__":
    print(main())

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


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

Solution (Python):



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

Solution (Python):
N = int(raw_input().replace("\n", ""))

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

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

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