Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque

gx, gy = w-1, h-1

q = deque()
q.appendleft([0,0])
INF = 10**5

dist = [[INF]*w for _ in range(h)]
dist[0][0] = 0

while q:
  x,y = q.pop()
  
  for dx,dy in [[1,0],[0,1],[-1,0],[0,-1]]:
    nx = x+dx
    ny = y+dy
    
    if 0<=nx<w and 0<=ny<h:
      if dist[ny][nx]==INF and maze[ny][nx] != '#':
        dist[ny][nx] = dist[y][x]+1
        q.appendleft([nx,ny])      

black_num = sum([maze[i].count('#') for i in range(h)])
print( h*w - dist[gy][gx] - black_num -1 )

Fixed submission:
from collections import deque

h,w = map(int,input().split())
maze = [input() for _ in range(h)]

gx, gy = w-1, h-1

q = deque()
q.appendleft([0,0])
INF = 10**5

dist = [[INF]*w for _ in range(h)]
dist[0][0] = 0

while q:
  x,y = q.pop()
  
  for dx,dy in [[1,0],[0,1],[-1,0],[0,-1]]:
    nx = x+dx
    ny = y+dy
    
    if 0<=nx<w and 0<=ny<h:
      if dist[ny][nx]==INF and maze[ny][nx] != '#':
        dist[ny][nx] = dist[y][x]+1
        q.appendleft([nx,ny])      

black_num = sum([maze[i].count('#') for i in range(h)])

if dist[gy][gx] == INF:
  print(-1)
else:  
  print( h*w - dist[gy][gx] - black_num -1 )
Buggy python submission (verdict: Runtime Error):
x,a,b = map(int,input().split())
print((x-a)%b)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print((x-a)%b)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
if (a*b)%2==0:
  print('Even')
else:
  print('Odd')
  

Fixed submission:
a,b = map(int,input().split())
if (a*b)%2==0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
  print('Borys')
else:
  pritn('Alice')

Fixed submission:
n,a,b = map(int,input().split())
if abs(b-a) % 2 == 0:
  print('Alice')
else:
  print('Borys')
Buggy python submission (verdict: Time Limit Exceeded):
def gen_primes(n: int) -> set:
    if n < 2:
        return set()
    is_prime = [True] * n
    for i in range(3, n, 2):
        if is_prime[i]:
            is_prime[i * i:: 2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
    return {2} | {i for i in range(3, n, 2) if is_prime[i]}

import sys
input = lambda: sys.stdin.readline().rstrip()  
  
q = int(input())
primes = gen_primes(10**5)

for i in range(q):
  l,r = map(int,input().split())
  ans = 0
  for p in primes:
    if (l <= p <= r) and (p+1)//2 in primes:
      ans += 1
  print(ans)

Fixed submission:
from math import ceil,sqrt
from bisect import bisect_right, bisect_left

def trial_division(n):  
  if n == 2:
    return True
  if n < 2 or n % 2 == 0:
    return False
  for i in range(3, int(ceil(sqrt(n))) + 1, 2):
    if n % i == 0:
      return False
  return True

import sys
input = lambda: sys.stdin.readline().rstrip()
q = int(input())

primes = [i for i in range(10**5+10) if trial_division(i)]  
p2017 = []
for i in range(len(primes)-1):
  if trial_division((primes[i]+1)//2):
    p2017.append(primes[i])
    
for i in range(q):
  l,r = map(int,input().split())  
  print(bisect_right(p2017,r) - bisect_left(p2017,l))

Buggy python submission (verdict: Time Limit Exceeded):
def gen_primes(n: int) -> set:
    if n < 2:
        return set()
    is_prime = [True] * n
    for i in range(3, n, 2):
        if is_prime[i]:
            is_prime[i * i:: 2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
    return {2} | {i for i in range(3, n, 2) if is_prime[i]}

q = int(input())
primes = gen_primes(10**5)

for i in range(q):
  l,r = map(int,input().split())
  ans = 0
  for p in primes:
    if (l <= p <= r) and (p+1)//2 in primes:
      ans += 1
  print(ans)

Fixed submission:
from math import ceil,sqrt
from bisect import bisect_right, bisect_left

def trial_division(n):  
  if n == 2:
    return True
  if n < 2 or n % 2 == 0:
    return False
  for i in range(3, int(ceil(sqrt(n))) + 1, 2):
    if n % i == 0:
      return False
  return True

import sys
input = lambda: sys.stdin.readline().rstrip()
q = int(input())

primes = [i for i in range(10**5+10) if trial_division(i)]  
p2017 = []
for i in range(len(primes)-1):
  if trial_division((primes[i]+1)//2):
    p2017.append(primes[i])
    
for i in range(q):
  l,r = map(int,input().split())  
  print(bisect_right(p2017,r) - bisect_left(p2017,l))
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
ff = [list(input()) for _ in range(h)]

d = [[-1,-1],[0,-1],[1,-1],
     [-1, 0],       [1, 0],
     [-1, 1],[0, 1],[1, 1]]

for hi in range(h):
  for wi in range(w):
    if f[hi][wi]=='#':
      pass
    else:
      count = 0
      for dx,dy in d:
        x = dx+wi
        y = dy+hi        
        if (0<= x < w) and (0<= y <h) :
          if ff[y][x] == '#':
            count += 1
      ff[hi][wi] = str(count)
      
for fi in ff:
  print(''.join(fi))      

Fixed submission:
h,w = map(int,input().split())
ff = [list(input()) for _ in range(h)]

d = [[-1,-1],[0,-1],[1,-1],
     [-1, 0],       [1, 0],
     [-1, 1],[0, 1],[1, 1]]

for hi in range(h):
  for wi in range(w):
    if ff[hi][wi]=='#':
      pass
    else:
      count = 0
      for dx,dy in d:
        x = dx+wi
        y = dy+hi        
        if (0<= x < w) and (0<= y <h) :
          if ff[y][x] == '#':
            count += 1
      ff[hi][wi] = str(count)
      
for fi in ff:
  print(''.join(fi))
Buggy python submission (verdict: Runtime Error):
n = int(input())
INF = 10**12

A = []
for i in range(n):
  A.append(list(map(int,input().split())))

B = [[1]*n for _ in range(n)]
G = A.copy()

for k in range(n):
  for i in range(n):
    for j in range(n):
      G[i][j] = min(G[i][j], G[i][k]+G[k][j])
      if not (i==j or j==k or k==i):
        if G[i][j] == G[i][k]+G[k][j]:
          B[i][j] = 0
      
if A==G:
  ans = 0
  for i in range(n):
    for j in range(i+1,n):      
      ans += G[i][j] * B[i][j]
  print(ans)
else:
  print(-1)

Fixed submission:
from copy import deepcopy
n = int(input())
INF = 10**12

A = []
for i in range(n):
  A.append(list(map(int,input().split())))

B = [[1]*n for _ in range(n)]
G = deepcopy(A)

for k in range(n):
  for i in range(n):
    for j in range(n):
      G[i][j] = min(G[i][j], G[i][k]+G[k][j])
      if not (i==j or j==k or k==i):
        if G[i][j] == G[i][k]+G[k][j]:
          B[i][j] = 0
      
if A==G:
  ans = 0
  for i in range(n):
    for j in range(i+1,n):      
      ans += G[i][j] * B[i][j]
  print(ans)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
s = input()
find = False
for c in string.ascii_lowercase:
  if c not in s:
    print(c)
    find = True
    break
if not find:
  print('None')
  
    

Fixed submission:
import string
s = input()
find = False
for c in string.ascii_lowercase:
  if c not in s:
    print(c)
    find = True
    break
if not find:
  print('None')
Buggy python submission (verdict: Runtime Error):
import sys 
sys.setrecursionlimit(10**5)

def search_unseen(fr,to,cost):  
  cost_from_k[to] += cost_from_k[fr] + cost
  for n_to,n_cost in es[to]:
    if cost_from_k[n_to] == 0 and k!=n_to:
      search_unseen(to, n_to, n_cost)

n = int(input())
es = {i:[] for i in range(n)}
for i in range(n-1):
  a,b,c = map(int,input().split())
  es[a-1].append((b-1,c))
  es[b-1].append((a-1,c))      
      
q,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(q)]
k -=1

cost_from_k = [0]*n      
search_unseen(k, k, 0)

for x,y in xy:
  print(cost_from_k[x-1] + cost_from_k[y-1])      

Fixed submission:
import sys 
sys.setrecursionlimit(10**8)

def search_unseen(fr,to,cost):  
  cost_from_k[to] += cost_from_k[fr] + cost
  for n_to,n_cost in es[to]:
    if cost_from_k[n_to] == 0 and k!=n_to:
      search_unseen(to, n_to, n_cost)

n = int(input())
es = {i:[] for i in range(n)}
for i in range(n-1):
  a,b,c = map(int,input().split())
  es[a-1].append((b-1,c))
  es[b-1].append((a-1,c))      
      
q,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(q)]
k -=1

cost_from_k = [0]*n      
search_unseen(k, k, 0)

for x,y in xy:
  print(cost_from_k[x-1] + cost_from_k[y-1])

Buggy python submission (verdict: Runtime Error):
INF = float('inf')

def search_unseen(fr,to,cost):  
  cost_from_k[to] += cost_from_k[fr]+cost
  for n_to,n_cost in es[to]:
    if cost_from_k[n_to] == 0 and k!=n_to:
      search_unseen(to,n_to,n_cost)

n = int(input())
es = {i:[] for i in range(n)}
for i in range(n-1):
  a,b,c = map(int,input().split())
  es[a-1].append((b-1,c))
  es[b-1].append((a-1,c))      
      
q,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(q)]
k -=1

cost_from_k = [0]*n      
search_unseen(k,k,0)

for x,y in xy:
  print(cost_from_k[x-1] + cost_from_k[y-1])      

Fixed submission:
import sys 
sys.setrecursionlimit(10**8)

def search_unseen(fr,to,cost):  
  cost_from_k[to] += cost_from_k[fr] + cost
  for n_to,n_cost in es[to]:
    if cost_from_k[n_to] == 0 and k!=n_to:
      search_unseen(to, n_to, n_cost)

n = int(input())
es = {i:[] for i in range(n)}
for i in range(n-1):
  a,b,c = map(int,input().split())
  es[a-1].append((b-1,c))
  es[b-1].append((a-1,c))      
      
q,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(q)]
k -=1

cost_from_k = [0]*n      
search_unseen(k, k, 0)

for x,y in xy:
  print(cost_from_k[x-1] + cost_from_k[y-1])
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
n = int(input())
aa = list(map(int,input().split()))

ans = [[0]*w for _ in range(h)]
nums = ''

for i in range(n):
  nums += str(i+1)*aa[i]    
  
for i in range(len(nums)):  
  ans[i//w][i%w] = nums[i]  
  
for hi in range(h):
  if hi % 2 == 1:    
    print(' '.join(list(reversed(ans[hi]))))
  else:
    print(' '.join(ans[hi]))  

Fixed submission:
h,w = map(int,input().split())
n = int(input())
aa = list(map(int,input().split()))

ans = [[0]*w for _ in range(h)]
nums = []

for i in range(n):
  for j in range(aa[i]):
    nums.append(i+1)
  
for i in range(len(nums)):  
  ans[i//w][i%w] = nums[i]  
  
for hi in range(h):
  if hi % 2 == 1:    
    print(' '.join(map(str,list(reversed(ans[hi])))))
  else:
    print(' '.join(map(str,ans[hi])))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split()) 
if b-a == c-b:
	print('YES')
else:
	print('NO')

Fixed submission:
n = int(input())
i = 1

while True:
  if n<2**i:
    break
  else:
    i+=1
print(2**(i-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
dic = {}
for i in range(m):
  a,b = map(int,input().split())
  if a not in dic:
    dic[a]=[b]    
  else:    
    if b not in dic[a]:
      dic[a].append(b)      
      
  if b not in dic:
    dic[b]=[a]
    if a not in dic[b]:
      dic[b].append(a)
      
ans = 'IMPOSSIBLE'
for i in dic[1]:   
  if n in dic[i]:
    ans = 'POSSIBLE'
    break
    
print(ans)

Fixed submission:
n,m = map(int,input().split())
dic = {i+1:set() for i in range(n)}
for i in range(m):
  a,b = map(int,input().split())
  dic[a].add(b)
  dic[b].add(a)
        
ans = 'IMPOSSIBLE'
for i in dic[1]:   
  if n in dic[i]:
    ans = 'POSSIBLE'
    break
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
dic = {}
for i in range(m):
  a,b = map(int,input().split())
  if a not in dic:
    dic[a]=[b]    
  else:    
    if b not in dic[a]:
      dic[a].append(b)      
      
  if b not in dic:
    dic[b]=[a]
    if a not in dic[b]:
      dic[b].append(a)
      
islands = set()
for i in dic[1]:
  islands.add(i)
  for j in dic[i]:
    islands.add(j)
    
if n in islands:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')          

Fixed submission:
n,m = map(int,input().split())
dic = {i+1:set() for i in range(n)}
for i in range(m):
  a,b = map(int,input().split())
  dic[a].add(b)
  dic[b].add(a)
        
ans = 'IMPOSSIBLE'
for i in dic[1]:   
  if n in dic[i]:
    ans = 'POSSIBLE'
    break
    
print(ans)
Buggy python submission (verdict: Runtime Error):
visited = [0]*n
ans = 0
i = 0
while True:
  i = A[i]
  ans += 1  
  if visited[i]==1:
    ans = -1
    break    
  visited[i] = 1
  if i == 1:
    break
  
print(ans)    

Fixed submission:
n = int(input())
A = [int(input())-1 for _ in range(n)]

visited = [0]*n
ans = 0
i = 0
while True:
  i = A[i]
  ans += 1  
  if visited[i]==1:
    ans = -1
    break    
  visited[i] = 1
  if i == 1:
    break
  
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
if len(s)==len(set(s)):
  print('yes')
else:
  print('no)

Fixed submission:
s = input()
if len(s)==len(set(s)):
  print('yes')
else:
  print('no')

Buggy python submission (verdict: Runtime Error):
s = input()
if len(s)==set(s):
  print('yes')
else:
  print('no)

Fixed submission:
s = input()
if len(s)==len(set(s)):
  print('yes')
else:
  print('no')
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split()) 
if b−a == c−b:
  print('YES')
else:
  print('NO')


Fixed submission:
a,b,c = map(int,input().split()) 
if b-a == c-b:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
o = input()
e = input()

n = len(e)
ans = ''
for i in range(n):
	ans += o[i]
  	ans += e[i]
    
if len(o)%2==1:
	ans += o[-1]
    
print(ans)

Fixed submission:
o = input()
e = input()

n = len(e)
ans = ''
for i in range(n):
  ans += o[i]
  ans += e[i]
    
if len(o)>n:
  ans += o[-1]

print(ans)

Buggy python submission (verdict: Runtime Error):
o = input()
e = input()
n = len(e)
ans = ''
for i in range(n)
	ans += o[i]
  	ans += e[i]
    
if len(o)%2==1:
  ans += o[-1]

print(ans)  
  
  

Fixed submission:
o = input()
e = input()

n = len(e)
ans = ''
for i in range(n):
  ans += o[i]
  ans += e[i]
    
if len(o)>n:
  ans += o[-1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(s-x+1):
    z = s - x - y
    if (x <= k and y <= k and z <= k) and (0 <= x and 0 <=y and 0 <= z):      
      count+=1
print(count)      

Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y    
    if (y <= k and z <= k) and (0 <= z):  
      count+=1
      
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
sr = s[::-1]
words = [w[::-1] for w in ('dream','dreamer','erase','eraser')]

f = 0
while f == 0:  
  f = 1
  for w in words_r:
    if sr[0:len(w)] == w:
      sr = sr[len(w):]
      f = 0
  
if sr =='':
  print('YES')
else:
  print('NO')
  

Fixed submission:

s = input()
words = ['dream','dreamer','erase','eraser']
words_r = [w[::-1] for w in words]
s = s[::-1]

ans = 'NO'
i = 0
while i < len(s):  
  p = i
  for w in words_r:        
    if s[i:i+len(w)] == w:      
      i += len(w)
      if i == len(s):
        ans ='YES'
      break
  if p==i or ans=='YES':
    break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

s = input()
words = ['dream','dreamer','erase','eraser']
words_r = [w[::-1] for w in words]
s = s[::-1]

ans = 'NO'
i = 0
while i < len(s):
  p = -1
  for w in words_r:    
    p = s.find(w,i)    
    if p == i:
      i = p + len(w)
      if i == len(s):
        ans ='YES'
      break
  if (p == -1) or ans=='YES':
    break

print(ans)    

Fixed submission:

s = input()
words = ['dream','dreamer','erase','eraser']
words_r = [w[::-1] for w in words]
s = s[::-1]

ans = 'NO'
i = 0
while i < len(s):  
  p = i
  for w in words_r:        
    if s[i:i+len(w)] == w:      
      i += len(w)
      if i == len(s):
        ans ='YES'
      break
  if p==i or ans=='YES':
    break

print(ans)
Buggy python submission (verdict: Runtime Error):
k,t = map(int,input().split())
A = list(map(int,input().split()))
print(max(2*max(A) - sum(A) -1))

Fixed submission:
k,t = map(int,input().split())
A = list(map(int,input().split()))
print(max(0,2*max(A) - sum(A) -1))
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
aa = np.array(list(map(int,input().split())))

ans = float('inf')
for i in range(min(aa),max(aa)+1):
  ans = min(ans,sum((aa-i)**2))
  
print(ans)  

Fixed submission:
import numpy as np
n = int(input())
aa = np.array(list(map(int,input().split())))

ans = float('inf')
for i in range(min(aa),max(aa)+1):
  ans = min(ans,sum((aa-i)**2))
  
print(ans)
Buggy python submission (verdict: Runtime Error):
line = input()

if line[len(line)] == ("s"):
  line += "es"
else:
  line += "s"
print(line)

Fixed submission:
line = input()
if line[len(line)-1] == "s":
	print(line + "es")
else:
  print(line + "s")
Buggy python submission (verdict: Runtime Error):
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(int(line[0]))

for i in range(n-3):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("Yes")
else:
  print("No")


Fixed submission:
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(len(z)-2):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(n-3):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("Yes")
else:
  print("No")


Fixed submission:
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(len(z)-2):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(n-3):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("yes")
else:
  print("no")


Fixed submission:
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(len(z)-2):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
z = []
y = o
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(n-3):
  if z[i]==z[i+1]:
    if z[i+1]==z[i+2]:
      y += 1
if y > 0:
  print("yes")
else:
  print("no")


Fixed submission:
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(len(z)-2):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
x=input().rstrip.split(" ")
z=[]
for i in range(2):
	z.append(x[i-2]*x[0])
    z.append(x[i-2]*x[1])
print(max(z))

Fixed submission:
x=input()

if int(x)==1:
  print(0)
else:
  print(1)
Buggy python submission (verdict: Runtime Error):
x=input().rstrip.split(" ")
z=[]
for i in range(2):
	z.append(x[i-2]*x[0])
    z.append(x[i-2]*x[1])
print(max(z))


Fixed submission:
x=input().split(" ")
z=[]
for i in range(2):
	z.append(int(x[i-2])*int(x[0]))
for i in range(2):
    z.append(int(x[i-2])*int(x[1]))
print(max(z))

Buggy python submission (verdict: Runtime Error):
x=input().rstrip.split(" ")
z=[]
for i in range(2):
	for y in range(2):
      z.append(x[i-2]*x[y-2])
print(max(z))

Fixed submission:
x=input().split(" ")
z=[]
for i in range(2):
	z.append(int(x[i-2])*int(x[0]))
for i in range(2):
    z.append(int(x[i-2])*int(x[1]))
print(max(z))
Buggy python submission (verdict: Runtime Error):
n=int(input())
mod = 10**9+7

dp = [0]*(s+1)
dp[0] = 1

print(dp[])

Fixed submission:
s=int(input())
mod = 10**9+7

dp = [0]*(s+1)
dp[0] = 1
x = 0

for i in range(1,s+1):
  if i-3>=0:
    x += dp[i-3]
    x %= mod
  dp[i]=x
print(dp[s])
Buggy python submission (verdict: Runtime Error):
#!/bin/python3

import os
import sys


if __name__ == '__main__':
    a = input().split()
    b = input().split()
    c = input().split()

	result = c - (a - b)
    if result > 0:
      result = 0
    print(result)

Fixed submission:
#!/bin/python3
 
import os
import sys


a = input().split()
result = int(a[2])+int(a[1])-int(a[0])
if result < 0:
  result = 0
print(result)
Buggy python submission (verdict: Runtime Error):
tmp=input().split()
n=int(tmp[0])
d=int(tmp[1])
xn = [0]*n
num = 0

for i in range(n):
  xn[i] = input().split()
    
for i in range(n):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist = dist + pow(int(xn[i][k])-int(xn[j][k]), 2)
#    print("test",dist)
#    print(int(pow(int(pow(dist,0.5)), 2)))
    if dist == int(pow(int(pow(dist,0.5)), 2)):
      num += 1
print(num)
                
    

Fixed submission:
tmp=input().split()
n=int(tmp[0])
a=int(tmp[1])
b=int(tmp[2])

if a*n < b:
  print(a*n)
else:
  print(b)
Buggy python submission (verdict: Runtime Error):
tmp=input().split()
n=int(tmp[0])
d=int(tmp[1])
xn = [0]*d
num = 0

for i in range(n):
  xn[i] = input().split()
    
for i in range(n):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist = dist + pow(int(xn[i][k])-int(xn[j][k]), 2)
#    print("test",dist)
#    print(int(pow(int(pow(dist,0.5)), 2)))
    if dist == int(pow(int(pow(dist,0.5)), 2)):
      num += 1
print(num)
                
    

Fixed submission:
tmp=input().split()
n=int(tmp[0])
d=int(tmp[1])
xn = [0]*n
num = 0

for i in range(n):
  xn[i] = input().split()
    
for i in range(n):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist = dist + pow(int(xn[i][k])-int(xn[j][k]), 2)
#    print("test",dist)
#    print(int(pow(int(pow(dist,0.5)), 2)))
    if dist == int(pow(int(pow(dist,0.5)), 2)):
      num += 1
print(num)