Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int,input().split())
n = list(range(b+1))
print(*sorted(set(n[a:(a+k)]) | set(n[-k:])),sep="\n")

Fixed submission:
a, b, k = map(int,input().split())
n = range(a,b+1)
print(*sorted(set(n[:k]) | set(n[-k:])),sep="\n")

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int,input().split())
n = list(range(a,b+1))
print(*sorted(set(n[:k]) | set(n[-k:])),sep="\n")

Fixed submission:
a, b, k = map(int,input().split())
n = range(a,b+1)
print(*sorted(set(n[:k]) | set(n[-k:])),sep="\n")

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int,input().split())
n = list(range(a,b+1))
print(*sorted(set(n[:k]) | set(n[-k:])),sep="\n")

Fixed submission:
a, b, k = map(int,input().split())
n = range(a,b+1)
print(*sorted(set(n[:k]) | set(n[-k:])),sep="\n")
Buggy python submission (verdict: Runtime Error):
import numpy as np
*a, = map(int,input().split())
a = np.array(a)
dp = [0]*3
count = 0
if a[0] == a[1] == a[2]:print(0);exit()
for i in range(3):
    if a[i] % 2 == 1:dp[i] = 1
if dp.count(1) == 2:
    for i in range(len(a)):
        if dp[i] == 1:a[i] += 1
    count += 1
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
elif dp.count(0) == 2:
    for i in range(len(a)):
        if dp[i] == 0:a[i] += 1
    count += 1
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
else:
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
print(count)

Fixed submission:
import sys
ary = list(map(int,input().split()))
count = 0
#最初から同じだった時
if ary[0] == ary[1] == ary[2]:
    print(0)
    sys.exit()

#和が偶数だった時
if (ary[0] + ary[1] + ary[2]) % 2 == 0:
    for i in range(3):
        if ary[i] % 2 == 1:
            ary[i] += 1
            count += 0.5
# 和が奇数だった時
elif (ary[0] + ary[1] + ary[2]) % 2 == 1:
    for i in range(3):
        if ary[i] % 2 == 0:
            ary[i] += 1
            count += 0.5

while not ary[0] == ary[1] == ary[2]:
    ary.sort()
    ary[0] += 2
    count += 1

print(int(count))

Buggy python submission (verdict: Runtime Error):
import sys
ary = list(map(int,input().split()))
parity = 0
count = 0
#最初から同じだった時
if ary[0] == ary[1] == ary[3]:
    print(0)
    sys.exit()

#和が偶数だった時
if (ary[0] + ary[1] + ary[2]) % 2 == 0:
    for i in range(3):
        if ary[i] % 2 == 1:
            ary[i] += 1
            count += 0.5
        print(ary)
# 和が奇数だった時
elif (ary[0] + ary[1] + ary[2]) % 2 == 1:
    for i in range(3):
        if ary[i] % 2 == 0:
            ary[i] += 1
            count += 0.5
while not ary[0] == ary[1] == ary[2]:
    ary.sort()
    ary[0] += 2
    count += 1
    
print(int(count))

Fixed submission:
import sys
ary = list(map(int,input().split()))
count = 0
#最初から同じだった時
if ary[0] == ary[1] == ary[2]:
    print(0)
    sys.exit()

#和が偶数だった時
if (ary[0] + ary[1] + ary[2]) % 2 == 0:
    for i in range(3):
        if ary[i] % 2 == 1:
            ary[i] += 1
            count += 0.5
# 和が奇数だった時
elif (ary[0] + ary[1] + ary[2]) % 2 == 1:
    for i in range(3):
        if ary[i] % 2 == 0:
            ary[i] += 1
            count += 0.5

while not ary[0] == ary[1] == ary[2]:
    ary.sort()
    ary[0] += 2
    count += 1

print(int(count))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0]+list(map(int,input().split()))+[0]
for i in range(1,n+1):
    ans = 0
    b = a[:i]+a[i+1:]
    for j in range(len(b)-1):
        ans += abs(b[j]-b[j+1])
    print(ans)

Fixed submission:
n = int(input())
a = [0]+list(map(int,input().split()))+[0]
cost = sum([abs(a[i-1]-a[i]) for i in range(1,n+2)])
for i in range(1,n+1):
    print(cost-abs(a[i]-a[i+1])-abs(a[i-1]-a[i])+abs(a[i-1]-a[i+1]))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
ary = []
for i in range(n):
    s = input()[0]
    if s == "M" or s == "A" or s =="R" or s =="C" or s == "H":
        ary.append(s)
print(len([ i for i in itertools.combinations(ary,3) if len(set(i)) == 3]))

Fixed submission:
from collections import Counter
import itertools
n = int(input())
ary = []
for i in range(n):
    s = input()[0]
    if s == "M" or s == "A" or s =="R" or s =="C" or s == "H":
        ary.append(s)
count = Counter(ary)
s = set(count.keys())
cnb = list(itertools.combinations(s,3))
ans = 0
for a,b,c in cnb:
    ans += count[a] * count[b] * count[c]
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y = [ int(i) for i in input().split()]

if: ((x * y ) % 2) == 0
  print('Even')
  
else: 
  print('Odd')

Fixed submission:
x,y = map(int,input().split())

result = x * y

if (result % 2) == 0 :
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
aaaa

Fixed submission:
x,y = map(int,input().split())

result = x * y

if (result % 2) == 0 :
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
n,y = map(int,input().split())
a,b,c = 10000,5000,1000
for i in range(y//a+1):
    total = 0
    for j in range((y-(a*i))//b+1):
        d = (y-(a*i)-(b*j))//c
        if i+j+d == n:print(i,j,d);exit()
eles:print(-1,-1,-1)

Fixed submission:
import sys
nums , money = map(int,input().split())

for i in range(nums+1):

    for x in range( nums +1 -i):

        if (i * 10000) + (x *5000) + ((nums -(i+x))*1000) == money:
            print(str(i) +" " + str(x) +" " +str((nums -(i +x))))
            sys.exit()

else:
    print("-1 -1 -1")
Buggy python submission (verdict: Time Limit Exceeded):
Num = int(input())
check,check1 = 0,Num

while not 0 < check1 < 1:
    check += Num % 10
    check1 = int(check1 / 10 )

if (Num % check) == 0 :
    print('Yes')
else:
    print('No')

Fixed submission:
Num = int(input())
check,check1 = 0,Num

while not 0 <= check1 < 1:
    check += check1 % 10
    check1 = int(check1 / 10 )

if (Num % check) == 0 :
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s = input()
S = input()
flag = False
for i in range(len(s)-len(S)+1):
    if s[i] == S[0] or s[i] == "?":
        a = s[i:i+len(S)]
        for j in range(len(S)):
            if a[j] == S[j] or a[j] == "?":
                continue
            break
        else:
            flag = True
            s = s[0:i]+S+s[i+len(S):-1]
print(s.replace("?","a") if flag == True else "UNRESTORABLE")

Fixed submission:
s = input()
S = input()
flag = False
ans = []
for i in range(len(s)-len(S)+1):
    if s[i] == S[0] or s[i] == "?":
        a = s[i:i+len(S)]
        for j in range(len(S)):
            if a[j] == S[j] or a[j] == "?":
                continue
            break
        else:
            flag = True
            ans.append(s[:i]+S+s[i+len(S):])
if not flag:
    print("UNRESTORABLE")
    exit()
for i in range(len(ans)):
    ans[i] = ans[i].replace("?","a")
ans.sort()
print(ans[0])
Buggy python submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())
A *= 100
B *= 100
check = 0
for i in range(F//A+1):
    for j in range((F-(A*i))//B+1):
        if i + j == 0:continue
        for k in range(((F-(A*i))-B*j)//C+1):
            for l in range((((F-(A*i))-B*j)-C*k)//D+1):
                water = A*i+B*j
                sugar = C*k+D*l
                if water//100*E < sugar:continue
                if check < 100*sugar/(water+sugar):
                    check = 100*sugar/(water+sugar)
                    ans = [water+sugar,sugar]
print(*ans)

Fixed submission:
ope1,ope2,ope3,ope4,concent,capacity = map(int,input().split())
ope1 *= 100
ope2 *= 100
noudo = 0
check = 0
check_capacity = 0
result =str(ope1)+" "+"0"

for i in range(int(capacity / ope1)+1):
    for x in range(int( (capacity -(i*ope1)) /ope2 )+1):
        if i+x == 0:
            continue
        for y in range(int( (capacity -(i*ope1 +x*ope2)) /ope3)+1):
            for z in range( int( (capacity -(i*ope1 +x*ope2 +y*ope3) ) /ope4)+1):
                if y+z ==0:
                    continue
                check = (100 *(y*ope3 + z*ope4)) / ( i*ope1 + x*ope2 + y*ope3 + z*ope4)

                if check > noudo and ((i*ope1+x*ope2)/100)*concent>= y*ope3+z*ope4:
                    noudo = check
                    result = (str(i*ope1+x*ope2+y*ope3+z*ope4)+" "+str(y*ope3+z*ope4))
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
a = set()
for i in range(int(input())):
    a = a^set([int(input())])
print(len(a))

Fixed submission:
nums = int(input())
ary = list(range(nums))
check_number = [0 for i in range(nums+2)]
for i in range(nums):
    ary[i] = int(input())

ary.sort()
check = 0
count = 0
result = 0
x = 0
for i in ary :
    if check == i:
        check_number[x] += 1
    else:
        check = i
        x += 1
        check_number[x] = 1

for i in check_number:
    if i % 2 == 1:
        result += 1
print (result)

Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
ary = list(range(nums))

for i in range(nums):
    ary[i] = int(input())
x = 0
count = 0
ary.sort()

while x < nums:
    check = ary.count(ary[x])
    if check % 2 == 1:
        count += 1
        x += check-1
    elif check > 0:
        x += check-1
    x += 1
print(count)

Fixed submission:
nums = int(input())
ary = list(range(nums))
check_number = [0 for i in range(nums+2)]
for i in range(nums):
    ary[i] = int(input())

ary.sort()
check = 0
count = 0
result = 0
x = 0
for i in ary :
    if check == i:
        check_number[x] += 1
    else:
        check = i
        x += 1
        check_number[x] = 1

for i in check_number:
    if i % 2 == 1:
        result += 1
print (result)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ary = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i+1 == ary[i]:
        a = ary[i]
        b = ary[i+1]
        ary[i] = b
        ary[i+1] = a
        ans += 1
    else:continue
print(ans)

Fixed submission:
n = int(input())
ary = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i == n-1 and i+1 == ary[i]:
        ans += 1
    elif i+1 == ary[i]:
        a = ary[i]
        b = ary[i+1]
        ary[i] = b
        ary[i+1] = a
        ans += 1
    else:continue
print(ans)
Buggy python submission (verdict: Runtime Error):
strings = list(input())
alfabet  = 'abcdefghijklmnopqrstuvwxyz'
for i in alfabet:
    if strings.count(i) <= 1:
        result = i
        break

print(result)

Fixed submission:
strings = list(input())
alfabet  = 'abcdefghijklmnopqrstuvwxyz'

for i in alfabet:
    if strings.count(i) == 0:
        result = i
        break
else:
    result = "None"

print(result)
Buggy python submission (verdict: Runtime Error):
b = -1
ans = [0,0]
count = 0
for i in range(n+1):
    count += 1
    if b != a[i]:
        if count >= 2:
            if ans[0]:
                ans[1] = b
                break
            else: ans[0] = b
        b = a[i]
        count = 0
print(ans[0]*ans[1])

Fixed submission:
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
a += [0]
b = -1
ans = [0,0]
count = 0
for i in range(n+1):
    count += 1
    if b != a[i]:
        if count >= 4:
            if ans[0]:
                ans[1] = b
                break
            else:
                ans[0] = b
                ans[1] = b
                break
        elif count >= 2:
            if ans[0]:
                ans[1] = b
                break
            else:ans[0] = b
        b = a[i]
        count = 0
print(ans[0]*ans[1])
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ary = [int(input()) for _ in range(n)]
ans = 1
for i in ary:
    ans = (ans*i)//math.gcd(ans,i)
print(ans)

Fixed submission:
import fractions
n = int(input())
ans = 1
for i in range(n):
    a = int(input())
    ans = ans // fractions.gcd(ans,a) * a
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ans = int(input())
for i in range(n-1):
    a = int(input())
    ans = ans // math.gcd(ans,a) * a
print(ans)

Fixed submission:
import fractions
n = int(input())
ans = 1
for i in range(n):
    a = int(input())
    ans = ans // fractions.gcd(ans,a) * a
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ans = int(input())
for i in range(n-1):
    a = int(input())
    ans = ans // math.gcd(ans,a) * a
print(ans)

Fixed submission:
import fractions
n = int(input())
ans = 1
for i in range(n):
    a = int(input())
    ans = ans // fractions.gcd(ans,a) * a
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ans = int(input())
for i in range(n-1):
    a = int(input())
    ans = ans // math.gcd(ans,a) * a
print(ans)

Fixed submission:
import fractions
n = int(input())
ans = 1
for i in range(n):
    a = int(input())
    ans = ans // fractions.gcd(ans,a) * a
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
def f(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n = n//f
        else:f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
s = set()
d = dict()
for i in range(n):
    c = collections.Counter(f(int(input())))
    for x,y in zip(c.keys(),c.values()):

        if x not in s :
            s.add(x)
            d[x] = y
        else:
            d[x] = max(y,d[x])
b = [ x**y for x,y in zip(d.keys(),d.values())]
ans = 1
for i in b:
    ans *= i
print(ans)

Fixed submission:
import fractions
n = int(input())
ans = 1
for i in range(n):
    a = int(input())
    ans = ans // fractions.gcd(ans,a) * a
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
a = [sorted(map(int,input().split())) for _ in range(m)]
for i in range(n):
    if [1,i] in a and [i,n] in a:
        print("POSSIBLE")
        exit()
print(("IMPOSSIBLE"))

Fixed submission:
n, m = map(int,input().split())
a = [[] for _ in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    a[x-1] += [y-1]
for i in a[0]:
    for j in a[i]:
        if j == n-1 :
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
a,b = int(input()),int(input())
print("Possible" if a*b*(a+b)%3==0 else "Impossible") 

Fixed submission:
a,b = map(int,input().split())
print("Possible" if a%3 == 0 else "Possible" if b%3 == 0 else "Possible" if (a+b)%3 == 0 else "Impossible")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = float("Inf")
for i in range(1,n):
    ans = min(ans,abs(sum(a[:i])-sum(a[i:])))
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = sum(a)
c = 0
ans = float("Inf")
for i in range(n-1):
    c += a[i]
    b -= a[i]
    ans = min(ans,abs(b-c))
print(ans)
Buggy python submission (verdict: Runtime Error):
n,*a = map(int,open(0).read().split())
b = filter(lambda x:x < 3200,a)
c = len(set([i//400 for i in b]))
print(c or 1,end=" ")
print(c + n-len(b))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = set()
all = 0
for i in a:
    if i >= 3200:
        all += 1
    else:s.add(i//400)
if not s:
    print(1,end=" ")
else:print(len(s),end=" ")
print(len(s)+all)

Buggy python submission (verdict: Runtime Error):
n,*a = map(int,open(0).read().split())
b = filter(lambda x:x < 3200,a)
c = set([i//400 for i in b])
print(c or 1,end=" ")
print(c + n-len(b))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = set()
all = 0
for i in a:
    if i >= 3200:
        all += 1
    else:s.add(i//400)
if not s:
    print(1,end=" ")
else:print(len(s),end=" ")
print(len(s)+all)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
dp = [[] for _ in range(n+1)]
for i in range(n+1):
    dp[i] += [-1 for _ in range(10010)]
dp[0][0] = 1
for i in range(n):
    for j in range(10010):
        if dp[i][j] == 1:
            dp[i+1][j] = 1
            dp[i+1][j+a[i]] = 1

for i in range(10010):
    if dp[n][i] == 1:
        if i % 10 != 0:
            ans = max(ans,i)
print(ans)

Fixed submission:
n = int(input())
a = sorted(int(input()) for _ in range(n))
ans = sum(a)
if ans % 10 != 0:
    print(ans)
    exit()
else:
    for i in a:
        if (ans-i) % 10 != 0:
            print(ans-i)
            exit()
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]
ary =[0]
ans = 0
for i in a:
    for j in range(len(ary)):
        ary.append(i+ary[j])
        if (i +ary[j]) % 10 != 0:
            ans = max(ans,i+ary[j])
print(ans)

Fixed submission:
n = int(input())
a = sorted(int(input()) for _ in range(n))
ans = sum(a)
if ans % 10 != 0:
    print(ans)
    exit()
else:
    for i in a:
        if (ans-i) % 10 != 0:
            print(ans-i)
            exit()
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
member = int(input())
member_array = sorted(list(map(int, input().split())),reverse=True)
result = 0

for i in range(member):
    member_array.pop()
    member_array.pop(0)
    result += member_array.pop(0)

print(result)

Fixed submission:
member = int(input())
member_array = sorted(list(map(int, input().split())),reverse=True)
result = 0
count = 1

for i in range(member):
    result += member_array[count]
    count += 2

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
member = int(input())
member_array = sorted(list(map(int,input().split())))
result = 0

for i in range(member):
    for x in range(3):
        if x == 2:
            member_array.pop(0)
        else:
            power = member_array.pop()

    result += power
print(result)

Fixed submission:
member = int(input())
member_array = sorted(list(map(int, input().split())),reverse=True)
result = 0
count = 1

for i in range(member):
    result += member_array[count]
    count += 2

print(result)
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
if a == b :
  print("H")
else:
  print("D")

Fixed submission:
a, b = input().split()
if a == b :
  print("H")
else:
  print("D")
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
result = 1
for i in range(1,num+1):
    result = result *i
print(result % 1000000007)

Fixed submission:
import math
print(math.factorial(int(input()))%1000000007)
Buggy python submission (verdict: Runtime Error):
S,C = map(int,input().split())
if C >= S*2:ans = S
ans += (C-ans*2) // 4
print(ans)

Fixed submission:
S,C = map(int,input().split())
if C <= 1:ans = 0
elif C//2 >= S:ans = S+(C-S*2) //4
else:ans = C//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j:j+m] == b[0] and a[i+1][j:j+m] == b[1]:
            flag = 1
print("Yes" if flag == 1 else "No")

Fixed submission:
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
r = any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print("Yes" if r else "No")

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
print(a,b)
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j:j+m] == b[0] and a[i+1][j:j+m] == b[1]:
            flag = 1
print("Yes" if flag == 1 else "No")

Fixed submission:
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
r = any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print("Yes" if r else "No")

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][i:i+m] == b[0] and a[i+1][i:i+m] == b[1]:
            flag = 1
print("Yes" if flag == 1 else "No")

Fixed submission:
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
r = any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print("Yes" if r else "No")
Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
ary = list(map(int, input().split()))
parity = [0,0]

# 奇数、偶数の数をとる
for i in ary:
    if   i % 2 == 0:
        parity[0] += 1
    elif i % 2 == 1:
        parity[1] += 1

while not parity[0] + parity[1] == 3:
    if parity[0] >= 2:
        parity[0] -= 2
        parity[0] += 1
    elif parity [1] >= 2:
        parity[1] -= 2
        parity[0] += 1
if (parity[0] == 1 and parity[1] == 2) or (parity[0] == 3 and parity[1] == 0):
    print("YES")
else :print("NO")

Fixed submission:
nums = int(input())
ary = list(map(int, input().split()))
parity = [0,0]

# 奇数、偶数の数をとる
for i in ary:
    if   i % 2 == 0:
        parity[0] += 1
    elif i % 2 == 1:
        parity[1] += 1

while not parity[0] + parity[1] <= 2:
    if parity[0] >= 2:
        parity[0] -= 2
        parity[0] += 1
    elif parity [1] >= 2:
        parity[1] -= 2
        parity[0] += 1
if parity[0] == 2 or parity[1] == 2:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
Num , Sum =  map(int,input().split())
count = 0
check = 0

for x in range(Num+1):
    for y in range ( Num+1 ):

        if (Sum - x)  >  Num * 2:
            break
        elif 0 <= (Sum - x ) - y <= Num :
            count += 1

print(count)

Fixed submission:
Num , Sum =  map(int,input().split())
count = 0
check = 0

for x in range(Num+1):
    for y in range ( Num+1 ):

        if 0 <= (Sum - x ) - y <= Num :
            count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
Num , Sum =  map(int,input().split())
count = 0

for x in range(Num+1):
    for y in range (Num+1):
        for z in range (Num+1):
            if Sum == x + y + z :
                count += 1

print(count)

Fixed submission:
Num , Sum =  map(int,input().split())
count = 0
check = 0

for x in range(Num+1):
    for y in range ( Num+1 ):

        if 0 <= (Sum - x ) - y <= Num :
            count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(500000)

def f(a,c,b,d):
    if a >= A and b >=B :
        return a,b
    return f(a+c,c,b+d,d)

n = int(input())
a = [list(map(int,input().split()))for _ in range(n)]
A,B = a[0][0],a[0][1]
for i in range(1,n):
    A,B = f(a[i][0],a[i][0],a[i][1],a[i][1])
print(A+B)

Fixed submission:
n = int(input())
a = [list(map(int,input().split()))for _ in range(n)]
A,B = a[0][0],a[0][1]
for i in range(1,n):
    C = max([1,-(-A//a[i][0]),-(-B//a[i][1])])
    A = a[i][0]*C
    B = a[i][1]*C
print(A+B)
Buggy python submission (verdict: Time Limit Exceeded):
def f(n,x,i):
    if n == 0:
        if i != 0:
            if x/i == m:
                return 1
        return 0
    if memo[n-1][i][x] != -1 :
        if memo[n-1][i][x] > 0:
            return memo[n-1][i][x]
    memo[n-1][i][x] = f(n-1,x,i)+f(n-1,x+a[n-1],i+1)
    return memo[n-1][i][x]

n, m= map(int,input().split())
a = list(map(int,input().split()))
memo = [[[-1 for _ in range(sum(a)+1)]for i in range(n)]for i in range(n)]
print(f(n,0,0))

Fixed submission:
def f(n,x,i):
    if n == 0:
        if i != 0:
            if x/i == m:
                return 1
        return 0
    if memo[n-1][i][x] != -1 :
        return memo[n-1][i][x]
    memo[n-1][i][x] = f(n-1,x,i)+f(n-1,x+a[n-1],i+1)
    return memo[n-1][i][x]

n, m= map(int,input().split())
a = list(map(int,input().split()))
memo = [[[-1 for _ in range(sum(a)+1)]for i in range(n)]for i in range(n)]
print(f(n,0,0))