Harryxun/stf_run huggingface dataset:
def main():
    def prime_table(n):
        list = [True for _ in range(n + 1)]
        list[0] = False

        for i in range(2, int(n ** 0.5) + 1):
            if list[i]:
                for j in range(i * 2, n, i):
                    list[j] = False
        return list[1:]

    def is_prime(n):
        for i in range(2, int(n ** 0.5) + 1):
            if n % i == 0:
                return False
        return True

    a, b = map(int, input().split())
    m = max(a, b)
    mx = int(m ** 0.5)

    tbl = prime_table(mx)

    ans = set()

    for p, bl in enumerate(tbl, 1):
        if a % p == 0 and b % p == 0:
            if bl:
                ans.add(p)

        qa = a // p
        if b % qa == 0 and is_prime(qa):
            ans.add(qa)

        qb = b // p
        if a % qb == 0 and is_prime(qb):
            ans.add(qb)

    print(len(ans))
    # print(*ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)


def factorize(n):
    res = set()

    diviser = 2
    exponent = 0
    while n % diviser == 0:
        exponent += 1
        n //= diviser
    if exponent > 0:
        res.add((diviser, exponent))
    # 2の冪数を先に調べることで、
    # diviserを奇数に限定できる

    to = int(pow(n, 0.5))
    for diviser in range(3, to + 1, 2):
        exponent = 0
        while n % diviser == 0:
            exponent += 1
            n //= diviser
        if exponent > 0:
            res.add((diviser, exponent))

    if n > 1:
        res.add((n, 1))
        # n:素数の場合

    return res


def main():
    a, b = map(int, input().split())
    g = gcd(a, b)
    e = factorize(g)

    ans = len(e) + 1
    # factorizeで、素数の種類数が分かる
    # 1で割る分を +1 で加算する
    print(ans)


if __name__ == '__main__':
    main()
n=int(input())
h=list(map(int,input().split()))
ans=[]
for i in range(n-1):
    ans_i=0
    for j in range(i+1,n):
        while h[j] <= h[i]:
            ans_i+=1
        ans.append(ans_i)
print(max(ans))

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
H=[]
for i in range(n-1):
    if h[i+1] <= h[i]:
        H.append('a')
    else:
        H.append('b')
s=''.join(H)
t=s.split('b')
ans=max(len(u) for u in t)
print(ans)
n, m = map(int, input().split())
print(max(n - sum(list(map(int, input().split())))), -1)


### FIXED CODE ###

n, m = map(int, input().split())
A = list(map(int,input().split()))

if n >= sum(A):
    print(n - sum(A))
else:
    print('-1')
h, w = map(int, input().split())
M = [input() for _ in range(h)]

ng = False
for i in range(h):
    for j in range(w):
        if M[i][j]  == '.':
            continue

        for mi, mj in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            ni = i + mi; nj = j + mj
            if ni < 0 or h <= ni or nj < 0 or w <= nj:
                continue

            if M[ni][nj] == '#':
                break
        else:
            ng=True
    if ng:
        break
if ng:
    break

if ng:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

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

ng = False
for i in range(h):
    for j in range(w):
        if M[i][j]  == '.':
            continue

        for mi, mj in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            ni = i + mi; nj = j + mj
            if ni < 0 or h <= ni or nj < 0 or w <= nj:
                continue

            if M[ni][nj] == '#':
                break
        else:
            ng=True
    if ng:
        break

if ng:
    print('No')
else:
    print('Yes')
#!/usr/bin/env python3
import sys
import math

def solve(N: int, A: "List[int]"):
    res = A[0]
    B = A[1:]
    for a in B:
        res = math.gcd(res,a)

    print(res)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import math

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

def solve(N: int, A: "List[int]"):
    res = A[0]
    B = A[1:]
    for a in B:
        res = gcd(res,a)

    print(res)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
#coding: UTF-8

l = input().split()

a = int(l[0])
b = int(l[1])



if 1 <= a and b <= 10*9:
	d = a / b
	r = a % b
	f = float (a )/ b

	print "%d %d %f" %(d, r, f)

### FIXED CODE ###

#coding: UTF-8

l = raw_input().split()

a = int(l[0])
b = int(l[1])



if 1 <= a and b <= 10**9:
	d = a / b
	r = a % b
	f = float (a )/ b

	print "%d %d %f" %(d, r, f)
nm = input().split(" ")
n = int(nm[0])
m = int(nm[1])

a = input().split(" ")

total = 0
for v in a:
  total += int(a)
  
mv = total / (4 * m)
q = 0
for e in a:
  e = int(e)
  if e >= mv:
    q += 1
    
if q >= m:
  print("Yes")
else:
  print("No")
 

### FIXED CODE ###

nm = input().split(" ")
n = int(nm[0])
m = int(nm[1])
 
a = input().split(" ")
 
total = 0
for v in a:
  total += int(v)
  
mv = total / (4 * m)
q = 0
for e in a:
  e = int(e)
  if e >= mv:
    q += 1
    
if q >= m:
  print("Yes")
else:
  print("No")
import numpy as np
NM = input()
N, M = NM.split(" ")
del NM
N, M = int(N), int(M)
broken_steps = [int(input()) for num in range(M)]
#all_steps = [num for num in range(N+1)]
all_steps = np.ones(N+1, dtype=np.int64)  ##np.int32だと足りない
all_steps[broken_steps] = 0
ok_steps = list(all_steps)
#ok_steps = [0 if num in broken_steps else 1 for num in range(len(all_steps))]
#for num in range(len(all_steps)):
#  if num in broken_steps:
#    ok_steps.append(0)
#  else:
#  	ok_steps.append(1)
#del all_steps, broken_steps
#print(ok_steps)
for num in range(0, len(ok_steps)):
  i = - (num + 1)
  
  if (i==-1 or i==-2):
    pass
  else:
    if ok_steps[i]==0:
      pass
    else:
      ok_steps[i] = ok_steps[i+1] + ok_steps[i+2]
      

#for num in range(0, len(ok_steps)):
#  i = - (num + 1)
#  
#  if (i==-1 or i==-2):
#    pass
#  else:
#    if ok_steps[i]==0:
#      pass
#    else:
#      print(i)
#      ok_steps[i] = ok_steps[i+1] + ok_steps[i+2]
#print(ok_steps[-3])        
print(ok_steps[0]%1000000007)

### FIXED CODE ###

tmp0 = input()
P, Q, R = tmp0.split(" ")
del tmp0
P, Q, R = int(P), int(Q), int(R)
print(min(P+Q, Q+R, R+P))
"\n".join(reverse(sort([input() for i in range(10)]))[:3])

### FIXED CODE ###

print "\n".join([str(x) for x in (sorted([input() for i in range(10)])[:-4:-1])])
A,B,K = map(int,input().split())

a = A
b = B
if a == b == 1:
    print('1')
    exit()
def cal_divisor(num):
    prime = [2,3,5,7,11,13]
    ans_list = []
    for i in range(len(prime)):
        ans_list.append([prime[i],0])
    for i in range(len(prime)):
        while True:
            if num % prime[i] == 0:
                num //= prime[i]
                ans_list[i][1] += 1
            if num % prime[i] != 0:
                break
    return ans_list

q = cal_divisor(a)
w = cal_divisor(b)

ans = []
for i in range(len(q)):
    ans.append([q[i][0],min(q[i][1],w[i][1])])


ans1 = []
for i in range(len(ans)):
    if ans[i][1] != 0:
        times = ans[i][1]
        for j in range(times+1):
            ans1.append(ans[i][0] ** j)
ans1.sort() 
print(ans1[K-1])

### FIXED CODE ###

a,b,k = map(int,input().split())

n = min(a,b)

count = 0
for i in reversed(range(1,n+1)):
    if a % i == 0 and b % i == 0:
        count += 1
    if count == k:
        print(i)
        break
import re
T=input()
N=len(re.findall(r'\?',T))
A=[]
def dfs(nums,length):
    if length==N:
        A.append(nums)
        return
    for i in range(0,2):
        new_nums=nums+[i]
        dfs(new_nums,length+1)
dfs([],0)
D={0:'P',1:'D'}
ans=0
ans2=''
for i in A:
    count=0
    new_T=''
    for j in T:
        if j=='?':
            j=D[i[count]]
            count+=1
        new_T=new_T+j
    if ans<=len(re.findall(r'PD',new_T))+len(re.findall(r'D',new_T)):
        ans2=new_T
print(ans2)

### FIXED CODE ###

T=input()
new_T=''
for i in T:
    if i=='?':
        i='D'
    new_T=new_T+i
print(new_T)
a,b,c,d,e,k=map(int,input().split())
if (a-e) < k :
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if ( e - a ) <= k :
  print("Yay!")
else:
  print(":(")
a = int(input())
i = 1
cnt = 0
while i <= a:
  if len(i)%2 == 1:
    cnt += 1
  i += 1

print("{}".format(cnt))

### FIXED CODE ###

a = int(input())
i = 1
cnt = 0
while i <= a:
  if len(str(i))%2 == 1:
    cnt += 1
  i += 1
 
print("{}".format(cnt))
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
sa1=(a1-b1)*t1
sa2=(a2-b2)*t2
if sa1>=0:
    --sa1
    --sa2
if sa1+sa2==0:
    print("infinity")
if sa1+sa2<0:
    print(0)
if sa1+sa2>0:
    ans=((-sa1)//(sa2+sa1))*2+1
    if sa1%(sa1+sa2)==0:
        ans-=1
    print(ans)


### FIXED CODE ###

m1,d1=map(int,input().split())
m2,d2=map(int,input().split())
if d2==1:
    print(1)
else:
    print(0)
a,b,c,k=map(int,input().split())
ans=0

while(1):
    if(b<=a):
        b=b*2
        ans+=1
    else:
        break
while(1):
    if(c<=b):
        c=c*2
        ans+=1
    else:
        break    
        
if(ans > k):
    print('No')
else:
    print('Yes') 

### FIXED CODE ###

a,b,c=map(int,input().split())
k=int(input())

ans=0

while(1):
    if(b<=a):
        b=b*2
        ans+=1
    else:
        break
while(1):
    if(c<=b):
        c=c*2
        ans+=1
    else:
        break    
        
if(ans > k):
    print('No')
else:
    print('Yes')
from functools import lru_cache
dan,ana=map(int,input().split())
l=[int(input()) for _ in range(ana)]
@lru_cache(maxsize=10000000)
def f(x,*li):
  if x in li:return 0
  elif x==1:return 1
  elif x==2:return f(1,*li)+1
  else:return (f(x-1,*li)+f(x-2,*li))%(10**9+7)

print(f(dan,*l))

### FIXED CODE ###

n,m=map(int,input().split())
l={int(input()) for i in range(m)}
dp=[0 for i in range(n+1)]
dp[0]=1
for i in range(1,1+n):
    if i not in l:dp[i]+=dp[i-1]+dp[i-2];dp[i]%=10**9+7
print(dp[n])
import sys

class Okojo:
    def __init__(self, line):
        self.line = line
        self.l = []
        self.r = []
        self.get_lr()

    def get_lr(self):
        for i in range(len(self.line)):
            if self.line[i] == 'L':
                self.l.append(i)
            else:
                self.r.append(i)

    def get_next(self, state):
        nex = [0] * len(self.line)
        for i in range(len(self.l)):
            nex[self.l[i] - 1] += state[self.l[i]]
        for i in range(len(self.r)):
            nex[self.r[i] + 1] += state[self.r[i]]
        return nex


def resolve():
    input = sys.stdin.readline
    line = input()

    okojo = Okojo(line)

    now = [1] * len(line)
    before1 = now
    for i in range(10 ** 100):
        before2 = before1
        before1 = now
        now = okojo.get_next(before1)
        if before1 == now:
            break
        elif before2 == now:
            if i % 2 == 0:
                now = before1
            break

    print(*now)
resolve()

### FIXED CODE ###

def resolve():
    line = input()
    result = [0] * len(line)

    r_odd = 0
    r_even = 0
    for i in range(len(line)):
        if line[i] == 'L':
            if i % 2 == 0:
                result[i] += r_even
                result[i-1] += r_odd
            else:
                result[i] += r_odd
                result[i-1] += r_even
            r_odd = 0
            r_even = 0
        elif line[i] == 'R':
            if i % 2 == 0:
                r_even += 1
            else:
                r_odd += 1
    l_odd = 0
    l_even = 0
    for i in range(len(line)-1, -1, -1):
        if line[i] == 'R':
            if i % 2 == 0:
                result[i] += l_even
                result[i+1] += l_odd
            else:
                result[i] += l_odd
                result[i+1] += l_even
            l_odd = 0
            l_even = 0
        elif line[i] == 'L':
            if i % 2 == 0:
                l_even += 1
            else:
                l_odd += 1

    print(*result)
    
resolve()
import sys
sys.setrecursionlimit(50000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)
a = int(input())
b = int(input())
if a*b % 2 = 1:
  print(a*b // 2+1)
else:
  print(a*b // 2)

### FIXED CODE ###

h,w=map(int,input().split())
if h==1 or w==1:
  print(1)
else:
  print((h*w+1)//2)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = raw_input().split()
rect = int(var[0]) * int(var[1])
length = int(var[0]) * 2 + int(var[1]) * 2

print rect + " " + length

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = raw_input().split()
rect = int(var[0]) * int(var[1])
length = int(var[0]) * 2 + int(var[1]) * 2

print str(rect) + " " + str(length)
from collection import Counter
n = int(input())
s = input()

mod = 10**9+7

scnt = Counter(s).most_common()
ans = 1

for i in range(len(scnt)):
    ans = ans*scnt[i][1]%p
ans = (ans - 1 + p)%p
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
s = input()

mod = 10**9+7

scnt = Counter(s).most_common()
ans = 1

for i in range(len(scnt)):
    ans = ans*(scnt[i][1]+1)%mod
ans = (ans - 1 + mod)%mod
print(ans)
N = int(input())
T, A = [int(i) for i in input().split(" ")]
temp = [int(T-0.006*h) for h in int(input().split(" "))]

place = 0
diff_min = 0

for cnt, t in enumerate(temp):
  if abs(T-t) < diff_min:
    diff_min = abs(T-t)
    place = cnt

print(place)
  

### FIXED CODE ###

N = int(input())
T, A = [int(i) for i in input().split(" ")]
temp = [T-0.006*int(h) for h in input().split(" ")]

place = 1
diff_min = abs(temp[0]-A)

for cnt, t in enumerate(temp,1):
  if abs(A-t) < diff_min:
    diff_min = abs(A-t)
    place = cnt

print(place)
n=int(input())
lst=[[[0]*10 for i in range(0,3)] for j in range(0,4)]
for k in range(n):
    b,f,r,v = map(int,input().split())
    lst[b-1][f-1][r-1] +=v
x=0
for i in range (4):
    if x!=0: print("#"*20)
    x+=1
    for a in range(3):
        for b in range(10):
            print(" %d",%(lst[i][a][b]),end="")
        print()


### FIXED CODE ###

n= int(input())
tbl=[[[0]*10 for i in range(0,3)] for j in range(0,4)]
for k in range(n):
    b,f,r,v = map(int,input().split())
    tbl[b-1][f-1][r-1] +=v
x=0
for i in range (4):
    if x !=0 : print("#"*20)
    x +=1
    for a in range(3):
        for b in range(10):
            print(" %d"%(tbl[i][a][b]),end="")     
        print()
# -*- coding: utf-8 -*-
# 標準入力を取得
N, X, M = list(map(int, input().split()))

# 求解処理


def f(x: int, m: int) -> int:
    return x**2 % m


A = {X}
loop_start_index = 0
while True:
    A_next = f(A[-1], M)
    if A_next in A:
        loop_start_index = A.index(A_next)
        break
    else:
        A.add(A_next)

loop_length = len(A) - loop_start_index
loop_cnt = (N - loop_start_index) // loop_length
loop_res = (N - loop_start_index) % loop_length
ans = sum(A[:loop_start_index]) + \
    loop_cnt * sum(A[loop_start_index:]) + \
    sum(A[loop_start_index: loop_start_index + loop_res])

# 結果出力
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 標準入力を取得
N, X, M = list(map(int, input().split()))

# 求解処理
s = {X}
l = [X]
i = 0
while True:
    a = l[-1]**2 % M
    if a in s:
        i = l.index(a)
        break
    else:
        s.add(a)
        l.append(a)

loop_length = len(l) - i
loop_cnt = (N - i) // loop_length
loop_res = (N - i) % loop_length
ans = sum(l[:i]) + loop_cnt * sum(l[i:]) + sum(l[i: i + loop_res])

# 結果出力
print(ans)
from operator import mul
from functools import reduce

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

mod=10**9+7

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under%mod

for i in range(K):
    print((cmb(N-K+1,i+1)*cmb(K-1,i))%mod)

### FIXED CODE ###

from operator import mul
from functools import reduce

from operator import mul
from functools import reduce

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

mod=10**9+7

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under%mod

for i in range(K):
    if i<N-K+1:
        print((cmb(N-K+1,i+1)*cmb(K-1,i))%mod)
    else:
        print(0)
import itertools
N, M = map(int, input().split())

G = {k: set() for k in range(N+1)}
for _ in range(N):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a].add(b)
    G[b].add(a)

ans = 0
for p in itertools.permutations(range(2, N+1)):
    c = 1
    for n in p:
        if n not in G[c]:
            break
        c = n
    else:
        ans += 1

print(ans)


### FIXED CODE ###

import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)
from math import sqrt
n,d = map(int, input().split())

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

def ds(a,b):
  s = 0
  for i in range(d):
    s += (b[i] - a[i])**2
  return sqrt(s)

ans = 0
for i in range(n):
  for j in range(i+1,n):
    d = ds(vs[i], vs[j])
    if d == int(d):
      ans += 1
      
print(ans)

### FIXED CODE ###

from math import sqrt
n, d = map(int, input().split())

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


def ds(a, b):
    s = 0
    for i in range(d):
        s += (b[i] - a[i])**2
    return sqrt(s)


ans = 0
for i in range(n):
    for j in range(i+1, n):
        dist = ds(vs[i], vs[j])
        if dist == int(dist):
            ans += 1

print(ans)
x = int(input())
while True:
  if isPrime(x):
    print(x)
    break
  x = x+1
  
def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  for p in range(2, n):
      if n % p == 0:
        return False
  return True

### FIXED CODE ###

def isPrime(n):
  if n == 2:
    return True
  for p in range(2, n):
      if n % p == 0:
        return False
  return True
 
x = int(input())
while True:
  if isPrime(x):
    print(x)
    break
  x = x+1
L, R = map(int, input().split())
import numpy as np
LL = L%2019
RR = R%2019
min = 2019


for i in range(LL, RR+1):
	for j in range(i+1, RR+1):
    	if (i*j)%2019 == 0:
        	min = 0
        	break
        elif (i*j)%2019 < min:
            min= (i*j)%2019


print(min)


### FIXED CODE ###

L, R = map(int, input().split())
import numpy as np
LL = L%2019
RR = R%2019

min = 2019
if LL >= RR:
    min = 0
elif R-L >= 2018:
    min = 0
else:
    for i in range(LL, RR+1):
        for j in range(i+1, RR+1):
            if (i*j)%2019 < min:
                min = (i*j)%2019
            if (i*j)%2019 == 0:
                min = 0
                break
        else:
            continue
        break


print(min)
def main():
    n, q = split_and_to_int(input().strip())
    s = input().strip()

    res = ""
    for _ in range(q):
        l, r = split_and_to_int(input().strip())
        n = 0
        for i in range(l-1, r-2):
            if s[i] == 'A' and s[i+1] == 'C':
                n += 1
                i += 1
        res = res + "\n" + n

    print(res)


def split_and_to_int(s):
    return [int(i) for i in s.split()]


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, q = map(int, input().split())
    s = input()

    # 累積出現数を格納: 指定される番号が1始まりなのでズラして格納
    p = [0] * (n+1)
    for i in range(n):
        p[i+1] = p[i] + (1 if s[i:i+2] == "AC" else 0)

    for i in range(q):
        l, r = map(int, input().split())
        # 終端(=l-1)から始端-1(=r-1)の累積出現数を引いた数が指定区間内での出現回数
        print(p[r-1] - p[l-1])


if __name__ == '__main__':
    main()
N,M = [int(v) for v in input().split()]
ad_list = [[] for _ in range (N+1)]
ad_num = [0 for _ in range(N)]
topo = []

for _ in range(M):
    l,r = [int(v) for v in input().split()]
    ad_list[l].append(r)
    ad_num[r-1] += 1
for i in range(1,N+1):
    if ad_num[i-1] == 0:
        topo.append(i)

queue = topo[:]
while queue:
    n1 = queue.pop(0)
    for n2 in ad_list[n1]:
        ad_num[n2-1] -= 1
        if ad_num[n2-1] == 0:
            topo.append(n2)
            queue.append(n2)

visited = [False for _ in range(N)]

ans = 0
path_len = 0
def dfs(node,cnt=1):
    global ans
    if visited[node-1]: return 0
    visited[node-1] = True
    ans = max(ans,cnt)
    for n in ad_list[node]:
        dfs(n,cnt+1)

for n in range(1,N+1):
    dfs(n)
print(ans)


### FIXED CODE ###

from collections import deque

N,M = [int(v) for v in input().split()]
ad_list = [[] for _ in range (N+1)]
ad_num = [0 for _ in range(N)]
topo = []

for _ in range(M):
    l,r = [int(v) for v in input().split()]
    ad_list[l].append(r)
    ad_num[r-1] += 1

for i in range(1,N+1):
    if ad_num[i-1] == 0:
        topo.append([i,0])
queue = deque(topo[:])
while queue:
    n1,cnt = queue.popleft()
    for n2 in ad_list[n1]:
        ad_num[n2-1] -= 1
        if ad_num[n2-1] == 0:
            topo.append([n2,cnt+1])
            queue.append([n2,cnt+1])
print(max([v[1] for v in topo]))
import numpy as np
N = int(input())
L = list(map(int,input().split()))
cnt = 0
L.sort()
L = L[::-1]

def nibutan(L,i,j,N):
    lower = N-1
    upper = j+1
    middle = int(np.round(upper+lower)/2)
    if upper> lower:
        return 0

    for cnt in range(16):
        if L[i] < L[j] + L[middle]:
            upper = middle
            middle = int(np.round((upper+lower)/2))
        else:
            lower = middle
            middle = int(np.round((upper+lower)/2))-1
#         print(middle)
    return max([middle - j,0])

# print('L',L)
for i in range(N):
    for j in range(i+1,N):
#         print('test',L[i],L[j])
        cnt += nibutan(L,i,j,N)
print(cnt)

### FIXED CODE ###

import bisect
 
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        tmp=a[i]+a[j]
        index=bisect.bisect_left(a,tmp)
        ans+=index-j-1
print(ans)
a, b, c = map(int, input().split)

if a > b + c:
  print(0)
else:
  print(c+b-a)

### FIXED CODE ###

a, b, c = map(int, input().split())

if a > b + c:
  print(0)
else:
  print(c+b-a)