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

Fixed submission:
import sys
sys.setrecursionlimit(4100000)

n = int(input())
dat =[]
link = []
for i in range(n+1):
    link.append([])
cost = [-1] * (n + 1)

for i in range(n - 1):
    a, b, c = map(int, input().split())
    dat.append((a, b, c))
    link[a].append((b,c))
    link[b].append((a,c))

dat_q = []
q, k = map(int, input().split())

for i in range(q):
    x, y = map(int, input().split())
    dat_q.append((x,y))

#print(link)

def search(curcost, current):
    #print("cost{0}, pos {1}: ".format(curcost, current))
    cost[current] = curcost
    for npos, ncost in link[current]:
        if cost[npos] != -1:
            # 戻らない
            continue
        search(curcost + ncost, npos)

search(0, k)

#print(cost)
for i in range(q):
    x,y = dat_q[i]
    print(cost[x] + cost[y])

Buggy submission (verdict: Runtime Error):
n = int(input())
dat =[]
link = []
for i in range(n+1):
    link.append([])
cost = [-1] * (n + 1)

for i in range(n - 1):
    a, b, c = map(int, input().split())
    dat.append((a, b, c))
    link[a].append((b,c))
    link[b].append((a,c))

dat_q = []
q, k = map(int, input().split())

for i in range(q):
    x, y = map(int, input().split())
    dat_q.append((x,y))

#print(link)

def search(curcost, current):
    #print("cost{0}, pos {1}: ".format(curcost, current))
    cost[current] = curcost
    for npos, ncost in link[current]:
        if cost[npos] != -1:
            # 戻らない
            continue
        search(curcost + ncost, npos)

search(0, k)

#print(cost)
for i in range(q):
    x,y = dat_q[i]
    print(cost[x] + cost[y])
Problem p03774 (python)

Fixed submission:
n,m = map(int, input().split())
dat_n = []
dat_m = []
for i in range(n):
    a,b = map(int, input().split())
    dat_n.append((a, b))
for i in range(m):
    a,b = map(int, input().split())
    dat_m.append((a, b))
for i in range(n):
    a, b = dat_n[i]
    index = -1
    distance = 1000000001
    for j in range(m):
        c,d = dat_m[j]
        t = abs(a-c) + abs(b-d)
        if t < distance:
            index = j + 1
            distance = t
    print(index)

Buggy submission (verdict: Runtime Error):
import math
n,m = map(int, input().split())
dat_n = []
dat_m = []
for i in range(n):
    a,b = map(int, input().split())
    dat_n.append((a, b))
for i in range(m):
    a,b = map(int, input().split())
    dat_m.append((a, b))
for i in range(n):
    a, b = dat_n[i]
    index = -1
    distance = math.inf
    for j in range(m):
        c,d = dat_m[j]
        t = abs(a-c) + abs(b-d)
        if t < distance:
            index = j + 1
            distance = t
    print(index)
Problem p03804 (python)

Fixed submission:
n, m = map(int, input().split())
dat_a = []
dat_b = []
for i in range(n):
    dat_a.append(input())
for i in range(m):
    dat_b.append(input())

if n == 1 and m == 1:
    if dat_a[0][0] == dat_b[0][0]:
        t = True
    else:
        t = False

for i in range(n - m + 1):
    for j in range(n - m + 1):
        for k in range(m):
            #print(dat_a[i + k][j : j + m])
            if dat_a[i + k][j : j + m] != dat_b[k]:
                t = False
                break
            t = True
        if t:
            break
    if t:
        break

print("Yes" if t else "No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
dat_a = []
dat_b = []
for i in range(n):
    dat_a.append(input())
for i in range(m):
    dat_b.append(input())

for i in range(n - m):
    for j in range(n - m + 1):
        t = True
        for k in range(m):
            #print(dat_a[i + k][j:j+m])
            #print(dat_b[k])
            if dat_a[i + k][j:j+m] != dat_b[k]:
                t = False
                continue
            if t:
                break
        if t:
            break
    if t:
        break

print("Yes" if t else "No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
dat_a = []
dat_b = []
for i in range(n):
    dat_a.append(input())
for i in range(m):
    dat_b.append(input())

for i in range(n - m):
    t = True
    for j in range(n - m):
        for k in range(m):
            if dat_a[i+ k][j:j+m] != dat_b[k]:
                t = False
                continue
        if t:
            break
    if t:
        break

print("Yes" if t else "No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
dat_a = []
dat_b = []
for i in range(n):
    dat_a.append(input())
for i in range(m):
    dat_b.append(input())

for i in range(n - m):
    t = True
    for j in range(n - m):
        for k in range(m):
            if dat_a[i+ k][j:j+m] != dat_b[k]:
                t = False
                continue
    if t:
        break
print("Yes" if t else "No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
dat_a = []
dat_b = []
for i in range(n):
    dat_a.append(input())
for i in range(m):
    dat_b.append(input())
for i in range(n - m):
    t = True
    for j in range(n - m):
        for k in range(m):
            #print(dat_a[i + k][j:j+m])
            #print(dat_b[k])
            if dat_a[i+ k][j:j+m] != dat_b[k]:
                t = False
                break
        if t:
            break
    if t:
        break
print("Yes" if t else "No")
Problem p02659 (python)

Fixed submission:
A,B=input().split()
B=int(B.replace(".",""))
A=int(A)*B
print(A//100)

Buggy submission (verdict: Runtime Error):
A,B=list(map(int,input().split()))
B*=100
A=A*B
print(A//100)
Problem p02735 (python)

Fixed submission:
H,W=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
inf=10**9
DP=[[inf]*W for i in range(H)]
DP[0][0]=0 if l[0][0]=="." else 1
for i in range(H):
   for j in range(W):
      if i>0:
         DP[i][j]=min(DP[i][j],DP[i-1][j]+1) if l[i-1][j] == "." and l[i][j]=="#" else min(DP[i][j],DP[i-1][j])
      if j>0:
         DP[i][j]=min(DP[i][j],DP[i][j-1]+1) if l[i][j-1] == "." and l[i][j]=="#" else min(DP[i][j],DP[i][j-1])
print(DP[H-1][W-1])

Buggy submission (verdict: Runtime Error):
W,H=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
DP=[[201]*W for i in range(H)]
DP[0][0]=0
for y in range(H):
   for x in range(W):
      if x ==0 and y==0:
         DP[y][x] += 1 if l[y][x] == "#" else 0
         continue
      elif x == 0:
         DP[y][x] = DP[y-1][x]
      elif y == 0:
         DP[y][x] = DP[y][x-1]
      else:
         DP[y][x] = min(DP[y][x-1],DP[y-1][x])
      DP[y][x] += 1 if l[y][x] == "#" else 0
print(DP[H-1][W-1])

Buggy submission (verdict: Runtime Error):
W,H=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
DP=[[201]*W for i in range(H)]
DP[0][0]=0
for y in range(H):
   for x in range(W):
      if x ==0 and y==0:
         DP[x][y] += 1 if l[x][y] == "#" else 0
         continue
      elif x == 0:
         DP[x][y] = DP[x][y-1]
      elif y == 0:
         DP[x][y] = DP[x-1][y]
      else:
         DP[x][y] = min(DP[x-1][y],DP[x][y-1])
      DP[x][y] += 1 if l[x][y] == "#" else 0
print(DP[W-1][H-1])
Problem p02773 (python)

Fixed submission:
import collections
N = int(input())
listA = []
listB = []
for i in range(N):
    listA.append(input())
c = collections.Counter(listA)
c = c.most_common()
max_number = c[0][1]
listB.append(c[0][0])
A = len(c)
for i in range(1,A):
    if max_number == c[i][1]:
        listB.append(str(c[i][0]))
    else:
        break
listB.sort()
for i in listB:
    print(i)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
listA = []
for i in range(N):
    listA.append(input())
c = collections.Counter(listA)
c = c.most_common()
max_number = c[0][1]
print(c[0][0])
for i in range(1,N+1):
    if max_number == c[i][1]:
        print(c[i][0])
    else:
        exit()
Problem p02785 (python)

Fixed submission:
N,K = list(map(int,input().split()))
R = list(map(int,input().split()))
R.sort(reverse=True)
if N < K:
    print(0)
    exit()
for i in range(K):
    R[i] = 0
print(sum(R))

Buggy submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
R = list(map(int,input().split()))
R.sort(reverse=True)
for i in range(K):
    R[i] = 0
print(sum(R))

Buggy submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
R = list(map(int,input().split()))
R.sort(reverse=True)
for i in range(K):
    R.pop(0)
print(sum(R))
Problem p02793 (python)

Fixed submission:
import fractions
N = int(input())
list_number = list(map(int,input().split(" ")))
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
number_max = lcm_list(list_number)
newlist = list(map(lambda x: number_max // x, list_number))
print(sum(newlist) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
list_number = list(map(int,input().split(" ")))
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
number_max = lcm_list(list_number)
newlist = list(map(lambda x: number_max // x, list_number))
print(sum(newlist) % 1000000007)
Problem p02819 (python)

Fixed submission:
import math
A = int(input())
i = 0
S = 0
B = int(math.sqrt(A))
while i == 0:
    S = 0
    B = int(math.sqrt(A))
    for n in range(2,B + 1):
        if A % n == 0:
            A += 1
            S = 1
            break
    if S == 0:
        print(A)
        exit()

Buggy submission (verdict: Runtime Error):
A = int(input())
i = 0
S = 0
B = int(math.sqrt(A))
while i == 0:
    S = 0
    B = int(math.sqrt(A))
    for n in range(2,B + 1):
        if A % n == 0:
            A += 1
            S = 1
            break
    if S == 0:
        print(A)
        exit()

Buggy submission (verdict: Runtime Error):
A = int(input())
i = 0
S = 0
B = int(math.sqrt(A))
while i == 0:
    S = 0
    B = int(math.sqrt(A))
    for n in range(2,B + 1):
        if A % n == 0:
            A += 1
            S = 1
            break
    if S == 0:
        print(A)
        exit()
Problem p02831 (python)

Fixed submission:
from fractions import gcd
X = input().split(" ")
A = int(X[0])
B = int(X[1])
C = A * B
D = gcd(A,B)
print(C // D)

Buggy submission (verdict: Runtime Error):
X = input().split(" ")
A = int(X[0])
B = int(X[1])
C = A * B
D = fractions.gcd(A,B)
print(round(C / D))

Buggy submission (verdict: Runtime Error):
import math
X = input().split(" ")
A = int(X[0])
B = int(X[1])
C = A * B
D = math.gcd(A,B)
print(round(C / D))

Buggy submission (verdict: Runtime Error):
import math
X = input().split(" ")
A = int(X[0])
B = int(X[1])
C = A * B
D = math.gcd(A,B)
print(C // D)

Buggy submission (verdict: Runtime Error):
import math
X = input().split(" ")
A = int(X[0])
B = int(X[1])
print(str(A * B // math.gcd(A,B)))

Buggy submission (verdict: Runtime Error):
import math
X = input().split(" ")
A = int(X[0])
B = int(X[1])
print(str(A * B // math.gcd(A,B)))
Problem p02836 (python)

Fixed submission:
A = list(input())
import math
B = math.ceil(len(A) / 2)
R = 0
C = A[0:B]
D = A[-B:]
D = D[::-1]
count = 0
for i in range(B):
	if C[count] != D[count]:
		R += 1
	count += 1
print(str(R))

Buggy submission (verdict: Runtime Error):
A = list(input())
B = round(len(A) / 2)
A.pop(B - 1)
R = 0
C = A[0:B-1]
D = A[-(B - 1):]
D.sort(reverse=True)
count = 0
for i in range(B - 1):
	if C[count] != D[count]:
	R += 1
	count += 1
print(str(R))
Problem p02847 (python)

Fixed submission:
S = input()
Dictionary = {"SAT":1,"FRI":2,"THU":3,"WED":4,"TUE":5,"MON":6,"SUN":7}
Day = Dictionary[S]
print(Day)

Buggy submission (verdict: Runtime Error):
S = input()
Dictionary = {"SAT":1,"FRI":2,"THU":3,"WED":4,"TUE":5,"MON":6,"SUN":7}
Day = Dictionary[S]
print(DAY)
Problem p02859 (python)

Fixed submission:
A = int(input())
print(A ** 2)

Buggy submission (verdict: Runtime Error):
A = input()
print(A ** 2)
Problem p02862 (python)

Fixed submission:
mod=10**9+7
N,K=list(map(int,input().split()))
if (N+K)%3==0 and N*2>=K and K*2>=N:
   A=max(N,K)-min(N,K)
   low=(min(N,K)-A)//3
   all_pt=low*2+A
else:
   print(0)
   exit()
up,down=1,1
for i in range(low):
   up=up*(all_pt-i)%mod
   down=down*(i+1)%mod
base=pow(down,mod-2,mod)
print(up*base%mod)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
N,K=list(map(int,input().split()))
if (N+K)%3==0 and N*2>K and K*2>N:
   A=max(N,K)-min(N,K)
   low=(min(N,K)-A)//3
   all_pt=low*2+A
up,down=1,1
for i in range(low):
   up=up*(all_pt-i)%mod
   down=down*(i+1)%mod
base=pow(down,mod-2,mod)
print(up*base%mod)
Problem p02879 (python)

Fixed submission:
A = list(map(int,input().split(" ")))
if max(A) > 9:
	print("-1")
else:
	print(str(A[0] * A[1]))

Buggy submission (verdict: Runtime Error):
A = list(map(int,input.split(" ")))
if max(A) > 9:
	print("-1")
else:
	print(str(A[0] * A[1]))
Problem p02891 (python)

Fixed submission:
A=list(input())
n=int(input())
tmp=0
if len(set(A)) == 1:
   print(len(A)*n//2)
   exit()
sum_n=0
tmp3=0
while A[0] == A[tmp3]:
   tmp3+=1
sum_n+=tmp3
tmp3=0
while A[-1] == A[-1-tmp3]:
   tmp3+=1
sum_n+=tmp3
for i in range(len(A)-1):
   if A[i] == A[i+1]:
      A[i+1]="1"
      tmp+=1
tmp2=0
if A[0] == A[-1]:
   tmp2=n-1
   if sum_n%2 == 1:
      tmp2-=n-1
print(tmp*n+tmp2)

Buggy submission (verdict: Runtime Error):
A=list(input())
n=int(input())
tmp=0
for i in range(len(A)-1):
   if A[i] == A[i+1]:
      A[i+1]=1
      tmp+=1
if A[0] == A[-1]:
   tmp2=n-1
print(tmp*n+tmp2)
Problem p02990 (python)

Fixed submission:
from scipy.special import comb
N,K=list(map(int,input().split()))
mod=10**9+7
red=N-K
for i in range(1,K+1):
   tmp=comb(N-K+1,i,exact=True)*comb(K-1,i-1,exact=True)%mod
   print(tmp)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N,K=list(map(int,input().split()))
mod=10**9+7
red=N-K
for i in range(1,K+1):
   print(int(comb(N-K+1,i)*comb(K-1,i-1)%mod))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N,K=list(map(int,input().split()))
mod=10**9+7
red=N-K
for i in range(1,K+1):
   print(int(comb(red+1,i)*pow(i,K-i)%mod))
Problem p03221 (python)

Fixed submission:
N,M=list(map(int,input().split()))
import sys
l=[list(map(int,_.rstrip().split())) for _ in sys.stdin.readlines()]
n=sorted(l,key=lambda x:x[1])
dic={}
mem=[0]*N
for i,j in n:
   mem[i-1]+=1
   dic[i,j]=str(i).zfill(6)+str(mem[i-1]).zfill(6)
for i,j in l:
   print(dic[i,j])

Buggy submission (verdict: Runtime Error):
N,M=list(map(int,input().split()))
import sys
l=[list(map(int,_.rstrip().split())) for _ in sys.stdin.readlines()]
n=sorted(l,key=lambda x:x[1])
dic={}
mem=[0]*M
for i,j in n:
   mem[i-1]+=1
   dic[i,j]=str(i).zfill(6)+str(mem[i-1]).zfill(6)
for i,j in l:
   print(dic[i,j])
Problem p02598 (python)

Fixed submission:
from math import ceil

def check(x):
    cnt = 0
    for a in A:
        cnt += ceil(a/x)-1
    return cnt <= K

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

left = 0
right = max(A)
while left < right-1:
    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)

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

def check(A,N,i,K):
    cnt=0
    for j in range(N):
        cnt+=ceil(A[j]/i)-1
    if cnt<=K:
        return 1
    else:
        return -1

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
M=A[-1]
res=[0 for _ in range(M+1)]
i=M//2
d=M//2
if K==0:
    print(M)
else:
    while True:
        d//=2
        res[i]=check(A,N,i,K)
        if i>0 and res[i-1]*res[i]==-1:
            ans=i
            break
        elif i<M and res[i]*res[i+1]==-1:
            ans=i+1
            break
        if res[i]==1:
            i-=d
        else:
            i+=d
    print(ans)
    print(res)
Problem p02629 (python)

Fixed submission:
N = int(input())
ans = ''
while N > 0:
    N -= 1
    ans += chr(ord('a') + N % 26)
    N //= 26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = ''
while N > 0:
N -= 1
ans += chr(ord('a') + N % 26)
N //= 26
print(ans[::-1])
Problem p02754 (python)

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

if N%(A+B)<=A:
    print(N//(A+B)*A+N%(A+B))
else:
    print(N//(A+B)*A+A)

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

elif N%(A+B)<=A:
    print(N//(A+B)*A+N%(A+B))
else:
    print(N//(A+B)*A+A)
Problem p02762 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5)

def DFS(i,g):
    if i not in done:
        done.add(i)
        circle.add(i)
        g_list[i]=g
        for f in F[i]:
            DFS(f,g)
    else:
        return

N,M,K=map(int,input().split())
F=[[] for _ in range(N)]
B=[[] for _ in range(N)]

for f in range(M):
    f1,f2=map(int,input().split())
    F[f1-1].append(f2-1)
    F[f2-1].append(f1-1)
for b in range(K):
    b1,b2=map(int,input().split())
    B[b1-1].append(b2-1)
    B[b2-1].append(b1-1)

Group=[]
circle=set()
done=set()
g_list=[0 for _ in range(N)]
g=0
for i in range(N):
    if i not in done:
        DFS(i,g)
        Group.append(circle)
        circle=set()
        g+=1

ans=[-1 for _ in range(N)]
for i in range(N):
    G=g_list[i]
    ans[i]+=len(Group[G])
    for fr in F[i]:
        if fr in Group[G]:
            ans[i]-=1
    for bl in B[i]:
        if bl in Group[G]:
            ans[i]-=1

print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)

def DFS(i):
    if i not in done:
        done.add(i)
        circle.add(i)
        for f in F[i]:
            DFS(f)
    else:
        return

N,M,K=map(int,input().split())
F=[[] for _ in range(N)]
B=[[] for _ in range(N)]

for f in range(M):
    f1,f2=map(int,input().split())
    F[f1-1].append(f2-1)
    F[f2-1].append(f1-1)
for b in range(K):
    b1,b2=map(int,input().split())
    B[b1-1].append(b2-1)
    B[b2-1].append(b1-1)

Group=[]
circle=set()
done=set()
for i in range(N):
    if i not in done:
        DFS(i)
        Group.append(circle)
        circle=set()

ans=[-1 for _ in range(N)]
for i in range(N):
    for j in range(len(Group)):
        if i in Group[j]:
            ans[i]+=len(Group[j])
            break
    for fr in F[i]:
        if fr in Group[j]:
            ans[i]-=1
    for bl in B[i]:
        if bl in Group[j]:
            ans[i]-=1

print(*ans)

Buggy submission (verdict: Runtime Error):
def DFS(i):
    if i not in done:
        done.add(i)
        circle.add(i)
        for f in F[i]:
            DFS(f)
    else:
        return

N,M,K=map(int,input().split())
F=[[] for _ in range(N)]
B=[[] for _ in range(N)]

for f in range(M):
    f1,f2=map(int,input().split())
    F[f1-1].append(f2-1)
    F[f2-1].append(f1-1)
for b in range(K):
    b1,b2=map(int,input().split())
    B[b1-1].append(b2-1)
    B[b2-1].append(b1-1)

Group=[]
circle=set()
done=set()
for i in range(N):
    if i not in done:
        DFS(i)
        Group.append(circle)
        circle=set()

ans=[-1 for _ in range(N)]
for i in range(N):
    for j in range(len(Group)):
        if i in Group[j]:
            ans[i]+=len(Group[j])
            break
    for fr in F[i]:
        if fr in Group[j]:
            ans[i]-=1
    for bl in B[i]:
        if bl in Group[j]:
            ans[i]-=1

print(*ans)
Problem p02793 (python)

Fixed submission:
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

a=10**9+7
N=int(input())
A=list(map(int,input().split()))

common=lcm(A)
ans=0
for i in range(N):
    ans+=common//A[i]
print(ans%a)

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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

a=10**9+7
N=int(input())
A=list(map(int,input().split()))

common=lcm_list(A)
ans=0
for i in range(N):
    ans+=A[i]**(-1)
print(int(common*ans)%a)

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

a=10**9+7
N=int(input())
A=list(map(int,input().split()))

common=lcm_list(A)
B=[]
for i in range(N):
    B.append(common//A[i])
print(sum(B)%a)
Problem p02831 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
A,B=map(int,input().split())
print(A*B//gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
print(A*B//math.gcd(A,B))
Problem p02860 (python)

Fixed submission:
N=int(input())
S=input()

if N%2==0 and S[0:N//2]==S[N//2:N]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
if N%2==1:
    print("No")
elif N==2:
    T1=S[0]
    T2=S[1]
else:
    T1=S[0:(N//2)]
    T2=S[N//2:(N)]
print(T1,T2)
if S==T1+T2:
    print("Yes")
else:
    print("No")
Problem p02879 (python)

Fixed submission:
A,B=map(int,input().split())
if A<10 and B<10:
    print(A*B)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np

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

AA=np.sort(A)
BB=np.sort(B)[::-1]
S=np.sum(A)
CC=np.array([AA[i]*BB[i] for i in range(N)])
if K>S:
    K=S

for j in range(K):
    m=np.argmax(CC)
    AA[m]-=1
    CC[m]=AA[m]*BB[m]
print(np.max(CC))

Buggy submission (verdict: Runtime Error):
import numpy as np

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

AA=np.sort(A)
BB=np.sort(B)[::-1]
S=np.sum(A)
CC=np.array([AA[i]*BB[i] for i in range(N)])
if K>S:
    K=S

for j in range(K):
    m=np.argmax(CC)
    AA[m]-=1
    CC[m]=AA[m]*BB[m]
print(np.max(CC))
Problem p02990 (python)

Fixed submission:
from math import factorial as f
mod=10**9+7

def c(n,k):
    if 0<=k<=n:
        return f(n)//f(k)//f(n-k)
    else:
        return 0

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

for i in range(1,K+1):
    print(c(N-K+1,i)*c(K-1,i-1)%mod)

Buggy submission (verdict: Runtime Error):
from math import factorial as f
def comb(n,k):
    return f(n)//f(k)//f(n-k)
N,K=map(int,input().split())
mod=10**9+7
for i in range(1,K+1):
    print((comb(N-K+1,i)*comb(K-1,i-1))%mod)
Problem p03013 (python)

Fixed submission:
mod=10**9+7

N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]
dp=[1,1]
m=0
if M>0 and a[0]==1:
    dp[1]=0
    m+=1
for i in range(2,N+1):
    if m<M and i==a[m]:
        dp.append(0)
        m+=1
    else:
        dp.append((dp[-1]+dp[-2])%mod)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
mod=10**9+7

N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]
dp=[1,1]
m=0
if a[0]==1:
    dp[1]=0
    m+=1
for i in range(2,N+1):
    if m<M and i==a[m]:
        dp.append(0)
        m+=1
    else:
        dp.append((dp[-1]+dp[-2])%mod)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
from collections import deque

mod=10**9+7

N,M=map(int,input().split())
dp=[1,1]
a=deque()
for i in range(M):
    a.append(int(input()))
if a[0]==1:
    dp[1]=0
    a.popleft()
for i in range(2,N+1):
    if len(a)>0 and i==a[0]:
        dp.append(0)
        a.popleft()
    else:
        dp.append((dp[-1]+dp[-2])%mod)
print(dp[-1])