Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
res = 0
if A >= B:
  res += A
  A-= 1
  if A >= B:
    res += A
    else:
      res += B
      print(res)
else:
  res += B
  B-= 1
  if A >= B:
    res += A
    else:
      res += B
      print(res)


Fixed submission:
A,B = map(int,input().split())
res = 0
for _ in range(2):
  if A>=B:
    res += A
    A-=1
  else:
    res += B
    B-=1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
A = []
B = []
for i in range(Q):
  l,r = map(int,input().split())
  A.append((l-1,r))
for i in range(len(S)-1):
  if S[i:i+2] == 'AC':
    B.append((i,i+2))
for el in A:
  res = 0
  a,b = el
  for el in B:
    x,y = el
    if a <= x and y <= b:
      res += 1
  print(res)

Fixed submission:
N,Q = map(int,input().split())
S = input()
t = [0] * (N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
  l,r = map(int,input().split())
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
A = []
B = []
for i in range(Q):
  l,r = map(int,input().split())
  A.append((l-1,r-1))
for el in A:
  res = 0
  m,n = el
  i = 0
  while True:
    if m + i + 2 > n+1:
      break
    if S[m+i:m+i+2] == 'AC':
      res += 1
    i += 1    
  print(res)

Fixed submission:
N,Q = map(int,input().split())
S = input()
t = [0] * (N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
  l,r = map(int,input().split())
  print(t[r-1]-t[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,M = map(int,input().split())
shops = dict()
price = []
takahashi = 0
money = 0
for i in range(N):
    bottle,stock = map(int,input().split())
    if bottle not in shops:
        shops[bottle] = 0
    shops[bottle] += stock
    if bottle not in price:
        price.append(bottle)
price.sort()
for y in price:
    if shops[y] <= (M-takahashi):
        takahashi += shops[y]
        money += shops[y]*y
        shops[y] = 0
        if takahashi == M:
            print(money)
            sys.exit(0)
    else:
        money += y*(M-takahashi)
        takahashi += (M-takahashi)
        shops[y] -= (M-takahashi)
        if takahashi == M:
            print(money)
            sys.exit(0)

Fixed submission:
N,M = map(int,input().split())
shops = []
for i in range(N):
    price,B = map(int,input().split())
    shops.append([price,B])
shops.sort()
i = 0
money = 0
while M > 0:
    if shops[i][1] > M:
        money += M*shops[i][0]
        break
    else:
        money += shops[i][1] * shops[i][0]
        M -= shops[i][1]
    i += 1
print(money)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,M = map(int,input().split())
shops = dict()
price = []
takahashi = 0
money = 0
for i in range(N):
    bottle,stock = map(int,input().split())
    if bottle not in shops:
        shops[bottle] = 0
    shops[bottle] += stock
    if bottle not in price:
        price.append(bottle)
price.sort()
for y in price:
    while takahashi != M:
        if shops[y] <= (M-takahashi):
            takahashi += shops[y]
            money += shops[y]*y
            shops[y] = 0
            break
        elif shops[y] != 0:
            takahashi += 1
            shops[y] -= 1
            money += y
        else:
            break
    if takahashi == M:
        print(money)
        sys.exit(0)

Fixed submission:
N,M = map(int,input().split())
shops = []
for i in range(N):
    price,B = map(int,input().split())
    shops.append([price,B])
shops.sort()
i = 0
money = 0
while M > 0:
    if shops[i][1] > M:
        money += M*shops[i][0]
        break
    else:
        money += shops[i][1] * shops[i][0]
        M -= shops[i][1]
    i += 1
print(money)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,M = map(int,input().split())
shops = dict()
price = []
takahashi = 0
money = 0
for i in range(N):
    bottle,stock = map(int,input().split())
    if bottle not in shops:
        shops[bottle] = 0
    shops[bottle] += stock
    if bottle not in price:
        price.append(bottle)
price.sort()
for y in price:
    while takahashi != M:
        if shops[y] != 0:
            takahashi += 1
            shops[y] -= 1
            money += y
        else:
            break
    if takahashi == M:
        print(money)
        sys.exit(0)

Fixed submission:
N,M = map(int,input().split())
shops = []
for i in range(N):
    price,B = map(int,input().split())
    shops.append([price,B])
shops.sort()
i = 0
money = 0
while M > 0:
    if shops[i][1] > M:
        money += M*shops[i][0]
        break
    else:
        money += shops[i][1] * shops[i][0]
        M -= shops[i][1]
    i += 1
print(money)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
L = [i for i in S]
K = len(S)
i = 0
while True:    
    if i == len(L)-1 or i > K:
        break
    if L[i:i+2] == ['1','0'] or L[i:i+2] == ['0','1']:
        del L[i:i+2]
        i = 0
    else:
        i += 1
print(K-len(L))

Fixed submission:
S = input()
m1 = S.count('0')
m2 = S.count('1')
print(2*min(m1,m2))
Buggy python submission (verdict: Runtime Error):
from functools import reduce
import fractions 
N = int(input())
L = [i for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd(),numbers)
prind(gcd_list(L))

Fixed submission:
from functools import reduce
import fractions 
N = int(input())
L = [i for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd,numbers)
print(gcd_list(L))
Buggy python submission (verdict: Runtime Error):
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N = int(input())
H = [i for i in map(int,input().split())]
dp = [10**5 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    chmin(dp,dp[i-1]+abs(H[i]-H[i-1]),i)
    print(dp)
    if i > 1:
        chmin(dp,dp[i-2]+abs(H[i]-H[i-2]),i)
print(dp[-1])

Fixed submission:
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N = int(input())
H = [i for i in map(int,input().split())]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    chmin(dp,dp[i-1]+abs(H[i]-H[i-1]),i)
    if i > 1:
        chmin(dp,dp[i-2]+abs(H[i]-H[i-2]),i)
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = mips()
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])

Fixed submission:
def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = mips()
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = mips()
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])

Fixed submission:
def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = mips()
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = map(int,input().split())
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    chmin(dp,dp[i-1]+abs(H[i]-H[i-1]),i)
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])

Fixed submission:
def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = mips()
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
def mips():
  return map(int,input().split())
def chmax(DP,b,weight,number):
    if DP[number+1][weight] < b : 
        DP[number+1][weight] = b
        return True
    return False    
N,W = mips()
Poids = []
Valeur = []
for i in range(N):
    weight,value = mips()
    Poids.append(weight)
    Valeur.append(value)
DP = [[0] * (2*W) for i in range(N+1)]
for i in range(N):
    for sum_p in range(0,W+1):
        if sum_p - Poids[i] >= 0:
            chmax(DP,DP[i][sum_p-Poids[i]] + Valeur[i],sum_p,i)
        chmax(DP,DP[i][sum_p],sum_p,i)
print(DP[N][W])

Fixed submission:
def mips():
    return map(int,input().split())
def chmax(DP,b,weight,number):
    if DP[number+1][weight] < b : 
        DP[number+1][weight] = b
        return True
    return False    
N,W = mips()
Poids = []
Valeur = []
for i in range(N):
    weight,value = mips()
    Poids.append(weight)
    Valeur.append(value)
DP = [[0] * (2*W) for i in range(N+1)]
for i in range(N):
    for sum_p in range(0,W+1):
        if sum_p - Poids[i] >= 0:
            chmax(DP,DP[i][sum_p-Poids[i]] + Valeur[i],sum_p,i)
        chmax(DP,DP[i][sum_p],sum_p,i)
print(DP[N][W])
Buggy python submission (verdict: Runtime Error):
S = input()
res = int(S[0:3])
for i in range(len(S)-3):
  if abs(res - 753) > abs(int(S[i:i+3])-753):
    res = S[i:i+3]
print(res)
  

Fixed submission:
S = input()
c = ''
L = []
i = 0
j = 3
min = 10**9
while j<=len(S):
    c = S[i:j]
    L.append(int(c))
    i += 1
    j += 1
for element in L:
    if abs(753-element) < min:
        min = abs(753-element)
print(min)
Buggy python submission (verdict: Runtime Error):
n = input()
s = ''
for c in n:
  if c == '1':
    s += '9'
  else:
  	if c == '9':
    	s += '1'
    else:
      s += c
print(s)
  

Fixed submission:
n = input()
s = ''
for c in n:
  if c == '1':
    s += '9'
  else:
    if c == '9':
        s += '1'
    else:
        s += c
print(s)
Buggy python submission (verdict: Runtime Error):
#merci drken
from fractions import Fraction
from 
N,X = map(int,input().split())
L = [(_-X) for _ in map(int,input().split())]
def gcd_list(numbers):
  return reduce(math.gcd,numbers)
print(gcd_list(L))
  

Fixed submission:
#starting from X is equivalent to go to x1-X,x2-X,... starting from 0.
#donc x1-X est multiple de D, x2-X l'est aussi...donc gcd des xi-X.
import fractions
from functools import reduce
N,X = map(int,input().split())
L = [abs(i-X) for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd,numbers)
print(gcd_list(L))
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [i for i in range(1, N+1) if i % 2 != 0]
ans = 0
if N < 105:
    print(0)
    sys.exit(0)
for num in L:
    counter = 1
    for i in range(1, num//2):
        if num % i == 0:
            counter += 1
    if counter == 8:
        ans += 1
print(ans)

Fixed submission:
import sys
N = int(input())
L = [i for i in range(1, N+1) if i % 2 != 0]
ans = 0
if N < 105:
    print(0)
    sys.exit(0)
for num in L:
    counter = 1
    for i in range(1, num//2):
        if num % i == 0:
            counter += 1
    if counter == 8:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
S = input()
K = int(input())
if len(S) == 1:
  print(S)
  sys.exit(0)
if K == 1:
  print(S[0])
i = 0
while i<len(S):
  if S[i] == '1':
  	i += 1
  else:
    break
keep = S[i]
if K <= i:
  print(1)
  sys.exit(0)
else:
  if S[0] != '1':
    print(S[0])
  else:
	  print(keep)

Fixed submission:
import sys
S = input()
K = int(input())
if len(S) == 1:
  print(S)
  sys.exit(0)
if K == 1:
  print(S[0])
  sys.exit(0) #
i = 0
while i<len(S):
  if S[i] == '1':
  	i += 1
  else:
    break
if i < len(S):
  keep = S[i]
else:
  keep = S[i-1]
if K <= i:
  print('1')
  sys.exit(0)
else:
  if S[0] != '1':
    print(S[0])
  else:
	  print(keep)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
j = 0
if L == []:
  print(0)
  sys.exit(0)
even = numpy.prod(L)
while (even % 2**j == 0):
  j += 1
print(j-1)


Fixed submission:
import sys
import numpy
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
L2 = [0 for i in range(len(L))]
if L == []:
  print(0)
  sys.exit(0)
for i in range(len(L)):
    s = 1
    while L[i] % 2**s == 0:
        s += 1
    L2[i] = s-1
Q = numpy.sum(L2)
print(Q)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
even = 1
j = 0
if L == []:
  print(0)
  sys.exit(0)
for i in range(len(L)):
  even *= L[i]
while (even % 2**j == 0):
  j += 1
print(j-1)


Fixed submission:
import sys
import numpy
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
L2 = [0 for i in range(len(L))]
if L == []:
  print(0)
  sys.exit(0)
for i in range(len(L)):
    s = 1
    while L[i] % 2**s == 0:
        s += 1
    L2[i] = s-1
Q = numpy.sum(L2)
print(Q)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
even = 1
res = 0
if L == []:
  print(0)
  sys.exit(0)
else:
  for i in range(len(L)):
    even *= L[i]
  while even != 0 and even % 2 == 0:
    even //= 2 
    res += 1
print(res)

Fixed submission:
import sys
import numpy
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
L2 = [0 for i in range(len(L))]
if L == []:
  print(0)
  sys.exit(0)
for i in range(len(L)):
    s = 1
    while L[i] % 2**s == 0:
        s += 1
    L2[i] = s-1
Q = numpy.sum(L2)
print(Q)

Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
even = 1
res = 0
for i in range(len(L)):
  even *= L[i]
while even != 0 and even % 2 == 0:
  even /= 2 
  res += 1
print(res)

	


Fixed submission:
import sys
import numpy
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
L2 = [0 for i in range(len(L))]
if L == []:
  print(0)
  sys.exit(0)
for i in range(len(L)):
    s = 1
    while L[i] % 2**s == 0:
        s += 1
    L2[i] = s-1
Q = numpy.sum(L2)
print(Q)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
move_x = [1,-1,0,0]
move_y = [0,0,1,-1]
Field = [[c for c in input()] for _ in range(H)]
seen = [[False for _ in range(W)] for _ in range(H)]
queue = []
black = 0
for i in range(H):
    for j in range(W):
        if Field[i][j] == '#':
            black += 1
dist = [[0 for _ in range(W)] for _ in range(H)]
res = -1 
def bfs(start_x,start_y,Field,seen,queue,dist):
    global res
    seen[start_x][start_y] = True
    for i in range(0,4):
        x = start_x + move_x[i]
        y = start_y + move_y[i]
        if x < 0 or y < 0 or x >= H or y >= W:
            continue #out of range
        if Field[x][y] == '#':
            continue #we don't visit black square.
        if seen[x][y]:
            continue #already visited
        if Field[x][y] in queue:
            continue #already in queue.
        if x == (H-1) and y == (W-1):
            dist[x][y] = dist[start_x][start_y] + 1
            res = H*W - dist[x][y] - black #H*W - counting(seen) - black 
        queue.append((x,y))
        dist[x][y] = dist[start_x][start_y] + 1
    for element in queue:
        x,y = element
        if seen[x][y]:
            continue
        seen[x][y] = True
        queue.remove(element)
        bfs(x,y,Field,seen,queue,dist)    
bfs(0,0,Field,seen,queue,dist)
print(res-1)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
H,W = map(int,input().split())
move_x = [1,-1,0,0]
move_y = [0,0,1,-1]
Field = [[c for c in input()] for _ in range(H)]
seen = [[False for _ in range(W)] for _ in range(H)]
queue = []
black = 0
for i in range(H):
    for j in range(W):
        if Field[i][j] == '#':
            black += 1
dist = [[0 for _ in range(W)] for _ in range(H)]
res = -1 
def bfs(start_x,start_y,Field,seen,queue,dist):
    global res
    seen[start_x][start_y] = True
    for i in range(0,4):
        x = start_x + move_x[i]
        y = start_y + move_y[i]
        if x < 0 or y < 0 or x >= H or y >= W:
            continue #out of range
        if Field[x][y] == '#':
            continue #we don't visit black square.
        if seen[x][y]:
            continue #already visited
        if Field[x][y] in queue:
            continue #already in queue.
        dist[x][y] = dist[start_x][start_y] + 1
        if x == (H-1) and y == (W-1):
            res = H*W - dist[x][y] - black #H*W - counting(seen) - black 
        queue.append((x,y))
    for element in queue:
        x,y = element
        if seen[x][y]:
            continue
        seen[x][y] = True
        queue.remove(element)
        bfs(x,y,Field,seen,queue,dist)    
bfs(0,0,Field,seen,queue,dist)
if res != -1:
	print(res-1)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
def diff4(x,y,z):
    temp1 = x
    temp2 = z
    z = temp2 - (diff//4)
    if z < 0:
        choge #RE CHECK
        sys.exit(0)
    x = temp1 + ((diff//4)*10)
    print('%d %d %d' % (x,y,z))
def diff9(x,y,z):
    temp1 = x
    temp2 = z
    z = temp2 - (diff//9)
    if z < 0:
        choge #RE CHECK
        sys.exit(0)
    x = temp1 + ((diff//9)*10)
    print('%d %d %d' % (x,y,z))
def diff1(x,y,z):
    temp1 = z
    temp2 = y
    z = temp1 - 1
    y = temp2 + 2

#C - Otoshidama
import sys
N,Y = map(int,input().split())
#10000yen,5000yen,1000yen
#N mai Y yen
if 10000 * N < Y:
    print('-1 -1 -1')
    sys.exit(0)
z = Y//10000
y = (Y-z*10000) // 5000
x = (Y-z*10000-y*5000) // 1000
#x = 4,y = 0,z = 123
diff = abs(N-(x+y+z))
if diff % 9 == 0:
    diff9(x,y,z)
    sys.exit(0)
elif diff % 4 == 0:
    diff4(x,y,z)
    sys.exit(0)
else:
    while diff % 4 == 0:
        diff1(x,y,z)
        diff = abs(N-(x+y+z))
    diff4(x,y,z)
    sys.exit(0)

Fixed submission:
import sys
N,Y = map(int,input().split())
for x in range(0,N+1):
    for y in range(0,N+1-x):
        if 10000*x+5000*y + (N-x-y)* 1000 == Y:
            print('%d %d %d' % (x,y,N-x-y))
            sys.exit(0)
print('-1 -1 -1')
Buggy python submission (verdict: Runtime Error):
import sympy
def mips():
    return map(int,input().split())
def ii():
    return int(input())
Q = ii()
S = [0 for i in range(10 ** 5 + 1)]
N = 0
for i in [j for j in range(1,10 ** 5 + 1)]:
    if sympy.isprime(i) and sympy.isprime((i+1)//2):
        N += 1
        S[i] = N
    else:
        S[i] = N
for i in range(Q):
    l,r = mips()
    print(S[r]-S[l-1])

Fixed submission:
def mips():
    return map(int,input().split())
def ii():
    return int(input())
def is_prime(n):
    if n == 1:
        return False
    i = 2
    while i*i <= n: #sqrt(n)までで十分。
        if n % i == 0:
            return False
        i += 1
    return True
Q = ii()
S = [0 for i in range(10 ** 5 + 1)]
N = 0
for i in [j for j in range(1,10 ** 5 + 1)]:
    if is_prime(i) and is_prime((i+1)//2):
        N += 1
        S[i] = N
    else:
        S[i] = N
for i in range(Q):
    l,r = mips()
    print(S[r]-S[l-1])
Buggy python submission (verdict: Runtime Error):
s = [c for c in "AKIHABARA"]
L = []
for i in range(0, 2):
    for j in range(0, 2):
        for k in range(0, 2):
            for l in range(0, 2):
                if i == 0:
                    s[0] = "X"
                if j == 0:
                    s[4] = "X"
                if k == 0:
                    s[6] = "X"
                if l == 0:
                    s[8] = "X"
                while "X" in s:
                    s.remove("X")
                L.append(s)
                s = [c for c in "AKIHABARA"] #bitで書きたかった・・・。
S = [c for c in input()]
for el in L:
    if S == el:
        print("YES")
        sys.exit(0)
print("NO")

Fixed submission:
import sys
s = [c for c in "AKIHABARA"]
L = []
for i in range(0, 2):
    for j in range(0, 2):
        for k in range(0, 2):
            for l in range(0, 2):
                if i == 0:
                    s[0] = "X"
                if j == 0:
                    s[4] = "X"
                if k == 0:
                    s[6] = "X"
                if l == 0:
                    s[8] = "X"
                while "X" in s:
                    s.remove("X")
                L.append(s)
                s = [c for c in "AKIHABARA"] #bitで書きたかった・・・。
S = [c for c in input()]
for el in L:
    if S == el:
        print("YES")
        sys.exit(0)
print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
K,S = map(int,input().split())
#0<=S<=3K
res = 0
for X in range(0,K+1):
    if X > S:
        break
        print(res)
        sys.exit(0)
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif (0<=(S-X-Y)) and ((S-X-Y) <= K):
            res += 1
print(res)


Fixed submission:
K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)]))

Buggy python submission (verdict: Time Limit Exceeded):
#B - Sum of Three Integers
K,S = map(int,input().split())
#0<=S<=3K
res = 0
for X in range(0,min((K+1,S+1))):
    if X > S:
        break
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif (0<=S-X-Y) and ((S-X-Y) <= K):
            res += 1
print(res)

Fixed submission:
K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)]))

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
#0<=S<=3K
res = 0
for X in range(0,K+1):
    if X > S:
        break
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif (0<=(S-X-Y)) and ((S-X-Y) <= K):
            res += 1
print(res)

Fixed submission:
K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)]))

Buggy python submission (verdict: Runtime Error):
K,S = map(int,input().split())
res = 0
for X in range(0,K+1):
    if X > S:
        break
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif 0<=(S-X-Y) and (S-X-Y)) <= K:
            res += 1
print(res)

Fixed submission:
K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)]))

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
res = 0
for X in range(0,K+1):
    if X > S:
        break
    for Y in range(0,K+1):
        if X + Y > S:
            break
        for Z in range(0,K+1):
            if X + Y + Z == S:
                res += 1
            elif X + Y + Z >S:
                break
print(res)

Fixed submission:
K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)]))

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
res = 0
for X in range(0,K+1):
    for Y in range(0,K+1):
        for Z in range(0,K+1):
            if X + Y + Z == S:
                res += 1
print(res)

Fixed submission:
K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)]))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())Liste= list(map(str,input().split()))
P = Liste.count('5')
Q = Liste.count('7')
if P == 2 and Q == 1:
    print('YES')
else:
    print('NO')

Fixed submission:
Liste= list(map(str,input().split()))
P = Liste.count('5')
Q = Liste.count('7')
if P == 2 and Q == 1:
    print('YES')
else:
    print('NO')