Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

import sys

line = sys.stdin.readline().strip()
n = int(line)
parts = sys.stdin.readline().strip().split()
nvals = map(int,parts)

line = sys.stdin.readline().strip()
m = int(line)
parts = sys.stdin.readline().strip().split()
mvals = map(int,parts)

for item in mvals:
    if item in nvals:
        nvals.remove(item)
    else:
        print "NO"
        sys.exit()

print "YES"

    

Fixed submission:
#!/usr/bin/env python

import sys

line = sys.stdin.readline().strip()
n = int(line)
parts = sys.stdin.readline().strip().split()
nvals = map(int,parts)
nhash = {}

for item in nvals:
    if nhash.has_key(item):
        nhash[item] += 1
    else:
        nhash[item] = 1

line = sys.stdin.readline().strip()
m = int(line)
parts = sys.stdin.readline().strip().split()
mvals = map(int,parts)
mhash = {}

for item in mvals:
    if mhash.has_key(item):
        mhash[item] += 1
    else:
        mhash[item] = 1

for item in mhash.keys():
    if nhash.has_key(item) and mhash[item] <= nhash[item]:
        pass
    else:
        print "NO"
        sys.exit()

print "YES"
Buggy python submission (verdict: Runtime Error):
import fileinput
s = fileinput.input().strip()
if len(s)>=4 and s[:4] == 'YAKI':
    print("Yes")
else:
    print("No")

Fixed submission:
s = input()
if len(s)>=4 and s[:4] == 'YAKI':
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import fileinput
s = fileinput.input().strip()
print(len(s)>=4 and s[:3] == 'YAKI')

Fixed submission:
s = input()
if len(s)>=4 and s[:4] == 'YAKI':
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N,M,K = map(int,input().strip().split())
def judge(N,M,K):
    if K > N * M or K < 0:
        return False
    for n in range(0, N + 1):
        for m in range(0, M + 1):
            if n * M + m * N - m * n == K or:
                return True
    return False
if judge(N, M, K):
    print("Yes")
else:
    print("No")

Fixed submission:
N,M,K = map(int,input().strip().split())
def judge(N,M,K):
    if K > N * M or K < 0:
        return False
    for n in range(0, N + 1):
        for m in range(0, M + 1):
            if n * M + m * N - 2*m * n == K:
                return True
    return False
if judge(N, M, K):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys

n = int(sys.stdin().strip())

result = str(int(n * (n + 1) / 2))

sys.stdout()

Fixed submission:
from sys import stdin, stdout

n = int(stdin.read().strip())

result = str(int(n * (n + 1) / 2))

stdout.write(result)
Buggy python submission (verdict: Runtime Error):
import math

def is_prime(q):
    if q == 2:
        return (True, 0)
    if q < 2:
        return (False, 1)
    if q&1 == 0:
        return (False, 2)

    i = 3
    end = int(math.sqrt(q))
    while i <= end:
        if q%i is 0:
            return (False, i)
        i += 2
    return (True, 0)

def split22(n, k):
	if n % k != 0:
		return None
	ml = int(n / k)
	ret = is_prime(ml)
	if ret[0] is True:
		return None
	return (int(n/2), int(ret[1]), int(ml/ret[1]))

def split13(n):
	# n = (3 - m) * l
	if n&1 == 0:
		l = n / 2
		if math.gcd(l, 2) == n:
			return (n, l, 2)
	# l^2 - 3l + n = 0
	tmp = 3**2 - 4 * n
	if tmp < 0:
		return None
	_x = math.sqrt(tmp)
	if _x - int(_x) == _x:
		x = (-1) * _x - b
		if x > 0:
			x = _x - b
		return (n, x, 3-x)
	return None

n = int(input())
ans = None

ans = split13(n)
k = 1
while ans is None:
	if n&1 == 0:
		ans = split22(n, k)
	n *= 2
	k *= 2

print(" ".join(map(str, ans)))


Fixed submission:
n = int(input())
ans = None
for i in range(1, 3501, 1):
	for j in range(1, 3501, 1):
		dominator = 4 * i * j - n * (i + j)
		if dominator > 0:
			numerator = i * j * n
			if numerator % dominator == 0:
				ans = (i, j, int(numerator / dominator))
				break
	if ans is not None:
		break
print(" ".join(map(str, ans)))
Buggy python submission (verdict: Time Limit Exceeded):
q, h, s, d = map(int, input().split())
n = int(input())

ans = 10 ** 9

i_max = int(n / 0.25)
for i in range(i_max+1):
	j_max = int((n - 0.25 * i)/0.5)
	for j in range(j_max+1):
		k_max = int((n - 0.25 * i - 0.5 * j))
		for k in range(k_max+1):
			l_max = int((n - 0.25 * i - 0.5 * j - k))
			for l in range(l_max+1):
				_n = 0.25 * i + 0.5 * j + k + 2 * l
				if _n != n:
					continue
				_sum = i * q + j * h + k * s + d * l
				ans = min(ans, _sum)
print(ans)


Fixed submission:
q, h, s, d = map(int, input().split())
n = int(input())
print(int(n/2) * min(q*8, h*4, s*2, d) + (n%2) * min(q*4, h*2, s))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
d = {}
d[s] = 1
for i in range(n-1):
	for j in range(i+2, n+1):
		_s = ''
		if i > 0:
			_s += s[:i]
		tmp = s[i:j]
		_s += tmp[::-1]
		_s += s[j:]
		#print(i, j, tmp, _s)
		if _s in d:
			continue
		d[_s] = 1
print(len(d.items()))


Fixed submission:
s = input()
n = len(s)
ans = n * (n - 1) / 2 + 1
c_list = [0 for _ in range(26)]
for c in s:
	c_list[ord(c) - ord('a')] += 1

delta = 0
for i in c_list:
	if i > 0:
		delta += i * (i - 1) / 2
print(int(ans - delta))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    return (N,)


def solve(N):
    ans = []
    for h in range(1, 3501):
        flag = False
        for n in range(1, 3501):
            w = (N * h * n) / (4 * h * n - N * h - N * n)
            if w > 0 and int(w) == w:
                ans = [h, n, w]
                flag = True
                break
        if flag:
            break
    ans = " ".join(map(str, map(int, ans)))
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Fixed submission:
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    return (N,)


def solve(N):
    ans = []
    for h in range(1, 3501):
        flag = False
        for n in range(1, 3501):
            if 4 * h * n - N * h - N * n == 0:
                continue
            div, mod = divmod(N * h * n, 4 * h * n - N * h - N * n)
            if mod == 0 and div > 0:
                ans = [h, n, div]
                flag = True
                break
        if flag:
            break
    ans = " ".join(map(str, ans))
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    return (N,)


def solve(N):
    ans = []
    for h in range(1, 3501):
        flag = False
        for n in range(1, 3501):
            w = (4 * h * n - N * h - N * n) / (N * h * n)
            if w > 0 and int(w) == w:
                ans = [h, n, w]
                flag = True
                break
        if flag:
            break
    ans = " ".join(map(str, map(int, ans)))
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Fixed submission:
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    return (N,)


def solve(N):
    ans = []
    for h in range(1, 3501):
        flag = False
        for n in range(1, 3501):
            if 4 * h * n - N * h - N * n == 0:
                continue
            div, mod = divmod(N * h * n, 4 * h * n - N * h - N * n)
            if mod == 0 and div > 0:
                ans = [h, n, div]
                flag = True
                break
        if flag:
            break
    ans = " ".join(map(str, ans))
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
from collections import defaultdict
from itertools import combinations

def main():
    A = str(input())
    set_all = set()
    set_all.add(A)
    for i in range(2, len(A) + 1):
        for j in range(len(A) - i + 1):
            _i, _j = j, i + j - 1
            if _i == 0:
                a = A[_j::-1] + A[_j + 1:]
            else:
                a = A[:_i] + A[_j:_i - 1:-1] + A[_j + 1:]
            if a in set_all:
                continue
                # print(_i, _j)
                # print(a)
            else:
                set_all.add(a)
    print(len(set_all))



if __name__ == "__main__":
    main()


Fixed submission:
# coding: utf-8
from collections import defaultdict
import math

def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n - r)


def main():
    A = str(input())
    d_ind = defaultdict(list)
    for ind, a in enumerate(A):
        d_ind[a].append(ind)
    ans = 1 + sum(range(len(A)))
    for ind in d_ind.values():
        if len(ind) == 1:
            continue
        ans -= nCr(len(ind), 2)
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
6
2 7 1 8 2 8

Fixed submission:
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    a = ILI()
    return N, a


def solve(N, a):
    n_odd = 0
    n_div_2 = 0
    n_div_4 = 0
    for _a in a:
        if _a % 2 == 1:
            n_odd += 1
        else:
            if _a % 4 == 0:
                n_div_4 += 1
            else:
                n_div_2 += 1

    ans = ""
    if n_div_2 == 0:
        if n_div_4 >= n_odd - 1:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if n_div_4 >= n_odd:
            ans = "Yes"
        else:
            ans = "No"

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())


def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    a = ILI()
    return (N, a)


def check_a(N, a):
    for i, _a in enumerate(a):
        if _a >= N:
            return i
    return -1


def solve(N, a):
    ans = 0
    while True:
        ret_ind = check_a(N, a)
        if ret_ind == -1:
            break
        div, mod = divmod(a[ret_ind], N)
        for i in range(N):
            if i == ret_ind:
                a[i] = mod
                continue
            a[i] += div
        ans += div

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Fixed submission:
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())


def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    a = ILI()
    return (N, a)


def check_a(N, a):
    for _a in a:
        if _a >= N:
            return False
    return True


def solve(N, a):
    ans = 0
    while True:
        if check_a(N, a):
            break

        l_div, l_mod = [None] * N, [None] * N
        for i, _a in enumerate(a):
            l_div[i], l_mod[i] = divmod(_a, N)

        sum_div = sum(l_div)
        for i in range(N):
            a[i] = l_mod[i] + sum_div - l_div[i]

        ans += sum_div

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(int, input().split()))
b = collections.deque(list)
if n % 2 == 0:
    for i, ele in enumerate(a):
        if i % 2 == 0:
            b.append(ele)
        else:
            b.appendleft(ele)
else:
    for i, ele in enumerate(a):
        if i % 2 == 0:
            b.appendleft(ele)
        else:
            b.append(ele)

print(" ".join(b))

Fixed submission:
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    n = II()
    a = list(map(str, input().split()))
    return n, a


def solve(n, a):
    b = collections.deque([])
    if n % 2 == 0:
        for i, ele in enumerate(a):
            if i % 2 == 0:
                b.append(ele)
            else:
                b.appendleft(ele)
    else:
        for i, ele in enumerate(a):
            if i % 2 == 0:
                b.appendleft(ele)
            else:
                b.append(ele)

    ans = " ".join(list(b))
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N, A, B = ILI()
    h = [II() for __ in range(N)]
    return (N, A, B, h)


def solve(N, A, B, h):
    mons = []
    for i in h:
        heapq.heappush(mons, -i)
    dif_ab = A - B
    count = 0
    while True:
        mons_max = -heapq.heappop(mons)
        if mons_max <= count * B:
            ans = count
            break
        else:
            heapq.heappush(mons, -(mons_max - dif_ab))
            count += 1

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Fixed submission:
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N, A, B = ILI()
    h = [II() for __ in range(N)]
    return (N, A, B, h)


def bool_exc(h, dif_ab, B, count):
    dif_count = 0
    for mon in h:
        dif_mon = mon - B * count
        if dif_mon <= 0:
            continue
        else:
            dif_count += math.ceil(dif_mon / dif_ab)
            if dif_count > count:
                break

    dif = count - dif_count
    return dif


def solve(N, A, B, h):
    right = max(h) // B + 1
    left = min(h) // A + 1
    dif_ab = A - B
    while left != right:
        mid = (left + right) // 2
        dif = bool_exc(h, dif_ab, B, mid)
        if dif >= 0:
            right = mid
        else:
            left = mid + 1

    ans = left
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N = II()
    a = ILI()
    return (N, a)


def solve(N, a):
    a_lef = a[0: N]
    a_rig = [-i for i in a[2 * N: 3 * N]]
    heapq.heapify(a_lef)
    heapq.heapify(a_rig)
    sum_lef = sum(a_lef)
    sum_rig = sum(a_rig)
    l_sum_lef = [sum_lef]
    l_sum_rig = [sum_rig]
    
    for i in range(1, N + 1):
        heapq.heappush(a_lef, a[N - 1 + i])
        lef_pop = heapq.heappop(a_lef)
        sum_lef += a[N - 1 + i] - lef_pop
        l_sum_lef.append(sum_lef)
        
        heapq.heappush(a_rig, -a[2 * N - i])
        rig_pop = heapq.heappop(a_rig)
        sum_rig += -a[2 * N - i] - rig_pop
        l_sum_rig.append(sum_rig)

    ans = -INF

    for i in range(N + 1):
        num_dif = l_sum_lef[i] + l_sum_rig[N - i]
        ans = max(ans, num_dif)

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Fixed submission:
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    H, W = ILI()
    return (H, W)

def solve(H, W):
    ans = INF
    
    if H % 3 == 0 or W % 3 == 0:
        return 0
    else:
        ans = min(ans, H, W)

    if W % 2 == 0:
        for h in range(1, H):
            num_1 = h * W
            num_2 = (H - h) * W // 2
            ans = min(ans, abs(num_1 - num_2))
    else:
        for h in range(1, H):
            num_1 = h * W
            num_2 = (H - h) * (W // 2)
            num_3 = (H - h) * (W // 2 + 1)
            nums = sorted([num_1, num_2, num_3])
            ans = min(ans, (nums[2] - nums[0]))

    if H % 2 == 0:
        for w in range(1, W):
            num_1 = w * H
            num_2 = (W - w) * H // 2
            ans = min(ans, abs(num_1 - num_2))
    else:
        for w in range(1, W):
            num_1 = w * H
            num_2 = (W - w) * (H // 2)
            num_3 = (W - w) * (H // 2 + 1)
            nums = sorted([num_1, num_2, num_3])
            ans = min(ans, (nums[2] - nums[0]))
    
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

num_N = int(input())

min_num = math.inf
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(int(num_N / i)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

Fixed submission:
# coding: utf-8
import math

num_N = int(input())

min_num = 999999
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(int(num_N / i)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

num_N = int(input())

min_num = math.inf
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(num_N // i))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

Fixed submission:
# coding: utf-8
import math

num_N = int(input())

min_num = 999999
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(int(num_N / i)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

num_N = int(input())

min_num = math.inf

for i in range(1, math.floor(math.sqrt(num_N)) + 1):
    if num_N % i == 0:
        num_A = i
        num_B = int(num_N // i)
        len_num_A = len(list(str(num_A)))
        len_num_B = len(list(str(num_B)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

Fixed submission:
# coding: utf-8
import math

num_N = int(input())

min_num = 999999
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(int(num_N / i)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
num = int(input())


def make_sum(ind):
    return sum(range(1, ind + 1))

ans = 0

if num == 1:
    print(1)
else:
    while True:
        ans += 1
        if make_sum(ans) < num <= make_sum(ans + 1):
            break

    print(ans + 1)

Fixed submission:
# coding: utf-8
num = int(input())


# def make_sum(ind):
#     return sum(range(1, ind + 1))

ans = 0
sum_num = 0

if num == 1:
    print(1)
else:
    while True:
        ans += 1
        sum_num += ans
        if sum_num < num <= (sum_num + ans + 1):
            break

    print(ans + 1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
num = int(input())


def make_sum(ind):
    num_sum = 0
    for i in range(1, ind + 1):
        num_sum += i
    return num_sum

ans = 0

if num == 1:
    print(1)
else:
    while True:
        ans += 1
        if make_sum(ans) < num <= make_sum(ans + 1):
            break

    print(ans + 1)

Fixed submission:
# coding: utf-8
num = int(input())


# def make_sum(ind):
#     return sum(range(1, ind + 1))

ans = 0
sum_num = 0

if num == 1:
    print(1)
else:
    while True:
        ans += 1
        sum_num += ans
        if sum_num < num <= (sum_num + ans + 1):
            break

    print(ans + 1)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

num = int(input())
l_cre = list(map(int, input().split()))
l_cre.sort()

counter = 0

for ind, cre in enumerate(l_cre):
    now_size = 0
    now_size += sum(l_cre[:(ind + 1)])
    rest_cre = len(l_cre) - ind - 1

    while True:
        if (ind + 1) == len(l_cre):
            counter += 1
            break

        ind += 1
        if (now_size * 2) >= l_cre[ind]:
            now_size += l_cre[ind]
            continue
        else:
            break

print(counter)

Fixed submission:
# coding: utf-8

num = int(input())
l_cre = list(map(int, input().split()))
l_cre.sort()

counter = 0
now_size = 0

for i in range(len(l_cre) - 1):
    now_size += l_cre[i]
    if now_size * 2 >= l_cre[i + 1]:
        counter += 1
    else:
        counter = 0

counter += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
N = input()
N = float(N)
result = 4/N
 
def output2():
    for i in range(3500):
        for j in range(3500):
            h = float(i+1)
            n = float(j+1)
            
            sum_ = 1/h + 1/n
            
            sum2 = result - sum_
            
            if(sum2 <= 0):
                continue
            
            w =  1/sum2
            
            if(w == int(w)):
                return('{} {} {}'.format(int(h),int(n),int(w)))
 
print(output2())

Fixed submission:
N = raw_input()
print(N.count('1'))