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

Fixed submission:
import copy

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

ans = [10 ** 12 for i in range(2 ** (N - 1))]
seen = 1  #[[A[j] for j in range(i,N) if A[j] > A[i]] for i in range(0,N)]

for i in range(2 ** (N - 1)):
  AA = copy.deepcopy(A)
  cost = 0
  s = str(bin(i))[2:]
  if s.count("1") >= K:
    continue
    
  for j in range(N - 1):
    m = max(AA[:j + 1])
    a = AA[j + 1]
    if ((i >> j) & 1) and a <= m:
      cost += (m - a + 1)
      AA[j + 1] = m + 1
  
  if len([AA[i] for i in range(1,N) if AA[i] > max(AA[:i])]) >= K - 1:
    ans[i] = cost
    #print(AA,bin(i),cost)
    
print(min(ans))

Buggy submission (verdict: Runtime Error):
import copy

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

ans = [None for i in range(2 ** (N - 1))]
seen = 1  #[[A[j] for j in range(i,N) if A[j] > A[i]] for i in range(0,N)]

for i in range(2 ** (N - 1)):
  AA = copy.deepcopy(A)
  cost = 0
  for j in range(N - 1):
    m = max(AA[:j + 1])
    a = AA[j + 1]
    if ((i >> j) & 1) and a <= m:
      cost += (m - a + 1)
      AA[j + 1] = m + 1
  print(AA,bin(i),cost)
  if len([AA[i] for i in range(1,N) if AA[i] > A[0]]) >= K - 1:
    ans[i] = cost
  
print(min(ans))

Buggy submission (verdict: Runtime Error):
import copy

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

ans = 10 ** 12
seen = 1  #[[A[j] for j in range(i,N) if A[j] > A[i]] for i in range(0,N)]

for i in range(2 ** (N - 1)):
  AA = copy.deepcopy(A)
  cost = 0
  con = 0
  for j in range(N - 1):
    m = max(AA[:j + 1])
    W
    #print(AA[:j + 1])
    a = AA[j + 1]
    if ((i >> j) & 1) and A[j + 1] <= m:
      cost += (m - a + 1)
      AA[j + 1] = m + 1
      con += 1
    if con == K - 1:
      break
  if len([AA[i] for i in range(1,N) if AA[i] > A[0]]) == K - 1:
    ans = min(cost,ans)
  
print(ans)
Problem p03813 (python)

Fixed submission:
N = int(input())

if N >= 1200:
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
X = int(input())

if x >= 1200:
  print("ARC")
else:
  print("ABC")
Problem p03827 (python)

Fixed submission:
N = int(input())
S = input()
m = 0
p = 0
for i in S:
  if i == "D":
    p -= 1
  else:
    p += 1
  if p >= m:
    m = p
print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
m = 0
p = 0
for i in S:
  if i == D:
    p -= 1
  else:
    p += 1
  if p >= m:
    m = p
print(m)
Problem p04043 (python)

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

if A + B + C == 17:
  if A + B or A + C or B + C == 10:
    print("YES")
  else:
    print("NO")
else:
  print("NO")

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

if A + B + C == 17:
  if A + B or A + C or B + C == 10:
    print("YES")
  else:
    print("NO")
else:
  print("NO")
Problem p02664 (python)

Fixed submission:
t = input()

prev = ""
res = []
for i, x in enumerate(t):
    if x == "?":
        if prev == "" and len(t) == 1:
            res.append("D")
        elif prev == "" and (i < len(t) - 1 and t[i+1] == "P"):
            res.append("D")
        elif prev == "" or prev == "D" and (i < len(t) - 1 and t[i+1] != "P"):
            res.append("P")
        else:
            res.append("D")
    else:
        res.append(x)
    prev = res[-1]
print("".join(res))

Buggy submission (verdict: Runtime Error):
t = input()

prev = ""
res = []
for i, x in enumerate(t):
    if x == "?":
        if prev == "" or prev == "D" and (i < len(t) and t[i+1] != "P"):
            res.append("P")
        else:
            res.append("D")
    else:
        res.append(x)
    prev = x
print("".join(res))
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for x in a:
    if x >= sum(a) / (4 * m):
        count += 1
if m <= count:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, m = set(map(int, input().split()))
a = set(map(int, input().split()))
count = 0
for x in a:
    if x >= sum(a) / (4 * m):
        count += 1
if m <= count:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = set(map(int, input().split()))
a = set(map(int,input().split()))
d = sum(a)/(4.0*m)
count = 0
for x in a:
    if x >= d:
        count += 1
if m <= count:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = set(map(int, input().split()))
a = set(map(int,input().split()))
d = sum(a)/(4.0*m)
count = 0
for x in a:
    if float(x) >= d:
        count += 1
if m <= count:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = set(map(int, input().split()))
a = set(map(int,input().split()))
d = sum(a)/(4*m)
count = 0
for x in a:
    if float(x) >= d:
        count += 1
if m <= count:
    print("Yes")
else:
    print("No")
Problem p02731 (python)

Fixed submission:
l = int(input())
print(l**3 / 27)

Buggy submission (verdict: Runtime Error):
l = int(input())
print(f"{l**3 / 27:.10f}")

Buggy submission (verdict: Runtime Error):
l = int(input())
print(f"{pow(l,3) / 27.0:.10f}")

Buggy submission (verdict: Runtime Error):
l = int(input())
print(f"{pow(l / 3.0, 3):.10f}")
Problem p02767 (python)

Fixed submission:
import statistics

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

a = round(statistics.mean(x))
sums = 0
for i in x:
    sums += (i - a) ** 2
print(sums)

Buggy submission (verdict: Runtime Error):
import statistics

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

a = round(statistics.mean(x))
sums = 0
for i in x:
    sums += (i - a) ** 2
print(sums)
Problem p02684 (python)

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


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    N, K = IL(int)
    A = IL(lambda x: int(x) - 1)
    memo = [0]
    visited = [False] * N
    i = 0
    while(not visited[A[i]]):
        memo.append(A[i])
        visited[A[i]] = True
        i = A[i]
    if K < len(memo):
        print(memo[K] + 1)
    else:
        loop = memo[memo.index(A[i]):]
        print(loop[(K - (len(memo) - len(loop))) % len(loop)] + 1)


solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    N, K = IL(int)
    A = IL(lambda x: int(x) - 1)
    memo = []
    i = 0
    while(i < N and A[i] != 0):
        memo.append(A[i])
        i += 1
    print(memo[K % len(memo)] + 1)


solve()
Problem p02787 (python)

Fixed submission:
H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    a, b = min(AB, key=lambda i: i[1] + dp[max(0, h - i[0])])
    dp.append(b + dp[max(0, h - a)])    
print(dp[-1])

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


DEBUG = True
dprint = print if DEBUG else lambda *x : x

H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    a, b = min(AB, key=lambda i: i[1] + dp[max(0, h - i[0])])
    dp.append(b + dp[max(0, h - a)])    
print(dp[-1])
Problem p02900 (python)

Fixed submission:
A, B = [int(str) for str in input().split()]

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


print(len(set(prime_factorize(gcd(A, B)))) + 1)

Buggy submission (verdict: Runtime Error):
import random, math


A, B = [int(str) for str in input().split()]

def is_prime(q,k=4):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし(但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


if A < B:
    A, B = B, A

div_list = [i for i in make_divisors(B) if A % i == 0]
prime_list = [1] + [i for i in range(1, math.gcd(A, B) + 1) if is_prime(i)]
print(len([i for i in prime_list if i in div_list]))
Problem p03263 (python)

Fixed submission:
H, W = [int(str) for str in input().strip().split()]
A = [[int(str) for str in input().strip().split()] for _ in range(H)]

N = 0
actions = []
for i in range(H):
    jd = 1 - (i % 2) * 2
    js = list(range(W))[::jd]
    for j in js:
        if A[i][j] % 2 and A[i][j] != 0:
            if j == js[-1]:
                if i != H - 1:
                    ti, tj = i + 1, j
                else:
                    break
            
            else:
                ti, tj = i, j + jd

            A[ti][tj] += 1
            actions.append('{0} {1} {2} {3}'.format(i + 1, j + 1, ti + 1, tj + 1))
            N += 1

print(N)
[print(action) for action in actions]

Buggy submission (verdict: Runtime Error):
H, W = [int(str) for str in input().strip().split()]
A = [[int(str) for str in input().strip().split()] for _ in range(H)]

N = 0
actions = []
for i in range(H):
    jd = 1 - (i % 2) * 2
    js = list(range(W))[::jd]
    for j in js:
        if A[i][j] % 2:
            if j == js[-1]:
                if i != H - 1:
                    ti, tj = i + 1, j
            
            else:
                ti, tj = i, j + jd

            A[ti][tj] += 1
            actions.append([i + 1, j + 1, ti + 1, tj + 1])
            N += 1

print(N)
for action in actions:
    [print(a, end=' ') for a in action]
    print('')
Problem p03282 (python)

Fixed submission:
S = input().strip()
K = int(input().strip())

i = 0
while S[i] == '1' and i < len(S) - 1:
    i += 1

print(S[i] if K > i else 1)

Buggy submission (verdict: Runtime Error):
S = input().strip()
K = int(input().strip())

i = 0
while S[i] == '1':
    i += 1

print(S[i] if K > i else 1)
Problem p02641 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def main():
    X, N = list(map(int, input().split(" ")))
    if N == 0:
        print(X)
        exit(0)
    arr = list(map(int, input().split(" ")))
    if X not in arr:
        print(X)
        exit(0)

    arr.sort()
    for i in range(len(arr)):
        if arr[i] >= X:
            diff = 1
            while True:
                if X - diff not in arr:
                    print(X - diff)
                    exit(0)
                if X + diff not in arr:
                    print(X + diff)
                    exit(0)
                diff += 1


if __name__ == '__main__':
    main()

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

input = sys.stdin.readline


def main():
    X, N = list(map(int, input().split(" ")))
    if N==0:
        print(X)
        exit(0)
    arr = list(map(int, input().split(" ")))
    if X not in arr:
        print(X)

    arr.sort()
    for i in range(len(arr)):
        if arr[i] >= X:
            diff = 1
            while True:
                if X - diff not in arr:
                    print(X-diff)
                    exit(0)
                if X + diff not in arr:
                    print(X+diff)
                    exit(0)
                diff +=1


if __name__ == '__main__':
    main()
Problem p02658 (python)

Fixed submission:
import numpy as np
N = int(input())
A =list(map(int, input().split(" ")))

if 0 in A:
    print(0)
    exit(0)
    
ret = 1
for a in A:
    ret *= a
    if len(str(ret)) >= 19 and ret != 10 ** 18:
        print(-1)
        exit(0)
    

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A =list(map(np.float128, input().split(" ")))
ret = np.prod(A)
ret = int(ret)

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)
Problem p02741 (python)

Fixed submission:
s = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')
k = int(input())
print(int(s[k-1]))

Buggy submission (verdict: Runtime Error):
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(', ')
k = int(input())
print(int(s[k]))

Buggy submission (verdict: Runtime Error):
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(', ')
k = int(input())
print(s[k])
Problem p02660 (python)

Fixed submission:
from collections import Counter
def factorization(n):
    a=[]
    for i in range(2,int(n**.5)+1):
        while n%i==0:
            n//=i
            a.append(i)
    if n!=1:
        a.append(n)
    return a
n=int(input())
A=factorization(n)
B=Counter(A)
count=0
for key,value in B.items():
    for i in range(1,value+1):
        if n%(key**i)==0:
            count+=1
            n//=(key**i)
        else:break
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
count=0
pn=[2]
for L in range(3,N):
    chk=True
    for L2 in pn:
        if L%L2==0:chk=False
    if chk==True:pn.append(L)
ph=[1]*len(pn)
i=0
while N!=1:
    if N%(pn[i]**ph[i])==0:
        count+=1
        N//=(pn[i]**ph[i])
        ph[i]+=1
    else:i+=1
print(count)
Problem p02947 (python)

Fixed submission:
from collections import Counter
from math import factorial
def combinations(n,r):
    return factorial(n)//(factorial(n-r)*factorial(r))
N=int(input())
S=["".join(sorted(input())) for i in range(N)]
s=Counter(S)
ans=0
for key,value in s.items():
    if value>=2:
        ans+=combinations(value,2)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from math import factorial
def combinations(n,r):
    return factorial(n)//(factorial(n-r)*factorial(r))
N=int(input())
S=["".join(sorted(input())) for i in range(N)]
s=Counter(S)
ans=0
for key,value in s.items():
    ans+=combinations(value,2)
print(ans)
Problem p03068 (python)

Fixed submission:
n=int(input())
s=input()
k=int(input())
for i in range(n):
    if s[i] == s[k-1]:
        print(s[i],end="")
    else:
        print("*",end="")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input())
for i in range(n):
    if s[i] == s[k]:
        print(s[i],end="")
    else:
        print("*",end="")
Problem p03101 (python)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
print(H*W-h*W-w*(H-h))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input(),split())
h,w=map(int,input(),split())
print(H*W-h*W-w*(H-h))
Problem p03196 (python)

Fixed submission:
n,p = map(int,input().split())
 
def pfact(m):
	pf = {}
	for i in range(2,int(m**0.5)+1):
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
	if m>1 : pf[m]=1
	return pf
 
ans = 1
for i, j in pfact(p).items():
	ans *= i**(j//n)
print(ans)

Buggy submission (verdict: Runtime Error):
N,P=map(int,input().split())
i=2
ans=1
while P!=1 or i<int(N**.5)+1:
    I=i**N
    if P%I==0:
        ans*=I
        P//=I
    elif P%i==0:
        P//=i
    else:
        i+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,P=map(int,input().split())
i=2
ans=1
while P!=1:
    if P%(i**N)==0:
        ans*=i
        P//=i**N
    elif P%i==0:
        P//=i
    else:
        i+=1
print(ans)
Problem p03294 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
y=0
for x in a:
    y+=x-1
print(y)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
def lcm(a,b):
    return (a*b)//gcd(a,b)

def lcm_list(numbers):
    return reduce(lcm,numbers,1)

n=int(input())
a=list(map(int,input().split()))
b=lcm_list(a)
y=0
for x in a:
    y+=x-1
print(y)
Problem p03361 (python)

Fixed submission:
H,W=map(int,input().split())
S=["."*(W+2)]+["."+input()+"." for i in range(H)]+["."*(W+2)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=="#":
            if S[i+1][j]=="." and S[i-1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                print("No")
                exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
S=["."*W]+["."+input()+"." for i in range(H)]+["."*W]
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=="#":
            if S[i+1][j]=="." and S[i-1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                print("No")
                exit()
print("Yes")
Problem p03578 (python)

Fixed submission:
import collections
 
n = int(input())
ln = list(map(int, input().split()))
m = int(input())
lm = list(map(int, input().split()))
 
c1 = collections.Counter(lm)
c2 = collections.Counter(ln)
 
for i in c1.keys():
    if c2[i] < c1[i]:
        print("NO")
        exit()
 
print("YES")

Buggy submission (verdict: Runtime Error):
mport collections
 
n = int(input())
ln = list(map(int, input().split()))
m = int(input())
lm = list(map(int, input().split()))
 
c1 = collections.Counter(lm)
c2 = collections.Counter(ln)
 
for i in c1.keys():
    if c2[i] < c1[i]:
        print("NO")
        exit()
 
print("YES")
Problem p03644 (python)

Fixed submission:
n=int(input())
b=0
for i in range(7):
    if 2**i<=n:
        b=2**i
print(b)

Buggy submission (verdict: Runtime Error):
n=int(input())
b=0
for i in range(7):
    if 2**i=<n:
        b=2**i
print(b)
Problem p03673 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
if N%2==0:
    B=A[::-2]+A[::2]
else:
    B=A[::-2]+A[1::2]
print(*B)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[n%2::2])

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[n%2::2])
Problem p03697 (python)

Fixed submission:
a,b = map(int, input().split())
print(a+b if a+b<10 else "error")

Buggy submission (verdict: Runtime Error):
a.b = map(int, input().split())
print(a+b if a+b<10 else "error")
Problem p03836 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
x=c-a
y=d-b
print("U"*y+"R"*x+"D"*y+"L"*x+"L"+"U"*(y+1)+"R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
x==c-a
y==d-b
print("U"*y+"R"*x+"D"*y+"L"*x+"L"+"U"*(y+1)*"R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
x=c-a
y=d-b
print("U"*y+"R"*x+"D"*y+"L"*x+"L"+"U"*(y+1)*"R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U")
Problem p03845 (python)

Fixed submission:
N=int(input())
T=list(map(int,input().split()))
M=int(input())
for i in range(M):
    P,X=map(int,input().split())
    print(sum(T[:P-1])+X+sum(T[P:]),end="\n")

Buggy submission (verdict: Runtime Error):
    print(sum(T[:P-1])+X+sum(T[P:]))
Problem p03910 (python)

Fixed submission:
N=int(input())
ans=0
reject=0
A=[]
for i in range(1,N+1):
    ans+=i
    if ans>=N:
        reject=ans-N
        for j in range(1,i+1):
            if j!=reject:
                print(j)
        break

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=0
A=[]
for i in range(1,N+1):
    if ans+i==N:
        A.append(i)
        break
    if N-(ans+i)>=i+1:
        A.append(i)
        ans+=i
    else:
        del A[-1]
        ans-=i-1
        if (N-ans)%2==0:
            A.append((N-ans)//2-1)
            A.append((N-ans)//2+1)
        else:
            A.append((N-ans)//2)
            A.append((N-ans)//2+1)
        break
print(*A,sep="\n")
Problem p02641 (python)

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

ans = None
for r in range(100):
    for i in [-r, r]:
        if (X + i) not in p:
            ans = X+i
            break

    if ans is not None:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
ans = None
for r in range(100):
    for i in [-r, r]:
        if (X + i) not in p:
            ans = X+i
            break

    if ans is not None:
        break


print(ans)
Problem p02732 (python)

Fixed submission:
from collections import defaultdict
import numpy as np

N = int(input())
A = np.fromstring(input(), np.int, sep=" ")

uniq_count = defaultdict(int)
for a in A:
    uniq_count[a] += 1
uniq = np.fromiter((uniq_count.keys()), np.int)
counts = np.fromiter(uniq_count.values(), np.int)

p = lambda n: n * (n - 1) // 2

n = p(counts)
m = p(counts - 1)

ans = n.sum() - n + m

mapping = dict(zip(uniq, ans))

for a in A:
    print(mapping[a])

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

N = int(input())
A = np.fromstring(input(), np.uint64, sep=" ")

uniq, counts = np.unique(A, return_counts=True)

p = lambda n: n * (n - 1) // 2

n = p(counts)
m = p(counts-1)

ans = n.sum() - n + m

mapping = dict(zip(uniq, ans))

for a in A:
    print(mapping[a])
Problem p02642 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
# dp = [0 for _ in range(N)]

# A.sort()

# for i in range(N):
#     if dp[i] < 2:
#         p = A[i]
#         for j in range(N):
#             if dp[j] < 2 and A[j]%p == 0 and A[j] >= p:
#                 dp[j] += 1
# cnt = 0
# for i in range(N):
#     if dp[i] == 1:
#         cnt += 1
M = 10**6  + 5
cnt = [0 for _ in range(M)]
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    i = x
    while i < M:
        cnt[i] += 1
        i += x
ans = 0
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(set(map(int, input().split())))
N = len(A)
cnt = N
dp = [0 for _ in range(N)]
A.sort()
A_max = A[-1]
p = A[0]
i = 0
while p**2 < A_max:
    if dp[i] < 2:
        p = A[i]
        for j in range(N):
            if dp[j] < 2 and A[j]%p == 0:
                dp[j] += 1
                if dp[j] == 2:
                    cnt -= 1
    i += 1

for i in dp:
    if i >= 2:
        cnt -= 1
if len(A) == 1:
    print(0)
else:
    print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(N)]
A.sort()
A_max = A[-1]
p = A[0]
i = 0
while p**2 < A_max:
    if dp[i] < 2:
        p = A[i]
        for j in range(N):
            if dp[j] < 2 and A[j]%p == 0 and A[j] >= p:
                dp[j] += 1
    i += 1
cnt = 0
for i in range(N):
    if dp[i] == 1:
        cnt += 1

print(cnt)
Problem p02768 (python)

Fixed submission:
n, a, b = [int(i) for i in input().split()]
mod = 10**9 + 7
 
total = pow(2, n, mod) - 1
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
 
at = combination(n,a)
bt = combination(n,b)
 
result = total - at - bt
result %= mod
if result < 0:
  result += mod
print(result)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
n, a, b = map(int, input().split())

def inv_felmat(a, p):
    return pow(a, p-2, p)

def cmb(n,r):
    r = min(n-r, r)
    if r == 0: return
    over = reduce(mul, range(n, n-r, -1))
    under = reduce(mul, range(1, r+1))
    under = inv_felmat(under, 10**9 + 7)
    return over * under

all = pow(2, n, 10**9 + 7) - 1 
tmp1 = 1
tmp2 = 1
# for i in range(n-a+1, n+1):
#     tmp1 *= i
# for i in range(1, a+1):
#     tmp2 *= i
tmp1 = cmb(n,a) % (10**9 + 7)
tmp3 = cmb(n,b) % (10**9 + 7)
# for i in range(n-b+1, n+1):
#     tmp3 *= i
# for i in range(1, b+1):
#     tmp4 *= i

result = all - tmp1 - tmp3
print(result%(10**9 + 7))