Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, m, *abc = map(int, string.split())
    a = sorted(abc[:n])
    bc = sorted(list(zip(*[iter(abc[n:])] * 2)), key=lambda x: x[1])
    i = 0
    ans = 0
    for b, c in bc[::-1]:
        start = i
        while a[i] < c and b > 0:
            i += 1
            b -= 1
            ans += c
        if start == i:
            break
    ans += sum(a[i:])
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m + 1)])))


Fixed submission:
def solve(string):
    n, m, *abc = map(int, string.split())
    a = sorted(abc[:n])
    bc = sorted(list(zip(*[iter(abc[n:])] * 2)), key=lambda x: x[1])
    i = 0
    ans = 0
    for b, c in bc[::-1]:
        start = i
        while i < n and a[i] < c and b > 0:
            i += 1
            b -= 1
            ans += c
        if start == i:
            break
    ans += sum(a[i:]) if i < n else 0
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m + 1)])))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, *h = map(int, string.split())
    count = 1
    for i in range(1, n):
        if max(h[:i]) <= h[i]:
            count += 1
    return str(count)


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
def solve(string):
    n, *h = map(int, string.split())
    count = 1
    for i in range(1, n):
        if max(h[:i]) <= h[i]:
            count += 1
    return str(count)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, k, s = string.split()
    n, k = map(int, [n, k])
    s = "1" + s + "0"
    starts = [1]
    ends = []
    for i, (s0, s1) in enumerate(zip(s, s[1:])):
        if s0 == "0" and s1 == "1":
            starts.append(i + 1)
        elif s0 == "1" and s1 == "0":
            ends.append(i + 1)
    return str(max([e - s for s, e in zip(starts, ends[k:])])) if len(starts) > k else str(n)


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
def solve(string):
    n, k, s = string.split()
    n, k = map(int, [n, k])
    flip = [0]
    for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1):
        if s0 != s1:
            flip.append(i)
    flip += [n]
    return str(
        max([
            flip[min(len(flip) - 1, i + 2 * k + (i % 2 ^ int(s[0])))] - flip[i]
            for i in range(len(flip))
        ]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    a, *_, e, k = map(int, string.split())
    return "Yay!" if e - a <= k else ":("


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
def solve(string):
    a, *_, e, k = map(int, string.split())
    return "Yay!" if e - a <= k else ":("


if __name__ == '__main__':
    print(solve('\n'.join([input() for _ in range(6)])))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
return "Yes" if a==b==c else "No"

Fixed submission:
a,b,c = map(int, input().split())
ans = "Yes" if a==b==c else "No"
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans "Yes" if s.count("R") > n//2 eise "No" 
print(ans)

Fixed submission:
n=int(input())
s=input()
ans= "Yes" if s.count("R") > n//2 else "No" 
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
return "Yes" if s.count("R") > n//2 eise "No" 

Fixed submission:
n=int(input())
s=input()
ans= "Yes" if s.count("R") > n//2 else "No" 
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np


def solve(string):
    n, m, c, *ba = map(int, string.split())
    """
    b = np.asarray(ba[:m])
    a = np.asarray(ba[m:])
    a.resize((n, m))
    return str(np.sum(np.dot(a, b.T) > -c))
    """
    b = ba[:m]
    ans = 0
    for i in range(n):
        tmp = c
        for j in range(m):
            tmp += b[j] * ba[(i + 1) * n + j]
        if tmp > c:
            ans += 1
    return str(ans)


if __name__ == '__main__':
    n, m, o = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, o) + '\n'.join([input() for _ in range(n + 1)])))


Fixed submission:
import numpy as np


def solve(string):
    n, m, c, *ba = map(int, string.split())
    b = np.asarray(ba[:m])
    a = np.asarray(ba[m:])
    a.resize((n, m))
    return str(sum(np.dot(b, a.T) > -c))


if __name__ == '__main__':
    n, m, o = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, o) + '\n'.join([input() for _ in range(n + 1)])))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations, combinations


def solve(string):
    n, a, b, c, *l = map(int, string.split())
    ans = 3000
    for _l in permutations(l):
        for i, j, k in combinations(range(1, len(l) + 1), 3):
            tmp = 10 * (i - 1) + abs(a - sum(_l[:i]))
            if tmp > ans:
                continue
            tmp += 10 * (j - i - 1) + abs(b - sum(_l[i:j]))
            if tmp > ans:
                continue
            tmp += 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
            if tmp < ans:
                ans = tmp
    return str(ans)


if __name__ == '__main__':
    n, a, b, c = map(int, input().split())
    print(solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([input() for _ in range(n)])))


Fixed submission:
from itertools import permutations


def solve(string):
    n, a, b, c, *l = map(int, string.split())
    ans = 3000

    for _l in permutations(l):
        for i in range(1, len(l) - 1):
            for j in range(i + 1, len(l)):
                for k in range(j + 1, len(l) + 1):
                    tmp = 10 * (i - 1) + abs(a - sum(_l[:i])) + 10 * (j - i - 1) + abs(
                        b - sum(_l[i:j])) + 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
                    if tmp < ans:
                        ans = tmp
    return str(ans)


if __name__ == '__main__':
    n, a, b, c = map(int, input().split())
    print(solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([input() for _ in range(n)])))

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


def solve(string):
    n, a, b, c, *l = map(int, string.split())
    ans = 3000
    for _l in permutations(l):
        for i, j, k in combinations(range(1, len(l) + 1), 3):
            tmp = 10 * (i - 1) + abs(a - sum(_l[:i])) + 10 * (j - i - 1) + abs(
                b - sum(_l[i:j])) + 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
            if tmp < ans:
                ans = tmp
    return str(ans)


if __name__ == '__main__':
    n, a, b, c = map(int, input().split())
    print(solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([input() for _ in range(n)])))


Fixed submission:
from itertools import permutations


def solve(string):
    n, a, b, c, *l = map(int, string.split())
    ans = 3000

    for _l in permutations(l):
        for i in range(1, len(l) - 1):
            for j in range(i + 1, len(l)):
                for k in range(j + 1, len(l) + 1):
                    tmp = 10 * (i - 1) + abs(a - sum(_l[:i])) + 10 * (j - i - 1) + abs(
                        b - sum(_l[i:j])) + 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
                    if tmp < ans:
                        ans = tmp
    return str(ans)


if __name__ == '__main__':
    n, a, b, c = map(int, input().split())
    print(solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([input() for _ in range(n)])))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import gcd
from functools import reduce


def solve(string):
    n, *a = map(int, string.split())
    return str(reduce(gcd, a))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd
from functools import reduce


def solve(string):
    n, *a = map(int, string.split())
    return str(reduce(gcd, a))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import gcd
from functools import reduce


def solve(string):
    n, *a = map(int, string.split())
    return str(reduce(gcd, a))


if __name__ == '__main__':
    print(solve("4\n2 10 8 40"))


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd
from functools import reduce


def solve(string):
    n, *a = map(int, string.split())
    return str(reduce(gcd, a))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import gcd
from functools import reduce


def solve(string):
    n, *a = map(int, string.split())
    return str(reduce(gcd, a))


if __name__ == '__main__':
    print(solve("4\n2 10 8 40"))


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd
from functools import reduce


def solve(string):
    n, *a = map(int, string.split())
    return str(reduce(gcd, a))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    nl = map(int, string.split())
    l = sorted(list(nl)[1:])
    return "Yes" if sum(l[:-1]) > l[-1] else "No"


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
def solve(string):
    l = map(int, string.split())
    l= sorted(l)
    return "Yes" if sum(l[:len(l)-1]) > l[-1] else "No"


if __name__ == '__main__':
    input()
    print(solve(input()))

Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, *l = map(int, string.split())
    l= sorted(l)
    return "Yes" if sum(l[:-1]) > l[-1] else "No"


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
def solve(string):
    l = map(int, string.split())
    l= sorted(l)
    return "Yes" if sum(l[:len(l)-1]) > l[-1] else "No"


if __name__ == '__main__':
    input()
    print(solve(input()))

Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, *l = map(int, string.split())
    l = sorted(l)
    return "Yes" if sum(l[:-1]) > l[-1] else "No"


if __name__ == '__main__':
    print(solve("\n".join[input(), input()]))


Fixed submission:
def solve(string):
    l = map(int, string.split())
    l= sorted(l)
    return "Yes" if sum(l[:len(l)-1]) > l[-1] else "No"


if __name__ == '__main__':
    input()
    print(solve(input()))
Buggy python submission (verdict: Runtime Error):
import numpy as np
def solve(string):
    n, m, *x = map(int, string.split())
    x = np.asarray(sorted(x))
    return str(sum(sorted(np.diff(x))[:-n+1]))



if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))


Fixed submission:
import numpy as np


def solve(string):
    n, m, *x = map(int, string.split())
    x = sorted(np.diff(sorted(x)))
    return str(sum(x)) if n == 1 else str(sum(x[:-n + 1]))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, k, *a = map(int, string.split())
    if k == 0:
        x = 0
    else:
        l = len("{:b}".format(k))
        count = [0] * l
        for _a in a:
            if _a == 0:
                continue
            tmp = "{:b}".format(_a)
            for i, _f in enumerate(tmp[::-1]):
                if _f == "1":
                    count[l - i - 1] += 1
        x = int("".join(["1" if _c < n / 2 else "0" for _c in count]), 2)
    return str(sum([x ^ _a for _a in a]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Fixed submission:
def solve(string):
    n, k, *a = map(int, string.split())
    if k == 0:
        x = 0
    else:
        l = len("{:b}".format(k))
        base = [2**(l - i - 1) for i in range(l)]
        count = [0] * l
        for _a in a:
            tmp = "{:b}".format(_a)
            for i, _f in enumerate(tmp[::-1]):
                if i >= l:
                    break
                if _f == "1":
                    count[l - i - 1] += 1
        x = 0
        for _c, _b in zip(count, base):
            if _c < n / 2 and x + _b <= k:
                x += _b
    return str(sum([x ^ _a for _a in a]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, k, *a = map(int, string.split())
    if k == 0:
        x = 0
    else:
        l = len("{:b}".format(k))
        count = [0] * l
        for _a in a:
            tmp = "{:b}".format(_a)
            for i, _f in enumerate(tmp[::-1]):
                if _f == "1":
                    count[l - i - 1] += 1
        x = int("".join(["1" if _c < n / 2 else "0" for _c in count]), 2)
    return str(sum([x ^ _a for _a in a]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Fixed submission:
def solve(string):
    n, k, *a = map(int, string.split())
    if k == 0:
        x = 0
    else:
        l = len("{:b}".format(k))
        base = [2**(l - i - 1) for i in range(l)]
        count = [0] * l
        for _a in a:
            tmp = "{:b}".format(_a)
            for i, _f in enumerate(tmp[::-1]):
                if i >= l:
                    break
                if _f == "1":
                    count[l - i - 1] += 1
        x = 0
        for _c, _b in zip(count, base):
            if _c < n / 2 and x + _b <= k:
                x += _b
    return str(sum([x ^ _a for _a in a]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
 
def solve(ins):
    n, k, *h = map(int, ins.split())
    costs = [0]
    for i in range(1, n):
        cost = min(costs[-j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1))
        costs.append(cost)
    return costs[-1]
 
 
if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(ins):
    n, k, *h = map(int, ins.split())
    costs = [0]
    for i in range(1, n):
        cost = min([costs[-j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1)])
        costs.append(cost)
    return costs[-1]


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(ins):
    n, k, *h = map(int, ins.split())
    costs = [0]
    for i in range(1, n):
        cost = min([costs[-j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1)])
        costs.append(cost)
    return costs[-1]


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(ins):
    n, k, *h = map(int, ins.split())
    costs = [0]
    for i in range(1, n):
        cost = min([costs[-j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1)])
        costs.append(cost)
    return costs[-1]


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))
Buggy python submission (verdict: Runtime Error):
ef solve(string):
    n, k = map(int, string.split("\n")[0].split(" "))
    ins = list(map(int, string.split("\n")[1:]))
    ins.sort()
    return str(min([ins[i + k - 1] - ins[i] for i in range(len(ins) - k + 1)]))


if __name__ == '__main__':
    n, k = map(int, input().split(" "))
    ins = [input() for _ in range(n)]
    print(solve("{} {}\n{}".format(n, k, "\n".join(ins))))



Fixed submission:
def solve(string):
    n, k = map(int, string.split("\n")[0].split(" "))
    ins = list(map(int, string.split("\n")[1:]))
    ins.sort()
    return str(min([ins[i + k - 1] - ins[i] for i in range(len(ins) - k + 1)]))


if __name__ == '__main__':
    n, k = map(int, input().split(" "))
    ins = [input() for _ in range(n)]
    print(solve("{} {}\n{}".format(n, k, "\n".join(ins))))
Buggy python submission (verdict: Time Limit Exceeded):
def solve(string):
    h, w, k = map(int, string.split())
    c = [1, 1]
    for _ in range(1, 7):
        i, j = c[-2:]
        c.append(i + j)

    def rec(pos, depth):
        if depth == h:
            return 1 if pos == 1 else 0
        ans = rec(pos, depth + 1) * c[pos - 1] * c[w - pos]
        if pos < w:
            ans += rec(pos + 1, depth + 1) * c[pos - 1] * c[w - pos - 1]
        if pos > 1:
            ans += rec(pos - 1, depth + 1) * c[pos - 2] * c[w - pos]
        return ans

    return str(rec(k, 0) % (10**9 + 7))


if __name__ == '__main__':
    print(solve(input()))


Fixed submission:
from functools import lru_cache


def solve(string):
    h, w, k = map(int, string.split())
    c = [1, 1]
    for _ in range(1, 7):
        i, j = c[-2:]
        c.append(i + j)

    @lru_cache(h * w)
    def rec(pos, depth):
        if depth == h:
            return 1 if pos == 1 else 0
        ans = rec(pos, depth + 1) * c[pos - 1] * c[w - pos]
        if pos < w:
            ans += rec(pos + 1, depth + 1) * c[pos - 1] * c[w - pos - 1]
        if pos > 1:
            ans += rec(pos - 1, depth + 1) * c[pos - 2] * c[w - pos]
        return ans

    return str(rec(k, 0) % (10**9 + 7))


if __name__ == '__main__':
    print(solve(input()))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    flag, *ab = map(int, string.split())
    return str(sum(ab)) if flag - 1 else "Hello World"


if __name__ == '__main__':
    flag = int(input())
    if flag - 1:
        flag = "{}\n".format(flag) + "\n".join([input(), input()])
    print(solve(flag))


Fixed submission:
def solve(string):
    flag, *ab = map(int, string.split())
    return str(sum(ab)) if flag - 1 else "Hello World"


if __name__ == '__main__':
    flag = int(input())
    if flag - 1:
        flag = "{}\n".format(flag) + "\n".join([input(), input()])
    print(solve(str(flag)))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, t, *ct = map(int, string.split())
    c = [_c for _c, _t in zip(ct[::2], ct[1::2]) if _t <= t]
    return str(min(c)) if len(c) else "TLE"


if __name__ == '__main__':
    n, t = map(int, input().split())
    print(solve("{} {}\n".format(n, t) + "\n".join([input() for _ in n])))


Fixed submission:
n, t = map(int, input().split(" "))
ct = [list(map(int, input().split(" "))) for _ in range(n)]
valid = [_ct for _ct in ct if _ct[-1] <= t]
if len(valid) > 0:
    print(sorted(valid, key=lambda x: x[0])[0][0])
else:
    print("TLE")

Buggy python submission (verdict: Runtime Error):
def solve(string):
    n, t, *ct = map(int, string.split())
    c = [_c for _c, _t in zip(ct[::2], ct[1::2]) if _t <= t]
    return str(min(c)) if len(c) else "TLE"


if __name__ == '__main__':
    n, t = map(int, input())
    print(solve("{} {}\n".format(n, t) + "\n".join([input() for _ in n])))


Fixed submission:
n, t = map(int, input().split(" "))
ct = [list(map(int, input().split(" "))) for _ in range(n)]
valid = [_ct for _ct in ct if _ct[-1] <= t]
if len(valid) > 0:
    print(sorted(valid, key=lambda x: x[0])[0][0])
else:
    print("TLE")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(" "))
for i in range(m // n, 0, -1):
    if m % i == 0:
        print(i)
        break

Fixed submission:
n, m = map(int, input().split())
d = [i for i in range(1, int(m**0.5) + 1) if m % i == 0]
d.extend([m // i for i in d])
print(max([i for i in d if m // i >= n]))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(" "))
answer = 1
for p in range(m // n, 0, -1):
    if m % p == 0:
        print(p)
        break

Fixed submission:
n, m = map(int, input().split())
d = [i for i in range(1, int(m**0.5) + 1) if m % i == 0]
d.extend([m // i for i in d])
print(max([i for i in d if m // i >= n]))

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


def get_prime(num):
    upper = int(math.sqrt(num)) + 1
    checks = [True for _ in range(upper + 1)]
    primes = []
    for i in range(2, len(checks)):
        if checks[i]:
            primes.append(i)
            for j in range(i, len(checks), i):
                checks[j] = False
    return primes


n, m = map(int, input().split(" "))
answer = 1
# for p in get_prime(m):
for p in range(1, m // n + 1):
    if m % p == 0:
        answer = p
print(answer)


Fixed submission:
n, m = map(int, input().split())
d = [i for i in range(1, int(m**0.5) + 1) if m % i == 0]
d.extend([m // i for i in d])
print(max([i for i in d if m // i >= n]))
Buggy python submission (verdict: Runtime Error):
def solve(string):
    s, t = map(int, string.split())

    c_s = sorted([s.count(_c) for _c in set(s)])
    c_t = sorted([t.count(_c) for _c in set(t)])

    if c_s == c_t:
        return "Yes"
    else:
        return "No"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Fixed submission:
s = input()
t = input()

c_s = sorted([s.count(_c) for _c in set(s)])
c_t = sorted([t.count(_c) for _c in set(t)])

if c_s == c_t:
    print("Yes")
else:
    print("No")