Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03096 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def IR_(n): return [II() - 1 for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

# 解説AC
# ナニコレこんなの解けるの？ｗ
# 数え上げはだいたいDP
# ICPCのも水パフォに見えてきた
# このようなDPの問題をもっと解きたい

#solve
def solve():
    n = II()
    m = 2 * 10 ** 5
    c = [m] + IR_(n) + [m]
    dp0 = [0] * (n + 1)
    dp1 = [0] * (m + 1)
    dp1[c[0]] = 1
    for i in range(n + 1):
        if c[i] != c[i + 1]:
            dp0[i] += dp1[c[i]]
            dp0[i] %= mod
            dp1[c[i + 1]] += dp0[i]
            dp1[c[i + 1]] %= mod
        else:
            dp0[i] = dp0[i - 1]
    print(dp0[-1])
    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def IR_(n): return [II() - 1 for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

# 解説AC
# ナニコレこんなの解けるの？ｗ
# 数え上げはだいたいDP
# ICPCのも水パフォに見えてきた
# このようなDPの問題をもっと解きたい

#solve
def solve():
    n = II()
    c = [n] + IR_(n) + [n]
    dp0 = [0] * (n + 1)
    dp1 = [0] * (n + 1)
    dp1[c[0]] = 1
    for i in range(n + 1):
        if c[i] != c[i + 1]:
            dp0[i] += dp1[c[i]]
            dp0[i] %= mod
            dp1[c[i + 1]] += dp0[i]
            dp1[c[i + 1]] %= mod
        else:
            dp0[i] = dp0[i - 1]
    print(dp0[-1])
    return


#main
if __name__ == '__main__':
    solve()
Problem p03109 (python)

Fixed submission:
#A


s = input().split("/")
if int(s[1]) <= 4:
    print("Heisei")
else:
    print("TBD")

#B
"""
n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans +=  float(a[0]) * 380000
print(ans)
"""

Buggy submission (verdict: Runtime Error):
inf = float("INF")
a,b,q = map(int, input().split())
s = [None] * (a + 3)
s[0:2] = [-inf,-inf]
s[-1] = inf
t = [None] * (b + 3)
t[0:2] = [-inf,-inf]
t[-1] = inf
for i in range(a):
	s[i+2] = int(input())
for i in range(b):
	t[i+2] = int(input())

from bisect import bisect_left

dp0 = [None] * (a+3)
dp1 = [None] * (b+3)

def f(s,t,x,ss,i):
  if i == 0 and dp0[ss] != None: return abs(x - s[ss]) + dp0[ss]
  elif i == 1 and dp1[ss] != None: return abs(x - s[ss]) + dp1[ss]
  tr = bisect_left(t, s[ss])
  tl = tr - 1
  if i == 0: dp0[ss] = min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))
  if i == 1: dp1[ss] = min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))
  return abs(x - s[ss]) + min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))


for _ in range(q):
  ans = inf
  x = int(input())
  sr = bisect_left(s, x)
  ans = min(ans, f(s,t,x,sr,0))
  ans = min(ans, f(s,t,x,sr - 1,0))
  tr = bisect_left(t, x)
  ans = min(ans, f(t,s,x,tr,1))
  ans = min(ans, f(t,s,x,tr - 1,1))
  print(ans)
Problem p03110 (python)

Fixed submission:
#A

"""
s = input().split("/")
if int(s[1]) <= 4:
    print("Heisei")
else:
    print("TBD")

#B
"""
n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans +=  float(a[0]) * 380000
print(ans)

Buggy submission (verdict: Runtime Error):
#A


s = input().split("/")
if (s[1] == "04" or s[1] == "4" )and s[2] == "30":
    print("Heisei")
else:
    print("TBD")

#B

n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans +=  float(a[0]) * 380000
print(ans)

Buggy submission (verdict: Runtime Error):
#A
"""
s = input().split("/")
if s[1] == "04" and s[2] == "30":
    print("Heisei")
else:
    print("TBD")
"""

#B
n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans += int(a[0]) * 380000
print(ans)
Problem p03126 (python)

Fixed submission:
#A
"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""

#B

n, m = map(int, input().split())
ans = list(map(int, input().split()))
del ans[0]
ans = set(ans)
for i in range(n-1):
    a = list(map(int, input().split()))
    del a[0]
    ans = ans & set(a)
print(len(ans))


#C
"""
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
print(gcd_list(a))
"""

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())

k, *a = [int(i) for i in input().split()]

a = set(a)

for _ in range(n-1):
  _, *b = [int(i) for i in input().split()]
  a = a & b
print(len(a))
Problem p03129 (python)

Fixed submission:
n,k = map(int, input().split())
ans = 2*k-1
if n < ans:
  print('NO')
else:
  print('YES')

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ans = 2*k+1
if (ans > n):
  print(‘NO’)
else:
  print(‘YES’)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ans = 2*k+1
if ans > n:
  print(‘NO’)
else:
  print(‘YES’)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
ans = 2*k+1
if ans > n:
  print(‘NO’)
else:
  print(‘YES’)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
ans = 2*k+1
if ans > n: print(‘NO’)
else: print(‘YES’)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
ans = 2*k+1
if ans > n:print(“NO”)
else:print(“YES”)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
ans = 2*k+1
if ans > n:
  print(“NO”)
else:
  print(“YES”)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
ans = 2*k+1
if ans > n:
  print(“NO”)
else:
  ,print(“YES”)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
ans = 2*k+1
if ans > n:
    print(“No”)
else:
    print(“Yes”)

Buggy submission (verdict: Runtime Error):
n,k = map(int(), input().split())
ans = 2*k+1
if ans > n:
  print(“No”)
else:
  print(“Yes”)
Problem p03130 (python)

Fixed submission:

def find(x):
    while table[x] >= 0:
        x = table[x]
    return x

def union(x, y):
    s1 = find(x)
    s2 = find(x)
    if s1 != s2:
        if table[s1] != table[s2]:
            if table[s1] < table[s2]:
                table[s2] = s1
            else:
                table[s1] = s2
        else:
            table[s1] -= 1
            table[s2] = s1
    return
    


a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

ans = [0 for i in range(4)]

ans[a1-1] += 1 
ans[a2-1] += 1 
ans[a3-1] += 1 
ans[b1-1] += 1 
ans[b2-1] += 1 
ans[b3-1] += 1 

if 0 in ans or 3 in ans:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
a1,bi = map(int, input().split())
a2,b2 = map(int, input().split())
a3,b3 = map(int, input().split())
 
ne = [1,1,2,3,4]
 
ne[max(a1,b1)] = min(a1,b1)
ne[max(a2,b2)] = ne[min(a2,b2)]
ne[max(a3,b3)] = ne[min(a3,b3)]
 
ne = set(ne)
ne = list(ne)
 
if len(ne) == 1:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a1,bi = map(int, input().split())
a2,b2 = map(int, input().split())
a3,b3 = map(int, input().split())

ne = [1,1,2,3,4]

ne[max(a1,b1)] = min(a1,b1)
ne[max(a2,b2)] = ne[min(a2,b2)]
ne[max(a3,b3)] = ne[min(a3,b3)]

ne = list(set(ne))

if len(ne) == 1:
  print("YES")
else:
  print("NO")
Problem p03131 (python)

Fixed submission:
#B
"""
def find(x):
    while table[x] >= 0:
        x = table[x]
    return x

def union(x, y):
    s1 = find(x)
    s2 = find(x)
    if s1 != s2:
        if table[s1] != table[s2]:
            if table[s1] < table[s2]:
                table[s2] = s1
            else:
                table[s1] = s2
        else:
            table[s1] -= 1
            table[s2] = s1
    return
    


a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

ans = [0 for i in range(4)]

ans[a1-1] += 1 
ans[a2-1] += 1 
ans[a3-1] += 1 
ans[b1-1] += 1 
ans[b2-1] += 1 
ans[b3-1] += 1 

if 0 in ans or 3 in ans:
    print("NO")
else:
    print("YES")
"""

#C
k, a, b = map(int, input().split())

if a + 1 >= b:
    print(k + 1)
else:
    ans = k - 2*((k-(a-1))//2) + 1 + (b-a) * ((k - (a - 1)) // 2)
    print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())

if b+2 > c:
  print(1+a)
else:
  a -= b
  if a <= 0:
    print(1+a)
  else:
    ans = c
    while a < 0:
    	a -= b+1
		if a <= 0:
    		print(ans+ a+b+1)
        	break
		ans += c
Problem p03138 (python)

Fixed submission:
#A

#B
"""
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = sum(l) - 2*l[-1]
if ans > 0:
    print("Yes")
else:
    print("No")
"""

#C
"""
import bisect
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
xb = [abs(x[i] - x[i + 1]) for i in range(m-1)]
xb.sort(reverse=True)
ans = sum(xb[n - 1::])
print(ans)
"""

#D
n, m = map(int, input().split())
x = list(map(int, input().split()))
a = 0
b = 0
ans = 0
ansb = 0
mae = 0
b = [0 for i in range(40)]
for i in range(40):
    for k in x:
        b[i] += (k & (1 << i)) >> i

for i in range(39, -1, -1):
    if m & (1 << i) > 0:
        ansb = mae
        ansb += b[i] << i
        for k in range(i):
            ansb += max(b[k], n-b[k]) << k
        ans = max(ans, ansb)
        mae += (n-b[i]) << i
    else:
        mae += b[i] << i
ans = max(ans, mae)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
x = list(map(int, input().split()))
a = 0
b = 0
ans = 0
mae = 0
b = [0] * 40
for i in range(40):
    for k in x:
        b[i] += (k & (1 << i)) >> i

c = [0] * 40
if b[0] > n - b[0]:
    c[0] = b[0]
else:
    c[0] = n - b[0]
for i in range(1,40):
    ansb = 0
    if b[i] > n - b[i]:
        ansb += b[k] << k
    else:
        ansb += n - b[k] << k
    c[i] = c[i-1] + ansb
for i in range(39, -1, -1):
    if m & (1 << i):
        ansb = mae
        ansb += b[i] << i
        ansb += c[i]
        if ans < ansb:
            ans = ansb
        mae += n-b[i] << i
    else:
        mae += b[i] << i
ans = max(ans, mae)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
x = list(map(int, input().split()))
a = 0
b = 0
ans = 0
mae = 0
b = [0] * 40
for i in range(40):
    for k in x:
        b[i] += (k & (1 << i)) >> i

c = [0] * 40
if b[0] > n - b[0]:
    c[0] = b[0]
else:
    c[0] = n - b[0]
for i in range(1,40):
    ansb = 0
    if b[i] > n - b[i]:
        ansb += b[k] << k
    else:
        ansb += n - b[k] << k
    c[i] = c[i-1] + ansb
for i in range(39, -1, -1):
    if m & (1 << i):
        ansb = mae
        ansb += b[i] << i
        ansb += c[k]
        if ans < ansb:
            ans = ansb
        mae += n-b[i] << i
    else:
        mae += b[i] << i
ans = max(ans, mae)
print(ans)
Problem p03141 (python)

Fixed submission:
#A
"""
n, a, b = map(int, input().split())
ab = n / 2
ansa = min(a, b)
ansb = max((a+b)-n, 0)
print(ansa,ansb)
"""

#B
"""
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
    bf = [a[i], b[i], c[i]]
    bf = set(bf)
    ans += len(bf) - 1
print(ans)
"""

#C 

n = int(input())
ab = []
aba = []
abb = []
for i in range(n):
    a,b = map(int, input().split())
    ab.append([a + b, i])
    aba.append(a)
    abb.append(b)
ab.sort(reverse = True, key = lambda x:x[0])
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += aba[ab[i][1]]
    else:
        ans -= abb[ab[i][1]]
print(ans)


#D
"""
n, m = map(int, input().split())
ab = [[] for _ in range(n)]
for i in range(n + m - 1):
    a,b = map(int, input().split())
    ab[a-1].append(b-1)
print(ab)
ans = [0 for i in range(n)]
def yosozero(i):
    if ans[i]
"""

Buggy submission (verdict: Runtime Error):
ab=[sum(map(int, input().split())) for i in range(int(input()))]
ab.sort(reverse=True)
print(ab[::2]-ab[1::2])

Buggy submission (verdict: Runtime Error):
ab=[sum(map(int, input().split())) for i in range(int(input()))]
ab.sort(reversed=1)
print(ab[::2]-ab[1::2])
Problem p03161 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    h = LI()
    dp = [0 for i in range(n)]
    dp[1] = abs(h[0] - h[1])
    for i in range(2,n):
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
    print(dp[n-1])
    return

#B
def B():
    n, K = LI()
    h = LI()
    dp = [float("INF") for i in range(n + K + 1)]
    dp[0] = 0
    for i in range(n):
        for k in range(1, K + 1):
            if i + k >= n:
                break
            dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]))
    print(dp[n-1])
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I():
    return 
#J

#K

#L

#M
#N
# O
# P
# Q
# R
# S
# T
# U
# V
# W
# X
# Y
# Z


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

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
dp = [float('inf')] * n
dp[0] = 0

for i in range(1, n):
    tmp = float("inf")
    hi = h[i]
    for j in range(max(i - k, 0), i):
      	res = dp[j] + abs(hi - h[j])
        if tmp > res:
            tmp = res
    dp[i] = tmp

print(dp[n - 1])

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
dp = [float('inf')] * n
dp[0] = 0

for i in range(1, n):
    tmp = float("inf")
    for j in range(max(i - k, 0), i):
      	res = dp[j] + abs(h[i] - h[j])
        if tmp > res:
            tmp = res
    dp[i] = tmp

print(dp[n - 1])
Problem p03174 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LIR(n)
    n1 = 1 << n
    dp = [0] * n1
    dp[0] = 1
    b = [0]
    for i in range(n):
        b += [x + 1 for x in b]
    # print(b)
    c = [1 << i for i in range(n)]
    for i in range(n1-1):
        p = b[i]
        ap = a[p]
        for j in range(n):
            if ap[j]:
                j1 = c[j]
                if i & j1:
                    continue
                dp[i|j1] += dp[i]


    print(dp[-1] % mod)


    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LIR(n)
    n1 = 1 << n
    dp = [0] * n1
    dp[0] = 1
    q = deque()
    q.append((0, 0))
    while q:
        p, i = q.popleft()
        ai = a[i]
        for j in range(n):
            if ai[j]:
                j1 = 1 << j
                if p & j1:
                    continue
                pj1 = p | j1
                dp[pj1] += dp[p]
                if i == n: continue
                q.append((pj1, i + 1))

    print(dp[-1] % mod)


    return


#main
if __name__ == '__main__':
    solve()
Problem p03243 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

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

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

#C
def C():
    return

#D
def D():
    return

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

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

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

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

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()
Problem p03244 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

a1 = a[::2]
a2 = a[1::2]

from collections import defaultdict

d1 = defaultdict(int)
d1[0] = 0
for ai in a1:
	d1[ai] += 1  

d2 = defaultdict(int)
d2[0] = 0
for ai in a2:
	d2[ai] += 1  

an1 = list(d1.items())
an1.sort(key = lambda x: -x[1])

an2 = list(d2.items())
an2.sort(key = lambda x: -x[1])

if an1[0][0] == an2[0][0]:
	print(n - max(an1[0][1] + an2[1][1], an1[1][1] + an2[0][1]))
else:
	print(n - an1[0][1] - an2[0][1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

a1 = a[::2]
a2 = a[1::2]

from collections import defaultdict

d1 = defaultdict(int)
for ai in a1:
	d1[ai] += 1  

d2 = defaultdict(int)
for ai in a2:
	d[ai] += 1  

an1 = list(d1.items())
an1.sort(key = lambda x: -x[1])

an2 = list(d2.items())
an2.sort(key = lambda x: -x[1])

if an1[0][0] == an2[0][0]:
	print(n - max(an1[0][1] + an2[1][1], an1[1][1] + an2[0][1]))
else:
	print(n - an1[0][1] - an2[0][1])