Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
  index = A.index(max(A))
  A[index] = A[index]//2

print(sum(A))


Fixed submission:
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
N,M = map(int, input().split())
A = []
for a in input().split():
  heappush(A,-int(a))

for _ in range(M):
  tmp = heappop(A)
  heappush(A, -(-tmp//2))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
  index = A.index(max(A))
  A[index] = A[index]//2

print(sum(A))


Fixed submission:
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
N,M = map(int, input().split())
A = []
for a in input().split():
  heappush(A,-int(a))

for _ in range(M):
  tmp = heappop(A)
  heappush(A, -(-tmp//2))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
  index = A.index(max(A))
  A[index] = round(A[index]//2)

print(sum(A))


Fixed submission:
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
N,M = map(int, input().split())
A = []
for a in input().split():
  heappush(A,-int(a))

for _ in range(M):
  tmp = heappop(A)
  heappush(A, -(-tmp//2))

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

if A => 13:
  print(B)
elif A => 6:
  print(B/2)
else:
  print(0)

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

if A >= 13:
  print(B)
elif 12 >= A >= 6:
  print(int(B/2))
elif 5 >= A >= 0:
  print(0)
Buggy python submission (verdict: Runtime Error):
N , K = map(int, input().split())
s = input()

print(s[:K-1]+s[K].lower()+s[K:])


Fixed submission:
N , K = map(int, input().split())
s = input()
o = []
for i in range(N):
  if i == K - 1:
    o.append(s[i].lower())
  else:
    o.append(s[i])

print("".join(o))
Buggy python submission (verdict: Runtime Error):
N = int(input())
F = []
P = []
Pre = []
for i in range(N):
  F.append(list(map(int, input().split())))
for i in range(N):
  P.append(list(map(int, input().split())))

for loop in range(1,1024):
  rieki = 0
  Fnum = 0
  f = str(format(loop,"b")).rjust(10,"0") #自店の開店時間帯
  for i in range(N): # 全店舗に対し利益計算
    for j in range(10): # 店舗iと同時に営業する時間帯の数
      Fnum = Fnum + F[i][j] * int(f[j])
    #print("時間帯:{}".format(Fnum))
    rieki = rieki + P[i][Fnum] # P行列参照
  #print("rieki is {}".format(rieki))
  Pre.append(rieki) 
print(max(Pre))
  

Fixed submission:
N = int(input())
F = []
P = []
Pre = []
for i in range(N):
  F.append(list(map(int, input().split())))
for i in range(N):
  P.append(list(map(int, input().split())))

for loop in range(1,1024):
  rieki = 0
  f = str(format(loop,"b")).rjust(10,"0") #自店の開店時間帯
  for i in range(N): # 全店舗に対し利益計算
    Fnum = 0
    for j in range(10): # 店舗iと同時に営業する時間帯の数
      Fnum = Fnum + F[i][j] * int(f[j])
    #print("loop:{},i:{},j:{}".format(loop,i,j))
    rieki = rieki + P[i][Fnum] # P行列参照
  Pre.append(rieki) 
print(max(Pre))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    a = A.copy()
    del a[i]
    print(max(a))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
a = sorted(A.copy())
a1 = a[len(A)-1]
a2 = a[len(A)-2]

for i in A:
    if i == a1:
        print(a2)
    else:
        print(a1)

Buggy python submission (verdict: Runtime Error):
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    a = A.copy()
    del a[i]
    print(max(a))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
a = sorted(A.copy())
a1 = a[len(A)-1]
a2 = a[len(A)-2]

for i in A:
    if i == a1:
        print(a2)
    else:
        print(a1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    a = A.copy()
    del a[i]
    print(max(a))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
a = sorted(A.copy())
a1 = a[len(A)-1]
a2 = a[len(A)-2]

for i in A:
    if i == a1:
        print(a2)
    else:
        print(a1)
Buggy python submission (verdict: Runtime Error):
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
count = 0
tmp = []

for i in range(N):
    r1 = X[i]
    for j in range(N):
        t = str(i)+str(j)
        if i == j or t in tmp or str(j)+str(i) in tmp:
            continue

        r2 = X[j]
        ls = [(r1[j] - r2[j])**2 for j in range(D)]
        res = math.sqrt(sum(ls))

        if res % 1 == 0:
            count += 1
        tmp.append(t)

print(count)

Fixed submission:
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
count = 0
tmp = []

for i in range(N):
    r1 = X[i]
    for j in range(N):
        t = str(i)+str(j)
        if i == j or t in tmp or str(j)+str(i) in tmp:
            continue

        r2 = X[j]
        ls = [(r1[j] - r2[j])**2 for j in range(D)]
        res = math.sqrt(sum(ls))

        if res % 1 == 0:
            count += 1
        tmp.append(t)

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
mod = 2019  # 素数ではない (素数は 673)
r = min(r, l+mod*2)

res = mod
for i in range(l, r):
    for j in range(r, l-1, -1):
        if i == j:
            break
        tmp = i*j % mod
        if tmp < res:
            res = tmp

print(res)

Fixed submission:
l, r = map(int, input().split())
mod = 2019
r = min(r, l+673)

res = mod
for i in range(l, r):
    for j in range(r, l-1, -1):
        if i == j:
            break
        tmp = i*j % mod
        if tmp < res:
            res = tmp

print(res)
Buggy python submission (verdict: Runtime Error):
import fractions

def f(x, c, d):
    lcm_num = c*d / fractions.gcd(c, d)
    return x - x//c - x//d + x//lcm_num

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

print(f(b) - f(a-1))

Fixed submission:
import fractions

def f(x, c, d):
    lcm_num = c*d // fractions.gcd(c, d)
    return x - x//c - x//d + x//lcm_num

a, b, c, d = map(int, input().split())
print(int(f(b, c, d) - f(a-1, c, d)))

Buggy python submission (verdict: Runtime Error):
import math

def f(x, c, d):
    lcm_num = c*d / math.gcd(c, d)
    return x - x//c - x//d + x//lcm_num

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

print(f(b) - f(a-1))

Fixed submission:
import fractions

def f(x, c, d):
    lcm_num = c*d // fractions.gcd(c, d)
    return x - x//c - x//d + x//lcm_num

a, b, c, d = map(int, input().split())
print(int(f(b, c, d) - f(a-1, c, d)))

Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
lcm_num = c*d / math.gcd(c, d)

def f(x):
    return x - x//c - x//d + x//lcm_num

print(f(b) - f(a-1))

Fixed submission:
import fractions

def f(x, c, d):
    lcm_num = c*d // fractions.gcd(c, d)
    return x - x//c - x//d + x//lcm_num

a, b, c, d = map(int, input().split())
print(int(f(b, c, d) - f(a-1, c, d)))

Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
lcm_num = c*d / math.gcd(c, d)

def f(x):
    return x - x//c - x//d + x//lcm_num

print(f(b) - f(a-1))

Fixed submission:
import fractions

def f(x, c, d):
    lcm_num = c*d // fractions.gcd(c, d)
    return x - x//c - x//d + x//lcm_num

a, b, c, d = map(int, input().split())
print(int(f(b, c, d) - f(a-1, c, d)))
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
count = 0

for i in range(N+1):
    if R*i > N:
        break
    for j in range(N+1):
        if R*i + G*j > N:
            break
        for k in range(N+1):
            if R*i + G*j + B*k > N:
                break
            if R*i + G*j + B*k == N:
                count += 1

print(count)

Fixed submission:
R, G, B, N = map(int, input().split())
count = 0

for i in range(N+1):
    r = R*i
    for j in range(N+1):
        g = G*j
        k = int((N-r-g)/B)
        if 0 <= k and r+g+(B*k) == N:
            count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

N = int(input())
# ボトルネックとなる制限人数を取得
mini = min([int(input()) for _ in range(5)])
# 都市2 以降で要する合計移動時間で初期化
time = 4

while N > 0:
    N -= mini
    time += 1

print(time)

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

N = int(input())
# ボトルネックとなる制限人数を取得
mini = min([int(input()) for _ in range(5)])

print(math.ceil(N/mini)+4)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
rules = [int(input()) for _ in range(5)]
mini = min(rules)

# 都市2 以降の合計移動時間で初期化
time = 4

while N > 0:
    N -= mini
    time += 1

print(time)

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

N = int(input())
# ボトルネックとなる制限人数を取得
mini = min([int(input()) for _ in range(5)])

print(math.ceil(N/mini)+4)
Buggy python submission (verdict: Runtime Error):
b = input()
if b == 'A':
    print(T)
elif b == 'T':
    print(A)
elif b == 'C':
    print(G)
else:
    print(C)


Fixed submission:
b = input()
if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
else:
    print('C')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
sums = sum(A)/N
avg = round(sums)
avg2 = avg-1 if avg == math.ceil(sums) else avg+1

result = 0
for i in range(N):
    if A[i] == avg:
        result = i
        break
    if A[i] == avg2:
        result = i
print(result)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
sums = sum(A)
sml = [abs(N*A[i]-sums) for i in range(N)]

tmp = 100
result = 0
for i, n in enumerate(sml):
    if tmp > n:
        result = i
        tmp = n

print(result)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

buckets = {}
for i in A:
    if i in buckets:
        buckets[i] += 1
    else:
        buckets[i] = 1

kinds = sorted(buckets.values())
if K < len(kinds):
    mini = 0
    for i in range(len(kinds)):
        mini += kinds.pop(i)
        if len(kinds) <= K:
            break
    print(mini)
else:
    print(0)

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

buckets = {}
for i in A:
    if i in buckets:
        buckets[i] += 1
    else:
        buckets[i] = 1

kinds = sorted(buckets.values())
count = len(kinds)
if K < count:
    mini = 0
    for i in kinds:
        mini += i
        count -= 1
        if count <= K:
            break
    print(mini)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
input=sys.stdin.readline
S = input()
size = len(S)
print(S[:1] + str(len(S[2:size])) + S[size-1:])

Fixed submission:
S = input()
size = len(S)
print(S[:1] + str(len(S[2:size])) + S[size-1:])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0

tmp = A[0]
bf = 1 if tmp < A[1] else 2 if tmp > A[1] else 0
af = 0  # {1: '+', 2: '-'}
for i in range(1, N):
    if tmp < A[i]:
        af = 1
    elif tmp > A[i]:
        af = 2

    tmp = A[i]
    if af != bf:
        count += 1
        if i+1 < N:
            af = 1 if tmp < A[i+1] else 2 if tmp > A[i+1] else 0
        else:
            break
    bf = af

print(count if bf == 0 else count+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 1

conti_flg = 0  # {-1: '-', 0: '=', 1: '+'}
fst = A[0]
for i in A:
    snd = i
    if fst > snd:
        conti_flg = -1 if conti_flg <= 0 else 2
    elif fst < snd:
        conti_flg = 1 if conti_flg >= 0 else 2

    if conti_flg == 2:
        count += 1
        conti_flg = 0
    fst = snd

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 1

tmp = A[0]
bf = 1 if tmp < A[1] else 2 if tmp > A[1] else 0
af = 0  # {1: '+', 2: '-'}
for i in range(1, N):
    if tmp < A[i]:
        af = 1
    elif tmp > A[i]:
        af = 2

    tmp = A[i]
    if af != bf:
        count += 1
        if i+1 < N:
            af = 1 if tmp < A[i+1] else 2 if tmp > A[i+1] else 0
    bf = af

print(count)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 1

conti_flg = 0  # {-1: '-', 0: '=', 1: '+'}
fst = A[0]
for i in A:
    snd = i
    if fst > snd:
        conti_flg = -1 if conti_flg <= 0 else 2
    elif fst < snd:
        conti_flg = 1 if conti_flg >= 0 else 2

    if conti_flg == 2:
        count += 1
        conti_flg = 0
    fst = snd

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

for i in range(math.ceil(math.sqrt(N)), 0, -1):
    if N % i == 0:
        print(len(str(N//i)))
        break

Fixed submission:
import math
N = int(input())

for i in range(int(math.sqrt(N)), 0, -1):
    if N % i == 0:
        print(len(str(N//i)))
        break
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env pypy3

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

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


N, K = input_ints()

print(N-K+1)


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

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

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


N, K = input_ints()

print(N-K+1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env pypy3

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

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


R, G, B, N = input_ints()

cnt = 0
for r in range(N // R + 1):
    for g in range(N // G + 1):
        rest = N - r * R - g * G
        if rest >= 0 and rest % B == 0:
            cnt += 1

print(cnt)


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

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

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


R, G, B, N = input_ints()

cnt = 0
for r in range(N // R + 1):
    for g in range(N // G + 1):
        rest = N - r * R - g * G
        if rest < 0:
            break
        if rest % B == 0:
            cnt += 1

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

import math, itertools, operator
from math import *
from math import factorial as fact
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd
#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

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

N = input_ints()
H = input_ints()

curmax = -inf
cnt = 0
for Hi in H:
    if curmax <= Hi:
        cnt += 1
        curmax = Hi
print(cnt)


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

import math, itertools, operator
from math import *
from math import factorial as fact
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd
#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

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

N = input_ints()
H = input_ints()

curmax = -inf
cnt = 0
for Hi in H:
    if curmax <= Hi:
        cnt += 1
        curmax = Hi
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]                                                                             │
                                                                                                                     │
likes = [0 for x in range(M)]                                                                                        │
                                                                                                                     │
for n in range(N):                                                                                                   │
    s = [int(x) for x in input().split()]                                                                            │
    K = s[0]                                                                                                         │
    for k in range(K):                                                                                               │
        likes[s[1+k] - 1] += 1                                                                                       │
                                                                                                                     │
print(likes.count(N))

Fixed submission:
N, M = [int(x) for x in input().split()]

likes = [0 for x in range(M)]

for n in range(N):
    s = [int(x) for x in input().split()]
    K = s[0]
    for k in range(K):
        likes[s[1+k] - 1] += 1

print(likes.count(N))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    print(sum(range(n)))


main()


Fixed submission:
def main():
    n = int(input())
    print((n - 1) * n // 2)


main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import fractions

N, M = map(int, input().split())
a_list = list(set(map(int, input().split())))

a = [int(i/2) for i in a_list]
ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

if ans <= M:
    b = M // ans

    if b % 2 == 1:
        print(b // 2 + 1)
    else:
        print(b // 2)
else:
    print(0)


Fixed submission:
# -*- coding: utf-8 -*-

a = list(map(int, input().split()))
print('Yes') if (500 * a[0] >= a[1]) else print('No')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

s = input()
t = input()

s_list = list(s)
t_list = list(t)

import itertools

flag = False

for i in itertools.permutations(s_list):
    s_new = ''.join(i)
    for n in itertools.permutations(t_list):
        t_new = ''.join(n)

        if s_new < t_new:
            flag = True
if flag:
    print('Yes')
else:
    print('No')


Fixed submission:
# -*- coding: utf-8 -*-

import math

a, b = map(int, input().split())

print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input.split())

res='bust'
if a+b+c<=21:
  res='win'

print(res)

Fixed submission:
a,b,c=map(int,input().split())
 
res='bust'
if a+b+c<=21:
  res='win'
 
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
x=list(int(input()) for _ in range(q))

import numpy as np

p=np.array([k]*n)

for i in range(q):
	p=p-1
	p[x[i]-1]+=1
    
for i in range(n):
	if p[i]<=0:
		print('No')
	else:
		print('Yes')

Fixed submission:
n,k,q=map(int,input().split())
x=list(int(input()) for _ in range(q))

p=[0]*n

for i in range(q):
	p[x[i]-1]+=1
    
for i in range(n):
	if k-q+p[i]<=0:
		print('No')
	else:
		print('Yes')