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:
def abc():
    s = input().rstrip()
    if len(set(s)) == 1:
        print(s)
        return
    for i in range(int(s), 1000):
        if len(set(str(i))) == 1:
            print(i)
            return


abc()

Submission status: Accepted

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


if n in lst:
    print(n)
    exit()

for i in range(1, 10):
    if n >= lst[i-1] and n <= lst[i]:
        print(lst[i])
        exit()
    elif n >= 100 and n <= 110:
        print(lst[0])
        exit()

Submission status: Accepted

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


def solve(N: int):
    for i in range(1, 10):
        if N <= 111 * i:
            print(111*i)
            break
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = input()
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())
L = [111, 222, 333, 444, 555,
     666, 777, 888, 999]
diff = [l-N if l >= N else 1000 for l in L]
print(L[diff.index(min(diff))])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(10):

    if (i != 0 and N <= i * 111):
        print( i*111 )
        break

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = input()

while 1:

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

    n = str(int(n)+1)

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

if(N > 111 and N <= 222):
    print('222')
if(N > 222 and N <= 333):
    print('333')
if(N > 333 and N <= 444):
    print('444')
if(N > 444 and N <= 555):
    print('555')
if(N > 555 and N <= 666):
    print('666')
if(N > 666 and N <= 777):
    print('777')
if(N > 777 and N <= 888):
    print('888')
if(N > 888 and N <= 999):
    print('999')
if N <= 111:
    print('111')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
a=int(n[0])
b=int(n[1])
c=int(n[2])
if a>b:
  print(a*111)
elif a<b:
  print((a+1)*111)
else:
  if b>=c:
    print(a*111)
  else:
    print((a+1)*111)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

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

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
while len(Counter(str(N)).keys()) != 1:
    N += 1
print(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
N = int(input())
a = int((N-1)/111)
print(111*(a+1))

Submission status: Accepted

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

i=0
while True:
    if n>list[i]:
        i+=1
    else:
        print(list[i])
        break

Submission status: Accepted

Solution code:
N = int(input())
kouho = [111, 222, 333, 444, 555, 666, 777, 888, 999]
result = 999
for k in kouho:
    if k < N:
        continue
    else:
        result = k
        break
print(result)

Submission status: Accepted

Solution code:
n=int(input())

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

if  a>b or a==b and b>=c:
    print(a*100+a*10+a)

else:
    print((a+1)*100+(a+1)*10+a+1)

Submission status: Accepted

Solution code:
n=int(input())

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

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

Submission status: Accepted

Solution code:
N = int(input())

goodABC = [111*i for i in range(1,10)]

for i in range(len(goodABC)):
  if N <= goodABC[i]:
    print(goodABC[i])
    exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())

for cnt in range(N,1000):
    if len(Counter(list(str(cnt))).most_common()) == 1:
        print(cnt)
        break

Submission status: Accepted

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

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:
n = input()
candidates = [3*str(i) for i in range(1,10)]
for i, j in enumerate(candidates):
    if n <= j:
        print(j)
        break

Submission status: Accepted

Solution code:
n = int(input())

def solve(n):
    if str(n)[0] == str(n)[1] == str(n)[2]:
        print(n)
    else:
        solve(n+1)

solve(n)

Submission status: Accepted

Solution code:
n = int(input())


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

else:
    a = 111 - (n % 111)
    print(n+a)

Submission status: Accepted

Solution code:
n = int(input())

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
contest_date = [111,222,333,444,555,666,777,888,999]
print(contest_date[(N-1)//111])

Submission status: Accepted

Solution code:
n=int(input())
a=(n-n%100)//100
if a==9:
    print(999)
else:
    ans=100*a+10*a+a
    if ans>=n:
        print(ans)
    else:
        print(ans+111)

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:
import math
print( math.ceil(int(input())/111)*111 )

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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)
else:
    print(1111)

Submission status: Accepted

Solution code:
N = input()
n = []
for v in N:
    n.append(v)
if (n[0]>=n[1]) and (n[0]>=n[2]):
    print(int(n[0]+n[0]+n[0]))
else:
    n[0] = str(int(n[0]) + 1)
    print(int(n[0]+n[0]+n[0]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0

while True:
    x = str(N + cnt)
    if len(x) >= 4:
        if x[0] == x[1] and x[0] == x[2] and x[0] == x[3]:
            break
    else:
        if x[0] == x[1] and x[0] == x[2]:
            break
    cnt += 1
    
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = input()
lst_N = list(N)

while 1:

    if lst_N[0] == lst_N[1] == lst_N[2]:
        break

    N = ''.join(lst_N)
    N = int(N)
    N += 1
    N = str(N)
    lst_N = list(N)

print(int(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def ok(n):
    s = str(n)
    if len(set(s)) == 1:
        return True
    return False

def solve():
    n = f()[0]
    for i in range(n, 1000):
        if ok(i):
            print(i)
            return

solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()

if n[0] < n[1]:
    x = int(n[0]) + 1
    temp_100 = x*100 + x*10 + x
    print(temp_100)
elif n[0] > n[1]:
    x = int(n[0]) 
    temp_100 = x*100 + x*10 + x
    print(temp_100)
else :
    if n[1] < n[2]:
        x = int(n[0]) + 1
        temp_100 = x*100 + x*10 + x
        print(temp_100)
    elif n[1] >= n[2]:
        x = int(n[0]) 
        temp_100 = x*100 + x*10 + x
        print(temp_100)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
from sys import stdin
N = stdin.readline().rstrip()
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 = input()
c = int(N[0] + N[0] + N[0])

if int(N) - c <= 0:
    print(c)
else:
    print(c + 111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s0 = int(s[0])
s1 = int(s[1])
s2 = int(s[2])

if s0 == s1 and s1 == s2:
    print(int(s))
elif s1 == s0:
    if s0 > s2:
        print("".join([str(s0)] * 3))
    else:
        print("".join([str(s0+1)] * 3))
elif s1 > s0:
    print("".join([str(s0+1)] * 3))
elif s1 < s0:
    print("".join([str(s0)] * 3))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
#!/usr/bin/env python3
import sys


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


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
for i in range(1,10):
    N = str(i) + str(i) + str(i)
    if n <= N:
        print(N)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(min(range(999,int(input())-1,-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()
int_N = int(N)
zorome = int(N[0]*3)
if int_N <= zorome:
    print(zorome)
else:
    print(zorome+111)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
B - AtCoder Beginner Contest 111
https://atcoder.jp/contests/abc111/tasks/abc111_b

"""
import sys


def solve(N):
    while True:
        if len(set(str(N))) == 1:
            break
        N += 1
    return N


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# 2019/05/17
# AtCoder Beginner Contest 111 - B

# Input
n = int(input())

# Calc
ans = (int(n / 111) + 1) * 111
if n % 111 == 0:
    ans -= 111

# Output
print(ans)

Submission status: Accepted

Solution code:
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

n = int(input())

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())

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

for i in b:
    if i < a:
        continue
    else:
        print(i)
        break

Submission status: Accepted

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

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:
def main():
    n = int(input())

    a = 111

    while (a < n):
        a += 111

    print(a)

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
#coding:utf-8

n=int(input())
print(n+(111-(n%111))%111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(n, 1000):
    if all([ii == str(i)[0] for ii in str(i)]):
        print(i)
        break

Submission status: Accepted

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

zoro=n[0]+n[0]+n[0]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

string_n = str(n)

third_digit = string_n[0]

next_third_digit = int(third_digit) + 1

if int(third_digit * 3) - n >= 0:
    print(int(third_digit * 3))
else:
    print(int(str(next_third_digit) * 3))

Submission status: Accepted

Solution code:
def main():
    N = input()
    ans = int(N[0]+N[0]+N[0])
    if ans < int(N):
        ans += 111
    print(ans)
main()

Submission status: Accepted

Solution code:
N = int(input())
ans = -1
while True:
    now = str(N)
    if now[0] == now[1] and now[1] == now[2]:
        ans = N
        break
    else:
        N += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC 111 B
n = int(input())
print(min([i*111 for i in range(1, 10) if n <= i * 111]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
a=list(str(input()))
e=int(''.join(a))


b=int(a[1])-int(a[1]*111)
c=a[0]
c=int(c)
b = e-c*111
if b <=0:
  print(c*111)
else:
  c+=1
  print(c*111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu May  9 23:00:25 2019

@author: Yamazaki Kenichi
"""
import sys

N = int(input())

for i in range(111):
    if N % 111 == 0:
        print(N)
        sys.exit()
    else:
        N += 1

Submission status: Accepted

Solution code:
N = input()

def check(n):
    for s in n:
        if s is not n[0]:
            return False
    return True

for i in range(int(N),1000):
    if check(str(i)):
        print(i)
        exit()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
N = int(input())
print(min([111*i-N for i in range(1,10) if 111*i>=N])+N)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
if n < 100:
    while int(n/10) != n % 10:
        n = n + 1
    print(n)
else:
    while not (int(n/100)==int((n%100)/10) and int(n/100) == n%10):
        n = n + 1
    print(n)

Submission status: Accepted

Solution code:
n = list(input())
for i in range(len(n)):
        n[i] = int(n[i])
ans = n[0]
if n[0] < n[1] or (n[0] == n[1] and n[1]<n[2]):
        ans += 1
for i in range(3):
        print(ans,end="")

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
ans=111
while a>ans:
  ans+=111
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = int(str(N)[0])
b = int(str(N)[1])
c = int(str(N)[2])
A = (a + 1) * 100 + (a + 1) * 10 + (a + 1)
B = a * 100 + a * 10 + a
if a < b:
    ans = A
elif a > b:
    ans = B
else:
    if b >= c:
        ans = B
    else:
        ans = A

print(ans)

Submission status: Accepted

Solution code:
N = input()
num = len(N)

a = list(map(int, N))

if max(a) == a[0]:
	print(N[0]*num)
else:
    print(str(a[0]+1)*num)

Submission status: Accepted

Solution code:
N = int(input())

a = (N-1)//111 + 1

print (111 * a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
while any([c!=N[0] for c in N]):
    N=str(int(N)+1)
print(N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###############################################################################

from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()

    for i in range(n, 1000):
        i2 = i // 100
        i1 = (i // 10) % 10
        i0 = i % 10

        if i0 == i1 and i1 == i2:
            print(i)
            return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
print(min([i for i in range(100,1000) if i >= n and i//100 == (i//10)%10 and i//100 == i%10]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
N = []
N.append(int(n[0]))
N.append(int(n[1]))
N.append(int(n[2]))

if N[0] * 100 + N[0] * 10 + N[0] >= N[0] * 100 + N[1] * 10 + N[2]:
    print(N[0] * 100 + N[0] * 10 + N[0])
else:
    print((N[0] + 1) * 100 + (N[0] + 1) * 10 + (N[0] + 1))

Submission status: Accepted

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

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())
for m in range(0,11):
 if 1+111*m<=n<=111+111*m:
  print(111*m+111)

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:
def solve():
    N = int(raw_input())
    ret = ((N - 1) // 111 + 1) * 111
    print str(ret)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding : UTF-8

from sys import stdin

N = stdin.readline().rstrip()

def main():
    if int(N) <= int(N[0]*len(N)):
        print(N[0]*len(N))
    else:
        print((str(int(N[0])+1))*len(N))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
abc = int(input())
for x in range(111, 1110, 111):
    if x >= abc:
        print(x)
        break

Submission status: Accepted

Solution code:
N = input()

for i in range(int(N), 10**9):
    if len(set(str(i))) == 1:
        ret = i
        break
print(i)

Submission status: Accepted

Solution code:
n=int(input())
a=[int(str(i)*3)-n for i in range(1,10)]
ans=[j for j in a if j>=0]
print(n+min(ans))

Submission status: Accepted

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

n = int(input())
for i in range(n, n + 111):
    temp = list(str(i))
    if temp[0]==temp[1]==temp[2]:
        print(i)
        exit()

Submission status: Accepted

Solution code:
N=input()
N=list(N)
Key=False
while Key==False:
    if N[0]==N[1] and N[1]==N[2]:
        break
    else:
        N=''.join(N)
        N=int(N)
        N+=1
        N=str(N)
        N=list(N)

N=''.join(N)
print(N)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
while True:
    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:
        print(n)
        break
    else:
        n+=1

Submission status: Accepted

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