Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    quantity, A, B = map(int, input().split())
    l = list(input())
    ans = []
    
    for i in range(quantity):
        if l[i] == 'a' and ans.count('Yes') < (A + B):
            ans.append('Yes')
            continue
        elif l[i] == 'b' and ans.count('Yes') < (A + B):
            check = 0
            for x in range(len(ans)):
                if ans[x] == 'Yes':
                    check = check + 1
            if check <= B:
                ans.append('Yes')
                continue
        ans.append('No')
    
    for y in ans:
        print(y)

main()

Fixed submission:
def main():
    quantity, A, B = map(int, input().split())
    l = list(input())
    yes = 0
    abroad = 0

    for i in range(quantity):
        if l[i] == 'a':
            if yes < (A + B):
                print('Yes')
                yes = yes + 1
            else:
                print('No')
        
        if l[i] == 'b':
            abroad = abroad + 1
            if yes < (A + B) and abroad <= B:
                print('Yes')
                yes = yes + 1

            else:
                print('No')
        
        if l[i] == 'c':
            print('No')

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    quantity, A, B = map(int, input().split())
    l = list(input())
    ans = []
    
    for i in range(quantity):
        if l[i] == 'a' and ans.count('Yes') < (A + B):
            ans.append('Yes')
            continue
        elif l[i] == 'b' and ans.count('Yes') < (A + B):
            check = 0
            for x in range(len(ans)):
                if ans[x] == 'Yes':
                    check = check + 1
            if check <= B:
                ans.append('Yes')
                continue
        ans.append('No')
    
    for y in ans:
        print(y)

main()

Fixed submission:
def main():
    quantity, A, B = map(int, input().split())
    l = list(input())
    yes = 0
    abroad = 0

    for i in range(quantity):
        if l[i] == 'a':
            if yes < (A + B):
                print('Yes')
                yes = yes + 1
            else:
                print('No')
        
        if l[i] == 'b':
            abroad = abroad + 1
            if yes < (A + B) and abroad <= B:
                print('Yes')
                yes = yes + 1

            else:
                print('No')
        
        if l[i] == 'c':
            print('No')

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

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

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

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

print(ans)


Fixed submission:
N = int(input())

A = list(map(int, input().split()))
S = sum(A)
ans = 0
for i in range(N):
    S -= A[i]
    ans += A[i] * S
    

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int, input().split()))
sum = 0
for i in range(N-1):
    for m in range(i+1, N):
        sum += A[i]*A[m]
        if sum > 1000000007:
            sum = sum%1000000007


print(sum)

Fixed submission:
N = int(input())

A = list(map(int, input().split()))
S = sum(A)
ans = 0
for i in range(N):
    S -= A[i]
    ans += A[i] * S
    

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int, input().split()))
sum = 0
for i in range(N-1):
    for m in range(i+1, N):
        sum += A[i]*A[m]

if sum < 1000000007:
    print(sum)
else:
    print(sum%1000000007)

Fixed submission:
N = int(input())

A = list(map(int, input().split()))
S = sum(A)
ans = 0
for i in range(N):
    S -= A[i]
    ans += A[i] * S
    

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int, input().split()))
sum = 0
for i in range(N-1):
    for m in range(i+1, N):
        sum += A[i]*A[m]

if sum < 1000000007:
    print(sum)
else:
    print(int(sum%(1e9 + 7)))

Fixed submission:
N = int(input())

A = list(map(int, input().split()))
S = sum(A)
ans = 0
for i in range(N):
    S -= A[i]
    ans += A[i] * S
    

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int, input().split()))
sum = 0
for i in range(N-1):
    for m in range(i+1, N):
        sum += A[i]*A[m]

print(int(sum%(1e9 + 7)))

Fixed submission:
N = int(input())

A = list(map(int, input().split()))
S = sum(A)
ans = 0
for i in range(N):
    S -= A[i]
    ans += A[i] * S
    

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

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = input().split()
np_a=np.array(a, dtype=int)

ans=np.zeros(n, dtype=int)

for i in range(0,n):
  loop=list(range(0,n))
  loop.pop(i)
  for j in loop:
    if (j == loop[0]): 
      atai=np_a[j]
    else:
      atai=atai ^ np_a[j]
  ans[i]=atai
  
print (*ans)

Fixed submission:
import numpy as np

n = int(input())
a = input().split()
np_a=np.array(a, dtype=int)

ans=np.zeros(n, dtype=int)

all=np_a[0]
for i in range(1,n):
  all=all ^ np_a[i]
  

for i in range(0,n):
  ans[i]=all ^ np_a[i]
  
print (*ans)
Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if (b >= a):
  aa=a+v*t
  bb=b+w*t
  if (bb-aa >=0):
    print ('NO')
  else:
    print ('YES')
else:
  aa=a-v*t
  bb=b-w*t
  if (bb-aa <=0):
    print ('NO')
  else:
    print ('YES')

Fixed submission:
s = input()
print (s[0:3])
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np

n, m, x= map(int, input().split())
a = [input().split() for l in range(n)]
npa=np.array(a, dtype=int)

hon=-1
for i in range(1,n+1):
  base = list(itertools.combinations(range(0,n),i))
#  print (base)
  
  for j in base:
    totalv=np.sum(npa[j,], axis=0)
#    print (totalv, min(totalv[1:-1]))
    
    if (min(totalv[1:-1]) >= x):
      if (hon == -1): hon=totalv[0]
      if (hon >= totalv[0]): hon=totalv[0]
#      print (hon)
      
print (hon)

Fixed submission:
import itertools
import numpy as np

n, m, x= map(int, input().split())
a = [input().split() for l in range(n)]
npa=np.array(a, dtype=int)

hon=-1
for i in range(1,n+1):
  base = list(itertools.combinations(range(0,n),i))
#  print (base)
  
  for j in base:
    totalv=np.sum(npa[j,], axis=0)
#    print (totalv, min(totalv[1:-1]))
    
    if (min(totalv[1:m+1]) >= x):
      if (hon == -1): hon=totalv[0]
      if (hon >= totalv[0]): hon=totalv[0]
#      print (hon)
      
print (hon)

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

n, m, x= map(int, input().split())
a = [input().split() for l in range(n)]
npa=np.array(a, dtype=int)

#print (npa)

hon=-1
for i in range(1,n+1):
  base = list(itertools.combinations(range(0,n),i))
#  print (base)
  
  for j in base:
    totalv=np.sum(npa[j,], axis=0)
#    print (totalv, min(totalv[1:-1]))
    
    if (min(totalv[1:-1]) >= x):
      if (hon < 0): hon=totalv[0]
      if (hon >= totalv[0]): hon=totalv[0]
#      print (hon)
      
print (hon)

Fixed submission:
import itertools
import numpy as np

n, m, x= map(int, input().split())
a = [input().split() for l in range(n)]
npa=np.array(a, dtype=int)

hon=-1
for i in range(1,n+1):
  base = list(itertools.combinations(range(0,n),i))
#  print (base)
  
  for j in base:
    totalv=np.sum(npa[j,], axis=0)
#    print (totalv, min(totalv[1:-1]))
    
    if (min(totalv[1:m+1]) >= x):
      if (hon == -1): hon=totalv[0]
      if (hon >= totalv[0]): hon=totalv[0]
#      print (hon)
      
print (hon)
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())


if (n >=b):
  x=int(n/b)*b-1
  print (int(a*x/b)-a*int(x/b))
else:
  xmax=0
  for x in range(1,n+1):
    atai=int(a*x/b)-a*int(x/b)
    if (atai >= xmax): xmax=atai
  print (xmax)

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

for i in range(1,1000):
  kk=k*i
  if (kk >= a and kk <= b):
    print ('OK')
    sys.exit()
  if (kk > b):
    print ('NG')
    sys.exit()
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())

if (n >=b):
  x=math.floor(n/b)*b-1
  print (math.floor(a*x/b)-a*math.floor(x/b))
#  print (int(a*(int(n/b)-1./b))-a*int(int(n/b)-1./b))
else:
#  xmax=0
#  for x in range(1,n+1):
#    atai=int(a*x/b)-a*int(x/b)
#    if (atai >= xmax): xmax=atai
#  print (xmax)
  print (math.floor(a*n/b)-a*math.floor(n/b))
  


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

if (b != 1):
  if (n >=b):
    x=math.floor(n/b)*b-1
    print (math.floor(a*x/b)-a*math.floor(x/b))
  else:
    print (math.floor(a*n/b)-a*math.floor(n/b))
else:
  print (0)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

play=n-sum(a)
if play < 0: play=-1
 

print (play)

Fixed submission:
import numpy as np
i = int(input())
pi = np.pi
print (2*pi*i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(0,n):
  print (a.count(i+1))
  a= [a[j] for j in range(0, len(a)) if a[j] != i+1]

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

#for i in range(0,n):
#  print (a.count(i+1))
#  a= [a[j] for j in range(0, len(a)) if a[j] != i+1]
#
#  print (a)

kekka= [0] * (n+1)
for i in range(0,n-1):
  kekka[a[i]]+=1

for i in range(1,n+1):
  print (kekka[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(0,n):
  aa=a.count(i+1)
  print (aa)

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

#for i in range(0,n):
#  print (a.count(i+1))
#  a= [a[j] for j in range(0, len(a)) if a[j] != i+1]
#
#  print (a)

kekka= [0] * (n+1)
for i in range(0,n-1):
  kekka[a[i]]+=1

for i in range(1,n+1):
  print (kekka[i])
Buggy python submission (verdict: Runtime Error):
i = input()
i1=int(i/100)
i2=int((i-i1*100)/10)
i3=i-i1*100-i2*10

if (i1 == 7 or i2 == 7 or i3 == 7):
    print ('Yes')
else:
    print ('No')


Fixed submission:
i = input()

if (i[0] == '7' or i[1] == '7' or i[2] == '7'):
    print ('Yes')
else:
    print ('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
n = int(input())
sum=0
for a in range(1, n+1):
    for b in range(1, n+1):
        for c in range(1, n+1):
            sum=sum+gcd_list([a,b,c])
print(sum)

Fixed submission:
import math
#from functools import reduce

#def gcd(*numbers):
#    return reduce(math.gcd, numbers)

#def gcd_list(numbers):
#    return reduce(math.gcd, numbers)
  
n = int(input())
sum=0
for a in range(1, n+1):
    for b in range(1, n+1):
        ab=math.gcd(a,b)
        for c in range(1, n+1):
#            print(list(set([a,b,c])))
#            abc=list(set([a,b,c]))
#            sum=sum+gcd_list(abc)
            abc=math.gcd(ab,c)
            sum=sum+abc
print(sum)
Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))
HH = i[0]
WW = i[1]
atai = HH*WW
amari=divmod(atai,2)
ans = int(atai/2) + amari[1]
print (ans)

Fixed submission:
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = input()
ki=int(k)-1
print(array[ki])

Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))
HH = i[0]
WW = i[1]
atai = HH*WW
#ans = int(atai/2) + (atai % 2)
amari=divmod(atai,2)
ans = int(atai/2) + amari[1]
print (ans)

Fixed submission:
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = input()
ki=int(k)-1
print(array[ki])
Buggy python submission (verdict: Runtime Error):
from sys import stdin


def f(x, k, d):
    if k == 0:
        return x

    if x == 0:
        if k % 2 == 0:
            return 0
        elif k % 2 == 1:
            return d
    elif x > 0:
        tmp = abs(x) / d
        if d * tmp > d * k:
            return x - d * k
        else:
            return f((x-d*tmp), (k-tmp), d)
    elif x < 0:
        tmp = abs(x) / d
        if d * tmp > d * k:
            return x + d * k
        else:
            return f((x+d*tmp), (k-tmp), d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(abs(f(X, K, D)))


Fixed submission:
from sys import stdin


def f(x, k, d):
    if k == 0:
        return x

    absX = abs(x)
    tmp = absX // d

    if tmp > k:
        return absX - d * k
    else:
        absX = absX - d * tmp
        k = k - tmp
        if k % 2 == 0:
            return absX
        else:
            return abs(absX - d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(f(X, K, D))

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


@lru_cache(maxsize=100)
def f(x, k, d):
    if k == 0:
        return x

    if x == 0:
        if k % 2 == 0:
            return 0
        if k % 2 == 1:
            return d
    if x > 0:
        return f(x-d, k-1, d)
    if x < 0:
        return f(x+d, k-1, d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(abs(f(X, K, D)))


Fixed submission:
from sys import stdin


def f(x, k, d):
    if k == 0:
        return x

    absX = abs(x)
    tmp = absX // d

    if tmp > k:
        return absX - d * k
    else:
        absX = absX - d * tmp
        k = k - tmp
        if k % 2 == 0:
            return absX
        else:
            return abs(absX - d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(f(X, K, D))

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


@lru_cache(maxsize=1000)
def f(x, k, d):
    if k == 0:
        return x

    if x == 0:
        if k % 2 == 0:
            return 0
        if k % 2 == 1:
            return d
    if x > 0:
        return f(x-d, k-1, d)
    if x < 0:
        return f(x+d, k-1, d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(abs(f(X, K, D)))


Fixed submission:
from sys import stdin


def f(x, k, d):
    if k == 0:
        return x

    absX = abs(x)
    tmp = absX // d

    if tmp > k:
        return absX - d * k
    else:
        absX = absX - d * tmp
        k = k - tmp
        if k % 2 == 0:
            return absX
        else:
            return abs(absX - d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(f(X, K, D))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007
    r = 0
    while True:
        r += 1
        n = N - K + 1

        if n - r < 0:
            break

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp)



Fixed submission:
from sys import stdin
from collections import Counter

S = stdin.readline().rstrip()
cnt = Counter(S)

if len(cnt.keys()) == 2 and set(cnt.values()) == {2}:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from math import factorial
 
if __name__ == '__main__':
 
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
 
    tmp = 1000000007
    r = 0
    for r in range(K)
        r += 1
        n = N - K + 1
 
        if n - r < 0 or K - r < 0:
            print(0)
            continue
 
        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))
 
        print((ret * ret2) % tmp)

Fixed submission:
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007
    r = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        if n - r < 0 or K - r < 0:
            print(0)
            continue

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp)

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

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007

    for r in range(K):
        r += 1
        n = N - K + 1

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp )


Fixed submission:
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007
    r = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        if n - r < 0 or K - r < 0:
            print(0)
            continue

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp)

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

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 100000007
    ret = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print(ret * ret2)

Fixed submission:
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007
    r = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        if n - r < 0 or K - r < 0:
            print(0)
            continue

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

if __name__ == '__main__':
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    a = [int(x) for x in stdin.readline().rstrip().split()]

    # 総組み合わせ数(nCr + N)の計算 n=N, r=2
    # N は数字を一つだけ選ぶパターン
    max = (factorial(N) // factorial(2) // factorial(N - 2)) + N

    # 条件を満たさないパターンを総当たりで計算
    count = 0
    for i in range(N):
        for j in range(N):
            if i > j:
                continue

            tmp = sum(a[i:j+1])

            if tmp < K:
                count = count + 1
            else:
                break

    print(max - count)


Fixed submission:
from sys import stdin

X, A = [int(x) for x in stdin.readline().rstrip().split()]

if X < A:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np

N, M = [int(x) for x in stdin.readline().rstrip().split()]

# カード。すべて通過できるなら１
cards = np.ones(N)

for i in range(M):
    L, R = [int(x) for x in stdin.readline().rstrip().split()]

    # [【Python】スライス操作についてまとめ \- Qiita](https://qiita.com/tanuk1647/items/276d2be36f5abb8ea52e)
    cards[:L-1] = 0
    cards[R:] = 0

print(int(np.sum(cards)))

Fixed submission:
from sys import stdin
import numpy as np

N, M = [int(x) for x in stdin.readline().rstrip().split()]

#[競プロ等におけるpython3の標準入力 \- Qiita](https://qiita.com/zenrshon/items/c4f3849552348b3dbe67)
L = []
R = []
for i in range(M):
    l,r=[int(i) for i in input().split()]
    L.append(l)
    R.append(r)

tmp = int(min(R) - max(L))
          
if tmp < 0:
    print(0)
else:
    print(tmp + 1)
Buggy python submission (verdict: Time Limit Exceeded):
# from itertools import combinations
n=int(input())
a=[int(i) for i in input().split()]
pro=0
for i in range(n-1):
    for j in range(i+1,n):
        pro+=a[i]*a[j]
print(pro%(10**9+7))

Fixed submission:
# from itertools import combinations
def Sum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
    array_sum_square = array_sum * array_sum 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -individual_square_sum) // 2
n=int(input())
a=[int(i) for i in input().split()]
print(Sum(a,n)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
x = int(input())

if x >= 1800:
    ans = 1
elif x >= 1600:
    ans = 2
elif x >= 1400:
    ans = 3
elif x >= 1200:
    ans = 4
elif x >= 1000:
    ans = 5
elif x >= 800:
    ans = 6
elif x >= 600:
    ans = 7
else:
    x = 8

print(str(int(ans)))

Fixed submission:
x = int(input())

if x >= 1800:
    ans = 1
elif x >= 1600:
    ans = 2
elif x >= 1400:
    ans = 3
elif x >= 1200:
    ans = 4
elif x >= 1000:
    ans = 5
elif x >= 800:
    ans = 6
elif x >= 600:
    ans = 7
else:
    ans = 8

print(str(int(ans)))
Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())
hk = [[0, i] for i in range(H + 1)]
wk = [[0, j] for j in range(W + 1)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    hk[h][0] += 1
    wk[w][0] += 1
    s.add((h, w))
hk.sort(reverse=True)
wk.sort(reverse=True)
colmax = wk[0][0]
ans = 0
for lowacc, i in hk:
    if lowacc + colmax < ans:
        break
    for colacc, j in wk:
        ans = max(ans, lowacc + colacc - ((i, j) in s))
        if lowacc + colacc < ans:
            break
print(ans)


Fixed submission:
H, W, M = map(int, input().split())
hk = [[0, i] for i in range(H + 1)]
wk = [[0, j] for j in range(W + 1)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    hk[h][0] += 1
    wk[w][0] += 1
    s.add((h, w))
hk.sort(reverse=True)
wk.sort(reverse=True)
colmax = wk[0][0]
ans = 0
for lowacc, i in hk:
    if lowacc + colmax <= ans:
        break
    for colacc, j in wk:
        if lowacc + colacc <= ans:
            break
        else:
            ans = max(ans, lowacc + colacc - ((i, j) in s))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heapify, heappop, heappush
import math
N, K = map(int, input().split())
aaa = [(-a, 1, -a) for a in map(float, input().split())]
heapify(aaa)
for _ in range(K):
    _, cnt, L = heappop(aaa)
    cnt += 1
    heappush(aaa, (L / cnt, cnt, L))
print(math.ceil(-aaa[0][0]))


Fixed submission:
import numpy as np
import math
N, K = map(int, input().split())
aaa = np.array(list(map(float, input().split())), dtype='f8')
l = 0
r = 10 ** 9
while r != l:
    mid = (r + l) // 2
    bbb = aaa / mid
    bbb -= 1
    bbb = np.ceil(bbb)
    if bbb.sum() <= K:
        r = mid
    else:
        l = mid + 1
print(l)
Buggy python submission (verdict: Runtime Error):
from collections import deque
N = int(input())
A = sorted(map(int, input().split()))
q = deque()
a = a.pop()
b = a.pop()
ans = a + b
q.append((a,b))
q.append((a,b))
while A:
    c = A.pop()
    a,b = q.popleft()
    ans += min(a,b)
    q.append((a,c))
    q.append((c,b))
print(ans)


Fixed submission:
N = int(input())
A = sorted(map(int, input().split()))
ans = 0
for k in range(1, N):
    ans += A[N - 1 - k // 2]
print(ans)