Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        a = (i*j)%2019
        ans = min(ans,a)
        if a == 0:
            break
        else:
            continue
        break
print(ans)

Fixed submission:
l,r = map(int,input().split())
value = 2019
if r - l > 2019:
    print(0)
else:
    l1 = l%2019
    r1 = r%2019
    ans = 100000000
    if r1>l1:
        for i in range(l,r):
            for j in range(i+1,r+1):
                if ans>(i*j)%2019:
                    ans = (i*j)%2019
        print(ans)
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
li = []
ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        a = (i*j)%2019
        ans = min(ans,a)
        if a == 0:
            break
print(ans)

Fixed submission:
l,r = map(int,input().split())
value = 2019
if r - l > 2019:
    print(0)
else:
    l1 = l%2019
    r1 = r%2019
    ans = 100000000
    if r1>l1:
        for i in range(l,r):
            for j in range(i+1,r+1):
                if ans>(i*j)%2019:
                    ans = (i*j)%2019
        print(ans)
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
li = []
for i in range(l,r):
    for j in range(i+1,r+1):
        li.append((i*j)%2019)
print(min(li))

Fixed submission:
l,r = map(int,input().split())
value = 2019
if r - l > 2019:
    print(0)
else:
    l1 = l%2019
    r1 = r%2019
    ans = 100000000
    if r1>l1:
        for i in range(l,r):
            for j in range(i+1,r+1):
                if ans>(i*j)%2019:
                    ans = (i*j)%2019
        print(ans)
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
s = input()
first = s[0]
cnt_f = 0
cnt_s = 0
for i in range(len(s)):
    if s[i] != first:
        second = s[i]
        break
for i in range(len(s)):
    if s[i] == first:
        cnt_f+=1
    if s[i] == second:
        cnt_s+=1
if cnt_f == 2 and cnt_s == 2:
    print("Yes")
else:
    print("No")



Fixed submission:
s = input()
first = s[0]
second = ""
cnt_f = 0
cnt_s = 0
for i in range(len(s)):
    if s[i] != first:
        second = s[i]
        break
for i in range(len(s)):
    if s[i] == first:
        cnt_f+=1
    if s[i] == second:
        cnt_s+=1
if cnt_f == 2 and cnt_s == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int,input().split()))
d = 0
cnt = 1
for i in range(N+1):
    d = d + L[i]
    if d>X:
        break
    else:
        cnt+=1
print(cnt)


Fixed submission:
N,X = map(int, input().split())
L = list(map(int,input().split()))
d = 0
cnt = 1
for i in range(N):
    d = d + L[i]
    if d>X:
        break
    else:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(map(int,input().split()))
q = []
for i in range(m):
    b,c = map(int,input().split())
    q.append([c,b])
q.sort(reverse=True)
for i in range(m):
    cnt = 0
    for j in range(n):
        if a[j] < q[i][0]:
            a[j] = q[i][0]
            cnt+=1
        if cnt == q[i][1]:
            break
print(sum(a))

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
q = []
for i in range(m):
    b,c = map(int,input().split())
    q.append([c,b])
q.sort(reverse=True)
j = 0
for i in range(m):
    while j < len(a) and q[i][1]>0:
        if a[j]<q[i][0]:
            a[j] = q[i][0]
            q[i][1] -= 1
        j+=1
print(sum(a))
Buggy python submission (verdict: Runtime Error):
s = input()
len_li = []
cnt = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == "C" or s[i] == "G" or s[i] == "T":
        cnt+=1
    else:
        len_li.append(cnt)
        cnt = 0 
print(max(len_li))

Fixed submission:
s = input()
len_li = [0]
cnt = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        cnt+=1
    else:
        len_li.append(cnt)
        cnt = 0 
len_li.append(cnt)
print(max(len_li))
Buggy python submission (verdict: Runtime Error):
import numpy as np
n,q = map(int,input().split())
s = input()
check = np.zeros(n)
for i in range(n):
    if s[i] == "A" and s[i+1] == "C":
        check[i] = 1
for i in range(q):
    l,r = map(int,input().split())
    cnt = 0
    for j in range(l-1,r-1):
        if check[j] == 1:
            cnt += 1
    print(cnt)

Fixed submission:
n,q = map(int,input().split())
s = input()
li = [0]*n
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        li[i+1] = li[i] + 1
    else:
        li[i+1] = li[i]
for i in range(q):
    l,r = map(int,input().split())
    print(li[r-1]-li[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
cnt = 0
while True:
    state = False
    if len(s) == 0:
        break
    li = []
    for i in s:
        li.append(i)
    for i in range(len(li)-1):
        if li[i] == "0" and li[i+1] == "1":
            li[i] = ""
            li[i+1] = ""
            cnt+=1
            state = True
            break
        elif li[i] == "1" and li[i+1] == "0":
            li[i] = ""
            li[i+1] = ""
            cnt+=1
            state = True
            break
    if state == False:
        break
    s = ""
    for i in range(len(li)):
        s += li[i]
print(cnt*2)
    

Fixed submission:
s = input()
cnt1 = 0
cnt0 = 0
for i in range(len(s)):
    if s[i] == "0":
        cnt0 +=1
    else:
        cnt1+=1
print(min(cnt0,cnt1)*2)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
cnt = 0
while True:
    state = False
    if len(s) == 0:
        break
    li = []
    for i in s:
        li.append(i)
    for i in range(len(li)-1):
        if li[i] == "0" and li[i+1] == "1":
            li[i] = ""
            li[i+1] = ""
            cnt+=1
            state = True
        elif li[i] == "1" and li[i+1] == "0":
            li[i] = ""
            li[i+1] = ""
            cnt+=1
            state = True
    s = ""
    for i in range(len(li)):
        s += li[i]
    if state == False:
        break
print(cnt*2)
    

Fixed submission:
s = input()
cnt1 = 0
cnt0 = 0
for i in range(len(s)):
    if s[i] == "0":
        cnt0 +=1
    else:
        cnt1+=1
print(min(cnt0,cnt1)*2)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
diff = []
if m == 1:
    print(0)
    sys.exit()
for i in range(m-1):
    d = x[i+1] - x[i]
    diff.append(d)
diff.sort(reverse= True)
for i in range(n-1):
    diff[i] = 0
print(sum(diff))

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
diff = []
visit = [False]*m
visit[0] = True
if m == 1 or n>=m:
    print(0)
    sys.exit()
for i in range(m-1):
    d = x[i+1] - x[i]
    diff.append(d)
diff.sort(reverse= True)
for i in range(n-1):
    diff[i] = 0
print(sum(diff))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
INF = 10**18

if __name__ == "__main__":
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [INF]*n
    dp[0] = 0
    for i in range(1,n):
        c = INF
        for j in range(max(i-k,0),i):
            d = dp[j] + abs(h[j]-h[i])
            c = min(c,d)
        dp[i] = c
    print(dp[-1])

Fixed submission:
import sys
INF = 10**18

if __name__ == "__main__":
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [INF]*n
    dp[0] = 0
    for i in range(1,n):
        c = INF
        for j in range(max(i-k,0),i):
            d = dp[j] + abs(h[j]-h[i])
            c = min(c,d)
        dp[i] = c
    print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__ == "__main__":
    n,x = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    a = bisect.bisect_left(X,x)
    X.insert(a,x)
    ans = []
    for i in range(1,len(X)):
        diff = X[i] - X[i-1]
        ans.append(diff)
    d = ans[0]
    for i in range(1,len(ans)):
        d = math.gcd(d,ans[i])
    print(d)
    

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

if __name__ == "__main__":
    n,x = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    a = bisect.bisect_left(X,x)
    X.insert(a,x)
    ans = []
    for i in range(1,len(X)):
        diff = X[i] - X[i-1]
        ans.append(diff)
    d = ans[0]
    for i in range(1,len(ans)):
        d = gcd(d,ans[i])
    print(d)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
import funtools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
if n%2 == 0:
    print(n)
else:
    print(2*n)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n = int(input())
if n%2 == 0:
    print(n)
else:
    print(2*n)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

d,n = map(int,input().split())
a = 100**d
c = [1]
for i in range(n):
    if i%100 == 0:
        continue
    c.append(a*i)
print(c[n])

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

d,n = map(int,input().split())
if n != 100:
    print(n*100**d)
else:
    print(101*100**d)

Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

d,n = map(int,input().split())
a = 100**d
c = []
for i in range(n+1):
    if i%100 == 0:
        continue
    c.append(a*i)
print(c[n-1])

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

d,n = map(int,input().split())
if n != 100:
    print(n*100**d)
else:
    print(101*100**d)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**9

if __name__ == "__main__":
    n = int(input())
    m = [1]
    dp = [INF]*201010
    t = 6
    q = 9
    while t<=n:
        m.append(t)
        t*=6
    while q<=n:
        m.append(q)
    for i in m:
        dp[i] = 1
    
    for i in range(1,n):
        for j in m:
            dp[i+j] = min(dp[i+j],dp[i]+1)
    print(dp[n])

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**9

if __name__ == "__main__":
    n = int(input())
    m = [1]
    dp = [101010]*201010
    t = 6
    q = 9
    while t<=n:
        m.append(t)
        t*=6
    while q<=n:
        m.append(q)
        q*=9
    for i in m:
        dp[i] = 1
    
    for i in range(1,n):
        for j in m:
            dp[i+j] = min(dp[i+j],dp[i]+1)
    print(dp[n])
Buggy python submission (verdict: Runtime Error):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,c = map(int,input().split())
li = [a,b,c]
li.sort()
cnt = 0
while a[2] != a[1]:
    a[0] += 1
    a[1] += 1
    cnt+=1
cnt += (a[1]-a[0])//2
if (a[1]-a[2])%2 != 0:
    cnt += 2
print(cnt)


Fixed submission:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,c = map(int,input().split())
li = [a,b,c]
li.sort()
cnt = 0
while li[2] != li[1]:
    li[0] += 1
    li[1] += 1
    cnt+=1
cnt += (li[1]-li[0])//2
if (li[1]-li[0])%2 != 0:
    cnt += 2
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = 0
while n >= 3:
　　　　n -=3
      cnt+=1
print()

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

N = int(input())
print(N//3)
Buggy python submission (verdict: Runtime Error):
import collections
INF = 10**18
h,w = map(int,input().split())
li = [list(input()) for i in range(h)]
sx,sy,gx,gy = 0,0,h-1,w-1

def bfs(sy,sx):
    #頂点をINFで初期化
    d = [[INF]*w for i in range(h)]
    #移動４方向のベクトル
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    #スタート地点をキューにいれ、頂点を０にする
    que = collections.deque([])
    que.append((sy,sx))
    d[sy][sx] = 0
    #キューが空になるまでループ（行ける要素がなくなるまで）
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 取り出してきた状態がゴールなら探索をやめる
        # 移動4方向をループ
        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            #壁との判定とすでに訪れたかどうかをチェック
            if 0<=nx and nx < w and 0 <= ny and ny < h:
                if li[ny][nx] != "#" and d[ny][nx] == INF:
                    #移動できる点なのでキューについか
                    que.append((ny,nx))
                    #前の点+1で移動できる
                    d[ny][nx] = d[p[0]][p[1]] + 1
    return d[-1][-1]
a = bfs(0,0)-1
if a + 1 == INF:
    print(-1)
    sys.exit()
maxgrid = h*w
cnt = 0
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":
            cnt+=1
ans = maxgrid - cnt - a -2
print(ans)


Fixed submission:
import collections
import sys
INF = 10**18
h,w = map(int,input().split())
li = [list(input()) for i in range(h)]
sx,sy,gx,gy = 0,0,h-1,w-1

def bfs(sy,sx):
    #頂点をINFで初期化
    d = [[INF]*w for i in range(h)]
    #移動４方向のベクトル
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    #スタート地点をキューにいれ、頂点を０にする
    que = collections.deque([])
    que.append((sy,sx))
    d[sy][sx] = 0
    #キューが空になるまでループ（行ける要素がなくなるまで）
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 取り出してきた状態がゴールなら探索をやめる
        # 移動4方向をループ
        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            #壁との判定とすでに訪れたかどうかをチェック
            if 0<=nx and nx < w and 0 <= ny and ny < h:
                if li[ny][nx] != "#" and d[ny][nx] == INF:
                    #移動できる点なのでキューについか
                    que.append((ny,nx))
                    #前の点+1で移動できる
                    d[ny][nx] = d[p[0]][p[1]] + 1
    return d[-1][-1]
a = bfs(0,0)-1
if a + 1 == INF:
    print(-1)
    sys.exit()
maxgrid = h*w
cnt = 0
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":
            cnt+=1
ans = maxgrid - cnt - a -2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for i in range(len(C)):
    b = bisect.bisect_left(B,C[i])
    if b == 0:
        continue
    for j in range(b):
        a = bisect.bisect_left(A,B[j])
        ans += a
print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect.bisect_left(A,b)
    c = n - bisect.bisect_left(C,b+1)
    ans += a*c
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = sorted(list(map(int,input().split())))
c = collections.Counter(a)
if n == 1:
    print(1)
    sys.exit()
item = []
for key,Value in c.items():
    item.append([key,Value])
koho = []
if item[1][0] - item[0][0] == 1:
    cnt = item[1][1] + item[0][1]
else:
    cnt = item[0][1]
koho.append(cnt)
cnt = 0
for i in range(1,n-2):
    cnt = 0
    if item[i][0] - item[i-1][0] == 1:
        cnt += item[i-1][1] + item[i][1]
    if item[i+1][0] - item[i][0] == 1:
        cnt += item[i+1][1]
    koho.append(cnt)
cnt = 0
if item[-1][0] - item[-2][0] == 1:
    cnt += item[-1][1] + item[-2][1]
else:
    cnt += item[-1][1]
koho.append(cnt)
print(max(koho))



Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = sorted(list(map(int,input().split())))
c = collections.Counter(a)
item = []
for key,Value in c.items():
    item.append([key,Value])
koho = []
if len(item) == 1:
    print(item[0][1])
    sys.exit()
if item[1][0] - item[0][0] == 1:
    cnt = item[1][1] + item[0][1]
else:
    cnt = item[0][1]
koho.append(cnt)
cnt = 0
for i in range(1,len(item)-1):
    cnt = 0
    if item[i][0] - item[i-1][0] == 1:
        cnt += item[i-1][1] + item[i][1]
    if item[i+1][0] - item[i][0] == 1:
        cnt += item[i+1][1]
    koho.append(cnt)
cnt = 0
if item[-1][0] - item[-2][0] == 1:
    cnt += item[-1][1] + item[-2][1]
else:
    cnt += item[-1][1]
koho.append(cnt)
print(max(koho))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = list(map(int,input().split()))
x = [0 for i in range(max(a)+1)]
for i in range(n):
    x[a[i]]+=1
li2 = [0]
li4 = [0]
for i in range(len(x)):
    if x[i]>=4:
        li4.append(i)
    elif x[i]>=2:
        li2.append(i)
ans = li4[-1]**2
ans2 = 0
if len(li2)>=2:
    ans2 = li2[-1]*li2[-2]
else:
    ans2 = 0
print(max(ans,ans2))

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
li2 = [0,0]
li4 = [0]
for key,value in c.items():
    if value>=4:
        li4.append(key)
    elif value>=2:
        li2.append(key)
li2.sort()
li4.sort()
ans1 = li2[-1]*li2[-2]
ans2 = li4[-1]**2
ans3 = li4[-1]*li2[-1]
ans = max(ans1,ans2)
ans = max(ans,ans3)
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

o = input()
e = input()
ans = ""
for i in range(len(o)):
    ans += o[i]+e[i]
print(ans)

Fixed submission:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

o = input()
e = input()
ans = ""
for i in range(len(e)):
    ans += o[i] + e[i]
if len(o)>len(e):
    ans += o[-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

o = input()
e = input()
ans = ""
for i in range(len(o) + len(e)):
    if i%2 == 0:
        ans += o[i]
    else:
        ans += e[i]
print(ans)

Fixed submission:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

o = input()
e = input()
ans = ""
for i in range(len(e)):
    ans += o[i] + e[i]
if len(o)>len(e):
    ans += o[-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

a,b,c.d = map(int,input().split())
print(max(a*b,c*d))

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

a,b,c,d = map(int,input().split())
print(max(a*b,c*d))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

k,s = map(int,input().split())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            d = i + j + l
            if d == s:
                cnt+=1
print(cnt)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

k,s = map(int,input().split())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        d = s - i - j
        if d>=0 and d<=k:
            cnt+=1

print(cnt)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = list(map(int,input().split()))

if n%2 == 0:
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    ans = 1
    for i in range(len(item)):
        if 2*i + 1 == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    print(ans%MOD)
else:
    c = collections.Counter(a)
    ans = 1
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    for i in range(1,len(item)):
        if 2*i == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    if item[0][0] == 0 and item[0][1] == 1:
        print(ans%MOD)
    else:
        print(0)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
n = int(input())
a = list(map(int,input().split()))

if n%2 == 0:
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    ans = 1
    for i in range(len(item)):
        if 2*i + 1 == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    print(ans%MOD)
else:
    c = collections.Counter(a)
    ans = 1
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    for i in range(1,len(item)):
        if 2*i == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    if item[0][0] == 0 and item[0][1] == 1:
        print(ans%MOD)
    else:
        print(0)