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

Fixed submission:
def opeCounter(S, K):
    T = S * K
    c = 0
    i = 1
    while i < len(T):
        if T[i-1] == T[i]:
            c += 1
            i += 1
        i += 1
    return c

def agc039a(S, K):
    s1 = opeCounter(S, 1)
    s2 = opeCounter(S, 2)
    s3 = opeCounter(S, 3)
    d1 = s2 - s1
    d2 = s3 - s2

    ans = 0
    if d1 == d2: ans = s1 + d1 * (K-1)
    else:
        if(K%2 != 0): ans = s1 + (d1+d2) * ((K+2-1)//2-1) ##(k/2):roundup
        else: ans = s2 + (d1+d2) * (K//2-1)
    return ans

S = input()
K = int(input())
print(agc039a(S, K))

Buggy submission (verdict: Runtime Error):
def opeCounter(S, K):
    T = S * K
    c = 0
    i = 1
    while i < len(T):
        if T[i-1] == T[i]:
            c += 1
            i += 1
        i += 1
    return c

def agc039a(S, K):
    s1 = opeCounter(S, 1)
    s2 = opeCounter(S, 2)
    s3 = opeCounter(S, 3)
    d1 = s2 - s1
    d2 = s3 - s2

    ans = 0
    if d1 == d2: ans = s1 + d1 * (K-1)
    else:
        if(k%2 != 0): ans = s1 + (d1+d2) * ((k+2-1)//2-1) ##(k/2):roundup
        else: ans = s2 + (d1+d2) * (k//2-1)
    return ans

S = input()
K = int(input())
print(agc039a(S, K))

Buggy submission (verdict: Runtime Error):
def opeCounter(S, K):
    T = S * K
    c = 0
    i = 1
    while i < len(T):
        if T[i-1] == T[i]:
            c += 1
            i += 1
        i += 1
    return c

def agc039a(S, K):
    s1 = opeCounter(S, 1)
    s2 = opeCounter(S, 2)
    s3 = opeCounter(S, 3)
    d1 = s2 - s1
    d2 = s3 - s2

    ans = 0
    if d1 == d2: ans = s1 + d1 * (K-1)
    else:
        if(k%2 != 0): ans = s1 + (d1+d2) * ((k+2-1)/2-1) ##(k/2):roundup
        else: ans = s2 + (d1+d2) * (k/2-1)
    return ans

S = input()
K = int(input())
print(agc039a(S, K))
Problem p03634 (python)

Fixed submission:
## abc070d: Transit Tree Path

n = int(input())

T = [None]*(n+1)
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    if(T[v1] is None): T[v1] = [[v1,v2,d]]
    else: T[v1].append([v1,v2,d])
    if(T[v2] is None): T[v2] = [[v2,v1,d]]
    else: T[v2].append([v2,v1,d])

depth = [0]*(n+1)

q,k = map(int, input().split())

is_visit = [False]*(n+1)
p,c,d = 0,k,0
depth[c] = d
is_visit[c] = True
stack = T[c]
while stack:
    p,c,d = stack.pop()
    if is_visit[c]: continue
    is_visit[c] = True
    depth[c] = depth[p] + d
    for pp,cc,dd in T[c]:
        if not is_visit[cc]: stack.append([pp,cc,dd])

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1]+depth[v2])

Buggy submission (verdict: Runtime Error):
## abc070d: Transit Tree Path

n = int(input())

T = [None]*(n+1)
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    if(T[v1] is None): T[v1] = [[v2,d]]
    else: T[v1].append([v2,d])
    if(T[v2] is None): T[v2] = [[v1,d]]
    else: T[v2].append([v1,d])

depth = [0 for _ in  range(n+1)]

def dfs(p, c, d):
    depth[c] = d
    for (v,vd) in T[c]:
        if v!=p: dfs(c, v, depth[c] + vd)

q,k = map(int, input().split())

dfs(0,k,0)

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1]+depth[v2])

Buggy submission (verdict: Runtime Error):
## abc070d: Transit Tree Path

n = int(input())

T = [None]*(n+1)
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    if(T[v1] is None): T[v1] = [[v2,d]] # [child, distance]
    else: T[v1].append([v2,d])
    if(T[v2] is None): T[v2] = [[v1,d]]
    else: T[v2].append([v1,d])

depth = [-1 for _ in  range(n+1)]

def dfs(p, d, pd):
    depth[p] = d + pd # 距離設定 == 訪問済み
    for (c,cd) in T[p]:
        if depth[c]>=0: continue # 訪問済み
        dfs(c, cd, depth[p])

q,k = map(int, input().split())

dfs(k,0,0)

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1]+depth[v2])
Problem p02596 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

k = int(input())
if k%2==0 or k%5==0:
    print(-1)
else:
    ret = 1
    res = 7%k
    while res != 0:
        res = (res * 10 + 7) % k
        ret += 1
    print(ret)

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

k = int(input())
if k%2==0:
    print(-1)
else:
    ret = len(str(k))-1
    x = int('7'*(len(str(k))-1))
    res = x%k
    while res != 0:
        res = (res * 10 + 7) % k
        ret += 1
    print(ret)
Problem p02597 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

n = int(input())
s = input()
r = s.count('R')
print(s[:r].count('W'))

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

n = int(input())
s = input()
def f(str):
    if str == '':
        return 0
    else:
        if str[0] == 'R':
            return f(str[1:])
        elif str[-1] == 'W':
            return f(str[:-1])
        else:
            ret = f(str[1:-1]) + 1
            ret = min(f(str[:-1]) + 1, ret)
            ret = min(f(str[1:]) + 1, ret)
            return ret

print(f(s))
Problem p02661 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = [None]*N
    B = [None]*N

    for i in range(N):
        a,b = map(int, input().split())
        A[i]=a
        B[i]=b
    A.sort()
    B.sort()

    if N%2==0:
        x=A[N//2-1]+A[N//2]
        y=B[N//2-1]+B[N//2]
        print(y-x+1)
    else:
        x=A[N//2]
        y=B[N//2]
        print(y-x+1)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [None]*N
B = [None]*N

for i in range(N):
  a,b = map(int, input().split())
  A[i]=a
  B[i]=b
  A.sort()
  B.sort()

  if N%2==0:
    x=A[N//2-1]
    y=B[N//2]
    else:
      x=A[N//2]
      y=B[N//2]
      print(y-x+1)
Problem p02682 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    A, B, C, K = map(int, input().split())
    if K<=A:
        print(K)
    elif K<=(A+B):
        print(A)
    elif K<=(A+B+C):
        print(A-(K-A-B))
    else:
        print(A-C)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
a, b, c, k = map(int,input().split())
li = [1]*a
li += [0]*b
li += [-1]*c
print(sum(li[:k]))
Problem p02763 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right


n = int(input())
s = list(input())
q = int(input())

al = 'abcdefghijklmnopqrstuvwxyz'
dicq = {i:[] for i in al}
for i, si in enumerate(s):
    dicq[si].append(i)

def q1(iq, cq):
    #print(iq,cq,s[iq],dicq[s[iq]],bisect_left(dicq[s[iq]], iq))
    dicq[s[iq]].pop(bisect_left(dicq[s[iq]], iq))   #更新前から削除
    s[iq] = cq
    dicq[cq].insert(bisect_left(dicq[cq], iq), iq)   #更新後に追加

def q2(l, r):
    ret = 0
    for ai in al:
        if len(dicq[ai])==0: continue
        li = bisect_left(dicq[ai], l)
        ri = bisect_right(dicq[ai], r)
        if li != ri:
            ret += 1
        elif li == len(dicq[ai]): continue
        elif dicq[ai][li] == l:
            ret += 1
    #    print(l,r,ai,dicq[ai],li,ri,ret)
    print(ret)

for i in range(q):
    fg, x, y = input().split()
    if fg == '1':
        q1(int(x)-1, y)
    else:
        q2(int(x)-1, int(y)-1)

Buggy submission (verdict: Runtime Error):
al = 'abcdefghijklmnopqrstuvwxyz'
N=int(input())
S=input()
Q=int(input())
from bisect import bisect_left, bisect_right
dic = {}
for i in range(N):
  if not S[i] in dic:
    dic[S[i]]=[i+1]
  else:
    dic[S[i]].append(i+1)
def fg1(l, r):
  l = int(l)
  dic[S[l-1]].remove(l)
  if not r in dic:
    dic[r]=[l]
  else:
    ins = bisect_left(dic[r], l)
    dicr = dic[r][:ins]
    dicr.append(l)
    dicr += dic[r][ins:]
    dic[r]=dicr
def fg2(l, r):
  l, r = int(l), int(r)
  ret = 0
  for d in list(dic.keys()):
    li = bisect_left(dic[d], l)
    if li<=len(dic[d])-1:
      ret += (dic[d][li]<=r)
  print(ret)
  
for i in range(Q):
  fg, l, r = input().split()
  if fg=='1':
    fg1(l, r)
  else:
    fg2(l, r)

Buggy submission (verdict: Runtime Error):
al = 'abcdefghijklmnopqrstuvwxyz'
N=int(input())
S=input()
Q=int(input())
from bisect import bisect_left, bisect_right
dic = {}
for i in range(N):
  if not S[i] in dic:
    dic[S[i]]=[i+1]
  else:
    dic[S[i]].append(i+1)
def fg1(l, r):
  l = int(l)
  dic[S[l-1]].remove(l)
  if not r in dic:
    dic[r]=[l]
  else:
    ins = bisect_left(dic[r], l)
    dicr = dic[r][:ins]
    dicr.append(l)
    dicr += dic[r][ins:]
    dic[r]=dicr
def fg2(l, r):
  l, r = int(l), int(r)
  ret = 0
  for d in list(dic.keys()):
    ll = bisect_left(dic[d], l)
    rr = bisect_right(dic[d], r)
    ret += ll<rr
  print(ret)
  
for i in range(Q):
  fg, l, r = input().split()
  if fg=='1':
    fg1(l, r)
  else:
    fg2(l, r)
Problem p02793 (python)

Fixed submission:
from fractions import gcd
N=int(input())
a = list(map(int, input().split()))
lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm, i)
ans = 0
for i in a:
    ans += (lcm//i)#%(10**9+7)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N=int(input())
a = list(map(int, input().split()))
lcm = 1
for i in range(N):
    lcm = lcm * a[i] // gcd(ans, a[i])
import numpy as np
aa = np.array(a)
print(sum(lcm//aa)%(10**9+7))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N=int(input())
a = list(map(int, input().split()))
lcm = 1
for i in range(N):
    lcm = lcm * a[i] // gcd(ans, a[i])
import numpy as np
aa = np.array(a)
print(sum(ans//aa)%(10**9+7))
Problem p02833 (python)

Fixed submission:
N = int(input())

if N%2==1:
  print(0)
else:
  cnt = 0
  NN = (N//10)*10
  for i in range(25):
    cnt += NN//((5**(i+1))*2)
  print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N%2==1:
  print(ans)
else:
  cnt = 0
  NN = (N//10)*10
  for i in range(25):
    cnt += NN//((5**(i+1))*2)
  print(cnt)
Problem p02860 (python)

Fixed submission:
N = int(input())
A = input()
AA = A[0:int(N/2)]
if A == (AA+AA):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input()
A = input()
AA = A[0:int(N/2)]
if A == (AA+AA):
    print('Yes')
else:
    print('No')
Problem p02897 (python)

Fixed submission:
N = int(input())
print( 1 - int(N/2) / N )

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
r = ""
for i in range(N):
  r+= str(A.index(i+1)+1)
  r+= " "
print(r)
Problem p02935 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A.sort()
r=A[0]
for i in range(1,N,1):
  r=float((r+A[i])/2)
print(r)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=map(int,input().split())
A.sort()
r=A[0]
for i in range(1,N,1):
  r=float((r+A[i])/2)
print(r)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=map(float,input().split())
A.sort()
r=A[0]
for i in range(1,N,1):
  r=(r+A[i])/2
print(r)
Problem p02954 (python)

Fixed submission:
S = input()
S = (S.replace('LR','L R')).split()
def subans(SR):
  rl =len(SR) 
  r = SR.count('R')
  l = rl-r
  r1 = rl//2
  r2 = rl-r1
  ret = [0]*rl
  if r%2==0:
    ret[r-1],ret[r] = r1,r2
  else:
    ret[r-1],ret[r] = r2,r1
  return ret
ans = []
for _ in S:
  ans += subans(_)
print(*ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = 10**5
keta = 17
S = list(input())
n = len(S)
npE = np.eye(n)
A = [[0]*n for i in range(n)]
for i in range(n):
  if S[i]=="R":
    A[i][i+1]=1
  else:
    A[i][i-1]=1
npA = np.array(A)
ans = npE
for i in range(keta):
  if N >> i & 1:
    ans = np.dot(ans,npA)
  npA = np.dot(npA, npA)
aa=ans.T
aaa = []
for i in range(n):
  aaa.append(int(sum(list(aa[i]))))
print(*aaa)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = 10**100
keta = 333
S = list(input())
n = len(S)
npE = np.eye(n)
A = [[0]*n for i in range(n)]
for i in range(n):
  if S[i]=="R":
    A[i][i+1]=1
  else:
    A[i][i-1]=1
npA = np.array(A)
ans = npE
for i in range(keta):
  if N >> i & 1:
    ans = np.dot(ans,npA)
  npA = np.dot(npA, npA)
aa=ans.T
aaa = []
for i in range(n):
  aaa.append(int(sum(list(aa[i]))))
print(*aaa)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = 10**100
keta = 334
S = list(input())
n = len(S)
npE = np.eye(n)
A = [[0]*n for i in range(n)]
for i in range(n):
  if S[i]=="R":
    A[i][i+1]=1
  else:
    A[i][i-1]=1
npA = np.array(A)
ans = npE
for i in range(keta):
  if N >> i & 1:
    ans = np.dot(ans,npA)
  npA = np.dot(npA, npA)
aa=ans.T
aaa = []
for i in range(n):
  aaa.append(int(sum(list(aa[i]))))
print(*aaa)
Problem p03012 (python)

Fixed submission:
N =int(input())
S = list(map(int,input().split()))
TT = sum(S)
T1 = 0
Ans = TT
for i in range(N):
  T1 += S[i]
  Ans = min(Ans,abs(TT-T1-T1))
print(Ans)

Buggy submission (verdict: Runtime Error):
N =int(input())
S = map(int,input().split())
TT = sum(TT)
T1 = 0
Ans = TT
for i in range(N):
  T1 += S[i]
  Ans = min(Ans,ABS(TT-T1-T1))
print(Ans)

Buggy submission (verdict: Runtime Error):
N =inptut()
S = map(int,imput().split())
TT = sum(TT)
T1 = 0
Ans = TT
for i in range(N):
  T1 += S[i]
  Ans = min(Ans,ABS(TT-T1-T1))
print(Ans)
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
mod = 10**9+7
fram = [1]
for i in range(1,N+1):
  fram.append(fram[-1]*i%mod)

#def framod(n, mod, a=1):
#    for i in range(1,n+1):
#        a = a * i % mod
#    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=fram[n]
    b=fram[k]
    c=fram[n-k]
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def cnt(n):
  s = sum([comb(n-i,i,mod)%mod for i in range(n//2+1)])
  s = s%mod
  return s

A0 = 0
ans = 1
for i in range(M):
  A1 = int(input()) - 1
  ans = (ans * cnt(A1-A0))%mod
  A0 = A1+2
ans = (ans * cnt(N-A0))%mod
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
mod = 10**9+7
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def cnt(n):
  s = sum([comb(n-i,i,mod)%mod for i in range(n//2+1)]):
  s = s%mod
  return s

A0 = 0
ans = 1
for i in range(M):
  A1 = int(input()) - 1
  ans = (ans * cnt(A1-A0))%mod
  A0 = A1+2
ans = (ans * cnt(N-A0))%mod
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
mod = 10**9+7
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def cnt(n):
  s = sum([comb(n-i,i,mod)%mod for i in range(n//2+1)]:
  s = s%mod
  return s

A0 = 0
ans = 1
for i in range(M):
  A1 = int(input()) - 1
  ans = (ans * cnt(A1-A0))%mod
  A0 = A1+2
ans = (ans * cnt(N-A0))%mod
print(ans)
Problem p03041 (python)

Fixed submission:
N,b=map(int,input().split())
S=input()
S=S[:b-1]+S[b-1].lower()+S[b:]
print(S)

Buggy submission (verdict: Runtime Error):
N,b=map(int,input().split())
S=input()
S[b-1]=S[b-1].lower()
print(S)
Problem p03053 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

H, W = map(int,input().split())

INF = -1
Gmap = [list(input()) for _ in range(H)]
next_q = deque([])

def dfs_settings():
    #複数
    for h in range(H):
        for w in range(W):
            if Gmap[h][w]=='#':
                next_q.append([h,w])
                Gmap[h][w]=0

def dfs():
    ret = 0
    while len(next_q)!=0:
        #スタック取り出し(先頭)幅優先
        h,w = next_q.popleft()
        lv=Gmap[h][w]+1
        hs, ws = h + 0 , w + 1
        if ws<W and Gmap[hs][ws]=='.':
            next_q.append([hs,ws])
            Gmap[hs][ws] = lv
            ret = max(ret, Gmap[hs][ws])
        hs, ws = h + 1 , w + 0
        if hs<H and Gmap[hs][ws]=='.':
            next_q.append([hs,ws])
            Gmap[hs][ws] = lv
            ret = max(ret, Gmap[hs][ws])
        hs, ws = h + 0 , w - 1
        if ws>=0 and Gmap[hs][ws]=='.':
            next_q.append([hs,ws])
            Gmap[hs][ws] = lv
            ret = max(ret, Gmap[hs][ws])
        hs, ws = h - 1 , w + 0
        if hs>=0 and Gmap[hs][ws]=='.':
            next_q.append([hs,ws])
            Gmap[hs][ws] = lv
            ret = max(ret, Gmap[hs][ws])
    return ret

def main():
    dfs_settings()
    ret = dfs()
    print(ret)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

H, W = map(int,input().split())
sth, stw = 0, 0
glh, glw = H-1, W-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
Dist = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}
next_q = deque([])

def dfs_settings():
    #複数
    for h in range(H):
        for w in range(W):
            if Gmap[h][w]=='#':
                next_q.append([h,w])
                Dist[h][w]=0

def dfs():
    ret = 0
    while len(next_q)!=0:
        #スタック取り出し(先頭)幅優先
        h,w = next_q.popleft()
        hs, ws = h + 0 , w + 1
        if Gmap[hs][ws]=='.' and Dist[hs][ws]==INF and ws<W:
            next_q.append([hs,ws])
            Dist[hs][ws] = Dist[h][w] + 1
            ret = max(ret, Dist[hs][ws])
        hs, ws = h + 1 , w + 0
        if Gmap[hs][ws]=='.' and Dist[hs][ws]==INF and hs<H:
            next_q.append([hs,ws])
            Dist[hs][ws] = Dist[h][w] + 1
            ret = max(ret, Dist[hs][ws])
        hs, ws = h +0 , w - 1
        if Gmap[hs][ws]=='.' and Dist[hs][ws]==INF and ws>=0:
            next_q.append([hs,ws])
            Dist[hs][ws] = Dist[h][w] + 1
            ret = max(ret, Dist[hs][ws])
        hs, ws = h - 1 , w + 0
        if Gmap[hs][ws]=='.' and Dist[hs][ws]==INF and hs>=0:
            next_q.append([hs,ws])
            Dist[hs][ws] = Dist[h][w] + 1
            ret = max(ret, Dist[hs][ws])
    return ret

def main():
    dfs_settings()
    ret = dfs()
    print(ret)

if __name__ == '__main__':
    main()
Problem p03242 (python)

Fixed submission:
print(((input().replace("1","d")).replace("9","1")).replace("d","9"))

Buggy submission (verdict: Runtime Error):
ret = ''
for a in input():
  if a = '1':
    ret += '9'
  elif a = '9':
    ret += '1'
  else:
    ret += a
print(ret)
Problem p03834 (python)

Fixed submission:
print(input().replace(',',' '))

Buggy submission (verdict: Runtime Error):
print(input().replace(',',' ')
Problem p02819 (python)

Fixed submission:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    X = int(input())
    for i in range(X, 10**12):
        if is_prime(i):
            print(i)
            exit()




if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    A, B, K = map(int, input().split())
    C = max(A - K , 0)
    K = max(K - A , 0)
    D = max(B - K , 0)
    print(C, D)



if __name__ == "__main__":
    main()
Problem p02990 (python)

Fixed submission:
import math

def comb(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)

def main():
    MOD = 10 ** 9 + 7
    N, K = map(int, input().split())
    for i in range(1,K+1):
        if i > N - K + 1:
            print(0)
            continue
        blue = comb(N-K+1,i) % MOD
        red = comb(K-1,i-1) % MOD

        ans = blue * red % MOD

        print(ans)
            

main()

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7
    for i in range(1,K+1):
        blue = cmb(K-1,i-1)
        red = cmb(N-K+1,N-K-i+1)
        ans = blue * red
        ans %= MOD
        print(ans)
        


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import factorial

def permutations_count(n, r):
    ''' 順列 '''
    return factorial(n) // factorial(n - r)

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

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

for i in range(1,K+1):
    #if i == 1:
    #    print(N-K+1)
    #else:
    if K % i == 0:
        print(combinations_count(N-K+1,i)%(10 ** 9 + 7))
    else:
        print(permutations_count(N-K+1,i)%(10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
import math

def permtest(n, k = 1):
    p = math.factorial(n) / math.factorial(n - k)
    return int(p)

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

for i in range(1,K+1):
    if i == 1:
        print(N-K+1)
    else:
        if K % i == 0:
            print(cmb(N-K+1,i)%(10 ** 9 + 7))
        else:
            print(permtest(N-K+1,i)%(10 ** 9 + 7))
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a = set(int(input()) for i in range(M))

dp = [0] * (N + 1)
dp[0] = 1

for i in range(1,N+1):
    if i in a:
        dp[i] = 0
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set(int(i) for i in input().split())

dp = [0] * (N + 1)
dp[0] = 1

for i in range(1,N+1):
    if i in a:
        dp[i] = 0
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set(int(i) for i in input().split())

dp = [0] * (N + 1)
dp[0] = 1

for i in range(1,N+1):
    if i in a:
        dp[i] = 0
        continue
    dp[i] = dp[i-1] + dp[i-2]

print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

a = [int(input()) for i in range(M)]
dp = [0] * (N + 1)
dp[0] = 0
if 1 in a:
    dp[1] = 0
    dp[2] = 1
else:
    if 2 in a:
        dp[1] = 1
        dp[2] = 0
    else:
        dp[1] = 1
        dp[2] = 2
for i in range(3,N+1):
    if i in a:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

a = [int(input()) for i in range(M)]
dp = [0] * (N + 1)
dp[0] = 0
if 1 in a:
    dp[1] = 0
    dp[2] = 1
else:
    if 2 in a:
        dp[1] = 1
        dp[2] = 0
    else:
        dp[1] = 1
        dp[2] = 2
for i in range(3,N+1):
    if i in a:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])