Problem:


Score : 100 points

Problem Statement

Given is a string S representing the day of the week today.

S is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.

After how many days is the next Sunday (tomorrow or later)?

Constraints

S is SUN, MON, TUE, WED, THU, FRI, or SAT.

Input

Input is given from Standard Input in the following format:

S

Output

Print the number of days before the next Sunday.

Sample Input 1

SAT

Sample Output 1

1

It is Saturday today, and tomorrow will be Sunday.

Sample Input 2

SUN

Sample Output 2

7

It is Sunday today, and seven days later, it will be Sunday again.



Sample input:
SAT


Sample output:
1

Submission status: Runtime Error

Solution code:

s=input()
if s=="SUN":
    print(7)
elif s == "MON":
    ptint(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Submission status: Runtime Error

Solution code:
s=input()
if s=="SUN":
    print(7)
elif s == "MON":
    ptint(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Submission status: Runtime Error

Solution code:

S=input()
if s='SUN':
    print(7)
elif s = 'MON':
    ptint(6)
elif s = 'TUE':
    print(5)
elif s = 'WED':
    print(4)
elif s = 'THU':
    print(3)
elif s = 'FRI':
    print(2)
elif s = 'SAT':
    print(1)

Submission status: Runtime Error

Solution code:
# get the date as a string
s = input()

WEEKDAYS=['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
integer_day = WEEKDAYS[::-1].indexof(s) + 1
print(integer_day)

Submission status: Runtime Error

Solution code:
# get the date as a string
s = raw_input()

WEEKDAYS=['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
integer_day = WEEKDAYS[::-1].indexof(s) + 1
print(integer_day)

Submission status: Runtime Error

Solution code:
def main():
  S = input()
  day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
  count = 7
  for i in day:
    if S == i:
        print(count)
    i -= 1

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
def sort(str):
  return ''.join(sorted(str))

i = int(input())
alpha = input()
x = sort(alpha[i:])
y = sort(alpha[:i])
if x.endswith("Z"):
	print(x + "A" + y)
else :
	print(x + y)

Submission status: Runtime Error

Solution code:
YOUBI = input()
if YOUBI == "MON":
  print"6"
if YOUBI == "TUE":
  print"5"
if YOUBI == "WED":
  print"4"
if YOUBI == "THU":
  print"3"
if YOUBI == "FRI":
  print"2" 
if YOUBI == "SAT":
  print"1"
if YOUBI == "SUN":
   print"7"

Submission status: Runtime Error

Solution code:
YOUBI = input()
if YOUBI == "MON":
  print"6"
if YOUBI == "TUE":
  print"5"
if YOUBI == "WED":
  print"4"
if YOUBI == "THU":
  print"3"
if YOUBI == "FRI":
  print"2" 
if YOUBI == "SAT":
  print"1"
if YOUBI == "SUN":
   print"7"
    
    
    SUN,MON,TUE,WED,THU,FRI,SAT

Submission status: Runtime Error

Solution code:
YOUBI = input()
if YOUBI == "MON

Submission status: Runtime Error

Solution code:
S = input()
if S = 'SUN':
  print(7)
elif S = 'MON':
  print(6)
elif S = 'TUE':
  print(5)
elif S = 'WED':
  print(4)
elif S = 'THU':
  print(3)
elif S = 'FRI':
  print(2)
elif S = 'SAT':
  print(1)

Submission status: Runtime Error

Solution code:
S = input()

week = {"SUT":1, "SUN":7, "MON":6, "TUE":5, "WED":4, "THU":3,"FRI":2}

ans = week[S]

print(ans)

Submission status: Runtime Error

Solution code:
S = input()

week = {"SUT":1, "SUN":7, "MON":6, "TUE":5, "WED":4, "THU":3,"FRI":2}

print(week[S])

Submission status: Runtime Error

Solution code:
s = input()
if s == "SAT":
  print(1)
elif s == "FRI":
  print(2)
elif s == "THU":
  print(3)
elif s == "WED":
  print(4)
elif s == "TUE":
  print(5)
elif s == "MON:
  print(6)
else:
  print(7)

Submission status: Runtime Error

Solution code:
week = ['MON','TUE','WED','THU','FRI','SAT','SUN']
day = input()
ans = week.index('SUN')-week,index(day)
print(ans if ans!=0 else 7)

Submission status: Runtime Error

Solution code:
week = ['SUN','MON','TUE','WED','THU','FRI','SAT' ]
print(week[(week.index(input)+1)%7])

Submission status: Runtime Error

Solution code:
S=input()
if S==SUN:
  print('7')
elif S==MON:
  print('6')
elif S==TUE:
  print('5')
elif S==WED:
  print('4')
elif S==THU:
  print('3')
elif S==FRI:
  print('2')
else:
  print('1')

Submission status: Runtime Error

Solution code:
S=input()
if S==SUN:
  print('7日後')
elif S==MON:
  print('6日後')
elif S==TUE:
  print('5日後')
elif S==WED:
  print('4日後')
elif S==THU:
  print('3日後')
elif S==FRI:
    print('2日後')
else:
    print('1日後')

Submission status: Runtime Error

Solution code:
S=input()
if S==SUN:
  print('7日後')
  elif S==MON:
    print('6日後')
  elif S==TUE:
    print('5日後')
  elif S==WED:
    print('4日後')
  elif S==THU:
    print('3日後')
  elif S==FRI:
    print('2日後')
  else S==SAT:
    print('1日後')

Submission status: Runtime Error

Solution code:
S=input()
if S==SUN:
  print('7日後')
elif S==MON:
  print('6日後')
elif S==TUE:
  print('5日後')
elif S==WED:
  print('4日後')
elif S==THU:
  print('3日後')
elif S==FRI:
  print('2日後')
else S==SAT:
  print('1日後')

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
S = input()
a = ["SUN", "MUN", "TUE", "WED", "THU", "FRI", "SAT"]
a.reverse()
ans = a.index(S) + 1
print(ans)

Submission status: Runtime Error

Solution code:
A, B, X = map(int, input().split())
i = 0
while A * (10 ** i) + B * i < X:
    i += 1

print(min((X - (B + i)) // A, 10 ** i - 1, 10 ** 9))

Submission status: Runtime Error

Solution code:
s=input()
if s='SUN':
    print(7)
elif s='MON':
    print(6)
elif s='TUE':
    print(5)
elif s='WED':
    print(4)
elif s='THU':
    print(3)
elif s='FRI':
    print(2)
else:
    print(1)

Submission status: Runtime Error

Solution code:
a,b,x=map(int,input().split())

def calc(n):
      p=a*n+b*len(str(n))
      return p<=x

h=10**9+1
ok=0
while h-ok>1:
      m=(h+ok)//2
      if calc(m):
            ok=m
      else:
            h=m

print(ok)

Submission status: Runtime Error

Solution code:

import numpy as np
N, K  = map(int, raw_input().split())
A = np.array(map(int, raw_input().split()))

A_cumsum = np.empty(N+1, dtype=int)
A_cumsum[0] = 0
A_cumsum[1:] = np.cumsum(A)
ans = 0
for i in xrange(1, K):
    seq_sum = A_cumsum[i:] - A_cumsum[:-i]
    ans += np.sum(seq_sum%K==1)
    
print ans

Submission status: Runtime Error

Solution code:
in = input()
d = {'SUN': 7, 'MON': 6, 'TUE': 5, 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1}
print(d[in])

Submission status: Runtime Error

Solution code:
A,B,X = map(int, input().split())

def func(N):
    return (A*N + B*len(str(N)))


def search(start, end):
    median = int((end - start)//2)
    if median == 0:
        if func(end) <= X:
            return end
        elif func(start) <= X:
            return start
        else:
            return 0

    val = func(start+median)
    if val == X:
        return (start+median)
    elif val > X:
        return search(start, start+median)
    elif val < X:
        return search(start+median, end)

result = search(1,10**9)
if result >= 1000000000:
    print(1000000000)
else:
    print(result)

Submission status: Runtime Error

Solution code:
A, B, X = map(int, raw_input().split())

def price(i, A, B):
    Dig = len(str(i))
    return A * i + B * Dig

l = 0
r = 10**9 + 1

while (r-l) > 1:
    c = (r+l)/2
    Pri = price(c, A, B)
    if Pri <= X:
        l = c
    else:
        r = c

print l

Submission status: Runtime Error

Solution code:

A, B, X = map(int, raw_input().split())

def price(i, A, B):
    Dig = len(str(i))
    return A * i + B * Dig

l = 0
r = 10**9 + 1

while (r-l) > 1:
    c = (r+l)/2
    Pri = price(c, A, B)
    if Pri <= X:
        l = c
    else:
        r = c

Submission status: Runtime Error

Solution code:
A, B, X = map(int, input().split())
l = 0
r = 10**9+1


def keta(n):
    cnt = 0
    while n > 0:
        n //= 10
        cnt += 1
    return cnt

while r-l > 1:
    c = (l + r) // 2
    keta_c = keta(c)
    if A * c + B * keta_c <= X:
        l = c
    else:
        r = c

print(l)

Submission status: Runtime Error

Solution code:
a, b, x = [int(x) for x in input().split(' ')]

prev_max_number = 0
answer = -1
for i in range(10):
    baseline = b * (i + 1)
    offset = (x - baseline) // a
    min_number = (10 ** i)
    max_number = (10 ** (i + 1)) - 1

    if offset < min_number:
        answer = prev_max_number
        break

    if offset < max_number:
        answer = offset
        break

    prev_max_number = max_number

if answer < (10 ** 9):
    print(answer)
else:
    print(10 ** 9)

Submission status: Runtime Error

Solution code:
n = int(input())
s = [{0} for i in range(n)]

ans = [0] * n
a = 0
b = 0
sp = {i for i in range(n)}
for i in range(1,n):
    a,b = list(map(int,input().split()))
    ans[i] = min(sp-(s[a-1]|s[b-1]))

    s[a-1].add(ans[i])
    s[b-1].add(ans[i])

print(max(ans))
for i in range(1,n):
    print(ans[i])

Submission status: Runtime Error

Solution code:
Day = {"SUN":7,
       "MON":6,
       "TUE":5,
       "WEN":4,
       "THU":3,
       "FRI":2,
       "SAT":1}

S = raw_input()

print Day[S]

Submission status: Runtime Error

Solution code:
# coding: utf-8

alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

num = int(input())
str = input()
result = ""

for s in str:
  pos = alpha.find(s)
  result += alpha[pos+num]

print(result)

Submission status: Runtime Error

Solution code:
import math
def solve():
    A, B, X = map(int, input().split())
    
    ans = 0
    for d in range(1, 18):
        N = (X - B*d)/A
        N = int(math.ceil(N))
        if N <= 0:
            continue
        if d == len(str(N)):
            if d >= 10:
                ans = 10**9
            else:
                ans = N
    
    print(ans)
 
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
A,B,X = map(int, input().split())

def money(n):
    re = A*n + B*len(str(n))
    return re

tmp = 0
if X >= money(1000000000):
    print(1000000000)
elif X < money(1):
    print(0)
else:
    left = 0
    right = 10**9
    while 1:
        mid = (left + right) // 2
        if money(mid) == X or right - left <= 1:
            print(mid)
            break
        elif money(mid) < X:
            left = mid
        elif money(mid) > X:
            right = mid

Submission status: Runtime Error

Solution code:
N = int(input())

graph = [[] for i in range(N)]

for i in range(N -1):
    a, b = map(int, input().split())
    graph[a-1].append((b, i))
    graph[b-1].append((a, i))

print(graph)
ans = [0] * (N -1)


def dfs(past, now, color):
    new_color = 1
    for future, edge in graph[now - 1]:
        if future == past:
            pass
        else:
            if new_color == color:
                new_color += 1
            ans[edge] = new_color
            dfs(now, future, new_color)
            new_color += 1

dfs(-1, 1, -1)

print(max(ans))
for i in ans:
    print(i)

Submission status: Runtime Error

Solution code:
import math

a, b, x = map(int, input().split())

for i in range(int(x/a-1),10000000000000000000):
    if x < (a*i+b*int(math.log10(i)+1)):
        break

if i > 1:
    print(a*(i-1)+b*int(math.log10(i-1)+1))
elif i == 1:
    print(0)

Submission status: Runtime Error

Solution code:
a, b, x = map(int, input().split())
q = x//a
k = len(str(q))
ary = []
for i in range(k-1, k+1):
	if len(str((x-b*i)//a)) == i:
		if (x-b*i)//a > 10**9:
			if a * 10**9 + b * 10 <= x:
				ary.append(10**9)
		else:
			ary.append(min((x-b*i)//a, 10 ** i - 1))
if len(ary) == 0:
	print (0)
else:
	print (max(ary))

Submission status: Runtime Error

Solution code:
S=input()

if S=="SUN":
    print('7')
elif S=="MON":
    print('6')
elif S=="TUE":
    print('5')
elif S=="WED":
    print('4')
elif S=="THU":
    print('3')
elif S=="FRI":
    print('2
elif S=="SAT":
    print('1')

Submission status: Runtime Error

Solution code:
s = input()
d = {"SAN":7,"MAN":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
print(d[s])

Submission status: Runtime Error

Solution code:
s = input()
d = {"SAN":7,"MAN":1,"TUE":2,"WED":3,"THU":4,"FRI":5,"SAT":6}
print(d[s])

Submission status: Runtime Error

Solution code:
i = str(input())
day = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']

if len(day) - day.index(i) == 0:
    print(7)
  else:
    print(len(day) - day.index(i))

Submission status: Runtime Error

Solution code:
a,b,x=map(int,input().split())
cnt=0
for i in range(1,11):
  if x-i*b>=0 and (x-i*b)//a>=10**(i-1):
    cnt+=1
if cnt==0 or x-i*b<0:
  print(0)
else:
  print(((x-cnt*b)-(x-cnt*b)%a)//a)

Submission status: Runtime Error

Solution code:
S = ["SUN","MON","TUE","WED","TUR","FRI","SAT"]
s = input()
print(7 - S.index(s))

Submission status: Runtime Error

Solution code:
n = int(input())
S = input()

ans=[]
for i in range(len(S)):
  s = S[i]
  sind = ord('A') + (ord(s)-ord('A')+ n)%26
  ans.append(chr(sind))

print(ans)

Submission status: Runtime Error

Solution code:
s = input()
slist = [SUN,MON,TUE,WED,THU,FRI,SAT]
i = slist[s]
  
print(7-i)

Submission status: Runtime Error

Solution code:
s = input()
slist = [SUN,MON,TUE,WED,THU,FRI,SAT]
i = slist[s]
if i == 6:
  i = -1
  
print(slist[i+1])

Submission status: Runtime Error

Solution code:
A,B,X = map(int,input().split())

i=0
N = 0
if A*(10**9) + B*(10) <= X:
    N=10**9
else:
    while i < 10:
        if A*(10**i) + B*(i+1) > X:
            if i==0:
                N = 0
            else:
                N = (X-B*i)//A
                if N < 10**(i-1):
                    N = 0
            break
        else:
            i += 1

print(N)

Submission status: Runtime Error

Solution code:
import math

a, b, x = map(int, input().split())
n = 0
i = 1
f = int(1e9)
ans = 0

while f-i > 1:
  n = (i+f)//2
  d = math.trunc(math.log10(n)) + 1
  if a*n + b*d <= x:
    i = n
  else:
    f = n

if a*f + b*d <= x:
  ans = f
elif a*i + b*d <= x:
  ans = i
else:
  ans = 0

print(ans)

Submission status: Runtime Error

Solution code:
a, b, x = list(map(int, input().split()))
res = 0
for l in range(1, 40):
  t = (x - b * l) // a
  if len(str(t)) == l:
    res = t
if res > 10**9:
  print(10**9)
elif res < 1:
  print(0)
else:
  print(res)

Submission status: Runtime Error

Solution code:
import math
a,b,x = map(int,input().split())
 
maxint = 10**9
 
def dn(p):
    plist = list(str(p))
    return len(plist) #nの桁数d(n)が帰る

def nibuntansaku(l,u):
    c = (l+u)//2 #切り捨て
    if c <= (x-b*dn(c))/a: #条件を満たす(つまり、)
        return c,u
    else:
        return l,c





#上限(大きい)
n_upper = math.ceil((x-b*1)/a)
#下限(小さい)
n_lower = math.floor((x-b*10)/a)


if n_upper < 1 : #最小条件ですでに1未満の場合は0を出力
    print(0)
    exit()

while True:
    if abs(n_upper-n_lower) <= 1:
        break 
    n_lower,n_upper = nibuntansaku(n_lower,n_upper)

if n_upper+1 <= (x-b*dn(n_upper+1))/a:
    ans = n_upper+1

elif n_upper <= (x-b*dn(n_upper))/a:
    ans = n_upper
else:
    ans = n_lower

print(min(ans,maxint))

Submission status: Runtime Error

Solution code:
s = input()

dic = {'SUN' : 6, 'MON' : 5, 'WED' : 4, 'THU' : 3, 'FRI' : 2, 'SAT' : 1}

print(dic[s])

Submission status: Runtime Error

Solution code:
import sys
a,b,x = map(int,input().split())
limit = 10**9
ans = 0
for d in range(1,10):
  n = (x - (b * d)) // a
  #if n <= limit and len(str(n)) == d:
    #ans = max(ans,n)
  #elif n > limit:
    #ans = limit
  # nが求まることとxが求まることは別物
  if 10**(d - 1) <= n < 10**d:
    ans = n
  elif n >= 10**d:
    # なぜ10**9-1は条件を満たすといいきれる？
    ans = 10**d-1
if x>=a*limit + b*10:
  ans = limit
print(ans)

Submission status: Runtime Error

Solution code:
a,b,x = map(int,input().split())

ans = 0
for i in range(1,10):
 n = (x - b*i)//a
 if 10**(i-1) <= n < 10**i:
  ans = n
 elif n>=10**i:
  ans=10**i-1
  
if x>=a*10**9+b*10:
 ans=10**9
print(ans)

Submission status: Runtime Error

Solution code:
a,b,x = map(int,input().split())

ans = 0
for i in range(1,10):
　　n = (x - b*i)//a
　　if 10**(i-1) <= n < 10**i:
　　　　ans = n
　　elif n >= 10**i:
　　　  ans = 10**i - 1
  
if x >= a*10**9+b*10:
       ans =10**9
print(ans)

Submission status: Runtime Error

Solution code:
s = input()
week = { 'SUN': 7, 'MUN': 6, 'TUE': 5, 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1 }
print(week[s])

Submission status: Runtime Error

Solution code:
week = {'SUN':7, 'MUN':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1}
print(week[str(input())])

Submission status: Runtime Error

Solution code:
choise = input()
week = {'SUN':7, 'MUN':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1}
print(week[choise])

Submission status: Runtime Error

Solution code:
week = {'SUN':7, 'MUN':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1}
print(week[input()])

Submission status: Runtime Error

Solution code:
print(7-'SUN,MON,TUE,WED,THU,FRI,SAT'.split().index(input()))

Submission status: Runtime Error

Solution code:
iro = []
iro_i = []
res = []
r = 1
cm = []

N = int(input())
for i in range(N+1):
  cm.append([])
for i in range(N-1):
  a,b = input().split(" ")
  a = int(a)
  b = int(b)
  cr = set(iro_i) - set(cm[a] + cm[b])
  
  if len(cr):
    cr = list(cr)[0]
    res.append(cr)
    cm[a].append(cr)
    cm[b].append(cr)
  else:
    iro_i.append(r)
    cm[a].append(r)
    cm[b].append(r)
    res.append(r)
    r+=1

print(r-1)
for i in res:
  print(i)

Submission status: Runtime Error

Solution code:
#xが所持金
#a * n + b *nの桁数
a,b,x =map(int,input().split())

if a+b>x:
  print(0)
  exit()

if a*(10**9)+b*10<=x:
  print(10**9)
  exit()
  
  
for i in range(10):
  if (a*(10**i)+b*len(str(10**i))<=x and a*(10**(i+1))+b*len(str(10**(1+i))) >x) or i==9:
    kagen=10**i
    jougen=min(10**9,10**(i+1))
    
    atai=kagen+jougen//2
    
    while 1:
      #print(kagen,atai,jougen)
      if a*atai+b*len(str(atai))<=x and a*(atai+1)+b*len(str((1+atai))) >x:
        print(atai)
        exit()
      if a*atai+b*len(str(atai))<=x:
        kagen=atai
        atai=(atai+jougen)//2
      else:
        jougen=atai
        atai=(kagen+atai)//2

Submission status: Runtime Error

Solution code:
import math
# 二分探索で効率的に数値を探す。
A, B, X  = map(int,input().split())

def buy(N):
    if N <= 0:
        return 0
    else:
        s = A*N + B*((math.log10(N)//1)+1)
        return int(s)

n = 10**9
L = 1
H = n
if buy(n) <= X:
    print(n)
elif buy(1) > X:
    print(0)
else:
    while H - L > 1:
        mid = int((L+H)/2)
        if buy(mid) <= X:
            L = mid
        elif buy(mid) > X:
            H = mid
    print(L)

Submission status: Runtime Error

Solution code:
import sys
A, B, X = map(int, input().split())
def ne(n):
    return A*n + B*len(str(n))
if ne(10**10) <= X:
    print(10**10)
    sys.exit()
high = 10**10
low = 0
ans = (high + low) // 2
while (low < high):
    if ans == 0:
        print(0)
        sys.exit()
    if ne(ans) <= X:
        if ne(ans+1) > X:
            print(ans)
            sys.exit()
        low = ans
    else:
        high = ans
    ans = (high + low) // 2
print(ans)

Submission status: Runtime Error

Solution code:
a,b,x=map(int,input().split())
def an():
    if x>a*1e+9+b*10:
        print(int(1e+9))
        return
    i=int(1e+9)
    j=i
    max=int(1e+9)
    min=1
    while max-min>1:
        d=len(str(i))
        if a*i+b*d>x:
            max=i
        else:
            min=(i+j)//2
        i=(max+min)/2
    print(min)
an()

Submission status: Runtime Error

Solution code:
a,b,x=map(int,input().split())
def an():
    if x>a*1e+9+b*10:
        print(int(1e+9))
        return
    i=int(1e+9)
    j=i
    cou=0
    while True:
        cou+=1
        if(cou>10000):break#整数除算で限界が来た時用
        d=len(str(i))
        if a*i+b*d>x:
            j=i
            i//=2
        elif a*i+b*d<x:
            i=(i+j)//2
        else:
            return
    for k in range(min(i,j),max(i,j)+1):
        d=len(str(k))
        if a*k+b*d==x:
            print(k)
            return
        if a*k+b*d>x:
            print(k-1)
            return
an()

Submission status: Runtime Error

Solution code:
a, b, x = [int(i) for i in input().split()]
for i in range(1,10):
  n = (x-b*i)/float(a)
  if n<0:
    if i==9:
      print(0)
    continue
  if len(str(int(n)))==i:
    print(int(n)-1)
    break
  elif i==9:
    print(10**9)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
S = input()
N0 = 2**(N+1).bit_length()
INF = 2**31-1

# k番目の要素をxに更新
def update(k, x, data):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

# [l,r)の最小値
def query(l, r, data):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s



data1 = [INF]*(2*N0)
update(0,0,data1)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(n-M+1,n+1,data1)+1,data1)

S = S[::-1]
data2 = [INF]*(2*N0)
update(0,0,data2)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(n-M+1,n+1,data2)+1,data2)

cost1 = [INF]*(N+1)
cost2 = [INF]*(N+1)
for n in range(N+1):
    cost1[n] = query(n,n+1,data1)
    cost2[n] = query(N-n,N-n+1,data2)

ans = []
cost = 0
for n in range(N+1):
    if cost != cost1[n] and cost1[n]+cost2[n]==cost1[N]:
        ans.append(n)
        cost = cost1[n]
ans = [0]+ans
for i in range(len(ans)-2,-1,-1):
    ans[i+1] = ans[i+1]-ans[i]

ans = ' '.join([str(c) for c in ans[1:]])
if cost2[0]==INF:
    ans = '-1'
print(ans)

Submission status: Runtime Error

Solution code:
a,b,x = list(map(int,input().split()))
if a*10**9+b*10 <= x:
  print(10**9)
elif a+b > x:
  print(0)
else:
  for i in range(9,0,-1):
    y = (x - i*b)//a
    if len(str(y))==i:
      print(max(0,y))
      break
  else:
    print(0)

Submission status: Runtime Error

Solution code:
a,b,x = list(map(int,input().split()))
if a*10**9+b*10 <= x:
  print(10**9)
elif a+b > x:
  print(0)
else:
  for i in range(9,0,-1):
    y = (x - i*b)//a
    if len(str(y))==i:
      if y<0:
        continue
      print(y)
      break
  else:
    print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

print(S.translate(str.maketrans(alphabet, alphabet[N:] + alphabet[:N])))

Submission status: Runtime Error

Solution code:
a, b, x = [int(i) for i in input().split()]
for i in range(1,10):
  n = (x-b*i)/float(a)
  if n<0:
    if i==9:
      print(0)
    continue
  if len(str(int(n)))==i:
    print(int(n)+1)
    break
  elif i==9:
    print(10**9)

Submission status: Runtime Error

Solution code:
S = str(input())
if S = "SUN":
    print(7)
if S = "MON":
    print(6)
if S = "TUE":
    print(5)
if S = "WED":
    print(4)
if S = "THU":
    print(3)
if S = "FRI":
    print(2)
if S = "SAT":
    print(1)

Submission status: Runtime Error

Solution code:
a, b, x = [int(i) for i in input().split()]
for i in range(1,10):
  n = (x-b*i)/float(a)
  if n<0:
    if i==9:
      print(0)
    continue
  if len(str(int(n)))==i:
    print(int(n))
    break
  elif i==9:
    print(10**9)

Submission status: Runtime Error

Solution code:
s=input()
if s='SUN':
    print(7)
elif s='MON':
    print(6)
elif s='TUE':
    print(5)
elif s='WED':
    print(4)
elif s='THU':
    print(3)
elif s='FRI':
    print(2)
elif s='SAT':
    print(1)

Submission status: Runtime Error

Solution code:
def main():
    A, B, X = list(map(int, input().split()))
    if A >= X or B >= X:
        N = 0
    elif X > 1e9 and afford(A, B, 1e9, X):
        N = int(1e9)
    else:
        limmin = 0
        limmax = 10 ** 9 + 1
        while limmax - limmin > 1:
            m = (limmax + limmin) // 2
            if afford(A, B, m, X):
                limmin = m
            else:
                limmax = m
        N = limmin
    print(N)


def afford(a, b, n, x):
    y = a * n + b * len(str(n))
    return y <= x


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
s=(input())
if s='SUN':
    print(7)
elif s='MON':
    print(6)
elif s='TUE':
    print(5)
elif s='WED':
    print(4)
elif s='THU':
    print(3)
elif s='FRI':
    print(2)
elif s='SAT':
    print(1)

Submission status: Runtime Error

Solution code:
A,B,X = map(int, input().split())
# 整数Nにたいして値段PはP=A*N + B*d(N), P<Xとなる最大のNを求める.ただしN<10**9以下となる
#d(N)に対して探索してみる
ketasu = 20
while True:
    if ketasu == 0:  # なんにもかえない場合
        n=0
        break
    Bdn = ketasu * B
    min_num = 1*10**(ketasu-1)
    min_P = min_num * A + Bdn
    if min_P > X:
        ketasu -= 1
        continue
    else:  # Xで買える桁数
        n = (X-Bdn) // A
        if n == 10**ketasu:  # 10**ketasu 
            n -= 1
        break
if n>10**9:
    print(10**9)
else:
    print(n)

Submission status: Runtime Error

Solution code:
su,keta,yosa=map(int,input().split())
if yosa<(su+keta):print(0);exit()
i=1
while su*(10**i)+keta*(i+1)<=yosa and i<10:
  i+=1
if i==10:print(10**9);exit()
f=(yosa-i*keta)//su
for j in range(f+3)[::-1]:
  if  j*su+keta*i<=yosa and len(str(j))==i:
    print(j)
    break

Submission status: Runtime Error

Solution code:
import math
a, b, x = map(int, input().split())
tmp = 0
for i in range(10, 0, -1):
  if a * (10**(i-1)) + b * i <= x:
    tmp = i
    break
if tmp >= 10:
  print(1000000000)
  exit()
if tmp == 0:
  print(0)
  exit()
ans = 0
ans = math.floor((x-b*tmp)/a)
if ans > 10**(tmp):
  ans = 10**(tmp)-1
print(ans)

Submission status: Runtime Error

Solution code:
a,b,x = map(int,input().split())
l = 1
r = 10**9
num = 0
b_num = 0
if 10**9*a + b*9 <= x:
  print(10**9)
elif a+b > x:
  print(0)
else:
  while 1:
    num = (l+r)//2
    if r - l == 1:
      c = [l*a+len(str(l))*b,r*a+len(str(r))*b]
      print(r if c[1]<=x else l)
      break
    cost = a*num+b*len(str(num))
    if cost < x:
      l = num
    else:
      r = num
    b_num = num

Submission status: Runtime Error

Solution code:
a , b, x = map(int,input().split())

if x >= 1000000000:
    print(10**9)
else:
    for n in range(1,10**9):
        l = len(str(n))
        if x <= a * n + b * l:
            ans = n - 1
            break
    print(ans)

Submission status: Runtime Error

Solution code:
a, b, x = map(int, input().split())
e = False
first = True
n = 0
chk = ''

if a * 1000000000 + b * len(str(1000000000)) <= x:
    print(1000000000)
    exit()


n = int((x -(len(str(int(x // a)))*b))//a) - 1000000
if n < 0:
    n = 0
    
while e == False:
    p = a * n + b * len(str(n))
    if p <= x:
        chk = 'kaeru'
    elif p > x:
        chk += 'kaenai'
    if first == True and chk == 'kaenai':
        print(0)
        break
        
    if chk == 'kaerukaenai':
        print(n - 1)
        break
    n += 1
    first = False

Submission status: Runtime Error

Solution code:
import math
import numpy as np
def get_price(a,b,n):
    return a * n + b * int (math.log10(n) + 1)    
a, b, x = map(int,input().split(' '))
currnt_max = 0
price_range = [get_price(a,b,10 ** i) for i in range(0,10)]    
price_range = np.asarray(price_range)

start = price_range[price_range < x].argmax()
end = 10 ** (start + 1)
start = 10 ** start
if start == 10 ** 9:
    print(10 ** 9)
    exit()

for i in range(start,10**9 + 1):
    tmp = get_price(a,b,i)
    if tmp < x:
        currnt_max = i
    else:
        break
print(currnt_max)

Submission status: Runtime Error

Solution code:
[A, B, X] = list(map(int, input().split()))
keta = list(range(1, 17, 1))
retun_N = []
for d in keta:
  max_x = (X - B * d) / A
  max_x = int(max_x)
  max_ket = len(str(max_x))
  if max_ket == d:
    retun_N.append(max_x)
if len(retun_N) != 0:
  print(retun_N[-1])
else:
  print("0")

Submission status: Runtime Error

Solution code:
A, B, X = map(int, input().split())

n = int(X / A)
n = int(X / A) - B * len(str(n))

while X < A * n + B * len(str(n)):
    n -= 1

if n > 1000000000:
    n = 1000000000

if n < 0:
    n = 0

print(n)

Submission status: Runtime Error

Solution code:
def main():
    A, B, X = list(map(int, input().split()))
    if A >= X or B >= X:
        N = 0
    else:
        for d in range(len(str(X)), 0, -1):
            if d * B < X:
                break
        if d > 0:
            N = 0
            d = min(X // A, pow(10, d))
            for N in range(d, 0, -1):
                if afford(A, B, N, X):
                    break
            else:
                N = 0
        else:
            N = 0
    print(N if N < 1e9 else int(1e9))


def afford(a, b, n, x):
    c = a * n
    if c >= x:
        return False
    y = c + b * len(str(n))
    return y <= x


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
s=int(input())
if s='SUN':
    print(7)
elif s='MON':
    print(6)
elif s='TUE':
    print(5)
elif s='WED':
    print(4)
elif s='THU':
    print(3)
elif s='FRI':
    print(2)
elif s='SAT':
    print(1)

Submission status: Runtime Error

Solution code:
def main():
    A, B, X = list(map(int, input().split()))
    if A >= X or B >= X:
        N = 0
    else:
        for d in range(len(str(X)), 0, -1):
            if d * B < X:
                break
        if d > 0:
            d = min(X // A, pow(10, d))
            for N in range(d, 0, -1):
                if afford(A, B, N, X):
                    break
            else:
                N = 0
        else:
            N = 0
    print(N if N < 1e9 else int(1e9))


def afford(a, b, n, x):
    c = a * n
    if c >= x:
        return False
    y = c + b * len(str(n))
    return y <= x


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    A, B, X = map(lambda x: int(x), input().split())
    c = 1
    result = 0
    while True:
        tmp = B * c
        if (X < tmp):
            break
        if (X < A * (10 ** (c-1))):
            break

        n = (X - tmp) // A
        print(X - tmp, n)

        if (len(str(n)) == c):
            result = max(result, n)
        if (result > 1000000000):
            result = 1000000000
            break
        c += 1

    print(result)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, K=(int(i) for i in input().split())
A=[int(i) for i in input().split()]

import numpy as np
from scipy.ndimage.interpolation import shift

res=[0]*(N+1)
res[1] = A[0]
for i in range(0,len(A)):
    res[i+1] = (res[i] + A[i])%K

array=np.array(res)
ans=0

for i in range(1,N):
    ans+=((array-shift(array,i,cval=0))%K==i).sum()
print(ans)

Submission status: Runtime Error

Solution code:
a,b,x = map(int,input().split())

if(a* 1000000000 + b * len(str(1000000000)) <= x):
    print(1000000000)
    exit()

n = int(x/a)

while(True):

    if(n == 0):
        print(0)
        exit()

    if(a * n + b * len(str(n)) <= x):
        print(n)
        exit()
    else:
     n -= 1

Submission status: Runtime Error

Solution code:
# ABC 146 C
import math
input_list = list(map(int, input().split()))
a = input_list[0]
b = input_list[1]
x = input_list[2]

a_check = math.floor(x / a)
try:
    b_check = math.floor(10 ** (x/b))
except:
    b_check = 1000000000

if (a_check < 1) | (b_check < 1):
    print(0)
    exit()
elif a_check <= b_check:
    n = a_check
elif b_check <= a_check:
    n = b_check

if n > 1000000000:
    n = 1000000000
    print(n)
    exit()
    
def n_check(n_):
    if a * n_ + b * len(str(n_)) <= x:
        return True

while n_check(n) != True:
    n -= 1
    n_check(n)
print(n)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()

def shifter(n, char):
    if ((ord(char) + n) > ord('Z')):
        n = n - 26
    
    return chr(ord(char) + n)

shifted_s = ''.join([shifter(n, char) for char in list(s)])

print(shifted_s)