Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def resolve():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p1 = list(map(lambda x: (x+1)/2, p))
    ans = 0
    if k==1:
        print(max(p1))
        exit()
    else:
        initial = sum(p1[0:k])
        for i in range(n-k+1):
            cal = initial-p1[i]+p1[i+k]
            if ans <= cal:
                ans = cal
    print(ans)
resolve()

Fixed submission:
def resolve():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p1 = list(map(lambda x: (x+1)/2, p))
    ans = 0
    if k==1:
        print(max(p1))
        exit()
    else:
        initial = sum(p1[0:k])
        if ans <= initial:
            ans = initial
            cal = initial
        for i in range(n-k):
            cal = cal-p1[i]+p1[i+k]
            if ans <= cal:
                ans = cal
    print(ans)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p1 = list(map(lambda x: (x+1)/2, p))
    ans = 0
    if k==1:
        print(max(p1))
        exit()
    else:
        for i in range(n-k+1):
            cal = sum(p1[i:i+k])
            if ans <= cal:
                ans = cal
    print(ans)
resolve()

Fixed submission:
def resolve():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p1 = list(map(lambda x: (x+1)/2, p))
    ans = 0
    if k==1:
        print(max(p1))
        exit()
    else:
        initial = sum(p1[0:k])
        if ans <= initial:
            ans = initial
            cal = initial
        for i in range(n-k):
            cal = cal-p1[i]+p1[i+k]
            if ans <= cal:
                ans = cal
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    i = sorted(h, reverse=True)

    if k==0:
        print(sum(i))
        exit()
    else:
        j = i[k:]
        print(sum(j))
resolve()

Fixed submission:
def resolve():
    import math
    h = int(input())
    logh = int(math.log(h,2))
    rlist = []
    cum = 1
    for i in range(40):
        rlist.append(cum)
        cum = cum*2+1
    print(rlist[logh])
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
        if temp!=1:
            arr.append([temp, 1])
        if arr==[]:
            arr.append([n, 1])
        return arr

    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9 + 7
    import copy

    gcddict = {}
    adiv = []
    for i in range(n):
        primes = factorization(a[i])
        adiv.append(primes)
        for j in range(len(primes)):
            if primes[j][0] in gcddict:
                gcddict[primes[j][0]] = max(gcddict[primes[j][0]], primes[j][1])
            else:
                gcddict[primes[j][0]] = primes[j][1]
    ans = 0
    for i in range(n):
        val = 1
        test = copy.deepcopy(gcddict)
        primes = adiv[i]
        for j in range(len(primes)):
            test[primes[j][0]] -= primes[j][1]
        for k in test.keys():
            val *= pow(k, test[k], mod)
        ans += val
    print(ans % mod)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    c = [[0] * 10 for i in range(10)]
    for i in range(n+1):
        b = i % 10
        for j in range(6):
            if i//(10**(j+1)) == 0:
                a = i//(10**j)
                break
        c[a][b] += 1
    ans = 0
    for i in range(1,10):
        for j in range(1,10):
            ans += c[i][j] * c[j][i]
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    n = int(input())
    if n==2:
        print("2")
    for j in range(10000):
        flag = 1
        a = int((n+j)**0.5)+1
        for i in range(2, a+1):
            if (n+i) % j == 0:
                flag = -1
            if i == a and flag ==1:
                print(n+j)
                exit()
resolve()

Fixed submission:
def resolve():
    n = int(input())
    primel = [2]
    for i in range(3,331):
        k = 0
        for j in range(len(primel)):
            if i % primel[j] == 0:
                break
            else:
                k += 1
            if k == len(primel):
                primel.append(i)

    for i in range(0, 100000):
        k=0
        for j in range(len(primel)):
            if (n+i) == primel[j]:
                print(n + i)
                exit()
            if (n+i) % primel[j] == 0:
                break
            else:
                k += 1
            if k == len(primel):
                print(n + i)
                exit()
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    zero = [0] * 61
    one = [0] * 61
    for i in range(n):
        for j in range(61):
            if a[i]>>j  & 1:
                one[j] += 1
            else:
                zero[j] += 1
    ans = 0
    for i in range(60):
        ans += ((one[i]*zero[i]) * pow(2, i, mod)) % mod
        ans %= mod
    print(ans)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    zero = [0] * 61
    one = [0] * 61
    for i in range(n):
        for j in range(61):
            if a[i]>>j  & 1:
                one[j] += 1
            else:
                zero[j] += 1
    ans = 0
    for i in range(60):
        ans += ((one[i]*zero[i]) * pow(2, i, mod)) % mod
        ans %= mod
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    import math
    a,b,x = map(int, input().split())
    if 10**((x//b)-1) < 10:
        pmax = min (x//a, 10**((x//b)-1))
    else:
        pmax = x//a
    if pmax ==0:
        print(0)
        exit()
    elif pmax > 10**9:
        pmax = 10**9

    for i in range(10**9):
        n1 = pmax-i
        logn1 = int(math.log(n1,10))+1
        if a*n1+b*logn1 <= x:
            print(n1)
            exit()
resolve()

Fixed submission:
def resolve():
    s = input()
    if s == "SUN":
        print(7)
    elif s == "MON":
        print(6)
    elif s == "TUE":
        print(5)
    elif s == "WED":
        print(4)
    elif s == "THU":
        print(3)
    elif s == "FRI":
        print(2)
    elif s == "SAT":
        print(1)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    import math
    a,b,x = map(int, input().split())
    area = x/a
    height = x/(a**2)
    if area >= (a*b/2):
        c = b-height
        angle = math.degrees(math.atan(a/(2*c)))
        print(90-angle)
    else:
        d = area*2/b
        angle = math.degrees(math.atan(d/b))
        print(90-angle)
resolve()

Fixed submission:
def resolve():
    import math
    a,b,x = map(int, input().split())
    area = x/a
    height = x/(a**2)
    if height == b:
        print(0)
    elif area >= (a*b/2):
        c = b-height
        angle = math.degrees(math.atan(a/(2*c)))
        print(90-angle)
    else:
        d = area*2/b
        angle = math.degrees(math.atan(d/b))
        print(90-angle)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    from collections import deque
    n, m = map(int, input().split())
    a = deque(map(int, input().split()))

    for i in range(m):
        a = deque(sorted(a))
        maxa = a.pop()
        maxa //= 2
        a.appendleft(maxa)
    print(sum(a))
resolve()

Fixed submission:
def resolve():
    n,k,q = map(int, input().split())
    a = [int(input()) for i in range(q)]
    point = [0]*n
    for i in range(q):
        point[a[i]-1] += 1
    for j in range(n):
        if k-q+point[j] > 0:
            print("Yes")
        else:
            print("No")
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    from collections import deque
    n, m = map(int, input().split())
    a = deque(map(int, input().split()))
 
    for i in range(m):
        a = deque(sorted(a))
        maxa = a.pop()
        maxa //= 2
        a.appendleft(maxa)
    print(sum(a))
resolve()

Fixed submission:
def resolve():
    import heapq
    n, m = map(int, input().split())
    a = list(map(lambda x:int(x)*-1, input().split()))
    heapq.heapify(a)
    for i in range(m):
        maxa = heapq.heappop(a) * -1
        maxa //= 2
        heapq.heappush(a, -maxa)
    print(sum(a)*-1)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    from collections import deque
    n, m = map(int, input().split())
    a = deque(map(int, input().split()))

    for i in range(m):
        a = deque(sorted(a))
        maxa = a.pop()
        maxa //= 2
        a.appendleft(maxa)
    print(sum(a))
resolve()

Fixed submission:
def resolve():
    import heapq
    n, m = map(int, input().split())
    a = list(map(lambda x:int(x)*-1, input().split()))
    heapq.heapify(a)
    for i in range(m):
        maxa = heapq.heappop(a) * -1
        maxa //= 2
        heapq.heappush(a, -maxa)
    print(sum(a)*-1)
resolve()

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

    for i in range(m):
        a = sorted(a, reverse = True)
        a[0] = a[0]//2
    print(sum(a))
resolve()

Fixed submission:
def resolve():
    import heapq
    n, m = map(int, input().split())
    a = list(map(lambda x:int(x)*-1, input().split()))
    heapq.heapify(a)
    for i in range(m):
        maxa = heapq.heappop(a) * -1
        maxa //= 2
        heapq.heappush(a, -maxa)
    print(sum(a)*-1)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    n = int(input())
    dict = {}
    for i in range(n):
        s = "".join(sorted(input()))
        if s[i] in dict.keys():
            dict[s] += 1
        else:
            dict[s] =1
    alist = list (dict.values())
    ans = 0
    for i in range(len(alist)):
        ct = alist[i]
        ans += (ct*(ct-1))//2
    print(ans)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    s = [",".join(sorted(input())) for i in range(n)]
    ans = {}
    count = 0
    for i in range(n):
        if s[i] in ans:
            count += ans[s[i]]
            ans[s[i]] += 1
        else:
            ans[s[i]] = 1
    print(count)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    dict = {}
    s = ["".join(sorted(input())) for _ in range(n)]
    for i in range(n):
        if s[i] in dict.keys():
            dict[s[i]] += 1
        else:
            dict[s[i]] =1
    alist = list (dict.values())
    ans = 0
    for i in range(len(alist)):
        ct = alist[i]
        ans += (ct*(ct-1))//2
    print(ans)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    s = [",".join(sorted(input())) for i in range(n)]
    ans = {}
    count = 0
    for i in range(n):
        if s[i] in ans:
            count += ans[s[i]]
            ans[s[i]] += 1
        else:
            ans[s[i]] = 1
    print(count)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    dict = {}
    s = ["".join(sorted(input())) for _ in range(n)]
    for i in range(n):

        if s[i] in dict.keys():
            dict[s[i]] += 1
        else:
            dict[s[i]] =1
    ans = 0
    for i in dict.keys():
        ct = dict[i]
        ans += (ct*(ct-1))//2
    print(ans)

resolve()

Fixed submission:
def resolve():
    n = int(input())
    s = [",".join(sorted(input())) for i in range(n)]
    ans = {}
    count = 0
    for i in range(n):
        if s[i] in ans:
            count += ans[s[i]]
            ans[s[i]] += 1
        else:
            ans[s[i]] = 1
    print(count)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    dict = {}
    for i in range(n):
        s = input()
        s = sorted(s)
        s = "".join(s)
        if s in dict.keys():
            dict[s] += 1
        else:
            dict[s] =1
    ans = 0
    for i in dict.keys():

        ct = dict[i]
        ans += (ct*(ct-1))//2
    print(ans)

resolve()

Fixed submission:
def resolve():
    n = int(input())
    s = [",".join(sorted(input())) for i in range(n)]
    ans = {}
    count = 0
    for i in range(n):
        if s[i] in ans:
            count += ans[s[i]]
            ans[s[i]] += 1
        else:
            ans[s[i]] = 1
    print(count)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    import math
    a = [int(input()) for _ in range(5)]
    b = []
    for i in range(5):
        if a[i]%10 != 0:
            b.append(a[i]%10)
    if b == []
        amin = 0
    else:
        amin = min(b)
    ans = 0
    for i in range(5):
        ans += math.ceil(a[i]/10)*10
    print(ans-10+amin)

resolve()

Fixed submission:
def resolve():
    import math
    a = [int(input()) for _ in range(5)]
    b = []
    for i in range(5):
        if a[i]%10 != 0:
            b.append(a[i]%10)
    if len(b) == 0:
        amin = 10
    else:
        amin = min(b)
    ans = 0
    for i in range(5):
        ans += math.ceil(a[i]/10)*10
    print(ans-10+amin)

resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    import math
    a = [int(input()) for _ in range(5)]
    b = []
    for i in range(5):
        if a[i]%10 != 0:
            b.append(a[i]%10)
    amin = min(b)
    ans = 0
    for i in range(5):
        ans += math.ceil(a[i]/10)*10
    print(ans-10+amin)

resolve()

Fixed submission:
def resolve():
    import math
    a = [int(input()) for _ in range(5)]
    b = []
    for i in range(5):
        if a[i]%10 != 0:
            b.append(a[i]%10)
    if len(b) == 0:
        amin = 10
    else:
        amin = min(b)
    ans = 0
    for i in range(5):
        ans += math.ceil(a[i]/10)*10
    print(ans-10+amin)

resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n,q = map(int, input().split())
    s = input()
    num = [0]*n
    for i in range(n):
        if i > 0:
            if s[i-1] == "A" and s[i] == "C":
                num[i-1] = 1
                num[i] = 1
    for i in range(q):
        l,r = map(int, input().split())
        test = sum(num[l-1: r])
        if (l-1) != 0:
            if s[l-1] != "A":
                test -= 1
        if r != n:
            if s[r-1] != "C":
                test -= 1
        print(test//2)
resolve()

Fixed submission:
def resolve():
    n,q = map(int, input().split())
    s = input()
    num = [0]*n
    k = 0
    for i in range(n):
        if i > 0:
            if s[i-1] == "A" and s[i] == "C":
                k += 1
            num[i] = k
    for i in range(q):
        l,r = map(int, input().split())
        test = num[r-1]-num[l-1]
        print(test)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    import math
    a, b = map(int, input().split())
    if a == 1:
        bina = 0
    elif a == 2:
        bina = 1
    elif a == 3:
        bina = 3
    elif a%4 ==3:
        bina = a
    else:
        lowera = math.floor((a - 3) / 4) * 4 + 3
        bina = 0
        for i in range(lowera + 1, a):
            bina = bina ^ i

    if b ==1:
        binb = 1
    elif b ==2:
        binb = 3
    elif b==3:
        binb =0
    else:
        if b%4 == 3:
            binb = 0
        else:
            lowerb = math.floor((b-3)/4)*4+3
            binb = 0
        for j in range(lowerb+1, b+1):
            binb = binb^j

    print(bina^binb)
resolve()

Fixed submission:
def resolve():
    import math
    a, b = map(int, input().split())
    if a == 1:
        bina = 0
    elif a == 2:
        bina = 1
    elif a == 3:
        bina = 3
    elif a%4 ==3:
        bina = a
    else:
        lowera = math.floor((a - 3) / 4) * 4 + 3
        bina = 0
        for i in range(lowera + 1, a):
            bina = bina ^ i

    if b ==1:
        binb = 1
    elif b ==2:
        binb = 3
    elif b==3:
        binb =0
    else:
        if b%4 == 3:
            binb = 0
        else:
            lowerb = math.floor((b-3)/4)*4+3
            binb = 0
            for j in range(lowerb+1, b+1):
                binb = binb^j

    print(bina^binb)
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    import math
    a, b = map(int, input().split())
    if a == 1:
        bina = 0
    elif a == 2:
        bina = 1
    elif a == 3:
        bina = 3
    elif a%4 ==3:
        bina = a
    else:
        lowera = math.floor((a - 3) / 4) * 4 + 3
        bina = 0
        for i in range(lowera + 1, a):
            bina = bina ^ i

    if b ==1:
        binb = 1
    elif b ==2:
        binb = 3
    elif b==3:
        binb =0
    else:
        if b%4 == 3:
            binb = 0
        else:
            lowerb = math.floor((b-3)/4)*4+3
            binb = 0
        for j in range(lowerb+1, b+1):
                binb = binb^j

    print(bina^binb)
resolve()

Fixed submission:
def resolve():
    import math
    a, b = map(int, input().split())
    if a == 1:
        bina = 0
    elif a == 2:
        bina = 1
    elif a == 3:
        bina = 3
    elif a%4 ==3:
        bina = a
    else:
        lowera = math.floor((a - 3) / 4) * 4 + 3
        bina = 0
        for i in range(lowera + 1, a):
            bina = bina ^ i

    if b ==1:
        binb = 1
    elif b ==2:
        binb = 3
    elif b==3:
        binb =0
    else:
        if b%4 == 3:
            binb = 0
        else:
            lowerb = math.floor((b-3)/4)*4+3
            binb = 0
            for j in range(lowerb+1, b+1):
                binb = binb^j

    print(bina^binb)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    import heapq
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    while True:
        mini = a[0]
        for i in range(1, len(a)):
            a[i] %= mini
            if sum(a[1:]) == 0:
                print(a[0])
                exit()

        a =[i for i in a if i!= 0]
        a = sorted(a)
resolve()


Fixed submission:
def resolve():
    import heapq
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    while True:
        mini = a[0]
        others = a[1:]
        others = [x % mini for x in others]
        if sum (others) == 0:
            print(a[0])
            exit()
        a = [mini] + others
        a =[i for i in a if i!= 0]
        a = sorted(a)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    import heapq
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    while True:
        mini = a[0]
        for i in range(1, len(a)):
            a[i] %= mini
            if sum(a[1:]) == 0:
                print(a[0])
                exit()
        
        a =[i for i in a if i!= 0]
        a = sorted(a)
resolve()

Fixed submission:
def resolve():
    import heapq
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    while True:
        mini = a[0]
        others = a[1:]
        others = [x % mini for x in others]
        if sum (others) == 0:
            print(a[0])
            exit()
        a = [mini] + others
        a =[i for i in a if i!= 0]
        a = sorted(a)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    cost = [float("inf") for _ in range(n)]
    cost[0] = 0
    for i in range(n):
        for j in range(1, min(k+1, n-i)):
            cost[i+j] = min(cost[i+j], cost[i] + abs(h[i+j]-h[i]))
    print(cost[n-1])
resolve()

Fixed submission:
def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    cost = [float("inf")]*n
    cost[0] = 0
    for i in range(n):
        for j in range(1, min(k+1, n-i)):
            cost[i+j] = min(cost[i+j], cost[i] + abs(h[i+j]-h[i]))
    print(cost[n-1])
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    cost = [float("inf")]*n
    cost[0] = 0
    for i in range(n):
        for j in range(1, min(k+1, n-i)):
            cost[i+j] = min(cost[i+j], cost[i] + abs(h[i+j]-h[i]))
    print(cost[n-1])
resolve()

Fixed submission:
def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    cost = [float("inf")]*n
    cost[0] = 0
    for i in range(n):
        for j in range(1, min(k+1, n-i)):
            cost[i+j] = min(cost[i+j], cost[i] + abs(h[i+j]-h[i]))
    print(cost[n-1])
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    from collections import deque

    def checker(n):
        n = str(n)
        OK3 = False
        OK5 = False
        OK7 = False
        for i in n:
            if i == "3":
                OK3 = True
            elif i== "5":
                OK5 = True
            elif i == "7":
                OK7 = True
        if OK3 and OK5 and OK7:
            return True
        else:
            return False

    n = int(input())
    if n < 357:
        print(0)
    else:
        ans = 0
        nxt = [3, 5, 7]
        nxt = deque(nxt)
        OK = True
        while OK:
            a = nxt.popleft()
            if a > n:
                break
            nxt.append(a*10+3)
            nxt.append(a * 10 + 5)
            nxt.append(a * 10 + 7)
            if checker(a):
                ans += 1
    print(ans)
resolve()

Fixed submission:
def resolve():
    from collections import deque
    n = int(input())
    ans = 0
    num = deque([3,5,7])
    while num[0] <= n:
        test = num.popleft()
        num.append(test * 10 + 3)
        num.append(test * 10 + 5)
        num.append(test * 10 + 7)
        if list(set([int(x) for x in list(str(test))])) == [3,5,7]:
            ans += 1
    print(ans)

resolve()