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 = input()
x = N[0]
xxx = int(3*x)
if int(N) <= xxx:
  print(xxx)
else:
  x = int(x)+1
  print(100*x + 10*x + x)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
num = [int(i) for i in input()]
if num[0] > num[1]:
    print(111*num[0])
elif num[0] == num[1]:
    if num[1] >= num[2]:
        print(111*num[0])
    else:
        print(111 * (num[0] + 1))
else:
    print(111*(num[0]+1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
print( (int(input())+110)//111*111 )

Submission status: Accepted

Solution code:
m = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

x = 111
while True:
    if x >= n:
        print(x)
        exit()
    else:
        x += 111

Submission status: Accepted

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

# input
N = int(input())

# solve
ans = int(N / 111)
if N % 111 != 0:
    ans += 1

# output
print(ans * 111)

Submission status: Accepted

Solution code:
import math
import copy
import sys

def zorome(num):
    return int(111*num)

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

# inputaList = [int(n) for n in inputa]

# inputb = input().split()
# inputbList = [int(n) for n in inputb]
#
# inputList = []
# inputNumList = []
# for i in range(a):
#     inputNum = input().split()
#     inputNumList = list(inputNum[0])
#     inputList.append(inputNumList)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

listNum = list(str(a))

if int(a) <= zorome(int(listNum[0])):
    print(zorome(int(listNum[0])))
else:
    print(zorome(int(listNum[0])+1))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(input())

num = (N-1) // 111

print((num+1)*111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
L = [0]*10
for i in range(10):
    L[i] = 111*i
for i in range(10):
    if (n > L[i]) and (n <= L[i+1]):
        print(L[i+1])
        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:
n=int(input())
d=int((n-1)/111)+1
print(*[d,d,d],sep='')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

l = [i * 111 for i in range(1, 10)]
for i in l:
    if N <= i:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
f = int(n[0])
s = int(n[1])
t = int(n[2])
if f < s:
    ans = (f+1)*100+ (f+1)*10+ (f+1)
elif f > s:
    ans = f*100 + f*10 + f
elif f == s and f >= t:
    ans = f*100 + f*10 + f
else:
    ans = (f+1)*100+ (f+1)*10+ (f+1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
g=n[0]
h=str(int(n[0])+1)
ni=int(n)
if ni <= int(g+g+g):
    print(g+g+g)
else:
    print(h+h+h)

Submission status: Accepted

Solution code:
n = int(input())

if n <= 111:
    print(111)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
n = int(N)//100
if N[0]==N[1]==N[2]:
    print(N)
elif N[0]==N[1] and N[0]>N[2]:
    print(100*n+10*n+n)
elif N[0]>N[1]:
    print(100*n+10*n+n)
else:
    n = n+1
    print(100*n+10*n+n)

Submission status: Accepted

Solution code:
s = int(input())

def check_target(s):
    s = str(s)
    prev = s[0]
    for i in range(len(s)):
        if s[0] != s[i]:
            return False
    return True

ans = 0
for i in range(s, 1000):
    if check_target(i):
        ans = i
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i,v in enumerate(ABC):
    tmp = v - N
    if tmp >= 0:
        print(v)
        break

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
x = str(n)
while True:
  digit = len(x)
  for i in range(digit):
    if x[i] != x[0]:
      break
  else:
    print(x)
    break
  y = int(x)
  y += 1
  x = str(y)

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())
t = n//100
t*=111
if t>=n:
  print(t)
else:
  print(t+111)

Submission status: Accepted

Solution code:
n = int(input())
candidates = [111 * i for i in range(1, 10)]
for candidate in candidates:
    if n <= candidate:
        print(candidate)
        exit()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	d = (n + 111 - 1) //111
	print(111 * d)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

print(((N + 110) // 111) * 111 )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

n100 = 0
n10 = 0
n1 = 0


while 1:
    n100 = n//100
    n10 = (n-n100*100)//10
    n1 = (n-n100*100-n10*10)
    if (n100 == n10) and (n10==n1):
        print(n)        
        break
    if n>= 1000:
        break
    n+=1

Submission status: Accepted

Solution code:
strN = input()
n = int(strN)
for i in range(n,n + 111):
    if i % 111 == 0:
        print(i)
        exit()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N] = string_to_int(inputs[0])
    i = N
    while 1:
        i_str = str(i)
        prev = i_str[0]
        is_ok = True
        for c in i_str:
            if c != prev:
                is_ok = False
                break
        if is_ok:
            return i
        i += 1


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
n = input()
while n.count(n[0]) != 3:
    n = int(n)
    n += 1
    n = str(n)
print(n)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = list((input()))
pred = n[0]*3
if pred == (''.join(n)) or int(pred) >= int(''.join(n)):
  print(pred)
elif int(pred) <= int(''.join(n)):
  print(int(pred)+111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
while True:
    if a % 111 == 0:
        print(a)
        exit()
    else:
        a += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():


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

    print(int(''.join(list(str(int(N/111)+1))*3)))





if __name__== "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

n = N
flag = True
while flag:
    s = str(n)
    s0 = s[0]
    for si in s:
        flag = True
        if si != s0:
            break
        flag = False
    n += 1

print(n - 1)

Submission status: Accepted

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

if N%111 == 0:
    print(N)
elif 111*a > N:
    print(111*a)
else:
    print(111*(a+1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())
i = int(s / 111)

if (s % 111 != 0):
  i = i + 1
  
print(i * 111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
n=list(map(int,input()))
i=n[0]
  
if n[0]>=n[1]:
  if n[0]==n[1]<n[2]:
    n[0],n[1],n[2]=i+1,i+1,i+1
  elif n[0]==n[1]==n[2]:
    n[0]=i
  else:
    n[1],n[2]=i,i
else:
  n[0],n[1],n[2]=i+1,i+1,i+1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
ans=int(n)

n_min=list(n[0]*3)
n_min=int("".join(n_min))

a=str(int(n[0])+1)

n_max=list(a*3)
n_max=int("".join(n_max))

#print(n_min)
#print(n_max)

if n_min>=ans:
    print(n_min)
else:
    print(n_max)

Submission status: Accepted

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


if N in ans:
    print(N)
else:
    for i in range(9):
        if N > ans[i]:
            continue
        else:
            print(ans[i])
            break

Submission status: Accepted

Solution code:
n = input()
nlower = int(''.join(list(n[0] * len(n))))
nupper = int(''.join(list(str(int(n[0]) + 1) * len(n))))
if nlower > int(n) or nlower == int(n):
    print(nlower)
else:
    print(nupper)

Submission status: Accepted

Solution code:

n = input()

temp = n[0]*len(n)

if int(n) <= int(temp):
    print(int(temp))
elif n[0] == "9":
    print("1" * (len(n) + 1))
else:
    print(str(int(n[0])+1)*len(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = n // 100
b = (n%100) // 10
c = n % 10


if a < b:
    ans = (a+1)*100 + (a+1)*10 + a+1
elif a == b:
    if c <= b:
        ans = a*100 + a*10 + a
    else:
        ans = (a+1)*100 + (a+1)*10 + a+1
else:
    ans = a*100 + a*10 + a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
N_len = len(list(str(N)))

while True:
    if len(set(str(N))) == 1:
        print(N)
        exit()
    else: N += 1

Submission status: Accepted

Solution code:
N = int(input())
ans = ["111", "222", "333", "444", "555", "666", "777", "888", "999"]
if not(N % 111):
    print(ans[int(N/111) - 1])
else:
    print(ans[int(N/111)])

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

for i in range(N, 1112):
    matched = True
    for j in range(1, len(str(i))):
        if str(i)[j - 1] != str(i)[j]:
            matched = False
            break
    if matched:
        print(i)
        exit(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = list(input())

ans = 0

N_len = len(N)
judge = True
if(N_len==1):
    print(int(N[0]))
else:
    for i in range(1,N_len):
        if int(N[0]) < int(N[i]):
            judge = False
            break
    
    if judge :
        for i in range(N_len):
            ans = ans + int(N[0])*10**i
    else :            
        for i in range(N_len):
            ans = ans + (int(N[0])+1)*10**i

    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
X = [111, 222, 333, 444, 555, 666, 777, 888, 999]
X = [x for x in X if x >= N]
print(min(X))

Submission status: Accepted

Solution code:
N=int(input())
i=int(N/111)

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

print(i * 111)

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
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = S()
    for i in n:
        if i == "1":
            print(9, end="")
        else:
            print(1, end="")
    print()
    return

#B
def B():
    n = II()
    for i in range(111, 1000, 111):
        if n <= i:
            print(i)
            return
    return

#C
def C():
    return

#D
def D():
    return

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

Submission status: Accepted

Solution code:
x=input()
xv=int(x)
n=len(x)

y=''
x1=str(int(x[0])+1)
z=''

for i in range(n):
	y=y+x[0]
	z=z+x1

yv=int(y)
zv=int(z)

if xv<=yv:
	res=yv
else:
	res=zv

print(res)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, 10):
    if N == int(str(i) + str(i) + str(i)):
        ans = int(str(i) + str(i) + str(i))
        break
    elif N < int(str(i) + str(i) + str(i)):
        ans = int(str(i) + str(i) + str(i))
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [str(i) * 3 for i in range(1, 10)]
for j in range(9):
  if N <= int(A[j]):
    print(A[j])
    break

Submission status: Accepted

Solution code:
s = input()
a = int(s)
s = s[0]
if int(s+s+s) >= a:
  print(s+s+s)
else:
  s = str(int(s)+1)
  print(s+s+s)

Submission status: Accepted

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

res = int(n[0])*111
if res - num < 0:
    res = (int(n[0])+1)*111
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inp = input()
n = list(inp)
x = int(n[0]+n[0]+n[0])
print(x) if int(inp)<=x else print(x+111)

Submission status: Accepted

Solution code:
n = int(input())

a = n // 100
if n <= int(str(a) * 3):
    print(str(a) * 3)
else:
    print(str(a + 1) * 3)

Submission status: Accepted

Solution code:
N = int(input())

#無限ループ
while True:
  if N % 111 == 0:
    print(N)
    exit()
  N += 1

Submission status: Accepted

Solution code:
N=int(input())
S=str(N)
a=int(S[0]+S[0]+S[0])
print(a if N<=a else a+111)

Submission status: Accepted

Solution code:
N=int(input())
if N%111==0:
    print(N)
else:
    for i in range(9):
        if (i+1)*111-N>0:
            print((i+1)*111)
            break
        else:
            continue

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

top = N[0]
little = True
for n in N:
    if int(n) > int(top):
        little = False
        break

if little:
    print(top*len(N))
else:
    print(str(int(top)+1)*len(N))

Submission status: Accepted

Solution code:
import sys
N = int(input())
for i in range(N, N*10):
    cur = 0
    for x, y in zip(str(i), str(i)[1:]):
        if x != y:
            break
        else:
            cur += 1
    if cur == 2:
        print(i)
        sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()

ans=int(N)//100

if N[0]==N[1]==N[2]:
    print(N)

elif N[0:2]<N[1:3]:
    print((ans+1)*100+(ans+1)*10+ans+1)
else:
    print(ans*100+ans*10+ans)

Submission status: Accepted

Solution code:
N = int(input())
for x in range(999):
  if str(N).count(list(str(N))[0]) == 3:
    print(N)
    break
  else:
    N += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
k=111
while n>k:
	k+=111
print(k)

Submission status: Accepted

Solution code:
def is_good(m):
    for i in range(2):
        a = m % 10
        m //= 10
        b = m % 10
        if a != b:
            return False
    return True

n = int(input())
while True:
    if is_good(n):
        print(n)
        break
    n += 1

Submission status: Accepted

Solution code:
a = int(input())

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

Submission status: Accepted

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

i = 0
while N <= KAI[i]:
     i += 1

print(KAI[i-1])

Submission status: Accepted

Solution code:
n = input()

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(n)

Submission status: Accepted

Solution code:
N = int(input())

x = N
while(1):
    s = str(x)
    if(s[0] == s[1] == s[2]):
        print(x)
        break
    else:
        x += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC111 B

n = int(input())

for i in range(n,1000):
    i = list(str(i))
    if len(list(set(i))) == 1:
        print(''.join(i))
        quit()

Submission status: Accepted

Solution code:
n = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
a = input()
b = 0
b = int(a[0] + a[0] + a[0])
if b < int(a):
    b += 111
print(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
#n, t = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
#ls = [int(input()) for i in range(n)]

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

Submission status: Accepted

Solution code:
n = str(input())

# ３桁目を抜き出す
# ３桁目の数字を３つ合成したものを、元の数字と比較する

c =  int(n[0] * 3)

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

if n in n_list:
  print(n)

for i in range(len(n_list)):
  if i == 0 and n < n_list[0]:
    print(n_list[0])
  if n_list[i-1] < n < n_list[i]:
    print(n_list[i])

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

Submission status: Accepted

Solution code:
S = input()
N = list(S)
ans = N[0]+N[0]+N[0]
if int(ans) < int(S):
  print(str(int(N[0])+1)+str(int(N[0])+1)+str(int(N[0])+1))
else:
  print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
r = math.ceil(N/111.0)*111
print(r)

Submission status: Accepted

Solution code:
def all_digits_same(N, d):
    if N == d:
        return True
    elif N % 10 != d:
        return False
    return all_digits_same(N // 10, d)

N = int(input())

while True:
    if all_digits_same(N, N % 10):
        print(N)
        break
    N += 1

Submission status: Accepted

Solution code:
N = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())

a = s//100
if s%(a*100) <= a*10+a:
    print(a*100+a*10+a)
else:
    print(((a+1)*100+(a+1)*10+(a+1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

i=0
while lst[i]<N:
    i+=1
    
print(lst[i])

Submission status: Accepted

Solution code:
def main():
    N = input()
    num = int(N[0])
    if int(N) <= num * 111:
        print(num * 111)
    else:
        print((num + 1) * 111)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()

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

Submission status: Accepted

Solution code:
nx = input()
n=int(nx)
x=111
for i in range (111,n,111):
    x+=111
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()

for i in range(1000):
    st = set()
    for k in str(i+N):
        st.add(k)
    if len(st) == 1:
        print(i+N)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(x)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

answer = []
for i in range(1,10) :
    num = int(str(i)+str(i)+str(i))
    calc = num-n
    if calc >=  0 :
        answer.append((num,calc))

print(answer[0][0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 整数の入力
N = int(input())

#百のケタに合わせる
if N<=int(N/100)*111:
  print(int(N/100)*111)
else:
  print((int(N/100)+1)*111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
a=x//100
b=100*a+10*a+a
if x<=b:
  print(b)
else:
    c=a+1
    print(100*c+10*c+c)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
N = int(input())

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