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

Fixed submission:
n = int(input())
x = 0
mn = 100
for i in range(n):
  s = int(input())
  x += s
  if s % 10 != 0:
    if s <= mn:
      mn = s
if x % 10 != 0:
  print(x)
else:
  x -= mn
  if x % 10 == 0:
    print(0)
  else:
    if x < 0:
      print(0)
      exit()
    print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = 0
mn = 101
for i in range(n):
  s = int(input())
  x += s
  if x % 10 != 0
    if s < mn:
      mn = s
if x % 10 != 0:
  print(x)
else:
  x -= mn
  if x % 10 == 0:
    print(0)
  else:
    if x < 0:
      print(0)
      exit()
    print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = 0
mn = 101
for i in range(n):
    s = int(input())
    x += s
    if x % 10 != 0
        if s < mn:
            mn = s
if x % 10 != 0:
    print(x)
else:
    x -= mn
    if x % 10 == 0:
        print(0)
    else:
        if x < 0:
            print(0)
            exit()
        print(x)
Problem p02999 (python)

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

if X < A:
    print(0)
elif X >= A:
    print(10)

Buggy submission (verdict: Runtime Error):
ans = 0 if x < a else 10
print(ans)

Buggy submission (verdict: Runtime Error):
ans = 0 if x < a else 10
print(ans)
Problem p02983 (python)

Fixed submission:
list1 = [int(i) for i in input().split()]
l = list1[0]
r = list1[1]
if (l// 2019 != r//2019):
	print(0)
else:
	max1 = 10000000000
	if l - r >= 2019:
		for i in range(l,l+2020):
			for j in range(i+1,l+2020):
				temp = ((i%2019)*(j%2019))%2019
				if temp < max1 :
					max1 = temp
	else :
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				temp = ((i%2019)*(j%2019))%2019
			
				if temp < max1 :
					max1 = temp
		
	print(max1)

Buggy submission (verdict: Runtime Error):
z = [int(i) for i in input().split()]
l = z[0]
r = z[1]
if l == 2019 or r == 2019 :
  print(0)
elif r < 2019 :
  max1 = 0 
  for i in range(l,r+1):
    for j in range(i,r+1):
      	temp = (i%2019)*(j%2019)
        if temp > max1:
          max1 = temp
  print(max1)        
                   
    
elif r > 2019 and l > 2019 :
  flag = 0 
  if l - r >= 2019:
    print(0)
  else:
    max1 = 0 
    for i in range(l,l+2020):
      for j in range(i,l+2020):
          temp = (i%2019)*(j%2019)
          if temp > max1:
            max1 = temp
    print(max1)

Buggy submission (verdict: Runtime Error):
z = [int(i) for i in input().split()]
l = z[0]
r = z[1]
if l == 2019 or r == 2019 :
  print(0)
elif r < 2019 :
  print(l*(l+1))
elif r > 2019 and l > 2019 :
  flag = 0 
  if l - r >= 2019:
    for i in range(l,l+2020):
      if i%2019 == 0:
        number = i 
        flag = 1 
        break
	if flag == 1 :
		print(0)
	else :
    	print((number%2019)*((number+1)%2019)    
  else :
    for i in range(l,r+1):
      if i % 2019 == 0 :
       	flag = 1 
        break
	  if flag == 1 :
	    print(0)
	  else :
	    print( (l%2019)*((l+1)%2019))

Buggy submission (verdict: Runtime Error):
z = [int(i) for i in input().split()]
l = z[0]
r = z[1]
if l == 2019 or r == 2019 :
  print(0)
elif r < 2019 :
  print(l*(l+1))
elif r > 2019 and l > 2019 :
  flag = 0 
  if l - r >= 2019:
    for i in range(l,l+2020):
      if i%2019 == 0:
        number = i 
        flag = 1 
        break
  else :
    for i in range(l,r+1):
      if i % 2019 == 0 :
       	flag = 1 
        break
  if flag == 1 :
    print(0)
  else :
    print(l*(l+1)
Problem p03523 (python)

Fixed submission:
s = input()
alpha = [0]*26
l = []
l.append('KIHBR')
l.append('AKIHBR')
l.append('KIHABR')
l.append('KIHBAR')
l.append('KIHBRA')

l.append('AKIHABR')
l.append('AKIHBAR')
l.append('AKIHBRA')
l.append('KIHABAR')
l.append('KIHABRA')
l.append('KIHBARA')
l.append('AKIHABAR')
l.append('KIHABARA')
l.append('AKIHBARA')
l.append('AKIHABRA')
l.append('AKIHABARA')
if s in l:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s = input()
alpha = [0]*26
for i in range(len(s)):
	alpha[ord(s[i]) - ord('a') ] += 1
if alpha['k' - 'a'] == 1:
	alpha['i' - 'a'] == 1:
		alpha['h' - 'a'] == 1:
			alpha['b' - 'a'] == 1:
				alpha['r' - 'a'] == 1:
					print("YES")
else:
	print("NO")
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
num = list(map(int,input().split()))
b= 1
for a in range(N):
  b = b * num[a]
  if b > 10**18:
    print(-1)
  else:
    print(b)

Buggy submission (verdict: Runtime Error):
N = int(input())
num = list(map(int,input().split()))
b= 0
for a in range(N):
  b = b * num[a]
  if b > 10**18:
    print('-1')
  else:
    print(b)

Buggy submission (verdict: Runtime Error):
N = int(input())
num = list(map(int,input().split()))
b= 0
for a in range(N):
  b = b * num[a]
if b > 10**18:
  print('-1')
else:
  print(b)
Problem p02705 (python)

Fixed submission:
enshu = int(input())
print(enshu * 2 *3.141592)

Buggy submission (verdict: Runtime Error):
enshu = int(input(R))
print(enshu * 2 * 3.1415)

Buggy submission (verdict: Runtime Error):
enshu = int(input(R))
print(enshu * 2 *3.141592)
Problem p02732 (python)

Fixed submission:
import sys

n = int(sys.stdin.readline().strip())
nums = list(map(int, sys.stdin.readline().strip().split()))
# appear times
d = dict()
for one in nums:
    if one in d:
        d[one] += 1
    else:
        d[one] = 1

def C(a):
    return (a*(a-1)//2 )

accum = 0
for k, v in d.items():
    accum += C(v)

res_history = dict()

for one in nums:
    if one in res_history:
        print(res_history[one])
    else:
        if d[one] == 1:
            print(accum)
        else:
            res = accum 
            delta = C(d[one]) - C(d[one] - 1)
            res -= delta
            res_history[one] = res
            print(res)

Buggy submission (verdict: Runtime Error):
import sys

n = int(sys.stdin.readline().strip())
nums = list(map(int, sys.stdin.readline().strip().split()))

d = dict()
for one in nums:
    if one in d:
        d[one] += 1
    else:
        d[one] = 1
history = dict()
history[0] = 1
history[1] = 1
history[2] = 2
def stepMulti(v):
    if v < 1:
        return 1
    if v not in history:
        history[v]  = v * stepMulti(v-1)
    return history[v]

def C(a,b):
    return stepMulti(a) // (stepMulti(a-b) * stepMulti(b))

res_history = dict()

for one in nums:
    if one in res_history:
        print(res_history[one])
    else:
        d[one] -= 1
        res = 0
        for k,v in d.items():
            if v==2:
                res += 1
            elif v > 2:
                res += C(v, 2)
        print (res)
        d[one] += 1
        res_history[one] = res
Problem p02615 (python)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
ans = 0
for i in range(0, n - 1):
    ans += a_list[(i + 1) // 2]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
ans = 0
for i in range(0, n - 1):
    ans += A[(i + 1) // 2]
print(ans)
Problem p02616 (python)

Fixed submission:
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a_list[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    count = 0
    while True:
        if count == k:
            break
        elif count == k - 1:
            ans *= a_list[r] % mod
            ans %= mod
            break
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            count += 2
            if l <= n - 2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= a_list[r] % mod
            r -= 1
            count += 1
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    for _ in range(0, k // 2):
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            if l <= n-2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= mlt2 % mod
            r -= 2
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod

    if k % 2 == 1:
        ans *= a_list[r]
        ans %= mod
print(ans)
Problem p02658 (python)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
if 0 in a_list:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[i])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = np.array(list(map(int, input().split())))
if 0 in a_list:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[i])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        print(ans)
Problem p02732 (python)

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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)

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

datas = [0] * n
for a in an:
    datas[a] += 1

for k in range(0,n):
    ans=0
    for i in range(1,n):
        if datas[i] > 1:
            if i == an[k]:
                ans += (datas[i]-1) * (datas[i]-2)/2
            else:
                ans += datas[i] * (datas[i]-1)/2
    print(int(ans))
Problem p02573 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r))
                         for r in self.roots())


n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)
maxSize = 0
for j in range(n):
    maxSize = max(maxSize, uf.size(j))
print(maxSize)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        # 親の名(いない場合はNone)
        self.parent = [None] * n
        # 子の数
        self.count = [0] * n

    def root(self, x):
        # xの根を返す
        if self.parent[x] is None:
            return x
        else:
            return self.root(self.parent[x])

    def union(self, x, y):
        # xとyをまとめる
        x0 = self.root(x)
        y0 = self.root(y)
        if x0 == y0:
            return
        if x0 > y0:
            x0, y0 = y0, x0
        self.parent[y0] = x0
        self.count[x0] += self.count[y0] + 1

    def size(self, x):
        # xの属する木の大きさ
        return self.count[self.root(x)] + 1

    def same(self, x, y):
        return self.root(x) == self.root(y)


n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)
maxSize = 0
for i in range(n):
    maxSize = max(maxSize, uf.size(i))
print(maxSize)
Problem p02574 (python)

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

m = max(A)
is_prime = [True] * (m + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, m + 1):
    for j in range(i * 2, m + 1, i):
        is_prime[j] = False
primes = [i for i in range(m + 1) if is_prime[i]]

Amap = {a: 0 for a in range(1, m + 1)}
for a in A:
    Amap[a] += 1

# Pmap[p]はAにでてくるpの倍数の数
Pmap = {p: 0 for p in primes}
for p in primes:
    for a in range(p, m + 1, p):
        Pmap[p] += Amap[a]

try:
    score = max(Pmap.values())
except BaseException:
    print('pairwise coprime')
    exit()
if score == 1:
    print('pairwise coprime')
elif score != n:
    print('setwise coprime')
else:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
n = int(input())
*A, = map(int, input().split())
m = max(A)
C = [0 for a in range(m + 1)]
for a in A:
    C[a] += 1
s = max(sum(C[a::a]) for a in range(2, m + 1))
if s < 2:
    print('pairwise coprime')
elif s < n:
    print('setwise coprime')
else:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
n = int(input())
*A, = map(int, input().split())

m = max(A)
is_prime = [True] * (m + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, m + 1):
    for j in range(i * 2, m + 1, i):
        is_prime[j] = False
primes = [i for i in range(m + 1) if is_prime[i]]

Amap = {a: 0 for a in range(1, m + 1)}
for a in A:
    Amap[a] += 1

# Pmap[p]はAにでてくるpの倍数の数
Pmap = {p: 0 for p in primes}
for p in primes:
    for a in range(p, m + 1, p):
        Pmap[p] += Amap[a]

score = max(Pmap.values())

if score == 1:
    print('pairwise coprime')
elif score != n:
    print('setwise coprime')
else:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
n = int(input())
*A, = map(int, input().split())

m = max(A)
is_prime = [True] * (m + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, m + 1):
    for j in range(i * 2, m + 1, i):
        is_prime[j] = False
primes = [i for i in range(m + 1) if is_prime[i]]

Amap = {a: 0 for a in range(1, m + 1)}
for a in A:
    Amap[a] += 1

# Pmap[p]はAにでてくるpの倍数の数
Pmap = {p: 0 for p in primes}
for p in primes:
    for a in range(p, m + 1, p):
        Pmap[p] += Amap[a]

score = max(Pmap.values())
if score == 1:
    print('pairwise coprime')
elif score != n:
    print('setwise coprime')
else:
    print('not coprime')
Problem p02599 (python)

Fixed submission:
import sys
input = sys.stdin.readline


class BIT:
    def __init__(self, n):
        self.array = [0] * (n + 1)
        self.size = n

    def sum(self, i):
        s = 0
        tmp = i
        while tmp > 0:
            s += self.array[tmp]
            tmp -= tmp & -tmp
        return s

    def add(self, i, x):
        tmp = i + 1
        while tmp <= self.size:
            self.array[tmp] += x
            tmp += tmp & -tmp


def main():
    n, q = map(int, input().split())
    *C, = map(lambda x: int(x) - 1, input().split())
    P = [0] * n
    N = [None] * n
    for i in range(n)[::-1]:
        if P[C[i]]:
            N[i] = P[C[i]]
        P[C[i]] = i
    F = [0] * n
    B = BIT(n)
    for i in range(n):
        if F[C[i]] == 0:
            B.add(i, 1)
            F[C[i]] = 1
    XY = [tuple(map(int, input().split())) for j in range(q)]
    ids = list(range(q))
    ids.sort(key=lambda j: XY[j][0])
    a = 0
    lst = [0] * q
    for j in ids:
        x, y = XY[j]
        for i in range(a, x - 1):
            if N[i]:
                B.add(N[i], 1)
        a = x - 1
        lst[j] = B.sum(y) - B.sum(x - 1)
    print(*lst, sep="\n")


main()

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
*C, = map(int, input().split())
k = 2**16
S = [set()] * (2 * k - 1)
for i in range(n):
    S[k - 1 + i] = {C[i]}
for i in range(k - 1)[::-1]:
    S[i] = S[2 * i + 1] | S[2 * i + 2]


def ans(a=0, b=k, p=0):
    if b <= x or y <= a:
        return set()
    if x <= a and b <= y:
        return S[p]
    left = ans(a, (a + b) // 2, 2 * p + 1)
    right = ans((a + b) // 2, b, 2 * p + 2)
    return left | right


for _ in range(q):
    x, y = map(int, input().split())
    x -= 1
    print(len(ans()))
Problem p02609 (python)

Fixed submission:
def popcount(n):
    return bin(n).count("1")


def f(n):
    tmp = n
    count = 0
    while tmp > 0:
        tmp %= popcount(tmp)
        count += 1
    return count


n = int(input())
# f(0)~f(n)までを計算しておく
F = [f(i) for i in range(n + 2)]
x = input()
pcx = x.count("1")
# xをpcx-1,pcx+1で割ったあまりをそれぞれ計算

a, b = 0, 0
if pcx == 1:
    for i in range(n):
        if x[i] == "1":
            b += pow(2, n - i - 1, pcx + 1)
            b %= (pcx + 1)
    for i in range(n):
        if x[i] == "1":
            print(0)
        else:
            print(1 + f((b + pow(2, n - i - 1, pcx + 1)) % (pcx + 1)))
    exit()

if pcx > 1:
    for i in range(n):
        if x[i] == "1":
            a += pow(2, n - i - 1, pcx - 1)
            a %= (pcx - 1)
            b += pow(2, n - i - 1, pcx + 1)
            b %= (pcx + 1)
else:
    for i in range(n):
        print(1)
    exit()
for i in range(n):
    if x[i] == "1":
        print(1 + f((a - pow(2, n - i - 1, pcx - 1)) % (pcx - 1)))
    else:
        print(1 + f((b + pow(2, n - i - 1, pcx + 1)) % (pcx + 1)))

Buggy submission (verdict: Runtime Error):
def popcount(n):
    return bin(n).count("1")


def f(n):
    tmp = n
    count = 0
    while tmp > 0:
        tmp %= popcount(tmp)
        count += 1
    return count


n = int(input())
# f(0)~f(n)までを計算しておく
F = [f(i) for i in range(n + 2)]
x = input()
pcx = x.count("1")
# xをpcx-1,pcx+1で割ったあまりをそれぞれ計算
a, b = 0, 0
if pcx > 0:
    for i in range(n):
        if x[i] == "1":
            a += pow(2, n - i - 1, pcx - 1)
            a %= (pcx - 1)
            b += pow(2, n - i - 1, pcx + 1)
            b %= (pcx + 1)
else:
    for i in range(n):
        print(1)
    exit()
for i in range(n):
    if x[i] == "1":
        print(1 + f((a - pow(2, n - i - 1, pcx - 1)) % (pcx - 1)))
    else:
        print(1 + f((b + pow(2, n - i - 1, pcx + 1)) % (pcx + 1)))
Problem p02616 (python)

Fixed submission:
n, k = map(int, input().split())
*A, = map(int, input().split())
p = 10**9 + 7
A.sort()
ans = 1
# 全部0以下の場合かつkが奇数の場合はトップk個の積
if A[n - 1] <= 0 and k % 2 == 1:
    for i in range(k):
        ans *= A[n - 1 - i]
        ans %= p
    print(ans)
    exit()

i = 0
j = n - 1
# kが奇数なら最大は絶対使う
if k % 2 == 1:
    ans *= A[j]
    ans %= p
    j -= 1
    k -= 1
    n -= 1
# 以下A[n-1]を除いてkを偶数として考える
k //= 2
for _ in range(min(k, n // 2)):
    # 2個ずつのペアを作って採用するかを決めていく
    left = A[i] * A[i + 1]
    right = A[j] * A[j - 1]
    if (left > right):
        ans *= left
        ans %= p
        i += 2
    else:
        ans *= right
        ans %= p
        j -= 2
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
*A, = map(int, input().split())
p = 10**9 + 7
A.sort()
ans = 1
if A[n - 1] <= 0 and k % 2 == 1:
    for i in range(k):
        ans *= A[n - 1 - i]
        ans %= p
    print(ans)
    exit()
if k % 2 == 1:
    ans *= A.pop()
    ans %= p
    n -= 1
A = [A[i] * A[i + 1] for i in range(0, n, 2)]
A.sort(reverse=True)
for i in range(k // 2):
    ans *= A[i]
    ans %= p
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
*A, = map(int, input().split())
p = 10**9 + 7
A.sort()
ans = 1
if A[n - 1] <= 0 and k % 2 == 1:
    for i in range(k):
        ans *= A[n - 1 - i]
        ans %= p
    print(ans)
    exit()
if k % 2 == 1:
    ans *= A.pop()
    ans %= p
A = [A[i] * A[i + 1] for i in range(0, n, 2)]
A.sort(reverse=True)
for i in range(k // 2):
    ans *= A[i]
    ans %= p
print(ans)
Problem p02642 (python)

Fixed submission:
n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in range(1, maxA + 1)}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in range(1, maxA + 1)}
for a in A:
    if C[a] > 0:
        tmp = 2
        while a * tmp <= maxA:
            D[a * tmp] = 1
            tmp += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
*A, = map(int, input().split())
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        tmp = 2
        while a * tmp <= maxA:
            D[a * tmp] = 1
            tmp += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {}
for a in A:
    try:
        C[a] += 1
    except KeyError:
        C[a] = 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {}
for a in A:
    if C[a] > 0:
        tmp = 2
        while a * tmp <= maxA:
            D[a * tmp] = 1
            tmp += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)
Problem p02697 (python)

Fixed submission:
n, m = map(int, input().split())
a, b = n, 1
V = [False for d in range(1, n + 1)]
for i in range(m):
    d = min(a - b, n - (a - b))
    if 2 * d == n or V[d]:
        a -= 1
    print(a, b)
    d = min(a - b, n - (a - b))
    V[d] = True
    a -= 1
    b += 1

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a, b = n, 1
V = [False for d in range(1, m + 2)]
for i in range(m):
    d = min(a - b, n - (a - b))
    if 2 * d == n or V[d]:
        a -= 1
    print(a, b)
    d = min(a - b, n - (a - b))
    V[d] = True
    a -= 1
    b += 1
Problem p02709 (python)

Fixed submission:
n = int(input())
*A, = map(int, input().split())
# n = 6
# A = [8, 6, 9, 1, 2, 1]
# n = 4
# A = [1, 3, 4, 2]
A = [(a, i) for i, a in enumerate(A)]
A.sort(reverse=True)
DP = [[0 for r in range(n+1)] for l in range(n+1)]
for l in range(n):
    for r in range(n-l):
        a, i = A[l+r]
        DP[l+1][r] = max(DP[l+1][r], DP[l][r]+a*abs(i-l))
        DP[l][r+1] = max(DP[l][r+1], DP[l][r]+a*abs(i-(n-1-r)))
print(max([DP[l][n-l] for l in range(n)]))

Buggy submission (verdict: Runtime Error):
n = int(input())
*A, = map(int, input().split())
# n = 4
# A = [1, 3, 4, 2]
# n = 6
# A = [5, 5, 6, 1, 1, 1]
# n = 6
# A = [8, 6, 9, 1, 2, 1]
A = [(a, i) for i, a in enumerate(A)]
A.sort(reverse=True)
DP = [[None for r in range(n+1)] for l in range(n+1)]


def dp(l, r):
    if l == r:
        DP[l][r] = 0
    if DP[l][r] != None:
        return DP[l][r]
    a, i = A[n-(r-l)]
    x = dp(l+1, r)+a*abs(i-l)
    y = dp(l, r-1)+a*abs(i-r+1)
    DP[l][r] = max(x, y)
    return DP[l][r]


print(dp(0, n))