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: Wrong Answer

Solution code:
n = input()

if int(n[0]) <= int(n[1]):
    if int(n[0]) == int(n[1]) and int(n[0]) < int(n[2]):
        temp=int(n[0])+1
        print(temp*100+temp*10+temp)
    else:
        temp=int(n[0])
        print(temp*100+temp*10+temp)
else:
    temp=int(n[0])
    print(temp*100+temp*10+temp)

Submission status: Wrong Answer

Solution code:
n = input()
num = int(n)
ans = 0
for digit in range(1,10):
    if int(num/digit) == 111:
        ans = num
        break
    elif int(num/digit) < 111:
        ans = digit*100+digit*10+digit
        break
print(ans)

Submission status: Wrong Answer

Solution code:
b = str(input())
num = list(b)
appear = b.count(num[0])
if appear == 3:
    print(b)
elif num[0] == num[1]:
    c = num[1]
    d=str(c)
    print(d*3)
else:
    c = int(num[0])+1
    d=str(c)
    print(d*3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
saisho = int(input())

a = int(saisho / 100)
b = int((saisho - 100 * a) / 10)
c = (saisho - 100 * a - 10 * b)

if a < b:
  s = b
else:
  s = a
if s < c:
  s = c
print(111 * s)

Submission status: Wrong Answer

Solution code:
n = int(input())
n_list = []

while n != 0:
    n_list.append(n%10)
    n //= 10
    n_list.reverse()

if max(n_list)-n_list[0] > 0:
    ans = n_list[0]
else:
    ans = max(n_list)

for _ in range(len(n_list)):
    print(ans,end='')

Submission status: Wrong Answer

Solution code:
A = list(input())
x = int(A[0])
y = int(A[1])
z = int(A[2])

ans = ''
a = 0
if x >= y:
    if y >= z:
        a = str(x)
        ans = a + a + a
    else:
        a = str(x + 1)
        ans = a + a + a
else:
    a = str(x + 1)
    ans = a + a + a

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
a = list(n)
if a[0] == a[1] ==a[2]:
    print(n)
else:
    if int(a[0])>= int(a[1]):
        a[1] = a[0]
        a[2] = a[0]  
        for i in range(3):
            print(a[i] ,end="")
    else:
        a[0] = str(int(a[0]) +1)
        a[1] =a[0]
        a[2] = a[0]

        for j in range(3):  
            print(a[j] ,end="")

Submission status: Wrong Answer

Solution code:
n = input()
mode = 0

for i in range(len(n)-1):
    if n[i] > n[i+1]:
        mode = 2
        break
    elif n[i] == n[i+1]:
        continue
    else:
        mode = 1
        break

if mode == 0:
    print(n)
elif mode == 1:
    print(int(n)+110)
else:
    print(n[0]*3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
b = str(input())
num=list(b)
appear = b.count(num[0])
if appear == 3:
    print(b)
else:
    c = int(num[0])+1
    d=str(c)
    print(d*3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

for i in range(1, 9, 1):
    str_i = str(i)
    str_x = "{}{}{}".format(str_i, str_i, str_i)
    x = int(str_x)
    if x >= N:
        break
print(x)

Submission status: Wrong Answer

Solution code:
N = str(input())
print(N.replace(N,max(N)+max(N)+max(N)))

Submission status: Wrong Answer

Solution code:
import sys
n=input()
n=list(n)
m=sys.maxsize;
for i in range(1,len(n)):
    n[i]=int(n[i])
    n[0]=int(n[0])
    if n[i]>n[0] and n[i]<m:
        m=n[i]
if m<=9:
    n[0]=m
    n[1]=m
    n[2]=m
    print(*n,sep='')
else:
    n[0] = n[0]
    n[1] = n[0]
    n[2] = n[0]
    print(*n,sep='')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=input()
length = len(n)
x = n[0]

# 10のくらいがｘ未満の場合はｘのゾロ目でよい
if n[1] < x:
    x = x*length
# 10の位がxより大きい場合はx+1のゾロ目
elif n[1] > x:
    x = str(int(x) + 1)*length
# 10の位がxと同じ場合は1の位を調べる
else:
    # 1に位がx未満ならばのゾロ目
    if n[2] < x:
        x = x *length
    # 1の位がxより大きい場合はx+1のゾロ目
    elif n[2] > x:
        x = str(int(x)+1)*length

# 999の場合は別処理
if int(n) == 999:
    x = '1111'

print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())

k = int(n/111)

u = 111*(k+1)

print(u)

Submission status: Wrong Answer

Solution code:
n=list(input())
for i in range(len(n)):
    n[i]=int(n[i])

for i in range(n[0],10):
    for i2 in range(n[1],10):
        for i3 in range(n[2],10):
            if(i==i2==i3):
                print(i*100+i2*10+i3)
                exit(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=N%10
N=int(N/10)
B=N%10
N=int(N/10)
C=N%10

print(max(A,B,C)*111)

Submission status: Wrong Answer

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

x = (s + 1) * 111
print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
if N % 111 == 0:
  print(N)
else:
  for i in range(N, 999):
    if i % 111 == 0:
      print(i)
      break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
n_list = []

while n != 0:
    n_list.append(n%10)
    n //= 10

ans = max(n_list)

for _ in range(len(n_list)):
    print(ans,end='')

Submission status: Wrong Answer

Solution code:
n = input()
N = list(n)

flag = max(N)
a = str(flag)
b = a * len(N)

if int(b) >= int(n):
    print(b)
else:
    print(a * (len(N)+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def check(n):
    count = 0
    n = str(n)
    # len_n = len(n)
    test = n[0]
    # n = int(n)
    for i in range(len(n)):
        if n[i] == test:
            count+=1
    if count == len(n):
        return True
    else:
        return False

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
a = N // 100
N -= 100*a
b = N // 10
N -= 10*b
c = N

if max(a, b, c) == a:
    ans = 100*a + 10*a + a
elif max(a, b, c) == b:
    a_ = a + 1
    ans = 100*a_ + 10*a_ + a_
else:
    if a >= b:
        ans = 111 * a
    else:
        a_ = a + 1
        ans = 100*a_ + 10*a_ + a_

print(ans)

Submission status: Wrong Answer

Solution code:
n=list(input())
re=''
for i in range(len(n)):
    n[i]=int(n[i])

for i in range(n[0],10):
    for i2 in range(n[1],10):
        for i3 in range(n[2],10):
            if(i==i2==i3):
                print(i*100+i2*10+i3)
                exit(0)

Submission status: Wrong Answer

Solution code:
N = input()
n1 = int(N[0])
n2 = int(N[1])
n3 = int(N[2])

if n1 >= n2 and n2 >= n3:
    v = n1
else:
    v = n1 + 1
print(str(v)+str(v)+str(v))

Submission status: Wrong Answer

Solution code:
n = [ int(i) for i in input() ]
print( str(max(n)) * 3 )

Submission status: Wrong Answer

Solution code:
n=input()
ans=""
an=""

for i in n:
    ans+=n[0]
    
if int(ans)>int(n):
    print(ans)
else:
    for i in n:
        an+=str(int(n[0])+1)
    print(an)

Submission status: Wrong Answer

Solution code:
N = map(int, list(raw_input()))
l = [max(N)] * len(N)
print(''.join([str(i) for i in l]))

Submission status: Wrong Answer

Solution code:
N = list(input())

flag = max(N)
a = str(flag)
print(a * len(N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

S = input()
values = list(map(int, list(S)))
if (values[0] > values[1]):
    print(str(values[0])*3)
elif (values[0] <= values[1] and values[1] > values[2]):
    print(str(values[1])*3)
else:
    print(str(values[2])*3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
j = []
for i in range(3):
    j.append(int(n[i]))
m = max(j)
print(111*m)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()

if n[0] == n[1] and n[1] == n[2] and n[0] == n[2]:
    print(n)
elif n[0] == n[1] and n[0] < n[2]:
    print(n[0]*3)
elif n[0] < n[1]:
    print(str(int(n[0])+1) * 3)
elif n[0] > n[1]:
    print(n[0]*3)

Submission status: Wrong Answer

Solution code:
a = raw_input()
b = int(a[0])
c = int(a[1])
d = int(a[2])
e = b+1
if b == c:
  if b == d:
    print 111*b
  else:
    print 111*e
else:
  print 111*e

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

if N <= 111:
    ans = 111
elif 111 < N < 222:
    ans = 222
elif 222 <= N < 333:
    ans = 333
elif 333 <= N < 444:
    ans = 444
elif 444 <= N < 555:
    ans = 555
elif 555 <= N < 666:
    ans = 666
elif 666 <= N < 777:
    ans = 777
elif 777 <= N < 888:
    ans = 888
elif 888 <= N <= 999:
    ans = 999

print(ans)

Submission status: Wrong Answer

Solution code:
n = input()

if n[0] == n[1] and n[1] == n[2] and n[0] == n[2]:
    print(n)
elif n[0] < n[1]:
    print(str(int(n[0])+1) * 3)
elif n[0] > n[1]:
    print(n[0]*3)

Submission status: Wrong Answer

Solution code:
N = list(input())
ans = ''
digit_max = 0
for d in N:
    digit_max = max(digit_max, int(d))
ans = str(digit_max) * len(N)
print(ans)

Submission status: Wrong Answer

Solution code:

S = input()
ans = max(list(map(int, list(S))))
print(str(ans)*3)

Submission status: Wrong Answer

Solution code:
n = str(input())
print(max(str(n[0]),str(n[1]),str(n[2])) * 3)

Submission status: Time Limit Exceeded

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

while n > ans:
    ans += ans
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

while 1:
  lst = set(list(str(n)))
  if len(lst)==1:
    print(n)
  else:
    n+= 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
while True:
    if n%10 == n//10%10 == n // 100:
        print(n)
    else:
        n += 1

Submission status: Time Limit Exceeded

Solution code:
def rec(n):
    m = str(n)
    c = m[0]
    get = n
    for i in range(len(m)):
        if m[i] != c:
            get = rec(n+1)

    return get



n = int(input())
res = rec(n)

print(res)

Submission status: Time Limit Exceeded

Solution code:
i = int(input())

while True:
    if set(str(i)) == 1:
        print(i)
        break
    i += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B AtCoder Beginner Contest 111
N = list(input())
n = int("".join(N))
ck = int(N[0] * 3)
if n - ck <= 0:
    print(int(N[0] * 3))
else:
    print(int(str(int(N[0])+1)*3))
pass

Submission status: Accepted

Solution code:
def answer(n: int) -> int:
    q = n // 111
    if n % 111 != 0:
        q += 1

    return 111 * q


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def isSame(n):
    if n[0] == n[1] and n[1] == n[2]:
        return True
    else:
        return False

n_s = input()
n_i = int(n_s)

while True:
    if isSame(n_s):
        print(n_s)
        break
    else:
        n_i += 1
        n_s = str(n_i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
flag = 0
for i in range(n,1000): 
    s = str(i)
    n_list = list(s)
    if n_list[0] == n_list[1] and n_list[1] == n_list[2] and flag == 0:
        flag = 1
        ans = i
        
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
hyaku=(n-n%100)/100
if n%100>hyaku*10+hyaku:
    hyaku+=1
    print(int(hyaku*100+hyaku*10+hyaku))
else:
    print(int(hyaku*100+hyaku*10+hyaku))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n_list=list(input())

n=[int(i) for i in n_list]

ans=str(n[0]+1)*3

if n[0]>n[1]:
    ans=str(n[0])*3

elif n[0]==n[1]:
    if n[1]>=n[2]:
        ans=str(n[0])*3
        
print(ans)

Submission status: Accepted

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

for i in range(9):
    if n <= ans:
        print(ans)
        exit()
    else:
        ans += 111

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc111/tasks/abc111_b"

def main():
    s = input()
    for n in range(int(s), 1000):
        str_n = str(n)
        if len(str_n) == str_n.count(str_n[0]):
            print(n)
            exit()



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
max_digit = N[0]

min_tmp = ''
max_tmp = ''
for i in range(len(N)):
    min_tmp += max_digit
    max_tmp += str(int(max_digit) + 1)
    
if  int(min_tmp) >= int(N):
    print(min_tmp)
else:
    print(max_tmp)

Submission status: Accepted

Solution code:
import sys

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

i = int(input())

for i in range(i, 1000):
    a = int((i/10)%10)
    b = int(i % 10)
    c = int(i /100)
    if a == b and b == c and c == a:
        print(i)
        exit(0)

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

oklist = [111, 222, 333, 444, 555, 666, 777, 888, 999]
n = ir()
ind = bisect.bisect_left(oklist, n)
print(oklist[ind])

Submission status: Accepted

Solution code:
N=input()
L=len(N)
if int(N[0]*L)>=int(N):
    print(int(N[0]*L))
else:
    print(int((N[0])*L)+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)
elif n <= 999:
    print(999)

Submission status: Accepted

Solution code:
n=int(input())
while str(n)[0]!=str(n)[1] or str(n)[1]!=str(n)[2]:
  n+=1
print(n)

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())
for i in range(N,1000):
    moji = str(i)
    if (moji[0] == moji[1]) and (moji[1] == moji[2]):
        break
        
print(i)

Submission status: Accepted

Solution code:
from math import ceil

n = int(input())
if n%111 == 0:
    print(n)
else:
    print(111*ceil(n/111))

Submission status: Accepted

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    # h, w, k = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys
n=input()
n=list(n)

if n[0]>n[1]:
  print(n[0]*3)
  sys.exit()

if n[0]<n[1]:
  print(str((int(n[0])+1))*3)
  sys.exit()
  
if n[0]==n[1]>=n[2]:
  print(n[0]*3)
  sys.exit()

if n[0]==n[1]<n[2]:
  print(str((int(n[0])+1))*3)
  sys.exit()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

for i  in ans_list:
  if i >= N:
    print(i)
    break

Submission status: Accepted

Solution code:
# import math
# import statistics
a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(i)
#e1,e2 = map(int,input().split())
#f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# zoro = int(a[0]*len(a))
zyun= len(a)*9+int(a[0])
zoro=0
z = zyun//9
af= zyun%9
if af==0:
    if int(a)<=int(str(9)*(z-1)):
        print(int(str(9)*(z-1)))
    else:
            print(str(1)*(z))
else :
    if int(a)<=int(str(af)*(z)):
        print(int(str(af)*(z)))
    else:
        print(int(str(af+1)*(z)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

h = n // 100
x = h * 100 + h * 10 + h
print(x) if n <= x else print(x + 111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, 10):
    l = [i, i, i]
    num = int(''.join(map(str, l)))
    if n <= num:
        print(num)
        break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    n = input()
    if n[0] == '0':
        print('111')
    elif n[0] < n[1] or n[0] < n[2]:
        print((int(n[0]) + 1) * 111)
    else:
        print(int(n[0]) * 111)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# ABC111

N = int(input())

zorome_contest = [111*i for i in range(1, 10)]
diff_min = 10**10
ans = 0

for contest in zorome_contest:
    if contest - N >= 0 and contest - N < diff_min:
        diff_min = contest - N
        ans = contest
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
k = int(n) % 111
if k==0:
    print(n)
else:
    if n[0]>n[1] or (n[0]==n[1] and n[1]>n[2]):
        print(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):
  i = str(i)
  if i[0] == i[1] and i[1] == i[2] and i[2] == i[0]:
    ans = i
    break
    
print(i)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = int(input())
for i in range(x, 1000):
  if i // 100 == i % 10 and i // 100 == (i // 10) % 10:
    break
print(i)

Submission status: Accepted

Solution code:
n = int(input())
a = 111
for _ in range(9):
    if n <= a:
        print(a)
        exit()
    a += 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 = int(input())
for i in range(1, 9+1):
    if a <= (t := i*111):
        print(t)
        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())
while True:
  if len(set(str(n))) == 1:
    print(n)
    break
  n += 1

Submission status: Accepted

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

Submission status: Accepted

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

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:
a=int(input())
b=a%100
c=a//100
if b<=c*11:
  print(c*111)
else:
  print((c+1)*111)

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,10):
    x = i*111
    if n <=x:
        print(x)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

else:
    print(111*int((N/111)))

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())
if N < 111:
  print(111)
else:
  for i in range(1,10):
    if N <= 111*i:
      ans = 111*i
      break
  print(ans)

Submission status: Accepted

Solution code:
import sys
import math
sys.setrecursionlimit(500000)
INF = float('inf')

def main():
    n = int(input())
    for i in range(n, 1000):
        flag = True
        for j, c in enumerate(str(i)):
            if j == 0:
                continue
            else:
                if c != str(i)[0]:
                    flag = False
                    break
        if flag:
            return i

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,i=int(input()),1
while n>111*i:
    i+=1
print(111*i)

Submission status: Accepted

Solution code:
N = int(input())

f = N
while True:
  x = str(f)
  if all(x[i] == x[0] for i in range(len(x))):
    print(x)
    exit()
  else:
    f += 1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

i = n
while True:
    if str(i)[0] != str(i)[1] or str(i)[1] != str(i)[2]:
        i += 1
    else:
        break
print(i)

Submission status: Accepted

Solution code:
contests = [i for i in range(100,1000) if i % 111 == 0]
N = int(input())
for contest in contests:
  if contest >= N:
    print(contest)
    break
  else:
    continue

Submission status: Accepted

Solution code:
n = int(input())
str_n = str(n)
keta = len(str_n)
suji = [str(i) for i in range(10)]
#print(str_n,keta,suji)
ans = 0
for i in range(int(str_n[0]),10):
    tmp = ''
    for j in range(keta):
        tmp += suji[i]
    #print(tmp)
    if int(tmp)>=n:
        ans = int(tmp)
        break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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