Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
a = list(map(int,input().split( )))

l = []
X = sum(a)
for i in range(N-1):
	x = sum(a[:i+1])
	l.append(abs(X - 2 * x))

print(min(l))

Fixed submission:
N =int(input())
a = list(map(int,input().split( )))

X = sum(a)
x = 0
ans = 10**100

for i in range(N-1):
	x += a[i]
	ans = min(ans,abs(X - 2 * x))
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
a = list(map(int,input().split( )))

l = []
for i in range(N-1):
	x = sum(a[:i+1])
	y = sum(a) - x
	l.append(abs(x-y))

print(min(l))

Fixed submission:
N =int(input())
a = list(map(int,input().split( )))

X = sum(a)
x = 0
ans = 10**100

for i in range(N-1):
	x += a[i]
	ans = min(ans,abs(X - 2 * x))
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N =  int(input())
a = list(map(int,input().split( )))
ans = a[0]
if N % 2  == 1:
	for i in range(N-1):
		if (i+1) % 2 == 0:
			ans = str(a[i+1]) + ' ' + str(ans)
		else:
			ans = str(ans) + ' ' + str(a[i+1])
else:
	for i in range(N-1):
		if (i+1) % 2 == 1:
			ans = str(a[i+1]) + ' ' + str(ans)
		else:
			ans = str(ans) + ' ' + str(a[i+1])

print(ans)

Fixed submission:
N =  int(input())
a = list(map(int,input().split( )))

#if N % 2 == 0:
a_1 = a[0::2]
a_2 = a[1::2]
if N % 2 == 0:
	ans_list = a_2[::-1] + a_1
else:
	ans_list = a_1[::-1] + a_2

ans = ''
for i in range(N):
	if i == N-1:
		ans += str(ans_list[i])
	else:
		ans += str(ans_list[i]) + ' '
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a = list(map(int, input().split()))

d = np.arange(0, 3600, 400)
c = []

for i in range(N):
	for j in range(len(d)-1):
		if d[j] <= a[i] < d[j + 1]:
			c.append(j)
	if a[i] >= 3200:
		c.append(8)

import collections
c_dict=collections.Counter(c)

s_val, s_count=zip(*c_dict.most_common())
nana_ika = [x for x in s_val if x < 8]

if not 8 in s_val:
	print(len(nana_ika), len(nana_ika))

else:
	if len(nana_ika) == 0:
		print(1, c_dict[8])
	elif 8 - len(nana_ika) > c_dict[8]:
		print(len(nana_ika), len(nana_ika) + c_dict[8])
	elif 8 -len(nana_ika) <= c_dict[8]:
		print(len(nana_ika), 8)



Fixed submission:
r, g, b = map(str, input().split( ))
ans = 'NO'

if int(r + g + b) % 4 ==0:
	ans = 'YES'
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, K = map(int,input().split( ))

a = []
b = []

for i in range(N):
	a_i, b_i = map(int, input().split( ))
	a.append(a_i)
	b.append(b_i)

d = defaultdict(int)

for i in range(N):
    if a[i] in d:
        d[a[i]] += b[i]
    else:
        d[a[i]] = b[i]

d_sorted = sorted(d.items())

l = 0
for a_i,b_i in d_sorted.items():
	l += b_i
	if l >= K:
		print(a_i)
		break


Fixed submission:
from collections import defaultdict

N, K = map(int,input().split( ))

a = []
b = []

for i in range(N):
	a_i, b_i = map(int, input().split( ))
	a.append(a_i)
	b.append(b_i)

d = defaultdict(int)

for i in range(N):
    if a[i] in d:
        d[a[i]] += b[i]
    else:
        d[a[i]] = b[i]

d_sorted = sorted(d.items())

l = 0

for i in range(N):
	a_i = d_sorted[i][0]
	b_i = d_sorted[i][1]
	l += b_i
	if l >= K:
		print(a_i)
		break

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split( ))
l = []
for i in range(N):
	a, b = map(int, input().split( ))
	l.append(b)
	print(l)
	if sum(l) > K-1:
		print(a)
		break


Fixed submission:
from collections import defaultdict

N, K = map(int,input().split( ))

a = []
b = []

for i in range(N):
	a_i, b_i = map(int, input().split( ))
	a.append(a_i)
	b.append(b_i)

d = defaultdict(int)

for i in range(N):
    if a[i] in d:
        d[a[i]] += b[i]
    else:
        d[a[i]] = b[i]

d_sorted = sorted(d.items())

l = 0

for i in range(N):
	a_i = d_sorted[i][0]
	b_i = d_sorted[i][1]
	l += b_i
	if l >= K:
		print(a_i)
		break

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split( ))
l = []
for i in range(N):
	a, b = map(int, input().split( ))
	for i in range(b):
		l.append(a)
l.sort()
print(l[K-1])

Fixed submission:
from collections import defaultdict

N, K = map(int,input().split( ))

a = []
b = []

for i in range(N):
	a_i, b_i = map(int, input().split( ))
	a.append(a_i)
	b.append(b_i)

d = defaultdict(int)

for i in range(N):
    if a[i] in d:
        d[a[i]] += b[i]
    else:
        d[a[i]] = b[i]

d_sorted = sorted(d.items())

l = 0

for i in range(N):
	a_i = d_sorted[i][0]
	b_i = d_sorted[i][1]
	l += b_i
	if l >= K:
		print(a_i)
		break
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = []
ans = ''
for i in range(n):
	s = list(input())
	S.append(s)


S[0].sort()

for i in range(len(S[0])):
	if n == 1:
		ans = ''.join(S[0])
        break
	a = S[0][i]
	l = 0
	for j in range(n - 1):
		if a in S[j + 1]:
			S[j + 1].remove(a)
			l += 1
		if l == n - 1:
			ans += a


print(ans)

Fixed submission:
n = int(input())
S = []
ans = ''
for i in range(n):
	s = list(input())
	S.append(s)


S[0].sort()

for i in range(len(S[0])):
	if n == 1:
		ans = ''.join(S[0])
	a = S[0][i]
	l = 0
	for j in range(n - 1):
		if a in S[j + 1]:
			S[j + 1].remove(a)
			l += 1
		if l == n - 1:
			ans += a


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

d = {}
ans = []

for i in range(N):
    S = input()
    d.setdefault(S,0)
    d[S] += 1

for key in d.keys():
    if d[key] == max(d.values()):
        ans.append(key)
        
ans = sorted(ans)

for word in ans:
    print(word)

Fixed submission:
N = int(input())

d = {}
ans = []

for i in range(N):
    S = input()
    d.setdefault(S,0)
    d[S] += 1

max = max(d.values())
for key in d.keys():
    if d[key] == max:
        ans.append(key)
        
ans = sorted(ans)

for word in ans:
    print(word)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

for i in range(N):
    P[i] = (1 + P[i])/2

for i in range(1,N):
    P[i] += P[i-1]

for i in range(K,N):
    T[i] = P[i] - P[i-K]

T = T[K:]

if N == 1:
    print(P[i])
else:
    print(max(T))

Fixed submission:
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

for i in range(N):
    P[i] = (1 + P[i])/2

if N == K:
    print(sum(P))

else:
    for i in range(1,N):
        P[i] += P[i-1]

    for i in range(K,N):
        T[i] = P[i] - P[i-K]

    T = T[K:]

    print(max(T))

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

for i in range(N):
    P[i] = (1 + P[i])/2

for i in range(1,N):
    P[i] += P[i-1]

for i in range(K,N):
    T[i] = P[i] - P[i-K]

T = T[K:]

print(max(T))

Fixed submission:
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

for i in range(N):
    P[i] = (1 + P[i])/2

if N == K:
    print(sum(P))

else:
    for i in range(1,N):
        P[i] += P[i-1]

    for i in range(K,N):
        T[i] = P[i] - P[i-K]

    T = T[K:]

    print(max(T))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
T = [0]*N
ans = 0

for i in range(N):
    T[i] = min([P[0]]+P[:i])

for i in range(N):
    if P[i] <= T[i]:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
T = [P[0]]+[10**10]*(N-1)
ans = 0

for i in range(N):
    T[i] = min(T[i-1],P[i])

for i in range(N):
    if P[i] <= T[i]:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
K,X = map(int,input().split())

l = max(X-K+1,-1000000)
r = min(X+K-1,1000000)

ans = []

for i in range(l,r+1):
    ans.append(str(i))

ans = " ".join(ans)

print(ans)

Fixed submission:
N = int(input())

ans = 0
d = {}

for i in range(N):
    txt = "".join(sorted(input()))
    d.setdefault(txt,0)
    
    ans += d[txt]
    d[txt] += 1
    
print(ans)

Buggy python submission (verdict: Runtime Error):
K,X = map(int,input().split())

l = max(X-K+1,-1000000)
r = min(X+K-1,1000000)

ans = []

for i in range(l,r+1):
    ans.append(str(i))

ans = " ".join(ans)

print(ans)

Fixed submission:
N = int(input())

ans = 0
d = {}

for i in range(N):
    txt = "".join(sorted(input()))
    d.setdefault(txt,0)
    
    ans += d[txt]
    d[txt] += 1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

l = []
c = 0

for i in range(N):
    text = "".join(sorted(list(input())))
    l.append(text)
    l = sorted(l)
    
for j in range(N):
    for k in range(j+1,N):
        if l[j] == l[k]:
            c += 1
        else:
            break

print(c)

Fixed submission:
N = int(input())

ans = 0
d = {}

for i in range(N):
    txt = "".join(sorted(input()))
    d.setdefault(txt,0)
    
    ans += d[txt]
    d[txt] += 1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = [int(input()) for i in range(N)]

for i in range(N):
    new_A = A.copy()
    del new_A[i]
    print(sorted(new_A)[-1])

Fixed submission:
N = int(input())

l = [int(input()) for i in range(N)]

new_l = sorted(l)

fmax = new_l[N-1]
fmax2 = new_l[N-2]
smax = fmax

for j in reversed(range(N)):
    if not new_l[j] == fmax:
        smax = new_l[j]
        break

if fmax == fmax2:
    for k in range(N):
        print(fmax)
else:
    for m in range(N):
        if l[m] == fmax:
            print(smax)
        else:
            print(fmax)
Buggy python submission (verdict: Runtime Error):
#! python3
#  solve_133B.py

import math

def dis(Y,Z):
    ans = 0
    for i in range(len(Y)):
        ans += (Y[i] - Z[i])**2
    return math.sqrt(ans)


N,D = map(int,input(().split()))
X = []
ans = 0

for i in range(N):
    X.append(list(map(int,input().split())))

for i in range(N):
    for j in range(i,N):
       if dis(i,j) % 1 == 0:
           ans += 1

print(ans)

Fixed submission:
#! python3
#  solve_133B.py

import math



N,D = map(int,input().split())
X = []
ans = 0


def dis(Y,Z):
    ans = 0
    for i in range(D):
        ans += (Y[i] - Z[i])**2
    return math.sqrt(ans)

for i in range(N):
    X.append(list(map(int,input().split())))

for i in range(N):
    for j in range(i+1,N):
       if dis(X[i],X[j]) % 1 == 0:
           ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())

ans = 2018

for i in range(L,min(R,L+2020)):
    for j in range(i+1,R+1):
        if (i*j) % 2019 <= ans:
            ans = (i*j) % 2019

print(ans)

Fixed submission:
L,R = map(int,input().split())

ans = 2018

for i in range(L,min(R,L+2100)):
    for j in range(i+1,min(R+1,i+2100)):
        if (i*j) % 2019 <= ans:
            ans = (i*j) % 2019

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())

ans = 2019

for i in range(L,R+1):
    for j in range(L,i):
        if (i*j) % 2019 <= ans:
            ans = (i*j) % 2019

print(ans)

Fixed submission:
L,R = map(int,input().split())

ans = 2018

for i in range(L,min(R,L+2100)):
    for j in range(i+1,min(R+1,i+2100)):
        if (i*j) % 2019 <= ans:
            ans = (i*j) % 2019

print(ans)

Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())

count = 0

for i in range(A,B+1):
    if not i % C == 0:
        if not i % D ==0:
            count += 1

print(count)

Fixed submission:
L,R = map(int,input().split())

ans = 2018

for i in range(L,min(R,L+2100)):
    for j in range(i+1,min(R+1,i+2100)):
        if (i*j) % 2019 <= ans:
            ans = (i*j) % 2019

print(ans)
Buggy python submission (verdict: Runtime Error):
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1

Fixed submission:
N = int(input())
l = list(map(int,input().split()))

new_l = sorted(l)
half1 = new_l[N//2-1]
half2 = new_l[N//2]

if half1 == half2:
    print(0)
else:
    print(half2-half1)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())

count = 0

for i in range(A,B+1):
    if not i % C == 0:
        if not i % D ==0:
            count += 1

print(count)

Fixed submission:
import math

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

#C,Dの最小公倍数
E = C*D//math.gcd(C,D)
def num_mult(fro,to,mult):
    goal = to//mult
    if fro % mult == 0:
        start = fro // mult
    else:
        start = fro // mult + 1
    
    return goal - start + 1

ans = B-A+1
#Cの倍数
ans -= num_mult(A,B,C)
#Dの倍数
ans -= num_mult(A,B,D)
#C,Dの公倍数
ans += num_mult(A,B,E)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(N):
    s,p = input().split()
    l.append([s,int(p),i+1])

l = sorted(l,key = lambda x:x[1],reverse=True)
l = sorted(l,key = lambda x:x[0])

for i in range(N):
    print(l[2])

Fixed submission:
N = int(input())
l = []
for i in range(N):
    s,p = input().split()
    l.append([s,int(p),i+1])

l = sorted(l,key = lambda x:x[1],reverse=True)
l = sorted(l,key = lambda x:x[0])

for i in range(N):
    print(l[i][2])
Buggy python submission (verdict: Runtime Error):
A,B = map(int(input()).split())

if A >= 13:
  print(B)
elif 6<=A<=12:
  print(B/2)
else:
  print(0)

Fixed submission:
A,B = map(int,input().split())
 
if A >= 13:
  print(B)
elif 6<=A<=12:
  print(B//2)
else:
  print("0")
Buggy python submission (verdict: Runtime Error):
#! python3
#  solve127A.py

age,cost = map(int,input().split())

if age <= 5:
    cost = 0
elif 6 <= age <= 12:
    cost = cost//2
elif 7 <= age:
    cost = cost

print(cost)

Fixed submission:
r,D,x =map(int,input().split())
 
for i in range(10):
	x = r*x-D
	print(x)

Buggy python submission (verdict: Runtime Error):
r,D,x =map(int,input().split())

for i in range(10)
	x = r*x-D
  	print(x)

Fixed submission:
r,D,x =map(int,input().split())
 
for i in range(10):
	x = r*x-D
	print(x)
Buggy python submission (verdict: Runtime Error):
l = [int(input()) for i in range(4)]

for i in range(4):
  for j in range(4):
    if l[i]*l[j]>l[4]:
      print(":(")
      break
    else:
      print("Yay!")

Fixed submission:
l = [int(input()) for i in range(6)]

if l[4]-l[0]>l[5]:
    print(":(")
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
l = list(map(int,input().split()))

for i in range(4):
  for j in range(4):
    if l[i]*l[j]>k:
      print(":(")
      break
    else:
      print("Yay!")

Fixed submission:
l = [int(input()) for i in range(6)]

if l[4]-l[0]>l[5]:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
#! python3
#  solve_122C.py

N,Q = map(int,input().split())
S = input()

for i in range(Q):
    l,r = map(int,input().split())
    cutted_str = S[l-1:r]
    print(cutted_str.count("AC"))

Fixed submission:
#! python3
#  solve_122C.py

N,Q = map(int,input().split())
S = input()

t = [0]*(N+1) #ACの内Aの番号を格納(?番目形式)

for i in range(N-1):
    if S[i:i+2] == "AC":
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for i in range(Q):
    l,r  = map(int,input().split())
    print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input())
print(a/b)

Fixed submission:
T,X = map(int,input().split())
print(T/X)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))

nl = sorted(l)

for i in range(n-1):
	other = 0 + n1[i]

if other < nl[n-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
N = int(input())
L = sorted(list(map(int,input().split())))

if L[-1] < sum(L[0:N-1]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
age = int(input())

if age == 3,5,7:
  print("YES")
else:
  print("NO")

Fixed submission:
age = int(input())
 
if age == 3 or age == 5 or age == 7:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
age = int(input())
A = int(input())
B = int(input())

if age == 1:
  print("Hello World")
  
else:
  print(A+B)

Fixed submission:
age = int(input())
 
if age == 1:
  print("Hello World")
  
else:
  A=int(input())
  B =int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
judge = 1

for i in range(K+1):
    if S[i] != "1":
        print(S[i])
        judge = 0
        break

if judge != 0:
    print("1")

Fixed submission:
S = input()
K = int(input())
judge = 1

for i in range(K):
    if S[i] != "1":
        print(S[i])
        judge = 0
        break

if judge != 0:
    print("1")
Buggy python submission (verdict: Runtime Error):
old_list = list(map(int, input().split()))
n = old_list.sort()

print(n[3]-n[0])

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

print(max(list)-min(list))
Buggy python submission (verdict: Runtime Error):
l = list(map(int,input().split()))
task_list = sorted(l)

print(task_list[2]-task_list[0])

Fixed submission:
S = input()
T = input()*2

if S in T:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a = list(map(str,input().split()))
 
num = 0
 
for i in range [0,1,2,3]:
  if a[i] == "+":
    num +=1
  else:
    num -=1
 
print(num)    


Fixed submission:
s = input()

print(s.count("+")-s.count("-"))

Buggy python submission (verdict: Runtime Error):
a = list(map(str,input().split()))

num = 0

for i in range len a:
  if a[i] = "+":
    num +=1
  else:
    num -=1

print(num)

Fixed submission:
s = input()

print(s.count("+")-s.count("-"))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
	if a*b % 2 ==0:
    	print("Even")
    else:
      print("Odd")

Fixed submission:
a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
Buggy python submission (verdict: Runtime Error):
r = input()
print(3*r*r)

Fixed submission:
r = int(input())
print(3*r*r)

Buggy python submission (verdict: Runtime Error):
r = 0

s = 3*r*r
printf(s)

Fixed submission:
r = int(input())
print(3*r*r)
Buggy python submission (verdict: Runtime Error):
n,d = (int(x) for x in input().split())
if n//(2*d) = 0:
  print(n/(2*d))
else:
  print(n/(2*d)+1)

Fixed submission:
n,d = (int(x) for x in input().split())
if n % (2*d + 1) == 0:
  print(n//(2*d + 1))
else:
  print(n//(2*d + 1) + 1)

Buggy python submission (verdict: Runtime Error):
n,d = (int(x) for x in input().split())
print(n/2d)

Fixed submission:
n,d = (int(x) for x in input().split())
if n % (2*d + 1) == 0:
  print(n//(2*d + 1))
else:
  print(n//(2*d + 1) + 1)

Buggy python submission (verdict: Runtime Error):
N,D = array(input(),input())
print(roundup(N/2D ,0)

Fixed submission:
n,d = (int(x) for x in input().split())
if n % (2*d + 1) == 0:
  print(n//(2*d + 1))
else:
  print(n//(2*d + 1) + 1)
Buggy python submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%k==0:
    a=1
if a==1:
  print("OK")
else:
  print("NG")
    


Fixed submission:
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%K==0:
    a=1
if a==1:
  print("OK")
else:
  print("NG")

Buggy python submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%k==0:
    a=1
if a=1:
  print("OK")
else:
  print("NG")
    

Fixed submission:
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%K==0:
    a=1
if a==1:
  print("OK")
else:
  print("NG")
Buggy python submission (verdict: Runtime Error):
S=input()
if S[1]==S[2]==S[3] or S[2]==S[3]==S[4]:
  print("Yes")
else:
  print("No")

Fixed submission:
S=input()
if S[0]==S[1]==S[2] or S[1]==S[2]==S[3]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
K+=1
ans=0
a=max(0,S-2*K)
for i in range(a,K):
  if i>S:
    break
  for j in range(a,K):
    if i+j>S :
      break
    for k in range (a,K):
      if i+j+k>S:
        break
      if i+j+k==S:
        ans+=1
print(ans)

Fixed submission:
K,S=map(int,input().split())
ans=0
#a=max(0,S-2*K)
for i in range(K+1):
  for j in range(K+1):
    if i+j+K>=S and i+j<=S :
      ans+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
K+=1
ans=0
for i in range(K):
  if i>S:
    break
  for j in range(K):
    if i+j>S :
      break
    for k in range (K):
      if i+j+k>S:
        break
      if i+j+k==S:
        ans+=1
print(ans)

Fixed submission:
K,S=map(int,input().split())
ans=0
#a=max(0,S-2*K)
for i in range(K+1):
  for j in range(K+1):
    if i+j+K>=S and i+j<=S :
      ans+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
K+=1
ans=0
for i in range(K):
  for j in range(K):
    if i+j>S :
      break
    for k in range (K):
      if i+j+k==S:
        ans+=1
print(ans)

Fixed submission:
K,S=map(int,input().split())
ans=0
#a=max(0,S-2*K)
for i in range(K+1):
  for j in range(K+1):
    if i+j+K>=S and i+j<=S :
      ans+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
K+=1
ans=0
for i in range(K):
  for j in range(K):
    for k in range (K):
      if(i+j+k==S):
        ans+=1
print(ans)

Fixed submission:
K,S=map(int,input().split())
ans=0
#a=max(0,S-2*K)
for i in range(K+1):
  for j in range(K+1):
    if i+j+K>=S and i+j<=S :
      ans+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N  = int(input())
nums = list(map(int,input().split()))
nums.sort()
cnt = 0
for i in range(min(nums),max(nums)+1):
  if len(list(j for j in nums if j >= i)) == N //2 :
    cnt += 1
print(cnt)

Fixed submission:
N  = int(input())
nums = list(map(int,input().split()))
nums.sort()
cnt = nums[N//2] - nums[N//2-1] 
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a,b = map(int, input().split())
former_set = { i for i in range(a,b+1)}
for i in range(M-1):
  a,b =  map(int, input().split())
  tmp_set = { i for i in range(a,b+1)}
  former_set = tmp_set & former_set
print(len(former_set))

Fixed submission:
N,M = map(int,input().split())
a = list()
b = list()
for i in range(M):
  tmp_a,tmp_b =  map(int, input().split())
  a.append(tmp_a)
  b.append(tmp_b)
print(min(b)-max(a)+1 if min(b)-max(a) >= 0 else 0)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
former_set = set()
for i in range(M):
  a,b =  map(int, input().split())
  if i != 0: 
    tmp_set = { i for i in range(a,b+1)}
    former_set = tmp_set & former_set
  else:
    former_set = { i for i in range(a,b+1)}
print(len(former_set))

Fixed submission:
N,M = map(int,input().split())
a = list()
b = list()
for i in range(M):
  tmp_a,tmp_b =  map(int, input().split())
  a.append(tmp_a)
  b.append(tmp_b)
print(min(b)-max(a)+1 if min(b)-max(a) >= 0 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K,S = map(int,input().split())
c = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i+j+k == S:
        c += 1
print(c)

Fixed submission:
K,S = map(int,input().split())
c = 0
for i in range(K+1):
  for j in range(K+1):
      if 0 <= S-(i+j) <= K:
        c += 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K,S = map(int,input().split())
c = 0
for i in itertools.product(range(K+1), repeat=3):
  if sum(i) == S:
    c += 1
print(c)

Fixed submission:
K,S = map(int,input().split())
c = 0
for i in range(K+1):
  for j in range(K+1):
      if 0 <= S-(i+j) <= K:
        c += 1
print(c)