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

Fixed submission:
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

import heapq
def solve(N, M, A):
    pq = [-x for x in A]
    heapq.heapify(pq)

    for _ in xrange(M):
        x = -heapq.heappop(pq)
        x /= 2
        heapq.heappush(pq, -x)
    return -sum(pq)


N, M = rrm()
print solve(N, M, rrm())

Buggy submission (verdict: Runtime Error):
import heapq
readints = lambda: map(int, raw_input().split())

def solve(N, M, A):
    pq = [-x for x in A]
    heapq.heapify(pq)
 
    for _ in xrange(M):
        x = -heapq.heappop(pq)
        x /= 2
        heapq.heappush(pq, -x)
    return -sum(pq)

N, M = readints()
print solve(N, M, rrm())
Problem p02925 (python)

Fixed submission:
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

from collections import deque
def solve(N, A):
    ans = 0
    todo = N * (N-1)
    to_inspect = range(N)
    while True:
        ans += 1
        found = False
        to_inspect2 = set()
        for i in to_inspect:
            row = A[i]
            if row:
                j = row[0]
                if (i not in to_inspect2 and j not in to_inspect2 and
                        A[j] and A[j][0] == i):
                    row.popleft()
                    A[j].popleft()
                    found = True
                    todo -= 2
                    to_inspect2.add(i)
                    to_inspect2.add(j)
        if not todo: return ans
        if not found: return -1
        to_inspect = to_inspect2


N = rri()
A = []
for _ in xrange(N):
    row = rrm()
    A.append(deque(x-1 for x in row))
print solve(N, A)

Buggy submission (verdict: Runtime Error):
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

from collections import deque
def solve(N, A):
    ans = 0
    todo = N * (N-1)
    to_inspect = range(N)
    while True:
        ans += 1
        found = False
        to_inspect2 = set()
        for i in to_inspect:
            row = A[i]
            if row:
                j = row[0]
                if (i not in to_inspect2 and j not in to_inspect2 and
                        A[j] and A[j][0] == i):
                    pairings[i] = j
                    pairings[j] = i
                    row.popleft()
                    A[j].popleft()
                    found = True
                    todo -= 2
                    to_inspect2.add(i)
                    to_inspect2.add(j)
        if not todo: return ans
        if not found: return -1
        to_inspect = to_inspect2


N = rri()
A = []
for _ in xrange(N):
    row = rrm()
    A.append(deque(x-1 for x in row))
print solve(N, A)
Problem p02597 (python)

Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

goal = sorted(S)

ans = 0
for i in range(N):
    if S[i] != goal[i]:
        ans += 1
print(ans // 2)

Buggy submission (verdict: Runtime Error):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

left = 0
right = N - 1

ans = 0
while right > left:
    while left < N and S[left] == 'R':
        left += 1
    while right > left and S[right] == 'W':
        right -= 1
    S[left], S[right] = S[right], S[left]
    ans += 1
    left += 1
    right -= 1

for i in range(right):
    if S[i] == 'W':
        S[i] = 'R'
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

left = 0
right = N - 1

ans = 0
while right - left > 1:
    while left < N and S[left] == 'R':
        left += 1
    while right > left and S[right] == 'W':
        right -= 1
    S[left], S[right] = S[right], S[left]
    ans += 1
    left += 1
    right -= 1

for i in range(right):
    if S[i] == 'W':
        S[i] = 'R'
        ans += 1
print(ans)
Problem p02685 (python)

Fixed submission:
import sys
import itertools
import numpy as np

MOD = 998244353
MAX = 10 ** 5 * 2 + 5

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]

def comInit(mod):
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

def com(n, r, mod):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod

comInit(MOD)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n, m, k = map(int, readline().split())

ans = 0
col = m
for x in range(n - 1, -1, -1):
    now = col
    now *= com(n - 1, x, MOD) % MOD
    if x <= k:
        ans += now
    col = (col * (m - 1)) % MOD

print(ans % MOD)

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

MOD = 998244353
MAX = 10 ** 5 * 2 + 5

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]

def comInit(mod):
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

def com(n, r, mod):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod

comInit(MOD)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n, m, k = map(int, readline().split())

ans = 0
for x in range(k, -1, -1):
    ans += now * com(n - 1, x, MOD) % MOD
    # ans += tmp
print(ans % MOD)

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

MOD = 998244353
MAX = 10 ** 5 * 2 + 5

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]

def comInit(mod):
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

def com(n, r, mod):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod

comInit(MOD)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n, m, k = map(int, readline().split())

ans = 0
now = m * (m - 1) ** (n - k - 2) % MOD
for x in range(k, -1, -1):
    now *= (m - 1) % MOD
    ans += now * com(n - 1, x, MOD) % MOD
    # ans += tmp
print(ans % MOD)
Problem p02723 (python)

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No"
Problem p03252 (python)

Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
T = input()

x = defaultdict(list)
y = defaultdict(list)

for i, t in enumerate(T):
    x[t].append(S[i])

for i, s in enumerate(S):
    y[s].append(T[i])

ok = True
for k, v in x.items():
    a = v[0]
    for c in v:
        if c != a:
            ok = False
            break

for k, v in y.items():
    a = v[0]
    for c in v:
        if c != a:
            ok = False
            break

if ok:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

x = defaultdict(list)

for i, t in enumerate(T):
    x[t].append(S[i])

ok = True
for k, v in x.items():
    a = v[0]
    for c in v:
        if c != a:
            ok = False
            break
if ok:
    print("Yes")
else:
    print("No")
Problem p03265 (python)

Fixed submission:
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4)

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4
Problem p03804 (python)

Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

def check(x, y):
    for i in range(M):
        for j in range(M):
            if y + i >= N or x + j >= N:
                return False
            if A[y + i][x + j] != B[i][j]:
                return False
    return True

for i in range(N):
    for j in range(N):
        if check(i, j):
            print("Yes")
            exit()
print("No")

Buggy submission (verdict: Runtime Error):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

def check(x, y):
    for i in range(M):
        for j in range(M):
            if A[y + i][x + j] != B[i][j]:
                return False
    return True

for i in range(N):
    for j in range(N):
        if check(i, j):
            print("Yes")
            exit()
print("No")
Problem p02580 (python)

Fixed submission:
H, W, M = map(int,input().split())
Bomb = []
for _ in range(M):
    hi, wi = map(lambda x: int(x) - 1, input().split())
    Bomb.append((hi, wi))

counterH = [0] * H
counterW = [0] * W

for (hi, wi) in Bomb:
    counterH[hi] += 1
    counterW[wi] += 1

# 最大のところを選ぶ
max_h = max(counterH)
max_w = max(counterW)

count = 0
for (hi, wi) in Bomb:
    if counterH[hi] == max_h and counterW[wi] == max_w:
        count += 1

# 共通部分を確認 (-1)
ans = max_h + max_w
if count == counterH.count(max_h) * counterW.count(max_w):
    ans -= 1
print(ans)

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

H, W, M = map(int, input().split())
Bomb = [[0] * W for _ in range(H)]

counterH = Counter()
counterW = Counter()

for _ in range(M):
    hi, wi = map(lambda x: int(x) - 1, input().split())
    counterH[hi] += 1
    counterW[wi] += 1
    Bomb[hi][wi] += 1

# for row in Bomb:
#     print(*row)


HH = [h for (h, _) in counterH.most_common(1)]
WW = [w for (w, _) in counterW.most_common(1)]

def count(h, w):
    bomb = 0
    for _w in range(W):
        if Bomb[h][_w] > 0:
            bomb += 1
    for _h in range(H):
        if Bomb[_h][w] > 0:
            bomb += 1
    if Bomb[h][w] > 0:
        bomb -= 1
    return bomb

m = -1
for h in HH:
    for w in range(W):
        m = max(m, count(h, w))
for w in WW:
    for h in range(H):
        m = max(m, count(h, w))

print(m)
# # 2次元累積和
# BombW = [[0] * (W + 1) for _ in range(H)]
# BombH = [[0] * W for _ in range(H + 1)]
# for h in range(H):
#     for w in range(W):
#         BombW[h][w + 1] = BombW[h][w] + Bomb[h][w]
# for w in range(W):
#     for h in range(H):
#         BombH[h + 1][w] = BombH[h][w] + Bomb[h][w]
# for row in BombW:
#     print(*row)
# for row in BombH:
#     print(*row)
Problem p02598 (python)

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

def is_ok(L):
    count = 0
    for a in A:
        count += a // L
        if a % L == 0:
            count -= 1
    return count <= K

ng = 0
ok = max(A)
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc174/tasks/abc174_e

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

if K == 0:
    print(max(A))
    exit()

# K回切って全ての長さをL未満にできるかどうか
def valid(L):
    # print(A, L)
    count = 0
    for a in A:
        # print(a, L, a // L, a % L)
        count += (a - 1) // L
    # print(count)
    return count <= K

# 長さLの二分探索
ng = -1
# ok = max(A) + 1
ok = 10 ** 9
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    # print(m, valid(m))
    if valid(m):
        ok = m
    else:
        ng = m
print(ok)

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

if K == 0:
    print(max(A))
    exit()

# K回切って全ての長さをL未満にできるかどうか
def valid(L):
    # print(A, L)
    count = 0
    for a in A:
        # print(a, L, a // L, a % L)
        count += a // L
    # print(count)
    return count <= K

# 長さLの二分探索
ng = -1
ok = max(A) + 1
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    # print(m, valid(m))
    if valid(m):
        ok = m
    else:
        ng = m
print(ok)

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

if K == 0:
    print(max(A))
    exit()

# K回切って全ての長さをL未満にできるかどうか
def valid(L):
    # print(A, L)
    count = 0
    for a in A:
        # print(a, L, a // L, a % L)
        count += a // L
    # print(count)
    return count <= K

# 長さLの二分探索
ng = -1
ok = max(A) + 1
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    # print(m, valid(m))
    if valid(m):
        ok = m
    else:
        ng = m
print(ok)
Problem p02633 (python)

Fixed submission:
# do simulation

X = int(input())
Y, K = 0, 0
while True:
  Y += X
  K += 1
  if Y % 360 == 0:
    print(K)
    exit()

Buggy submission (verdict: Runtime Error):
# do simulation

X = int(input())
Y, K = 0, 0
while True:
  Y += X
  K += 1
  if Y % 360 == 0:
    print(k)
    exit()
Problem p02771 (python)

Fixed submission:
A, B, C = map(int, input().split())
if len(set({A, B, C})) == 2:
       print("Yes")
else:
       print("No")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if len(set({A, B, C}) == 2:
       print("Yes")
else:
       print("No")
Problem p02777 (python)

Fixed submission:
S,  T = input().split()
r, b = map(int, input().split())
N = input()
 
if S == N:
  r -= 1
elif T == N:
  b -= 1
  
 
print(r, b)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
r, b = map(int, input().split())
N = input()

if S == N:
  r -= 1
elif T == N:
  b -= 1
  
 print(r, b)
Problem p03017 (python)

Fixed submission:
N, A, B, C, D = map(int, input().split())
S = input()
S = "#" + S + "#"

# A -= 1
# B -= 1
# C -= 1
# D -= 1

def can_reach(start, end):
    for i in range(start, end + 1):
        if S[i] == '#' and S[i + 1] == '#':
            return False
    return True


if not can_reach(A, C) or not can_reach(B, D):
    print("No")
    exit()

if C > D:
    cover = False
    for i in range(B, D + 1):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            cover = True
    if not cover:
        print("No")
        exit()


print("Yes")

Buggy submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
S = input()
S = "#" + S + "#"

# A -= 1
# B -= 1
# C -= 1
# D -= 1

def can_reach(start, end):
    for i in range(start, end + 2):
        if S[i] == '#' and S[i + 1] == '#':
            return False
    return True


if not can_reach(A, C) or not can_reach(B, D):
    print("No")
    exit()

if C > D:
    cover = False
    for i in range(B, D + 1):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            cover = True
    if not cover:
        print("No")
        exit()


print("Yes")

Buggy submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
S = input()
S = "#" + S + "#"

# A -= 1
# B -= 1
# C -= 1
# D -= 1

def can_reach(start, end):
    for i in range(start, end + 2):
        if S[i] == '#' and S[i + 1] == '#':
            return False
    return True


if not can_reach(A, C) or not can_reach(B, D):
    print("No")
    exit()

if C > D:
    cover = False
    for i in range(B, D + 1):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            cover = True
    if not cover:
        print("No")
        exit()


print("Yes")
Problem p03617 (python)

Fixed submission:
q, h, s, d = map(int, input().split())
n = int(input())
print((n // 2) * min(8 * q, 4 * h, 2 * s, d) + (n % 2) * min(4 * q, 2 * h, s))

Buggy submission (verdict: Runtime Error):
print((n // 2) * min(8 * q, 4 * h, 2 * s, d) + (n % 2) * min(4 * q, 2 * h, s))
Problem p03634 (python)

Fixed submission:
from heapq import heapify, heappush, heappop

import sys
sys.setrecursionlimit(100000000)

n = int(input())
G = [[] for _ in range(n + 1)]

for _ in range(n - 1):
    ai, bi, ci = map(int, input().split())
    G[ai].append((bi, ci))
    G[bi].append((ai, ci))

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

# # 頂点KからDFSする
# d = [None for _ in range(n + 1)]
# d[K] = 0

# def dfs(v, dist):
#     for (u, cvu) in G[v]:
#         if d[u] is None:
#             d[u] = dist + cvu
#             dfs(u, dist + cvu)

# dfs(K, 0)

# 頂点KからDFSする (heap ver.)
queue = []
d = [None for _ in range(n + 1)]
heappush(queue, (0, K, -1))
while len(queue) > 0:
    dist, index, parent = heappop(queue)
    if d[index] is not None:
        continue
    d[index] = dist
    for (u, cvu) in G[index]:
        if u == parent:
            continue
        heappush(queue, (dist + cvu, u, index))

for _ in range(Q):
    xi, yi = map(int, input().split())
    print(d[xi] + d[yi])

Buggy submission (verdict: Runtime Error):
from heapq import heapify, heappush, heappop

n = int(input())
G = [[] for _ in range(n + 1)]

for _ in range(n - 1):
    ai, bi, ci = map(int, input().split())
    G[ai].append((bi, ci))
    G[bi].append((ai, ci))

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

# 頂点KからDFSする
d = [None for _ in range(n + 1)]

def dfs(v, dist):
    for (u, cvu) in G[v]:
        if d[u] is None:
            d[u] = dist + cvu
            dfs(u, dist + cvu)

d[K] = 0
dfs(K, 0)

for _ in range(Q):
    xi, yi = map(int, input().split())
    print(d[xi] + d[yi])
Problem p03705 (python)

Fixed submission:
n, A, B = map(int, input().split())
if A > B:
  print(0)
elif n == 1:
  if A != B:
    print(0)
  else:
    print(1)
else:
  print((B - A) * (n - 2) + 1)

Buggy submission (verdict: Runtime Error):
n, A, B = map(int, input().split())
if A > B:
  print(0)
elif n == 1:
  if A != B:
    print(0)
  else:
    print(1)
else:
  print((B - A) * (N - 2) + 1)
Problem p02596 (python)

Fixed submission:
K = int(input())
def check(k):
    aaa = 0
    prev = 7%k
    for i in range(0,k):
        aaa+=1
        if prev == 0:
            return(aaa)
        prev = (prev*10+7)%k
    return(-1)
print(check(K))

Buggy submission (verdict: Runtime Error):
K = int(input())
firsta = 7 % K
if firsta == 0:
    print(1)
elif firsta == 77 % K:
    print(-1)
else:
    ans = 2
    preva = 77 % K
    while preva != firsta and preva != 0:
        preva = ((preva*10)+7) % K
        ans += 1
        if preva = firsta:
            ans = -1
    print(ans)
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a=int(a)
b = int(b.replace('.',''))
c = a*b
c = c//100
print(c)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
b = b + "*" + "100"
total = a + "*" + b
print(eval(total)//100)
a, b = input().split()
b = b + "*" + "100"
total = a + "*" + b
print(eval(total)//100)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
b = b + "*" + "100"
total = a + "*" + b
print(eval(total)//100))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
if a >= 3200:
  print("red")
else:
  print("pink")
Problem p03775 (python)

Fixed submission:
n = int(input())
lis = []

for a in range(1, int(n**0.5)+1):
  if n % a == 0:
    lis.append(max(a, int(n/a)))

print(len(str(min(lis))))

Buggy submission (verdict: Runtime Error):
n = int(input())
lis = []

for a in range(1, int(n**0.5)):
  if n % a == 0:
    lis.append(max(a, int(n/a)))

print(len(str(min(lis))))
Problem p03835 (python)

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

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

print(count)

Buggy submission (verdict: Runtime Error):
a
Problem p02792 (python)

Fixed submission:
n = int(input())
d = [[0]*10 for _ in range(10)]
ans = 0
for i in range(1, n+1):
    s = str(i)
    if s[0] == '0' or s[-1] == '0':
        continue
    d[int(s[0])][int(s[-1])] += 1
for i in range(1, 10):
    for j in range(1, 10):
        ans += d[i][j] * d[j][i]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [[0]*10 for _ in range(n)]
ans = 0
for i in range(1, n+1):
    s = str(i)
    if s[0] == '0' or s[-1] == '0':
        continue
    d[int(s[0])][int(s[-1])] += 1
for i in range(1, 10):
    for j in range(1, 10):
        ans += d[i][j] * d[j][i]
print(ans)
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())

if 1 <= a <= 9 and 1 <= b <= 9:
    print(a*b)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
if 1 <= a <= 9 and 1 <= b <= 9:
    print(a*b)
else:
    print(-1)