Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def erase_end(string):
    if string.endswith("dream"):
        string = string.rstrip("dream")
    elif string.endswith("dreamer"):
        string = string.rstrip("dreamer")
    elif string.endswith("erase"):
        string = string.rstrip("erase")
    elif string.endswith("eraser"):
        string = string.rstrip("eraser")
    elif string == "":
        string = "YES"
    else:
        string = "NO"
    return string
    
string = input()

while True:
    if string == "YES" or string == "NO":
    string = erase_end(string)
        break

print(string)

Fixed submission:

def erase_end(string):
    if string.endswith("dream"):
        string = string[:-5]
    elif string.endswith("dreamer"):
        string = string[:-7]
    elif string.endswith("erase"):
        string = string[:-5]
    elif string.endswith("eraser"):
        string = string[:-6]
    elif string == "":
        string = "YES"
    else:
        string = "NO"
    return string
    
string = input()

while True:
    if string == "YES" or string == "NO":
        break
    string = erase_end(string)

print(string)
Buggy python submission (verdict: Runtime Error):
#import numpy as np#not for pypy

def main():
    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")
    #second_input = input().split(" ")

    N = first_input[0]
    K = first_input[1]
    A_n_list = second_input

    current_i = N-1
    chain = [A_n_list[current_i]]
    while True:
        current_i = A_n_list[current_i]-1
        if A_n_list[current_i] in chain:
            sentou_index = chain.index(A_n_list[current_i])
            chain_roop = chain[sentou_index:]
            break
        chain.append(A_n_list[current_i])

    print(chain_roop)
    if sentou_index>=K:
        print(chain[K])
    else:
        print(chain_roop[(K-sentou_index-2)%len(chain_roop)])

if __name__ == '__main__':
    main()


Fixed submission:
#import numpy as np
#import math
#from fractions import gcd

def main():

    ##get int
    #first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    first_input = input().split(" ")
    second_input = input().split(" ")

    S = first_input[0]
    T = second_input[0]

    if S==T[:-1]:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#import numpy as np
import math
#from fractions import gcd

def check_Q(current_list,Qset):

    sum_d = 0
    for i in range(len(Qset)):
        current_Qset = Qset[i]
        if (current_list[current_Qset[1]-1]-current_list[current_Qset[0]-1])==current_Qset[2]:
            sum_d = sum_d+current_Qset[3]

    return sum_d

def check_N(preget_list,zan_pre,M,nokori_N,Qset):

    if nokori_N==1:
        sum_list = []
        for i in range(zan_pre,M+1):
            current_list = preget_list+[i]
            sum_list.append(check_Q(current_list,Qset))

        return sum_list
    else:
        sum_list = []
        for i in range(zan_pre,M+1):
            current_list = preget_list+[i]
            sum_list = sum_list + check_N(current_list,i+1,M,nokori_N-1,Qset)

        return sum_list

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    N = first_input[0]
    M = first_input[1]
    Q = first_input[2]

    Qset = []
    for i in range(Q):
        secondkara_input = list(map(lambda x:int(x), input().split(" ")))
        Qset.append(secondkara_input)

    #print(check_N([],1,M,N,Qset))
    print(max(check_N([],1,M,N,Qset)))

if __name__ == '__main__':
    main()


Fixed submission:
#import numpy as np
import math
#from fractions import gcd

def check_Q(current_list,Qset):

    sum_d = 0
    for i in range(len(Qset)):
        current_Qset = Qset[i]
        #print(current_Qset)
        #print(current_list)
        #print(sum_d)
        if (current_list[current_Qset[1]-1]-current_list[current_Qset[0]-1])==current_Qset[2]:
            sum_d = sum_d+current_Qset[3]

    return sum_d

def check_N(preget_list,zan_pre,M,nokori_N,Qset):

    if nokori_N==1:
        sum_list = []
        for i in range(zan_pre,M+1):
            current_list = preget_list+[i]
            sum_list.append(check_Q(current_list,Qset))

        return sum_list
    else:
        sum_list = []
        for i in range(zan_pre,M+1):
            current_list = preget_list+[i]
            sum_list = sum_list + check_N(current_list,i,M,nokori_N-1,Qset)

        return sum_list

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    N = first_input[0]
    M = first_input[1]
    Q = first_input[2]

    Qset = []
    for i in range(Q):
        secondkara_input = list(map(lambda x:int(x), input().split(" ")))
        Qset.append(secondkara_input)

    #print(check_N([],1,M,N,Qset))
    print(max(check_N([],1,M,N,Qset)))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
#import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    R = first_input[0]

    print(R*2*np.pi)

if __name__ == '__main__':
    main()


Fixed submission:
#import numpy as np
import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    R = first_input[0]

    print(R*2*math.pi)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):

first_input = map(lambda x:int(x), input().split(" "))
#second_input = input()

print(str(first_input[2])+" "+str(first_input[0])+" "+str(first_input[1]))


Fixed submission:

first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = input()

print(str(first_input[2])+" "+str(first_input[0])+" "+str(first_input[1]))

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

first_input = map(lambda x:int(x), input().split(" "))
#second_input = input()

print(str(first_input[2])+" "+str(first_input[0])+" "+str(first_input[1]))


Fixed submission:

first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = input()

print(str(first_input[2])+" "+str(first_input[0])+" "+str(first_input[1]))

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

first_input = map(lambda x:int(x), input().split(" "))
#second_input = input()

print(first_input[2]+" "+first_input[0]+" "+first_input[1])


Fixed submission:

first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = input()

print(str(first_input[2])+" "+str(first_input[0])+" "+str(first_input[1]))
Buggy python submission (verdict: Runtime Error):

first_input = list(map(lambda x:int(x), input().split(" ")))
second_input = list(map(lambda x:int(x), input().split(" ")))

second_input.sort(reverse=True)
criteria = sum(second_input)/float(4*first_input[1])

count = 0
for i in range(len(second_input)):
    if second_input[i]>=criteria:
        count = count+1
    else:
        break

if count >= first_input[1]:
    print("Yes")
else:
    print("No")
break


Fixed submission:

first_input = list(map(lambda x:int(x), input().split(" ")))
second_input = list(map(lambda x:int(x), input().split(" ")))

second_input.sort(reverse=True)
criteria = sum(second_input)/float(4*first_input[1])

count = 0
for i in range(len(second_input)):
    if second_input[i]>=criteria:
        count = count+1
    else:
        break

if count >= first_input[1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

N = first_input[0]
K = first_input[1]

#print(int(N/K))
if N>K:
    first_min_N = N - K*math.floor(N/K)

print(min(first_min_N,abs(first_min_N-K)))


Fixed submission:
import math
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

N = first_input[0]
K = first_input[1]

#print(math.floor(N // K))
#print(K*math.floor(N // K))
if N>K:
    first_min_N = N - K*math.floor(N // K)
else:
    first_min_N = N

print(min(first_min_N,abs(first_min_N-K)))
Buggy python submission (verdict: Runtime Error):
##input##
Nvar = int(input())
T_list = map(lambda x:int(x),input().split(" "))
M_var = int(input())
P_dict = {}
for i in range(M_var):
    buf = map(lambda x:int(x),input().split(" "))
    P_dict[buf[0]] = buf[1]
##

time_sum = 0
for d_num in range(M_var):
    for q_num in range(Nvar):
        if q_num==d_num:
            time_sum += P_list[q_num+1]
        else:
            time_sum += T_list[q_num]


Fixed submission:
##input##
Nvar = int(input())
T_list = list(map(lambda x:int(x),input().split(" ")))
M_var = int(input())
P_list = []
for i in range(M_var):
    P_list.append(list(map(lambda x:int(x),input().split(" "))))
##

for d_num in range(M_var):
    time_sum = 0
    for q_num in range(Nvar):
        if q_num==P_list[d_num][0]-1:
            time_sum += P_list[d_num][1]
        else:
            time_sum += T_list[q_num]
    print(time_sum)
Buggy python submission (verdict: Runtime Error):
n = int(input())
array = input().split()
l = list(map(int, array))
for i in range(1, n + 1):
    print(l.count(i))


Fixed submission:
import math
r = int(input())
r = r * 2 * math.pi
print(r)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = []
for i in range(n)
a[i] = list(map(int, input().split()))[i]
sort(a)
if a[m-1] > 1/4*m:
  print("Yes")
else:
  print("No")

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

i = list(map(int, input().split()))
a=[]
for x in range(n):
    a.append(i[x])
a.sort(reverse = True)
if a[m-1] >= sum(a)/(4*m):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n,m = map(int, input())
a = []
for i in range(n)
a[i] = list(input().split())[i]
sort(a)
if a[m-1] > 1/4*m:
  print("Yes")
else:
  print("No")

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

i = list(map(int, input().split()))
a=[]
for x in range(n):
    a.append(i[x])
a.sort(reverse = True)
if a[m-1] >= sum(a)/(4*m):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

z = a % b

if z > b/2:
    print(abs(z-k))
else:
    print(z)

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


z = a % b


if z > b/2:
    print(abs(z-b))
else:
    print(z)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n = ni()

    print(sum(range(n)))


if __name__ == '__main__':
    main()


Fixed submission:
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n = ni()

    print(n * (n - 1) // 2)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

def main():
    n, k = na()

    '''
    for i in range(k, n+1, k):
        for j in range(k, n+1, k):
            if (i + j) % k == 0:
                for m in range(k, n+1, k):
                    if (i+m) % k == 0 and (j+m) % k == 0:
                        print(i, j, m)
    '''
    # kは奇数
    if k % 2 == 1:
        print((n // k) ** 3)
        return

    c = 0
    for i in range(k//2, n+1, k//2):
        for j in range(k//2, n+1, k//2):
            if (i + j) % k == 0:
                for m in range(k//2, n+1, k//2):
                    if (i+m) % k == 0 and (j+m) % k == 0:
                        #print(i, j, m)
                        c += 1

    # kは偶数
    print(c)

main()


Fixed submission:
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

def main():
    n, k = na()

    '''
    for i in range(k, n+1, k):
        for j in range(k, n+1, k):
            if (i + j) % k == 0:
                for m in range(k, n+1, k):
                    if (i+m) % k == 0 and (j+m) % k == 0:
                        print(i, j, m)
    '''
    # kは奇数
    if k % 2 == 1:
        print((n // k) ** 3)
        return
    '''
    c = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            if (i + j) % k == 0:
                for m in range(1, n+1):
                    if (i+m) % k == 0 and (j+m) % k == 0:
                        print(i, j, m)
                        c += 1
    '''
    # kは偶数
    c = (n//k) ** 3 + (n//(k//2) - n//k)  ** 3
    print(c)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

def main():
    n, k = na()
    xs = na()

    m = float('inf')
    for i in range(n-k+1):
        vs = xs[i:i+k]
        if vs[0] * vs[-1] < 0:
            l = abs(vs[0]) + abs(vs[-1]) + min(abs(vs[0]), abs(vs[-1]))
        else:
            l = max(abs(vs[0]), abs(vs[-1]))

        m = min(m, l)

    print(m)
    
main()


Fixed submission:
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

def main():
    n, k = na()
    xs = na()

    m = float('inf')
    for i in range(n-k+1):
        if xs[i] * xs[i+k-1] < 0:
            l = abs(xs[i]) + abs(xs[i+k-1]) + min(abs(xs[i]), abs(xs[i+k-1]))
        else:
            l = max(abs(xs[i]), abs(xs[i+k-1]))

        m = min(m, l)

    print(m)
    
main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

def main():
    n, k = na()
    xs = na()

    m = float('inf')
    for i in range(n-k+1):
        vs = xs[i:i+k]
        if vs[0] * vs[-1] < 0:
            m = min(m, abs(vs[0]) + abs(vs[-1]) + min(abs(vs[0]), abs(vs[-1])))
        else:
            m = min(m, max(abs(vs[0]), abs(vs[-1])))

    print(m)
    
main()


Fixed submission:
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

def main():
    n, k = na()
    xs = na()

    m = float('inf')
    for i in range(n-k+1):
        if xs[i] * xs[i+k-1] < 0:
            l = abs(xs[i]) + abs(xs[i+k-1]) + min(abs(xs[i]), abs(xs[i+k-1]))
        else:
            l = max(abs(xs[i]), abs(xs[i+k-1]))

        m = min(m, l)

    print(m)
    
main()
Buggy python submission (verdict: Runtime Error):
def main():
    a = int(input())
    b = int(input())

    print((a-1) * (b-1))

        
if __name__ == '__main__':
    main()


Fixed submission:
def main():
    a, b = [int(x) for x in input().rstrip().split()]

    print((a-1) * (b-1))
        
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    s = input().rstrip()
    k = int(input().rstrip())

    if s[0] != '1':
        print(s[0])
        return

    cnt = 0
    for a in s:
        if a == '1':
            cnt += 1
        else:
            break

    if k < cnt:
        print(1)
    else:
        print(s[cnt])
    
    
main()


Fixed submission:
def main():
    s = input().rstrip()
    k = int(input().rstrip())

    if s[0] != '1':
        print(s[0])
        return

    cnt = 0
    for a in s:
        if a == '1':
            cnt += 1
        else:
            break

    if k <= cnt:
        print(1)
    else:
        print(s[cnt])
    
    
main()

Buggy python submission (verdict: Runtime Error):
def main():
    s = input().rstrip()
    k = int(input().rstrip())

    if s[0] != '1':
        print(s[0])
        return

    cnt = 0
    for a in s:
        if a == '1':
            cnt += 1

    if k < cnt:
        print(1)
    else:
        print(s[cnt])
    
    
main()


Fixed submission:
def main():
    s = input().rstrip()
    k = int(input().rstrip())

    if s[0] != '1':
        print(s[0])
        return

    cnt = 0
    for a in s:
        if a == '1':
            cnt += 1
        else:
            break

    if k <= cnt:
        print(1)
    else:
        print(s[cnt])
    
    
main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n, m, q = na()
    lrs = [na() for _ in range(m)]
    pqs = [na() for _ in range(q)]

    map = {}
    for l, r in lrs:
        x = r - l
        if l in map:
            if x in map[l]:
                map[l][x] += 1
            else:
                map[l][x] = 1
        else:
            map[l] = {}
            map[l][x] = 1

    for p, q in pqs:
        cnt = 0
        for l in range(p, q+1):
            if l in map:
                for x in range(q-l+1):
                    if x in map[l]:
                        cnt += map[l][x]

        print(cnt)
                

main()


Fixed submission:
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n, m, q = na()
    lrs = [na() for _ in range(m)]
    pqs = [na() for _ in range(q)]

    table = [[0] * (n+1) for _ in range(n+1)]

    # 
    for l, r in lrs:
        table[l][r] += 1

    # 行方向の累積和
    for i in range(1, n+1):
        for j in range(1, n+1):
            table[i][j] += table[i][j-1]

    # 列方向の累積和
    for j in range(1, n+1):
        for i in range(1, n+1):
            table[i][j] += table[i-1][j]
            
    for p, q in pqs:
        v = table[q][q] - table[q][p-1] - table[p-1][q] + table[p-1][p-1]
        print(v)
    

main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n, m = na()
    a = na()

    c = 0
    for l in range(n):
        v = 0
        for r in range(l, n):
            v += a[r]
            if v % m == 0:
                c += 1

    print(c)
                
main()


Fixed submission:
import sys
import math

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n, m = na()
    a = na()

    vs = {}

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

    for i in range(n):
        k = b[i] % m
        if k in vs:
            vs[k] += 1
        else:
            vs[k] = 1
            

    cnt = 0
    for k, v in vs.items():
        if v >= 2:
            cnt += math.factorial(v) // 2 // math.factorial(v-2)
        if k == 0:
            cnt += v


    print(cnt)


main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input().strip())
    a = [int(i) for i in input().split(' ')]

    c = n
    for i in range(n):
        s1, s2 = a[i], a[i]
        for j in range(i+1, n):
            s1 |= a[j]
            s2 += a[j]
            if s1 == s2:
                c += 1
            
    print(c)

if __name__ == '__main__':
    main()


Fixed submission:


def main():
    a, b = [int(x.strip()) for x in input().split()]
    c = max(a + b, a - b, a * b)

    print(c)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    n = int(input().strip())
    s = input().strip()

    m = 300000
    for i in range(0, len(s)):
        c = len([x for x in s[0:i] if x == 'W'])
        c += len([x for x in s[i+1:] if x == 'E'])

        m = min(m, c)

    print(m)


if __name__ == '__main__':
    main()


Fixed submission:

def main():
    n = int(input().strip())
    s = input().strip()

    right_e = len([x for x in s if x == 'E'])
    left_w = 0

    m = right_e - 1 if s[0] == 'E' else right_e
    
    for i in range(1, len(s)):
        if s[i-1] == 'E':
            right_e -= 1
        else:
            left_w += 1

        if s[i] == 'E':
            m = min(m, right_e - 1 + left_w)
        else:
            m = min(m, right_e + left_w)


    print(m)


if __name__ == '__main__':
    main()