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

Fixed submission:
N = int(input())
A_list = list(map(int, input().split()))
ans_list = [0] * (N + 1)
for i in range(N-1):
    ans_list[A_list[i]] += 1
for j in range(N):
    print(ans_list[j + 1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A_list = list(map(int, input().split()))
ans_list = [0] * (N + 1)
for i in range(N-1):
    ans_list[A_list[i]] += 1
for j in range(N+1):
    print(ans_list[j + 1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A_list = list(map(int, input().split()))
B_list = [0]* n
for i in range(1, N):
    print(A_list.count(i))
print(0)
Problem p02688 (python)

Fixed submission:
#coding: utf-8
N, K = map(int, input().split())
A = [0 for _ in range(N)]
ans = 0
for i in range(K):
    d = int(input())
    tmp = list(map(int, input().split()))
    for j in range(d):
        A[tmp[j]-1] += 1
for i in range(N):
    if A[i] == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
from math import ceil, floor
X = int(input())
a = 0
a2 = -a
def sign(v):
    if v < 0:
        return -1
    else:
        return 1
def counter(a):
    v = abs(a)
    for i in range(1, int(v**0.5)+2):
        if v % i == 0:
            if v == i**5:
                return True
    return False
while True:
    a2 = -a
    b = (a**5 - X)
    b2 = (a2**5 - X)
    if counter(b):
        if a**5 - b == X:
            print(a, int(abs(round(b))**(1/5))*sign(b))
            quit()
    if counter(b2):
        if a2 ** 5 - b2 == X:
            print(a2, int(abs(round(b))**(1/5))*sign(b2))
            quit()
    a += 1
Problem p02987 (python)

Fixed submission:
# coding: utf-8
S = list(input())
if len(set(S)) == 2:
    cnt = 0
    for s in set(S):
        if S.count(s) == 2:
            cnt += 1
    if cnt == 2:
        print("Yes")
        exit()
print("No")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
    if n >= r:
        return int(factorial(n) // (factorial(r) * factorial(n - r)))
    else:
        return 0

for i in range(1, K+1):
    print(combination(N-K+1, i) * combination(K-1, i-1)%mod)
Problem p02990 (python)

Fixed submission:
# coding: utf-8
from math import factorial
def combination(n, r):
    if n >= r and n >= 0 and r >= 0:
        return int(factorial(n) // (factorial(r) * factorial(n - r)))
    else:
        return 0
N, K = map(int, input().split())
mod = 10**9 + 7

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

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
    if n > r:
        return int(factorial(n) / (factorial(r) * factorial(n - r)))
    else:
        return 1

for i in range(1, K+1):
    if N == i:
        print(1)
    elif i%2 == 0:
        print(combination(N-K+1, i)*2%mod)
    else:
        print(combination(N-K+1, i)%mod)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
    if n > r:
        return int(factorial(n) / (factorial(r) * factorial(n - r)))
    else:
        return 1
for i in range(1, K+1):
    if i%2 == 0:
        print(combination(N-K+1, i)*2%mod)
    else:
        print(combination(N-K+1, i)%mod)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
    return int(factorial(n) / (factorial(r) * factorial(n - r)))

for i in range(1, K+1):
    if i%2 == 0:
        print(combination(N-K+1, i)*2%mod)
    else:
        print(combination(N-K+1, i)%mod)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
    return int(factorial(n) / (factorial(r) * factorial(n - r)) % mod)

for i in range(1, K+1):
    if i%2 == 0:
        print(combination(N-K+1, i)*2)
    else:
        print(combination(N-K+1, i))
Problem p03038 (python)

Fixed submission:
# coding: utf-8
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)
minus = 0
l = []
for i in range(M):
    b, c = map(int, input().split())
    l.append([b, c])
l.sort(key=lambda x: x[1], reverse=True)
A.sort(reverse=False)
idx = 0
i = 0
ans = 0
while i < N and idx < M:
    if l[idx][0] == 0:
        idx += 1
    if idx >= M:
        ans += A[i]
        i += 1
        continue
    if A[i] < l[idx][1]:
        ans += l[idx][1]
        l[idx][0] -= 1
        i += 1
    else:
        ans += A[i]
        i += 1
    # print("ans =", ans)
for j in range(i, N):
    ans += A[j]
print(ans)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n, m = map(int, input().split())
A = list(map(int, input().split()))
ll = []
for i in range(m):
    b, c = map(int, input().split())
    ll.extend([c] * b)
A.sort(reverse=True)
ll.sort(reverse=True)
i, j = 0, 0
ans = 0
for _ in range(n):
    if A[i] >= ll[j] and i < n:
        ans += A[i]
        i += 1
    elif A[i] < ll[j] and j < n:
        ans += ll[j]
        j += 1
    else:
        ans += A[i]
        i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n, m = map(int, input().split())
A = list(map(int, input().split()))
ll = []
for i in range(m):
    b, c = map(int, input().split())
    ll.extend([c] * b)
A.sort(reverse=True)
ll.sort(reverse=True)
i, j = 0, 0
ans = 0
for _ in range(n):
    if A[i] > ll[j]:
        ans += A[i]
        i += 1
    else:
        ans += ll[j]
        j += 1
print(ans)
Problem p03042 (python)

Fixed submission:
#coding: utf-8
S = input()
year = 99
month = 12
mae, ushiro = int(S[:2]), int(S[2:])
if 0 < mae <= month and 0 < ushiro <= month:
	print("AMBIGUOUS")
elif 0 < mae <= month and 0 <= ushiro <= year:
	print("MMYY")
elif 0 <= mae <= year and 0 < ushiro <= month:
	print("YYMM")
else:
	print("NA")

Buggy submission (verdict: Runtime Error):
#coding: utf-8
S = input()
year = 19
month = 12
mae, ushiro = S[:2], S[2:]
if 0 < mae <= month and 0 < ushiro <= month:
	print("AMBIGUOUS")
elif 0 < mae <= month and 0 < ushiro <= year:
	print("MMYY")
elif 0 < mae <= year and 0 < ushiro <= month:
	print("YYMM")
else:
	print("NA")
Problem p03107 (python)

Fixed submission:
#coding: utf-8
s = list(map(int, input()))
cnt = 0
zero = s.count(0)
one = s.count(1)
print(zero*2 if zero < one else one * 2)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
s = list(map(int, input()))
if len(s) <= 1:
    print(0)
else:
    zero = [i for i, x in enumerate(s) if x == 0]
    one = [i for i, x in enumerate(s) if x == 1]
    zeros = s[:zero[-1]].count(0)
    ones = s[:one[-1]].count(1)
    print(zeros * 2 if zeros < ones else ones * 2)
Problem p03127 (python)

Fixed submission:
from functools import reduce
from fractions import gcd
N = int(input())
monster = list(map(int, input().split()))
print(reduce(gcd, monster))

Buggy submission (verdict: Runtime Error):
N = int(input())
monster = list(map(int, input().split()))
if 1 in monster:
  print(1)
else:
  monster.sort()
  min1, min2 = monster[0], monster[1]
  while min1 >= 0 and min2 > 0:
    if min1 <= min2:
      min2 = min2 % min1
    else:
      min1 = min1 % min2
  print(max(min1, min2))

Buggy submission (verdict: Runtime Error):
N = int(input())
monster = list(map(int, input().split()))
if 1 in monster:
  print(1)
else:
  monster.sort()
  min1, min2 = monster[0], monster[1]
  while min1 >= 0 and min2 > 0:
    if min1 < min2:
      min2 = min2 % min1
    else:
      min1 = min1 % min2
  print(max(min1, min2))

Buggy submission (verdict: Runtime Error):
N = int(input())
monster = list(map(int, input().split()))
if 1 in monster:
  print(1)
else:
  monster.sort()
  min1, min2 = monster[0], monster[1]
  while min1 >= 0 and min2 > 0:
    if min1 < min2:
      min2 = min2 % min1
    else:
      min1 = min1 % min2
  print(min1 + min2)

Buggy submission (verdict: Runtime Error):
N = int(input())
monster = list(map(int, input().split()))
if 1 in monster:
  print(1)
else:
  monster.sort()
  min1, min2 = monster[0], monster[1]
  while min1 >= 0 and min2 > 0:
    if min1 < min2:
      min2 = min2 % min1
    else:
      min1 = min1 % min2
  print(max(min1, min2))
Problem p03135 (python)

Fixed submission:
#coding: utf-8
x, t = map(int, input().split())
print(x / t)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
koma.sort()
print(sum(koma[:M-N]))

Buggy submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
koma.sort()
print(sum(koma[:M-N]))

Buggy submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points = sorted(points)
koma = [points[i+1] - points[i] for i in range(M-1)]
koma.sort(reverse=True)
print(sum(koma[:M-N]
Problem p03137 (python)

Fixed submission:
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))

Buggy submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
for _ in range(N-1):
  koma.remove(max(koma))
print(sum(koma))

Buggy submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
sum_ = sum(koma)
for i in range(N-1):
  sum_ -= max(koma)
  koma.remove(max(koma))
print(sum_)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
for i in range(N-1):
  koma.remove(max(koma))
print(sum(koma))
Problem p03221 (python)

Fixed submission:
#coding: utf-8
from copy import deepcopy


def main():
    N, M = map(int, input().split())
    p_dict = {}
    for i in range(M):
        p, y = map(int, input().split())
        if p not in p_dict.keys():
            p_dict[p] = [[y, p, i]]
        else:
            #yとp元の順番を入れとく
            p_dict[p].append([y, p, i])
    ans = []
    for p in p_dict.keys():
        p_dict[p].sort()
        for i in range(len(p_dict[p])):
            #昇順で並べたときの順番を入れとく
            p_dict[p][i].append(i+1)
            ans.append(p_dict[p][i])
    #ans = [y, p, input_index, sorted_index]
    ans.sort(key=lambda x: x[2])
    for y, p, oi, si in ans:
        print("{:06d}{:06d}".format(p, si))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# coding: utf-8

N, M = map(int, input().split())
p_dict = {}
for i in range(M):
	p, y = map(int, input().split())
	if p not in p_dict.keys():
		p_dict[p] = [[y, p, i]]
    else:
		# yとp元の順番を入れとく
		p_dict[p].append([y, p, i])
ans = []
for p in p_dict.keys():
    p_dict[p].sort()
    for i in range(len(p_dict[p])):
        # 昇順で並べたときの順番を入れとく
        p_dict[p][i].append(i+1)
        ans.append(p_dict[p][i])
# ans = [y, p, input_index, sorted_index]
ans.sort(key=lambda x: x[2])
for y, p, oi, si in ans:
    print("{:06d}{:06d}".format(p, si))
Problem p02570 (python)

Fixed submission:

from sys import stdin

input = stdin.readline().rstrip

#x = input().rstrip()
#n = int(input())

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

D,T,S = map(int, input().split(" "))

if(T * S >= D):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
#from sys import stdin

#input = stdin.readline
#inputRstrip = stdin.readline().rstrip

#x = input().rstrip()
#n = int(input())

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

ST = [input() for i in range(2)]
S = ST[0]
T = ST[1]
ans = len(T)

for i in range(len(S) - len(T) + 1):
	count = len(T)
	for j in range(len(T)):
		if(T[j] == S[i + j]):
			count -= 1
	if(ans > count):
		ans = count
print(ans)

Buggy submission (verdict: Runtime Error):

from sys import stdin

input = stdin.readline().rstrip

#x = input().rstrip()
#n = int(input())

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

D,T,S = input().split()

if(T * S >= D):
	print("Yes")
else:
	print("No")
Problem p02577 (python)

Fixed submission:

N = int(input())

if(N % 9 == 0):
	ans = True
else:
	ans = False



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

Buggy submission (verdict: Runtime Error):

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

ans = True if N % 9 == 0 else False

print("Yes" if ans else "Np")
Problem p02570 (python)

Fixed submission:
D,T,S = map(int,input().split())

if D/S <= T:
    print('Yes')
else:
  	print('No')

Buggy submission (verdict: Runtime Error):
D = input('距離')
T = input('時間')
S = input('速度')
if D/S < T:
  print('Yes')
else:
  print('No')
Problem p02829 (python)

Fixed submission:
q = [1,2,3]

A = int(input())
B = int(input())

q.remove(A)
q.remove(B)

print(q[0])

Buggy submission (verdict: Runtime Error):
q = [0,1,2]

A = int(input())
B = int(input())

q.remove(A)
q.remove(B)

print(q[0])
Problem p02831 (python)

Fixed submission:
#最小公倍数を求める

(A,B) = map(int,input().split(" "))

m=max(A,B)
n=min(A,B)
while m%n != 0:
    temp = n
    n = m%n
    m = temp


print(A*B // n)

Buggy submission (verdict: Runtime Error):

import math

(A,B) = map(int,input().split(" "))
ans = (A * B) // math.gcd(A, B)
print(ans)

Buggy submission (verdict: Runtime Error):
#最小公倍数を求める
import math

(A,B) = map(int,input().split(" "))
ans = (A * B) // math.gcd(A, B)
print(ans)

Buggy submission (verdict: Runtime Error):
#最小公倍数を求める
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
    
(A,B) = input().split(" ")

print(lcm(int(A),int(B)))

Buggy submission (verdict: Runtime Error):
#最小公倍数を求める
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
    
(A,B) = input().split(" ")

print(lcm(int(A),int(B)))
Problem p02597 (python)

Fixed submission:
from collections import deque

N = int(input())
c = list(str(input()))
dw = deque()
dr = deque()

for i, c in enumerate(c, 1):
    if c == 'W':
        dw.append(i)
    else:
        dr.appendleft(i)

ans = 0
while dw and dr:
    w = dw.popleft()
    r = dr.popleft()
    if w < r:
        ans += 1

    else:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
# D - Alter Altar

from collections import deque

N = int(input())
c = list(str(input()))
dw = deque()
dr = deque()

for i, c in enumerate(c, 1):
    if c == 'W':
        dw.append(i)
    else:
        dr.appendleft(i)

ans = 0
while dw:
    w = dw.popleft()
    r = dr.popleft()
    if w < r:
        ans += 1

    else:
        break
print(ans)

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

N = int(input())
c = list(str(input()))
dw = deque()
dr = deque()

for i, c in enumerate(c, 1):
    if c == 'W':
        dw.append(i)
    else:
        dr.appendleft(i)

ans = 0
while dw:
    w = dw.popleft()
    r = dr.popleft()
    print(w, r)
    if w < r:
        ans += 1

    else:
        break
print(ans)
Problem p02623 (python)

Fixed submission:
# C - Tsundoku

import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Asum = [0]
for i in range(N):
    Asum.append(Asum[i] + A[i])

Bsum = [0]
for j in range(M):
    Bsum.append(Bsum[j] + B[j])

ans = 0
for i in range(N+1):
    if Asum[i] > K:
        continue
    tmp = K - Asum[i]
    j = bisect.bisect_right(Bsum, tmp) - 1
    ans = max(ans, i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
# C - Tsundoku
import sys
sys.setrecursionlimit = 10**18

N, M, K = map(int, input().split())
A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
la = len(A)
lb = len(B)
T = 0
r = 0
ans = 0
def dfs(i, j, T, r):
    global ans
    ans = max(ans, r)
    if i < la and T+A[i] <= K:
        dfs(i+1, j, T+A[i], r+1)
    if j < lb and T+B[j] <= K:
        dfs(i, j+1, T+B[j], r+1)
    return
    
dfs(0, 0, T, 0)
print(ans)

Buggy submission (verdict: Runtime Error):
# C - Tsundoku
import sys
sys.setrecursionlimit = 10**18

N, M, K = map(int, input().split())
A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
la = len(A)
lb = len(B)
T = 0
r = 0
ans = 0
def dfs(i, j, T, r):
    global ans
    ans = max(ans, r)
    if i < la and T+A[i] <= K:
        dfs(i+1, j, T+A[i], r+1)
    if j < lb and T+B[j] <= K:
        dfs(i, j+1, T+B[j], r+1)

dfs(0, 0, T, 0)
print(ans)

Buggy submission (verdict: Runtime Error):
# C - Tsundoku
import sys
sys.setrecursionlimit = 10**10

N, M, K = map(int, input().split())
A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
la = len(A)
lb = len(B)
T = 0
r = 0
ans = 0
def dfs(i, j, T, r):
    global ans
    ans = max(ans, r)
    if i < la and T+A[i] <= K:
        dfs(i+1, j, T+A[i], r+1)
    if j < lb and T+B[j] <= K:
        dfs(i, j+1, T+B[j], r+1)

dfs(0, 0, T, 0)
print(ans)

Buggy submission (verdict: Runtime Error):
# C - Tsundoku
import sys
sys.setrecursionlimit = 10**7

N, M, K = map(int, input().split())
A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
la = len(A)
lb = len(B)
T = 0
r = 0
ans = 0
def dfs(i, j, T, r):
    global ans
    ans = max(ans, r)
    if i < la and T+A[i] <= K:
        dfs(i+1, j, T+A[i], r+1)
    if j < lb and T+B[j] <= K:
        dfs(i, j+1, T+B[j], r+1)

dfs(0, 0, T, 0)
print(ans)
Problem p02629 (python)

Fixed submission:
# C - One Quadrillion and One Dalmatians

N = int(input())

ans = ''
while N > 0:
    N -= 1
    t = N % 26
    ans = chr(t+97) + ans
    N //= 26

print(ans)

Buggy submission (verdict: Runtime Error):
# C - One Quadrillion and One Dalmatians
import bisect

N = int(input())

keta = [26 ** i for i in range(1, 12)]
keta_sum = [0] * 12
for i in range(11):
    keta_sum[i+1] = keta_sum[i] + keta[i]
k = bisect.bisect_left(keta_sum, N)
ans = ''

for i in range(k):
    n = N - keta_sum[k-i-1]
    if n > 26:
        s = n // 26
        t = n % 26
    else:
        s = n
        t = n
    if t == 0:
        t = 26
    ans = ans + chr(t+96)
    N = (n//26) + (n%26) + 26

print(ans)
Problem p02679 (python)

Fixed submission:
# E - ∙ (Bullet)
import sys
from collections import defaultdict

readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())

# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。 
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(int)

def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y%x, x)

zeros = 0
for i in range(N):
    A, B = map(int, readline().split())
    # (0, 0)のイワシは他の全てのイワシと仲が悪いため、
    # 1匹のみでしか選ぶことができない。最後にこの数を足す。
    if A == 0 and B == 0:
        zeros += 1
    # (?, 0),(0, ?)のイワシは、?がどのような数字であろうとも
    # この組合せであれば仲が悪い。一律、(1,0)(0,-1)として考える。
    elif A == 0:
        d_S[(1, 0)] += 0
        d_T[(0, -1)] += 1
    elif B == 0:
        d_S[(1, 0)] += 1
        d_T[(0, -1)] += 0
    else:
        g = gcd(A, B)
        A //= g
        B //= g
        # いずれもマイナスの場合、傾きはプラスになる
        if A < 0 and B < 0:
            A *= -1
            B *= -1
        if A * B > 0:
            d_S[(A, B)] += 1
            d_T[(B, -A)] += 0
        # 片方がマイナスの場合、必ずAがマイナスになるよう揃える
        else:
            if A > B:
                A, B = B, A
            d_S[(-A, B)] += 0
            d_T[(B, A)] += 1

ans = 1
for (si, sj), s_cnt in d_S.items():
    t_cnt = d_T[(sj, -1*si)]
    tmp = 0
    tmp += pow(2, s_cnt, MOD) - 1
    tmp += pow(2, t_cnt, MOD) - 1
    tmp += 1
    ans = (ans * tmp)%MOD

ans -= 1
ans += zeros

print(ans%MOD)

Buggy submission (verdict: Runtime Error):
# E - ∙ (Bullet)
import sys
from collections import defaultdict

readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())

# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。 
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(int)

def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y%x, x)

pow2_mod = [1] + [0] * (N-1)
for i in range(1, N):
    pow2_mod[i] = pow2_mod[i-1] * 2 % MOD

zeros = 0
for i in range(N):
    A, B = map(int, readline().split())
    # (0, 0)のイワシは他の全てのイワシと仲が悪いため、
    # 1匹のみでしか選ぶことができない。最後にこの数を足す。
    if A == 0 and B == 0:
        zeros += 1
    # (?, 0),(0, ?)のイワシは、?がどのような数字であろうとも
    # この組合せであれば仲が悪い。一律、(1,0)(0,-1)として考える。
    elif A == 0:
        d_S[(1, 0)] += 0
        d_T[(0, -1)] += 1
    elif B == 0:
        d_S[(1, 0)] += 1
        d_T[(0, -1)] += 0
    else:
        g = gcd(A, B)
        A //= g
        B //= g
        # いずれもマイナスの場合、傾きはプラスになる
        if A < 0 and B < 0:
            A *= -1
            B *= -1
        if A * B > 0:
            d_S[(A, B)] += 1
            d_T[(B, -A)] += 0
        # 片方がマイナスの場合、必ずAがマイナスになるよう揃える
        else:
            if A > B:
                A, B = B, A
            d_S[(-A, B)] += 0
            d_T[(B, A)] += 1

ans = 1
for (si, sj), s_cnt in d_S.items():
    t_cnt = d_T[(sj, -1*si)]
    tmp = 0
    tmp += pow2_mod[s_cnt] - 1 # Sから1匹以上選ぶ組合せ
    tmp += pow2_mod[t_cnt] - 1 # Tから1匹以上選ぶ組合せ
    tmp += 1 # どちらも選ばない組合せ
    ans = (ans * tmp)%MOD

ans -= 1 # 最終的に1匹も選ばない組合せ
ans += zeros # (0, 0)のイワシの数

print(ans%MOD)
Problem p02726 (python)

Fixed submission:
# D - Line++

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
cnt = [0] * N

for i in range(N):
    for j in range(i+1,N):
         tmp = min(j-i, abs(i-X)+abs(j-Y)+1)
         cnt[tmp] += 1

for k in range(1, N):
    print(cnt[k])

Buggy submission (verdict: Runtime Error):
# D - Line++
import numpy as np 

N, X, Y = map(int, input().split())

T = np.zeros((N,N), dtype=np.int64)
for i in range(N):
    for j in range(i+1,N):
        T[i,j] = min(j-i, abs(i-X+1)+abs(j-Y+1)+1)

for k in range(1, N):
    print(np.count_nonzero(T==k))
Problem p02792 (python)

Fixed submission:
import numpy as np

def main():
    N = np.array([str(i) for i in range(1,int(input())+1)])
    C = np.zeros((10,10), dtype=np.int)
    ans = 0

    # C[i][j](0 <= i,j <= 9)のテーブルを構築する: O(N)
    for n in N:
        C[int(n[0])][int(n[-1])] += 1

    for i in range(1,9+1):
        for j in range(1,9+1):
            ans += C[i][j] * C[j][i]

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = np.array([str(i) for i in range(1,int(input())+1)])
C = np.zeros((10,10), dtype=np.int)
ans = 0

# C[i][j](0≦i,j≦9)のテーブルを構築する: O(N)
for n in N:
    C[int(n[0])][int(n[-1])] += 1

for i in range(1,9+1):
    for j in range(1,9+1):
        ans += C[i][j] * C[j][i]

print(ans)
Problem p02833 (python)

Fixed submission:
# E - Double Factorial

N = int(input())

ans = 0
p = 10

if (N%2==0):
    while True:
        if p > N:
            break
        ans += N // p
        p *= 5

print(ans)

Buggy submission (verdict: Runtime Error):
# E - Double Factorial

N = int(input())

ans = 0
p = 10

if (N%2):
    continue
else:
    while True:
        if p > N:
            break
        ans += N // p
        p *= 5

print(ans)