Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M =map(int,input().split())
ans=0

def fact(n):
    if n==0:
        return 1
    return n*fact(n-1)

if abs(N-M)>=2:
    print(0)
elif abs(N-M)==0:
    ans=fact(N)*4
elif abs(N-M)==1:
    ans=fact(N)*fact(M)
else:
    print(0)

ans=ans%(10**9+7)

print(ans)

Fixed submission:
import math
N, M =map(int,input().split())
ans=0

if abs(N-M)==0:
    ans=math.factorial(N)*math.factorial(M)*2
elif abs(N-M)==1:
    ans=math.factorial(N)*math.factorial(M)
else:
    ans=0

ans=ans%(10**9+7)

print(ans)

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

def fact(n):
    if n==0:
        return1:
    return n*fact(n-1)

if abs(N-M)>=2:
    print(0)
elif abs(N-M)==0:
    ans=fact(N)*4
elif abs(N-M)==1:
    ans=fact(N)*fact(M)
else:
    print(0)

ans=ans%(10**9+7)

print(ans)

Fixed submission:
import math
N, M =map(int,input().split())
ans=0

if abs(N-M)==0:
    ans=math.factorial(N)*math.factorial(M)*2
elif abs(N-M)==1:
    ans=math.factorial(N)*math.factorial(M)
else:
    ans=0

ans=ans%(10**9+7)

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for c in [chr(i) for i in range(ord('a'), ord('z')+1)]
    ans=ans+c*counter[c]
print(ans)

Fixed submission:
from collections import Counter

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for c in [chr(i) for i in range(ord('a'), ord('z')+1)]:
    ans=ans+c*counter[c]
print(ans)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
for i in range(n) :
  x -= a[i]
  if(x == 0) : 
    print(i+1)
    exit()
  elif(a[i] > x) : print(i)

Fixed submission:
def gcm(a, b) :
  while(b) :
    a, b = b, a%b
  return a
def lcm(a, b) :
  return int(a*b/gcm(a, b))

n, m = map(int, input().split())
s = list(str(input()))
t = list(str(input()))
s_out = []
t_out = []
for i in range(int(gcm(n, m))) :
  s_out.append(s[i*int(n/gcm(n, m))])
for i in range(int(gcm(n, m))) :
  t_out.append(t[i*int(m/gcm(n, m))])
  
if(s_out == t_out) : print(lcm(n, m))
else : print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
def gcm(a, b) :
  while(b) :
    a, b = b, a%b
  return a
def lcm(a, b) :
  return int(a*b/gcm(a, b))

b = a[0]
for i in range(n-1) :
  b = lcm(b, a[i+1])
  
print(sum([(b-1)%a[i] for i in range(n)]))

Fixed submission:
n = input()
print(sum(list(map(lambda x: int(x)-1, input().split()))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = [0]*int(1e5+10)
for i in range(n) :
  cnt[a[i]] += 1
print(sum([cnt[i]%2 for i in range(len(cnt))]))

Fixed submission:
n = int(input())
a = sorted([int(input()) for _ in range(n)])
tmp = a[0]
cnt = [0]*n
ptr = 0
for i in range(n) :
  if(a[i-1] != a[i]) :
    ptr += 1
  cnt[ptr] += 1
print(sum([cnt[i]%2 for i in range(len(cnt))]))
Buggy python submission (verdict: Runtime Error):
def napsach(N, W, v, w):
    if N == 0 or K == 0:
        return 0
    V = []
    for i in range(N):
        V.append([0] * W)

    for i in range(N):
        for j in range(W):
            if i == 0:
                if j + 1 >= w[i]:
                    V[i][j] = v[i]
            else:
                if j + 1 >= w[i]:
                    V[i][j] = max(V[i - 1][j], V[i - 1][j + 1 - w[i]] + v[i])
                else:
                    V[i][j] = V[i - 1][j]
    return V[-1][-1]

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

A_max = max(A)
max_val = max(A_max, K)

i = 0
tot_val = 0
w = []
v = []

while (1 << i) <= max_val:
    temp_w = 0
    for j in range(N):
        temp_w += (A[j] >> i) & 1
    temp_w = N - temp_w
    tot_val += (1 << i) * (N - temp_w)
    if temp_w * 2 > N:
        w.append(1 << i)
        v.append((1 << i) * (2 * temp_w - N))
    i += 1
print(tot_val + napsach(len(v), K, v, w))




Fixed submission:
T, X = map(int, input().split())
print(float(T) / float(X))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    A[i] -= i + 1

min_sum = 10 ** 9 * 2 * 10 ** 5
for i in range(min(A), max(A) + 1):
    summ = 0
    for j in range(N):
        summ += abs(A[j] - i)
    min_sum = min(min_sum, summ)
print(min_sum)


Fixed submission:
import math

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

for i in range(N):
    A[i] -= i + 1

A.sort()
start_index = math.floor(N / 2)

min_sum = 10 ** 9 * 2 * 10 ** 5
for i in range(A[start_index], A[start_index] + 1):
    summ = 0
    for j in range(N):
        summ += abs(A[j] - i)
    min_sum = min(min_sum, summ)
print(min_sum)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')

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

if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
N=input()
num=int(N[3:])

if num>999:
    print("ABD")
else:
    print("ABC")

Fixed submission:
N = input()
num = int(N)
if num < 1000:
    print('ABC')
else:
    print('ABD')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())

array = [A + B, A - B, A * B]
max = array[0]
if max < array[1]:
    max = array[1]
if max < array[2]:
    max = array[2]

print(max)


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

array = [A + B, A - B, A * B]
max = array[0]
if max < array[1]:
    max = array[1]
if max < array[2]:
    max = array[2]

print(max)
Buggy python submission (verdict: Runtime Error):
def input_N_T():
    N_T=input().split()
    int_N_T=list(map(int,N_T))
    N=int_N_T[0]
    T=int_N_T[1]
    return [N,T]

N,T=input_N_T()

min_c,min_t=1001,1001

for i in range(N):
    c,t=input_N_T()
    if(t<=T and min(min_c,c)==c):
        min_c,min_t=c,t

if(N==1001 and T==1001):
    print("TLE")
    
else:
print(c)

Fixed submission:
def input_N_T():
    N_T=input().split()
    int_N_T=list(map(int,N_T))
    N=int_N_T[0]
    T=int_N_T[1]
    return [N,T]

N,T=input_N_T()

min_c,min_t=1001,1001

for i in range(N):
    c,t=input_N_T()
    if(t<=T and min(min_c,c)==c):
        min_c=c

if(min_c==1001):
    print("TLE")
    
else:
    print(min_c)
Buggy python submission (verdict: Runtime Error):
for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue


Fixed submission:
N=input()

str_output=""

for i in range(3):
    if(N[i]=="1"):
        str_output+="9"
    elif(N[i]=="9"):
        str_output+="1"
        
print(int(str_output))
Buggy python submission (verdict: Runtime Error):
for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue


Fixed submission:
N=int(input())
L=[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue

Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if(N>=L[i] and N<=L[i+1]):
        print(L[i+1])
    else:
        continue


Fixed submission:
N=int(input())
L=[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

output=min(S[1:].count("E"),S[:N-1].count("W"))

for i in range(1,N-1):
    cnt=S[:i].count("W")+S[i+1:].count("E")
    output=min(output,cnt)
print(output)

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

output=S[1:].count("E")
a=output

for i in range(N-1):
    if(S[i]=="W"):
        a+=1
    if(S[i+1]=="E"):
        a-=1
    if(a<output):
        output=a
print(output)
Buggy python submission (verdict: Runtime Error):
s=input()
K=int(input())

sub_list=[]

for i in range(len(s)):
    for j in range(1,K+1):
        if(i+j<len(s)):
            sub_list.append(s[i:i+j])

sub_set=set(sub_list)
sub_dict=sorted(sub_set,key=str)

print(sub_dict[K-1])

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

sub_list=[]
i,j=0,1
while True:
    if(i+j>=len(s) and i==len(s)):
        break
    else:
        sub_list.append(s[i:i+j])
        if(j<=K):
            j+=1
        else:
            i+=1
            j=1
set_list=set(sub_list)

dict_list=list(set_list)
dict_list.sort(key=str)

print(dict_list[K-1])

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

sub_list=[]
i,j=0,1
while True:
    if(i+j>=len(s) and i==len(s)-1):
        break
    else:
        sub_list.append(s[i:i+j])
        if(j<=K):
            j+=1
        else:
            i+=1
            j=1
set_list=set(sub_list)

dict_list=list(set_list)
dict_list.sort(key=str)

print(dict_list[K-1])

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

sub_list=[]
i,j=0,1
while True:
    if(i+j>=len(s) and i==len(s)):
        break
    else:
        sub_list.append(s[i:i+j])
        if(j<=K):
            j+=1
        else:
            i+=1
            j=1
set_list=set(sub_list)

dict_list=list(set_list)
dict_list.sort(key=str)

print(dict_list[K-1])
Buggy python submission (verdict: Runtime Error):
S = str(input())
S = S.replace(2017, 2018, 1)
print(S)


Fixed submission:
S = str(input())
S = S.replace("2017", "2018", 1)
print(S)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()


def fnc(l,r):
    cnt = 0
    for i in range(l-1,r):
        if S[i] == "A" and S[i+1] == "C" and i != r-1:
            cnt += 1
    print(cnt)
    
for i in range(Q):
    L,R = map(int,input().split())
    fnc(L,R)
            

Fixed submission:
N,Q = map(int,input().split())
S = input()
t = [0]*(N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2]=="AC" else 0)

for i in range(Q):
    r,l = map(int,input().split())
    print(t[l-1]-t[r-1])
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = abs(x_new[i+1] - x_new[i])
c = sorted(intervals, reverse=True)
s = 0
for j in range(n-1):
  s += c[j]
 
min = sum(intervals) - s
print(min)

Fixed submission:
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = abs(x_new[i+1] - x_new[i])
c = sorted(intervals, reverse=True)
s = 0
if n < m:
    for j in range(n-1):
        s += c[j]
    min = sum(intervals) - s
    print(min)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = x[i+1] - x[i]
c = sorted(intervals, reverse=True)
s = 0
for j in range(n-1):
  s += c[j]

min = sum(intervals) - s
print(s)
  

Fixed submission:
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = abs(x_new[i+1] - x_new[i])
c = sorted(intervals, reverse=True)
s = 0
if n < m:
    for j in range(n-1):
        s += c[j]
    min = sum(intervals) - s
    print(min)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
x = input()
l = len(x)
for _ in range(l):
    x = x.replace('01', '')
    x = x.replace('10', '')
print(l - len(x))


Fixed submission:
x = input()
l = len(x)
l0 = sum([1 for c in x if c == '1'])
l1 = l - l0
if l1 < l0:
    print(l - l0 + l1)
else:
    print(l - l1 + l0)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter

print('yes' if all([True if x <= 1 else False for x in list(Counter(sys.argv[1]).values())]) else 'no')

Fixed submission:
from collections import Counter

print('yes' if all([True if x <= 1 else False for x in list(Counter(input()).values())]) else 'no')
Buggy python submission (verdict: Runtime Error):
def count_apper(str) :
    n = 0
    for c in str :
        if c.isuppper() :
            n = n+1
    return n

str = input()
if (str[0] == "A") && (str.count("C") == 1) && (2 < str.find("C") < len(str)-1) && (count_apper(str) == 2) :
                print("AC")
                exit()
print("WA")
    

Fixed submission:
def count_apper(str) :
    n = 0
    for c in str :
        if c.isupper() :
            n = n+1
    return n

str = input()
if (str[0] == "A") and (str.count("C") == 1) and (1 < str.find("C") < len(str)-1) and (count_apper(str) == 2) :
                print("AC")
                exit()
print("WA")
Buggy python submission (verdict: Runtime Error):
input_string = input().split()

K = int(input_string[0])
A = int(input_string[1])
B = int(input_string[2])

if (A > B):
    print(K+1)
    
# y = -Ax + B(K-x)
# y = -Ax + BK - Bx
# y = -(A + B)x + BK

y = -(A + B)*0 + B*K + 1

print(y)


Fixed submission:
input_string = input().split()
N = int(input_string[0])
K = int(input_string[1])

r = int(N / 2 + 0.5)

if (r >= K):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
def main():
    year, month, day = int(input().strip().split('/'))

    if year < 2019:
        print('Heisei')
        return
    
    if year == 2019:
        if month < 4:
            print('Heisei')
            return
        elif month == 4 and day <= 30:
            print('Heisei')
            return

    print('TBD')
    return

if __name__ == '__main__':
    main()


Fixed submission:

def main():
    year, month, day = map(int, input().strip().split('/'))

    if year < 2019:
        print('Heisei')
        return
    
    if year == 2019:
        if month < 4:
            print('Heisei')
            return
        elif month == 4 and day <= 30:
            print('Heisei')
            return

    print('TBD')
    return

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

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])

A_list = list(AB.keys())
A_list.sort()

cost = 0
amount = 0
for i in range(N):
  if amount + AB[A_list[i]] < M:
    amount += AB[A_list[i]]
    cost += A_list[i]*AB[A_list[i]]
  else:
    temp = M - amount
    cost += A_list[i]*temp
    break
    
print(cost)


Fixed submission:
from sys import stdin
import heapq
hq = []  

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

hq = []
AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])
  heapq.heappush(hq, (int(temp[0]), int(temp[1])))

cost = 0
amount = 0
for i in range(N):
  temp = heapq.heappop(hq)
  if amount + temp[1] < M:
    amount += temp[1]
    cost += temp[0]*temp[1]
  else:
    temp1 = M - amount
    cost += temp[0]*temp1
    break
    
print(cost)

Buggy python submission (verdict: Runtime Error):
from sys import stdin

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])

A_list = list(AB.keys())
A_list.sort()

cost = 0
amount = 0
for i in range(N):
  if amount + AB[A_list[i]] <= M:
    amount += AB[A_list[i]]
    cost += A_list[i]*AB[A_list[i]]
  else:
    temp = M - amount
    cost += A_list[i]*temp
    break
    
print(cost)


Fixed submission:
from sys import stdin
import heapq
hq = []  

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

hq = []
AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])
  heapq.heappush(hq, (int(temp[0]), int(temp[1])))

cost = 0
amount = 0
for i in range(N):
  temp = heapq.heappop(hq)
  if amount + temp[1] < M:
    amount += temp[1]
    cost += temp[0]*temp[1]
  else:
    temp1 = M - amount
    cost += temp[0]*temp1
    break
    
print(cost)

Buggy python submission (verdict: Runtime Error):
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])

A_list = list(AB.keys())
A_list.sort()

cost = 0
amount = 0
for i in range(N):
  if amount + AB[A_list[i]] <= M:
    amount += AB[A_list[i]]
    cost += A_list[i]*AB[A_list[i]]
  else:
    print(amount)
    temp = M - amount
    cost += A_list[i]*temp
    break
    
print(cost)

Fixed submission:
from sys import stdin
import heapq
hq = []  

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

hq = []
AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])
  heapq.heappush(hq, (int(temp[0]), int(temp[1])))

cost = 0
amount = 0
for i in range(N):
  temp = heapq.heappop(hq)
  if amount + temp[1] < M:
    amount += temp[1]
    cost += temp[0]*temp[1]
  else:
    temp1 = M - amount
    cost += temp[0]*temp1
    break
    
print(cost)
Buggy python submission (verdict: Runtime Error):
# coding=utf-8

tile = input()

cor_list = ["10"*50000, "01"*50000]

diff_1 = int("0b"+tile, 2) ^ int("0b"+cor_list[0][:len(tile)], 2)  
diff_2 = int("0b"+tile, 2) ^ int("0b"+cor_list[1][:len(tile)], 2)

score_1 = sum([int(s) for s in bin(diff_1)[2:]])
score_2 = sum([int(s) for s in bin(diff_2)[2:]])
print(min[score_1, score_2])

Fixed submission:
tile = input()

cor_list = ["10"*50000, "01"*50000]

diff_1 = int("0b"+tile, 2) ^ int("0b"+cor_list[0][:len(tile)], 2)  
diff_2 = int("0b"+tile, 2) ^ int("0b"+cor_list[1][:len(tile)], 2)

score = [0, 0]
score[0] = sum([int(s) for s in bin(diff_1)[2:]])
score[1] = sum([int(s) for s in bin(diff_2)[2:]])

print(min(score))
Buggy python submission (verdict: Time Limit Exceeded):
# AGC032 Problem-C
def special_case() :
    #Check 辺が4本出ているノードが2つあるケース
    #　　　2ノード間に4本の辺がある場合はNG
    #　　　2ノード間に2本の辺がある場合はOK (自分に戻るループがある)
    st = -1
    for i in range(0,n) :
        if check[i] == 4 :
            st = i
            break
    
    for i in edge[st] :
        p = i
        while (check[p]==2) :
            t1, t2 = edge[p]
            if t1 == st :
                p = t2
            else: 
                p = t1
        if p == st :
            return 0
    return -1

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

check = [0 for i in range(0,n)]
edge  = [[] for i in range(0,n)]
#table = [[0 for i in range (0,n)] for j in range (0,n)]
for i in range(0,m) :
    a, b = map(int,input().split())
    check[a-1] += 1
    check[b-1] += 1
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
#print (check)
#print(edge)

node4 = 0
node6 = 0
node_odd = 0
for i in range(0,n):
    if check[i] % 2 == 0:
        if check[i]==4 :
            node4 += 1
        if check[i]>=6 :
            node6 +=1
    else:
        node_odd += 1

if (node_odd != 0) :
    print ("No")
else :
    if ((node4 >= 3) or (node6 >=1)) :
        print ("Yes")
    elif (node4 == 2) :
        if special_case() == 0 :
            print ("Yes")
        else :
            print ("No")
    else :
        print ("No")


Fixed submission:
# AGC032 Problem-C
def special_case() :
    #Check 辺が4本出ているノードが2つあるケース
    #　　　2ノード間に4本の辺がある場合はNG
    #　　　2ノード間に2本の辺がある場合はOK (自分に戻るループがある)
    st = -1
    for i in range(0,n) :
        if check[i] == 4 :
            st = i
            break
    
    for i in edge[st] :
        p0 = st
        p1 = i
        while (check[p1]==2) :
            t1, t2 = edge[p1]
            if t1 == p0 :
                p0 = p1
                p1 = t2
            else: 
                p0 = p1
                p1 = t1
        if p1 == st :
            return 0
    return -1

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

check = [0 for i in range(0,n)]
edge  = [[] for i in range(0,n)]
#table = [[0 for i in range (0,n)] for j in range (0,n)]
for i in range(0,m) :
    a, b = map(int,input().split())
    check[a-1] += 1
    check[b-1] += 1
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
#print (check)
#print(edge)

node4 = 0
node6 = 0
node_odd = 0
for i in range(0,n):
    if check[i] % 2 == 0:
        if check[i]==4 :
            node4 += 1
        if check[i]>=6 :
            node6 +=1
    else:
        node_odd += 1

if (node_odd != 0) :
    print ("No")
else :
    if ((node4 >= 3) or (node6 >=1)) :
        print ("Yes")
    elif (node4 == 2) :
        if special_case() == 0 :
            print ("Yes")
        else :
            print ("No")
    else :
        print ("No")
Buggy python submission (verdict: Runtime Error):
n = input()

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

l.sort(reverse=True)

total = l.sum()

if (total - 2 * l[0] > 0 ) :
  print("yes")
else:
  print("no")
  

Fixed submission:
n = input()
 
l = list(map(int, input().split()))
 
l.sort(reverse=True)
 
total = sum(l)
 
if (total - 2 * l[0] > 0 ) :
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
def 通るかな():
    X,Y,Z,K = [int(_) for _ in input().split()]
    #aA = sorted((int(_) for _ in input().split()),reverse=True)
    #aB = sorted((int(_) for _ in input().split()),reverse=True)
    #aC = sorted((int(_) for _ in input().split()),reverse=True)
    aA = [int(_) for _ in input().split()]
    aB = [int(_) for _ in input().split()]
    aC = [int(_) for _ in input().split()]

    aD =[0] *(X*Y)
    i=0
    for a in aA:
        for b in aB:
            aD[i]=a+b
            i+=1
    aD.sort(reverse=True)
    if 3000 < X*Y :
        aD=aD[:3000]
    iL = len(aD)
    aE = [0] * (iL*Z)
    i = 0
    for d in aD:
        for c in aC:
            aE[i] = d+c
            i+=1
    aE.sort(reverse=True)
    print(*aE[:K],sep="\n")
通るかな()


Fixed submission:
def 解法3優先度付きキュー():
    import heapq
    X,Y,Z,K = [int(_) for _ in input().split()]
    aA = sorted((int(_) for _ in input().split()),reverse=True)
    aB = sorted((int(_) for _ in input().split()),reverse=True)
    aC = sorted((int(_) for _ in input().split()),reverse=True)
    dS=set()
    aAns = [0]*K
    aQ = []
    def fPush(aQ,i,j,k):
        if X <= i :
            i = X-1
        if Y <= j:
            j = Y-1
        if Z <= k:
            k = Z-1
        if (i,j,k) not in dS:
            heapq.heappush(aQ,(-1*(aA[i]+aB[j]+aC[k]),i,j,k))
            dS.add((i,j,k))
    def fPop(aQ):
        iD,i,j,k = heapq.heappop(aQ)
        return (-1*iD,i,j,k)
    fPush(aQ,0,0,0)
    for iU in range(K):
        aAns[iU],i,j,k = fPop(aQ)
        fPush(aQ,i+1,j,k)
        fPush(aQ,i,j+1,k)
        fPush(aQ,i,j,k+1)

    print(*aAns,sep="\n")

解法3優先度付きキュー()