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

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

Solution (Python):
N = input()
f_num = int(N[0])
f = 100*f_num+10*f_num + f_num
if f >= int(N):
    print(f)
else:
    print(100*(1+f_num)+10*(1+f_num)+(1+f_num))

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

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

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

for i in range(9):
    if n <= li[i]:
        print(li[i])
        break

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

if str(n)[0]==str(n)[1]==str(n)[2]:
    print(n)

else:
    for _ in range(1000):
        n += 1
        if str(n)[0]==str(n)[1]==str(n)[2]:
            break

    print(n)

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

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

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

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

print(ans)

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

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

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

ans = 0

if N <= 111:
    ans = 111

for i in range(len(abc)-1):
    if abc[i] < N <= abc[i+1]:
        ans = abc[i+1]
        break

print(ans)

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

Solution (Python):
N = input()
num = int(N[0])*100+int(N[0])*10+int(N[0])
if(int(N)-num<=0):
	print(num)
else:
	print(int(num/int(N[0]))*(int(N[0])+1))

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

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):
    ans = int(str(i)*3)
    if n <= ans:
        print(ans)
        break

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

for i in range(111,1000,111):
  if N//i == 1:
    if N%111 == 0:
      ans = i
    else:
      ans = i + 111
print(ans)

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

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

Solution (Python):
n=int(input())
a_list=[str(i)*3 for i in range(1,10)]
flag=False

for i in range(0,9):
  if int(a_list[i])==n:
    print(a_list[i])
    flag=True
    break
  elif n < 111:
    print("111")
    break
if flag==False:
  for i in range(0,8):
    if int(a_list[i])< n < int(a_list[i+1]):
      print(a_list[i+1])
      break

Solution (Python):
import math

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

Solution (Python):
from bisect import bisect_left as bl
n=int(input())
A=[111,222,333,444,555,666,777,888,999]
x=bl(A,n)
print(A[x])

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

m = n // 100
d = int(str(m) * 3)
if n <= d:
    print(d)
else:
    print(d + 111)

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

print(ans)

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

for i in range(N, 1000):
	tmp = str(i)
	candidate = tmp[0]
	flag = True
	for j in tmp:
		if j != tmp[0]:
			flag = False
			break
	if flag:
		print(int(tmp))
		exit()

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

while len(set(str(N))) != 1:
    N += 1

print(N)

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

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

print(n)

Solution (Python):
n=int(input())
c=111
while True:
    if n<=c:
        print(c)
        break
    c+=111

Solution (Python):
n = list(input())
n[0] = int(n[0])
n[1] = int(n[1])
n[2] = int(n[2])
while (not (n[0] == n[1] == n[2])):
    if n[2] == 10:
        n[2] = 0
        n[1] = int(n[1])+1
    if n[1] == 10:
        n[1] = 0
        n[0] = int(n[0])+1
    n[2] = int(n[2]) + 1
print(n[0]*100+n[1]*10+n[2])

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

for i in range(999):
    x = str(n)
    if x[0] == x[1] == x[2]:
        print(n)
        break
    n += 1

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

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
ans = [111,222,333,444,555,666,777,888,999]
for i in ans:
    if i >= N:
        print(i)
        sys.exit()

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

Solution (Python):
N=[i for i in input()]
if len(set(N))==1:
    print(''.join(N))
else:
    s=int(N[0]*2)
    t=int(N[1]+N[2])
    
    if t<s:
        print(N[0]*3)
    else:
        print(str(int(N[0])+1)*3)

Solution (Python):

n = int(input())

idx = [111*i for i in range(1,9+1)]
idx = [i for i in idx if i>=n]

print(idx[0])

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

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

Solution (Python):

N = int(input())

while True:
    s = list(str(N))
    if s[0] != s[1] or s[1] != s[2]:
        N += 1
    elif s[0] == s[1] and s[1] == s[2]:
        break
print(N)

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

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

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

Solution (Python):
a=int(input())
b=[0]
for i in range(10):
  if a>111*i:
    b.append(111*(i+1))
print(max(b))

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

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

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

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

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

for i in range(999):
    x = str(n)
    if x[0] == x[1] == x[2]:
        print(n)
        break
    n += 1

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

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

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

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

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

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

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

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

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

for i in range(111):
	if n % 111 == 0:
		print(n)
		break
	else:
		n = n + 1

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

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

Solution (Python):


N=int(input())
ns=N//100*100+N//100*10+N//100
print("".join([str(N//100+int(N>ns))]*3))

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
A = int(input())
B = int(A / 111)
C = A % 111 == 0
if not C:
  B = (B+1) * 111
  print(B)
else:
  B = B*111
  print(B)

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

list_aaa = [111,222,333,444,555,666,777,888,999]
cnt =0

for i in range(len(list_aaa)):
    if N > list_aaa[i]:
        cnt +=1

if cnt ==0:
    print(111)
else:
    print(list_aaa[cnt])

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

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

Solution (Python):
N = input()
input_num = int(N)
N_list = list(N)

first_num = N_list[0]

number = first_num * 3

if input_num <= int(number):
  print(number)
else:
  first_num = int(first_num) + 1
  number = str(first_num) * 3
  print(number)

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

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

ans = N
for i in range(200):
  if str(ans)[0] == str(ans)[1] and str(ans)[0] == str(ans)[2]:
    print(ans)
    break
  else:
    ans += 1

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

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

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

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

for i in range(9):
    if list1[i] >= n:
        print(list1[i])
        exit()

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

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

Solution (Python):
N = list(input())
if N[0] == N[1] == N[2]:
    print("".join(N))
else:
    num_N = int("".join(N))
    if num_N < int(N[0] * 3):
        print(N[0] * 3)
    else:
        for _ in range(3):
            print(int(N[0]) + 1,end = "")

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

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

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

Solution (Python):
N = int(input())
for i in range(N, 1000):
    if N == 111 or N == 222 or N == 333 or N == 444 or N == 555 or N == 666 or N == 777 or N == 888 or N == 999:
        break
    N += 1
print(N)

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

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

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

Solution (Python):

n = int(input())
i = n // 111

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

print(i * 111)

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

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

Solution (Python):


n = int(input())
num = n // 111

if n % 111 != 0:
    num += 1
print(111*num)

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

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

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

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

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

Solution (Python):
import bisect
x=int(input())
a=[i*111 for i in range(1,10)]
print(a[bisect.bisect_left(a,x)])

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

Solution (Python):
N = int(input())
N_list = list(str(N))

for i in range(999):
  if N_list[0] == N_list[1] == N_list[2]:
    print(int(N_list[0] + N_list[1] + N_list[2]))
    break
  else:
    N += 1
    N_list = list(str(N))

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

Solution (Python):

import sys










def main():
    n = int(sys.stdin.readline().rstrip())
    for i in range(1, 10):
        nex = int(str(i) * 3)
        if nex >= n:
            ans = nex
            break
    
    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):
from sys import stdin
s = stdin.readline().rstrip()

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

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

def main():
    n=int(input())
    while True:
        if len(set(str(n)))==1:
            print(n)
            return
        n+=1

main()

Solution (Python):

import numpy as np
N = int(input())
l = np.array([111, 222, 333, 444, 555, 666, 777, 888, 999])
ind = sum(l < N)
print(l[ind])

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

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

Solution (Python):
n = int(input())
while not all(i==str(n)[0] for i in str(n)):
    n += 1
print(n)

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

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

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

Solution (Python):
n = int(input())
lis = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in range(9):
    if n > lis[i]:
        continue
    else:
        print(lis[i])
        break

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

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

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

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

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

Solution (Python):
N = int(input())
count = 0
m = 1

while count == 0:
    x = 100 * m + 10 * m + m
    if N <= x:
        print(str(x))
        count += 1
    else:
        m += 1

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

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

Solution (Python):
N = list(map(int,input()))
target = ''.join(map(str,N))
if N[0]*111 < int(target):
	print((N[0]+1)*111)
else:
	print(N[0]*111)

Solution (Python):
N = list(map(int,input()))
target = ''.join(map(str,N))

if N[0]*111 < int(target):
	print((N[0]+1)*111)
else:
	print(N[0]*111)

Solution (Python):

n = int(input())

i = int(n / 111)


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

print(i * 111)

Solution (Python):
n = input()
one = list(n)[0]
base = int(one) * 111
if int(n) > base:
  print(base+111)
else:
  print(base)

Solution (Python):
N = int(input())
ABC_list = [111,222,333,444,555,666,777,888,999]
gap = dict()
for i in ABC_list:
	if i - N >= 0:
		gap[i] = abs(i-N)
print(min(gap))

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

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

for comp in range(111,1000,111):
  if i <= comp:
    print(comp)
    break

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

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

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

Solution (Python):
N=int(input())
x=111
while True:
  if N<=x:
    print(x)
    break
  else:
    x+=111

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

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

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

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

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

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

import bisect
b = bisect.bisect_left(w, n)
print(w[b])

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

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

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

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

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

Solution (Python):


N = int(input().split()[0])
s = list(str(N))

if N <= int(s[0] * len(s)):
    ans = s[0] * len(s)
else:
    ans = str(int(s[0]) + 1) * len(s)

print(ans)

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

Solution (Python):
x = int(input())
sam = [j*100+j*10+j for j in range(1,10)]

for k in range(len(sam)):
  if x>sam[k] and x<sam[k+1]:
    print(sam[k+1])
    break
  elif x==sam[k]:
    print(sam[k])
    break
  elif x<sam[0]:
    print(sam[0])
    break

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

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

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

Solution (Python):
n = int(input())
m1 = int(str(n//100)*3)
print(m1 if n<=m1 else str((n+100)//100)*3)

Solution (Python):
n = int(input())
m1 = int(str(n//100)*3)
m2 = str((n+100)//100)*3
print(m1 if n<=m1 else m2)

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

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

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

Solution (Python):
import math


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

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

Solution (Python):
n = input()
m = str(int(n[0]) + 1)

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

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

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

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

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

Solution (Python):

N = int(input())





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

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

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

Solution (Python):
N = int(input())
x = 111
while N > x:
    x += 111
print(x)

Solution (Python):
nums = [c for c in input()]
n = int(nums[0])
if nums[0] == nums[1]:
    if nums[2] <= nums[1]:
        print ('%d%d%d' % (n, n, n))
    else:
        print ('%d%d%d' % (n+1, n+1, n+1))
elif nums[0] > nums[1]:
    print ('%d%d%d' % (n, n, n))
else:
    print ('%d%d%d' % (n+1, n+1, n+1))

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

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

Solution (Python):
import bisect

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

print(tmp[bisect.bisect_left(tmp,N)])

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    for i in range(n, 10 ** 10):
        s = str(i)
        b = True
        for j in range(1, len(s)):
            if s[j] != s[j-1]:
                b = False
                break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    slove()

Solution (Python):
def main():
    N = input()
    hun = N[0]
    hikaku = int(hun + hun + hun)
    N = int(N)
    if(hikaku >= N):
        print(hun + hun + hun)
        return 
    
    new_hun = str(int(hun) +1)
    print(new_hun + new_hun + new_hun)

if __name__ == "__main__":
    main()

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

Solution (Python):
N = int(input())
while len(set([s for s in str(N)])) != 1:
  N+=1
print(N)

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

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

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

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

Solution (Python):

N = open(0).read()
same_nums = int(N[0]*3)
print( same_nums if int(N) <= same_nums else same_nums+111)

Solution (Python):
n = int(input())
while n <= 999:
    if n % 111 == 0:
        print(n)
        break
    else:
        n += 1

Solution (Python):
a,b,c=[int(i) for i in input()]
print(a*111 if a>=b and a>=c else (a+1)*111)

Solution (Python):
a,b,c=[int(i) for i in input()]
print(a*111 if a>=b and a>=c else (a+1)*111)

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

Solution (Python):
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()

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

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

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

Solution (Python):
a = input()
if len(set(a)) == 1:
  print(a)
  exit()
else:
  print(((int(a)//111)+1)*111)

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    for i in range(N, 1000):
        if len(set(list(str(i))))==1:
            print(i)
            return


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    for i in range(n, 1000):
        b = True
        s = str(i)
        t = ""
        for j in range(len(s)):
            if t == "":
                t = s[j]
            else:
                if t != s[j]:
                    b = False
                    break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    slove()

Solution (Python):

import bisect
l=[111,222,333,444,555,666,777,888,999,1111]
n=int(input())
print(l[bisect.bisect_left(l,n)])

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

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

for i in A:
    if N==i:
        print(i)
        break
    elif N > i:
        continue
    elif N <= i:
        print(i)
        break

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    n = input().strip()
    if len(set(n)) == 1:
        print(n)
    elif int(n) < int(n[0] * 3):
        print(int(n[0] * 3))
    else:
        print(str(int(n[0]) + 1) * 3)


if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):


n = int(input())

suitable = n
shouldGetOut = False
for i in range(n, 1000):
    if len(set(list(str(i)))) == 1:
        suitable = i
        shouldGetOut = True
    if shouldGetOut == True:
        break
print(suitable)

Solution (Python):
a,b,c = list(map(int, list(str(input()))))
if not (b <= a and c <= a):
    if (b > a) or (b == a and c > a):
        a += 1
b = a; c = a

ans = list(map(str, [a,b,c]))
print("".join(ans))

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

Solution (Python):
N = int(input())
res = 0
while N > res:
  res += 111
print(res)

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

z = []
for i in range(1, 10):
    z.append(i * 100 + i * 10 + i)

for zi in z:
    if zi >= n:
        print(zi)
        exit()

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

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

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

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

Solution (Python):
n = input()

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

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

Solution (Python):
n = list(map(int, list(input())))
v1 = n[0] * 100 + n[1] * 10 + n[2] * 1
v2 = n[0] * 100 + n[0] * 10 + n[0] * 1
if v1 > v2:
    n[0] += 1
s = str(n[0])
print(''.join([s, s, s]))

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

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

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

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

cand_list = [100*i+10*i+i for i in range(1, 10)]
target_list = list(filter(lambda x:x>=n, cand_list))
print(min(target_list))

Solution (Python):
import sys

L = [111, 222, 333, 444, 555, 666, 777, 888, 999]
N = int(input())
for Li in L:
    if Li >= N:
        print(Li)
        sys.exit()

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

n_100 = n//100
n_10 = (n - n_100 *100) // 10 
n_1 = n - n_100*100 - n_10*10

m = n_100 * 111

if m >= n:
  print(m)
else:
  print((n_100 +1) * 111)

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

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

Solution (Python):
a,b,c=input()
if max(int(a),int(b),int(c)) == int(a):
    print(int(a+a+a))
else:
    print(int(a+a+a) + 111)

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

for i in range(N, 1000):
    digit1 = i % 10
    digit2 = i // 10 % 10
    digit3 = i // 100
    if digit1 == digit2 == digit3:
        print(i)
        break

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

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

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

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

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    for n in range(N, 1000):
        flag = True
        num = n
        d = n%10
        n = n//10
        while n != 0:
            if d == n%10:
                n = n//10
            else:
                flag = False
                break
        if flag:
            break
    print(num)