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

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

Cnt = []
cnt = 0
ans = 0
for idx, p in enumerate(P, 1):
    if idx == p:
        Cnt.append(idx)
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        ans -= 1
        cnt = 0

ans += len(Cnt)
print(ans)

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

ans = 0
Cnt = []
for idx, p in enumerate(P, 1):
    if idx == p:
        Cnt.append(idx)
#print(Cnt)
if len(Cnt) == 0:
    ans = 0

elif len(Cnt) == 2:
    ans += Cnt[1] - Cnt[0]

elif len(Cnt) %2:
    for i in range(1, len(Cnt), 2):
        if i == 0:
            ans += Cnt[i+1] - Cnt[i]
        elif i == len(Cnt)-1:
            ans += Cnt[i] - Cnt[i-1]
        else:
            ans += min(Cnt[i] - Cnt[i-1], Cnt[i+1] - Cnt[i])
else:
    for i in range(0, len(Cnt), 2):
        if i == 0:
            ans += Cnt[i+1] - Cnt[i]
        elif i == len(Cnt)-1:
            ans += Cnt[i] - Cnt[i-1]
        else:
            ans += min(Cnt[i] - Cnt[i-1], Cnt[i+1] - Cnt[i])

print(ans)

########################

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

Cnt = []
cnt = 0
ans = 0
for idx, p in enumerate(P, 1):
    if idx == p:
        Cnt.append(idx)
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        ans -= 1
        cnt = 0

ans += len(Cnt)
print(ans)
Problem p03627 (python)

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
A_dic = Counter(A)

set_A = sorted((set(A)), reverse=True)
tmp = 0
for a in set_A:
    if A_dic[a] >= 4:
        print(max(tmp*a, a*a))
        exit()
    if A_dic[a] >= 2:
        ans = tmp * a
        if ans != 0:
            print(ans)
            exit()
        tmp = a
print(0)

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

Side = [0] * (10**5+1)
for a in A: Side[a] += 1

Side_2 = [i for i, x in enumerate(Side) if (x >= 2) and (x < 4)]
Side_4 = [i for i, x in enumerate(Side) if x >= 4]

if (len(Side_2) < 2) and not Side_4:
  print(0)
  exit()

if not Side_2 and Side_4:
  print(Side_4[-1]*2)
  exit()

if (len(Side_2) >= 2) and not Side_4:
  print(Side_2[-1]*Side_2[-2])
  exit()
  
if (len(Side_2) == 1) and Side_4:
  max2 = Side_2[-1]
  max4 = Side_4[-1]
  if max4 >= max2:
    print(max4*2)
    exit()
  else:
    print(max4*max2)
    exit()
    
if (len(Side_2) >= 2) and Side_4:
  max2 = Side_2[-1]
  max2_2 = Side_2[-2]
  max4 = Side_4[-1]
  if max4 >= max2:
    print(max4*2)
    exit()
  elif (max4 < max2) and (max4 <= max2_2):
    print(max2 * max2_2)
    exit()
  elif (max4 < max2) and (max4 > max2_2):
    print(max2 * max4)
    exit()
Problem p03644 (python)

Fixed submission:
n = int(input())

ans = 1
while ans * 2 <= n:
    ans *= 2
print(ans)

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

cont = 0
cont_list = [1]
cont_num =[]

for i in range(1, n+1):
    cont_num.append(i)
    while i % 2 == 0:
        i //= 2
        cont += 1
    cont_list.append(cont)
    cont = 0


if max(cont_list) == 1:
    print(1)
else:
    print(cont_num[cont_list.index(max(cont_list))])
Problem p03695 (python)

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

Colors = []
High_scorer = []
for a in A:
    if a < 400:
        Colors.append("Gray")
    if 400 <= a and a < 800:
        Colors.append("Brown")
    if 800 <= a and a < 1200:
        Colors.append("Green")
    if 1200 <= a and a < 1600:
        Colors.append("Light_blue")
    if 1600 <= a and a < 2000:
        Colors.append("Blue")
    if 2000 <= a and a < 2400:
        Colors.append("Yellow")
    if 2400 <= a and a < 2800:
        Colors.append("Orange")
    if 2800 <= a and a < 3200:
        Colors.append("Red")
    if 3200 <= a:
        High_scorer.append(a)

MIN = len(set(Colors))
H = len(High_scorer)

if MIN >= 1:
    print(MIN, (MIN+H))
elif MIN == 0:
    print(1, H)

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

Colors = []
High_scorer = []
for a in A:
    if a < 400:
        Colors.append("Gray")
    if 400 <= a and a < 800:
        Colors.append("Brown")
    if 800 <= a and a < 1200:
        Colors.append("Green")
    if 1200 <= a and a < 1600:
        Colors.append("Light_blue")
    if 1600 <= a and a < 2000:
        Colors.append("Blue")
    if 2000 <= a and a < 2400:
        Colors.append("Yellow")
    if 2400 <= a and a < 2800:
        Colors.append("Orange")
    if 2800 <= a and a < 3200:
        Colors.append("Red")
    if 3200 <= a:
        High_scorer.append(a)

MIN = len(set(Colors))
H = len(High_scorer)

MIN >= 1:
    print(MIN, (MIN+H))
MIN = 0:
    print(1, H)
Problem p03699 (python)

Fixed submission:
n = int(input())
S = list(int(input()) for i in range(n))

ans = sum(S)
sort_S = sorted(S)

if ans % 10 != 0:
    print(ans)
    exit()
else:
    for s in sort_S:
        if s % 10 != 0:
            ans -= s
            print(ans)
            exit()
print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(int(input()) for i in range(n))

ans = sum(S)
sort_S = sorted(S)

if ans % 10 != 0:
    print(ans)
    exit()
else:
    for s in sort_S:
        if s % 10 != 0:
            ans -= s
            print(ans)
            exit()
print(0)
Problem p03739 (python)

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

def Chk(a, pos):
    cnt = 0
    tmp = 0

    for a in A:
        tmp += a

        if pos and tmp < 1:
            cnt += 1 - tmp
            tmp = 1
        elif not pos and tmp > -1:
            cnt += 1 + tmp
            tmp = -1

        pos = not pos
    return cnt

print(min(Chk(A, True), Chk(A, False)))

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    def Chk(a, pos):
        cnt = 0
        tmp = 0

        for a in A:
            tmp += a

            if pos and tmp < 1:
                cnt += 1 - tmp
                tmp = 1
            elif not pos and tmp > -1:
                cnt += 1 + tmp
                tmp = -1

            pos = not pos
        return cnt

    print(min(Chk(A, True), Chk(A, False)))
    
if __name__ == '__main__':
    main()

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

def Chk(a, pos):
    cnt = 0
    tmp = 0
    
    for a in A:
        tmp += a
        
        if pos and tmp < 1:
            cnt += 1 - tmp
            tmp = 1
        elif not pos and tmp > -1:
            cnt += 1 + tmp
            tmp = -1
        
        pos = not pos
    return cnt

print(min(Chk(A, True), Chk(a, False)))

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    A = ()
    A_append = A.append
    cnt = 0

    for i in range(n-1):
        A_append(a[i])
        x = sum(A) + a[i+1]
        if sum(A) > 0 and x > 0:
            y = abs(x)+1
            cnt += y
            a[i+1] -= y

        elif sum(A) < 0 and x < 0:
            y = abs(sum(A) - a[i+1])-1
            cnt += y
            a[i+1] += y

    if sum(a) == 0:
        cnt += 1

    print(cnt)

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

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

if a <= 0 and b >= 0:
    print("Zero")

elif a < 0 and b < 0:
    if (abs(a)-abs(b+1))%2:
        print("Negative")
    else:
        print("Positive")

else:
    print("Positive")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a <= 0 and b >= 0:
    print("Zero")
    
elif a < 0 and b < 0:
    if len(list(range(a, b+1))) % 2:
        print("Negative")
    else:
        print("Positive")

else:
    print("Positive")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a <= 0 and b >= 0:
    print("Zero")
elif a < 0 and b < 0:
    if len(list(range(a, b+1))) % 2:
        print("Negative")
else:
    print("Positive")
Problem p02639 (python)

Fixed submission:
g=[]
a, b, c, d, e = map(int,input().split())
for i in a, b, c, d, e:
    g.append(i)
print(g.index(0)+1)

Buggy submission (verdict: Runtime Error):
g=[]
a, b, c, d, e = map(int,input().split())
for i in a, b, c, d, e, f:
    g.append(i)
print(g.index(0)+1)

Buggy submission (verdict: Runtime Error):
g=[]
a, b, c, d, e = map(int,input().split())
for i in a, b, c, d, e, f:
    g.append(i)
h=g.index(0)
print(h+1)

Buggy submission (verdict: Runtime Error):
g=[]
a, b, c, d, e, f = map(int,input().split())
for i in a, b, c, d, e, f:
    g.append(i)
h=g.index(0)
print(h+1)
Problem p03456 (python)

Fixed submission:
a,b = input().split()
a += b
can = 0
for i in range(1,1000):
  if(i*i == int(a)):
    can = 1
if(can == 1):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
a += b
can = 0
for i in range(1,100):
  if(i*i == int(a)):
    can = 1
if(can == 1):
  print("Yes")
else:
  print("No")
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())
if a > b :
  print('GREATER')
elif a < b :
  print('LESS')
else :
  print('EQUAL')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a > b :
  print('GREATER')
elif a < b :
  print('LESS')
else :
  print('EQUAL')
Problem p02744 (python)

Fixed submission:
n = int(input())

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for c in [chr(ord('a') + i) for i in range(ord(mx) - ord('a') + 1)]:
            dfs(s + c, chr(ord(mx) + 1) if c == mx else mx)

dfs('', 'a')

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

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for c in [chr(ord('a') + i) for i in range(ord(mx) - ord('a') + 1)]:
            dfs(s + c, chr(ord(mx) + 1) if c == mx else mx)

dfx('', 'a')
Problem p02756 (python)

Fixed submission:
s = input()
q = int(input())
is_r = False
f_list = []
b_list = []

for i in range(q):
    q_i = input().split(' ')
    t_i = q_i[0]
    if t_i == '1':
        is_r = not is_r
    else:
        f_i = q_i[1]
        if (f_i == '1' and not is_r) or (f_i == '2' and is_r):
            f_list.append(q_i[2])
        else:
            b_list.append(q_i[2])

f_list = f_list[::-1]
f_list.append(s)
f_list.extend(b_list)
s = ''.join(f_list) if not is_r else ''.join(f_list)[::-1]
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
is_r = False
f_list = []
b_list = []

for i in range(q):
    q_i = input().split(' ')
    t_i = q_i[0]
    if t_i == '1':
        is_r = not is_r
    else:
        f_i = q_i[1]
        if (f_i == '1' and not is_r) or (f_i == '2' and is_r):
            f_list.append(q_i[2])
        else:
            b_list.append(q_i[2])

f_list = f_list[::-1]
f_list.append(s)
f_list.extend(b_list)
s = f_list.join('') if not is_r else f_list[::-1].join('')
print(s)
Problem p02837 (python)

Fixed submission:
n = int(input())

testimony_dict = {}
for i in range(n):
    a = int(input())
    testimony_dict[i + 1] = []
    for j in range(a):
        xy = input().split(' ')
        testimony_dict[i + 1].append(xy)

max_valid_bin = ''
for i in range(2 ** n - 1, 0, -1):
    is_valid = True
    bin_i = format(i, '0{}b'.format(n))
    for j in range(1, len(bin_i) + 1):
        if bin_i[j - 1] == '1':
            for xy_list in testimony_dict[j]:
                if bin_i[int(xy_list[0]) - 1] != xy_list[1]:
                    is_valid = False
    if is_valid:
        max_valid_bin = bin_i
        break

print(len([i for i in max_valid_bin if i == '1']))

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

testimony_dict = {}
for i in range(n):
    a = int(input())
    testimony_dict[i + 1] = []
    for j in range(a):
        xy = input().split(' ')
        testimony_dict[i + 1].append(xy)

max_valid_bin = ''
for i in range(2 ** n - 1, 0, -1):
    is_valid = True
    bin_i = format(i, f'0{n}b')
    for j in range(1, len(bin_i) + 1):
        if bin_i[j - 1] == '1':
            for xy_list in testimony_dict[j]:
                if bin_i[int(xy_list[0]) - 1] != xy_list[1]:
                    is_valid = False
    if is_valid:
        max_valid_bin = bin_i
        break

print(len([i for i in max_valid_bin if i == '1']))
Problem p03112 (python)

Fixed submission:
import bisect

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

INF = 10 ** 18
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for i in range(Q):
  x = int(input())
  b = bisect.bisect_right(s, x)
  d = bisect.bisect_right(t, x)
  dist = INF
  for sb in [s[b - 1], s[b]]:
    for td in [t[d - 1], t[d]]:
      d1, d2 = abs(x - sb) + abs(sb - td), abs(x - td) + abs(td - sb)
      dist = min(dist, d1, d2)
  print(dist)

Buggy submission (verdict: Runtime Error):
import bisect

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

INF = 10 ** 18
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for x in range(Q):
  b = bisect.bisect_right(s, x)
  d = disect.bisect_right(t, x)
  dist = 0
  for sb in [s[b - 1], s[b]]:
    for td in [t[d - 1], t[d]]:
      d1, d2 = abs(x - sb) + abs(sb - td), abs(x - td) + abs(td - sb)
      dist = min(dist, d1, d2)
  print(dist)
Problem p03447 (python)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())

ans = (x - a) % b
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()

cnt = 0
for i in range(a + 1):
	if 500 * i <= x:
		p = x - 500 * i
		for j in range(b + 1):
			if 100 * j <= p:
				q = p - 100 * j:
				for k in range(c + 1):
					if q - 50 * k == 0:
						cnt += 1

print(cnt)
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if 500 * i + 100 * j + 50 * k == x:
				cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()

cnt = 0
for i in range(a + 1):
	if 500 * i <= x:
		p = x - 500 * i
		for j in range(b + 1):
			if 100 * j <= p:
				q = p - 100 * j
				for k in range(c + 1):
					if q - 50 * k == 0:
						cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()

cnt = 0
for i in range(a + 1):
	if 500 * i <= x:
		p = x - 500 * i
		for j in range(b + 1):
			if 100 * j <= p:
				q = p - 100 * j:
				for k in range(c + 1):
					if q - 50 * k == 0:
						cnt += 1

print(cnt)
Problem p02553 (python)

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

lstx=[a,b]
lsty=[c,d]
result=[]
for i in lstx:
    for n in lsty:
        result.append(i*n)
print(max(result))

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

X=[]
Y=[]
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
A="NO"
for n in range(N-2):
    if X[n]==Y[n] and X[n+1]==Y[n+1] and X[n+2]==Y[n+2]:
        A="YES"
        break
print(A)
Problem p02718 (python)

Fixed submission:
n, m = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]

a_sum = sum(a_list)
a_list.sort()
a_list.reverse()
for i in range(m):
    a = a_list[i]
    if a < a_sum / (4 * m):
        print('No')
        exit()
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

a.sort()
a.reverse()
print('Yes' if (a[m] >= (sum(a) / (4 * m))) else 'No')
Problem p02548 (python)

Fixed submission:
# import math
# import sympy
# sympy.divisors(10**9)

n = int(input())

# count = 0
# for i in range(1, n):
#     count = count + math.ceil(len(sympy.divisors(i)))
#     # print(math.ceil(len(sympy.divisors(i))))
# print(count)

count = 0
for a in range(1, n - 1):
    if n % a != 0:
        b = n // a
    else:
        b = n // a - 1
    if a <= b:
        count = (count + b)
    else:
        count = (count + b)
    # print(count)

print(count + 1)

Buggy submission (verdict: Runtime Error):
import math
import sympy
# sympy.divisors(10**9)

n = int(input())

# count = 0
# for i in range(1, n):
#     count = count + math.ceil(len(sympy.divisors(i)))
#     # print(math.ceil(len(sympy.divisors(i))))
# print(count)

count = 0
for a in range(1, n - 1):
    if n % a != 0:
        b = n // a
    else:
        b = n // a - 1
    if a <= b:
        count = (count + b)
    else:
        count = (count + b)
    # print(count)

print(count + 1)
Problem p03455 (python)

Fixed submission:
# coding: utf-8
in_str = input()
a, b = in_str.split(" ")
a = int(a)
b = int(b)

if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")

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

in_str = input()
a, b = in_str.split(" ")
if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")
Problem p03457 (python)

Fixed submission:
# coding: utf-8
import math
n = int(input())
t = 0
x = 0
y = 0
txy = []
for i in range(n):
    ti, xi, yi = list(map(int, input().split()))
    txy.append((ti, xi, yi))

for ti, xi, yi in txy:
    if abs(xi - x) + abs(yi - y) > abs(ti - t):
        print("No")
        exit()
    elif (abs(xi - x) + abs(yi - y) - abs(ti - t)) % 2 != 0:
        print("No")
        exit()
    else:
        t = ti
        x = xi
        y = yi
print("Yes")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math
n = int(input())
t = 0
x = 0
y = 0
# txy = []
# for i in range(n):
#     ti, xi, yi = list(map(int, input().split()))
#     txy.append((ti, xi, yi))

for ti, xi, yi in map(int, input().split()):
    if abs(xi - x) + abs(yi - y) > abs(ti - t):
        print("No")
        exit()
    elif (abs(xi - x) + abs(yi - y) - abs(ti - t)) % 2 != 0:
        print("No")
        exit()
    else:
        t = ti
        x = xi
        y = yi
print("Yes")
Problem p02607 (python)

Fixed submission:
N=int(input())
#N=17



input=input()
#input="13 76 46 15 50 98 93 77 31 43 84 90 6 24 14 0 1"
masu=[int(r) for r in input.split()]
ans=[]

for i in range(1,N+1,2):

    if masu[i-1]%2==1:
        ans.append(i)

print(len(ans))

Buggy submission (verdict: Runtime Error):

N=15
input=input()

masu=[int(r) for r in input.split()]
ans=[]

for i in range(1,N+1,2):

    if masu[i-1]%2==1 and i%2==1:
        ans.append(i)

print(len(ans))
Problem p02678 (python)

Fixed submission:
from collections import deque

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

d = {}

for i in range(N):
    d[i+1] = set()

for i in range(M):
    a, b = map(int,input().split())
    d[a].add(b)
    d[b].add(a)

que = deque([1])
checked = set()
ans = {1:-1}

while que:
    now = que.popleft()
    for h in d[now]:
        if not h in ans:
            ans[h] = now
            que.append(h)
    if len(ans) == N:
        break
    
if len(ans) == N:
    print('Yes')
    for i in range(N-1):
        print(ans[i+2]) 
else:
    print('No')

Buggy submission (verdict: Runtime Error):
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Problem p02684 (python)

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

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

now = 1

d = []
set_d = set()

while True:
    if A[now-1] in set_d:
        i = d.index(A[now-1])
        check = d[i:]
        break
    now = A[now-1]
    d.append(now)
    set_d.add(now)

    if len(set_d) >= K:
        break

if K <= len(set_d):
    print(d[K-1])
else:
    K -= (len(set_d)-len(check))
    K = K % len(check)
    print(check[K-1])

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

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

now = 1

d = []

while True:
    if A[now-1] in d:
        i = d.index(A[now-1])
        check = d[i:]
        break
    d.append(A[now-1])
    now = A[now-1]
    print(d,now)

if K <= len(d):
    print(d[K-1])
else:
    K -= (len(d)-len(check))
    K = K % len(check)
    print(check[K-1])
Problem p02690 (python)

Fixed submission:
X = int(input())

d = {}
k = {}
for i in range(-1000,1001):
    d[i] = pow(i,5)
    k[d[i]] = i
i = 1000

while True:
    if X + d[i] in d.values():
        b = i
        a = k[X + d[i]]
        break
    i -= 1

print(a, b)

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

d = {}
k = {}
for i in range(-100,101):
    d[i] = pow(i,5)
    k[d[i]] = i
i = -100

while True:
    if X + d[i] in d.values():
        b = i
        a = k[X + d[i]]
        break
    i += 1

print(a, b)
Problem p02732 (python)

Fixed submission:
N = int(input())

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

d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

ans_all = 0
ans_list = {}
for k, v in d.items():
    if v == 1:
        ans_list[k] = 0
        continue
    if v == 2:
        ans_all += 1
        ans_list[k] = 1
        continue
    ans_all += v*(v-1)/2
    ans_list[k] = v*(v-1)/2 - (v-1)*(v-2)/2

for a in A:
    print(int(ans_all-ans_list[a]))

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

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

d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

ans_all = 0
ans_list = {}
for k, v in d.items():
    if v == 1:
        continue
    if v == 2:
        ans_all += 1
        ans_list[k] = 1
        continue
    ans_all += v*(v-1)/2
    ans_list[k] = v*(v-1)/2 - (v-1)*(v-2)/2

for a in A:
    print(int(ans_all-ans_list[a]))
Problem p02767 (python)

Fixed submission:
N = int(input())

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

dp = {}

for i in range(N):
    for j in range(min(X), max(X)+1):
        if j in dp:
            dp[j] += (X[i] - j)*(X[i] - j)
        else:
            dp[j] = (X[i] - j)*(X[i] - j)

print(min(dp.values()))

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

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

dp = {}

for i in range(N):
    for j in range(min(X), max(X)):
        if j in dp:
            dp[j] += (X[i] - j)**2
        else:
            dp[j] = (X[i] - j)**2

print(min(dp.values()))
Problem p02995 (python)

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

def lcm(x, y):
    return (x * y) // gcd(x, y)


A, B, C, D = map(int, input().split())
ans = set()
if A%C == 0:
    c = (B//C) - (A//C) + 1
else:
    c = (B//C) - (A//C)

if A%D == 0:
    d = (B//D) - (A//D) + 1
else:
    d = (B//D) - (A//D)

CD = lcm(C, D)

if A%CD == 0:
    cd = (B//CD) - (A//CD) + 1
else:
    cd = (B//CD) - (A//CD)

print(B - A + 1 - (c+d-cd))

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)


A, B, C, D = map(int, input().split())
ans = set()
if A%C == 0:
    c = (B//C) - (A//C) + 1
else:
    c = (B//C) - (A//C)

if A%D == 0:
    d = (B//D) - (A//D) + 1
else:
    d = (B//D) - (A//D)

CD = lcm(C, D)

if A%CD == 0:
    cd = (B//CD) - (A//CD) + 1
else:
    cd = (B//CD) - (A//CD)

print(B - A + 1 - (c+d-cd))

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
ans = set(list(range(A, B+1)))


for i in range(A//C + 1, B //C + 1):
    if i*C in ans:
        ans.remove(i*C)

for i in range(A//D + 1, B //D + 1):
    if i*D in ans:
        ans.remove(i*D)
    


print(len(ans))
Problem p03079 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a == b and b == c:
    print("Yes")
else:
    print("No")

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

r = 0
b = 0
for c in s:
    if c = "R":
        r = r + 1
    else:
        b = b + 1
if r > b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=input()

if a == b and b == c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,d=input()

if a == b and b == c:
    print("yes")
else:
    print("no")