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:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())

b = 111
if N <= b :
  print (b)
  exit()

while N-b > 111 :
  b += 111
b += 111
print (b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



n = int(sys.stdin.buffer.readline())
while True:
    if len(Counter(str(n))) == 1:
        print(n)
        break
    n += 1

Submission status: Accepted

Solution code:
# coding: utf-8

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

ans = [i for i in target if i >= next][0]
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:
x=input()
l=list(map(int,list(x)))
print(str(max(l))*3 if int(str(max(l)-1)*3) < int(x) else str(max(l)-1)*3)

Submission status: Accepted

Solution code:
n=input()
a,b,c=n[0],n[1],n[2]
if a==b==c:
  print(n)
elif a==max(a,b,c):
  print(a*3)
else:
  d=int(a)+1
  print(str(d)*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())
ans = 0
while ans < N:
    ans += 111
print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_left
n = int(input())
lst = [int(str(i) * 3) for i in range(1, 10)]
print(lst[bisect_left(lst, n)])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

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

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)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, 10):
    ans = int(str(i)*3)
    if n <= ans:
        print(ans)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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:
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])

Submission status: Accepted

Solution code:
n = int(input())

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

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

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

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

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

print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
##### 解けた #####

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
N = int(input())
for i in range(N,1000):
    t = set(list(str(i)))
    if len(t) == 1:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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())
i = 1
while i * 111 < n :
    i += 1
print((i) * 111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 111: B – AtCoder Beginner Contest 111
n = int(input())
i = n // 111

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

print(i * 111)

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())
num = n // 111

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

Submission status: Accepted

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

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())
l=[111,222,333,444,555,666,777,888,999]
for i in l:
  if i>=n:
    ans=i
    print(ans)
    exit()

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())
m=999
for i in range(1,10):
    if 111*i>=n:
        m=min(m,111*i)
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019-11-10 17:11:42(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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])

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Nを入力
n = int(input())
# N割る111の1の位だけ抽出してiにいれる
i = int(n / 111)
# nを111で割った数の余りが0じゃない場合のみ、
# N割る111の1の位だけ抽出してiに1を足す
if n % 111 != 0:
    i += 1
# iと111をかける
print(i * 111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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())
w = [111 * i for i in range(1,10)]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#ABC は第 N 回です． 100≤N≤999
#黒橋君は，初めて参加する ABC を第 x 回としたときに，xの十進法表記でのすべての桁の数字が同じであるようにしたいです．
#黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回でしょうか？

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#2019/10/03
N = open(0).read()
same_nums = int(N[0]*3)
print( same_nums if int(N) <= same_nums else same_nums+111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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