Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

move_p = [a, b, c, d, e]
pos = np.zeros(6)
pos_pre = np.zeros(6)
move_n = np.zeros(5)
pos[0] = n
cnt = 0
while sum(pos[: 6]) != 0:

    for i in range(5):
        if move_p[i] <= pos[i]:
            move_n[i] = move_p[i]
            pos[i] -= move_n[i]
            pos_pre[i + 1] += move_n[i]
        elif pos[i] < move_p[i]:
            move_n[i] = pos[i]
            pos[i] -= move_n[i]
            pos_pre[i + 1] += move_n[i]

    for i in range(5):
        pos[i] += pos_pre[i]
        pos_pre[i] = 0
    cnt += 1

print(cnt)


Fixed submission:
import numpy as np

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

move_p = [a, b, c, d, e]
# pos = np.zeros(6)
# pos_pre = np.zeros(6)
# move_n = np.zeros(5)
# pos[0] = n
# cnt = 0
# while sum(pos[: 6]) != 0:

#     for i in range(5):
#         if move_p[i] <= pos[i]:
#             move_n[i] = move_p[i]
#             pos[i] -= move_n[i]
#             pos_pre[i + 1] += move_n[i]
#         elif pos[i] < move_p[i]:
#             move_n[i] = pos[i]
#             pos[i] -= move_n[i]
#             pos_pre[i + 1] += move_n[i]

#     for i in range(5):
#         pos[i] += pos_pre[i]
#         pos_pre[i] = 0
#     cnt += 1

min_ = min(move_p)
cnt = int(np.ceil(n / min_) + 4)

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

n, q = map(int, input().split())
s = input()
l_ = np.zeros(q)
r_ = np.zeros(q)

for i in range(q):
    l_tmp, r_tmp = map(int, input().split())
    l_[i] = l_tmp
    r_[i] = r_tmp
l_ = l_ - 1
r_ = r_ - 1
for i in range(q):
    cnt = 0
    t = s[int(l_[i]) : int(r_[i]) + 1]
    for j in range(len(t) - 1):
        if t[j : j + 2] == "AC":
            cnt += 1
    print(cnt)


Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
    if s[i : i + 2] == "AC":
        t[i + 1] = t[i] + 1
    else:
        t[i + 1] = t[i]

for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

cnt = 0

cnt01 = s.count('01')
cnt10 = s.count('10')

while cnt01 != 0 or cnt10 != 0:
    if cnt01 >= cnt10:
        s = s.replace('01', '')
        cnt += cnt01
    else:
        s = s.replace('10', '')
        cnt += cnt10

    cnt01 = s.count('01')
    cnt10 = s.count('10')

print(cnt * 2)


Fixed submission:
s = input()
n = len(s)
cnt = []
cnt.append(s.count('0'))
cnt.append(s.count('1'))

print(2 * min(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)


cnt = 0

idx01 = s.find('01')
idx10 = s.find('10')
cnt01 = s.count('01')
cnt10 = s.count('10')

while idx01 != -1 or idx10 != -1:
    if idx01 == -1 and idx10 == -1:
        print(cnt)
        exit()
    if idx01 == -1:
        idx01 = 1000000
    if idx10 == -1:
        idx10 = 1000000
    if cnt01 >= cnt10:
        s = s.replace('01', '', cnt01)
        cnt += cnt01
    else:
        s = s.replace('10', '', cnt10)
        cnt += cnt10

    idx01 = s.find('01')
    idx10 = s.find('10')
    cnt01 = s.count('01')
    cnt10 = s.count('10')

print(cnt * 2)

Fixed submission:
s = input()
n = len(s)
cnt = []
cnt.append(s.count('0'))
cnt.append(s.count('1'))

print(2 * min(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)


cnt = 0

idx01 = s.find('01')
idx10 = s.find('10')
cnt01 = s.count('01')
cnt10 = s.count('10')

while idx01 != -1 or idx10 != -1:
    if idx01 == -1 and idx10 == -1:
        print(cnt)
        exit()
    if idx01 == -1:
        idx01 = 1000000
    if idx10 == -1:
        idx10 = 1000000
    if idx01 <= idx10:
        s = s.replace('01', '', cnt01)
        cnt += cnt01
    else:
        s = s.replace('10', '', cnt10)
        cnt += cnt10

    idx01 = s.find('01')
    idx10 = s.find('10')
    cnt01 = s.count('01')
    cnt10 = s.count('10')

print(cnt * 2)

Fixed submission:
s = input()
n = len(s)
cnt = []
cnt.append(s.count('0'))
cnt.append(s.count('1'))

print(2 * min(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)


cnt = 0

idx01 = s.find('01')
idx10 = s.find('10')

while idx01 != -1 or idx10 != -1:
    if idx01 == -1 and idx10 == -1:
        print(cnt)
        exit()
    if idx01 == -1:
        idx01 = 1000000
    if idx10 == -1:
        idx10 = 1000000
    if idx01 <= idx10:
        s = s.replace('01', '', 1)
    else:
        s = s.replace('10', '', 1)
    cnt += 1
    idx01 = s.find('01')
    idx10 = s.find('10')

print(cnt * 2)


Fixed submission:
s = input()
n = len(s)
cnt = []
cnt.append(s.count('0'))
cnt.append(s.count('1'))

print(2 * min(cnt))
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = []
u = []

total = 0
for i in range(n):
    x_tmp, u_tmp = map(int(input))
    if u_tmp == 'JPY':
        total += x_tmp
    elif u_tmp == 'BTC':
        total += x_tmp * 380000

print(total)


Fixed submission:
n = int(input())
x = []
u = []

total = 0
for i in range(n):
    x_tmp, u_tmp = input().split()
    if u_tmp == 'JPY':
        total += int(x_tmp)
    elif u_tmp == 'BTC':
        total += float(x_tmp) * 380000

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

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.full(n, np.inf)

dp[0] = 0
dp[1] = np.abs(h[1] - h[0])

def chmin(a, b):
    if a < b:
        return a
    else:
        return b

for i in range(2, n):
    # for j in range(1, k):
    #     dp[i] = chmin(dp[i], dp[i - j] + np.abs(h[i] - h[i - j]))
    tmp1 = dp[max(i - k, 0):i + 1 - 1]
    tmp2 = np.abs(h[i] - h[max(i - k, 0):i + 1 - 1])
    dp[i] = np.min(tmp1 + tmp2)

print(int(dp[-1]))


Fixed submission:
import numpy as np

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.full(n, np.inf)

dp[0] = 0
dp[1] = np.abs(h[1] - h[0])

# def chmin(a, b):
#     if a < b:
#         return a
#     else:
#         return b

for i in range(2, n):

    # 1回目の投稿：for文。ほぼTLE。遅すぎ。
    # for j in range(1, k):
    #     dp[i] = chmin(dp[i], dp[i - j] + np.abs(h[i] - h[i - j]))
    # 2回目の投稿：ベクトル化。最後4つTLE。少し早いけどまだだめ。
    # tmp1 = dp[max(i - k, 0):i + 1 - 1]
    # tmp2 = np.abs(h[i] - h[max(i - k, 0):i + 1 - 1])
    # dp[i] = np.min(tmp1 + tmp2)
    # 3回目の投稿：
    start = max(i - k, 0)
    dp[i] = np.min(dp[start:i] + np.abs(h[i] - h[start:i]))

print(int(dp[-1]))

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

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = np.full(n, np.inf)

dp[0] = 0
dp[1] = np.abs(h[1] - h[0])

def chmin(a, b):
    if a < b:
        return a
    else:
        return b

for i in range(2, n):
    if i > k:
        k = i
    for j in range(1, k):
        dp[i] = chmin(dp[i], dp[i - j] + np.abs(h[i] - h[i - j]))

print(int(dp[-1]))


Fixed submission:
import numpy as np

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.full(n, np.inf)

dp[0] = 0
dp[1] = np.abs(h[1] - h[0])

# def chmin(a, b):
#     if a < b:
#         return a
#     else:
#         return b

for i in range(2, n):

    # 1回目の投稿：for文。ほぼTLE。遅すぎ。
    # for j in range(1, k):
    #     dp[i] = chmin(dp[i], dp[i - j] + np.abs(h[i] - h[i - j]))
    # 2回目の投稿：ベクトル化。最後4つTLE。少し早いけどまだだめ。
    # tmp1 = dp[max(i - k, 0):i + 1 - 1]
    # tmp2 = np.abs(h[i] - h[max(i - k, 0):i + 1 - 1])
    # dp[i] = np.min(tmp1 + tmp2)
    # 3回目の投稿：
    start = max(i - k, 0)
    dp[i] = np.min(dp[start:i] + np.abs(h[i] - h[start:i]))

print(int(dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for i in range(n)])

dp = np.zeros((n + 1, W + 1), dtype=np.int)


def chmax(a, b):
    if a > b:
        return a
    else:
        return b


for i in range(n):
    for sum_w in range(W + 1):
        if sum_w >= wv[i, 0]:
            dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w - wv[i, 0]] + wv[i, 1])
        dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w])

print(int(dp[n , W]))


Fixed submission:
import numpy as np

n, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for i in range(n)])

dp = np.zeros((n + 1, W + 1), dtype=np.int)


def chmax(a, b):
    if a > b:
        return a
    else:
        return b


# # 遅い
# for i in range(n):
#     for sum_w in range(W + 1):
#         if sum_w >= wv[i, 0]:
#             dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w - wv[i, 0]] + wv[i, 1])
#         dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w])

for i in range(0, n):
    w, v = wv[i, :]
    dp[i + 1, w:] = np.maximum(dp[i, w:], dp[i, :-w] + v)
    dp[i + 1, :] = np.maximum(dp[i + 1, :], dp[i, :])

print(int(dp[n , W]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = []
for i in range(n):
    p.append(int(input()))

p_max = max(p)

print(int(sum(p) - p_max / 2)


Fixed submission:
n = int(input())
p = []
for i in range(n):
    p.append(int(input()))

p_max = max(p)

print(int(sum(p) - p_max / 2))
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())

print(int(x + y / 2))
x, y = map(int, input().split())

print(int(x + y / 2))


Fixed submission:
x, y = map(int, input().split())

print(int(x + y / 2))
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, T = map(int, input().split())
c = np.zeros(n)
t = np.zeros(n)
for i in range(n):
    c_tmp, t_tmp = map(int, input().split())
    c[i] = (c_tmp)
    t[i] = (t_tmp)

tmp = c[t <= T]

if len(tmp) == 0:
    print("TLE")
else:
    print(int(min(tmp)))


Fixed submission:
import numpy as np

n, T = map(int, input().split())
c = np.zeros(n)
t = np.zeros(n)
for i in range(n):
    c_tmp, t_tmp = map(int, input().split())
    c[i] = (c_tmp)
    t[i] = (t_tmp)

tmp = c[t <= T]

if len(tmp) == 0:
    print("TLE")
else:
    print(int(min(tmp)))
Buggy python submission (verdict: Runtime Error):
n = input()

if '1' in n:
  s = s.replace('1', '9')

if '9' in n:
  s = s.replace('9', '1')
  
print(s)

Fixed submission:
s = list(input())

if s[0] == '1':
    s[0] = s[0].replace('1', '9')
elif s[0] == '9':
    s[0] = s[0].replace('9', '1')
if s[1] == '1':
    s[1] = s[1].replace('1', '9')
elif s[1] == '9':
    s[1] = s[1].replace('9', '1')
if s[2] == '1':
    s[2] = s[2].replace('1', '9')
elif s[2] == '9':
    s[2] = s[2].replace('9', '1')

print(''.join(s))
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
gcd = math.gcd(a,b)

#print(gcd)
pnum = set()

if gcd == 1:
    print(1)
elif gcd == 2:
    print(2)
else:
    pnum.add(2)
    for num in range(3,gcd+1):
        if gcd%num ==0:
            ptf = True
            for p in pnum:
                if num%p==0:
                    ptf = False
                    break
            if ptf ==True:
                pnum.add(num)
            
    print(len(pnum)+1)#1の分を足す

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
      
    divisors.sort()
    return divisors

import fractions
a,b=map(int,input().split())
gcd = fractions.gcd(a,b)

#print(gcd)
pnum = set()

if gcd == 1:
    print(1)
elif gcd == 2:
    print(2)
else:
    devlist = make_divisors(gcd)
    #print(devlist)
    #pnum.add(2)
    
    for num in devlist:
        if (num!=1):
            #print("gg",num)
            ptf = True
            for p in pnum:
                if num%p==0:
                    ptf = False
                    break
            if ptf ==True:
                pnum.add(num)
            
    print(len(pnum)+1)#1の分を足す
Buggy python submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())

ans = False
keyhi = 0
keywi = 0

sqsq = False
if (h==w)&(a==b):
    sqsq=True

if sqsq == False:
    for hi in range(h+1):
        tmp_sum_h = hi*a + (h-hi)*(w-a)
        for wi in range(w+1):
            tmp_sum_w = wi*b + (w-wi)*(h-b)

            if tmp_sum_h == tmp_sum_w:
                ans = True
                keyhi = hi
                keywi = wi
                break

        if ans == True:
            break

    #print(keyhi,keywi)

    if (h/2 < b)|(w/2 < a):
        ans = False

    if ans == True:
        for hi in range(h):
            if hi<keyhi:
                    row = "1"*a + "0"*(w-a)
            else:
                    row = "0"*a + "1"*(w-a)
            print(row)
    else:
        print("No")

if sqsq == True:
    if h%a!=0:
        print("No")
    else:
        koma = a
        for hi in range(h):
            ov = hi//koma
            row = "0"*(ov*koma) +"1"*koma+"0"*(w-ov*koma-koma)
            print(row)

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

if (h/2 < b)|(w/2 < a):
        print("No")    
else:
    for hi in range(h):
        if hi<b:
            row = ""
            for wi in range(w):
                if wi <a:
                    row += "1"
                else:
                    row += "0"
        else:
            row = ""
            for wi in range(w):
                if wi <a:
                    row += "0"
                else:
                    row += "1"
            
        print(row)

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

ans = False
keyhi = 0
keywi = 0

sqsq = False
if (h==w)&(a==b):
    sqsq=True

if sqsq == False:
    for hi in range(h+1):
        tmp_sum_h = hi*a + (h-hi)*(w-a)
        for wi in range(w+1):
            tmp_sum_w = wi*b + (w-wi)*(h-b)

            if tmp_sum_h == tmp_sum_w:
                ans = True
                keyhi = hi
                keywi = wi
                break

        if ans == True:
            break

    print(keyhi,keywi)

    if (h/2 < b)|(w/2 < a):
        ans = False

    if ans == True:
        for hi in range(h):
            if hi<keyhi:
                    row = "1"*a + "0"*(w-a)
            else:
                    row = "0"*a + "1"*(w-a)
            print(row)
    else:
        print("No")

if sqsq == True:
    if h%a!=0:
        print("No")
    else:
        koma = a
        for hi in range(h):
            ov = hi//koma
            row = "0"*(ov*koma) +"1"*koma+"0"*(w-ov*koma-koma)
            print(row)

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

if (h/2 < b)|(w/2 < a):
        print("No")    
else:
    for hi in range(h):
        if hi<b:
            row = ""
            for wi in range(w):
                if wi <a:
                    row += "1"
                else:
                    row += "0"
        else:
            row = ""
            for wi in range(w):
                if wi <a:
                    row += "0"
                else:
                    row += "1"
            
        print(row)
Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
d = {}
ans = [0]*(n+1)
for i in range(n-1):
    sta,gol = map(int,input().split())
    d[gol] = sta

for i in range(q):
    sta,val = map(int,input().split())
    ans[sta]+=val
    

for i in range(n):
    gol = i+1
    if gol in d:
        ans[gol]+=ans[d[gol]]
    

anss = ""
for i in range(n):
    anss = anss+str(ans[i+1])+" "
print(anss)

Fixed submission:
a=int(input())
s = str(input())

if a >= 3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
inf = 10**9+7
def conv(l,r):
    up = 1
    lo = 1
    for i in range(r):
        up *= l-i
        lo *= r-i
    return int(up/lo)

for i in range(1,k+1):
    print((conv(n-k+1,i)*conv(k-1,i-1))%inf)

Fixed submission:
n,k=map(int,input().split())
inf = 10**9+7

inv_t = [0]+[1]
for i in range(2,n+1):
    inv_t += [inv_t[inf % i] * (inf - int(inf / i)) % inf]
    
bik =  [1]+[1]
for i in range(2,n+1):
    bik += [(bik[i-1]*i)% inf]
    
bik_inv =  [1]+[1]
for i in range(2,n+1):
    bik_inv += [(bik_inv[i-1]*inv_t[i])% inf]

def conv(l,r):
    if l>=r:
        up = bik[l]
        lo = bik_inv[l-r]*bik_inv[r]
        return up*lo
    else:
        return 0

for i in range(1,k+1):
    """print("#########")
    print(i)
    print(conv(n-k+1,i))
    print(conv(k-1,i-1))"""
    print((conv(n-k+1,i)*conv(k-1,i-1))%inf)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
import math

ans = 0
if n >(k-1):
    ans += (n-k+1)/n


for i in range(1,min(k,n+1)):
    temp = 1/n
    tval = k/i
    p = int(math.log2(tval))+1

    ans +=temp*(0.5**p)
print(ans)

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

ans = 0
if n >(k-1):
    ans += (n-k+1)/n

for i in range(1,min(k,n+1)):
    if math.log(k/i,2)-int(math.log(k/i,2))== 0:
        p = int(math.log(k/i,2))
    else:
        p = int(math.log(k/i,2))+1
    ans +=(1/n)*(0.5**p)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]

ans=np.unique(road,return_counts=True)
for i in range(n):
    print(ans[1,i])

Fixed submission:
n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]
 
ans={}
for i in range(m):
  sta,gol = road[i][0],road[i][1]
  if sta not in ans:
    ans[sta] = []
  ans[sta].append(gol)
  
  if gol not in ans:
    ans[gol] = []
  ans[gol].append(sta)
  
for i in range(1,n+1):
  if i in ans:
  	print(len(ans[i]))
  else:
    print(0)

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

n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]

ans=np.unique(road,return_counts=True)
for i in range(n):
    print(ans[1,i])

Fixed submission:
n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]
 
ans={}
for i in range(m):
  sta,gol = road[i][0],road[i][1]
  if sta not in ans:
    ans[sta] = []
  ans[sta].append(gol)
  
  if gol not in ans:
    ans[gol] = []
  ans[gol].append(sta)
  
for i in range(1,n+1):
  if i in ans:
  	print(len(ans[i]))
  else:
    print(0)

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

n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]

ans=np.unique(road,return_counts=True)
for i in range(n):
    print(ans[1][i])

Fixed submission:
n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]
 
ans={}
for i in range(m):
  sta,gol = road[i][0],road[i][1]
  if sta not in ans:
    ans[sta] = []
  ans[sta].append(gol)
  
  if gol not in ans:
    ans[gol] = []
  ans[gol].append(sta)
  
for i in range(1,n+1):
  if i in ans:
  	print(len(ans[i]))
  else:
    print(0)

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

n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]

ans=np.unique(road,return_counts=True)
for i in range(n):
    print(ans[1][i])

Fixed submission:
n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]
 
ans={}
for i in range(m):
  sta,gol = road[i][0],road[i][1]
  if sta not in ans:
    ans[sta] = []
  ans[sta].append(gol)
  
  if gol not in ans:
    ans[gol] = []
  ans[gol].append(sta)
  
for i in range(1,n+1):
  if i in ans:
  	print(len(ans[i]))
  else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import math 
A,B,X = map(int,input().split())

t = 0
if (A**2)*B/X >= 2:
    t = float((A*(B**2))/(2*X))
else:
    t = float((A**3)/(2*(A**2)*B-2*X))

print(math.atan(t)*180/math.pi)

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

t = 0
if (A**2)*B/X >= 2:
    t = float((A*(B**2))/(2*X))
else:
    t = float((2*(A**2)*B-2*X)/(A**3))

print(math.atan(t)*180/math.pi)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N%2 == 0:
    print(0.5000)
else:
    print(((N-1)//(2*N))

Fixed submission:
N = int(input())

if N%2 == 0:
    print(1/2)
else:
    print(((N-1)//2+1)/N)
Buggy python submission (verdict: Runtime Error):
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]

ans = [0]*N
for a in A:
    ans[a-1] += 1
for i in range(Q):
    if K-Q+ans[i] > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]

ans = [0]*N
for a in A:
    ans[a-1] += 1
for i in range(N):
    if K-Q+ans[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [[int(input()),i] for i in range(n)]
l.sort(key=lambda x:x[0])
#print(n,l)

for i in range(n):
    if l[-1][1] == i:
        print(l[-2][0])
    else:
        print(l[-1][0])

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
half = n//2

ans = [0]*n
for i in range(half,n):
    if l[i] == 1:
        ans[i] = 1
for i in range(0,half):
    p = half-1-i
    s = 0
    qmax = n //(p+1)
    for j in range(1,qmax+1):
        s += ans[j*(p+1)-1]
    if s%2 != l[p]:
        ans[p] = 1
print(sum(ans))
for i in range(n):
    if ans[i] == 1:
        print(i+1,end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [int(input()) for i in range(n)]
#print(n,l)

L = 0
for i in range(n):
    cnt = 1
    x = l[i]
    for j in range(i+1,n):
        if l[j] <= x:
            cnt += 1
    if L <= cnt:
        L = cnt
print(L)

Fixed submission:
import bisect

N = int(input())
A = [10**10 - int(input()) for i in range(N)]
INF = 10**12

dp = [INF for i in range(N+1)]
#print(A,dp)

for a in A:
    i = bisect.bisect_right(dp,a)
    dp[i] = a
#print(dp)
res = bisect.bisect_left(dp,INF)
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [int(input()) for i in range(n)]
#print(n,l)

L = 0
cnt = 0
for i in range(n):
    if l[i] >= l[i+1]:
        cnt += 1
    else:
        cnt = 0
    if L <= cnt:
        L = cnt
print(L)

Fixed submission:
import bisect

N = int(input())
A = [10**10 - int(input()) for i in range(N)]
INF = 10**12

dp = [INF for i in range(N+1)]
#print(A,dp)

for a in A:
    i = bisect.bisect_right(dp,a)
    dp[i] = a
#print(dp)
res = bisect.bisect_left(dp,INF)
print(res)
Buggy python submission (verdict: Runtime Error):
import math
def P(p, q):
  return math.factorial(p)//math.factorial(p-q)

def cmb(p, q):
  return P(p, q)//math.factorial(q)

n,k = map(int,input().split())
#print(n,k)

ans = []

x = 0
a = 1
if n-k == 1:
  b = 2
elif n-k > 1:
  b = cmb(n-k-1, 1)
else:
  b = 0
x = (2 + a * b)%(1000000007)
ans.append(x)

x = 0
if k == 1:
  a = 1
else:
  a = cmb(k-1, 1)
if n-k == 1:
  b = 1
elif n-k == 2:
  b = cmb(n-k-1, 1) * 2 + 1
else:
  b = cmb(n-k-1, 2) + cmb(n-k-1, 1) * 2 + 1
x = (a * b)%(1000000007)
ans.append(x)

#print(ans)

 
for i in range(3,k+1):
  x = 0
  a = cmb(k-1, i-1)#青玉の並べ方
  if n-k-1 < i-2:
    b = 0
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-2)
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  else:
    b = cmb(n-k-1,i) + cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  x = (a * b)%(1000000007)
  ans.append(x)

for i in range(k):
  print(ans[i])

Fixed submission:
s = list(input())
#print(s)

l = []

for i in range(4):
  if not s[i] in l:
    l.append(s[i])
#print(l)

if len(l) != 2:
  print("No")
else:
  if s.count(l[0]) == 2:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
'''for i in range(n):
  x = l[i][1] - l[i][0]
  l[i][2] = x'''
l.sort(key=lambda x: x[1])
#print(l)

check = []
c = 0
for i in range(n):
  if c != l[i][1]:
    check.append(l[i][1])
    c = l[i][1]
#print(check)

sum_t = 0
limit = l[0][1]
ans = 0
for i in range(n):
  if limit != l[i][1]:
    limit = l[i][1]
  sum_t += l[i][0]
  if sum_t > limit:
    ans += 1
#print(ans)
if ans == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
c = 0

for i in range(0,3):
  if s[i] == s[i+1]:
    c += 1
if c == 0:
  print("Good")
else:
  print("Bad")