Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    num = (10 ** 9) + 7

    for i in range(n):
        tmp = 0
        for j in range(i+1, n):
            tmp = (a[i] * a[j]) % num
            ans += tmp
    
    ans = int(ans % num)
    print(ans)
 
resolve()

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

    ans = 0
    mod = (10 ** 9) + 7
    csum = sum(a)

    for i in range(n):
        csum -= a[i]
        ans += a[i] * csum

    ans = int(ans % mod)
    print(ans)
 
resolve()

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

    ans = 0
    num = (10 ** 9) + 7
    a.sort()

    for i in range(n):
        tmp = 0
        for j in range(i+1, n):
            tmp = (a[i] * a[j]) % num
            ans += tmp
    
    ans = int(ans % num)
    print(int(ans % num))
 
resolve()

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

    ans = 0
    mod = (10 ** 9) + 7
    csum = sum(a)

    for i in range(n):
        csum -= a[i]
        ans += a[i] * csum

    ans = int(ans % mod)
    print(ans)
 
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    num = (10 ** 9) + 7
    for i in range(n):
        for j in range(i+1, n):
            ans += (a[i] * a[j]) % num
    
    ans = int(ans % num)
    print(int(ans % num))

resolve()

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

    ans = 0
    mod = (10 ** 9) + 7
    csum = sum(a)

    for i in range(n):
        csum -= a[i]
        ans += a[i] * csum

    ans = int(ans % mod)
    print(ans)
 
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import math
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


def solve(n):
    ans = 0
    for x in range(1, n + 1):
        for y in range(1, n + 1):
            z1, z2 = 0, 0
            try:
                z1 = -(y + x) + math.sqrt(-3 * x ** 2 -
                                        3 * y ** 2 - 2 * x * y + 4 * n)
                z2 = -(y + x) - math.sqrt(-3 * x ** 2 -
                                        3 * y ** 2 - 2 * x * y + 4 * n)
            except:
                pass

            if z1 >= 1 and is_integer_num(z1):
                ans += 1
                continue
            if z2 >= 1 and is_integer_num(z2):
                ans += 1
                continue

    return ans


def resolve():
    N = int(input())
    for n in range(1, N + 1):
        print(solve(n))

    return

resolve()

Fixed submission:
def resolve():
    N = int(input())
    ans = [0 for _ in range(100005)]
    for x in range(1, 105):
        for y in range(1, 105):
            for z in range(1, 105):
                tmp = x * x + y * y + z * z + x * y + y * z + z * x
                if tmp < 10005:
                    ans[tmp] += 1
    
    for i in range(1, N+1):
        print(ans[i])
    return
 
resolve()
Buggy python submission (verdict: Runtime Error):
A, B = int(input()), float(input())
print(int(A * B))


Fixed submission:
from decimal import Decimal
A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print(int(A * B))

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


Fixed submission:
from decimal import Decimal
A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print(int(A * B))
Buggy python submission (verdict: Runtime Error):
data = map(int, input().split())

main = (data[2] - date[0]) * 60 + data[3] - date[1] - data[3]

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

main = (data[2] - data[0]) * 60 + data[3] - data[1] - data[4]

print(main)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K = list(map(int, input().split()))
    if (K == 1):
        print(0)
        return
    if N % K == 0:
        print(0)
        return
    x = N
    memo = [N]
    while True:
        x = min(abs(x - K), x)
        if x in memo:
            print(min(memo))
            return
        memo.append(x)
    return


resolve()


Fixed submission:
def resolve():
    N, K = list(map(int, input().split()))
    print(min(N % K, K - (N % K)))
    return


resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K = list(map(int, input().split()))
    if (K == 1):
        print(0)
        return
    x = N
    memo = [N]
    while True:
        x = min(abs(x - K), x)
        if x in memo:
            print(min(memo))
            return
        memo.append(x)
    return

resolve()

Fixed submission:
def resolve():
    N, K = list(map(int, input().split()))
    print(min(N % K, K - (N % K)))
    return


resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    N, A, B = list(map(int, input().split()))
    line = ''
    for i in range(10 ** 100):
        if len(line) > N:
            break
        if i % 2 == 0:
            line += 'b' * A
        else:
            line += 'r' * B

    print(line[:N].count('b'))

    return


resolve()

Fixed submission:
def resolve():
    N, A, B = list(map(int, input().split()))
    ans = 0
    ans += N // (A + B) * A
    ans += min(N % (A+B), A)

    print(ans)

    return


resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    N, A, B = list(map(int, input().split()))
    line = ''
    for i in range(10 ** 100):
        if i > N:
            break
        if i % 2 == 0:
            line += 'b' * A
        else:
            line += 'r' * B

    print(line[:N].count('b'))

    return

resolve()

Fixed submission:
def resolve():
    N, A, B = list(map(int, input().split()))
    ans = 0
    ans += N // (A + B) * A
    ans += min(N % (A+B), A)

    print(ans)

    return


resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    import sys
    sys.setrecursionlimit(100000)
    H = int(input())

    def battle(n):
        if n == 1:
            return 1
        return battle(n / 2) * 2 + 1

    print(battle(H))

    return
  
resolve()

Fixed submission:
def resolve():
    import sys
    sys.setrecursionlimit(1000000)
    H = int(input())

    def battle(n):
        if n == 1:
            return 1
        return battle(n // 2) * 2 + 1

    print(battle(H))

    return


resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    H = int(input())
    depth = 0
    monster = [2 ** depth]
    depth += 1

    while True:
        monster.append(2 ** depth)

        if H % 2 == 1:
            H = (H-1)/2
        else:
            H = H / 2
        depth += 1

        if H == 1:
            break

    print(sum(monster))

    return


resolve()

Fixed submission:
def resolve():
    import sys
    sys.setrecursionlimit(1000000)
    H = int(input())

    def battle(n):
        if n == 1:
            return 1
        return battle(n // 2) * 2 + 1

    print(battle(H))

    return


resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    def is_prime(n):
      	import math
        if n == 1:
            return False
 
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
 
        return True
    X = int(input())
 
    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1
 
    return
 
resolve()

Fixed submission:
import math
def resolve():
    def is_prime(n):
        if n == 1:
            return False
 
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
 
        return True
    X = int(input())
 
    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1
 
    return
 
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    def is_prime(n):
        if n == 1:
            return False

        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False

        return True
    X = int(input())

    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1

    return

resolve()

Fixed submission:
import math
def resolve():
    def is_prime(n):
        if n == 1:
            return False
 
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
 
        return True
    X = int(input())
 
    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1
 
    return
 
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    def is_prime(n):
        if n == 1:
            return False

        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False

        return True
    X = int(input())

    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1

    return
  
  
resolve()

Fixed submission:
import math
def resolve():
    def is_prime(n):
        if n == 1:
            return False
 
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
 
        return True
    X = int(input())
 
    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1
 
    return
 
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N = int(input())
    S = str(input())
    cnt = 0

    for i in range(1000):
        c = [int(i / 100), int(i / 10) % 10, int(i % 10)]
        f = 0

        for j in range(N):
            if S[j] == ('0' + str(c[f])) or S[j] == str(c[f]):
                f += 1
            if f == 3:
                break

        if f == 3:
            cnt += 1
    print(cnt)
    return

resolve()

Fixed submission:
def resolve():
    N = int(input())
    S = str(input())
    cnt = 0

    for i in range(1000):
        c = [int(i / 100), int(i / 10) % 10, int(i % 10)]
        f = 0

        for j in range(N):
            if S[j] == ('0' + str(c[f])) or S[j] == str(c[f]):
                f += 1
            if f == 3:
                break

        if f == 3:
            cnt += 1
    print(cnt)
    return

resolve()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

def resolve():
    N = int(input())
    S = str(input())
    ans = []
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                ans.append(S[i] + S[j] + S[k])

    print(len(set(ans)))
    return

resolve()


Fixed submission:
def resolve():
    N = int(input())
    S = str(input())
    cnt = 0

    for i in range(1000):
        c = [int(i / 100), int(i / 10) % 10, int(i % 10)]
        f = 0

        for j in range(N):
            if S[j] == ('0' + str(c[f])) or S[j] == str(c[f]):
                f += 1
            if f == 3:
                break

        if f == 3:
            cnt += 1
    print(cnt)
    return

resolve()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

def resolve():
    N = int(input())
    S = str(input())
    ans = []
    for i in range(N):
        for j in range(N):
            for k in range(N):
                if i < j and j < k:
                    ans.append(S[i] + S[j] + S[k])

    print(len(set(ans)))
    return

resolve()

Fixed submission:
def resolve():
    N = int(input())
    S = str(input())
    cnt = 0

    for i in range(1000):
        c = [int(i / 100), int(i / 10) % 10, int(i % 10)]
        f = 0

        for j in range(N):
            if S[j] == ('0' + str(c[f])) or S[j] == str(c[f]):
                f += 1
            if f == 3:
                break

        if f == 3:
            cnt += 1
    print(cnt)
    return

resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    diff = 10 ** 10
    for i in range(N):
        partA = sum(A[:i])
        partB = sum(A[i:])
        diff = min(diff, abs(partA-partB))
    
    print(diff)
    return
resolve()

Fixed submission:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    diff = 10 ** 10

    partA = 0
    partB = sum(A)

    for i in range(N):
        diff = min(diff, abs(partA-partB))
        partA += A[i]
        partB -= A[i]
    print(diff)
    return
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    x, y, = [], []
    for i in range(N):
        x_tmp, y_tmp = list(map(int, input().split()))
        x.append(x_tmp)
        y.append(y_tmp)
    ans = 0
    ls = list(permutations(list(range(N)), N))
    for l in ls:
        for i in range(len(l)-1):
            ans += dist(x[l[i]], y[l[i]], x[l[i+1]], y[l[i+1]])

    print(ans / len(ls))
    return

resolve()

Fixed submission:
import math
from itertools import permutations

def dist(x0, y0, x1, y1):
    return math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2)

def resolve():
    N = int(input())
    x, y = [], []
    for _ in range(N):
        x_tmp, y_tmp = list(map(int, input().split()))
        x.append(x_tmp)
        y.append(y_tmp)

    ls = list(permutations(list(range(N)), N))
    ans = 0
    for l in ls:
        idx = 0
        while idx + 1 < len(l):
            ans += dist(x[l[idx]], y[l[idx]], x[l[idx+1]], y[l[idx+1]])
            idx += 1

    print(ans / len(ls))
    return

resolve()

Buggy python submission (verdict: Runtime Error):
def dist(x0, y0, x1, y1):
    return math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2)

def resolve():
    N = int(input())
    x, y = [], []
    for _ in range(N):
        x_tmp, y_tmp = list(map(int, input().split()))
        x.append(x_tmp)
        y.append(y_tmp)

    ls = list(permutations(list(range(N)), N))
    ans = 0
    for l in ls:
        idx = 0
        while idx + 1 < len(l):
            ans += dist(x[l[idx]], y[l[idx]], x[l[idx+1]], y[l[idx+1]])
            idx += 1

    print(ans / len(ls))
    return

resolve()

Fixed submission:
import math
from itertools import permutations

def dist(x0, y0, x1, y1):
    return math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2)

def resolve():
    N = int(input())
    x, y = [], []
    for _ in range(N):
        x_tmp, y_tmp = list(map(int, input().split()))
        x.append(x_tmp)
        y.append(y_tmp)

    ls = list(permutations(list(range(N)), N))
    ans = 0
    for l in ls:
        idx = 0
        while idx + 1 < len(l):
            ans += dist(x[l[idx]], y[l[idx]], x[l[idx+1]], y[l[idx+1]])
            idx += 1

    print(ans / len(ls))
    return

resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    for i in range(N):
        if K + A.count(i+1) - Q > 0:
            print('Yes')
        else:
            print('No')

    return


resolve()

Fixed submission:
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [0] * N
    for i in range(Q):
        points[A[i]-1] += 1

    for i in range(N):
        if K + points[i] - Q > 0:
            print('Yes')
        else:
            print('No')

    return

resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [K] * N
    for i in range(N):
        points[i] += A.count(i+1) - Q
        if points[i] > 0:
            print('Yes')
        else:
            print('No')

    return


resolve()

Fixed submission:
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [0] * N
    for i in range(Q):
        points[A[i]-1] += 1

    for i in range(N):
        if K + points[i] - Q > 0:
            print('Yes')
        else:
            print('No')

    return

resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [K] * N
    for i in range(N):
        points[i] += A.count(i+1)
        points[i] -= Q
        if points[i] > 0:
            print('Yes')
        else:
            print('No')

    return


resolve()

Fixed submission:
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [0] * N
    for i in range(Q):
        points[A[i]-1] += 1

    for i in range(N):
        if K + points[i] - Q > 0:
            print('Yes')
        else:
            print('No')

    return

resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [K] * N
    for i in range(N):
        points[i] += A.count(i+1)

    points = list(map(lambda x: x - Q, points))

    for i in points:
        if i > 0:
            print('Yes')
        else:
            print('No')
    return

resolve()

Fixed submission:
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [0] * N
    for i in range(Q):
        points[A[i]-1] += 1

    for i in range(N):
        if K + points[i] - Q > 0:
            print('Yes')
        else:
            print('No')

    return

resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    for i in range(N):
        if max(A) > A[i]:
            print(max(A))
        elif max(A) == A[i]:
            if A.count(max(A)) >= 2:
                print(max(A))
            else:
                print(B[-2])
    return

resolve()

Fixed submission:
def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    mx = max(A)
    count = A.count(mx)

    for i in range(N):
        if mx > A[i]:
            print(mx)
        elif mx == A[i]:
            if count >= 2:
                print(mx)
            else:
                print(B[-2])
    return


resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    for i in range(N):
        if max(A) > A[i]:
            print(max(A))
        elif max(A) == A[i]:
            if A.count(max(A)) >= 2:
                print(max(A))
            else:
                print(B[-2])
    return

resolve()

Fixed submission:
def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    mx = max(A)
    count = A.count(mx)

    for i in range(N):
        if mx > A[i]:
            print(mx)
        elif mx == A[i]:
            if count >= 2:
                print(mx)
            else:
                print(B[-2])
    return


resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, M = list(map(int, input().split()))
    interval = []
    for i in range(M):
        L, R = list(map(int, input().split()))
        interval.append(list(range(L, R + 1)))
    # print(interval)
    interval = [set(l) for l in interval]
    interval = set.intersection(*interval)

    print(len(set(range(1, N + 1)) & interval))

    return


resolve()

Fixed submission:
def resolve():
    N, M = list(map(int, input().split()))
    interval = []
    l, r = 0, 10**5
    for i in range(M):
        L, R = list(map(int, input().split()))
        l = max(l, L)
        r = min(r, R)

    interval = set(list(range(l, r + 1)))
    interval = interval & set(range(1, N + 1))

    print(len(interval))

    return


resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    S = str(input())
    ans = 0

    while True:
        tmp1 = S.count('01')
        ans += tmp1 * 2
        S = S.replace('01', '')

        tmp2 = S.count('10')
        ans += tmp2*2
        S = S.replace('10', '')

        if tmp1 == 0 and tmp2 == 0:
            break

    print(ans)
    return
resolve()

Fixed submission:
def resolve():
    S = str(input())
    ans = 2 * min(S.count('1'), S.count('0'))

    print(ans)
    return
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    S = str(input())
    ans = 0

    while True:
        tmp1 = S.count('01')
        ans += tmp1 * 2
        S = S.replace('01', '')

        tmp2 = S.count('10')
        ans += tmp2*2
        S = S.replace('10', '')

        if tmp1 == 0 and tmp2 == 0:
            break

    print(ans)
    return
resolve()

Fixed submission:
def resolve():
    S = str(input())
    ans = 2 * min(S.count('1'), S.count('0'))

    print(ans)
    return
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    s = str(input())
    ans = 0
    while True:
        origin = s
        cnt = s.count('BW')
        s = s.replace('BW', 'WB')
        if origin == s:
            break
        ans += cnt
    print(ans)

    return
resolve()

Fixed submission:
def resolve():
    s = str(input())
    ans = 0
    ind = []
    for i, char in enumerate(s):
        if char == 'W':
            ind.append(i)
    lst = 0
    # print(ind)
    for i in ind:
        ans += (i - lst)
        lst += 1

    # idx = s.index('W')
    print(ans)
    return


resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    s = str(input())
    ans = 0
    while True:
        origin = s
        s = s.replace('BW', 'WB', 1)
        if origin == s:
            break
        ans += 1
    print(ans)

    return
resolve()

Fixed submission:
def resolve():
    s = str(input())
    ans = 0
    ind = []
    for i, char in enumerate(s):
        if char == 'W':
            ind.append(i)
    lst = 0
    # print(ind)
    for i in ind:
        ans += (i - lst)
        lst += 1

    # idx = s.index('W')
    print(ans)
    return


resolve()