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

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

ans = []
RL = []
s = "R"
flag = False
for i in range(1, N):
  if S[i] == "L" or S[i] == "R" and S[i - 1] == "R":
    s += S[i]
  else:
    RL.append(s)
    s = "R"
RL.append(s)

for rl in RL:
  for i in range(len(rl)):
    if rl[i] == "R" and rl[i + 1] == "L" or rl[i] == "L" and rl[i - 1] == "R":
      if i % 2 == 1:
        ans.append(len(rl) // 2)
      else:
        ans.append((len(rl) + 1) // 2)
    else:
      ans.append(0)

for i in range(N):
  print(ans[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
c = [1 for _ in range(N)]

dic = {}
freq = 0
start = 0
for i in range(int(N ** 0.5) + 1):
  tmp = [0 for _ in range(N)]
  for j in range(N):
    if j > 0 and S[j - 1] == "R":
      tmp[j] += c[j - 1]
    if j < N - 1 and S[j + 1] == "L":
      tmp[j] += c[j + 1]
  c = tmp
  if str(c) in dic.keys():
    freq = i - dic[str(c)]
    start = dic[str(c)]
    break
  else:
    dic[str(c)] = i

n = start + ((10 ** 100 - start - 1) % freq)
key = [k for k, v in dic.items() if v == n][0]
key = key.replace("[", "").replace("]", "")
k = list(key.split(", "))
for i in range(N):
  print(k[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
c = [1 for _ in range(N)]

dic = {}
freq = 0
start = 0
for i in range(int(N ** 0.5)):
  tmp = [0 for _ in range(N)]
  for j in range(N):
    if j > 0 and S[j - 1] == "R":
      tmp[j] += c[j - 1]
    if j < N - 1 and S[j + 1] == "L":
      tmp[j] += c[j + 1]
  c = tmp
  if str(c) in dic.keys():
    freq = i - dic[str(c)]
    start = dic[str(c)]
    break
  else:
    dic[str(c)] = i

n = start + ((10 ** 100 - start - 1) % freq)
key = [k for k, v in dic.items() if v == n][0]
key = key.replace("[", "").replace("]", "")
k = list(key.split(", "))
for i in range(N):
  print(k[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
c = [1 for _ in range(N)]

dic = {}
freq = 0
start = 0
for i in range(int(N ** 0.5):
  tmp = [0 for _ in range(N)]
  for j in range(N):
    if j > 0 and S[j - 1] == "R":
      tmp[j] += c[j - 1]
    if j < N - 1 and S[j + 1] == "L":
      tmp[j] += c[j + 1]
  c = tmp
  if str(c) in dic.keys():
    freq = i - dic[str(c)]
    start = dic[str(c)]
    break
  else:
    dic[str(c)] = i

n = start + ((10 ** 100 - start - 1) % freq)
key = [k for k, v in dic.items() if v == n][0]
key = key.replace("[", "").replace("]", "")
k = list(key.split(", "))
for i in range(N):
  print(k[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")
Problem p02984 (python)

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

ans = 0
for i in range(N):
  tmp = ans
  if i == 0:
    for j in range(N):
      if j % 2 == 0:
        ans += A[j]
      else:
        ans -= A[j]
  else:
    ans = 2 * A[i - 1] - tmp

  tmp = ans
  print(ans, end = "")
  if i != N - 1:
    print(" ", end = "")
  else:
    print()

Buggy submission (verdict: Runtime Error):
from numpy.linalg import solve
N = int(input())
A = list(map(int, input().split()))

left = [[0 for _ in range(N)] for _ in range(N)]
right = []
for i in range(N):
  right.append(2 * A[i] + 2 * A[(i + 1) % N])
  for j in range(N):
    if j == i or j == (i + 2) % N:
      left[i][j] = 1
    if j == (i + 1) % N:
      left[i][j] = 2

ans = solve(left, right)
for i in range(N):
  print(int(round(ans[i])), end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")
Problem p02990 (python)

Fixed submission:
N, K = map(int, input().split())
MOD = 1000000007

fact = [1]
for i in range(1, N):
  fact.append(fact[-1] * i)

def comb(n, k):
  return (fact[n] // (fact[n - k] * fact[k])) % MOD

def f2(n, k):
  return comb(n + k - 1, k - 1)

def f(n, k):
  if n < k:
    return 0
  if n == 0 and k == 0:
    return 1
  if k < 1:
    return 0
  return f2(n - k, k)

for i in range(1, K + 1):
  blue = f(K, i)
  red = (f(N - K, i - 1) + 2 * f(N - K, i) + f(N - K, i + 1)) % MOD
  ans = blue * red
  print(ans % MOD)

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

fact = [1]
for i in range(1, N):
  fact.append(fact[-1] * i)

def comb(n, k):
  return (fact[n] // (fact[n - k] * fact[k])) % MOD

def f2(n, k):
  return comb(n + k - 1, k - 1)

def f(n, k):
  if n < k:
    return
  if n == 0 and k == 0:
    return 1
  if k < 1:
    return 0
  return f2(n - k, k)

for i in range(1, K + 1):
  blue = f(K, i)
  red = (f(N - K, i - 1) + 2 * f(N - K, i) + f(N - K, i + 1)) % MOD
  ans = blue * red
  print(ans % MOD)
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
lenA = len(A)
minA = min(A)
BC.sort(reverse = True, key = lambda x:x[1])

i = 0
cnt = 0
while cnt < lenA and i < M:
  A.extend([BC[i][1] for _ in range(BC[i][0])])
  cnt += BC[i][0]
  i += 1
A.sort(reverse = True)
l = A[0:lenA]

print(sum(l))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
lenA = len(A)
minA = min(A)
BC.sort(reverse = True, key = lambda x:x[1])

i = 0
cnt = 0
while cnt < lenA:
  A.extend([BC[i][1] for _ in range(BC[i][0])])
  cnt += BC[i][0]
  i += 1
A.sort(reverse = True)
l = A[0:lenA]

print(sum(l))
Problem p03137 (python)

Fixed submission:
def game(n, m, x_list):
  if n >= m:
    return 0
  
  x_list.sort()
  interval = []
  for i in range(m - 1):
    interval.append(x_list[i + 1] - x_list[i])
  interval.sort(reverse = True)
  sum_interval = 0
  for i in range(n - 1):
    sum_interval += interval[i]
  return x_list[m - 1] - x_list[0] - sum_interval

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

print(game(n, m, x))

Buggy submission (verdict: Runtime Error):
def game(n, m, x_list):
  if n >= m:
    return 0
  x_list.sort()
  count = 0
  stone = [x_list[0]]
  
  interval = []
  for i in range(m - 1):
    interval.append(x_list[i + 1] - x_list[i])
    interval.sort(reverse = True)
    if len(interval) > n - 1:
      del(interval[n - 1])
  tmp = 0
  for i in range(n - 1):
    for j in range(tmp, m - 1):
      if x_list[j + 1] - x_list[j] == interval[i]:
        stone.append(x_list[j + 1])
        tmp = j + 1
        break
  stone.sort()

  tmp = 1
  for i in range(n):
    for j in range(tmp, m):
      if i == n - 1:
        if x_list[j] == stone[n - 1]:
          count += abs(x_list[m - 1] - x_list[j])
          break
      elif x_list[j] == stone[i + 1]:
        count += abs(x_list[j - 1] - stone[i])
        tmp = j + 1
        break
  return count

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

print(game(n, m, x))
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
iPYx = []
for i in range(M):
  P, Y = map(int, input().split())
  iPYx.append([i, P, Y])

iPYx.sort(key = lambda x: (x[1], x[2]))
cnt = 0
for i in range(M):
  if i == 0 or iPYx[i][1] != iPYx[i - 1][1]:
    cnt = 1
  else:
    cnt += 1
  iPYx[i].append(cnt)
iPYx.sort(key = lambda x: x[0])
for i in range(M):
  print("{:06}{:06}".format(iPYx[i][1], iPYx[i][3]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
PYI = []
for i in range(M):
  pi, yi = map(int, input().split())
  PYI.append("{:06}{:06}{:06}".format(pi, yi, i))
  
ID = ["" for i in range(M)]
PYI.sort()
count = 0
for i in range(M):
  y = int(PYI[i][6 : 12])
  if i == 0 or PYI[i][0 : 6] != PYI[i - 1][0 : 6]:
    count = 1
  else:
    count += 1
  ID[int(PYI[i][12 :])] = "{}{:06}".format(PYI[i][0 : 6], count)

for i in range(M):
  print(ID[i])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
PYI = []
for i in range(M):
  pi, yi = map(int, input().split())
  PYI.append("{:06}{:06}{:06}".format(pi, yi, i))
ID = ["" for i in range(M)]
PYI.sort()
count = 0
for i in range(M):
  y = int(PYI[i][6 : 12])
  if i == 0 or PYI[i][0 : 6] != PYI[i - 1][0 : 6]:
    count = 1
  else:
    count += 1
  ID[int(PYI[i][12 :])] = "{}{:06}".format(PYI[i][0 : 6], count)
for i in range(M):
  print(ID[i])
Problem p03013 (python)

Fixed submission:
# 再帰上限あげとく
import sys
sys.setrecursionlimit(10**6)

# 値入力
mod = 7+10**9
N,M = map(int, input().split())
a = [0]*M
for i in range(M):
    a[i] = int(input())

# メモ化フィボナッチ
# 参考:http://python-remrin.hatenadiary.jp/entry/2017/05/19/153228
fib_memo = {}
def fib(n):
    if n < 3: return 1
    if n not in fib_memo:
        fib_memo[n] = fib(n-1) + fib(n-2)
    return fib_memo[n]

now = 0 # 今いる場所と考える
count = 1
for i in a:
    count *= fib(i-now)
    count = count%mod
    if now == i:
        print(0)
        quit()
    now = i+1 # 穴を超えた次の段に移動する

# 最上段までを計算
count *= fib(N-now+1)
print(count%mod)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
a = [0]*M
for i in range(M):
    a[i] = int(input())

fib_memo = {}
def fib(n):
    if n < 3: return 1
    if n not in fib_memo:
        fib_memo[n] = fib(n-1) + fib(n-2)
    return fib_memo[n]

now = 0
count = 1
mod = 7+10**9
for i in a:
    count *= fib(i-now)
    count = count%mod
    if now == i:
        print(0)
        quit()
    now = i+1

count *= fib(N-now+1)

print(count%mod)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
a = [0]*M
for i in range(M):
    a[i] = int(input())

fib_memo = {}
def fib(n):
    if n < 3: return 1
    if n not in fib_memo:
        fib_memo[n] = fib(n-1) + fib(n-2)
    return fib_memo[n]

now = 0
count = 1
for i in a:
    count *= fib(i-now)
    if now != 0 and now+1 == i:
        print(0)
        quit()
    now = i+1

count *= fib(N-now+1)

mod = 7+10**9
print(count%mod)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

N,M= map(int, input().split())
aList = [0] * M
for i in range(M):
    aList[i] = int(input())

aList.sort()
aList.append(N+1)

result = 1
MOD = 7+10**9
now = 0
for a in aList:
    if now == a:
        result = 0
        break

    x = (a - now - 1)
    root = 1
    for i in range(x//2, x):
        root += int(comb(x, (x-i+1), exact = False))
    result = result * root
    result = result % MOD
    now = a+1
print(result)
Problem p03137 (python)

Fixed submission:
N, M = input().split()
N = int(N)
M = int(M)

def diffculc(st, ed):
    if ed < st:
        tmp = ed
        ed = st
        st = tmp
    if st < 0 and ed < 0:
        diff = abs(st - ed)
    elif -1 < st and ed < 0:
        diff = abs(ed - st)
    elif st < 0 and -1 < ed:
        diff = abs(st - ed)
    elif -1 < st and -1 < ed:
        diff = ed - st
    return diff

xList = [int(x) for x in input().split()]
sortedList = sorted(xList)

# 0番目と1番目の間のdiffはdiffcache[0]
diffcache = {}
diff = 0
for i, x in enumerate(sortedList):
    if i == len(sortedList) - 1:
        break
    diffcache[i] = diffculc(sortedList[i+1], x)

rangeset = []
counter = 0
for k, v in sorted(diffcache.items(), key=lambda x: -x[1]):
    if counter == N - 1:
        break
    diffcache.pop(k)
    counter = counter + 1

result = 0
for k,v in diffcache.items():
    result = result + v
print(result)

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

def diffculc(st, ed):
    if ed < st:
        tmp = ed
        ed = st
        st = tmp
    if st < 0 and ed < 0:
        diff = abs(st - ed)
    elif -1 < st and ed < 0:
        diff = abs(ed - st)
    elif st < 0 and -1 < ed:
        diff = abs(st - ed)
    elif -1 < st and -1 < ed:
        diff = ed - st
    return diff

xList = [int(x) for x in input().split()]
sortedList = sorted(xList)

# 0番目と1番目の間のdiffはdiffcache[0]
diffcache = {}
diff = 0
for i, x in enumerate(sortedList):
    if i == len(sortedList) - 1:
        break
    diffcache[i] = diffculc(sortedList[i+1], x)

rangeset = []
counter = 0
for k, v in sorted(diffcache.items(), key=lambda x: -x[1]):
    if counter == N - 1:
        break
    diffcache.pop(k)
    counter = counter + 1

result = 0
for k,v in diffcache:
    result = result + v
print(result)
Problem p03207 (python)

Fixed submission:
n = int(input())
prices = []
for i in range(0,n):
    prices.append(int(input()))
    
coupon = max(prices) // 2
    
total = sum(prices) - coupon
print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
prices = []
for i in range(0,n):
    prices[i] = int(input())

coupon = max(prices) / 2

total = sum(prices) - coupon
print(total)
Problem p02955 (python)

Fixed submission:
n, k = map(int,input().split())
a = list(map(int,input().split()))


def d(x):
    l = []
    for i in range(1, int(x**0.5)+1):
        if x%i==0:
            l.append(i)
            if i != x//i:
                l.append(x//i)
    l.sort(reverse=True)
    return l

s = d(sum(a))
for i in s:
    x = [0 for k in range(n)]
    for j in range(len(a)):
        x[j] = a[j] % i
    x.sort()
    l = [0 for k in range(n+1)]
    r = [0 for k in range(n+1)]
    for j in range(n+1):
        if j == 0:
            l[0] = 0
            r[n-0] = 0
        else:
            l[j] = l[j-1] + x[j-1]
            r[n-j] = r[n-j+1] + (i-x[n-j])
    ans = 1
    for j in range(n+1):
        if l[j] == r[j] and l[j] <= k:
            ans = i
            print(ans)
            exit()

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))

s = 2
l = [0]*n
maxs = 0
suma = sum(a)
while s < suma:
    if s > math.sqrt(suma):
        break
    if sum(a)%s == 0:
        for i in range(n):
            l[i] = a[i]%s
        l.sort()
        sml = sum(l)
        ns = sml//s
        if sml%s == 0 and -sum(l[len(l)-ns:len(l)])+ns*s<=k:
            maxs = s
        s = s + 1
    else:
        s = s + 1
print(maxs)
Problem p02987 (python)

Fixed submission:
s = input()


s1 = s[0]
if s.count(s1) == 2:
    s = s.replace(s1,"")
    s2 = s[0]
    if s.count(s2) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):


import sys
sys.setrecursionlimit(10000)

n, k = map(int,input().split())
nck = {}

def c(n,k):
    if k == 0 or n==k:
        return 1
    elif n<k:
        return 0
    elif k == 1:
        return n  
    elif (n,k) in nck:
        return nck[(n,k)]
    else:
        nck[n,k] = c(n-1,k-1)+c(n-1,k)
        return nck[n,k]

for j in range(1,k+1):
    r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)
Problem p02990 (python)

Fixed submission:


import sys
sys.setrecursionlimit(10000)

n, k = map(int,input().split())
nck = {}

def c(n, r):
    
    if n<r: return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

for j in range(1,k+1):
    r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)

Buggy submission (verdict: Runtime Error):


import sys
sys.setrecursionlimit(10000)

n, k = map(int,input().split())
nck = {}

def c(n,k):
    if k == 0 or n==k:
        return 1
    elif n<k:
        return 0
    elif k == 1:
        return n  
    elif (n,k) in nck:
        return nck[(n,k)]
    else:
        nck[n,k] = c(n-1,k-1)+c(n-1,k)
        return nck[n,k]

for j in range(1,k+1):
    if n == k:
        r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)

Buggy submission (verdict: Runtime Error):


import sys
sys.setrecursionlimit(100000)

n, k = map(int,input().split())
nck = {}

def c(n,k):
    if k == 0 or n==k:
        return 1
    elif k == 1:
        return n  
    elif (n,k) in nck:
        return nck[(n,k)]
    else:
        nck[n,k] = c(n-1,k-1)+c(n-1,k)
        return nck[n,k]

for j in range(1,k+1):
    r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)

Buggy submission (verdict: Runtime Error):


import sys
sys.setrecursionlimit(10000)

n, k = map(int,input().split())
nck = {}

def c(n,k):
    if k == 0 or n==k:
        return 1
    elif k == 1:
        return n  
    elif (n,k) in nck:
        return nck[(n,k)]
    else:
        nck[n,k] = c(n-1,k-1)+c(n-1,k)
        return nck[n,k]

for j in range(1,k+1):
    r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
def kai(m):
    r = 1
    for i in range(1,m+1):
        r = r * i
    return r
def c(a,b):
    r = kai(a)/kai(b)/kai(a-b)
    return r

for j in range(1,k+1):
    print(int(c(n-k+1,j)*c(k-1,j-1)))
Problem p03011 (python)

Fixed submission:
p,q,r = map(int,input().split())
print(min(p+q,q+r,r+p))

Buggy submission (verdict: Runtime Error):
p,q,r = map(int,input().split())
print(min(min(p+q,q+r),r+p)))

Buggy submission (verdict: Runtime Error):
p,q,r = map(int,input().split)
print(min(p+q,q+r,r+p))
Problem p03041 (python)

Fixed submission:
n,k = map(int,input().split())
s = input()
 
if s[k-1] == "A":
  s=s[0:k-1]+"a"+s[k:n]
elif s[k-1] == "B":
  s=s[0:k-1]+"b"+s[k:n]
else:
  s=s[0:k-1]+"c"+s[k:n]
print(s)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()
 
if s[k-1] == "A":
  s=s[0:k-1]+"a"+s[k:n]
elif s[k] == "B":
  s=s[0:k-1]+"b"+s[k:n]
else:
  s=s[0:k-1]+"c"+s[k:n]
print(s)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()

if s[k] == "A":
  s=s[0:k]+"a"+s[k+1:n]
elif s[k] == "B":
  s=s[0:k]+"b"+s[k+1:n]
else:
  s=s[0:k]+"c"+s[k+1:n]
print(s)
Problem p03045 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)
n , m = map(int,input().split())
g = [i for i in range(n)]
def find(x):
    if g[x] == x:
        return x
    g[x] = find(g[x])
    return g[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x!=y:
        g[x] = y

for i in range(m):
    xi,yi,zi = map(int,input().split())
    union(xi-1,yi-1)

ans = 0
for i in range(n):
    if find(i) == i:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n , m = map(int,input().split())
g = [i for i in range(n)]
def find(x):
    if g[x] == x:
        return x
    g[x] = find(g[x])
    return g[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x!=y:
        g[x] = y

for i in range(m):
    xi,yi,zi = map(int,input().split())
    union(xi-1,yi-1)

print(len(set([find(i) for i in range(n)])))

Buggy submission (verdict: Runtime Error):
n , m = map(int,input().split())
d = {}

g = [i for i in range(n+1)]
def find(x):
    if g[x] == x:
        return x
    g[x] = find(g[x])
    return g[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x!=y:
        g[x] = y

for i in range(m):
    xi,yi,zi = map(int,input().split())
    union(xi,yi)

print(len(set([find(i) for i in range(1,n+1)])))

Buggy submission (verdict: Runtime Error):
n , m = map(int,input().split())
d = {}
for i in range(m):
    xi, yi, zi = map(int,input().split())
    if xi in d:
        d[xi] += [yi]
    else:
        d[xi] = [yi]
    if yi in d:
        d[yi] += [xi]
    else:
        d[yi] = [xi]

def f(x):
    global v
    v.remove(x)
    if x in d:
        for k in d[x]:
            if k in v:
                f(k)


v = [i+1 for i in range(n)]
count = 0
while len(v) > 0:
    f(v[0])
    count += 1
print(count)
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a>k:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
r = [b-a,c-b,d-c,e-d]
count = 0
for rr in r:
  if rr > k:
    count += 1
print(count
Problem p03804 (python)

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

ans = "No"
for x in range(0,n-m+1):
    for y in range(0,n-m+1):
        bina = True
        for i in range(m):
            for j in range(m):
                if a[x+i][y+j] != b[i][j]:
                    bina = False
        if bina:
            ans = "Yes"

print(ans)

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

ans = "No"
for x in range(0,n-m):
    for y in range(0,n-m):
        bina = True
        for i in range(m):
            for j in range(m):
                if a[i][j] != b[x+i][y+j]:
                    bina = False
        if bina:
            ans = "Yes"

print(ans)
Problem p03805 (python)

Fixed submission:
from copy import copy
n, m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    ai,bi = map(int,input().split())
    ab[ai-1][bi-1] = 1
    ab[bi-1][ai-1] = 1

count = 0

def dfs(x,v):
    l = copy(v)
    l.append(x)
    if len(l)==n:
        global count
        count += 1
    for i in range(n):
        if ab[x][i] == 1 and not i in l:
            dfs(i,l)
    
dfs(0,[])
print(count)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    ai,bi = map(int,input().split())
    ab[ai-1][bi-1] = 1
    ab[bi-1][ai-1] = 1

count = 0

def dfs(x,v):
    l = v.copy()
    l.append(x)
    if len(l)==n:
        global count
        count += 1
    for i in range(n):
        if ab[x][i] == 1 and not i in l:
            dfs(i,l)
    
dfs(0,[])
print(count)
Problem p03834 (python)

Fixed submission:
s = input()
print(s.replace(","," "))

Buggy submission (verdict: Runtime Error):
s = input()
print(s[0:5]+" "+s[5:12]+" "s[12:19])
Problem p03835 (python)

Fixed submission:
k,s = map(int,input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        z = s-i-j
        if z>=0 and z<=k:
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
k,s = map(int,input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        z = s-x-y
        if z>=0 and z<=k:
            count += 1

print(count)
Problem p02880 (python)

Fixed submission:
N = int(input())
dict = {}

for i in range(1, 10):
    for j in range(i, 10):
        dict[i*j] = True
print('Yes' if dict.get(N) else 'No')

Buggy submission (verdict: Runtime Error):
N = input()
dict = {}

for i in range(1: 10):
    for j in range(i+1: 10):
        dict[i*j] = True

return dict.get(N)
Problem p02729 (python)

Fixed submission:
import math

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

def f(a):
    if a > 1:
        return int(math.factorial(a) / math.factorial(a-2) / 2)
    else:
        return 0

print(f(N) + f(M))

Buggy submission (verdict: Runtime Error):
import math

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

n = math.factorial(N) / math.factorial(N-2) / 2
m = math.factorial(M) / math.factorial(M-2) / 2

print(int(n + m))
Problem p02753 (python)

Fixed submission:
S = input()

if len(set(S)) == 2:
    print("Yes")
else:
    print("No")

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

ans = N // (A + B) * A
temp = N % (A + B)
if temp < A:
    ans += temp
else:
    ans += A
print(ans)
Problem p03327 (python)

Fixed submission:
n = int(input())

if n <= 999:
    print("ABC")
else:
    print("ABD")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

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