Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())

a = [K]*N


for i in range(Q):
    A = int(input())

    a[A-1] += 1

    a = list(map(lambda x: x-1, a))

for i in a:
    if i > 0:
        print('Yes')
    else:
        print('No')

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

a = {}

for i in range(Q):
    A = int(input()) - 1

    if A in a.keys():
        a[A] += 1
    else:
        a[A] = 1

    K -= 1

count = 0

if K > 0:
    for i in range(N):
        print('Yes')
else:
    for i in range(N):
        if i in a.keys():
            if a[i] + K > 0:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    count = 0
    for j in range(i, N):
        try:
            if H[j] < H[j+1]:
                break
            else:
                count += 1
        except IndexError:
            pass

    ans = max(ans, count)

print(ans)

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

count = 0
ans = 0
a = 0

for i in H:
    a, b = i, a

    if a <= b:
        count += 1
    else:
        count = 0

    ans = max(ans, count)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = []

for i in range(N):
    A.append(int(input()))

for i in range(N):
    if i == 0:
        print(max(A[1:]))
    elif i == N-1:
        print(max(A[:N-1]))
    else:
        print(max(max(A[:i]), max(A[i+1:])))



Fixed submission:
N = int(input())
maxv1 = 0
maxv2 = 0

for i in range(N):
    a = int(input())
    if a >= maxv1:
        maxv1, maxv2 = a, maxv1
        flag = i
        continue
    if a >= maxv2:
        maxv2 = a

for i in range(N):
    if i == flag:
        print(maxv2)
    else:
        print(maxv1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = []

for i in range(N):
    A.append(int(input()))

for i in range(N):
    if i == 0:
        print(max(A[1:]))
    elif i == N-1:
        print(max(A[:N-1]))
    else:
        print(max(max(A[:i]), max(A[i+1:])))



Fixed submission:
N = int(input())
maxv1 = 0
maxv2 = 0

for i in range(N):
    a = int(input())
    if a >= maxv1:
        maxv1, maxv2 = a, maxv1
        flag = i
        continue
    if a >= maxv2:
        maxv2 = a

for i in range(N):
    if i == flag:
        print(maxv2)
    else:
        print(maxv1)
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]

maxv = 0
b = 5
for i in range(5):
    if maxv < 10 - (a[i]%10) and a[i] % 10 != 0:
        maxv, b = 10 - (a[i]%10), i

ans = 0

for i in range(5):
    if i != b:
        ans += a[i]

    if ans % 10 != 0:
        for j in range(10):
            ans += 1
            if ans % 10 == 0:
                break

ans += a[b]
print(ans)

Fixed submission:
a = [int(input()) for _ in range(5)]

maxv = 0
b = 4
for i in range(5):
    if maxv < 10 - (a[i]%10) and a[i] % 10 != 0:
        maxv, b = 10 - (a[i]%10), i

ans = 0

for i in range(5):
    if i != b:
        ans += a[i]

    if ans % 10 != 0:
        for j in range(10):
            ans += 1
            if ans % 10 == 0:
                break

ans += a[b]
print(ans)

Buggy python submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]

maxv = 0
for i in range(5):
    if maxv < 10 - (a[i]%10) and a[i] % 10 != 0:
        maxv, b = 10 - (a[i]%10), i

ans = 0

for i in range(5):
    if i != b:
        ans += a[i]

    if ans % 10 != 0:
        for j in range(10):
            ans += 1
            if ans % 10 == 0:
                break

ans += a[b]
print(ans)

Fixed submission:
a = [int(input()) for _ in range(5)]

maxv = 0
b = 4
for i in range(5):
    if maxv < 10 - (a[i]%10) and a[i] % 10 != 0:
        maxv, b = 10 - (a[i]%10), i

ans = 0

for i in range(5):
    if i != b:
        ans += a[i]

    if ans % 10 != 0:
        for j in range(10):
            ans += 1
            if ans % 10 == 0:
                break

ans += a[b]
print(ans)

Buggy python submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]

maxv = 0
for i in range(5):
    if maxv < 10 - (a[i]%10) and a[i] % 10 != 0:
        maxv, b = 10 - (a[i]%10), i

ans = 0

for i in range(5):
    if i != b:
        ans += a[i]

    if ans % 10 != 0:
        for j in range(10):
            ans += 1
            if ans % 10 == 0:
                break

ans += a[b]
print(ans)

Fixed submission:
a = [int(input()) for _ in range(5)]

maxv = 0
b = 4
for i in range(5):
    if maxv < 10 - (a[i]%10) and a[i] % 10 != 0:
        maxv, b = 10 - (a[i]%10), i

ans = 0

for i in range(5):
    if i != b:
        ans += a[i]

    if ans % 10 != 0:
        for j in range(10):
            ans += 1
            if ans % 10 == 0:
                break

ans += a[b]
print(ans)
Buggy python submission (verdict: Runtime Error):
D = input()
eve = 'Eve'
print("Christmas " + eve * (25 - D))

Fixed submission:
D = input()
eve = ' Eve' * (25 - int(D))
print('Christmas' + eve)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

h = []
ans = 10**9

for i in range(N):
    h.append(int(input()))

h.sort()

for i in range(N-K+1):
    ans = min(max(h[i:i+K]) - min(h[i:i+K]), ans)


print(ans)

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

h = []
ans = 10**9

for i in range(N):
    h.append(int(input()))

h.sort()

for i in range(N-K+1):
    ans = min(h[i+K-1]-h[i], ans)


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int, input().split())

for i in range(K):
    A, B, C = B+C, A+C, A+B

if abs(A-B) > 10**18:
    print('Unfair')
else:
    print(A-B)

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

if K == 0:
    print(A-B)
    exit()

A, B, C = B+C, C+A, A+B

if abs(A-B) > 10**18:
    print('Unfair')
else:
    if K % 2 == 1:
        print(A-B)
    else:
        print(-(A-B))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

l = len(s)
ans = 0
tmp = 0

for i in range(l-1):
    if s[i] == 'A':
        count = 1
        for j in range(i+1, l):
            count += 1
            if s[j] == 'Z':
                tmp = count

        ans = max(ans, tmp)

print(ans)

Fixed submission:
s = input()

ans = 0
tmp = 0
flag = 0

for i, j in enumerate(s):
    if flag == 0 and j == 'A':
        tmp = i
        flag = 1
    elif flag == 1 and j == 'Z':
        ans = max(ans, i-tmp+1)
        flag = 2
    elif flag == 2:
        if j == 'Z':
            ans = max(ans, i-tmp+1)
        elif j == 'A':
            flag = 1

print(ans)
Buggy python submission (verdict: Runtime Error):
A = int(input())

print(a+a**2+a**3)

Fixed submission:
a = int(input())

print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
K = int(input())
A,B = map(int,input().split())

for i in range(A,B+1):
  if i % K == 0:
    flag = 1
    break
if flag == 0:
  print("NG")
else:
  print("OK")

Fixed submission:
K = int(input())
A,B = map(int,input().split())
flag = 0

for i in range(A,B+1):
  if i % K == 0:
    flag = 1
    break
if flag == 0:
  print("NG")
else:
  print("OK")
Buggy python submission (verdict: Runtime Error):
import math
X = int(input())
money = 100
y = 1
while X > money:
  money += moth.floor(money*0.01)
  y += 1
  
print(y)
  

Fixed submission:
import math
X = int(input())
money = 100
y = 0

while X > money:
  money += math.floor(money*0.01)
  y += 1
print(y)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())

d1 = math.ceil(C / B)
d2 = math.ceil(A / D)

if d1 <= d2:
  print("Yes")
else:
  print("No")

Fixed submission:
import math
a,b,c,d = map(int,input().split())

d1 = math.ceil(c / b)
d2 = math.ceil(a/ d)

if d1 <= d2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
ans = 0
for i in range(M):
  A = int(input())
  N -= M
if N >= 0:
  print(N)
else:
  print("-1")

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
ans = N - sum(A)
if ans >= 0:
  print(ans)
else:
  print("-1")
Buggy python submission (verdict: Runtime Error):
N,R = map(int,input().split())
 
if N >= 10:
  print(R)
else:
  print(R + 100*(10-K))

Fixed submission:
N,R = map(int,input().split())
 
if N >= 10:
  print(R)
else:
  print(R + 100*(10-N))

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

if K >= 10:
  print(R)
else:
  print(R + 100*(10-K))

Fixed submission:
N,R = map(int,input().split())
 
if N >= 10:
  print(R)
else:
  print(R + 100*(10-N))
Buggy python submission (verdict: Runtime Error):
a,b = map(str,input().split())
lst = [a*b,b*a]
new = sorted(lst)
print(new[0])

Fixed submission:
a,b = map(str,input().split())
lst = [a*int(b),b*int(a)]
new = sorted(lst)
print(new[0])
Buggy python submission (verdict: Runtime Error):
C = input()
c = chr(ord(c)+1)
print(c)

Fixed submission:
C = input()
c = chr(ord(C)+1)
print(c)
Buggy python submission (verdict: Runtime Error):
A = map(int,input().split())
if A[0]+A[1]+A[2] < 22:
  print("win")
else:
  print("bust")

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

if sum(A)<=21:
  print("win")
else:
  print("bust")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
min = 10**12
for i in range(1,N+1,1):
    for j in range(i,N+1,1):
        ans = i * j
        if ans > N:
            break
        else:
            if ans == N:
                if min >= (i + j - 2):
                    min = i + j - 2
print(min)  

Fixed submission:
N = int(input())
lst = []

for i in range(1,int(N**0.5)+1,1):
  if N % i == 0:
    lst.append(int(i + N/i - 2))
print(min(lst))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = []
for i in range(1,N//2+1,1):
    if N % i == 0:
        ok_lst = [i,int(N/i)]
        lst.append(ok_lst)

min = 10 **12
for j in lst:
    if min >= (j[0] + j[1] - 2):
        min = j[0] + j[1] - 2
print(min)

Fixed submission:
N = int(input())
lst = []

for i in range(1,int(N**0.5)+1,1):
  if N % i == 0:
    lst.append(int(i + N/i - 2))
print(min(lst))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

for i in range(N-1):
  if i == 0:
    count = 1
  else:
    if S[i] != S[i+1]:
      count += 1
print(count)

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

for i in range(N-1):
  if S[i] != S[i+1]:
    ans += 1
ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

for i in range(N-1):
  if i == 0:
    count = 1
  else:
    if S[i] != S[i+1]:
      count += 1
    else:
      continue
print(count)

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

for i in range(N-1):
  if S[i] != S[i+1]:
    ans += 1
ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) #マスの数
H = list(map(int,input().split())) #各マスの高さ

#リストのソートと添字の紐付け
H_sort = []
for i in range(len(H)):
  	a = [H[i],i]
  	H_sort.append(a)
H_sort.sort(reverse=True)

max_move = 0 #移動距離の最大値
for n in range(0,len(H)):
  move = 0
  i = H_sort[n][1]
  if i <= N-2 and max_move < N-1-i:
    while(i <= N-2 and H[i]>=H[i+1]):
      move += 1
      i += 1
    if max_move <= move:
      max_move = move
print(max_move)


Fixed submission:
N = int(input()) #マスの数
H = list(map(int,input().split())) #各マスの高さ

move  = 0
max_move = 0

for i in range(N-1):
  if H[i] >= H[i+1]:
    move += 1
    if max_move <= move:
      max_move = move
  else:
    move = 0
print(max_move)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) #マスの数
H = list(map(int,input().split())) #各マスの高さ

#リストのソートと添字の紐付け
H_sort = []
for i in range(len(H)):
  	a = [H[i],i]
  	H_sort.append(a)
H_sort.sort(reverse=True)

max_move = 0 #移動距離の最大値
for n in range(0,len(H)):
  move = 0
  i = H_sort[n][1]
  if i < N-2:
    while(i <= N-2 and H[i] >= H[i+1]):
    	move += 1
    	i += 1
    if max_move <= move:
      max_move = move
print(max_move)

Fixed submission:
N = int(input()) #マスの数
H = list(map(int,input().split())) #各マスの高さ

move  = 0
max_move = 0

for i in range(N-1):
  if H[i] >= H[i+1]:
    move += 1
    if max_move <= move:
      max_move = move
  else:
    move = 0
print(max_move)
Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split())
count = 0
for x in range(L,R+1,1):
  for y in range(L,R+1,1):
    surplus = y % x
    xor_xy = bin(x ^ y)
    xor_10 = int(xor_xy,2)
    if (surplus == xor_10):
      count += 1
result = count % (10 ** 9 + 7)
print(result)

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

if a >= 3200:
  print(s)
else:
  print("red")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
B = []
def Cumulative_sum(n,A):
  B=[0]
  for i in range(n):
    B.append(A[i] + B[i])
  return B
B = Cumulative_sum(n,A)
ans = 0
B_set = set(B)
for x in B_set:
  count = B.count(x)
  if count > 1:
    ans += (count*(count-1)/2)
print(int(ans))
    



Fixed submission:
n = int(input())
A = list(map(int,input().split()))
B = []
def Cumulative_sum(n,A):
  B=[0]
  for i in range(n):
    B.append(A[i] + B[i])
  return B
B = Cumulative_sum(n,A)
B_sort = sorted(B)
y = 0
ans = 0
count = 1
while(y < n):
  if B_sort[y] == B_sort[y+1]:
    count += 1
    y += 1
  else:
    if count > 1:
      ans += (count*(count-1)/2)
      count = 1
    y += 1
    
if count > 1:
  ans += (count*(count-1)/2)
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
B = []
def Cumulative_sum(n,A):
  B=[0]
  for i in range(n):
    B.append(A[i] + B[i])
  return B
B = Cumulative_sum(n,A)
count = 0
for x in range(n):
  for y in range(x+1,n+1):
    if B[y] - B[x] == 0:
      count += 1
print(count)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
B = []
def Cumulative_sum(n,A):
  B=[0]
  for i in range(n):
    B.append(A[i] + B[i])
  return B
B = Cumulative_sum(n,A)
B_sort = sorted(B)
y = 0
ans = 0
count = 1
while(y < n):
  if B_sort[y] == B_sort[y+1]:
    count += 1
    y += 1
  else:
    if count > 1:
      ans += (count*(count-1)/2)
      count = 1
    y += 1
    
if count > 1:
  ans += (count*(count-1)/2)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())

print(sum(N))

Fixed submission:
N = int(input())

print(sum(range(N+1)))
Buggy python submission (verdict: Runtime Error):
N, M, K =  [int(x) for x in input().split()]

stackA = [int(x) for x in input().split()]
stackB = [int(x) for x in input().split()]

indexB = 0
indexA = 0

books = 0
mostBooks = 0
time = 0

for x in stackB:
    if time + x > K:
        indexB -= 1
        break

    else:
        time += x
        indexB += 1
        books += 1

mostBooks = books

for x in stackA:
    time += x
    books += 1

    while time > K and indexB >= 0:
        time -= stackB[indexB]
        indexB -= 1
        books -= 1

    if indexB < 0 and time > K:
        break

    mostBooks = max(mostBooks, books)

print(mostBooks)

Fixed submission:
N, M, K =  [int(x) for x in input().split()]

stackA = [int(x) for x in input().split()]
stackB = [int(x) for x in input().split()]

indexB = 0
indexA = 0

books = 0
mostBooks = 0
time = 0

for x in stackB:
    if time + x > K:
        break

    else:
        time += x
        indexB += 1
        books += 1

indexB -= 1

mostBooks = books

for x in stackA:
    time += x
    books += 1

    while time > K and indexB >= 0:
        time -= stackB[indexB]
        indexB -= 1
        books -= 1

    if indexB < 0 and time > K:
        break

    mostBooks = max(mostBooks, books)

print(mostBooks)

Buggy python submission (verdict: Runtime Error):
N, M, K =  [int(x) for x in input().split()]

stackA = [int(x) for x in input().split()]
stackB = [int(x) for x in input().split()]

books = 0

while True:
    if len(stackB) == 0:
        if len(stackA) == 0:
            break

        K -= stackA.pop(0)

    elif len(stackA) == 0:
        K -= stackB.pop(0)

    else:
        test = 0
        while stackA[test] == stackB[test]:
            test += 1
          
        if stackA[test] > stackB[test]:
            K -= stackB.pop(0)

        else:
            K -= stackA.pop(0)        

    if K < 0:
        break
        
    books += 1

print(books)

Fixed submission:
N, M, K =  [int(x) for x in input().split()]

stackA = [int(x) for x in input().split()]
stackB = [int(x) for x in input().split()]

indexB = 0
indexA = 0

books = 0
mostBooks = 0
time = 0

for x in stackB:
    if time + x > K:
        break

    else:
        time += x
        indexB += 1
        books += 1

indexB -= 1

mostBooks = books

for x in stackA:
    time += x
    books += 1

    while time > K and indexB >= 0:
        time -= stackB[indexB]
        indexB -= 1
        books -= 1

    if indexB < 0 and time > K:
        break

    mostBooks = max(mostBooks, books)

print(mostBooks)
Buggy python submission (verdict: Runtime Error):
n=int(imput())

ans=0
for i in range(n):
  i=i+1
  a=i
  y=n//i

  ans+=(i*y*(y+1)/2)



print(ans)

Fixed submission:
n=int(input())
 
ans=0
for i in range(n):
  i=i+1
  a=i
  y=n//i
 
  ans+=(i*y*(y+1)/2)
 
 
 
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c=180-n
k=1
while(1):
  if c*k==180*(k-2):
    print(k)
    break
  else:
    k+=1

Fixed submission:
n = int(input())
import numpy as np
x=0
y=0
rad=0
k=1
while(1):
  y+=np.cos(rad*np.pi/180)
  x+=np.sin(rad*np.pi/180)
  if x<0.0001 and y<0.0001:
    print(k)
    break
  else:
    k+=1
    rad+=n

Buggy python submission (verdict: Runtime Error):
x=input()
print(360/x)

Fixed submission:
n = int(input())
import numpy as np
x=0
y=0
rad=0
k=1
while(1):
  y+=np.cos(rad*np.pi/180)
  x+=np.sin(rad*np.pi/180)
  if x<0.0001 and y<0.0001:
    print(k)
    break
  else:
    k+=1
    rad+=n
Buggy python submission (verdict: Runtime Error):
import re
sin = input()
match = re.findall(r'[ACTG]+',sin)
m_len = [len(m) for m in match]
print(max(m_len))

Fixed submission:
import re
sin = input()
match = re.findall(r'[ACTG]+',sin)
m_len = [len(m) for m in match]
print(max(m_len if m_len else '0'))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import numpy as np
from collections import Counter

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = int(input())
    A = LII()
    A.sort()
    C = Counter(A)
    ans = 0
    while len(A) != 0:
        a = A[0]
        A = list(filter(lambda x: x % a != 0, A))
        if C[a] == 1:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3

import sys
import numpy as np
from collections import Counter

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))


def main():
    N = int(input())
    A = LII()
    A.sort() 
    
    if N == 1:
        print(1)
        return

    ax = max(A) + 1
    dp = [0] * ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2

    print(sum(filter(lambda x: x == 1, dp)))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import numpy as np

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = int(input())
    A = LII()
    A.sort()

    B = A.copy()

    for a in A:
        c = B.count(a)
        B = list(filter(lambda x: x % a != 0, B))
        if c == 1:
            B.append(c)

    print(len(B))

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3

import sys
import numpy as np
from collections import Counter

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))


def main():
    N = int(input())
    A = LII()
    A.sort() 
    
    if N == 1:
        print(1)
        return

    ax = max(A) + 1
    dp = [0] * ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2

    print(sum(filter(lambda x: x == 1, dp)))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math

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

def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0
col = m
for k in range(N-1, -1, -1):
    now = col
    now *= combinations(N-1, k);
    if k <= K:
        ans += now
    col *= m-1

print(ans)

Fixed submission:
mod = 998244353


class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod

    def calc(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod


N, M, K = map(int, input().split())
C = Combination(N)

ans = 0
for k in range(K + 1):
    now = C.calc(N - 1, k) * M * pow(M - 1, N - k - 1, mod) % mod
    ans = (ans + now) % mod

print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np

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

A = np.array(list(itertools.combinations_with_replacemeent(range(1, M+1), N)))
s = np.zeros(len(A), np.int32)

for i in range(Q):
    a, b, c, d = map(int, input().split())
    s += d * (A[:, b-1] - A[:, a-1] == c)

print(s.max())

Fixed submission:
import itertools
import numpy as np

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

A = np.array(list(itertools.combinations_with_replacement(range(1, M+1), N)))
s = np.zeros(len(A), np.int32)

for i in range(Q):
    a, b, c, d = map(int, input().split())
    s += d * (A[:, b-1] - A[:, a-1] == c)

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

mx = 0

if N < B:
    print(A * N)//B
else:
    x = (N // B) * B - 1
    print((A*x)//B - A*(x//B))

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

if N < B:
    print((A * N)//B)
else:
    x = (N // B) * B - 1
    print((A*x)//B - A*(x//B))

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())

mx = 0
for i in range(N+1):
    mx = max(mx, (A*i)//B-A*(i//B))
    
print(mx)

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

if N < B:
    print((A * N)//B)
else:
    x = (N // B) * B - 1
    print((A*x)//B - A*(x//B))
Buggy python submission (verdict: Runtime Error):
import numpy as np
from collections import Counter

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

C = Counter(A)

D = np.zeros(N).astype(int)
D -= 1
for i in A:
    if D[i] != -1:
        print(D[i])
        continue
    C[i] -= 1
    res = 0
    for value in C.values():
        res += value * (value - 1) // 2
    C[i] += 1
    D[i] = res
    print(res)

Fixed submission:
import numpy as np
from collections import Counter, defaultdict

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

C = Counter(A)
Normal = defaultdict(int)
Banned = defaultdict(int)

for i in A:
    Normal[i] = C[i] * (C[i]-1) // 2
    Banned[i] = (C[i]-1) * (C[i]-2) // 2
    
Normal_sum = sum(Normal.values())
for i in A:
    print(Normal_sum - (Normal[i] - Banned[i]))