Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])


Fixed submission:
a = int(input())
s = input()
if a >=3200:
    print(s)
else:
    print('red')

Buggy python submission (verdict: Runtime Error):
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in range(N-1)]
px = [LI() for _ in range(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in range(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])


Fixed submission:
a = int(input())
s = input()
if a >=3200:
    print(s)
else:
    print('red')
Buggy python submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
H = LI()
for i in range(N-1):
    print(H)
    if i==0:
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')


Fixed submission:
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
H = LI()
if N==1:
    print('Yes')
    exit()
if N==2:
    print('Yes' if H[0]-1<=H[1] else 'No')
    exit()
for i in range(N-1):
    if i==0:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    print('No')
    break
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
def LI(): return list(map(int,input().split()))
N,D = LI()
X = [LI() for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        temp = 0
        for k in range(D):
            temp += (X[j][k]-X[i][k])**2
        if temp **0.5%1==0:
        ans += 1
print(ans)

Fixed submission:
import numpy
N, D = map(int, input().split())
listx = []
count = 0
for i in range(N):
    x = list(map(int, input().split()))
    listx.append(x)

for j in range(0, N):
    for k in range(j+1,N):
        a = numpy.array(listx[j])
        b = numpy.array(listx[k])
        u = b - a
        c = float(numpy.linalg.norm(u))
        if c.is_integer() :
            count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

listLR = [a for a in range(L, R+1)]

flg = 0
for i in range(len(listLR)):
    if listLR[i] % 2019 == 0:
        flg = 1
        break

ans = 0
modL = L % 2019
modR = R % 2019
min2019 = 2019

if flg == 1:
    print(0)
elif modL <=3 and modR >=673:
    print(0)
else:
    for j in range(modL, modR+1):
        for k in range(j+1, modR+1):
            if j * k % 2019 < min2019:
                min2019 = j * k % 2019
    print(min2019)

Fixed submission:
L, R = map(int, input().split())
modL = L % 2019
modR = R % 2019
min2019 = 2019

if R - L >= 2018:
    print(0)
else:
    for j in range(modL, modR+1):
        for k in range(j+1 , modR+1):
            min2019 = min(min2019, j * k % 2019)
    print(min2019)
Buggy python submission (verdict: Runtime Error):
import math
def main(A,B,C,D):
    allAB = B - A + 1
    divC = B // C - (A-1) // C
    divD = B // D - (A-1) // D
    lcmCD = lcm(C,D)
    divCD = B // (lcmCD) - (A-1) // (lcmCD)
    count = allAB - divC - divD + divCD
    return count

def lcm(x, y):
    return (x*y) // math.gcd(x,y)
    
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))

Fixed submission:
import fractions
def main(A,B,C,D):
    allAB = B - A + 1
    divC = B // C - (A-1) // C
    divD = B // D - (A-1) // D
    lcmCD = lcm(C,D)
    divCD = B // (lcmCD) - (A-1) // (lcmCD)
    count = allAB - divC - divD + divCD
    return count

def lcm(x, y):
    return (x*y) // fractions.gcd(x,y)
    
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))

Buggy python submission (verdict: Runtime Error):
import math
def main(A,B,C,D):
    allAB = B - A + 1
    divC = B // C - (A-1) // C
    divD = B // D - (A-1) // D
    lcmCD = lcm(C,D)
    divCD = B // (lcmCD) - (A-1) // (lcmCD)
    count = allAB - divC - divD + divCD
    return count

def lcm(x, y):
    return (x*y) // math.gcd(x,y)
    
    
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))

Fixed submission:
import fractions
def main(A,B,C,D):
    allAB = B - A + 1
    divC = B // C - (A-1) // C
    divD = B // D - (A-1) // D
    lcmCD = lcm(C,D)
    divCD = B // (lcmCD) - (A-1) // (lcmCD)
    count = allAB - divC - divD + divCD
    return count

def lcm(x, y):
    return (x*y) // fractions.gcd(x,y)
    
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))

Buggy python submission (verdict: Time Limit Exceeded):
def main(A,B,C,D):
    count = 0    
    for i in range(A,B+1):
        if i % C != 0 and i % D !=0:
            count += 1
    return count
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))

Fixed submission:
import fractions
def main(A,B,C,D):
    allAB = B - A + 1
    divC = B // C - (A-1) // C
    divD = B // D - (A-1) // D
    lcmCD = lcm(C,D)
    divCD = B // (lcmCD) - (A-1) // (lcmCD)
    count = allAB - divC - divD + divCD
    return count

def lcm(x, y):
    return (x*y) // fractions.gcd(x,y)
    
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))
Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
S = W * H / 2
if W / x == 2 and H / y == 2:
    res = 1
else:
    res = 0
print(S, res)

Fixed submission:
W, H, x, y = map(int, input().split())
S = W * H / 2
if W / 2 == x and H / 2 == y:
    res = 1
else:
    res = 0
print(S, res)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
probability = 0


for x in range(N):
    bekicount = 0
    y = x
    while y < K:
        y = y*2
        bekicount = bekicount +1
    probability = probability + (x/N)*pow(0.5,bekicount)
    bekicount = 0
print(probability)

Fixed submission:
N,K = map(int, input().split())
probability = 0


for x in range(1,N+1):
    bekicount = 0
    y = x
    while y < K:
        y = y*2
        bekicount = bekicount +1
    probability = probability + (1/N)*(pow(0.5,bekicount))
    bekicount = 0
print(probability)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
R,G,B,N = LI()
ans = 0
for i in range(N+1):
    for j in range(N+1):
        temp = N-(R*i+G*j)
        if temp>=0 and temp%B==0:
            ans += 1
print(ans)


Fixed submission:
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
R,G,B,N = LI()
ans = 0
for i in range(N+1):
    for j in range(N+1):
        temp = N-(R*i+G*j)
        if temp>=0 and temp%B==0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = return sys.stdin.readline().rstrip()
ans,temp = 0,0
for x in S:
    if x in 'ACGT':
        temp += 1
        ans = max(ans,temp)
    else:
        temp = 0
print(ans)


Fixed submission:
S = input()
ACGT = 'ACGT'
ans = 0
temp = 0
for x in S:
    if x in ACGT:
        temp += 1
    else:
        ans = max(ans, temp)
        temp = 0
ans = max(ans, temp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i,j in itertools.product(range(1,N),range(1,K+1)):
    if i-j>=0:
        dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])


Fixed submission:
def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i,j in itertools.product(range(N),range(1,K+1)):
    if i+j>=N:
        continue
    dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])


Fixed submission:
def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))

Buggy python submission (verdict: Time Limit Exceeded):
def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))

Fixed submission:
def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))

Buggy python submission (verdict: Runtime Error):
2 100
10 10

Fixed submission:
def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))
Buggy python submission (verdict: Runtime Error):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
        for j in range(V+1)):
        if j-v>=0 and dp[i-1][j-v]+w<=W:
            dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
        dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))

Fixed submission:
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i,j in itertools.product(range(1,N+1),range(V+1)):
    w,v = wv[i-1]
    if j-v>=0:
        dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
    dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [collections.defaultdict(int) for _ in range(N+1)] #1_indexed
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
    for dw,dv in dp[i-1].items():
        dp[i][dw] = max(dp[i][dw],dv)
        if w+dw<=W:
            dp[i][w+dw] = max(dp[i][w+dw],v+dv)
print(max(dp[-1].values()))


Fixed submission:
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i,j in itertools.product(range(1,N+1),range(V+1)):
    w,v = wv[i-1]
    if j-v>=0:
        dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
    dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def S(): return sys.stdin.readline().rstrip()
S = S()
ans = 0
while 1:
    if S.count('BW')==0:
        break
    ans += S.count('BW')
    S = S.replace('BW','WB')
print(ans)


Fixed submission:
import sys
def S(): return sys.stdin.readline().rstrip()
S = S()
ans,target_index = 0,0
for i in range(len(S)):
    if S[i]=='W':
        ans += i-target_index
        target_index += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections,math,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ans = 1
def prime_factor(num):
    prime_factor = collections.defaultdict(int)
    for i in range(2,int(num**0.5)+1):
        while num%i==0:
            prime_factor[i] += 1
            num //= i
    if num>1:
        prime_factor[num]=1
    return prime_factor
for v in prime_factor(M).values():
    ans *= math.factorial(v+N-1)//math.factorial(v)//math.factorial(N-1)
    ans %= 10**9+7
print(ans)

Fixed submission:
ABC = list(map(int,input().split()))
ABC.sort(reverse= True)
print(int(str(ABC[0])+str(ABC[1])) +ABC[2])
Buggy python submission (verdict: Time Limit Exceeded):
import collections,math,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ans = 1
def prime_factor(num):
    prime_factor = collections.defaultdict(int)
    for i in range(2,int(num**0.5)+1):
        while num%i==0:
            prime_factor[i] += 1
            num //= i
    if num>1:
        prime_factor[num]=1
    return prime_factor
for v in prime_factor(M).values():
    ans *= math.factorial(v+N-1)//math.factorial(v)//math.factorial(N-1)
    ans %= 10**9+7
print(ans)

Fixed submission:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ans = 1
def prime_factor(num):
    prime_factor = collections.defaultdict(int)
    for i in range(2,int(num**0.5)+1):
        while num%i==0:
            prime_factor[i] += 1
            num //= i
    if num>1:
        prime_factor[num]=1
    return prime_factor
def nCr(n,r,mod):
    comb_count = 1
    for i in range(r):
        comb_count *= n-i
        comb_count %= mod
    for j in range(1,r+1):
        comb_count *= pow(j,mod-2,mod)
        comb_count %= mod
    return comb_count
for v in prime_factor(M).values():
    ans *= nCr(v+N-1,v,10**9+7)
    ans %= 10**9+7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections,math,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ans = 1
def prime_factor(num):
    prime_factor = collections.defaultdict(int)
    for i in range(2,int(num**0.5)+1):
        while num%i==0:
            prime_factor[i] += 1
            num //= i
    if num>1:
        prime_factor[num]=1
    return prime_factor
for v in prime_factor(M).values():
    ans *= math.factorial(v+N-1)//math.factorial(v)//math.factorial(N-1)
    ans %= 10**9+7
print(ans)

Fixed submission:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ans = 1
def prime_factor(num):
    prime_factor = collections.defaultdict(int)
    for i in range(2,int(num**0.5)+1):
        while num%i==0:
            prime_factor[i] += 1
            num //= i
    if num>1:
        prime_factor[num]=1
    return prime_factor
def nCr(n,r,mod):
    comb_count = 1
    for i in range(r):
        comb_count *= n-i
        comb_count %= mod
    for j in range(1,r+1):
        comb_count *= pow(j,mod-2,mod)
        comb_count %= mod
    return comb_count
for v in prime_factor(M).values():
    ans *= nCr(v+N-1,v,10**9+7)
    ans %= 10**9+7
print(ans)
Buggy python submission (verdict: Runtime Error):
def I(): return int(input())
N = I()
ans = 0
for i in range(105,N+1,2):
    count_yakusuu = 0
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count_yakusuu += 2
    if count_yakusuu==8:
        ans += 1
print(ans)


Fixed submission:
A,B = map(int,input().split())
print((A-1)*(B-1))
Buggy python submission (verdict: Runtime Error):
import collections,itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
s = [S() for _ in range(H)]
black_count = 0
for i,j in itertools.product(range(H),range(W)):
    if s[i][j]=='#':
        black_count += 1
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
min_dist = [[-1]*W for _ in range(H)]
seen = [[0]*W for _ in range(H)]
queue = collections.deque() #位置[行,列]を入れておく
def bfs():
    seen[0][0] = 1
    queue.append([0,0])
    min_dist[0][0] = 1
    while queue:
        qh,qw = queue.popleft()
        for dh,dw in dhdw:
            nh,nw = qh+dh,qw+dw
            if not(0<=nh<=H-1) or not(0<=nw<=W-1) or seen[nh][nw] or s[nh][nw]=='#':
                continue
            if [nh,nw]==[H-1][W-1]:
                return min_dist[qh][qw]+1
            seen[nh][nw] = 1
            queue.append([nh,nw])
            min_dist[nh][nw] = min_dist[qh][qw]+1
    else:
        return -1
min_dist = dfs()
print(H*W-black_count-min_dist if min_dist!=-1 else -1)


Fixed submission:
import collections,itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
s = [S() for _ in range(H)]
black_count = 0
for i,j in itertools.product(range(H),range(W)):
    if s[i][j]=='#':
        black_count += 1
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
min_dist = [[-1]*W for _ in range(H)]
seen = [[0]*W for _ in range(H)]
queue = collections.deque() #位置[行,列]を入れておく
def bfs():
    seen[0][0] = 1
    queue.append([0,0])
    min_dist[0][0] = 1
    while queue:
        qh,qw = queue.popleft()
        for dh,dw in dhdw:
            nh,nw = qh+dh,qw+dw
            if not(0<=nh<=H-1) or not(0<=nw<=W-1) or seen[nh][nw] or s[nh][nw]=='#':
                continue
            seen[nh][nw] = 1
            queue.append([nh,nw])
            min_dist[nh][nw] = min_dist[qh][qw]+1
bfs()
if min_dist[H-1][W-1]!=-1:
    print(H*W-black_count-min_dist[H-1][W-1])
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
BC = []
for b in B:
    C2 = C[:]
    ok = bisect.bisect(C2,b)
    if ok!=N:
        bisect.insort(C2,b)
        for _ in range(N-ok):
            BC.append(C2[ok:])
for a in A:
    for bc in BC:
        if bisect.bisect(bc,a)==0:
            ans += 1
print(ans)


Fixed submission:
import bisect
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
for b in B:
    ok_a = bisect.bisect_left(A,b)
    ok_c = bisect.bisect_right(C,b)
    if ok_a!=0 and ok_c!=N:
        ans += ok_a*(N-ok_c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
BC = []
for b in B:
    C2 = C[:]
    ok = bisect.bisect(C2,b)
    if ok!=N:
        bisect.insort(C2,b)
        for _ in range(N-ok):
            BC.append(C2[ok:])
for a in A:
    for bc in BC:
        if bisect.bisect(bc,a)==0:
            ans += 1
print(ans)

Fixed submission:
import bisect
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
for b in B:
    ok_a = bisect.bisect_left(A,b)
    ok_c = bisect.bisect_right(C,b)
    if ok_a!=0 and ok_c!=N:
        ans += ok_a*(N-ok_c)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
print(s[0]+(len(s)-2)+s[-1])

Fixed submission:
s = input()
len = len(s)-2
print(s[0]+str(len)+s[-1])
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                count += 1
print(count)

Fixed submission:
K,S = map(int,input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i -j
        if 0 <= k <= K: 
            count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
a=list(map(int, input().split()))
ans=1
for v in a:
	ans*=v
if 1000000000000000000 < ans:
	ans = -1
print(ans)


Fixed submission:
N=input()
a=list(map(int, input().split()))
#print(a)
ans=1
for v in a:
	ans*=v
	if 1000000000000000000 < ans:
		ans = -1
		break
if any([v==0 for v in a]):
	ans=0
print(ans)

Buggy python submission (verdict: Runtime Error):
N=input()
if not N:
	break
a=list(map(int, input().split(" ")))
ans=1
for v in a:
	ans*=v
if 1000000000000000000 < ans:
	ans = -1
print(ans)


Fixed submission:
N=input()
a=list(map(int, input().split()))
#print(a)
ans=1
for v in a:
	ans*=v
	if 1000000000000000000 < ans:
		ans = -1
		break
if any([v==0 for v in a]):
	ans=0
print(ans)

Buggy python submission (verdict: Runtime Error):
while True:
	N=input()
	if not N:
		break
	a=list(map(int, input().split(" ")))
	ans=1
	for v in a:
		ans*=v
	if 1000000000000000000 < ans:
		ans = -1
	print(ans)


Fixed submission:
N=input()
a=list(map(int, input().split()))
#print(a)
ans=1
for v in a:
	ans*=v
	if 1000000000000000000 < ans:
		ans = -1
		break
if any([v==0 for v in a]):
	ans=0
print(ans)

Buggy python submission (verdict: Runtime Error):
while True:
	N=input()
	if not N:
		break
	a=list(map(int, input().split(" ")))
	ans=1
	for v in a:
		ans*=v
	if 1000000000000000000 < ans:
		ans = -1
	print(ans)


Fixed submission:
N=input()
a=list(map(int, input().split()))
#print(a)
ans=1
for v in a:
	ans*=v
	if 1000000000000000000 < ans:
		ans = -1
		break
if any([v==0 for v in a]):
	ans=0
print(ans)
Buggy python submission (verdict: Runtime Error):
print input

Fixed submission:
a = input()
print(a[0:3])
Buggy python submission (verdict: Runtime Error):
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))

Fixed submission:
from math import pi, cos,  sqrt
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))