Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
N, W = map(int, input().split())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
g = math.gcd(W, A[0][0]) 
for a in range(1, N):
	g = math.gcd(g, A[a][0])
W = W//g 
# print(g)
dp = [[0 for w in range(W+1)] for n in range(N+1)]
for i in range(W+1):
	dp[0][i] = 0
for p in range(1, N+1):
	for q in range(W+1):
		dp[p][q] = dp[p-1][q]
		if ((A[p-1][0]//g) <= q):
			dp[p][q] = max(dp[p][q], dp[p-1][q - (A[p-1][0]//g)] + A[p-1][1])
# print(dp)
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
inf = 10**10
V = 0
for a in range(N):
	V += A[a][1]
dp = [inf for v in range(V+1)]
dp[0] = 0
for p in range(N):
	for q in range(V - A[p][1], -1, -1):
		dp[q + A[p][1]] = min(dp[q + A[p][1]], dp[q] + A[p][0])
# print(dp)
ans = 0
for b in range(V+1):
	if (dp[b] <= W):
		ans = b
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N, W = map(int, input().split())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
g = math.gcd(W, A[0][0]) 
for a in range(1, N):
	g = math.gcd(g, A[a][0])
W = W//g 
# print(g)
dp = [[0 for w in range(W+1)] for n in range(N+1)]
for i in range(W+1):
	dp[0][i] = 0
for p in range(1, N+1):
	for q in range(W+1):
		dp[p][q] = dp[p-1][q]
		if (A[p-1][0]//g <= q):
			dp[p][q] = max(dp[p][q], dp[p-1][q - (A[p-1][0]//g)] + A[p-1][1])
# print(dp)
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
inf = 10**10
V = 0
for a in range(N):
	V += A[a][1]
dp = [inf for v in range(V+1)]
dp[0] = 0
for p in range(N):
	for q in range(V - A[p][1], -1, -1):
		dp[q + A[p][1]] = min(dp[q + A[p][1]], dp[q] + A[p][0])
# print(dp)
ans = 0
for b in range(V+1):
	if (dp[b] <= W):
		ans = b
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()
dp = [[-1 for i in range(len(S)+1)] for j in range(len(T)+1)]
sub = [["" for i in range(len(S)+1)] for j in range(len(T)+1)]
for a in range(len(S)+1):
	dp[0][a] = 0
for b in range(len(T)+1):
	dp[b][0] = 0
for p in range(1, len(T)+1):
	for q in range(1, len(S)+1):
		if T[p-1] == S[q-1]:
			dp[p][q] = 1 + dp[p-1][q-1]
			sub[p][q] = sub[p-1][q-1] + T[p-1]
		else:
			if dp[p-1][q] > dp[p][q-1]:
				dp[p][q] = dp[p-1][q]
				sub[p][q] = sub[p-1][q]
			else:
				dp[p][q] = dp[p][q-1]
				sub[p][q] = sub[p][q-1]
print(sub[len(T)][len(S)])

Fixed submission:
S = input()
T = input()
dp = [[-1 for i in range(len(S)+1)] for j in range(len(T)+1)]
sub = [["" for i in range(len(S)+1)] for j in range(len(T)+1)]
for a in range(len(S)+1):
	dp[0][a] = 0
for b in range(len(T)+1):
	dp[b][0] = 0
for p in range(1, len(T)+1):
	for q in range(1, len(S)+1):
		if T[p-1] == S[q-1]:
			dp[p][q] = 1 + dp[p-1][q-1]
			sub[p][q] = "c"
		else:
			if dp[p-1][q] > dp[p][q-1]:
				dp[p][q] = dp[p-1][q]
				sub[p][q] = "u"
			else:
				dp[p][q] = dp[p][q-1]
				sub[p][q] = "l"
t = len(T)
s = len(S)
out = ""
while sub[t][s] != "":
	if sub[t][s] == "c":
		out = S[s-1] + out
		t -= 1
		s -= 1
	elif sub[t][s] == "u":
		t -= 1
	else:
		s -= 1
print(out)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
ans = []
for x in range(1, math.ceil(n**(1/2))+1):
    for y in range(1, math.ceil(n**(1/2))+1):
        for z in range(1, math.ceil(n**(1/2))+1):
            ans.append(x**2 + y**2 + z**2 + x*y + y*z + z*x)
ans.sort()
for i in range(1, n+1):
    tmp = 0
    for x in ans:
        if x == i:
            tmp += 1
        elif x > i:
            print(tmp)
            break

Fixed submission:
L, R, d = map(int, input().split())
ans = 0
for x in range(L, R+1):
    if x % d == 0:
        ans += 1

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

n = int(input())
ans = []
for x in range(1, math.ceil(n**(1/2))+1):
    for y in range(1, math.ceil(n**(1/2))+1):
        for z in range(1, math.ceil(n**(1/2))+1):
            ans.append(x**2 + y**2 + z**2 + x*y + y*z + z*x)
ans.sort()
for i in range(1, n+1):
    tmp = 0
    for x in ans:
        if x == i:
            tmp += 1
        elif x > i:
            print(tmp)
            break

Fixed submission:
import math

n = int(input())
ans = []
for x in range(1, math.ceil(n**(1/2))+1):
    for y in range(1, math.ceil(n**(1/2))+1):
        for z in range(1, math.ceil(n**(1/2))+1):
            ans.append(x**2 + y**2 + z**2 + x*y + y*z + z*x)
ans.sort()
for i in range(1, n+1):
    tmp = 0
    for x in ans:
        if x == i:
            tmp += 1
        elif x > i:
            print(tmp)
            break
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = sorted([int(x) for x in input().split()])
if A[0] == 1:
    if N == 1:
        print(1)
        exit()
    elif A[1] == 1:
        print(0)
        exit()
    print(1)
    exit()
cA = Counter(A)

cand = set()
ans = 0
for a, val in cA.items():
    if len(cand) != 0 and val == 1:
        for t in cand:
            if a % t == 0:
                break
        else:
            #print(a)
            cand.add(a)
            ans += 1
    elif val == 1:
        #print(a)
        cand.add(a)
        ans += 1
    else:
        continue
print(ans)


Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
count = [0 for _ in range(10**6+10)]
for a in A:
    if count[a] > 1:
        continue
    for x in range(0, 10**6+10, a):
        count[x] += 1
ans = 0
for a in A:
    if count[a] == 1:
        ans += count[a]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split()]
ans = 1
for x in A:
    ans *= x
if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
if 0 in A:
    print(0)
    exit()
ans = 1
for x in A:
    ans *= x
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
A = [0]*N
B = [0]*N
i = 0
for line in readlines():
    A[i], B[i] = map(int, line.rstrip().decode('utf-8').split())
    i+=1
sA = sorted(A)
sB = sorted(B)
if N % 2 == 0:
    ans = ((sB[(N//2)-1]+sB[(N//2)]) - (sA[(N//2)-1]+sA[(N//2)])) + 1
else:
    ans = (sB[(N-1)//2]-sA[(N-1)//2]) + 1
print(ans)


Fixed submission:
N = int(input())
A = [0]*N
B = [0]*N
i = 0
for i in range(N):
    A[i], B[i] = map(int, input().split())
sA = sorted(A)
sB = sorted(B)
if N % 2 == 0:
    ans = ((sB[(N//2)-1]+sB[(N//2)]) - (sA[(N//2)-1]+sA[(N//2)])) + 1
else:
    ans = (sB[(N-1)//2]-sA[(N-1)//2]) + 1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
a, b = input().split()
A = int(a)
B = float(b)
print(int(A*B))


Fixed submission:
N = int(input())
A = [0]*N
B = [0]*N
i = 0
for i in range(N):
    A[i], B[i] = map(int, input().split())
sA = sorted(A)
sB = sorted(B)
if N % 2 == 0:
    ans = ((sB[(N//2)-1]+sB[(N//2)]) - (sA[(N//2)-1]+sA[(N//2)])) + 1
else:
    ans = (sB[(N-1)//2]-sA[(N-1)//2]) + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
FB = [0]*N
for i in range(1,N+1):
    if i % 3 != 0 and i % 5 != 0:
        FB[i] = i

print(sum(FB))

Fixed submission:
N = int(input())
FB = [0]*N
for i in range(1,N+1):
    if i % 3 != 0 and i % 5 != 0:
        FB[i-1] = i

print(sum(FB))
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
sumgcd = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            sumgcd += math.gcd(math.gcd(a, b), c)
print(sumgcd)


Fixed submission:
import math
K = int(input())
sumgcd = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            sumgcd += math.gcd(math.gcd(a, b), c)
print(sumgcd)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 21:08:11 2020

@author: azikausy
"""


from scipy.special import comb
n, m = map(int, input().split())
print(int(comb(n,2)+comb(m,2)))

Fixed submission:
from scipy.misc import comb
n, m = map(int, input().split())
print(comb(n, 2, exact=True)+comb(m, 2, exact=True))
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb

N = int(input())
temp = input().split()
A = {}
for i in range(0, N):
    A[i] = temp[i]

B = {}
for i in range(0, N):
    if not(A[i] in B.keys()):
        B[A[i]] = 1
    else:
        B[A[i]] += 1 

for i in range(0, N):
    B[A[i]] -= 1
    S = 0    
    for value2 in B.values():
        S = S + comb(int(value2), 2, exact=True)
    print(S)
    B[A[i]] += 1

Fixed submission:
from scipy.misc import comb

N = int(input())
A = input().split()

B = {}
for i in range(0, N):
    if not(A[i] in B.keys()):
        B[A[i]] = 1
    else:
        B[A[i]] += 1 

S = 0
for value2 in B.values():
    S = S + comb(int(value2), 2, exact=True)

S0 = 0
for i in range(0, N):
    S0 = S - (comb(int(B[A[i]]), 2, exact=True) - comb(int(B[A[i]])-1, 2, exact=True))
    print(S0)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

N = int(input())
temp = input().split()
A = {}
for i in range(0, N):
    A[i] = temp[i]

B = {}
for i in range(0, N):
    if not(A[i] in B.keys()):
        B[A[i]] = 1
    else:
        B[A[i]] += 1 

for i in range(0, N):
    B[A[i]] -= 1
    S = 0    
    for value2 in B.values():
        S = S + comb(int(value2), 2, exact=True)
    print(S)
    B[A[i]] += 1

Fixed submission:
from scipy.misc import comb

N = int(input())
A = input().split()

B = {}
for i in range(0, N):
    if not(A[i] in B.keys()):
        B[A[i]] = 1
    else:
        B[A[i]] += 1 

S = 0
for value2 in B.values():
    S = S + comb(int(value2), 2, exact=True)

S0 = 0
for i in range(0, N):
    S0 = S - (comb(int(B[A[i]]), 2, exact=True) - comb(int(B[A[i]])-1, 2, exact=True))
    print(S0)

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb

N = int(input())
A = input().split()
B = {}
for i in range(0, N):
    if not(A[i] in B.keys()):
        B[A[i]] = 1
    else:
        B[A[i]] += 1 

for i in range(0, N):
    B[A[i]] -= 1
    S = 0    
    for value2 in B.values():
        S = S + comb(int(value2), 2, exact=True)
    print(S)
    B[A[i]] += 1

Fixed submission:
from scipy.misc import comb

N = int(input())
A = input().split()

B = {}
for i in range(0, N):
    if not(A[i] in B.keys()):
        B[A[i]] = 1
    else:
        B[A[i]] += 1 

S = 0
for value2 in B.values():
    S = S + comb(int(value2), 2, exact=True)

S0 = 0
for i in range(0, N):
    S0 = S - (comb(int(B[A[i]]), 2, exact=True) - comb(int(B[A[i]])-1, 2, exact=True))
    print(S0)
Buggy python submission (verdict: Runtime Error):
num = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(num[a])


Fixed submission:
num = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(num[a-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = 0
wa_max = 0.0
wa_temp = [sum(P[i:i+K]) for i in range(N-K+1)]
print(max(wa_temp))


Fixed submission:
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = sum(P[0:K])
max_wa = wa_temp

for i in range(N-K):
    wa_temp = wa_temp - P[i] + P[i+K]
    if wa_temp > max_wa:
        max_wa = wa_temp
print(max_wa)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = 0
wa_max = 0.0
wa_temp = [sum(P[i:i+K]) for i in range(N-K+1)]
print(max(wa_temp))


Fixed submission:
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = sum(P[0:K])
max_wa = wa_temp

for i in range(N-K):
    wa_temp = wa_temp - P[i] + P[i+K]
    if wa_temp > max_wa:
        max_wa = wa_temp
print(max_wa)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = 0
wa_max = 0.0
for i in range(N-K+1):
    wa_temp = sum(P[i:i+K])
    if wa_max < wa_temp:
        wa_max = wa_temp
print(wa_max)

Fixed submission:
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = sum(P[0:K])
max_wa = wa_temp

for i in range(N-K):
    wa_temp = wa_temp - P[i] + P[i+K]
    if wa_temp > max_wa:
        max_wa = wa_temp
print(max_wa)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = 0
wa_max = 0.0
for i in range(N-K+1):
    wa_temp = sum(P[i:i+K])
    if wa_max < wa_temp:
        wa_max = wa_temp
print(wa_max)


Fixed submission:
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = sum(P[0:K])
max_wa = wa_temp

for i in range(N-K):
    wa_temp = wa_temp - P[i] + P[i+K]
    if wa_temp > max_wa:
        max_wa = wa_temp
print(max_wa)
Buggy python submission (verdict: Runtime Error):
dp = [[100000000]*(10000*2)]*(N+1)
dp[0][0] = 0

for i in range(0, N):
    for h in range(0, H+1):
        dp[i+1][h] = min(dp[i+1][h], dp[i][h])
        dp[i+1][min(h+AB[i][0], H)] = min(dp[i+1][min(h+AB[i][0], H)], dp[i+1][h]+AB[i][1])

ans = {}
for i in range(N):
    ans[i] = dp[i][H]
print(min(ans.values()))

Fixed submission:
def main():
    H, N = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    dp = [[100000000]*(10000*2)]*(N+1)
    dp[0][0] = 0

    for i in range(0, N):
        for h in range(0, H+1):
            dp[i+1][h] = min(dp[i+1][h], dp[i][h])
            dp[i+1][min(h+AB[i][0], H)] = min(dp[i+1][min(h+AB[i][0], H)], dp[i+1][h]+AB[i][1])

    ans = {}
    for i in range(N):
        ans[i] = dp[i][H]
    print(min(ans.values()))
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H, N = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    dp = [[100000000]*(10000*2)]*(N+1)
    dp[0][0] = 0

    for i in range(0, N):
        for h in range(0, H+1):
            dp[i+1][h] = min(dp[i+1][h], dp[i][h])
            dp[i+1][min(h+AB[i][0], H)] = min(dp[i+1][min(h+AB[i][0], H)], dp[i+1][h]+AB[i][1])

    ans = {}
    for i in range(N):
        ans[i] = dp[i][H]
    print(min(ans.values()))
    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    H, N = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    dp = [[100000000]*(10000*2)]*(N+1)
    dp[0][0] = 0

    for i in range(0, N):
        for h in range(0, H+1):
            dp[i+1][h] = min(dp[i+1][h], dp[i][h])
            dp[i+1][min(h+AB[i][0], H)] = min(dp[i+1][min(h+AB[i][0], H)], dp[i+1][h]+AB[i][1])

    ans = {}
    for i in range(N):
        ans[i] = dp[i][H]
    print(min(ans.values()))
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
s = input()
N = len(s)
i = 0
count = 0
while len(s) > 2:
    print(s)
    if i == 0:
        word =s[i]
        s = s[i+1:]
        count += 1
        last = 1
    if s[i+1] == s[i]:
        s = s[i+2:]
        count += 1
        last = 2
    else:
        word = s[i]
        s = s[i+1:]
        count += 1
        last = 1

if len(s) == 1 and last == 1 and word == s:
    count += 1
print(count)


Fixed submission:
S = input()
N = len(S)
count = 0
i = 0
last = ""

while i < N:
    if i == 0:
        last = S[i]
        i += 1
        count += 1
    elif i != 0 and last == S[i]:
        if i > N-2:
            break
        last = S[i:i+2]
        i += 2
        count += 1
    elif i != 0 and last != S[i]:
        last = S[i]
        i += 1
        count += 1

if i == N-1 and last != S[N-1]:
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
j = 0
i = 0
flag = 1
while flag == 1:
    k = 0
    for i in range(len(S)-1):
        if S[i] == "B" and S[i+1] == "W":
            temp = S[i+1]
            temp2 = S[i]
            S[i] = temp
            S[i+1] = temp2
            j += 1
            k += 1
            #print(S)
    if k == 0:
        flag = 0
print(j)

Fixed submission:
S = list(input())
j = 0
k = 0
for i in range(len(S)):
    if S[i] == "W":
        j += i - k
        k += 1
print(j)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
j = 0
i = 0
flag = 1
while flag == 1:
    k = 0
    for i in range(len(S)-1):
        if S[i] == "B" and S[i+1] == "W":
            temp = S[i+1]
            temp2 = S[i]
            S[i] = temp
            S[i+1] = temp2
            j += 1
            k += 1
            #print(S)
    if k == 0:
        flag = 0
print(j)

Fixed submission:
S = list(input())
j = 0
k = 0
for i in range(len(S)):
    if S[i] == "W":
        j += i - k
        k += 1
print(j)
Buggy python submission (verdict: Runtime Error):
def main():
    x = int(input())
    ans = "NO"
    if (x == 7 or x == 5 or x == 3):
        ans = "YES"

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    x = int(input())
    ans = "NO"
    if (x == 7 or x == 5 or x == 3):
        ans = "YES"

    print(ans)


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

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
y_low = {}
i = 0
for x in A:
    y_low[i] = bisect_right(B, x)
    i += 1
for y_lowi in y_low.values():
    for y in B[y_lowi:]:
        z_low = bisect_right(C, y)
        ans += N - z_low
print(ans)


Fixed submission:
from bisect import bisect_left
from bisect import bisect_right


N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
y_low = {}
i = 0
for y in B:
    x = bisect_left(A, y)
    z = bisect_right(C, y)
    ans += x * (N-z)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
y_low = 0
z_low = 0
for x in A:
    y_low = bisect_right(B, x)
    for y in B[y_low:]:
        z_low = bisect_right(C, y)
        ans += N - z_low
print(ans)


Fixed submission:
from bisect import bisect_left
from bisect import bisect_right


N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
y_low = {}
i = 0
for y in B:
    x = bisect_left(A, y)
    z = bisect_right(C, y)
    ans += x * (N-z)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for x in A:
    y_low = bisect_right(B, x)
    for y in B[y_low:]:
        z_low = bisect_right(C, y)
        ans += N - z_low
print(ans)


Fixed submission:
from bisect import bisect_left
from bisect import bisect_right


N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
y_low = {}
i = 0
for y in B:
    x = bisect_left(A, y)
    z = bisect_right(C, y)
    ans += x * (N-z)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

H, W = map(int, input().split())

raw = ""
for i in range(H):
    raw = raw + input()
#words = Counter(list(raw))

print(words)
if H*W % 2 == 1:
    flag = 0
    two_sum = (H-1) + (W-1)
elif H%2 == 1:
    flag = 1
    two_sum = W
elif W%2 == 1:
    flag = 1
    two_sum = H
else:
    flag = 1
    two_sum = 0

for value in words.values():
    if value % 2 == 1:
        flag += 1
    if flag > 1:
        print("No")
        break

if flag < 2 and two_sum > -1:
    for key, value in words.items():
        N_key = value
        while N_key > 0:
            if 1 < N_key < 4:
                N_key -= 2
                two_sum -= 2
            else:
                N_key -= 4

if flag < 2 and two_sum > -1:
    print("Yes")
elif two_sum < 0:
    print("No")


Fixed submission:
from collections import Counter

H, W = map(int, input().split())

raw = ""
for i in range(H):
    raw = raw + input()
words = Counter(list(raw))

if H*W % 2 == 1:
    flag = 0
    two_sum = (H-1) + (W-1)
elif H%2 == 1:
    flag = 1
    two_sum = W
elif W%2 == 1:
    flag = 1
    two_sum = H
else:
    flag = 1
    two_sum = 0

for value in words.values():
    if value % 2 == 1:
        flag += 1
    if flag > 1:
        print("No")
        break

if flag < 2 and two_sum > -1:
    for key, value in words.items():
        N_key = value
        while N_key > 0:
            if 1 < N_key < 4:
                N_key -= 2
                two_sum -= 2
            else:
                N_key -= 4

if flag < 2 and two_sum > -1:
    print("Yes")
elif two_sum < 0:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(x) for x in input().split()]

b = [0]*9
ans = 0
count = 0
for i in a:
    if i//400 < 8:
        b[i//400] = 1
    else:
        b[i//400] += 1
print(max(1, sum(b[:8])), sum(b))


Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]

dict = {}
ans = 0
count = 0
for i in range(N):
    if not( a[i]//400 in dict.keys() ):
        dict[a[i]//400] = 1
    else:
        dict[a[i]//400] += 1
for key in dict.keys():
    if key < 8:
        ans += 1
    else:
        count += dict[key]
if ans == 0:
    print(1, count)
else:
    print(ans, ans+count)
Buggy python submission (verdict: Runtime Error):
a = [int(x) for x in input().split()]
if a[0] >= a[1]:
  if a[0] >= a[2] and a[2] >= a[1]:
    print(Yes)
  else:
    print(No)
else:
  if a[1] >= a[2] and a[2] >= a[0]:
    print("Yes")
  else:
    print("No")

Fixed submission:
a = [int(x) for x in input().split()]
if a[0] >= a[1]:
  if a[0] >= a[2] and a[2] >= a[1]:
    print("Yes")
  else:
    print("No")
else:
  if a[1] >= a[2] and a[2] >= a[0]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
T = input()
count, temp = [], 0
AGCT = ['A', 'G', 'C', 'T']
for i in T:
  if (i in AGCT) == True:
    temp += 1
  else:
    count.append(temp)
    temp = 0
print(max(count))

Fixed submission:
T = input()
count, temp = [], 0
AGCT = ['A', 'G', 'C', 'T']
for i in T:
  if (i in AGCT) == True:
    temp += 1
  else:
    count.append(temp)
    temp = 0
count.append(temp)
print(max(count))
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
	K = int(input())
	dls = []
	d = 7 % K
	dls.append(d)
	c = 1
	if K % 2 == 0:
		c = -1
		d = 0
	while(d != 0):
		d = (d*10 + 7)%K
		if d in dls:
			c = -1
			break
		else:
			c += 1
	print(c)

Fixed submission:
if __name__ == '__main__':
	K = int(input())
	dls = [0] * (K+1)
	d = 7 % K
	dls[d] = 1
	c = 1
	if K % 2 == 0:
		c = -1
		d = 0
	while(d != 0):
		d = (d*10 + 7)%K
		if dls[d] == 1:
			c = -1
			break
		else:
			dls[d] = 1
			c += 1
	print(c)
Buggy python submission (verdict: Time Limit Exceeded):
def change(S,index,color):
	lstS = list(S)
	lstS[index] = color
	S = ''.join(lstS)

	return S


if __name__ == '__main__':
	N = int(input())
	S = input()
	L = 0
	R = N-1
	count = 0
	if S.count('W') == 0 or S.count('R') == 0:
		R = -1
	while(L < R):
		while(S[L] == 'R'):
			L += 1
		while(S[R] == 'W'):
			R -= 1
		if L > R:
			break
		S = change(S,L,'R')
		S = change(S,R,'W')
		L += 1
		R -= 1
		count += 1

	print(count)

Fixed submission:
if __name__ == '__main__':
	N = int(input())
	S = input()
	L = 0
	R = N-1
	count = 0
	if S.count('W') == 0 or S.count('R') == 0:
		R = -1
	while(L < R):
		while(S[L] == 'R'):
			L += 1
		while(S[R] == 'W'):
			R -= 1
		if L > R:
			break
		L += 1
		R -= 1
		count += 1

	print(count)