TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
import numpy as np

S = input()
mod = int(10**9 + 7)
dp = np.zeros(13)
dp[0] = 1

amari = [[0]*13 for _ in range(13)]
for j in range(10):
  for i in range(13):
    amari[i][(i*10+j)%13] += 1
M = np.array(amari)

for s in range(len(S)):
    ndp = np.zeros(13)
    if s == '?':
        ndp = np.matmul(dp, M)
    else:
        d = int(s)
        for j in range(13):
            ndp[(j * 10 + d) % 13] += dp[j]
    dp = np.mod(ndp, mod)

print(dp[5])

    import numpy as np
     
    s = input()
    p = np.array([0]*13)
    p[0] = 1
     
    amari = [[0]*13 for _ in range(13)]
    for j in range(10):
      for i in range(13):
        amari[i][(i*10+j)%13] += 1
    M = np.array(amari)
     
    for si in range(len(s)):
      a = np.array([0]*13)
      if s[si] == '?':
        a = np.dot(p,M)
      else:
        c = int(s[si])
        for i in range(13):
          a[(i*10+c)%13] += p[i]
      p = np.mod(a,1000000007)
    print(p[5])

import numpy as np

S = input()
mod = int(10**9 + 7)
dp = np.zeros(13, dtype=int)
dp[0] = 1

M = np.zeros((13, 13), dtype=int)
for i in range(13):
    for d in range(10):
        M[i][(i * 10 + d) % 13] += 1

for s in S:
    ndp = np.zeros(13, dtype=int)
    if s == '?':
        ndp = np.dot(dp, M)
    else:
        d = int(s)
        for j in range(13):
            ndp[(j * 10 + d) % 13] += dp[j]
    dp = ndp % mod
    print(dp)

print(dp[5])

import numpy as np

S = input()
mod = 10**9 + 7
dp = np.zeros(13)
dp[0] = 1

M = np.zeros((13, 13))
for i in range(13):
    for d in range(10):
        M[i][(i * 10 + d) % 13] += 1

for i in range(len(S)):
    ndp = np.zeros(13)
    if S[i] == '?':
        ndp = np.matmul(dp, M)
    else:
        d = int(S[i])
        for j in range(13):
            ndp[(j * 10 + d) % 13] += dp[j]
    dp = ndp % mod
print(int(dp[5])


import numpy as np

S = input()
mod = int(10**9 + 7)
dp = np.zeros(13, dtype=int)
dp[0] = 1

M = np.zeros((13, 13), dtype=int)
for i in range(13):
    for d in range(10):
        M[i][(i * 10 + d) % 13] += 1

for s in S:
    ndp = np.zeros(13, dtype=int)
    if s == '?':
        ndp = np.dot(dp, M)
    else:
        d = int(s)
        for j in range(13):
            ndp[(j * 10 + d) % 13] += dp[j]
    dp = ndp % mod

print(dp[5])

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
r = [[(j - k) * 9 % 13 for j in range(10)] for k in range(13)]
d = [1] + [0] * 12

for c in input():
    if c == '?':
        d = [sum(d[j] for j in k) % M for k in r]
    else:
        d = [d[(int(c) - k) * 9 % 13] for k in range(13)]
    #print(d)
print(d[5])

r = [[(j - k) * 9 % 13 for j in range(10)] for k in range(13)]
d = [1] + [0] * 12

for c in input():
    if c == '?':
        d = [sum(d[j] for j in k) for k in r]
    else:
        d = [d[(int(c) - k) * 9 % 13] for k in range(13)]
    print(d)
print(d[5])

import numpy as np
S = input()

MOD = 10 ** 9 + 7
mod_change_table = [(i * 10) % 13 for i in range(13)]
dp = np.array([[0] * 13] * (len(S)))
if S[0] == '?':
    dp[0][:10] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1, len(S)):
    for j in range(13):
        if S[i] == '?':
            for k in range(10):
                dp[i][(mod_change_table[j] + k) % 13] += dp[i - 1][j]
        else:
            dp[i][(mod_change_table[j] + c) % 13] += dp[i - 1][j]
    dp[i] %= MOD
print(dp[len(S) - 1][5])

r = [[(j - k) * 9 % 13 for j in range(10)] for k in range(13)]
d = [1] + [0] * 12
M = 10 ** 9 + 7
for c in input():
    if c == '?':
        d = [sum(d[j] for j in k) % M for k in r]
    else:
        d = [d[(int(c) - k) * 9 % 13] for k in range(13)]
    #print(d)
print(d[5])

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
mod=10**9+7
r=[[(j-k)*9%13 for j in range(10)] for k in range(13)]
dp=[1]+[0]*12
for c in input():
  dp = [sum(dp[j] for j in k)%mod for k in r] if c>'9' else [dp[(int(c)-k)*9%13] for k in range(13)]
print(d[5])

s=list(input())
n=len(s)
mod=10**9 + 7
dp=[[0]*(n) for i in range(13)]

if s[n-1]=='?':
    for i in range(10):
        dp[0][i]+=1
else:
    dp[0][s[n-1]]+=1

for i in range(n-1):
    if s[n-2-i]=='?':
        for j in range(13):
            if dp[i][j]>0:
                for k in range(10):
                    dp[i+1][(j+(10**i)*k)%13]+=1
                    dp[i+1][(j+(10**i)*k)%13]%=mod
    else:
        for j in range(13):
            if dp[i][j]>0:
                dp[i+1][j+(10**i)*s[n-2-i]]+=1
                dp[i+1][j+(10**i)*s[n-2-i]]%=mod
print(dp[n-1][5]%mod)

mod=10**9+7
r=[[(j-k)*9%13 for j in range(10)] for k in range(13)]
dp=[1]+[0]*12
for c in input():
  dp = [sum(dp[j] for j in k)%mod for k in r] if c>'9' else [dp[(int(c)-k)*9%13] for k in range(13)]
print(dp[5])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
import sys
input = sys.stdin.readline

M=10**9+7
r=tuple(tuple((j-k)*9%13for j in range(10))for k in range(13))
d=[1]+[0]*12
for c in input():
    if c>'9':
      d=[sum(d[j]for j in k)%M for k in r]
    else:
      d=[d[(int(c)-k)*9%13]for k in range(13)]
print(d[5])


M=10**9+7
r=tuple(tuple((j-k)*9%13for j in range(10))for k in range(13))
d=[1]+[0]*12
for c in input():
    if c>'9':
        d=[sum(d[j]for j in k)%M for k in r]
    else:
        d=[d[(int(c)-k)*9%13]for k in range(13)]
print(d[5])

Verdicts: Runtime Error

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
def main():
  M=10**9+7
  r=tuple(tuple((j-k)*9%13for j in range(10))for k in range(13))
  d=[1]+[0]*12
  for c in input():
    d = if c>'9' [sum(d[j]for j in k)%M for k in r] else [d[(int(c)-k)*9%13]for k in range(13)]
  print(d[5])
main()

M=10**9+7
r=[[(j-k)*9%13for j in range(10)]for k in range(13)]
d=[1]+[0]*12
for c in input():
  d = [sum(d[j]for j in k)%M for k in r] if c>'9' else [d[(int(c)-k)*9%13]for k in range(13)]
print(d[5])

Verdicts: Runtime Error

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
import sys,math,copy
import numpy as np
input = sys.stdin.readline
S = [int(x) if x != '?' else -1 for x in input().strip()]
N = len(S)

dp = np.zeros((13), dtype=int)
dp_ = np.zeros((13), dtype=int)
dp_[0] = 1
mod = 1
for i, s in enumerate(S[::-1], start=1):
    if s == -1:
        for d in range(10):
            m = (d * mod) % 13
            for pm in range(13):
                dp[(pm+m)%13] = (dp[(pm+m)%13] + dp_[pm]) % (10 ** 9 + 7)

    else:
        m = (s * mod) % 13
        for pm in range(13):
            dp[(pm+m)%13] = (dp[(pm+m)%13] + dp_[pm]) % (10 ** 9 + 7)
    dp_ = dp
    dp *= 0
    mod = (mod * 10) % 13
print(dp_[5] % (10 ** 9 + 7))

import sys,math,copy

def main():
    # import numpy as np
    input = sys.stdin.readline
    S = ''.join(reversed(input().strip()))

    
    
    dp = [0] * 13
    dp_ = [0] * 13
    mod13_tuple = tuple([i % 13 for i in range(12 ** 2 + 1)])
    tuple10 = tuple(range(10))
    tuple13 = tuple(range(13))
    divisor = 10 ** 9 + 7
    dp_[0] = 1
    mul = 1
    for i in range(len(S)):
        s = S[i]
        if s == '?':
            for d in tuple10:
                m = mod13_tuple[(d * mul)]
                for pm in tuple13:
                    dp[mod13_tuple[(pm+m)]] += dp_[pm]

        else:
            si = int(s)
            m = mod13_tuple[(si * mul)]
            for pm in tuple13:
                dp[mod13_tuple[(pm+m)]] = dp_[pm]

        
        
        for j in tuple13:
            dp_[j] = dp[j] % divisor
            dp[j] = 0
        mul = mod13_tuple[(mul * 10)]
    print(dp_[5])

main()

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
#!/usr/bin/env python

import sys

s= sys.stdin.readline()
#
m0 = 0
mmap= []
for i in range(6):
    b = 10**i % 13
    mmap.append( [ (b*i)%13 for i in range(10) ] )
#
dp= [ 0 for i in range(13) ]
for i,c in enumerate(reversed(s)):
    tmp  = dp.copy()
    if i==0: tmp[0]= 1
    #
    if c=="?":
        bset = mmap[i%6][1:]
        for m in range(13):
            num= tmp[m]
            if num==0: continue
            for b in bset:
                idx= (m+b)%13
                dp[idx]+= num
    else:
        b= mmap[i%6][int(c)]
        for m in range(13):
            idx= (m+b)%13
            dp[idx]= tmp[m]
#
print(dp[5])


import sys
 
s= sys.stdin.readline().strip()
#
MOD=10**9+7
mmap= []
for i in range(6):
    b = 10**i % 13
    mmap.append( [ [ (b*i+j)%13 for i in range(1,10) ] for j in range(13) ] )
#
dp= [ 0 ] * 13
dp[0] = 1
j= 0
for c in reversed(s):
    tmp = dp.copy()
    #
    if c=="0": pass
    elif c=="?":
        bset = mmap[j]
        for m,num in enumerate(tmp):
            if num==0: continue
            for idx in bset[m]: dp[idx]+=num
        #
        for i in range(13): dp[i]%=MOD
    else:
        b= mmap[j][0][int(c)-1]
        for m in range(13):
            idx= (m+b)%13
            dp[idx]= tmp[m]
    #
    if j==5: j=0
    else: j+=1
#
print(dp[5])

Verdicts: Runtime Error

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
import sys


def main():
    s = str(input())
    l = len(s)
    ans = [0 for _ in range(13)]
    MOD = 10**9+7
    ans[0] = 1
    print(len(s))
    
    for st in s:
        dp = [0 for _ in range(13)]
        for i in range(13):
            dp[(10*i)%13] = ans[i]%MOD
        dp += dp
        if st != "?":
            for i in range(13):
                num = int(st)
                ans[i] = dp[i+13-num]
        else:
            for i in range(13):
                ans[i] = sum(dp[i+4:i+14])
    
    print(ans[5]%MOD)

if __name__ == "__main__":
    main()

import sys


def main():
    s = str(input())
    l = len(s)
    ans = [0 for _ in range(13)]
    MOD = 10**9+7
    ans[0] = 1
    
    for st in s:
        dp = [0 for _ in range(13)]
        for i in range(13):
            dp[(10*i)%13] = ans[i]%MOD
        dp += dp
        if st != "?":
            for i in range(13):
                num = int(st)
                ans[i] = dp[i+13-num]
        else:
            for i in range(13):
                ans[i] = sum(dp[i+4:i+14])
    
    print(ans[5]%MOD)

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
MOD = 10**9 + 7

def main():
    s = [int(in_i) if in_i != '?' else -1 for in_i in list(open(0).read())[:-1]]
    n = len(s)

    cnt = [0] * 13
    if s[0] == -1:
        for j in range(10):
           cnt[j] = 1
    else:
        cnt[s[0]] = 1

    for cur_s in s[1:]:
        print(cnt)
        dp = [0] * 26
        for i in range(13):
            dp[i*10%13] = cnt[i] % MOD
        dp[13:] = dp[:13]

        if cur_s == -1:
            for i in range(13):
                cnt[i] = sum(dp[i+4:i+14])
        else:
            for i in range(13):
                cnt[i] = dp[i+13-cur_s]

    ans = cnt[5] % MOD
    return()

if __name__ == '__main__':
    main()


MOD = 10**9 + 7

def main():
    s = open(0).read()[:-1][::-1]
    n = len(s)

    prev = [0] * n
    if s[0] == '?':
        for j in range(10):
            prev[j] = 1
    else:
        prev[int(s[0])] = 1

    mod13 = [1, 10, 9, 12, 3, 4]
    for i, cur_s in enumerate(s[1:], start=1):
        next = [0] * n
        if cur_s == '?':
            for j in range(10):
                remain = j * mod13[i % 6] % 13
                for k in range(13):
                    next[(k + remain) % 13] += prev[k]
        else:
            remain = int(cur_s) * mod13[i % 6] % 13
            for k in range(13):
                next[(k + remain) % 13] += prev[k]
        prev = [cur_next % MOD for cur_next in next]

    ans = prev[5] % MOD
    print(ans)
    return()

if __name__ == '__main__':
    main()


MOD = 10**9 + 7

def main():
    s = [int(in_i) if in_i != '?' else -1 for in_i in list(open(0).read())[:-1]]
    n = len(s)

    cnt = [0] * 13
    if s[0] == -1:
        for j in range(10):
           cnt[j] = 1
    else:
        cnt[s[0]] = 1

    for cur_s in s[1:]:
        dp = [0] * 26
        for i in range(13):
            dp[i*10%13] = cnt[i] % MOD
        dp[13:] = dp[:13]

        if cur_s == -1:
            for i in range(13):
                cnt[i] = sum(dp[i+4:i+14])
        else:
            for i in range(13):
                cnt[i] = dp[i+13-cur_s]

    ans = cnt[5] % MOD
    print(ans)
    return()

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
s=input()
l=len(s)
a=10**9+7
print(a)

if s[l-1]=='?':
  n=[1,1,1,1,1,1,1,1,1,1,0,0,0]
else:
  n=[0,0,0,0,0,0,0,0,0,0,0,0,0]
  n[int(s[l-1])]=1
d=[0,0,0,0,0,0,0,0,0,0,0,0,0]

m=1
for i in range(1,len(s)):
  m=(m*10)%13
  if s[l-1-i] == '?':
    for j in range(13):
      for k in range(10):
        d[(m*k+j)%13] += n[j]
  else:
    for j in range(13):
      d[(m*int(s[l-1-i])+j)%13] += n[j]

  for j in range(13):
    n[j]=d[j]%a
    d[j]=0

print(n[5])


s=input()
l=len(s)
a=10*9+7

if s[l-1]=='?':
  n=[1,1,1,1,1,1,1,1,1,1,0,0,0]
else:
  n=[0,0,0,0,0,0,0,0,0,0,0,0,0]
  n[int(s[l-1])]=1
d=[0,0,0,0,0,0,0,0,0,0,0,0,0]

m=1
for i in range(1,len(s)):
  m=(m*10)%13
  if s[l-1-i] == '?':
    for j in range(13):
      for k in range(10):
        d[(m*k+j)%13] += n[j]
  else:
    for j in range(13):
      d[(m*int(s[l-1-i])+j)%13] += n[j]

  for j in range(13):
    n[j]=d[j]%a
    d[j]=0

print(n[5])


S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
MOD = 10 ** 9 + 7


def main(s):
    reminder = [[(j - k) * 9 % 13 for j in range(10)] for k in range(13)]
    dp = [1] + [0] * 12
    for char in s:
        if char == "?":
            dp = [sum(dp[j] for j in k) % MOD for k in reminder]
        else:
            dp = [dp[(int(char) - k) * 9 % 13] for k in range(13)]
        print(dp)

    return dp[5]


S = input()
print(main(S))

MOD = 10 ** 9 + 7


def main(s):
    reminder = [[(j - k) * 9 % 13 for j in range(10)] for k in range(13)]
    dp = [1] + [0] * 12
    for char in s:
        if char == "?":
            dp = [sum(dp[j] for j in k) % MOD for k in reminder]
        else:
            dp = [dp[(int(char) - k) * 9 % 13] for k in range(13)]

    return dp[5]


S = input()
print(main(S))

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
mod = 10**9+7
s=list(input())
l=len(s)
mod=10**9+7
dp=[0]*13
dp[0] = 1
mul=1
for i in s[::-1]:
    nextDp=[0]*13
    if i=="?":
        for k in range(10):
            for j in range(13):
                nextDp[(k*mul+j)%13] += dp[j]
                nextDp[(k*mul+j)%13]%=mod
    else:
        for j in range(13):
            nextDp[(int(i)*mul+j)%13] += dp[j]
            nextDp[(int(i)*mul+j)%13]%=mod
    print(dp)
    mul *= 10
    mul%=mod
    dp = nextDp

print(dp[5])

s=input()
l=len(s)
mod=10**9+7
dp=[[0 for j in range(13)] for i in range(l+1)]
dp[0][0]=1
for i in range(l):
    if s[i]=='?':
        for j in range(10):
            for k in range(13):
                dp[i+1][(k*10+j)%13]+=dp[i][k]%mod
    else:
        for k in range(13):
            dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]%mod
print(dp)
print(dp[-1][5]%mod)


MOD = 10**9 + 7
S = input()
 
cur = [0] * 13
cur[0] = 1
r = 1
base = 0
for i in range(len(S)):
    s = S[-(i+1)]
    if s == '?':
        prev = cur
        cur = [sum(prev)] * 13
        for m in range(13):
            for d in range(10,13):
                cur[(m + r*d) % 13] -= prev[m]
        for m in range(13):
            cur[m] %= MOD
    else:
        base = (base + r*int(s)) % 13
 
    r = (10 * r) % 13
 
print(cur[(5-base) % 13])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.  Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.  Since the answer can be enormous, print the count modulo 10^9+7.

Submission attempts (in order):
import numpy as np
a0 = np.array([1,1,1,1,1,1,1,1,1,1,0,0,0])
print(a0[10])

s = str(input())
mod = 10**9 + 7
n = len(s)

if s[0] == "?":
  ans = [1,1,1,1,1,1,1,1,1,1,0,0,0]
else:
  ans = [0,0,0,0,0,0,0,0,0,0,0,0,0]
  ans[int(s[0])] = 1


for i in s[1:]:
  dp = [0]*13
  for j in range(13):
    dp[j*10%13] = ans[j] % mod
  dp += dp
  if i == "?":
    for j in range(13):
      ans[j] = sum(dp[j+4:j+14])
  else:
    for j in range(13):
      ans[j] = dp[j+13-int(i)]
print(ans[5]%mod)

Verdicts: Wrong Answer

Accepted
Problem: We have a sequence of N \times K integers: X=(X_0,X_1,\cdots,X_{N \times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\cdots,A_{N-1}). For each pair i, j (0 \leq i \leq K-1,\ 0 \leq j \leq N-1), X_{i \times N + j}=A_j holds.  Snuke has an integer sequence s, which is initially empty. For each i=0,1,2,\cdots,N \times K-1, in this order, he will perform the following operation:    * If s does not contain X_i: add X_i to the end of s.   * If s does contain X_i: repeatedly delete the element at the end of s until s no longer contains X_i. Note that, in this case, we do **not** add X_i to the end of s.  Find the elements of s after Snuke finished the operations.

Submission attempts (in order):
import numpy as np

N,K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
s = np.zeros(0)

for i in range(N):
    for j in range(N):
        if np.any(s == A[j]) == False:
            s = np.append(s, A[j])
            
        else:
            k = np.where(s == A[j])[0][-1]
            s = s[:k]
            
print(*s.astype(np.int32))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
 
M = [None]*(max(A)+1)
T = [None]*N
for i,a in enumerate(A):
    M[a] = i
 
for i,a in enumerate(A):
    T[M[a]]=(i+1)%N
    M[a]=i
 
ptr=0
ptr_head = [ptr]
while True:
    ptr_next = T[ptr]
    if ptr_next==0: break
    if ptr_next <= ptr+1: ptr_head.append(ptr_next)
    ptr = ptr_next
 
period = len(ptr_head)
if T[-1]==0: period+=1
 
if K % period==0:
    print()
    exit()
 
ret = []
ptr = ptr_head[K % period - 1]
while ptr<N:
    ptr_next = T[ptr]
    if ptr_next > ptr+1:
        ptr = ptr_next
    elif ptr_next==0 and ptr!=N-1:
        break
    else:
        ret.append(A[ptr])
        ptr+=1
 
print(' '.join(map(str, ret)))

Verdicts: Wrong Answer

Accepted
Problem: We have a sequence of N \times K integers: X=(X_0,X_1,\cdots,X_{N \times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\cdots,A_{N-1}). For each pair i, j (0 \leq i \leq K-1,\ 0 \leq j \leq N-1), X_{i \times N + j}=A_j holds.  Snuke has an integer sequence s, which is initially empty. For each i=0,1,2,\cdots,N \times K-1, in this order, he will perform the following operation:    * If s does not contain X_i: add X_i to the end of s.   * If s does contain X_i: repeatedly delete the element at the end of s until s no longer contains X_i. Note that, in this case, we do **not** add X_i to the end of s.  Find the elements of s after Snuke finished the operations.

Submission attempts (in order):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

#print(*range(10000))

def func(L):
  s = []
  for l in L:
    if l in s:
      del s[s.index(l):]
      #s_set.remove(l)
    else:
      s.append(l)
      #s_set.add(l)
  return s

index_dict={}

for i,a in enumerate(A):
  index_dict.setdefault(a,[]).append(i)

#print(index_dict)

from_in_cycle=[]

i = 0
while True:
  a = A[i]
  l = len(index_dict[a])
  j = index_dict[a].index(i)
  if j==l-1:
    from_in_cycle.append(i)
    i = (index_dict[a][0]+1)%N
  else:
    i = (index_dict[a][j+1]+1)%N
  
  if i==0:
    break
    
#print(from_in_cycle)

if from_in_cycle:
  k = K%(len(from_in_cycle))
  print(*func(A[from_in_cycle[k]:]))
else:
  print('')

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

if N==1:
  if K%2:
    print(A[0])
  else:
    print('')
  exit()
  

#print(*range(10000))

def func(L):
  s = []
  for l in L:
    if l in s:
      del s[s.index(l):]
      #s_set.remove(l)
    else:
      s.append(l)
      #s_set.add(l)
  return s




index_dict={}
for i,a in enumerate(A):
  index_dict.setdefault(a,[]).append(i)

next_i = [0]*N
cycle_i = [0]*N
for k,v in index_dict.items():
  for i in range(len(v)):
    next_i[v[i]] = (v[(i+1)%len(v)]+1)%N
    cycle_i[v[i]] = (i+1)//len(v)
#print(next_i)
#print(cycle_i)

from_in_cycle=[]

i = 0
while True:
  j = next_i[i]
  if cycle_i[i]:
    from_in_cycle.append(i)
  i = j
  
  if i==0:
    break
    
#print(from_in_cycle)

if from_in_cycle:
  k = K%(len(from_in_cycle)+1)
  #print(*func(A[from_in_cycle[k-1]:]))

  ans = []
  i = from_in_cycle[k-1]
  while i < N:
    if cycle_i[i]:
      ans.append(A[i])
      i += 1
    else:
      if next_i[i]==0:
        break
      i = next_i[i]
  print(*ans)


else:
  print('')

Verdicts: Wrong Answer

Accepted
Problem: We have a sequence of N \times K integers: X=(X_0,X_1,\cdots,X_{N \times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\cdots,A_{N-1}). For each pair i, j (0 \leq i \leq K-1,\ 0 \leq j \leq N-1), X_{i \times N + j}=A_j holds.  Snuke has an integer sequence s, which is initially empty. For each i=0,1,2,\cdots,N \times K-1, in this order, he will perform the following operation:    * If s does not contain X_i: add X_i to the end of s.   * If s does contain X_i: repeatedly delete the element at the end of s until s no longer contains X_i. Note that, in this case, we do **not** add X_i to the end of s.  Find the elements of s after Snuke finished the operations.

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

def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    D = {}
    for j,a in enumerate(A):
        D[a] = D.get(a,[])+[j]

    t,k = 0,0
    T = [0]
    while True:
        k = (D[A[t]].index(t)+1)%len(D[A[t]])
        if k == 0:
            T.append(A[t])
        t = (D[A[t]][k]+1)%N
        if t == 0:
            break

    T[0] = T.pop()
    t = D[T[K%len(T)]][0]+1
    S = []
    while t < N:
        k = (D[A[t]].index(t)+1)%len(D[A[t]])
        if k == 0:
            S.append(A[t])
        t = D[A[t]][k]+1

    res = ' '.join(map(str,S))

    return str(res)

if __name__ == '__main__':
    print(solve())

# -*- coding: utf-8 -*-

def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    D = {}
    for j,a in enumerate(A):
        D[a] = D.get(a,[])+[j]

    t,k = 0,0
    T = [0]
    while True:
        k = (D[A[t]].index(t)+1)%len(D[A[t]])
        if k == 0:
            T.append(A[t])
        t = (D[A[t]][k]+1)%N
        if t == 0:
            break

    if T == [0]:
        return ''
    if K == 1 or (K-1)%len(T) == 0:
        t = 0
    else:
        t = D[T[(K-1)%len(T)]][0]+1
    S = []
    flag = False
    while t < N:
        k = (D[A[t]].index(t)+1)%len(D[A[t]])
        if k == 0:
            S.append(A[t])
            t += 1
        else:
            t = D[A[t]][k]+1

    res = ' '.join(map(str,S))

    return str(res)

if __name__ == '__main__':
    print(solve())

Verdicts: Runtime Error

Accepted
Problem: We have a sequence of N \times K integers: X=(X_0,X_1,\cdots,X_{N \times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\cdots,A_{N-1}). For each pair i, j (0 \leq i \leq K-1,\ 0 \leq j \leq N-1), X_{i \times N + j}=A_j holds.  Snuke has an integer sequence s, which is initially empty. For each i=0,1,2,\cdots,N \times K-1, in this order, he will perform the following operation:    * If s does not contain X_i: add X_i to the end of s.   * If s does contain X_i: repeatedly delete the element at the end of s until s no longer contains X_i. Note that, in this case, we do **not** add X_i to the end of s.  Find the elements of s after Snuke finished the operations.

Submission attempts (in order):
n,k,*a=map(int,open(0).read().split())
l,r,*b=[[]for _ in range(10**6)]
for i,v in enumerate(a):
  b[v]+=i,
  l+=len(b[v]),
s=a[0]
i=c=0
while 1:
  j=l[i]%len(b[s])
  if(c>k-2)>j:
    r+=s,
    i+=1
  else:i=-~b[s][j]%n
  c+=j<1
  if i<1:
    if c>k-2:break
    k%=c+1
    c=0
  s=a[i]
print(*r)

from bisect import*
from collections import*
n,k,*a=map(int,open(0).read().split())
b=defaultdict(list)
for i,v in enumerate(a):b[v]+=i,
s=a[0]
i=c=0
while 1:
  t=b[s]
  m=len(t)
  j=bisect(t,i)
  c+=j==m
  i=t[j%m]+1
  if i==n:break
  s=a[i]
k%=c+1


from bisect import*
from collections import*
n,k,*a=map(int,open(0).read().split())
b=defaultdict(list)
for i,v in enumerate(a):b[v]+=i,
s=a[0]
i=c=0
while 1:
  t=b[s]
  m=len(t)
  j=bisect(t,i)
  c+=j==m
  i=t[j%m]+1
  if i==n:break
  s=a[i]
k%=c+1

a*k

n,k,*a=map(int,open(0).read().split())
l,r,*b=[[]for _ in range(10**6)]
for i,v in enumerate(a):
  b[v]+=i,
  l+=len(b[v]),
s=a[0]
i=c=0
while 1:
  j=l[i]%len(b[s])
  if(c>k-2)>j:
    r+=s,
    i+=1
  else:i=b[s][j]+1
  c+=j<1
  if i==n:
    if c>k-2:break
    k%=c+1
    i=c=0
  s=a[i]
print(*r)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: We have a sequence of N integers: x=(x_0,x_1,\cdots,x_{N-1}). Initially, x_i=0 for each i (0 \leq i \leq N-1).  Snuke will perform the following operation **exactly** M times:    * Choose two distinct indices i, j (0 \leq i,j \leq N-1,\ i \neq j). Then, replace x_i with x_i+2 and x_j with x_j+1.  Find the number of different sequences that can result after M operations. Since it can be enormous, compute the count modulo 998244353.

Submission attempts (in order):
def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs


def get_nhr(n, facts, invs, MOD):
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr


def solve(n, m):
    MOD = 998244353
    facts, invs = prepare(n + 3 * m, MOD)
    fn = facts[n]
    nhr = get_nhr(n, facts, invs, MOD)
    nm2 = min(n, m - 2)
    ans = 0
    for odd in range(m % 2, min(m, n) + 1, 2):
        tmp = nhr((3 * m - odd) // 2)
        if odd > 0:
            tmp -= odd * nhr((m - odd) // 2)
        if odd < nm2:
            tmp -= (n - odd) * nhr((m - odd - 2) // 2)
        ans = (ans + fn * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
    return ans


n, m = list(map(int, input().split()))
print(solve(n, m))


def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs


def get_nhr(n, facts, invs, MOD):
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr


def solve(n, m):
    MOD = 998244353
    facts, invs = prepare(n + 3 * m, MOD)
    fn = facts[n]
    nhr = get_nhr(n, facts, invs, MOD)
    nm2 = min(n, m - 1)
    ans = 0
    for odd in range(m % 2, min(m, n) + 1, 2):
        tmp = nhr((3 * m - odd) // 2)
        if odd > 0:
            tmp -= odd * nhr((m - odd) // 2)
        if odd < nm2:
            tmp -= (n - odd) * nhr((m - odd - 2) // 2)
        ans = (ans + fn * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
    return ans


n, m = list(map(int, input().split()))
print(solve(n, m))


Verdicts: Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

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

print((N+D*2)/(D*2+1))

N=int(input())
D=int(input())

print((N+D*2)//(D*2+1))

N,D=map(int,input().split())

print((N+2*D) // (2*D+1))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
N ,D =map(int,input().split())
cnt = 0
i2 = 0
for i in range(N):
    if i - D ==1:
        i2 = i
        break
for j in range(N):
    if i2 + D >=N:
        cnt += 1
        break
    else:
        print(i2)
        i2 = i2 + D + i2
        cnt+= 1
print(cnt)


N ,D =map(int,input().split())
cnt = 0
i2 = 0
for i in range(N):
    if i - D ==1:
        i2 = i + 1
        break
for j in range(N):
    if i2  + D >= N:
        cnt+=1
        print(cnt)
        exit()
    else:
        i2 = i2 + D * 2 + 1
        cnt+=1


N,D = map(int,input().split())
if N % (2*D + 1) == 0:
    print(int(N/(2*D+1)))
else:
    print(int(N//(2*D + 1)+1))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
import math
n, d = map(input().split())
se = d * 2 + 1
print(math.ceil(n/d))

n, d = map(int, input().split())
a = n // (2d + 1) + 1
print(a)


n, d = map(int, input().split())
a = n // (2d + 1) + 1
print(a)

import math
n, d = map(input().split())
se = d * 2 + 1
print(math.ceil(n/se))


n = int(input())
d = int(input())
a = n/d + 1
print(a)

n, d = map(int, input().split())
a = n//d + 1
print(a)

import math
n, d = map(int, input().split())
se = d * 2 + 1
print(math.ceil(n/se))


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
import math

inputted = list(map(int, input().split()))
N = inputted[0]
D = inputted[1]

monitor = (D + 1) * 2
answer = math.ceil(N / monitor)

print(answer)


import math

inputted = list(map(int, input()))
N = inputted[0]
D = inputted[1]

monitor = (D + 1) * 2
answer = math.ceil(N / monitor)

print(answer)


import math

inputted = list(map(int, input().split()))
N = inputted[0]
D = inputted[1]

monitor = D * 2 + 1
answer = math.ceil(N / monitor)

print(answer)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
import io
import sys
from math import ceil


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
20 4
'''


def MAIN():
  T_IN()
  A()


def A():
  n, d = IN_L_I()
  
  print(ceil( n / (d * 2 + 1)))
  
  return None
 

def B():
  return None


def C():
  return None


MAIN()


import io
import sys
from math import ceil


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
20 1
'''


def MAIN():
  # T_IN()
  A()


def A():
  n, d = IN_L_I()

  print(ceil(n / (d * 2 + 1)))

  return None


def B():
  return None


def C():
  return None


MAIN()


Verdicts: Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
a,b=map(int,input().split())
prnit((a-0.01)//(2*b+1)+1)

a,b=map(int,input().split())
print((a-0.01)//(2*b+1)+1)


a,b=map(int,input().split())
print(int((a-0.01)//(2*b+1)+1))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
import math
N, D = map(int, input().split())
print(math.ceil((N - 1) / (2 * D + 1)))

import math
N, D = map(int, input().split())
print(math.ceil(N / (2 * D + 1)))

Verdicts: Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
n,d=map(int,input().split())
print(n//d)


n,d=map(int,input().split())
print(int((n+d*2)/(d*2+1)))


Verdicts: Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):

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

print(a/(b*2)+1)


N,D = map(int,input().split())

if N % (D*2+1)== 0:
    print(int(N / (D*2+1)))
else:
    print(int(N / (D*2+1)) + 1)

Verdicts: Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
n,d=map(int,input().split())
if n%(2*d+1)!=0:
   print(n//(2*d+1)+1)
else:
    print(n//(2*d+1

n,d=map(int,input().split())
if n%(2*d+1)!=0:
   print(n//(2*d+1)+1)
else:
    print(n//(2*d+1))

Verdicts: Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
# -*- coding: UTF-8 -*-
import math
n, d = map(int, input().split())
print(math.floor(n/(2*d+1)))


# -*- coding: UTF-8 -*-
import math
n, d = map(int, input().split())
print(math.ceil(n/(2*d+1)))


Verdicts: Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
n,d=map(int,input().split())
x=2*d+1
if(n%x!=0):
    print(int(n/x))
else:
    print(int(n/x)+1)




n,d=map(int,input().split())
if(d>=10){
print(1)
}else{
x=2*d+1
print(int(n/x)+1)
}


n,d=map(int,input().split())
x=2*d+1
if(n%x!=0):
    print(int(n/x)+1)
else:
    print(int(n/x))




Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
import math
N, D = map(int, input().split())
print(math.ceil(N/(2D+1)))


import math
N, D = map(int, input().split())
print(math.ceil(N /(2 * D + 1)))



Verdicts: Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
N, D = map(int, input().split())
print(N//(D*2+1)+1)N, D = map(int, input().split())
print(-(-N//(D*2+1)))

N, D = map(int, input().split())
print(-(-N//(D*2+1)))

Verdicts: Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
n,d = map(int,input().split())
x = d*2 + 1
print((n+d*2)//(x)

n,d = map(int,input().split())
x = d*2 + 1
print((n+d*2)//x)

Verdicts: Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
n,d = (int(i) for i in input().split())

i=1
answer=0
while(True):
    i = i + 2*d + 1
    answer += 1
    if i>=n:
        break
        
print(answer)

n,d = (int(i) for i in input().split())

i=1
answer=0
while(True):
    i = i + 2*d + 1
    answer += 1
    if (i-1)>=n:
        break
        
print(answer)

Verdicts: Wrong Answer

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
n,s=map(int,input().split())

count=n//(2*d+1)

if n%(2*d+1)==0:
    print(count)
else:
    print(count+1)

n,s=map(int,input().split())

count=n//(2*s+1)

if n%(2*s+1)==0:
    print(count)
else:
    print(count+1)

Verdicts: Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
import math
N = int(input())
D = int(input())
i = N / (2*D + 1)
if 1 <= N <= 20 and 1 <= D <= 20:
    if i > 0:
        i = math.ceil(i)
        print(i)



import math
N, D = map(int, input().split())
i = N / (2*D + 1)
if 1 <= N <= 20 and 1 <= D <= 20:
    if i > 0:
        i = math.ceil(i)
        print(i)

Verdicts: Runtime Error

Accepted
Problem: There are N apple trees in a row. People say that one of them will bear golden apples.  We want to deploy some number of inspectors so that each of these trees will be inspected.  Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).  Find the minimum number of inspectors that we need to deploy to achieve the objective.

Submission attempts (in order):
N,D=map(int,input().split())
people=N/(2D+1)
if people%2==O:
    print(int(people))
else:
    print(int(people)+1)


N,D=map(int,input().split())
people=N/(2*D+1)
if N % (2*D+1) == 0:
    print(int(people))
else:
    print(int(people)+1)


Verdicts: Runtime Error

Accepted