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

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 9)

def main():
  input = sys.stdin.buffer.readline
  read = sys.stdin.buffer.read
  # Nがノードの数, Qが操作回数
  N, Q = map(int, input().split())
  ABPX = list(map(int, read().split()))
  AB = iter(ABPX[:N+N-2])
  PX = iter(ABPX[N+N-2:])

  parents = [None] * N
  childrens = [set() for _ in range(N)]
  relations = [[] for _ in range(N)]
  shown = set()

  for a, b in zip(AB, AB):
    a -= 1
    b -= 1
    relations[a].append(b)
    relations[b].append(a)

  points = [0] * N
  result = [0] * N

  for p, x in zip(PX, PX):
    p -= 1
    points[p] += x

  def solve(parent, relations, points, result):
    result[parent] += points[parent]
    shown.add(parent)
    for child in relations[parent]:
      if child not in shown:
        result[child] += result[parent]
        solve(child, relations, points, result)
      
  solve(0, relations, points, result)
  print(*result)

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
# Nがノードの数, Qが操作回数
N, Q = map(int, input().split())

points = [0] * N
nodes = [set() for _ in range(N)]
parents = [-1] * N

for _ in range(N - 1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  nodes[a].add(b)
  nodes[b].add(a)

def fill_parent(parent, n):
  global parents, nodes
  parents[n] = parent
  if parent in nodes[n] and len(nodes[n]) == 1:
    return
  for i in nodes[n]:
    if i != parent:
      fill_parent(n, i)

for i in nodes[0]:
  fill_parent(0, i)

h = {}
for i in range(N):
  if parents[i] not in h:
    h[parents[i]] = set()
  h[parents[i]].add(i)

# print(h)
for _ in range(Q):
  p, x = map(int, input().split())
  p -= 1
  points[p] += x

c = [0] * N

def calc(n):
  if n == 0:
    c[n] = points[n]
  else:
    c[n] = points[n] + c[parents[n]]
  if n in h:
    for i in h[n]:
      calc(i)

calc(0)
print(*c)

Buggy submission (verdict: Runtime Error):
def main():
  N, Q = map(lambda i: int(i), input().split(' '))
  vertices = [[] for i in range(N)]
  points = [0] * N
  for n in range(N - 1):
    a, b = map(lambda i: int(i), input().split(' '))
    vertices[a - 1].append(b - 1)
  # print(vertices)
  for q in range(Q):
    p, x = map(lambda i: int(i), input().split(' '))
    add(points, vertices, p - 1, x)
  print(' '.join(list(map(lambda p: str(p), points))))

def add(points, vertices, i, x):
  points[i] += x
  if len(vertices[i]) > 0:
    for v in vertices[i]:
        add(points, vertices, v, x)

main()
Problem p03658 (python)

Fixed submission:
def main():
  N, K = map(lambda i: int(i), input().split(' '))
  l = list(map(lambda i: int(i), input().split(' ')))
  l.sort()
  l.reverse()
  m = 0
  for i in range(K):
    m += l[i]
  print(m)

main()

Buggy submission (verdict: Runtime Error):
def main():
  N, K = map(lambda i: int(i), input().split(' '))
  l = list(map(lambda i: int(i), input().split(' '))
  l.sort()
  l.reverse()
  m = 0
  for i in range(K):
    m += l[i]
  print(m)

main()
Problem p02700 (python)

Fixed submission:
import math
a,b,c,d = map(int,input().split(" "))
taka = math.ceil(c/b)
aoki = math.ceil(a/d)

if taka <= aoki:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
mport math
a,b,c,d = map(int,input().split(" "))
taka = math.ceil(c/b)
aoki = math.ceil(a/d)

if taka <= aoki:
    print("Yes")
else:
    print("No")
Problem p02742 (python)

Fixed submission:
x = list(map(int,input().split(" ")))
h = x[0]
w = x[1]

ans = 0
if h == 1:
    print(1)
elif w == 1:
    print(1)
elif h % 2 == 0:
    ans = int(h/2 * w)
    print(ans)
elif (h % 2 != 0) and (w % 2 == 0):
    ans = int(h * w/2)
    print(ans)
elif (h % 2 != 0) and (w % 2 != 0):
    ans = int((h//2 +1) * (w//2 +1)) + (h//2 * (w - 1 - w//2))
    print(int(ans))

Buggy submission (verdict: Runtime Error):
x = list(map(int,input().split(" ")))
h = x[0]
w = x[1]

ans = 0
if h % 2 == 0:
    for i in range(w):
        ans += h/2
    print(int(ans))
elif w % 2 == 0:
    for i in range(w/2):
        ans += h
    print(int(ans))
else:
    for i in range(w//2):
        ans += h
    ans += h // 2 +1
    print(int(ans))

Buggy submission (verdict: Runtime Error):
ans = 0
if h % 2 == 0:
    for i in range(w):
        ans += h/2
    print(int(ans))
elif w % 2 == 0:
    for i in range(w/2):
        ans += h
    print(int(ans))
else:
    for i in range(w//2):
        ans += h
    ans += h // 2 +1
    print(int(ans))
Problem p02812 (python)

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

count = 0

for i in range(n-2):
    if s[i] == "A":
        if s[i+1] == "B":
            if s[i+2] == "C":
                count += 1

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

count = 0

for i in range(n):
    if s[i] == "A":
        if s[i+1] == "B":
            if s[i+2] == "C":
                count += 1

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

count = 0

for i in range(n):
    if s[i] == "A":
        if s[i+1] == "B":
            if s[i+2] == "C":
                count += 1
            else:
                continue
        else:
            continue
    else:
        continue

print(count)
Problem p02818 (python)

Fixed submission:
n = input()
n_list = n.split(" ")
a = int(n_list[0])
b = int(n_list[1])
k = int(n_list[2])

if k < a:
    a = a-k
    b = b
    print(str(a) + " " + str(b))
elif k >= a and k-a < b:
    b = b - (k-a)
    print(str(0) + " " + str(b))
elif k >= a and k-a >= b:
    a = 0
    b = 0
    print(str(0) + " " + str(0))

Buggy submission (verdict: Runtime Error):
n_list = n.split(" ")
a = int(n_list[0])
b = int(n_list[1])
k = int(n_list[2])

if k < a:
    a = a-k
elif k >= a and k-a < b:
    a = 0
    b = b - (k-a)
elif k-a >= b:
    a = 0
    b = 0

print(str(a) + " " + str(b))
Problem p02848 (python)

Fixed submission:
n = int(input())
s = input()
nl = len(s)

alp =["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
s_ans = ""

for i in range(nl):
    newnumber = alp.index(s[i])+n
    if newnumber > 25:
        newnumber = newnumber - 26
    newi = alp[newnumber]
    s_ans += newi

print(s_ans)

Buggy submission (verdict: Runtime Error):
s = input()
nl = len(s)

alp =["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
s_new = []

for i in range(nl):
    newnumber = alp.index(s[i])+n
    if newnumber > 25:
        newnumber = newnumber - 26
    newi = alp[newnumber]
    s_new.append(newi)

s_ans = ""
for i in range(nl):
    s_ans += s_new[i]
print(s_ans)
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
answer = -1#これなに
m = 0#カウントするやつやね
for i in range(n-1):
    if h[i] >= h[i+1]:
        m += 1
    else:
        answer = max(answer,m)
        m = 0
answer = max(answer,m)
print(answer)

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

plsl = []
plsn = 0
for i in range(n-1):
    if h[i]>= h[i+1] and i == n-2:
        plsn += 1
        # print(plsn)
        plsl.append(plsn)
        # print(plsl)
    elif h[i]>= h[i+1] and i < n-2:
        plsn += 1
        # print(plsn)
    else:
        plsl.append(plsn)
        # print(plsl)
        plsn = 0
        # print(plsn)
plsl.sort(reverse = True)
print(plsl[0])

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

plsl = []
plsn = 0
for i in range(n-1):
    if h[i]>= h[i+1] and i == n-2:
        plsn += 1
        # print(plsn)
        plsl.append(plsn)
        # print(plsl)
    elif h[i]>= h[i+1] and i < n-1:
        plsn += 1
        # print(plsn)
    else:
        plsl.append(plsn)
        # print(plsl)
        plsn = 0
        # print(plsn)
plsl.sort(reverse = True)
print(plsl[0])
Problem p02995 (python)

Fixed submission:
import fractions

x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//d)

cd = c*d // fractions.gcd(c,d)
cd_count = (b//cd) - ((a-1)//cd)
ans = (b+1-a)-c_count-d_count+cd_count

print(ans)

Buggy submission (verdict: Runtime Error):
import math

x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//d)

cd = c*d // math.gcd(c,d)
print(cd)

Buggy submission (verdict: Runtime Error):
import math

x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//d)

cd = c*d // math.gcd(c,d)
cd_count = (b//cd) - ((a-1)//cd)
ans = (b+1-a)-c_count-d_count+cd_count

print(ans)

Buggy submission (verdict: Runtime Error):
import math

x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//d)

cd = c*d // math.gcd(c,d)
cd_count = (b//cd) - ((a-1)//cd)

print((b+1-a)-c_count-d_count+cd_count)

Buggy submission (verdict: Runtime Error):
x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//d)

import math

cd = c*d // math.gcd(c,d)
cd_count = (b//cd) - ((a-1)//cd)

print((b+1-a)-c_count-d_count+cd_count)

Buggy submission (verdict: Runtime Error):
x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//c)

import math

cd = c*d // math.gcd(c,d)
cd_count =  (b//cd) - ((a-1)//cd)

print((b+1-a)-c_count-d_count+cd_count)

Buggy submission (verdict: Runtime Error):
x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//c)

import math

cd = c*d // math.gcd(c,d)
cd_count =  (b//cd) - ((a-1)//cd)

print(cd)
print(c_count)
print(d_count)
print(cd_count)

print((b+1-a)-c_count-d_count+cd_count)
Problem p03071 (python)

Fixed submission:
x = input().split(" ")
a = int(x[0])
b = int(x[1])

ans = 0
num = 0

while num < 2:
    if a >= b:
        ans += a
        a -= 1
    else:
        ans += b
        b -= 1
    num += 1
print(ans)

Buggy submission (verdict: Runtime Error):
x = input().split(" ")
a = int(x[0])
b = int(x[1])

ans = 0
num = 0
while num < 2:
    if a >= b:
        ans += a
        a -= 1
    else:
        asn += b
        b -= 1
    num += 1
print(ans)
Problem p03101 (python)

Fixed submission:
l = input().split(" ")
s = input().split(" ")

H = int(l[0])
W = int(l[1])
h = int(s[0])
w = int(s[1])

print(H*W-(w*H + h*W - w*h))

Buggy submission (verdict: Runtime Error):
l = input().split(" ")
s = input().split(" ")

H = int(l[0])
W = int(l[1])
h = int(s[0])
w = int(s[1])

print(HW-(wH + hW - wh))
Problem p03210 (python)

Fixed submission:
x = int(input())
if x == 3 or x == 5 or x == 7:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
x = int(input())
if x = 3 or x = 5 or x = 7:
    print("YES")
else:
    print("NO")
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().split())
num = abs(n - k)
if num == 0:
    print(0)
    exit()
tmp = n % k
print(min(tmp, abs(tmp - k)))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
num = abs(n - k)
tmp = n % num
print(min(tmp, abs(tmp - k)))
Problem p02923 (python)

Fixed submission:
# coding: utf-8
n = int(input())
lst = list(map(int, input().split()))
cnt = 0
data = []
for i in range(n - 1):
    if lst[i] >= lst[i + 1]:
        cnt += 1
    else:
        data.append(cnt)
        cnt = 0
data.append(cnt)
print(max(data))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
n = int(input())
lst = list(map(int, input().split()))
cnt = 0
data = []
for i in range(n - 1):
    if lst[i] >= lst[i + 1]:
        cnt += 1
    else:
        data.append(cnt)
        cnt = 0
print(max(cnt))
Problem p02934 (python)

Fixed submission:
# coding: utf-8
n = int(input())
a = list(map(int, input().split()))

tmp = 0
for i in a:
    tmp += 1 / i

print(1 / tmp)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
n = int(input())
a = list(map(int, input().split()))

tmp = 0
for i in a:
    tmp += 1 / a

print(tmp)
Problem p03424 (python)

Fixed submission:
# coding: utf-8
# Your code here!
n = int(input())
l = list(map(str, input().split()))
if len(set(l)) == 3:
    print('Three')
else:
    print('Four')

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n = int(input())
l = list(map(int, input().split()))
if len(set(l)) == 3:
    print('Three')
else:
    print('Four')
Problem p02640 (python)

Fixed submission:
S = input( ).split( )
x = int(S[0])
y = int(S[1])
if 2*x <= y <= 4*x and y%2 == 0:
  print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
x=input()
y=input()
if 2*x <= y <= 4*x and y%2 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x=input()
y=input()
if 2*x <= y <= 4*x and y%2 == 0:
    print("Yes")
else:
    print("No")
Problem p02690 (python)

Fixed submission:
import math
def main():
  x = int(input())
  r = range(-1000,1000)
  for i in r:
    for j in r:
      if math.pow(i, 5) - math.pow(j, 5) == x:
        print(str(i) + ' ' + str(j))
        return
main()

Buggy submission (verdict: Runtime Error):
x = int(input())
for i in range(120):
  for j in range(-119, a):
    if i**5 - j**5 == x:
      print(i, j)
      exit()
Problem p02691 (python)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
  d[i+a[i]] += 1
ans = 0
for i in range(n):
  ans += d[i-a[i]]
print(ans)

Buggy submission (verdict: Runtime Error):
def main():
 n,*a=map(int,open(0).read().split());d,s=[0]*n,0
 for i,x in enumerate(a):
  if i+x<n:d[i+x]+=1
  s+=d[i-x]
 print(s)
main()

Buggy submission (verdict: Runtime Error):
def main():
 n,a=map(int,open(0).read().split());d,s=[0]*n,0
 for i,x in enumerate(a):
  if i+x<n:d[i+x]+=1
  if i-x>=0:s+=d[i-x]
 print(s)
main()

Buggy submission (verdict: Runtime Error):
def main():
 n,a,d = int(input()),list(map(int, input().split())),[0]*n
 for i,x in enumerate(a):
  if i+x < n: d[i+x] += 1
 print(sum([d[i-x] for i,x in enumerate(a) if i-x>=0]))
main()
Problem p02696 (python)

Fixed submission:
a, b, n = map(int, input().split())
ans = 0
e = min(n+1,b)
s = max(int(b/a),e-1000)
for i in range(s, e):
  x = (int(a*i/b)-a*int(i/b))
  if ans < x:
    ans = x
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
ans = 0
for i in range(int(b/a), n+1):
  if ans < int(a*i/b)-a*int(i/b);
    ans = ans, int(a*i/b)-a*int(i/b)
  else:
    break
print(ans)
Problem p02697 (python)

Fixed submission:
n, m = map(int, input().split())
if m%2 == 1:
  # for i in range(m):
  #   print(str(i+1) + ' ' + str(2*m-i))
  for i in range(int((m-1)/2)):
    print(str(i+1) + ' ' + str(m-i))
  for i in range(int((m+1)/2)):
    print(str(m+i+1) + ' ' + str(2*m-i+1))
else:
  for i in range(int(m/2)):
    print(str(i+1) + ' ' + str(m-i+1))
  for i in range(int(m/2)):
    print(str(i+m+2) + ' ' + str(2*m-i+1))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
if m%2b == 1:
  for i in range(m):
    print(str(i+1) + ' ' + str(2*m-i))
else:
  for i in range(m/2):
    print(str(i+1) + ' ' + str(m-i+1))
  for i in range(m/2):
    print(str(i+m+2) + ' ' + str(2*m-i+1))
Problem p02702 (python)

Fixed submission:
s = input()
p = 2019
n = 0
ans = 0
mods = [0]*p
mods[0] = 1
for i, j in enumerate(reversed(s)):
  n += int(j)*pow(10, i, p)
  n %= p
  mods[n] += 1
for i in mods:
  ans += i*(i-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
def main():
  n, d, mods = 0, 1, [1]+[0]*2019
  # for i in reversed(input()):
  #   n = (n+int(i)*d)%2019
  #   d = d*10%2019
  #   mods[n] += 1
  for i, j in enumerate(reversed(s)):
  n = (n+int(j)*10**i%2019)%2019
  mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()

Buggy submission (verdict: Runtime Error):
s = input()
n = 0
ans = 0
mods = [0]*p
mods[0] = 1
for i, j in enumerate(reversed(s)):
  n += int(j)*pow(10, i, 2019)
  n %= 2019
  mods[n] += 1
for i in mods:
  ans += i*(i-1)//2
print(ans)
Problem p02713 (python)

Fixed submission:
import math
k = int(input())
ans = k**3 - (k-1)**3
for a in range(2,k+1):
  for b in range(2,k+1):
    tmp = math.gcd(a,b)
    for c in range(2,k+1):
      ans += math.gcd(tmp, c)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
f=fractions.gcd(a,b)
k = int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += fractions.gcd(a, fractions.gcd(b, c))
print(ans)
Problem p03455 (python)

Fixed submission:
nums = input().split(' ')
product = int(nums[0]) * int(nums[1])
if product % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
nums = input().split(' ')
product = int(nums[0]) * int(num[1])
if product % 2 == 0:
  print(Even)
else:
  print(Odd)
Problem p03000 (python)

Fixed submission:
N, X = list(map(int,input().split()))
L = list(map(int,input().split()))
prevd = 0
prevl = 0
ans = 0
for i in range(N+1):
    d = prevd + prevl
    if d <= X:
        ans += 1
    else:
        break
    if i != N:
        prevd = d
        prevl = L[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N, X = list(map(int,input().split()))
L = list(map(int,input().split()))
prevd = 0
prevl = 0
ans = 0
for i in range(N+1):
    d = prevd + prevl
    if d <= X:
        ans += 1
    else:
        break
    prevd = d
    prevl = L[i]
print(ans)
Problem p03106 (python)

Fixed submission:
A, B, K = list(map(int,input().split()))
L = [i for i in range(100,0,-1) if A%i == 0 and B%i == 0]
print(L[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K = list(map(int,input().split()))
L = [str(i) for i in range(100,1,-1) if A%i == 0 and B%i == 0]
if len(L) == 0:
  print(1)
else:
  print(L[K-1])
Problem p03262 (python)

Fixed submission:
import fractions

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

ans = 0
for i in range(len(x)):
    ans = fractions.gcd(ans, abs(X - x[i]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

ans = 0
for i in range(len(x)):
    ans = math.gcd(ans, abs(X - x[i]))

print(ans)
Problem p03328 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000) 
def f(n):
    if n == 0:
        return 0
    else:
        return n + f(n-1)
a, b = list(map(int,input().split()))
i1 = 1
i2 = 2
while True:
    if b - a == f(i2) - f(i1):
        break
    i1 += 1
    i2 += 1
print(f(i1) -a)

Buggy submission (verdict: Runtime Error):
def f(n):
    if n == 0:
        return 0
    else:
        return n + f(n-1)
a, b = list(map(int,input().split()))
i1 = 1
i2 = 2
while True:
    if b - a == f(i2) - f(i1):
        break
    i1 += 1
    i2 += 1
print(f(i1) -a)
Problem p03380 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
amax = max(A)
AA = sorted(A,key=lambda x: abs(amax/2-x))
if AA[0] == amax:
    print(amax,AA[1])
else:
    print(amax,AA[0])

Buggy submission (verdict: Runtime Error):
class Com:
    def __init__(self, MAX = 10000000, MOD = 1000000000007):
        self.MAX = MAX
        self.MOD = MOD
        self._fac = [0]*MAX
        self._finv = [0]*MAX
        self._inv = [0]*MAX
        self._fac[0], self._fac[1] = 1, 1
        self._finv[0], self._finv[1] = 1, 1
        self._inv[1] = 1
        for i in range(2,self.MAX):
            self._fac[i] = self._fac[i - 1] * i % self.MOD
            self._inv[i] = self.MOD - self._inv[self.MOD%i] * (self.MOD // i) % self.MOD
            self._finv[i] = self._finv[i - 1] * self._inv[i] % self.MOD
    
    def com(self, n, k):
        if (n < k):
            return 0
        if (n < 0 or k < 0):
            return 0
        return self._fac[n] * (self._finv[k] * self._finv[n - k] % self.MOD) % self.MOD
n = int(input())
A = list(map(int,input().split()))
amax = max(A)
com = Com(amax+10)
ans = -1
MAX = -1
for a in A:
    if a == amax:continue
    if com.com(amax,a) > MAX:
        MAX = com.com(amax,a)
        ans = a
print(amax,ans)

Buggy submission (verdict: Runtime Error):
class Com:
    def __init__(self, MAX = 1000000, MOD = 1000000007):
        self.MAX = MAX
        self.MOD = MOD
        self._fac = [0]*MAX
        self._finv = [0]*MAX
        self._inv = [0]*MAX
        self._fac[0], self._fac[1] = 1, 1
        self._finv[0], self._finv[1] = 1, 1
        self._inv[1] = 1
        for i in range(2,self.MAX):
            self._fac[i] = self._fac[i - 1] * i % self.MOD
            self._inv[i] = self.MOD - self._inv[self.MOD%i] * (self.MOD // i) % self.MOD
            self._finv[i] = self._finv[i - 1] * self._inv[i] % self.MOD
    
    def com(self, n, k):
        if (n < k):
            return 0
        if (n < 0 or k < 0):
            return 0
        return self._fac[n] * (self._finv[k] * self._finv[n - k] % self.MOD) % self.MOD
n = int(input())
A = list(map(int,input().split()))
amax = max(A)
com = Com()
ans = -1
MAX = -1
for a in A:
    if a == amax:continue
    if com.com(amax,a) > MAX:
        MAX = com.com(amax,a)
        ans = a
print(amax,ans)
Problem p03612 (python)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
count = 0
for i in range(N):
    if i != N-1 and P[i] == i+1:
        P[i],P[i+1]=P[i+1],P[i]
        count += 1
if P[N-1] == N:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int,input().split()))
count = 0
for i in range(N):
    if P[i] == i+1:
        P[i],P[i+1]=P[i+1],P[i]
        count += 1
print(count)
Problem p03807 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
AA = sum([i%2 for i in A])
if N == 1:
    print('YES')
    exit()
if AA % 2 == 1:
    print('NO')
    exit()
print('YES')

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
AA = sum([i%2 for i in A])
if N == 1:
    print('YES')
    exit()
if AA % 2 == 1:
    print('NO')
    exit()
print('YES')
Problem p03101 (python)

Fixed submission:
a = [input() for i in range(2)]
H, W = map(int, a[0].split())
h, w = map(int, a[1].split())
print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input.split())
h, w = map(int, input.split())

print((H-h)*(W-w))
Problem p03102 (python)

Fixed submission:
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
count=0
for n in range(N):
    sum = C
    for m in range(M):
        sum += B[m]*A[n][m]
    if sum > 0:
        count+= 1
print(count)

Buggy submission (verdict: Runtime Error):
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

count = 0
for n in range(N):
  sum = C
  for m in range(M):
    sum += b[m]*a[n][m]
  if sum > 0:
    count += 1
print(count)
Problem p02780 (python)

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

p.insert(0, 0)
for i in range(1, N+1):
    p[i] = (p[i] + 1) / 2 + p[i-1]

s = [0] * (N+1)
for i in range(N-K+1):
    s[i] = p[i+K] - p[i]

print(max(s))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

kernel = [1] * K
est = (p + 1) / 2

est_k = np.convolve(est, kernel)
print(np.max(est_k))
Problem p02982 (python)

Fixed submission:
import numpy as np


def main():
    N, D = map(int, input().split())
    p = [np.array(list(map(int, input().split()))) for _ in range(N)]
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            d = np.sqrt(np.sum(np.power(p[i] - p[j], 2)))
            if d % 1 == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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


def main():
    N, D = map(int, input().split())
    p = [np.array(list(map(int, input().split()))) for _ in range(N)]
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            d = np.sqrt(np.sum(np.power(p[i] - p[j], 2)))
            if d % 1 == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()