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=input()
M=0
if int(N[0])*111>=int(N):
    M=int(N[0])*111
else:
    M=(int(N[0])+1)*111
print(M)

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):
str_input = input()
num_list = list(str_input)
next_stage = 0

num1 = int(num_list[0])
num2 = int(num_list[1])
num3 = int(num_list[2])

def change_nums( num ):
    return num*100+num*10+num


if num1 > num2:
    next_stage = change_nums( num1 )
elif num1==num2==num3:
    next_stage = change_nums( num1 )
elif num1==num2 and num1 > num3:
    next_stage = change_nums( num1 )
else:
    next_stage = change_nums( num1+1 )

print(next_stage)

Solution (Python):
st=raw_input()
s=list(st)
if int(s[2])>int(s[1]):
  s[1]=str(int(s[1])+1)
  s[2]=s[1]
else:
  s[2]=s[1]
if int(s[1])>int(s[0]):
  s[0]=str(int(s[0])+1)
  s[1]=s[0]
  s[2]=s[1]
else:
  s[1]=s[0]
  s[2]=s[1]
unko=""
for i in s:
  unko+=i
print(unko)

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

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

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

Solution (Python):
n = input()
N = list(n)
if N[0] > 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])
    else:
        b = int(N[0]) + 1
        print(b * 111)
else:
    b = int(N[0]) + 1
    print(b * 111)

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

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

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

Solution (Python):

N=int(input() )

while(N<1000):
    if(N%111==0):
        print (N)
        break
    N+=1

Solution (Python):

n = int(input())
a = int(n/111.1)

print(int(111*(a+1)))

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

Solution (Python):
n = int(input())
cs = [1111, 999, 888, 777, 666, 555, 444, 333, 222, 111]
f = False
for i, c in enumerate(cs):
    if (c+1) <= n:
        print(cs[i-1])
        f = True
        break
if not f:
    print(cs[len(cs)-1])

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

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

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


H = N // 100
T = (N % 100) // 10
O = N % 10

if T > H:   H += 1
elif T == H and O > H:  H += 1

print(H*111)

Solution (Python):
n=int(input())
while True:
  d=[]
  n0=n
  while n0>0:
    d.append(n0%10)
    n0//=10
  if d[0]==d[1] and d[1]==d[2]:
    break
  n+=1
print(n)

Solution (Python):
x=int(input())
z=[111,222,333,444,555,666,777,888,999]
for i in range(9):
  if x==z[i]:
    print(z[i])
    break
  elif i==0 and x<z[i]:
    print(z[i])
    break
  elif i!=8 and z[i]<x<z[i+1]:
    print(z[i+1])
    break
  elif i==8 and x<z[i]:
    print(z[i])
    break

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

while not done:
    n = list(map(int,list(str(N))))
    if n[0] == n[1] and n[1] == n[2]:
        done = True
    else:
        N += 1

print(N)

Solution (Python):
N = input()

if int(N) <= int(''.join([N[0] for _ in range(3)])):
    print(int(''.join([N[0] for _ in range(3)])))
else:
    print(''.join(str(int(N[0]) + 1) for _ in range(3)))

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

Solution (Python):
n = raw_input()

if int(n) <= int(n[0]*3):
    print int(n[0]*3)
else:
    print (int(n[0])+1)*111

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

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

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

Solution (Python):




def solve(num):             
    c = num // 100          
    du = num - c * 100      
    if du <= c*11:          
        return c*111        
    else:
        return (c+1)*111    

if __name__ == "__main__":
    print (solve(int(input(""))))

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

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

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

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

Solution (Python):
import math as M
n=input()
list = list(map(int,n))
max = sorted(list)[len(n)-1]
if int(n[0])==max:
    print(str(max)*len(n))
else:
    print(str(int(n[0])+1) * len(n))

Solution (Python):
import re
import sys

n = int(input())

for i in range(n, 1000):
    if re.match('^([0-9])\\1+$', str(i)):
        print(i)
        sys.exit(0)

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((i-1)*111<N and N<=i*111):
        print(i*111)

Solution (Python):
n = input()

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

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

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

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

Solution (Python):
N = int(input())
for i in range(1, 10):
  if 100*i + 10*i + i >= N:
    print('{}{}{}'.format(i, i, i))
    break

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

if n[1]*10+n[2] > n[0]*11:
    print((n[0]+1)*111)
else:
    print(n[0]*111)

Solution (Python):
i = str(raw_input())
top = i[0]

if int(i[0])<int(i[1]):
	top = str(int(i[0])+1)
elif int(i[0])==int(i[1]):
	if int(i[1])<int(i[2]):
		top = str(int(i[0])+1)

print str(top)*3

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

if N[0] > N[1]:
	print(N[0] * 111)
elif N[0] == N[1]:
	if N[1] >= N[2]:
		print(N[0] * 111)
	else:
		print((N[0] + 1) * 111)

else:
	print((N[0] + 1) * 111)

Solution (Python):
N = int(input())
j = 1
while j <= 9:
  if N <= (100*j+10*j+j):
    N = 100*j+10*j+j
    break;
  j = j + 1
print(N)

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

for i in range(9):
    if N <= detect[i]:
        print(detect[i])
        exit()

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

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

Solution (Python):

ABC = 111
event_time = []
while 100 <= ABC <= 999:
    event_time.append(ABC)
    ABC += 111



N = int(input())
i = 0

for x in event_time:
    if N <= x:
        print(x)
        break

Solution (Python):
abcs = [111,222,333,444,555,666,777,888,999]
res = abcs[0]
i = int(input())

for abc in abcs:
  if i <= abc:
    res = abc
    break
print (res)

Solution (Python):
a_str = input()
a = int(a_str)
x, y, z = map(int, list(a_str))
if x*111==a:
    print(a)
elif x*111 > a:
    print(x*111)
else:
    print((x+1)*111)

Solution (Python):


n  = int( input())

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

Solution (Python):



def main():
    n = int(input())
    numlist = [111, 222, 333, 444, 555, 666, 777, 888, 999]
    for num in numlist:
        if num >= n:
            print(num)
            break


if __name__ == "__main__":
    main()

Solution (Python):

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

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

Solution (Python):
n=int(input())
c=n%10
b=int(((n-c)%100)/10)
a=int(((n-b-c)%1000)/100)
x=a*100+a*10+a
if b < a:pass
elif b==a and c<b:pass
elif a==b and b==c:pass
else:x+=111
print(x)

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

if(n[0] > n[1]):
    n[1] = n[0]
    n[2] = n[0]
elif(n[0] == n[1] and n[1] >= n[2]):
    n[2] = n[0]
elif(n[0] == n[1] and n[1] < n[2]):
    n[0] = n[0] + 1
    n[1] = n[0]
    n[2] = n[0]
elif(n[0] < n[1]):
    n[0] = n[0] + 1
    n[1] = n[0]
    n[2] = n[0]

print("{}{}{}".format(n[0],n[1],n[2]))

Solution (Python):


N = int(input())

for i in range(1000):
    n = N + i
    nums = []
    while n != 0:
        nums.append(n % 10)
        n //= 10

    f = True
    if all([n == nums[0] for n in nums]):
        print(N + i)
        break

Solution (Python):
k=int(input())
l=[]
p=[]
for i in range(1,10):
  l.append(111*i)
for i in l:
  if i-k>=0:
    p.append(i)
print(min(p))

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

Solution (Python):
def solve(n):
    for k in range(1, 10):
        x = k*111
        if x >= n:
            return x

assert solve(111) == 111
assert solve(112) == 222
assert solve(750) == 777
print solve(input())

Solution (Python):
import sys

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

for i in range(len(nl)):
    if(n == nl[i]):
        print(nl[i])
        sys.exit()
    elif(n < nl[i]):
        print(nl[i])
        sys.exit()
    else:
        continue

Solution (Python):


N = int(input())

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

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())
for i in range(100,1000):
    if len(set(str(i)))==1 and n<=i:
        print(i)
        exit()

Solution (Python):
import numpy as np
n=int(input())
a=str(n)
while(a[0]!=a[1] or a[1]!=a[2]):  
    n+=1
    a=str(n)

print(n)

Solution (Python):
x = int(input())
a = [111*i for i in range(1,10)]
print(x+min([abs(x-y) for y in a if x<=y]))

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

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

Solution (Python):

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

Solution (Python):
N=int(input())
while N%111!=0:
    N+=1
print(N)

Solution (Python):
n =int(input())
p_100 = n // 100
tmp = n % 100
p_10 = tmp // 10
p_1 = tmp % 10
if p_100 == p_10:
    if p_10 == p_1:
        print(str(p_1) * 3)
    elif p_10 <= p_1:
        print(str(p_10+1) * 3)
    elif p_10 >= p_1:
        print(str(p_10) * 3)
elif p_100 <= p_10:
    print(str(p_100+1) * 3)
elif p_100 >= p_10:
    print(str(p_100) * 3)

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

if 100 <= n and n <= 111:
    match = 111
elif 112 <= n and n <= 222:
    match = 222
elif 223 <= n and n <= 333:
    match = 333
elif 334 <= n and n <= 444:
    match = 444
elif 445 <= n and n <= 555:
    match = 555
elif 556 <= n and n <= 666:
    match = 666
elif 667 <= n and n <= 777:
    match = 777
elif 778 <= n and n <= 888:
    match = 888
elif 889 <= n and n <= 999:
    match = 999

print(match)

Solution (Python):
n = int(input())
n1 = n//100
n2 = n//10 - n1*10
n3 = n - n1*100 -n2*10

if n<=n1*111:
    print(n1*111)
    exit()
else:
    print((n1+1)*111)
    exit()

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

if S.count(S[0]) == len(S):
    print("".join(S))

else:
    if S[0] < S[1]:
        ans = str((int(S[0]) + 1)) * 3
    elif S[0] > S[1]:
        ans = S[0] * 3
    else:
        if S[0] < S[2]:
            ans = str(int(S[0]) + 1) * 3
        else:
            ans = S[0] * 3
            
    print(ans)

Solution (Python):


def main():
    s = raw_input().strip()
    retval = ""
    num = int(s[0])
    if int(s) <= num * 111:
        print num * 111
    else:
        print (num + 1) * 111

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

Solution (Python):



import sys  
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools



sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)


def local_input():
    from pcm.utils import set_stdin
    import sys
    if len(sys.argv) == 1:
        set_stdin(os.path.dirname(__file__) + '/test/' + 'sample-1.in')

def solve():
    N = int(input())
    for n in range(N, 1112):
        s = set()
        for c in str(n):
            s.add(c)
        if len(s)==1:
            print(n)
            return 0
    return 0

if __name__ == "__main__":
    try:
        local_input()
    except:
        pass
    solve()

Solution (Python):
n = int(raw_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 = input()
if int(N[0]) < int(N[1]):
    print((int(N[0])+1)*111)
elif int(N[0]) == int(N[1]) < int(N[2]):
    print((int(N[0])+1)*111)
else:
    print((int(N[0])*111))

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

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

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

for i in range(9):
    if x >= n:
        print(x)
        break
    else:
        x += 111

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

while True:

  temp = list(str(n))
  if temp.count(temp[0]) == len(temp):
    print(n)
    break
  
  n += 1

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

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

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

Solution (Python):

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

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

Solution (Python):



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

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


if __name__ == '__main__':
    main()

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

Solution (Python):

N = input()

ans = N[0]
for i in range(2):
    if N[i] != N[i+1]:
        if int(N[i]) < int(N[i+1]):
            ans = str(int(N[i]) + 1)
        break

for i in range(3):
    print(ans, end="")
print()

Solution (Python):
a = int(input())
while True:
    c = str(a)
    if c[0] == c[1] and c[1] == c[2]:
        print(a)
        break
    a += 1

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

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

print((a+1) * 111)

Solution (Python):
N = int(input())
while True:
    s = str(N)
    if s[0] == s[1] and s[1] == s[2]:
        print(N)
        break
    N += 1

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

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

Solution (Python):
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n=int(arr_data[0][0])

arr=[int(str(x)*3) for x in range(1,10)]

print(min(list(filter(lambda x : x >=n, arr))))

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

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


for _ in range(n, 1000):
    if len(set(list(str(n)))) == 1:
        print(n)
        exit()
    n += 1

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

n = N
for n in range(n, n+200):
    a = int(n / 100)
    b = int((n % 100) / 10)
    c = int(n % 10)
    if (a == b and b == c):
        print(str(a) * 3)
        break

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

Solution (Python):
n = input()
m = int(n[0] * len(n))
if int(n) > m:
    m = int(str(int(n[0])+1) * len(n))
print(m)

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

Solution (Python):
N = input()

x = int(N[0]) * 111
if int(N) <= x:
    print(x)
else:
    print(x + 111)

Solution (Python):
s=input()
a=s[0]
b=a*len(s)
if int(s)<=int(b):
    print(b)
else:
    if int(a)!=9:
        print(str(int(a)+1)*len(s))
    else:
        print('1'*(len(s)+1))

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

Solution (Python):
a = input()
a=[int(i) for i in a]
l=len(a)
m=max(a)
if a[0]==m:
    print(str(m)*l)
else:
    print(str(a[0]+1)*l)

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

Solution (Python):
N=int(input())
r,q=divmod(N,100)
if r*11 >= q:
    print(r*111)
else:
    print((r+1)*111)

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

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

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

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

print(ans)

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

Solution (Python):

x = raw_input()

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

Solution (Python):
n = input()

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

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

def isredigits(num):
    if len(set(list(str(num)))) is 1:
        return True

while not isredigits(n):
    n += 1

print(n)

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

for i in num:
    if i >= n:
        print(i)
        exit()

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

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

Solution (Python):
a=list(input())
A = B = C = ''
if a[0] == a[1] and a[0] == a[2] or a[0] >= a[2] and a[0] == a[1]:
    for _ in range(3):
        A += str(a[0])
    print(A)
else:
    if a[1] >= a[0] :
       a[0] = int(a[0]) + 1
       for i in range(3):
        B += str(a[0])
    
       print(B)

    else:
       for i in range(3):
        C += str(a[0])
    
       print(C)

Solution (Python):


n = int(input())

shou = int(n / 111)
amari = int(n % 111)

ans = shou
if amari != 0:
    ans = shou + 1

print(ans * 111)

Solution (Python):
n=input()
a=n[0]
if a+a+a >= n:
    print(a+a+a)
else:
    print(*[int(a)+1]*3,sep='')

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

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

print(ans)

Solution (Python):
N = input()
stra = N[0]
strb = N[1]
strc = N[2]
a = int(stra)
b = int(strb)
c = int(strc)
if a > b:
    print(3 * stra)
elif a < b:
    print(3 * str((a + 1)))
else:
    if b >= c:
        print(3*strb)
    else:
        print(3* str(a + 1))

Solution (Python):
N = input()

n1 = int(N[0])
n2 = int(N[1])
n3 = int(N[2])

if n1 >= n2 and n1 >= n3:
    n1String = str(n1)
    print(n1String * 3)
else:
    n1StringPlus = str(n1+1)
    print(n1StringPlus * 3)

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

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

list_map  = list(map(int, listed_N))
 
if list_map[0]<list_map[1]:
    print("{}{}{}".format(list_map[0]+1,list_map[0]+1,list_map[0]+1))
elif list_map[0] == list_map[1]:
    if list_map[1]<list_map[2]:
        print("{}{}{}".format(list_map[0]+1,list_map[0]+1,list_map[0]+1))
    else:
        print("{}{}{}".format(list_map[0],list_map[0],list_map[0]))
else:
    print("{}{}{}".format(list_map[0],list_map[0],list_map[0]))

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

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

for num in list:
    if (n <= num):
        print(num)
        break

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

handret = n // 100
number = handret * 100 + handret * 10 + handret

if number < n:
    handret += 1
    number = handret * 100 + handret * 10 + handret

print(number)

Solution (Python):
n = list(input())
ori = ''.join(map(str, n))
n = set(n)

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

Solution (Python):
n = str(input())
minim = 1000
x = int(n)
for i in range(1, 10):
    nr = i*100 + i*10 + i
    if x <= int(nr) < minim:
        minim = int(nr)
print(minim)

Solution (Python):
n = int(input())
if n%111 == 0:
    check = True
else:
    check = False

while check == False:
    n += 1
    if n%111 == 0:
        check = True
    
print(n)

Solution (Python):
import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline().rstrip())]+[0]
print(str(a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*(len(a)-1))

Solution (Python):
import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline()[:3])]+[0]
print((a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*111)

Solution (Python):
import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline()[0:3])]+[-1]
print(str(a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*3)

Solution (Python):
print((10 -[1 if i%111==0 else 0 for i in range(1001)][int(input()):1001].count(1)) *111)

Solution (Python):
import math

N = int(input())

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

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

Solution (Python):
import sys

input = sys.stdin.readline
n = int(input())
if n%111 == 0:
    print(n)
else:
    print(111*(int(n/111)+1))

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

ans = n
s = str(n)

flag = s[0] == s[1] and s[1] == s[2]

while not flag:
    n+=1
    s=str(n)
    flag = s[0] == s[1] and s[1] == s[2]

print(s)

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

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

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

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

Solution (Python):
n = int(input())
ans = 0
for i in range(10):
    if ans >= n:
        break
    ans+=111

print(ans)

Solution (Python):
import sys


def solve(n):
    a = []
    b = str(n)
    a.append(b)
    for i in a:
        c = i
    d = c[0]
    e = int(d)*100 + int(d)*10 + int(d)
    if e >= n:
        return e
    else:
        return int(e)+111


def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

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

c=N%10
N//=10
b=N%10
N//=10
a=N%10

d=1
if((a==b and b>=c )or a>b):
    a=a-1
a=a+1
d=a*100+a*10+a
print(d)

Solution (Python):
s = int(input())
while(True):
    ss = str(s)
    if(max(ss) == min(ss)):
        print(s)
        break
    s += 1

Solution (Python):
n=list(input())
temp=""
temp=temp.join(map(str,n))
temp=int(temp)
if n[0]==n[1]==n[2]:
    temp=""
    temp=temp.join(map(str,n))
    temp=int(temp)
    print(temp)
else:
    a=n[0]*3
    a=int(a)
    b=(str(int(n[0])+1))*3
    b=int(b)
    if a<temp:
        print(b)
    else:
        print(a)

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

a = int(n / 100)

zoro = (100 * a) + (10 * a) + a

if(n <= zoro):
    print(zoro)
else:
    a = a + 1
    zoro = (100 * a) + (10 * a) + a
    print(zoro)

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

S = (((N-1)//111)+1)*111

print(S)

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

Solution (Python):
n = int(input())
if n % 111 > 0:
    n = int((n - int(n / 100) * 11 + 100) / 100) * 111
print(n)

Solution (Python):


nextContest = int(input())

for i in range(nextContest, 1000):
    dig1 = int(i / 100)
    dig2 = int((i % 100) / 10)
    dig3 = int((i % 100) % 10)
    if dig1 == dig2 and dig2 == dig3:
        print (str(i))
        break

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

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

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

if a > b:
  print("{0}{0}{0}".format(a))
elif a==b and b>=c:
  print("{0}{0}{0}".format(a))
else:
  print("{0}{0}{0}".format(a+1))

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

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

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:
    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 == 0:
    x = n
else:
    x = ((n // 111) + 1) * 111
print(x)

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

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

canditates = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in range(len(canditates) - 1):
    if n < 111:
        print(111)
        exit()
    elif canditates[i] == n:
        print(n)
        exit()
    elif canditates[i] < n <= canditates[i + 1]:
        print(canditates[i + 1])
        exit()

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

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

Solution (Python):
N = int(input())
print(-N%111 + N)

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

i = 0

while N > 0:
    N -= 111
    i += 1

print(111*i)

Solution (Python):
import sys
import math
 
N = sys.stdin.readline().strip()
N = int(N)
 
M = math.ceil(N / 111.0)
M = int(M * 111)

print(M)

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

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

Solution (Python):
N = int(input())
for n in range(N, N + 1000):
    if len(set(list(str(n)))) == 1:
        print(n)
        exit()

Solution (Python):
N = int(input())
boolean = False
while True:
  isAccept =True
  N_str = list(map(int, str(N)))
  first = N_str.pop()
  for n in N_str:
    if n != first:
      N += 1
      isAccept = False
      break
  if isAccept:
    break
print(N)

Solution (Python):



a = int(raw_input())

a0 = a
a1 = a/100 
a = a%100
a2 = a/10  
a = a%10
a3 = a     

if a1*111 >= a0:
    print a1*111
else:
    print (a1+1)*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())
ans = 0

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

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

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