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

Fixed submission:
import itertools as it

n,m,q = map(int,input().split())

ar = [[0]*4]*q

for i in range(q):
    ar[i] = [int(s) for s in input().split()]

A = list(it.combinations_with_replacement(list(range(1,m+1)),n))
mx = 0

for cnd in A:
    mx_tmp=0
    for i in range(q):
        if(cnd[ar[i][1]-1] - cnd[ar[i][0]-1] == ar[i][2]):
            mx_tmp += ar[i][3]
    mx = max(mx,mx_tmp)

print(mx)

Buggy submission (verdict: Runtime Error):
import itertools as it

n,m,q = map(int,input().split())

ar = [[0]*4]*q

for i in range(q):
    ar[i] = [int(s) for s in input().split()]

A = it.combinations_with_replacement(list(range(1,m+1)),n)
mx = 0

for cnd in A:
    mx_tmp=0
    for i in range(q):
        if(A[ar[i][1]-1] - A[ar[i][0]-1] == ar[i][2]):
            mx_tmp += ar[i][3]
    mx = max(mx,mx_tmp)

print(mx)
Problem p02860 (python)

Fixed submission:
N=int(input())
S=input()
if N%2!=0:
    print('No')
else:
    if S[0:N//2]==S[N//2:N]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
if N%2!=0:
    print('No')
	exit()
    
if S[0:N//2]==S[N//2:N]:
	print('Yes')
else:
	print('No')
Problem p02879 (python)

Fixed submission:
a,b=map(int,input().split())
if a<10 and b <10:
    print(a*b)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a<10 and b <10:
	print(a*b)
elif:
    print(-1)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a<10 and b <10:
    return a*b
elif:
    return -1
Problem p02676 (python)

Fixed submission:
#In[]:
k = int(input())
s = input()

if len(s) > k:
    s_str = s[:k]
    print(s_str + "...")
else:
    print(s)

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

s_li = []
for i in s:
    s_li.append(i)

if len(s_li) > k:
    s_str = s_li[:k]
    print(''.join(s_str) + "...")
else:
    print(''.join(s_str))
Problem p03834 (python)

Fixed submission:
print(*input().split(","))

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

Buggy submission (verdict: Runtime Error):
print(*input().sep(","))
Problem p02881 (python)

Fixed submission:
import sys
input = sys.stdin.readline
s = 0
N = int(input())
for i in range(1, int(N**(1/2))+1):
    if N%i == 0 and i > s:
        s = i
print(s+(N//s)-2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
s = 0
N = int(input())
for i in range(1, int(N**(1/2))):
    if N%i == 0 and i > s:
        s = i
print(s+(N//s)-2)

Buggy submission (verdict: Runtime Error):
s = 0
N = int(input())
for i in range(1, int(N/2)):
    if N%i == 0 and i > s:
        s = i
print(s+(N//s)-2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
s = 0
N = int(input())
for i in range(1, int(N/2)):
    if N%i == 0 and i > s:
        s = i
print(s+(N//s)-2)
Problem p02984 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B1 = 0
B = []
for i in range(0,N):
    if i%2 == 0:
        B1 += A[i]
    else:
        B1 -= A[i]
B.append(B1)
XX = B1
for i in range (0,N-1) :
    X = 2*A[i]-XX
    B.append(X)
    XX = X
for i in range(0,N):
    print(B[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B1 = 0
B = []
for i in range(0,N+1):
    if A[i]%2 == 1:
        B1 += A[i]
    else:
        B1 -= A[i]
B.append(B1)
XX = B1
for i in range (0,N-1) :
    X = 2*A[i]-XX
    B.append(X)
    XX = X
print(B)
Problem p02987 (python)

Fixed submission:
S = input()
A = set (S)
B = len (A)
if B == 2:
    print ('Yes')
else:
    print ('No')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = list(map(int, input().split()))
c = sorted(b)
d = c[(a//2)]-c[(a//2)-1]
print(d)

Buggy submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
c=0
d=0
while c<=n-3 :
    if (b[c+1]>b[c] and b[c+1]<b[c+2]) or (b[c+1]<b[c] and b[c+1]>b[c+2]):
        d +=1
        c +=1
    else:
        c+=1

print(d)

Buggy submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
c=0
d=0
while c<=n-3 :
    if (b[c+1]>b[c] and b[c+1]<b[c+2]) or (b[c+1]<b[c] and b[c+1]>b[c+2]):
        d +=1
        c +=1
    else:
        c+=1

print(d)
Problem p03011 (python)

Fixed submission:
P, Q, R =map(int, input().split())
if P+Q <= P+R and P+Q <= Q+R:
    print(P+Q)
elif P+R <= P+Q and P+R <= Q+R:
    print(P+R)
else:
    print(Q+R)

Buggy submission (verdict: Runtime Error):
P, Q, R = list(map (int, input().split(' ') ) )
if P+Q > P+R. Q+R ;
    print(P+Q)
elif P+R>P+Q,Q+R:
    print(P+R)
else:
    print(Q+R)
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S = list(input())
S[K-1] = S[K-1].lower()
print("".join(S))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
S[K-1] = S[K-1].lower()
print(S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
S[K-1] = S[K-1].lower()
print("".join(S))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
S = input()
S[K-1] = S[K-1].lower()
print(''.join(S))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
S = input()
S[K-1] = S[K-1].lower()
print('',join(S))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
S = input()
S[K-1] = S[K-1].lower()
print(S)

Buggy submission (verdict: Runtime Error):
N,K=map(input().split())
S=str.input()
S[K-1] = S[K-1].lower()
print(S)

Buggy submission (verdict: Runtime Error):
N,K=map(input().split())
S=str.input()
S[K-1] = S[K-1].lower()

Buggy submission (verdict: Runtime Error):
N,K=map(input().split())
S=input()
S[K-1] = S[K-1].lower()

Buggy submission (verdict: Runtime Error):
N,K=map(input().split())
S=input()
S = S[:K] + S[K+1].lower() + S[K+2:]

Buggy submission (verdict: Runtime Error):
N,K=map(input().split())
S=input()
S = S[:K] + S[K+1].lower() + S[K:]
Problem p03075 (python)

Fixed submission:
a,b,c,d,e,k = map(int,open(0).read().split())
if e-a <= k:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = map(int,open(0).read().split())
if max(e-a) <= k:
    print("Yay!")
else:
    print(":(")
Problem p03250 (python)

Fixed submission:
listabc = sorted(list(map(int,input().split())))
print(9*listabc[2]+sum(listabc))

Buggy submission (verdict: Runtime Error):
A,B,C = map(int.input().split())
print(max(A+B,B+C,C+A))
Problem p03631 (python)

Fixed submission:
N = input()
NN = list(N)
checker = ""
for i in range(len(NN)):
    checker += NN[-i-1]
if N == checker:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
if C >= B or D <= A:
    print(0)
elif A <= C <= D <= B:
    print(D-C)
elif C <= A <= B <= D:
    print(B-A)
elif C <= B:
    print(B-C)
else:
    print(D-A)
Problem p02699 (python)

Fixed submission:
s, w= map(int, input().split())
if w >= s:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
s, w = int(input()).split()
if w >= s:
  print("unsafe")
else:
  print("safe")
Problem p02723 (python)

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = str(input())
if S[3] == S[4] and S[5] == S[6]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if S[3] == S[4] and S[5] == S[6]:
  print("Yes")
else:
  print("No")
Problem p02729 (python)

Fixed submission:
N,M=map(int,input().split())
Ans = (N**2-N)/2 + (M**2-M)/2
print(int(Ans))

Buggy submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split())
a = N(N-1)/2
b = M(M-1)/2
c = N(N-1) + M(M-1)
print(a + b + c)
Problem p02627 (python)

Fixed submission:
s = input()
if s.isupper():
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
print(α)
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if w>=s:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
a, b, c, d = list(map(int, input().split()))
A = a - d
B = c - b
if A>=B:
  print('Yes')
else:
  print('No')
Problem p02594 (python)

Fixed submission:
temperature = int(input())

if 30 <= temperature:
    print("Yes")
else:
    print("No")

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

if 30 <= temperature:
    print('Yes')
els:
    print('No')
Problem p02693 (python)

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

a_div_k = a // k
b_div_k = b // k

a_mod_k = a % k
b_mod_k = b % k

if b < k:
    print("NG")
elif k == 1:
    print("OK")
elif k == b:
    print("OK")
elif (a_mod_k == 0) or (b_mod_k == 0) and (a_div_k == b_div_k):
    print("OK")
elif (k < a) and (a_div_k == b_div_k):
    print("NG")
else:
    print("OK")

Buggy submission (verdict: Runtime Error):
if k >= 1:
    print("OK")

if b - a + 2 >= k:
    print("OK")
else:
    print("NG")
Problem p02596 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    K = I()
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1
    
    else:
        print('-1')

main()

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

def main():
    
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1
main()
Problem p02970 (python)

Fixed submission:
n,d = map(int,input().split())
 
if n % (d*2+1) != 0:
  print(int(n // (d*2+1) + 1)) 
else:
  print(int(n // (d*2+1)))

Buggy submission (verdict: Runtime Error):
n,d = mat(int,input().split())

if n % (d*2+1) != 0:
  print(int(n % (d*2+1) + 1)) 
 else:
  print(int(n % (d*2+1)))
Problem p03307 (python)

Fixed submission:
n = int(input())

if n % 2 == 0:
    print(n)
else:
    print(n * 2)

Buggy submission (verdict: Runtime Error):
from statistics import median

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

b = [v - (i + 1) for i, v in enumerate(a)]

median = int(median(b))

c = sum(abs(v - median) for v in b)

print(c)
Problem p02623 (python)

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

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

time = 0
count = 0
i = 0
j = 0

if k < a[i] or k < b[j]:
    k = -1

while k > time and i != n and j != m:
    if a[i] >= b[j] and k >= time:
        time += b[j]
        j += 1
        count += 1
        if j == m and i != n-1 and k >= time:
            while i != n:
                time += a[j]
                i += 1
                count += 1
    if a[i] <= b[j] and k >= time:
        time += a[i]
        i += 1
        count += 1
        if i == n and j != m-1 and k >= time:
            while j != m:
                time += b[j]
                j += 1
                count += 1

if count > 0 and k < time:
    count -= 1

print(count)
Problem p02682 (python)

Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)

Buggy submission (verdict: Runtime Error):
A, B, C, K = (int(x) for x in input().split())

a = [1] * A
b = [0] * B
c = [-1] * C

X = a + b + c
print(sum(X[:K]))

Buggy submission (verdict: Runtime Error):
A, B, C, K = (int(x) for x in input().split())

a = [1] * A
b = [0] * B
c = [-1] * C
X = a + b + c
print(sum(X[:K]))
Problem p02759 (python)

Fixed submission:
from math import ceil
N = int(input())
print(ceil(N/2))

Buggy submission (verdict: Runtime Error):
from math import ceil
N = int(inpput())
print(ceil(N/2))
Problem p02897 (python)

Fixed submission:
n = int(input())
print(((n+1)//2)/n)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = {(i+1):int(j) for i, j in enumerate(input().split())}
A_sorted = sum(map(list, sorted(A.items(), key=lambda x:x[1])), [])
t = A_sorted[0::2]
print(*t, sep=' ')
Problem p02594 (python)

Fixed submission:
X=int(input())
if(X<=40 and X>=-40):
    if(X>=30):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
int X=input()
if(X==30):
  print("Yes")
else:
  print("No")
Problem p02595 (python)

Fixed submission:
import math

N, D = map(int, input().split())
ans = 0

for i in range(N):
    x, y = map(int, input().split())
    if math.sqrt(x**2 + y**2) <= D:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N, D = map(int, input().split())
ans = 0

for i in range(N):
    x, y = map(int, input().split())
    if math.sqrt(x**2 + y**2) =< D:
        ans += 1

print(ans)
Problem p02693 (python)

Fixed submission:
k = int(input())
a,b = map(int, input().split())
if b//k * k >= a:
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = map(int, input().split()) 
i = 0
j = 0
if(A==B):
  if(A%K==0):
    print('OK')
  else:
    prin('NG')
for x in range(A, B):
    if A / K == B  or (x % K == 0 or K % x == 0):
        print('OK')
        i += 1
        break
if i == 0:
    print('NG')
Problem p02729 (python)

Fixed submission:
from functools import reduce
def permu(n,r):
    return reduce(lambda a,b: a*b, range(n-r+1,n+1))
N,M = map(int, input().split())
print(int((permu(N,2)+permu(M,2))/2))

Buggy submission (verdict: Runtime Error):
S = input()
N = len(str(S))
temp = S[0:(N-1)/2]
temp2 = S[(N+2)/2:N]
print("Yes") if temp == temp[::-1] and temp2 == temp2[::-1] else "No"
Problem p02759 (python)

Fixed submission:
import math
N = int(input())
if( N%2 == 0 ):
  print(int(N/2))
else:
  print(math.ceil((N/2)))

Buggy submission (verdict: Runtime Error):
N = int(input())
if(n%2 ==0):
  print(n/2)
else:
  print((n/2)+1)
Problem p02790 (python)

Fixed submission:
a,b = input().split()
a = int(a)
b = int(b)
string = ""
if a>b:
    for i in range(a):
        string = string+str(b)
elif b>a:
    for i in range(b):
        string = string+str(a)
else:
    for i in range(a):
        string =  string+str(a)
print(string)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
string = ""
if N>M:
    for i in range(N):
        string = string+str(M)
elif b>a:
    for i in range(M):
        string = string+str(N)
else:
    for i in range(N):
        string =  string+str(N)
print(string)
Problem p02819 (python)

Fixed submission:
num = int(input())

def is_prime(num):
  for i in range(2,num):
    if (num % i) == 0:
      return False
  return True
while is_prime(num) == False:
    num = num + 1
print (num)

Buggy submission (verdict: Runtime Error):
if (N <= 1):
  print(2) 
int prime = N; 
bool found = false; 
while (!found):
  prime++ 
  if (isPrime(prime)):
    found = true; 
print(prime)
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())
print(6-(A+B))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if(A==1&&B==2):
  print(3)
elif(A==2&&B==1):
  print(3)
elif(A==1&&B==3):
  print(2)
elif(A==3&&B==1):
  print(2)
elif(A==3&&B==2):
  print(1)
else(A==2&&B==3):
  print(1)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if(A==1&&B==2):
  print(3)
if(A==2&&B==1):
  print(3)
if(A==1&&B==3):
  print(2)
if(A==3&&B==1):
  print(2)
if(A==3&&B==2):
  print(1)
if(A==2&&B==3):
  print(1)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if(A=1&&B==2):
  print(3)
if(A==2&&B==1):
  print(3)
if(A=1&&B==3):
  print(2)
if(A==3&&B==1):
  print(2)
if(A=3&&B==2):
  print(1)
if(A==2&&B==3):
  print(1)
Problem p02897 (python)

Fixed submission:
N = int(input())
if(N%2==0):
  print((N/2)/N)
else:
  print(((N+1)/2)/N)

Buggy submission (verdict: Runtime Error):
N = int(input("Number:\n"))
if(N%2==):
  res = (N/2)/N
else:
  res = ((N+1)/2)/N
print(res)

Buggy submission (verdict: Runtime Error):
N = input("Number:\n")
if(N%2==0):
  res = (N/2)/N
else:
  res = ((N+1)/2)/N
print(res)
Problem p03013 (python)

Fixed submission:
def fib(n):
    if n == 0: 
        return 0

    if n == 1: 
        return 1

    def matmul(M1, M2):
        a11 = M1[0][0]*M2[0][0] + M1[0][1]*M2[1][0]
        a12 = M1[0][0]*M2[0][1] + M1[0][1]*M2[1][1]
        a21 = M1[1][0]*M2[0][0] + M1[1][1]*M2[1][0]
        a22 = M1[1][0]*M2[0][1] + M1[1][1]*M2[1][1]
        return [[a11, a12], [a21, a22]]

    def matPower(mat, p):
        if p == 1: 
            return mat

        m2 = matPower(mat, p//2)
        if p % 2 == 0:
            return matmul(m2, m2)
        else: 
            return matmul(matmul(m2, m2),mat)

    Q = [[1,1],[1,0]]

    q_final = matPower(Q, n-1)
    return q_final[0][0]

N, M = map(int, input().split())
if(M==0):
    print(fib(N+1)%1000000007)
else:
    V = []
    for x in range(M):
        V.append(int(input()))

    result = 1

    for i in range(1, M):
        if(V[i]-V[i-1]==1):
            result = 0

    result *= fib(V[0])

    for x in range(1, M):
        result *= fib(V[x]-V[x-1]-1)

    if(V[M-1]!=N):
        result *= fib(N-V[M-1])

    print(result%1000000007)

Buggy submission (verdict: Runtime Error):
def fib(n):
    if n == 0: 
        return 0

    if n == 1: 
        return 1

    def matmul(M1, M2):
        a11 = M1[0][0]*M2[0][0] + M1[0][1]*M2[1][0]
        a12 = M1[0][0]*M2[0][1] + M1[0][1]*M2[1][1]
        a21 = M1[1][0]*M2[0][0] + M1[1][1]*M2[1][0]
        a22 = M1[1][0]*M2[0][1] + M1[1][1]*M2[1][1]
        return [[a11, a12], [a21, a22]]

    def matPower(mat, p):
        if p == 1: 
            return mat

        m2 = matPower(mat, p//2)
        if p % 2 == 0:
            return matmul(m2, m2)
        else: 
            return matmul(matmul(m2, m2),mat)

    Q = [[1,1],[1,0]]

    q_final = matPower(Q, n-1)
    return q_final[0][0]

N, M = map(int, input().split())
V = []
for x in range(M):
    V.append(int(input()))

result = 1

for i in range(1, M):
    if(V[i]-V[i-1]==1):
        result = 0

result *= fib(V[0])

for x in range(1, M):
    result *= fib(V[x]-V[x-1]-1)

if(V[M-1]!=N):
    result *= fib(N-V[M-1])

print(result%1000000007)
Problem p02779 (python)

Fixed submission:
i=int(input())
x=[int(x) for x in input().split()]
y=set(x)
if(len(y)==len(x)):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
i=int(input())
x=[]
for i in range(0,i):
  a=int(input())
  if a in x:
    c=0
    break
  else:
    c=1
if(c==0):
  print("NO")
else: 
  print("YES")
Problem p02594 (python)

Fixed submission:
n = int(input())
a = "Yes"
b = "No"
if n >= 30:
  print(a)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n >= 30:
  return "Yes"
else:
  return "No"
Problem p02935 (python)

Fixed submission:
import heapq

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

heapq.heapify(q)

while (len(q) > 1):
    v1 = heapq.heappop(q)
    v2 = heapq.heappop(q)
    heapq.heappush(q, (v1+v2)/2.0)

print(heapq.heappop(q))

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  priority_queue<double, vector<double>,  greater<double>> q;
  int v;
  for (int i = 0; i < N; i++) {
    cin >> v;
    q.push((double)v);
  }
  while (q.size() > 1) {
    double v1 = q.top();
    q.pop();
    double v2 = q.top();
    q.pop();
    q.push((v1+v2)/2);
  }
  cout << fixed << setprecision(10) << q.top() << endl;
  return 0;
}

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  priority_queue<double, vector<double>,  greater<double>> q;
  int v;
  for (int i = 0; i < N; i++) {
    cin >> v;
    q.push((double)v);
  }
  while (q.size() > 1) {
    double v1 = q.top();
    q.pop();
    double v2 = q.top();
    q.pop();
    q.push((v1+v2)/2);
  }
  cout << setprecision(10) << q.top() << endl;
  return 0;
}
Problem p02689 (python)

Fixed submission:
import collections

N, M = map(int,input().split())
H = [int(i) for i in input().split()]

X = []
for i in range(M):
    Aj, Bj = map(int,input().split())
    if H[Aj - 1] < H[Bj - 1]:
       X.append(Aj)
    elif H[Bj - 1] < H[Aj - 1]:
       X.append(Bj)
    elif H[Aj - 1] == H[Bj - 1]:
        X.append(Aj)
        X.append(Bj)

low_H = collections.Counter(X)
ans = N - len(low_H)
print(ans)

Buggy submission (verdict: Runtime Error):
import collections

N, M = map(int,input().split())
H = [int(input()) for i in range(N)]

X = []
for i in range(M):
    Aj, Bj = map(int,input().split())
    if H[Aj - 1] < H[Bj - 1]:
       X.append(Aj)
    elif H[Bj - 1] < H[Aj - 1]:
       X.append(Bj)
    elif H[Aj - 1] == H[Bj - 1]:
        X.append(Aj)
        X.append(Bj)

low_H = collections.Counter(X)
ans = N - len(low_H)
print(ans)
Problem p02661 (python)

Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2-1]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2-1]+A[N//2])/2
    BB = (B[N//2-1]+B[N//2])/2
    print(int((BB-AA)*2+1))

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

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2]+A[N//2+1])//2
    BB = (B[N//2-1]+B[N//2+1-1])//2
    print(BB-AA+1)

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

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2]+A[N//2+1])/2
    BB = (B[N//2-1]+B[N//2+1-1])/2
    print(BB-AA+1)

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

A.sort()
B.sort()
print(A)
print(B)
if N % 2 == 1:
    AA = A[(N+1)//2]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2]+A[N//2+1])/2
    BB = (B[N//2-1]+B[N//2+1-1])/2
    print(BB-AA+1)
Problem p02729 (python)

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

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

print(N*(N-1)//2 + M*(M-1)//2)

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

import sys
input = sys.stdin.readline

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

N = int(input())
L = list(map(int, input().split()))
M = [0] *(N+1)
cnt = [0] *(N+1)

for i in L:
    cnt[i] += 1
    C = cnt[i]
    if C == 2:
        M[i] = 2
    elif C > 2:
        M[i] *= C
        M[i] //= (C-2)     
ans = sum(M)//2

for i in range(N):
    B = cnt[L[i]]
    if B == 2:
        print(ans - 1)
    elif B > 2:
        print(ans -combinations_count(B,2) +combinations_count(B-1,2))
    else:
        print(ans)