TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
N=int(input())
S=input()
a,i,j=0
while j<N:
  t=S[i:j]
  if t in S[j:]:
    a=max(a,len(t))
    j+=1
  else:
    i+=1
print(a)

N=int(input())
S=input()
d={}
for i in range(N):
  for j in range(i,N+1):
    now=S[i:j]
    if now in d:
      d[now]+=1
    else:
      d.setdefault(now,1)
twice={k:v for k, v in d.items() if v>=2}
v1=sorted(twice.keys(), key=len)[::-1] 
for v in v1:
    f=S.find(v)+len(v)-1
    if v in S[f:]:
        break
print(len(v))

N=int(input())
S=input()
a=i=j=0
while j<N:
  t=S[i:j]
  if t in S[j:]:
    a=max(a,len(t))
    j+=1
  else:
    i+=1
print(a)  

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
def calc_length(s: str, l1: int, l2, int, n: int) -> int:
  for i in range(1, min[l2 - l1, n - l2]):
    if s[l1 + i] != s[l2 + i]:
      return i
  return i + 1

n = int(input())
s = input()

longest = 0
for l1 in range(n - 1):
  for l2 in range(l1 + 1, n):
    if s[l1] == s[l2]:
      length = calc_length(s, l1, l2, n)
      if length > longest:
        longest = length

print(longest)

n = int(input())
s = input()

l1 = l2 = length = 0

while l2 + length < n:
  if s[l1 : l2] in s[l2:]:
    length = l2 - l1
    l2 += 1
  else:
    l1 += 1
    l2 = l1 + length + 1

print(length)

Verdicts: Runtime Error

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
S=input()
a=[0 for x in range(len(S))]

def zal(s):
  a[0]=len(s)
  i,j=1,0
  while i < a[0]:
    while i+j < a[0] and s[j]==s[i+j]:
      j+=1
    a[i]=j
    if j==0:
      i+=1
    else:
      k=1
      while i+k < a[0] and k+a[k] < j:
        a[i+k]=a[k]
        k+=1
      i+=k
      j-=k
  m=0
  for i in range(1,a[0]):
    if i >= a[i]:
      m=max(m,a[i])
  return m

m,i=0,0
while i < len(S)-1:
  m = max(m,zal(S[i:]))
  i += 1

print(m)


n=int(input())
s=input()

m,j = 0,0
for i in range(n):
  if s[j:i+1] in s[i+1:]:
    m=i-j+1
  else:
    j+= 1

print(m)


Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
n=int(input())
s=input()

len_s = len(s)
max_match = 0
for i in range(0, len_s):
    for j in range( len_s-2, i, -1 ):
        if s[i:j] in s[i+1:]:
            if len(s[i:j]) > max_match:
                max_match = len(s[i:j])
            break

print(max_match)
    

N=int(input())
S=input()
a=i=j=0
while j<N:
  if j-i > N-j:
      break  

  t=S[i:j]
  if t in S[j:]:
    a=max(a,len(t))
    j+=1
  else:
    i+=1
print(a)  

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
class RollingHash():
    def __init__(self,s):
        self.n=n=len(s)
        self.b=b=129
        self.M=M=2**61-1
        x,y=1,0
        self.f=f=[x]*(n+1)
        self.h=h=[y]*(n+1)
        for i,c in enumerate(s.encode()):
            f[i+1]=x=x*b%M
            h[i+1]=y=(y*b+c)%M
    def get(self,l,r):
        return(self.h[r]-self.h[l]*self.f[r-l])%self.M
def check(x):
    d={}
    for i in range(0,n-x+1):
        k=s.get(i,i+x)
        if k in d:
            if d[k]+x<=i:
                return True
        else:
            d[k]=j
    return False
n=int(input())
s=RollingHash(input())
ok,ng=0,n
while ng-ok>1:
    mid=ok+ng>>1
    if check(mid):
        ok=mid
    else:
        ng=mid
print(ok)

n,s=open(0);a=i=j=0
while j<1e7:f=s[i:j]in s[j:];a=max(a,j*f-i);j+=f;i+=f^1
print(a)

n,s=open(0);a=i=j=0
while j<3e7:f=s[i:j]in s[j:];a=max(a,j*f-i);j+=f;i+=f^1
print(a)

n,s=open(0);a=i=j=0
while j<int(n):
 if s[l:j]in s[j:]:a=max(a,j-i);j+=1
 else:i+=1
print(a)

def main():
    import sys
    input=sys.stdin.buffer.readline
    n=int(input())
    b,M=37,998244353
    x,y=1,0
    f,h=[1],[0]
    f_add,h_add=f.append,h.append
    for c in input():
        x=x*b%M
        f_add(x)
        y=(y*b+c)%M
        h_add(y)
    ok,ng=0,n//2+1
    while ng-ok>1:
        mid=ok+ng>>1
        d={}
        for i in range(n-mid+1):
            k=(h[i+mid]-h[i]*f[mid])%M
            if k in d:
                if d[k]+mid<=i:
                    ok=mid
                    break
            else:
                d[k]=i
        else:
            ng=mid
    print(ok)
main()

Verdicts: Runtime Error

Time Limit Exceeded

Time Limit Exceeded

Runtime Error

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
import sys,collections as cl,bisect as bs , heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k][0] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if kkk in se:
            if se[kkk][j] <= i-n:
                    return True
        else:
            se[kkk] = i
    return False


n = onem()

s = list(input())
l = 0
r = n//2
while True:
    mid = -(-(l+r)//2)
    ans = search(s,mid)
    if l == mid:
        break
    if ans:
        l = mid
    else:
        r = mid-1
print(l)


import sys,collections as cl,bisect as bs , heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k][0] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if kkk in se:
            if se[kkk] <= i-n:
                    return True
        else:
            se[kkk] = i
    return False


n = onem()

s = list(input())
l = 0
r = n//2
while True:
    mid = -(-(l+r)//2)
    ans = search(s,mid)
    if l == mid:
        break
    if ans:
        l = mid
    else:
        r = mid-1
print(l)


Verdicts: Runtime Error

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
N=int(input())
s=input()

def z_naive(s):
    Z = [len(s)]
 
    for k in range(1, N):
        n = 0
        while n + k < len(s) and s[n] == s[n + k]:
            n += 1
        Z.append(n)
 
    return Z

print(z_naive(s))

n=int(input())
s=input()
a=i=j=0
while j<n:
  t=s[i:j]
  if t in s[j:]:
    a=max(a,j-i)
    j+=1
  else:
    i+=1
print(a)



Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
N = int(input())
S = str(input())
#N = 13
#S = "strangeorange"

lb = 3
ub = N //2 + 1
flag = False
while (ub - lb > 1):
    mid = (lb + ub) // 2
    s = set()
    for i in range(N - 2*mid + 1):
        s.add(S[mid+i:2*mid+i])
        for j in range(i+1):
            if S[j:j+mid] in s:
                flag = True
                break
            else:
                flag = False
    if flag == True:
        lb = mid
    else:
        ub = mid
print(lb)     

N = int(input())
S = str(input())
 
lb = 0
ub = N //2 + 1
while (ub - lb > 1):
    mid = (lb + ub) // 2
    s = []
    for i in range(N - 2*mid + 1):
        s.append(S[mid+i : 2*mid + i])
    if S[i:i+mid] in s:
        flag = True
        break
    else:
        flag = False
        s.pop(0)
    
    if flag == True:
        lb = mid
    else:
        ub = mid
print(lb)

N = int(input())
S = str(input())
#N = 13
#S = "strangeorange"

lb = 0
ub = N //2 + 1
flag = False
while (ub - lb > 1):
    mid = (lb + ub) // 2
    s = set()
    for i in range(N - 2*mid + 1):
        s.add(S[i:mid+i])
        if S[mid+i:i+2*mid] in s:
            flag = True
            break
        else:
            flag = False
    if flag == True:
        lb = mid
    else:
        ub = mid
print(lb)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
n1 = int(input())
s1 = input()

r1 = 0
for i1 in range (n1):
    for i2 in range(((n1 - i1) // 2) - r1):
        t2 = r1 + i2
        if s1[i1:i1 + t2] in s1[i1 + t2:] and s1[i1:i1 + t2] != "":
            r1 += 1
            continue
        else:
            break
print(r1)

n1 = int(input())
s1 = input()

r1 = 0
r2 = 0
for i1 in range (n1):
    if n1 - (r1 * 2) - i1 < 0:
        break
    for i2 in range(n1 - r1):
        t2 = r1 + i2 + 1
        if s1[i1:i1 + t2] in s1[i1 + t2:] and s1[i1:i1 + t2] != "":
            continue
        else:
            r1 = max(r1, r1 + i2)
            break


print(r1)


Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):

#Z-Algorithm
n = int(input())
s = input()
 
a = ""
ans = 0
for i in range(n):
    a += s[i]
    while(len(a) > 0):
        if a in s[i+1:]:    
            ans = max(ans,len(a))
            break
        else:               
        a = a[1:]
print(ans)


#Z-Algorithm
n = int(input())
s = input()
 
a = ""
ans = 0
for i in range(n):
    a += s[i]
    while(len(a) > 0):
        if a in s[i+1:]:    
            ans = max(ans,len(a))
            break
        else:               
            a = a[1:]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
N = int(input())
s = str(input())
maxlen = N//2

def solve(tgt):
    for i in range(N-tgt*2+1):
        src = s[i:i+tgt]
        if src in s[i+tgt:]:
            return True
    return False

ng = maxlen + 1
ok = 0
while np.abs(ok-ng) > 1:
    tgt = (ok+ng)//2
    if solve(tgt):
        ok = tgt
    else:
        ng = tgt
print(ok)


from collections import defaultdict as dd
N = int(input())
s = str(input())
maxlen = N//2

def solve(tgt):
    dic = dd(int)
    st = s[tgt:2*tgt]
    dic[st] += 1
    ls = [st]
    for char in s[2*tgt:]:
        st = st[1:]+char
        dic[st] += 1
        ls.append(st)
    st = s[:tgt]
    if dic[st] > 0:
        return True
    dic[ls[0]] -= 1
    for i,char in enumerate(s[tgt:N-tgt]):
        st = st[1:]+char
        if dic[st] > 0:
            return True
        dic[ls[i+1]] -= 1
    return False

ng = maxlen + 1
ok = 0
while ng-ok > 1:
    tgt = (ok+ng)//2
    if solve(tgt):
        ok = tgt
    else:
        ng = tgt
print(ok)


Verdicts: Runtime Error

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

def get_keys_from_value(d, val):
    return [k for k, v in d.items() if v == val]

n = INT()
s = input()

a=0
i=0
j=1

while j<n:
    print(s[i:j],s[j:])
    if s[i:j] in s[j:]:
        a = max(a,len(s[i:j]))
        j+=1
    else:
        i+=1
    if i==j:
        i+=1
        j+=2

print(a)

import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
s = input()

a=0
i=0
j=1

while j<n:
    if s[i:j] in s[j:]:
        a = max(a,len(s[i:j]))
        j+=1
    else:
        i+=1
    if i==j:
        i+=1
        j+=2

print(a)

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
import random
from collections import defaultdict
from itertools import accumulate
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
mod = (1<<61)-1
base = 1000+random.randint(0,100)
power = [1]
for i in range(1,n):
  power.append((power[-1]*base)%mod)
hvalue = [0]
for i in range(n):
  hvalue.append((hvalue[-1]+(ord(s[i])*power[i]))%mod)
def rollinghash(l,r):
  return ((hvalue[r]-hvalue[l])*power[n-r])%mod
def pun(i):
  dc = defaultdict(int)
  if i>n//2:
    return False
  for j in range(n-i+1):
    x = rollinghash(j,i+j)
    if dc[x]:
      rg =dc[x]
      if rg<=j:
        return True
      else:
        dc[x] = i+j
  return False
l=0
r=n//2+1
while l+1<r:
  mi=(l+r)//2
  if pun(mi):
    l=mi
  else:
    r=mi
print(l)


import random
from collections import defaultdict
from itertools import accumulate
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
mod = (1<<61)-1
base = 1000+random.randint(0,100)
power = [1]
for i in range(1,n):
  power.append((power[-1]*base)%mod)
hvalue = [0]
for i in range(n):
  hvalue.append((hvalue[-1]+(ord(s[i])*power[i]))%mod)
def rollinghash(l,r):
  return ((hvalue[r]-hvalue[l])*power[n-r])%mod
def pun(i):
  dc = defaultdict(int)
  if i>n//2:
    return False
  for j in range(n-i+1):
    x = rollinghash(j,i+j)
    if dc[x]:
      rg =dc[x]
      if rg<=j:
        return True
    else:
      dc[x] = i+j
  return False
l=0
r=n//2+1
while l+1<r:
  mi=(l+r)//2
  if pun(mi):
    l=mi
  else:
    r=mi
print(l)


Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
N = int(input())
S = input()

ans = 0
for i in range(N):
  j_start = ans + 1
  j_end = (N - i) // 2
  for j in range(j_start, j_end):
    base = S[i:i+j]
    if base in S[i+j:]:
      ans = max(ans, j)


print(ans)

N = int(input())
S = input()

ans = 0
for i in range(N):
  j_start = ans + 1
  for j in range(j_start, N-i):
    base = S[i:i+j]
    if base in S[i+j:]:
      ans = max(ans, j)
    else:
      break


print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
import collections
n=int(input())
s=input()
ans=0
d=collections.defaultdict(int)
for i in range(n):
  t=0
  for j in range(i,n):
    t+=(ord(s[j])-97)*(10**(j-i))
    if 0<d[t]<i and j-i+1>ans:
      ans=j-i+1
    elif d[t]==0 and i+2*(j-i+1)<=n:
      d[t]=j
    
print(ans)


import collections
mod=10**9+7
base=37
n=int(input())
S=list(ord(s)-96 for s in input())
B=[0]*(n+1)
B[0]=1
for i in range(n):
  B[i+1]=(B[i]*base)%mod

def chk(x):
  ret=False
  h=0
  bx=B[x]
  d=collections.defaultdict(int)
  for i in range(x):
    h=(h*base+S[i])%mod
  d[h]=x
  for i in range(x,n):
    h=(h*base+S[i]-S[i-x]*bx)%mod
    if d[h]==0:
      d[h]=i+1
    elif d[h]<=i-x+1:
      if S[d[h]-x:d[h]]==S[i-x+1:i+1]:
        ret=True
  return ret

l,r=0,n//2
while r-l>1:
  m=(l+r)//2
  if chk(m):
    l=m
  else:
    r=m
print(r if chk(r) else l)


Verdicts: Wrong Answer

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
N = int(input())
S = input()

left = 0
right = 1
max_length = 0

while left < N:
    if right - left > N - right:
        break
    if S[left:right] in S[right:]:
        max_length = max(max_length, len(serch_str))
        right += 1
    else:
        left += 1

print(max_length)


N = int(input())
S = input()

left = 0
right = 1
max_length = 0

while left < N:
    if right - left > N - right:
        break
    serch_str = S[left:right]
    if serch_str in S[right:]:
        max_length = max(max_length, len(serch_str))
        right += 1
    else:
        left += 1

print(max_length)

Verdicts: Runtime Error

Accepted
Problem: Given is a string S of length N.  Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.  More formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the following:    * l_1 + len \leq l_2    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)  If there is no such integer len, print 0.

Submission attempts (in order):
N = int(input())
S = input()

ans = 0
left, right = 0, 1

while right < N:
    s = S[left:right]
    if s in S[right:]:
        right += 1
        ans = max(ans, len(s))
    else:
        left = right - 1

print(ans)


N = int(input())
S = input()

ans = 0


for i in range(0, N - 3):
    for j in range(i + 2, N):
        if S[i:i + 1] == S[j:j + 1]:
            i, j = i + 1, j + 1
            length, max_length = 2, j
            while True:
                if i + 1 == max_length or j + 1 == N:
                    break
                else:
                    i, j = i + 1, j + 1
                    if S[i] == S[j]:
                        length += 1
                    else:
                        break
            if length > ans:
                ans = length


if ans == 0:
    for i in range(N - 1):
        s = S[i]
        if s in S[i + 1:]:
            ans = 1

print(ans)


N = int(input())
S = input()

ans = 0
left, right = 0, 1

while right < N:
    s = S[left:right]
    if s in S[right:]:
        right += 1
        ans = max(ans, len(s))
    else:
        left += 1

print(ans)


Verdicts: Time Limit Exceeded

Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a,b=map(int,input().split())
ans=0
for i in rnage(0,b,a-1):
  ans+=1
print(ans+1)

a,b=map(int,input().split())
ans=1
for i in range(a,b,a-1):
  ans+=1
print(ans+1)

a,b=map(int,input().split())
ans=0
plag=0
while plag<b:
  ans+=1
  plag=plag+a-1
print(ans)

a,b=map(int,input().split())
ans=0
plag=0
while plag<b:
  ans+=1
  plag+=a-1
print(ans)

a,b=map(int,input().split())
ans=0
for i in range(1,b,a-1):
  ans+=1
print(ans)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a, b = map(int, input().split())
ans = a
count = 1
if b = 0 :
  count = 0
elif a >= b :
  count = 1
else :
  while True :
    count += 1
    ans += (a-1)
    if b <= ans:
      break
  
print(count)

a, b = map(int, input().split())
ans = a
count = 1
if b = 1 :
  count = 0
elif a >= b :
  count = 1
else :
  while True :
    count += 1
    ans += (a-1)
    if b <= ans:
      break
  
print(count)

a, b = map(int, input().split())
ans = a
count = 1
if b == 1 :
  count = 0
elif a >= b :
  count = 1
else :
  while True :
    count += 1
    ans += (a-1)
    if b <= ans:
      break
  
print(count)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a, b = map(int, input().split())
current = 1
nums = 0

while True:
  if b <= current:
    print(nums)
    exit(0)
  current += (a - 1)

a, b = map(int, input().split())
current = 1
nums = 0

while True:
  if b <= current:
    print(nums)
    exit(0)
  current += (a - 1)
  nums += 1


Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
A,B=map(int,input().split())

cnt = 0
  
for i in range(1,A+1):
  if ((A-1)+A)*i <= B+(A-1):
    cnt += 1
    
print(cnt)

A,B=map(int,input().split())

cnt = 0
  
for i in range(1,A):
  if i * A <= B:
    cnt += 1
    
print(cnt)

A,B=map(int,input().split())
x=0
cnt=1

while(cnt < B):
  cnt -= 1
  cnt += A
  x += 1
    
print(cnt)

A,B=map(int,input().split())
x=0
cnt=1
 
while(cnt < B):
  cnt -= 1
  cnt += A
  x += 1
    
print(x)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
A, B = (int(x) for x in input().split())

S = A
num  = 0
i = 0

while(S < B):
    i += 1
    A = A * 2
    S = A - i
    num += 1

print(num)

A, B = (int(x) for x in input().split())

S = A
num  = 1
i = 1

if (B == 1):
    print("0")
elif (A >= B):
    print("1")
else:
    while(S < B):
        S = (A * (i + 1)) - i
        num += 1
        i += 1
    print(num)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a, b=map(int,input().split())
if 1<=b<=a+1:
    print(1)
else:
    print((b-2)//a)

import math
a, b=map(int,input().split())
print(math.ceil((b-1)/(a-1)))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
A, B = map(int, input().split())

a = A
num = 1

while True:
    if a >= B:
        break
    a += A
    a -= 1
          
    num += 1
print(a, num)


A, B = map(int, input().split())

a = 1
num = 0

while a < B:
    a += (A-1)
    num += 1

print(num)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a,b=map(int,input().split())
if b%a>0:print(b//a+1)
elif a=b:print(1)
else:print(b//a)

a,b=map(int,input().split())
if b>a:if b%a>0:print(b//a+1)
elif b<=a:print(1)
else:print(b//a)

a,b=map(int,input().split())
if (b-1)%(a-1)>0:
  print((b-1)//(a-1)+1)
if (b-1)%(a-1)==0:
  print((b-1)//(a-1))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a,b = map(int,input(),split())
n = 1
c = 0
while n < b:
    n += a-1
    c += 1
print(c)

a,b = map(int,input().split())
n = 1
c = 0
while n < b:
    n += a-1
    c += 1
print(c)


Verdicts: Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
import math

a = input()
b = input()

answer = math.ceil((b-1)/(a-1))
print(answer)

import math

a, b = (int(i) for i in input().split())  

 
answer = math.ceil((b-1)/(a-1))
print(answer)

Verdicts: Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
t=int(input())
d=int(input())
c=d//t
f=c/t
if f!=c:
  c+=1
print(c)

import math
a,b=map(int,input().split())
print(math.ceil((b-1)/(a-1)))

Verdicts: Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
# coding: utf-8

a, b = map(int, input().split())
ans = 0
i = 1
while i < b:
    i -= 1
    i += a
    ans = i
print(ans)


# coding: utf-8

a, b = map(int, input().split())
ans = 0
i = 1
while i < b:
    i -= 1
    i += a
    ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a,b=map(int,input().split())
for i in range(1000000):
  if a*i-i+1>=b:
    print(i)

n,k=map(int,input().split()) ; i=0
for q in range(1,364187,n-1):
    if q>=k:
        print(i)
        exit()
    i+=1


Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
import math

A,B = map(int,input().split())

print(math.ceil(B-A/A-1)+1)



import math

A,B = map(int,input().split())

print(math.ceil(B-A/A-1)+1)



import math

A,B = map(int,input().split())

print(math.ceil(B-1/A-1)+1)



import math

A,B = map(int,input().split())

print(math.ceil((B-A)/(A-1))+1)



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
import math
A, B = map(int, input().split())

if B> A:
	print(math.ceil((B-1)//(A-1))
  
else:
	print(1)

import math
A, B = map(int, input().split())

print(math.ceil((B-1)/(A-1)))

Verdicts: Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a, b = [int(x) for x in input().split()]

r = 1
cnt = 0
while r < b:
	cnt += 1
	r = r * a

print(cnt)

a, b = [int(x) for x in input().split()]

r = a
cnt = 1
while r < b:
	cnt += 1
	r = r * a

print(cnt)

a, b = [int(x) for x in input().split()]

if b == 1:
	print(0)
else:
	r = a
	cnt = 1
	while r < b:
		r += (a-1)
		cnt += 1
	print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
A_B = input().split()
print(-(-int(A_B[1])//(int(A_B[0])-1)))



A_B = input().split()
print((int(A_B[1])-1)//int(A_B[0]))

A_B = input().split()
print(-(-(int(A_B[1])-1)//(int(A_B[0])-1)))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
nums = list(map(int,input().split()))

result = 0
count = 1
while(True):
    if nums[1] >= 1:
        break
    count -= 1
    count += nums[0]
    result += 1
    if nums[1] <= count:
        break
print(result)

nums = list(map(int,input().split()))

result = 0
count = 1
while(True):
    if nums[1] <= 1:
        break
    count -= 1
    count += nums[0]
    result += 1
    if nums[1] <= count:
        break
print(result)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a_b = list(map(int, input()))
i=1
sum = a_b[0]
if sum<=a_b[1]:
	for sum>=a_b[1]:
		sum+=a_b[0]-1
		i++
print(i)

a,b = map(int, input().split())
i=0
sum = 1

while sum<b:
	sum+=a-1
	i+=1
print(i)


Verdicts: Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
A,B=map(int,input().split())
print(round(B/A))

A,B=map(int,input().split())
if B==1:
  print(0)
  exit()
for i in range(20):
  if (i+1)*A-i>=B:
    break
print(i+1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
def main():
    import copy
    a, b = map(int, input().split())
    
    times = copy.copy(a)
    num = 1

    while a <= b:
        num = num + 1
        a = a + times - 1

    print(num)
    

main()

def main():
    import copy
    a, b = map(int, input().split())
    
    times = copy.copy(a)
    num = 1

    while a < b:
        num = num + 1
        a = a + (times * num) - 1
    
    print(num)
    

main()

def main():
    import copy
    a, b = map(int, input().split())
    
    ans = 0
    outlet = 1
    while outlet < b:
        outlet = outlet - 1
        outlet = outlet + a
        ans = ans + 1
    
    print(ans)
    

main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a,b = map(int, input().split())  
t = a
res = 1
while 1:
  if a *(res -1) < b:
    t = t + a
    res = res + 1
    print(a,"個口を",res,"つ使うと未使用は、",a *(res -1))
  else:
    break
print(res - 1)
    
    

    


a,b = map(int, input().split())  
res = 1
while 1:
  if a *res - (res -1 ) =< b:
    res = res + 1
    
  else:
    break
print(res)
    
    

    


a,b = map(int, input().split())  
res = 1
while 1:
  if a *res - (res -1 ) < b:
    res = res + 1
    print(a,"個口を",res,"つ使うと未使用は、",a *res - (res -1 ))
  else:
    break
print(res)
    
    

    


a,b = map(int, input().split())  
res = 1
while 1:
  if a *(res -1) < b:
    res = res + 1
    print(a,"個口を",res,"つ使うと未使用は、",a *(res -1))
  else:
    break
print(res)

a,b = map(int, input().split())  
res = 1
while 1:
  if a *(res -1) < b:
    res = res + 1
    
  else:
    break
print(res)

a,b = map(int, input().split())  
res = 1
while 1:
  if a *res - (res -1 ) < b -1 :
    res = res + 1
    print(a,"個口を",res,"つ使うと未使用は、",a *res - (res -1 ))
  else:
    break
print(res)
    
    

    


a,b = map(int, input().split())  
t = a
res = 1
while 1:
  if a *(res -1) < b:
    t = t + a
    res = res + 1
    print(a,"個口を",res,"つ使うと未使用は、",a *(res -1))
  else:
    break
print(res)
    
    

    


a,b = map(int, input().split())  
res = 1
while 1:
  if a *res - (res -1 ) < b +1 :
    res = res + 1
    print(a,"個口を",res,"つ使うと未使用は、",a *res - (res -1 ))
  else:
    break
print(res)
    
    

    


a,b = map(int, input().split())  
res = 1
while a *res - (res -1 ) < b:
    res = res + 1
    print(a,"個口を",res,"つ使うと未使用は、",a *res - (res -1 ))
    if a *res - (res -1 ) >= b:
      break
print(res)
    
    

a,b = map(int, input().split())  
res = 1
while 1:
  if a *res - (res -1 ) < b:
    res = res + 1
    print(a,"個口を",res,"つ使うと未使用は、",a *res - (res -1 ))
  else:
    break
print(res)
    
    

    

    


a,b = map(int, input().split())
res = 1
if b == 1:
    print(0)
    exit(0)
while a *res - (res -1 ) < b  :
 res = res + 1
 
print(res)



Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
import math
A,B=map(int,input().split())
c=0
if A%B!=0:
    c=1
print(A+c)

A,B=map(int,input().split())
s=1
cut=0
while B>=s:
    cut+=1
    s=s+A-1
print(cut)

A,B=map(int,input().split())
c=A
while c<=B:
  c=c+A-1
print(c)


A,B=map(int,input().split())
c=A
while c>=B:
  c=c-1+A
print(c)

A,B=map(int,input().split())
cut=0
while B>=A:
    cut+=1
    A+=A-1
print(cut)

A,B=map(int(input().split())
c=A
x=1
while c<B:
        c=c-1+A
        x+=1
print(x)

import math
A,B=map(int,input().split())
print(math.ceil(A/B))


A,B=map(int,input().split(' '))
k=1
c=A
while c<=B:
  c=c+A-1
  k+=1
print(k)

A,B=map(int,input())
c=0
if B%A!=0:
  c=1
print(B+c)

A,B=map(int,input().split())
s=1
cut=0
while B>s:
    cut+=1
    s=s+A-1
print(cut)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
B = int(s[1])
 
sum = A
cnt = 1
flg = True
 
while flg:
  if B ==0 or B == 1:
    cnt = 0
    break
  if sum >= B:
    break
  sum += A -1
  cnt += 1
 
print(cnt)

s = input().rstrip().split(' ')
A = int(s[0])
B = int(s[1])
 
sum = A
cnt = 1
flg = True
 
while flg:
  if B ==0 or B == 1:
    cnt = 0
    break
  if sum >= B:
    break
  sum += A -1
  cnt += 1
 
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a,b=map(int,input().split())
tmp=a
count=1
while tmp<=b:
  tmp+=a-1
  count+=1
print(count)

a,b=map(int,input().split())
tmp=a
count=1
while tmp<b:
  tmp+=a-1
  count+=1
if 1==b:
  print(0)
else:
  print(count)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
A, B = map(int, input().split())

for i in range(1, 20):
  c = (A-1)*(i-1) + A
  if C >= B:
    break
    
print(i)

A, B = map(int, input().split())

for i in range(1, 20):
  if B > 1:
    c = (A-1)*(i-1) + A
    if c >= B:
      break
  else:
    i = 0
    break

print(i)

Verdicts: Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
import math
a,b = map(int,input().split())
print(math.ceil((b-a/a)))

a,b = map(int,input().split())
n = 0

while (n*a -(n-1) < b):
  n += 1
  
print(n)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a,b = map(int(input().split()))
s = -(-b// a)
print(s)

a,b = map(int,input().split())
if b/a == 1:
  print(1)
else:
  print(-(-b//(a-1)))

a,b = map(int,input().split())
if b/a == 1:
  print(1)
else:
  print(-(-b/(a-1)))
  

a,b = map(int,input().split())
print(-(-(b-1)//(a-1)))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
A, B=map(int, input().split())
a=(B-1)/(A-1)
b=(B-1)//(A-1)
if a==b:
    print(a)
else:
	print(b+1)

A,B=map(int,input())
if (B-1)/(A-1)==(B-1)//(A-1):
	print((B-1)/(A-1))
else:
	ptint((B-1)//(A-1)+1)

A, B=map(int, input().split())
a=(B-1)/(A-1)
b=(B-1)//(A-1)
if a==b:
    print(a)
else:
	print(b+1)

A, B=map(int, input().split())
if (B-1)/(A-1)==(B-1)//(A-1):
	print((B-1)/(A-1))
else:
	ptint((B-1)//(A-1)+1)

A, B=map(int, input().split())
a=(B-1)/(A-1)
b=(B-1)//(A-1)
if a==b:
    print(a)
else:
	print(b+1)

A, B=map(int, input().split())
a=(B-1)/(A-1)
b=(B-1)//(A-1)
if a==b:
    print(b)
else:
	print(b+1)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
A,B = map(int, input().split())
print(1+B//(A-1))

A,B = map(int, input().split())
if B==1:
  print(0)
else if B<A:
  print(1)
else:
  print(B//(A-1))

import math
A,B = map(int, input().split())
print(math.ceil((B-1)/(A-1)))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
import sys
a,b=map(int,input().split())
if b=1:
  print("0")
  sus.exit()
p=1
ans=0
for i in range(0,20):
  p+=a-1
  ans+=1
  if p>=b:
    print(ans)
    sys.exit()

import sys
a,b=map(int,input().split())
if b==1:
  print("0")
  sys.exit()
p=1
ans=0
for i in range(0,20):
  p+=a-1
  ans+=1
  if p>=b:
    print(ans)
    sys.exit()

Verdicts: Runtime Error

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a, b = map(int, input().split())
cnt = 0
while a < b:
    a += a
    cnt += 1
print(cnt)

a, b = map(int, input().split())
cnt = 1
soc = 1
while soc < b:
    soc += a - 1
    cnt += 1
print(cnt)

a, b = map(int, input().split())
m = 1
cnt = 0
while m < b:
    m += a-1
    cnt += 1
print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi's house has only one socket.  Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.  One power strip with A sockets can extend one empty socket into A empty sockets.  Find the minimum number of power strips required.

Submission attempts (in order):
a, b = map(int, input().split())
  
from math import ceil
ans = ceil((b - a)/ (a - 1))
  
print(ans)


a, b = map(int, input().split())
  
from math import ceil
ans = int(ceil((b - a)/ (a - 1)))
  
print(ans)

a, b = map(int, input().split())
  
from math import ceil
ans = int(ceil((b - a)/ (a - 1)))
  
print(ans + 1)

Verdicts: Wrong Answer

Wrong Answer

Accepted