Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
print((N*(N-1))/2+(M*(M-1))/2)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
print(N*(N-1)/2+M*(M-1)/2)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
print(N*(N-1)+M*(M-1))

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
print(N*(N-1)+N*M)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)
Buggy python submission (verdict: Runtime Error):
S=input()

if S="AAA" or S="BBB":
  print("NO")
else:
  print("Yes")

Fixed submission:
S=input()
if S.count("AAA") or S.count("BBB"):
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
S,T=map(input().split())
a,b=mao(int,input().split())
U=input()

if S==U:
  print(a-1,b)
else:
  print(a,b-1)

Fixed submission:
S,T=input().split()
a,b=map(int,input().split())
U=input()

if S==U:
  print(a-1,b)
else:
  print(a,b-1)
Buggy python submission (verdict: Runtime Error):
s=input()
day=['SUN','MON','TUE','WED','THU','FRI','SAT']
for i in range(7):
  if s=day[i]:
    print(7-i)

Fixed submission:
s=input()
day=['SUN','MON','TUE','WED','THU','FRI','SAT']
for i in range(7):
  if s==day[i]:
    print(7-i)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
if A=B*2<0:
  print(0)
else:
  print(A-B*2)

Fixed submission:
A,B=map(int,input().split())
if A-B*2<0:
  print(0)
else:
  print(A-B*2)
Buggy python submission (verdict: Runtime Error):
s,t=input().split()
cnt=0
for i in range(3):
  if s[i]==t[i]:
    cnt+=1
print(cnt)


Fixed submission:
s=input()
t=input()
cnt=0
for i in range(3):
  if s[i]==t[i]:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s=int(input())
t=input()

if a>=3200:
  print(s)
else:
  print('red')

Fixed submission:
a=int(input())
s=input()

if a>=3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
P,Q,R=map(int,input().split())
min=P+Q
if min>Q+R:
  min=Q+R
if min>R+P:
  min=R+P:
print(min)

Fixed submission:
P,Q,R=map(int,input().split())
min=P+Q
if min>Q+R:
  min=Q+R
if min>R+P:
  min=R+P
print(min)
Buggy python submission (verdict: Runtime Error):
x=[(int(input()) for i in range(5)]
k=int(input())

if x[-1]-x[0]<=k:
  print("Yay!")
else:
  print(":(")

Fixed submission:
x=[int(input()) for i in range(5)]
k=int(input())

if x[-1]-x[0]<=k:
  print("Yay!")
else:
  print(":(")

Buggy python submission (verdict: Runtime Error):
x=list(int(input()) for i in range())
k=int(input())

if x[-1]-x[0]<=k:
  print("Yay!")
else:
  print(":(")

Fixed submission:
x=[int(input()) for i in range(5)]
k=int(input())

if x[-1]-x[0]<=k:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
n=int(input)

if n==1:
  print("Hello World")
else:
  A=int(input())
  B=int(input())
  print(A+B)

Fixed submission:
n=int(input())

if n==1:
  print("Hello World")
else:
  A=int(input())
  B=int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
count=0
 
while all(a%2==0 for a in A):
  A=[a//2 for a in A]
  count+=1
 
print(count)

Fixed submission:
s=input()
print(s.count('1'))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
cnt = 0

while all(i%2==0 for i in a ):
  A = [i//2 for i in a]
  cnt+=1

print(cnt)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
cnt=0

while all(i%2==0 for i in A):
  A=[i//2 for i in A]
  cnt+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
cnt = 0

while all(i%2==0 for i in a ):
  A = [i//2 for i in a]
  cnt+=1

print(cnt)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
cnt=0

while all(i%2==0 for i in A):
  A=[i//2 for i in A]
  cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
cnt=0
while True:
  if A%2==0:
    cnt+=1
  else:
    break
print(cnt)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
cnt=0

while all(i%2==0 for i in A):
  A=[i//2 for i in A]
  cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
a=False
count=0

while True:
  for i in range(n):
    if A[i]%2==1:
      a=True
      break
    A[i]//=2
  if a=True:
    break    
  else:
    count+=1
  
print(count)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
cnt=0

while all(i%2==0 for i in A):
  A=[i//2 for i in A]
  cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
A,B,C=input().split()

if A[len(A)-1]==B[0] and B[len(B-1)]==C[0]:
  print('YES')
else:
  print('NO')

Fixed submission:
A,B,C=input().split()

if A[len(A)-1]==B[0] and B[len(B)-1]==C[0]:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
A,op,B=input().split()

if op=='+':
  print(int(A)+int(B))
else:
  print(int(-A)-int(B))

Fixed submission:
A,op,B=input().split()

if op=='+':
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
Buggy python submission (verdict: Runtime Error):
a,s,c=input().split()
print(a[0+s[0]+c[0])

Fixed submission:
a,s,c=input().split()
print(a[0]+s[0]+c[0])
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 0
for i in range(3):
  if s[i] == 'R'
  	ans += 1
  else:
    if ans == 1:
      break
print(ans)

Fixed submission:
s = input()
ans = 0
for i in range(3):
  if s[i] == 'R':
  	ans += 1
  else:
    if ans == 1:
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
	if b == 0:
      print(-1)

Fixed submission:
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
  if b == 0:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      break
    a = a * 10 + 7

Fixed submission:
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
  if b == 0:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  for i in range(1000000)
    if a % n == 0:
      print(i+1)
      break
    a = a * 10 + 7


Fixed submission:
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
  if b == 0:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'tle':
    tle += 1
  else:
    re += 1
print('AC x ' + ac)
print('WA x ' + wa)
print('TLE x ' + tle)
print('RE x ' + re)


Fixed submission:
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
  s = input()
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  else:
    re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ans = 0
n = [0] * 10005
for i in range(N):
    n[A[i]] += 1
    ans += A[i]
Q = int(input())
for i in range(Q):
    b, c = map(int, input().split())
    ans += c * n[b] - b * n[b]
    print(ans)
    n[c] += n[b]
    n[b] = 0


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

ans = 0
n = [0] * 100005
for i in range(N):
    n[A[i]] += 1
    ans += A[i]
Q = int(input())
for i in range(Q):
    b, c = map(int, input().split())
    ans += c * n[b] - b * n[b]
    print(ans)
    n[c] += n[b]
    n[b] = 0
Buggy python submission (verdict: Runtime Error):
x = list(map(int, input().split()))
for i in range(5):
  if x[i] != i+1
  	print(i+1)


Fixed submission:
x = list(map(int, input().split()))
for i in range(5):
  if x[i] != i+1:
    print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= A[i]
if ans > 1000000000000000000:
    ans = -1
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > 1000000000000000000:
        ans = -1
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
for i in range(len(s)):
    if s[i] == "?":
        s = s[:i] + 'D' + s[i+1:]
print(s)

Fixed submission:
s = input()
print(s.replace('?', 'D'))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = ''
for i in range(len(s)):
    if s[i] == "?":
        ans += "D"
    else:
        ans += s[i]
print(ans)

Fixed submission:
s = input()
print(s.replace('?', 'D'))

Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(len(s)):
    if s[i] == '?':
        s[i] = 'D'
print(s)

Fixed submission:
s = input()
print(s.replace('?', 'D'))
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
a = [0] * 2050
n = 0
p = 1
for i in range(len(N)):
    n += int(N[len(N)-1-i]) * p
    p *= 10
    a[int(n) % 2019] += 1
ans = 0
for i in range(2019):
    if i == 0:
        ans += a[i] * (a[i]+1) // 2
    else:
        ans += (a[i]-1) * a[i] // 2
print(ans)


Fixed submission:
N = input()
a = [0] * 2050
n = 0
p = 1
for i in range(len(N)):
    n += int(N[len(N)-1-i]) * p
    p *= 10
    p %= 2019
    a[int(n) % 2019] += 1
ans = 0
for i in range(2019):
    if i == 0:
        ans += a[i] * (a[i]+1) // 2
    else:
        ans += (a[i]-1) * a[i] // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
a = [0] * 2050
for i in range(len(N)):
    n = N[len(N)-1-i:]
    a[int(n) % 2019] += 1
ans = 0
for i in range(2019):
    if i == 0:
        ans += a[i] * (a[i]+1) // 2
    else:
        ans += (a[i]-1) * a[i] // 2
print(ans)


Fixed submission:
N = input()
a = [0] * 2050
n = 0
p = 1
for i in range(len(N)):
    n += int(N[len(N)-1-i]) * p
    p *= 10
    p %= 2019
    a[int(n) % 2019] += 1
ans = 0
for i in range(2019):
    if i == 0:
        ans += a[i] * (a[i]+1) // 2
    else:
        ans += (a[i]-1) * a[i] // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [0] * 2050
for i in range(200010):
    a[N % 2019] += 1
    N //= 10**(i+1)
    N *= 10**(i+1)
    if N <= 0:
        break
ans = 0
for i in range(2019):
    if i == 0:
        ans += a[i] * (a[i]+1) // 2
    else:
        ans += (a[i]-1) * a[i] // 2
print(ans)


Fixed submission:
N = input()
a = [0] * 2050
n = 0
p = 1
for i in range(len(N)):
    n += int(N[len(N)-1-i]) * p
    p *= 10
    p %= 2019
    a[int(n) % 2019] += 1
ans = 0
for i in range(2019):
    if i == 0:
        ans += a[i] * (a[i]+1) // 2
    else:
        ans += (a[i]-1) * a[i] // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int,input().split())

min8 = (A * 25 + 1) // 2 
max8 = ((A+1) * 25 - 1) // 2
min10 = A * 10
max10 = (A+1) * 10 - 1

if min10 > max8 or min8 > mix10:
	print(-1)
else:
	print(min[min8, min10])


Fixed submission:
A, B = map(int,input().split())

min8 = (A * 25 + 1) // 2 
max8 = ((A+1) * 25 - 1) // 2
min10 = B * 10
max10 = (B+1) * 10 - 1

if min10 > max8 or min8 > max10:
	print(-1)
else:
	print(max([min8, min10]))
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
Q = int(input())
N = len(S)

flag = 0
for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == '1':
		flag = 1 - flag
	else:
		if (q[1] == '1' and flag == 1) or (q[1] == '2' and flag == 0):
			S.append(q[2])
		else:
			S.insert(0, q[2])
if flag == 1:
	S.reverse()
ans = ''.join(S)
print(ans)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
N = len(S)

flag = 0
for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == '1':
		flag = 1 - flag
	else:
		if (q[1] == '1' and flag == 1) or (q[1] == '2' and flag == 0):
			S.append(q[2])
		else:
			S.appendleft(q[2])
if flag == 1:
	S.reverse()
ans = ''.join(S)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
N = len(S)

rev = list(reversed(S))
S_rev = ''.join(rev)

for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == '1':
		S, S_rev = S_rev, S
	else:
		if q[1] == '1':
			s = [q[2], S]
			s_rev = [S_rev, q[2]]
			S = ''.join(s)
			S_rev = ''.join(s_rev)
		else:
			s = [S, q[2]]
			s_rev = [q[2], S_rev]
			S = ''.join(s)
			S_rev = ''.join(s_rev)

print(S)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
N = len(S)

flag = 0
for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == '1':
		flag = 1 - flag
	else:
		if (q[1] == '1' and flag == 1) or (q[1] == '2' and flag == 0):
			S.append(q[2])
		else:
			S.appendleft(q[2])
if flag == 1:
	S.reverse()
ans = ''.join(S)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
N = len(S)

rev = []
for i in range(N):
	rev.append(S[N-i-1])
S_rev = ''.join(rev)

for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == '1':
		S, S_rev = S_rev, S
	else:
		if q[1] == '1':
			s = [q[2], S]
			s_rev = [S_rev, q[2]]
			S = ''.join(s)
			S_rev = ''.join(s_rev)
		else:
			s = [S, q[2]]
			s_rev = [q[2], S_rev]
			S = ''.join(s)
			S_rev = ''.join(s_rev)

print(S)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
N = len(S)

flag = 0
for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == '1':
		flag = 1 - flag
	else:
		if (q[1] == '1' and flag == 1) or (q[1] == '2' and flag == 0):
			S.append(q[2])
		else:
			S.appendleft(q[2])
if flag == 1:
	S.reverse()
ans = ''.join(S)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, P = map(int, input().split())
S = input()

ans = 0
if P == 2 or P == 5:
	for i in range(N):
		if int(S[i]) % P == 0:
			ans += i+1
else:
	t = [0] * 20000
	t[0] = 1
	now = 0
	for i in range(N):
		n = N - i - 1
		now = (int(S[n]) * pow(10,i) + now) % P
		ans += t[now]
		t[now] += 1
print(ans)

Fixed submission:
N, P = map(int, input().split())
S = input()
 
ans = 0
if P == 2 or P == 5:
	for i in range(N):
		if int(S[i]) % P == 0:
			ans += i+1
else:
	t = [0] * 20000
	t[0] = 1
	now = 0
	po = 1
	for i in range(N):
		n = N - i - 1
		now = (int(S[n]) * po + now) % P
		po = 10 * po % P
		ans += t[now]
		t[now] += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())

parents = [-1] * N
friend = [set() for _ in range(N)]

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

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

	if x == y:
		return

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

	parents[x] += parents[y]
	parents[y] = x

for _ in range(M):
	A, B = map(int, input().split())
	union(A-1, B-1)
	friend[A-1].add(B-1)
	friend[B-1].add(A-1)

a = [-parents[find(i)]-len(friend[i])-1 for i in range(N)]

for _ in range(K):
	C, D = map(int, input().split())
	if find[C-1] == find[D-1]:
		a[C-1] -= 1
		a[D-1] -= 1
print(*a)


Fixed submission:
N, M, K = map(int, input().split())

parents = [-1] * N
friend = [set() for _ in range(N)]

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

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

	if x == y:
		return

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

	parents[x] += parents[y]
	parents[y] = x

for _ in range(M):
	A, B = map(int, input().split())
	union(A-1, B-1)
	friend[A-1].add(B-1)
	friend[B-1].add(A-1)

a = [-parents[find(i)]-len(friend[i])-1 for i in range(N)]

for _ in range(K):
	C, D = map(int, input().split())
	if find(C-1) == find(D-1):
		a[C-1] -= 1
		a[D-1] -= 1
print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()

flag = 0
res = 0
while len(N) > 0:
	n = int(N[len(N)-1])

	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n
		
	N = N[:len(N)-1]

if flag == 1:
	print(res + 1)
else:
	print(res)

Fixed submission:
N = input()

nagasa = len(N)
flag = 0
res = 0
for i in range(nagasa):
	s = nagasa - i - 1
	n = int(N[s])

	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n

if flag == 1:
	print(res + 1)
else:
	print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

flag = 0
res = 0
while N > 0:
	n = N % 10
	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n
		
	N = N // 10

if flag == 1:
	print(res + 1)
else:
	print(res)

Fixed submission:
N = input()

nagasa = len(N)
flag = 0
res = 0
for i in range(nagasa):
	s = nagasa - i - 1
	n = int(N[s])

	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n

if flag == 1:
	print(res + 1)
else:
	print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

flag = 0
res = 0
while N >= 0:
	n = N % 10
	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n
		
	N = N // 10
	if N == 0 and flag == 0:
		break

print(res)

Fixed submission:
N = input()

nagasa = len(N)
flag = 0
res = 0
for i in range(nagasa):
	s = nagasa - i - 1
	n = int(N[s])

	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n

if flag == 1:
	print(res + 1)
else:
	print(res)
Buggy python submission (verdict: Runtime Error):
a, b = map(string, input().split())
s = ''
if a > b:
	for _ in range(int(a)):
		s += b
else:
	for _ in range(int(b)):
		s += a
print(s)

Fixed submission:
a, b = map(str, input().split())
s = ''
if a > b:
	for _ in range(int(a)):
		s += b
else:
	for _ in range(int(b)):
		s += a
print(s)
Buggy python submission (verdict: Runtime Error):
max = 0
cnt = 0
N = int(input())
for _ in range(N):
	p = int(input())
	if max < p:
		max = p
		cnt += 1
print(cnt)

Fixed submission:
min = 10000000
cnt = 0
N = int(input())
P = list(map(int, input().split()))

for i in range(N):
	p = P[i]
	if min >= p:
		min = p
		cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
max = 0
cnt = 0
N = int(input())
for _ in range(N):
	p = int(input())
	if max < p
		max = p
		cnt += 1
print(cnt)

Fixed submission:
min = 10000000
cnt = 0
N = int(input())
P = list(map(int, input().split()))

for i in range(N):
	p = P[i]
	if min >= p:
		min = p
		cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
M = ''
for i in range(N):
	if i >= K and M[i-K] == T[i]:
		M += 'x'
		continue
	else:
		if T[i] == 'r':
			ans += P
			M += 'r'
		if T[i] == 's':
			ans += R
			M += 's'
		if T[i] == 'p':
			ans += S
			M += 'p'
print(ans)

Fixed submission:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
M = []
for i in range(N):
	if i >= K and M[i-K] == T[i]:
		M.append('x')
		continue
	else:
		if T[i] == 'r':
			ans += P
			M.append('r')
		if T[i] == 's':
			ans += R
			M.append('s')
		if T[i] == 'p':
			ans += S
			M.append('p')
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
M = ''
for i in range(N):
	if i < K:
		if T[i] == 'r':
			ans += P
			M += 'r'
		if T[i] == 's':
			ans += R
			M += 's'
		if T[i] == 'p':
			ans += S
			M += 'p'
	elif M[i-K] != T[i]:
		if T[i] == 'r':
			ans += P
			M += 'r'
		if T[i] == 's':
			ans += R
			M += 's'
		if T[i] == 'p':
			ans += S
			M += 'p'
	else:
		M += 'x'
print(ans)

Fixed submission:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
M = []
for i in range(N):
	if i >= K and M[i-K] == T[i]:
		M.append('x')
		continue
	else:
		if T[i] == 'r':
			ans += P
			M.append('r')
		if T[i] == 's':
			ans += R
			M.append('s')
		if T[i] == 'p':
			ans += S
			M.append('p')
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
a = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]
ans = ''
for i in range(len(S)):
  ans += a[(ord(S[i])-ord('A')+N)%26]
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = ''
for i in range(len(S)):
  temp = ord(S[i]) - ord('A') + N
  ans += chr(ord("A") + temp%26 )
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
a = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]
ans = ''
for i in range(len(S)):
  ans += S[(i+N)%26]
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = ''
for i in range(len(S)):
  temp = ord(S[i]) - ord('A') + N
  ans += chr(ord("A") + temp%26 )
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input())
h = list(map(int, input().split()))

ans = 0
for i in range(N):
	if h[i] >= K:
		ans += 1
print(ans)

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
ans = 0
for i in range(N):
	if h[i] >= K:
		ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
if S == 'Sunny':
  print('Cloudy')
if S == 'Cloudy':
  print('Rainy'):
if S == 'Rainy':
  print('Sunny')

Fixed submission:
S = input()
if S == 'Sunny':
  print('Cloudy')
if S == 'Cloudy':
  print('Rainy')
if S == 'Rainy':
  print('Sunny')