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



Sample input:
111


Sample output:
111

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a,b=divmod(n,111)
if b==0:
  print(a*111)
else:
  print((a+1)*111)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input().strip())
for i in range(10):
  if N <= 111*i:
    print(111*i)
    break

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int):
    for i in range(N, 1000):
        if len(set(str(i))) == 1:
            return i


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N = int(input())
A = N//100

print((A*111) if N <= A*111 else (A+1)*111)

Submission status: Accepted

Solution code:
N = int(input())
i = 1
while i*111<N:
    i += 1
print(i*111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
N = input()
a = int(N[0])
X = a*100+a*10+a
if int(N) <= X:
    print(X)
else:
    print(X+111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
N_list=list(N)
triple=[N[0],N[0],N[0]]
triple_one=[str(int(N[0])+1),str(int(N[0])+1),str(int(N[0])+1)]
num=int("".join(triple))
num_one=int("".join(triple_one))
N_int=int(N)
if N_int > num and N_int < num_one:
    ans = num_one
elif N_int <= num:
    ans= num

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = list(map(int,input()))
if N[0] > N[1] or (N[0] == N[1] and N[1] >= N[2]):
    print(N[0]*100+N[0]*10+N[0])
else:
    print((N[0]+1)*100+(N[0]+1)*10+(N[0]+1))

Submission status: Accepted

Solution code:
N = int(input())
ceil = 1000

for num in range(N, ceil):
    num = str(num)
    if num[0] == num[1] and num[0] == num[2]:
        print(int(num))
        break
    else:
        pass

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(9):
  j = i+1
  a = 100*j + 10*j + j
  if n <= a:
    ans = a
    break
  if n > a:
    k = j+1
    b = 100*k + 10*k + k
    if n < b:
      ans = b
      break
print(ans)

Submission status: Accepted

Solution code:
N = input()

p = ''
Flag = False
for s in N:
    if p == '':
        p = s
        continue
    else:
        if p == s:
            continue
        else:
            if int(p) > int(s):
                print(p * len(N))
                Flag = True
                break
            else:
                pref = str(int(p) + 1)
                print(pref * len(N))
                Flag = True
                break
if not Flag:            
    print(N)

Submission status: Accepted

Solution code:
def is_same(n):
    s = str(n)

    num = s[0]
    for x in s:
        if num != x:
            return False
    return True

N = int(input())

while True:
    if is_same(N):
        break
    N = N + 1

print(N)

Submission status: Accepted

Solution code:
a = int(input())

for i in range(10):
	if a<=i*111:
		print(i*111)
		break

Submission status: Accepted

Solution code:
N = int(input())
ABC = [111, 222, 333, 444, 555, 666, 777, 888, 999]
minimum = 10**9
answer = N
for i in ABC:
  sub = i-N
  if sub >= 0 and minimum > sub:
    minimum = sub
    answer = i
print(answer)

Submission status: Accepted

Solution code:
N = input()

for s in "123456789":
	if int(N) <= int(s * 3):
		print(s * 3)
		break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

a=n//100
b=(n-a*100)//10
c=n-a*100-b*10

if a==b:
    if a<c:
        print((a+1)*100+(a+1)*10+a+1)
    elif c<a:
        print(a*100+a*10+a)
    elif a==c:
        print(n)
elif a<b:
    print((a+1)*100+(a+1)*10+a+1)
elif a>b:
    print(a*100+a*10+a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def main():
    a = int(input())
    for i in range(a, 1000):
        a1, a2, a3 = list(str(i))
        if a1 == a2 == a3:
            print(i)
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC111B - AtCoder Beginner Contest 111
from math import ceil
n = int(input())

print(ceil(n / 111) * 111)

Submission status: Accepted

Solution code:
N = input()
n = int(N[0])*100 + int(N[0])*10+int(N[0])*1
if int(N) - n <= 0:
    print(n)
else:
    print(n + 111)

Submission status: Accepted

Solution code:
import sys
N = int(input())

for n in range (N,1000):
    str_n = str(n)
    if str_n[0] == str_n[1] == str_n[2]:
        print(n)
        sys.exit()

Submission status: Accepted

Solution code:
N=int(input())
for i in range(900):
  if (N+i)%111==0:
    print(N+i)
    exit()

Submission status: Accepted

Solution code:
# ABC111B
from math import ceil

num = int(input())
print(ceil(num / 111) * 111)

Submission status: Accepted

Solution code:
# ABC111B
from math import ceil

print(ceil(int(input()) / 111) * 111)

Submission status: Accepted

Solution code:
# ABC111B
from math import ceil

num = int(input())
i = ceil(num / 111)
print(i * 111)

Submission status: Accepted

Solution code:
s=input()
print(str(int(s[0])+1)*3 if s[0]*3<s else s[0]*3)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    ret = ''
    for i in range(N, 1000):
        s = str(i)
        if s[0] == s[1] and s[1] == s[2]:
            ret = s
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 10):
        n = int(str(i)*3)
        if N <= n:
            break
    else:
        print("1111")
        return
    print(n)

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, = (int(x) for x in input().split())

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

print(iii)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = int(input())

a, b = divmod(n, 111)

if b == 0:
    print(111*a)
else:
    print(111*(a+1))

Submission status: Accepted

Solution code:
n = int(input())

for i in range(111,889,111):
  if n <= i:
    print(i)
    break
else: print(999)

Submission status: Accepted

Solution code:
#111 B
N =int(input())

for i in range(N,99999):
    if len(set(list(str(i))))==1:
           print(i)
           exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input();s=n[0]*3;print([n,[s,str(int(n[0])+1)*3][int(s)<int(n)]][int(n)%111>0])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = int(input())

a, b = divmod(n, 111)

if b == 0:
    print(111*a)
else:
    print(111*(a+1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
if n%111==0:
  print(n)
else:
  import math
  print(111*math.ceil(n/111))

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
#N = list(map(int, input()))
N = int(input())

list = [111,222,333,444,555,666,777,888,999, 1000000]
ans = 0
for l in list:
  if N > l:
    continue
  else:
    ans =l
    break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
num = 111

while num <= 999:
    if n <= num:
        print(num)
        break
    else:
        num += 111

Submission status: Accepted

Solution code:
n = int(input())
x = n
while True:
    flag = False
    first_s = str(x)[0]
    if all(s == first_s for s in str(x)):
        print(x)
        exit()
    x += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
from bisect import bisect_left

def main():
	N = int(input())
	
	for i in range(N, 1000):
		tmp = i % 10
		ans = ""
		tugi = 0
		isOK = True
		for j in range(len(str(i))):
			if j == 0:
				tugi = i
			tmp2 = tugi % 10
			tugi = tugi // 10
			ans += str(tmp)
			if tmp != tmp2:
				isOK = False
				break
		if isOK == True:
			print(ans)
			sys.exit()
		
	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
digit_3 = int(N[2])
N = int(N)
nums = [111,222,333,444,555,666,777,888,999]
for num in nums[::-1]:
    temp = num - N
    if temp < 111:
        print(num)
        break

Submission status: Accepted

Solution code:
n = int(input())
num = [111, 222, 333, 444, 555, 666, 777, 888, 999]
min_ = 111
ans = 0
for i in num:
  if i-n<0:
    None
  else:
    if min_ > i-n:
      ans = i
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N = int(raw_input())
ans = (N / 111 + 1) * 111
if N % 111 == 0: ans -= 111
print ans

Submission status: Accepted

Solution code:
N = int(input())

rev1 = (N//100) * 100 + (N//100) * 10 + (N//100)
rev2 = (N//100 +1) * 100 + (N//100+1) * 10 + (N//100+1)

if N <= rev1 <= rev2:
  print(rev1)
else:
  print(rev2)

Submission status: Accepted

Solution code:
N = int(input())

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

for c in candidate:
    if N <= c:
        print(c)
        break

Submission status: Accepted

Solution code:
N = input()
n = [int(i) for i in N]
N = int(N)
a = n[0]
b = len(n)
c = 0

for i in range(b):
    c += a*10**i

if N <= c:
    print(c)
else:
    c = [str(int(i)+1) for i in str(c)]
    print(''.join(c))

Submission status: Accepted

Solution code:
n=input()
m=n[0]
for i in range(len(n)-1):
  m+=n[0]
if int(n)>int(m):
  if n[0]!=str(9):
    a=str(int(n[0])+1)
    for j in range(len(n)-1):
      a+=str(int(n[0])+1)
    print(a)
  else:
    b=str(1)
    for k in range(len(n)):
      b+=str(1)
    print(b)
else:
  print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
x = [i*100 +i* 10+i for i in range(1, 10)]
for i in x:
  if i >= N:
    print(i)
    break

Submission status: Accepted

Solution code:
N = int(input())
list = [111 * i for i in range(1,10)]
num = 0

for i in list:
    if N <= i:
        num = i
        break

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

x = n // 100

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
X = int(input())

if 100 <= X <= 111:
  n = 111
elif X <= 222:
  n = 222
elif X <= 333:
  n = 333
elif X <= 444:
  n = 444
elif X <= 555:
  n = 555
elif X <= 666:
  n = 666
elif X <= 777:
  n = 777
elif X <= 888:
  n = 888
elif X <= 999:
  n = 999
else:
  print("error")

print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in abc:
    if n <= i:
        ans = i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
N = input()
x = N[0]
if int(N) > int(x * 3):
  x = str(int(x) + 1)
print(x * 3)

Submission status: Accepted

Solution code:
N = int(input())
i = 1
while True:
    if 111 * i >= N:
        print(111 * i)
        break
    else:
        i += 1

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
q,m=divmod(int(input()),111);print((q+1*(m>0))*111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def main():
    base = 111
    ans = base
    while ans < N:
        ans = ans + base
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
x=[111*i for i in range(1,10)]
for i in x:
  if i>=n:
    print(i)
    break

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    flag = True
    i = N
    while flag:
        if str(i)[0] == str(i)[1] and str(i)[1] == str(i)[2]:
            print(i)
            flag = False
        i += 1


main()

Submission status: Accepted

Solution code:
N = int(input())

ans = (N+111-1)/111
ans = int(ans)
ans *= 111

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
s = ''
def ans(N):
    for ctr in range(N,1000):
        s = str(ctr)
        if s[0]==s[1] and s[1]==s[2]:
            return(ctr)
print(ans(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = S()
    for i in n:
        if i == "1":
            print(9,end = "")
        else:
            print(1,end = "")
    print()
#B
def B():
    n = I()
    for i in range(n,1000):
        if i%111 == 0:
            print(i)
            quit()
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
X=P=0
for i in range(10) :
  P=i*111
  if X < N and N <= P :
    print(P)
  X=P

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N, 1000):
    xs = set()
    n = i
    while n > 0:
        xs.add(n % 10)
        n //= 10
    if len(xs) == 1:
        ans = i
        break

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = list(input())
kouho1 = n[0] * len(n)
kouho2 = str(int(n[0]) + 1) * len(n)

m = "".join(n)

if int(kouho1) >= int(m):
    print(kouho1)
else:
    print(kouho2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def main():
    for n in range(N, 1000):
        if len(set(str(n))) == 1:
            return n

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

Submission status: Accepted

Solution code:
n = int(input())
print(str((n - 1) // 111 + 1) * 3)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(input())

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

Submission status: Accepted

Solution code:
#coding: utf-8
N = int(input())
l = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in range(len(l)):
    if N <= l[i]:
        print(l[i])
        break

Submission status: Accepted

Solution code:
N=int(input())
ans = 1000
for i in range(1,10):
    if ((i*100+i*10+i)-N)>=0:
        ans = min(ans, i*100+i*10+i)
print(ans)

Submission status: Accepted

Solution code:
N = str(input())
m0 = int(N[0])
m1 = int(N[0]) + 1
M0 = 100*m0 + 10*m0 + m0
M1 = 100*m1 + 10*m1 + m1
if int(N[1])<=int(N[0]) and int(N[2])<=int(N[0]):
    print(M0)
else:
    print(M1)

Submission status: Accepted

Solution code:
N = int(input())
a = [str(i)*3 for i in range(1,10)]
print(a[(N-1)//111])

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1000):
    if n + i == 111 or n + i == 222 or n + i == 333 or n + i == 444 or n + i == 555 or n + i == 666 or n + i == 777 or n + i == 888 or n + i == 999:
        print(n+i)
        exit()

Submission status: Accepted

Solution code:
n = input()

for i in range(10):
    if int(str(i)*3) >= int(n):
        print(str(i)*3)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
T=int(input())
TT=T//100
if T<=TT*111:
  print(TT*111)
else:
  print((TT+1)*111)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
strN = list(str(N))
a = int(strN[0]*3)
if N > a:
    ans = str(int(strN[0])+1)*3
else:
    ans = a

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

n=int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
print(str((int(input())-1)//111+1)*3)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
if int(N) <= 111:
    print(111)
else:
    for m in range(0, 9):
        left = 112 + 111*m
        right = 222 + 111*m
        if (left<=int(N))&(int(N)<=right):
            print(right)
            break

Submission status: Accepted

Solution code:
from sys import stdin
n=int(stdin.readline().rstrip())
l=[111*i for i in range(1,10)]
for i in l:
    if n <= i:
        print(i)
        break
    else:
        pass

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#111
n = int(input())

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

Submission status: Accepted

Solution code:
def calc(n):
    a_list = []
    a = 0
    for i in range(0, n+1):
        a += 10**i
        a_list.append(a)
    return a_list
n = int(input())
N = len(list(str(n)))
a_list = calc(N+1)
b_list = []
for i in range(1, 10):
    for a in a_list:
        b_list.append(a * i)
b_list = sorted(b_list)
print([b for b in b_list if b >= n][0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

target = int(s[0]) * 111
if int(s) <= target:
  print(target)
else:
  print(target+111)

Submission status: Accepted

Solution code:
data = input()

sc = 0
ans = []
if (data[0] == data[1]) & (data[0] == data[2]):
    data = int(data)
    print(data)
elif int(data[0]) > int(data[1]):
    sc = int(data[0])
    ans = 100 * sc + 10 * sc + sc
    print(ans)
elif int(data[0]) == int(data[1]):
    if int(data[1]) > int(data[2]):
        sc = int(data[0])
        ans = sc * 100 + sc * 10 + sc
        print(ans)
    else :
        sc = int(data[0]) + 1
        ans = 100* sc + 10 * sc + sc
        print(ans)


        
else:
    sc = int(data[0]) + 1
    ans = 100* sc + 10 * sc + sc
    print(ans)

Submission status: Accepted

Solution code:
a = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
ABC = [111 * i for i in range(1, 10)]

for i in ABC:
    if N <= i:
        break

print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main111():
    N = int(input())

    first = int(N / 100)

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

main111()

Submission status: Accepted

Solution code:
N=int(input())
list=[111,222,333,444,555,666,777,888,999]
for i in list:
    if i>=N:
        print(str(i))
        break;
    else:
        pass;

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=input();x=l[0];print(x*3 if int(l) <= int(x*3) else str(int(x)+1)*3)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
ans=0

for i in range(n,n+1000):
    
    a=str(i)
    flag=1

    for j in range(len(a)):
        if(a[0]!=a[j]):
            flag=0
    if(flag==1):
        ans=a
        break
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
while n % 111 != 0:
	n += 1
print(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [111, 222, 333, 444, 555, 666, 777, 888, 999]
E = []
for i in range(9):
    if D[i] >= N:
        E.append(D[i])
ans = E[0]
print(ans)

Submission status: Accepted

Solution code:
N = input()
N0 = int(N)
N1 = list(N)
N2 = int(N1[0]+N1[0]+N1[0])

if(N0 <= N2):
  print(N2)
else:
  print(N2+111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=N//100
p=A*111
q=(A+1)*111
if N<=p:
    print(p)
else:
    print(q)

Submission status: Accepted

Solution code:
A = input()
AAA = int(A[0]*3)
if AAA >= int(A):
  print(AAA)
else:
  print(AAA + 111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=(n-1)/111
b=(a+1)//1
print(int(100*b+10*b+b))

Submission status: Accepted

Solution code:
n=int(input())
k=int(n/100)
k=100*k+10*k+k
if n<=k:
	print(k)
else:
	print(k+111)