Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 3*10^5

for i in range(N):
    n = 0

    n += S[:i].count("W")
    n += S[i+1:].count("E")

    if ans > n:
        ans = n

print(ans)


Fixed submission:
N = int(input())
S = input()

n = p = S[1:].count("E")

for i in range(0,N-1):
    if S[i+1] == "E":
        p -= 1
    if S[i] == "W":
        p += 1
    n = min(p, n)

print(n)

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

ans = 3*10^5

for i in range(N):
    n = 0
    for j in range(i):
        if "W" == S[j]:
            n += 1
    for j in range(i+1, N):
        if "E" == S[j]:
            n += 1

    if ans > n:
        ans = n

print(ans)


Fixed submission:
N = int(input())
S = input()

n = p = S[1:].count("E")

for i in range(0,N-1):
    if S[i+1] == "E":
        p -= 1
    if S[i] == "W":
        p += 1
    n = min(p, n)

print(n)
Buggy python submission (verdict: Runtime Error):
x = int(input())
A = int(input())
B = int(input())

x = x-A
n = x//B
print(x-n+*B)

Fixed submission:
x = int(input())
A = int(input())
B = int(input())

x = x-A
n = x//B
print(x-n*B)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(input().split(), int())

if a+b < c+d :
    print("Left")
elif a+b > c+d:
    print("Right")
else:
    print("Balanced")
    

Fixed submission:
a,b,c,d = map(int, input().split())

if a+b < c+d :
    print("Right")
elif a+b > c+d:
    print("Left")
else:
    print("Balanced")
Buggy python submission (verdict: Runtime Error):
l = sum(map(int, input().split()))
n = sum(l)%3
if n == 0:
    print("Yes")
else:
    print("No")

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

if l[0] == l[1] + l[2] or l[1] == l[0] + l[2] or l[2] == l[0] + l[1]:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
l = sum(map(int, input().split()))
n = sum(l)%3
if n == 0:
    print("YES")
else:
    print("NO")

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

if l[0] == l[1] + l[2] or l[1] == l[0] + l[2] or l[2] == l[0] + l[1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 25 00:39:05 2019

@author: yuta
"""

def dic(n,m):
    x = ''.join(sorted(n))
    y = ''.join(sorted(m,reverse = True))
    if x < y:
        print("Yes")
    else:
        print("No")
dic(input(),input())

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 22:23:09 2019

@author: yuta
"""
import math

def pmean(a,b):
    x = math.ceil((a + b)/2)
    print(x)

c = input().split()
pmean(int(c[0]),int(c[1]))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 01:07:09 2019

@author: yuta
"""

NK = list(map(int,input().split()))
A = list(map(int,input().split()))

"""
TLE解法
def main(nk,a):
    k = nk[1]
    a_uni = list(set(a)) #重複なし数列
    a_uni_num = [0]*len(a_uni) #各数字の重複個数
    for i in range(len(a_uni)):
        for j in range(len(a)):
            if a[j] == a_uni[i]:
                a_uni_num[i] += 1
    a_uni_num_sort = sorted(a_uni_num) #重複個数を昇順で並び替え
    red_num = len(a_uni) - k #減らす種類の数
    print(sum(a_uni_num_sort[:red_num]))

main(NK,A)
"""
def main(nk,a):
    k = nk[1]
    a_uni = list(set(a)) #重複なし数列
    a_uni_num = [0]*len(a_uni) #各数字の重複個数
    for i in range(len(a_uni)):
        a_uni_num[i] = a.count(a_uni[i])
    a_uni_num_sort = sorted(a_uni_num) #重複個数を昇順で並び替え
    red_num = len(a_uni) - k #減らす種類の数
    print(sum(a_uni_num_sort[:red_num]))

main(NK,A)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 01:07:09 2019

@author: yuta
"""
import collections

NK = list(map(int,input().split()))
A = list(map(int,input().split()))

"""
TLE解法
def main(nk,a):
    k = nk[1]
    a_uni = list(set(a)) #重複なし数列
    a_uni_num = [0]*len(a_uni) #各数字の重複個数
    for i in range(len(a_uni)):
        for j in range(len(a)):
            if a[j] == a_uni[i]:
                a_uni_num[i] += 1
    a_uni_num_sort = sorted(a_uni_num) #重複個数を昇順で並び替え
    red_num = len(a_uni) - k #減らす種類の数
    print(sum(a_uni_num_sort[:red_num]))

main(NK,A)
"""
def main(nk,a):
    k = nk[1]
    values,counts = zip(*collections.Counter(a).most_common())
    print(sum(counts)-sum(counts[:k]))
main(NK,A)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 01:07:09 2019

@author: yuta
"""

NK = list(map(int,input().split()))
A = list(map(int,input().split()))

def main(nk,a):
    k = nk[1]
    a_uni = list(set(a)) #重複なし数列
    a_uni_num = [0]*len(a_uni) #各数字の重複個数
    for i in range(len(a_uni)):
        for j in range(len(a)):
            if a[j] == a_uni[i]:
                a_uni_num[i] += 1
    a_uni_num_sort = sorted(a_uni_num) #重複個数を昇順で並び替え
    red_num = len(a_uni) - k #減らす種類の数
    print(sum(a_uni_num_sort[:red_num]))

main(NK,A)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 01:07:09 2019

@author: yuta
"""
import collections

NK = list(map(int,input().split()))
A = list(map(int,input().split()))

"""
TLE解法
def main(nk,a):
    k = nk[1]
    a_uni = list(set(a)) #重複なし数列
    a_uni_num = [0]*len(a_uni) #各数字の重複個数
    for i in range(len(a_uni)):
        for j in range(len(a)):
            if a[j] == a_uni[i]:
                a_uni_num[i] += 1
    a_uni_num_sort = sorted(a_uni_num) #重複個数を昇順で並び替え
    red_num = len(a_uni) - k #減らす種類の数
    print(sum(a_uni_num_sort[:red_num]))

main(NK,A)
"""
def main(nk,a):
    k = nk[1]
    values,counts = zip(*collections.Counter(a).most_common())
    print(sum(counts)-sum(counts[:k]))
main(NK,A)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections


def main():
    # N,M は10^5
    N, M = [int(ele) for ele in input().split()]
    tmp = str(1)*N
    ans = int('0b' + tmp, 2)

    for i in range(M):
        l, r = [int(ele) for ele in sys.stdin.readline().split()]

        secure = int('1' * (r-l+1) + '0' * (N-r), 2)
        ans = ans & secure

    print(bin(ans).count("1"))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import collections


def tle_solver():
    # N,M <=10^5
    N, M = [int(ele) for ele in input().split()]
    ans = int('0b' + str(1)*N, 2)

    for i in range(M):
        l, r = [int(ele) for ele in sys.stdin.readline().split()]
        secure = int('1' * (r-l+1) + '0' * (N-r), 2)
        ans = ans & secure

    print(bin(ans).count("1"))


def ac_solver():
    # N,M <=10^5
    N, M = [int(ele) for ele in input().split()]
    ll = 1
    rr = N
    ans = "Error"

    for i in range(M):
        l, r = [int(ele) for ele in sys.stdin.readline().split()]
        ll = max(ll, l)
        rr = min(rr, r)

    ans = max(0, rr - ll+1)
    print(ans)


if __name__ == "__main__":
    # tle_solver()
    ac_solver()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections


def main():
    # N,M は10^5
    N, M = [int(ele) for ele in input().split()]
    tmp = str(1)*N
    ans = int('0b' + tmp, 2)

    for i in range(M):
        l, r = [int(ele) for ele in sys.stdin.readline().split()]

        secure = int('1' * (r-l+1) + '0' * (N-r), 2)
        ans = ans & secure

    print(bin(ans).count("1"))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import collections


def tle_solver():
    # N,M <=10^5
    N, M = [int(ele) for ele in input().split()]
    ans = int('0b' + str(1)*N, 2)

    for i in range(M):
        l, r = [int(ele) for ele in sys.stdin.readline().split()]
        secure = int('1' * (r-l+1) + '0' * (N-r), 2)
        ans = ans & secure

    print(bin(ans).count("1"))


def ac_solver():
    # N,M <=10^5
    N, M = [int(ele) for ele in input().split()]
    ll = 1
    rr = N
    ans = "Error"

    for i in range(M):
        l, r = [int(ele) for ele in sys.stdin.readline().split()]
        ll = max(ll, l)
        rr = min(rr, r)

    ans = max(0, rr - ll+1)
    print(ans)


if __name__ == "__main__":
    # tle_solver()
    ac_solver()
Buggy python submission (verdict: Runtime Error):
import numpy as np
import sys
input = sys.stdin.readline


def main():
    R, G, B, N = [int(ele) for ele in input().split()]
    ans = 0
    for i in range(N+1):
        tmp = N - i*R

        for j in range(N+1):
            tmp2 = tmp - j*G
            if tmp2 < 0:
                break
            if tmp2 % B == 0:
                ans += 1

    print(ans)


def make_prim_nu(n):
    np.set_printoptions(threshold=np.inf)   # 配列の ... 表示を抑制
    N = n                  # 引数の上限値を含める
    is_prime = np.ones((N,), dtype=bool)
    is_prime[:2] = 0
    N_max = int(np.sqrt(N))
    for j in range(2, N_max+1):
        if(is_prime[j]):
            is_prime[j*j::j] = False        # 素数jの間隔で消していく
    primes = np.arange(N)[is_prime]
    return primes


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.readline


def main():
    R, G, B, N = [int(ele) for ele in input().split()]
    ans = 0
    for i in range(N+1):
        tmp = N - i*R

        for j in range(N+1):
            tmp2 = tmp - j*G
            if tmp2 < 0:
                break
            if tmp2 % B == 0:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# vim: set fileencoding=utf-8 :
x, y = map(int, raw_input().split())

if x == y:
    print(-1)
    exit()

n = 1
top = pow(10, 18)

while True:
    t = n * x
    if t >= top:
        print(-1)
        break

    if t % y != 0:
        print(t)
        break

    n += 1


Fixed submission:
# vim: set fileencoding=utf-8 :
x, y = map(int, raw_input().split())

if x % y == 0:
    print(-1)
    exit()

n = 1
top = pow(10, 18)

while True:
    t = n * x
    if t >= top:
        print(-1)
        break

    if t % y != 0:
        print(t)
        break

    n += 1

Buggy python submission (verdict: Time Limit Exceeded):
# vim: set fileencoding=utf-8 :
x, y = map(int, raw_input().split())

if x == y:
    print(-1)
    exit()

n = 1
top = pow(10, 18)

while True:
    if n * x >= top:
        print(-1)
        break

    if n * x % y != 0:
        print(n * x)
        break

    n += 1


Fixed submission:
# vim: set fileencoding=utf-8 :
x, y = map(int, raw_input().split())

if x % y == 0:
    print(-1)
    exit()

n = 1
top = pow(10, 18)

while True:
    t = n * x
    if t >= top:
        print(-1)
        break

    if t % y != 0:
        print(t)
        break

    n += 1
Buggy python submission (verdict: Runtime Error):
a,b=map(int,raw_input()).split()
if a%2==0 or b%2==0:
    print("Even")
else:
    print("Odd")


Fixed submission:
# vim: set fileencoding=utf-8 :
a, b = map(int, raw_input().split())

if a % 2 == 0 or b % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,raw_input()).split()
if a%2==0 or b%2==0:
  print("Even")
else:
  print("Odd")

Fixed submission:
# vim: set fileencoding=utf-8 :
a, b = map(int, raw_input().split())

if a % 2 == 0 or b % 2 == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
# vim: set fileencoding=utf-8 :
from collections import Counter

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
c = Counter(a).values().sort(reverse=True)
print(sum(c[:k]))


Fixed submission:
# vim: set fileencoding=utf-8 :
from collections import Counter

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
c = Counter(a)
v = sorted(c.values())
print(sum(v[:-k]))

Buggy python submission (verdict: Time Limit Exceeded):
# vim: set fileencoding=utf-8 :
n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
freq = {}
b = [0] * n
for ele in a:
    if {ele} <= set(freq):
        freq[ele] += 1
    else:
        freq[ele] = 1

i = 0
ct = 0
freq_cp = freq
for ke, v in sorted(freq.items(), key=lambda x: x[1]):
    if k < len(set(freq_cp)):
        ct += v
        del freq_cp[ke]
    else:
        break

print(ct)


Fixed submission:
# vim: set fileencoding=utf-8 :
from collections import Counter

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
c = Counter(a)
v = sorted(c.values())
print(sum(v[:-k]))
Buggy python submission (verdict: Runtime Error):
# utf-8:

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "E": 15}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


if __name__ == '__main__':
    main()


Fixed submission:
# utf-8:

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# utf-8:

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 12, "E": 12, "E": 12}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


if __name__ == '__main__':
    main()


Fixed submission:
# utf-8:

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# utf-8:
import math as np


def main():
    n = int(raw_input())
    for i in range(n, 0, -1):
        sqrt = np.sqrt(i)
        if sqrt - int(sqrt) == 0:
            print(i)
            break


if __name__ == '__main__':
    main()


Fixed submission:
# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    for i in range(n, 0, -1):
        sqrt = np.sqrt(i)
        if sqrt - int(sqrt) == 0:
            print(i)
            break


if __name__ == '__main__':
    main()


Fixed submission:
# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    if n == 1:
        print(n)
    else:
        for i in range(n, 0, -1):
            sqrt = np.sqrt(n)
            if sqrt - int(sqrt) == 0:
                print(n)
                break


if __name__ == '__main__':
    main()


Fixed submission:
# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    if n == 1:
        print(n)
    else:
        for i in range(n):
            sqrt = np.sqrt(n - i + 1)
            if sqrt - int(sqrt) == 0:
                print(n - i)
                break


if __name__ == '__main__':
    main()


Fixed submission:
# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    for i in range(n):
        sqrt = np.sqrt(n - i +1)
        if sqrt - int(sqrt) == 0:
            print(n - i)
            break


if __name__ == '__main__':
    main()


Fixed submission:
# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    for i in range(n):
        sqrt = np.sqrt(n - i)
        if sqrt - int(sqrt) == 0:
            print(n - i)
            break


if __name__ == '__main__':
    main()


Fixed submission:
# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):

import sys

def main():
    N = input()
    ans = 0
    for _ in range(N):
        l, r =  map(int, sys.stdin.readline().rstrip().split())
        ans += abs(r-l) + 1

    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
# vim: set fileencoding=utf-8 :
n = int(raw_input())
kyaku = 0

for _ in range(n):
    l, r = map(int, raw_input().split())
    kyaku += r - l + 1

print(kyaku)
Buggy python submission (verdict: Runtime Error):
import math
import fractions


def main():
    N = int(input())
    ans = int(input())
    for i in range(N-1):
        T = int(input())
        ans = (ans * T) / fractions.gcd(ans, T)  # 最小公倍数
        ans = int(ans)
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import fractions


def main():
    N = int(input())
    ans = int(input())
    for i in range(N-1):
        T = int(input())
        ans = (ans * T) // fractions.gcd(ans, T)  # 最小公倍数
        ans = int(ans)
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import fractions


def main():
    N = int(input())
    ans = int(input())
    for i in range(N-1):
       T = int(input())
       ans = (ans * T) / fractions.gcd(ans, T)
       ans = int(ans)


    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import fractions


def main():
    N = int(input())
    ans = int(input())
    for i in range(N-1):
        T = int(input())
        ans = (ans * T) // fractions.gcd(ans, T)  # 最小公倍数
        ans = int(ans)
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# vim: set fileencoding=utf-8 :
n = int(raw_input())
a = map(int, raw_input().split())

diff = None
min_diff = 999999999999999999

for i in range(n - 1):
    x = sum(a[0:i + 1])
    y = sum(a[i + 1:])
    diff = abs(x - y)
    if diff < min_diff:
        min_diff = diff

print(min_diff)


Fixed submission:
# vim: set fileencoding=utf-8 :
n = int(raw_input())
a = map(int, raw_input().split())

diff = None
min_diff = 999999999999999999
x = 0
y = sum(a)

for i in range(n - 1):
    x += a[i]
    y -= a[i]
    diff = abs(x - y)
    if diff < min_diff:
        min_diff = diff

print(min_diff)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import collections

stack = collections.deque()
N, M = [int(ele) for ele in input().split()]
edges = []
adj_list = []
for _ in range(N+1):
    adj_list.append([])

d = [-1000000000000000000000000000000000000000000000000000000] * (N+1)

for _ in range(M):
    src, dst, w = [int(ele) for ele in input().split()]
    if src == 1:
        d[dst] = w
    edges.append([src, dst, w])
    adj_list[src].append(dst)

yet = [ele for ele in range(1, N+1)]
queue = collections.deque()


def main():
    global edges
    queue.append(1)
    bfs(queue)
    edges = list(filter(lambda x: x[0] not in yet or x[1] not in yet, edges))

    print(d[-1] if bellman_ford() != -1 else "inf")


def bfs(queue):
    if not queue:  # queueが空ならfalseで終了
        return

    n = queue[-1]
    yet.remove(n)

    for dst in adj_list[n]:
        if dst in yet and dst not in queue:  # 未訪問かつqueueにもない
            queue.appendleft(dst)
    else:
        queue.pop()
        bfs(queue)


def bellman_ford():
    for _ in range(N - 1):
        for src, dst, w in edges:
            if d[dst] < w + d[src]:
                d[dst] = w + d[src]

    for src, dst, w in edges:
        if d[dst] < w + d[src]:
            return -1

    return


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
sys.setrecursionlimit(100000)

N, M = [int(ele) for ele in input().split()]
edges = []

d = [-100000000000000000000000000000000000000000000000] * (N+1)
d_tmp = []

for _ in range(M):
    src, dst, w = [int(ele) for ele in input().split()]
    if src == 1:
        d[dst] = w
    edges.append([src, dst, w])

yet = [ele for ele in range(1, N+1)]


def main():
    print(d[-1] if bellman_ford() != -1 else "inf")


def bellman_ford():
    for _ in range(N - 1):
        for src, dst, w in edges:
            if d[dst] < w + d[src]:
                d[dst] = w + d[src]

    d_tmp = d[-1]

    for src, dst, w in edges:
        if d[dst] < w + d[src]:
            d[dst] = w + d[src]

    if d_tmp != d[-1]:
        return -1

    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# vim: set fileencoding=utf-8 :
k, s = map(int, raw_input().split())
patterns = []

for x in range(k + 1):
    nokori = s - x
    for y in range(k + 1):
        if 0 <= nokori - y <= k:
            patterns.append([x, y, nokori - y])

ct = len(patterns)
print(ct)


Fixed submission:
# vim: set fileencoding=utf-8 :
k, s = map(int, raw_input().split())
patterns = []
ct = 0

for x in range(k + 1):
    nokori = s - x
    for y in range(k + 1):
        if 0 <= nokori - y <= k:
            ct += 1

print(ct)

Buggy python submission (verdict: Time Limit Exceeded):
# vim: set fileencoding=utf-8 :


def main():
    k, s = map(int, raw_input().split())
    patterns = []

    # 重複していいからとにかくpushする
    for x in range(k + 1):
        nokori = s - x
        for y in range(k + 1):
            if 0 <= nokori - y <= k:
                z = nokori - y
                patterns.append([x, y, z])

    ct = len(patterns)
    print(ct)


if __name__ == "__main__":
    main()


Fixed submission:
# vim: set fileencoding=utf-8 :
k, s = map(int, raw_input().split())
patterns = []
ct = 0

for x in range(k + 1):
    nokori = s - x
    for y in range(k + 1):
        if 0 <= nokori - y <= k:
            ct += 1

print(ct)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
 
if a > 13:
  return b
elif a < 6:
  return 0
elif a >= 6 and a <= 12: 
  return int(b/2)

Fixed submission:
a, b = map(int, input().split())
 
if a < 6:
  print(0)
elif a <= 12:
  print(int(b/2))
else: 
  print(b)

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

if a > 13:
  return b
elif a < 6:
  return 0
else: 
  return b//2


Fixed submission:
a, b = map(int, input().split())
 
if a < 6:
  print(0)
elif a <= 12:
  print(int(b/2))
else: 
  print(b)
Buggy python submission (verdict: Runtime Error):
8 3

Fixed submission:
t,x = [int(i) for i in input().split()]
print(t/x)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a<=8 and b<=8:
    print('Yay!')
else:
    print(':(')


Fixed submission:
a,b=input().split()
if int(a)<=8 and int(b)<=8:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(N):
    listed_a = list(map(int, input().split())).pop(0)
    a.append(set(listed_a))


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))


Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(N):
    listed_a = list(map(int, input().split()))
    listed_a.pop(0)
    a.append(set(listed_a))


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))
Buggy python submission (verdict: Runtime Error):
S = input()

listed_S = list[S]
if len(listed_S)==2:
    print(S)
elif len(listed_S)==3:
    print(S[::-1])

Fixed submission:
S = input()

listed_S = list(S)
if len(listed_S)==2:
    print(S)
elif len(listed_S)==3:
    print(S[::-1])
Buggy python submission (verdict: Runtime Error):
N = input("N:")
mapped_N  = map(int, list(N))
sum_s = sum(list(mapped_N))
if N % sum_s == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
N = input()
mapped_N  = map(int, list(N))
sum_s = sum(list(mapped_N))
if int(N) % sum_s == 0:
    print("Yes")
else:
    print("No")