Harryxun/stf_run huggingface dataset:
def dfs(cur_node, candidates, visited, level, cnt):

  while len(candidates) > 0:
    node, level = candidates.pop(0)

    if visited[node]: continue
    visited[node] = True

    if level > 0: cnt += 1
    print(cur_node, node, cnt)

    for n in adj_list[node][FRIEND]:
      if n in adj_list[cur_node][BLOCK]:
        candidates.append((n, 0))
      if visited[n] == False:
        candidates.append((n, level+1))

  return cnt

# -----------------------------------------

FRIEND, BLOCK = 0, 1

N, F, B = list(map(int, input().split()))
adj_list = defaultdict(dict)
for i in range(1, N+1):
  adj_list[i][0] = set()
  adj_list[i][1] = set()

for _ in range(F):
  u, v = list(map(int, input().split()))
  adj_list[u][FRIEND].add(v)
  adj_list[v][FRIEND].add(u)

for _ in range(B):
  u, v = list(map(int, input().split()))
  adj_list[u][BLOCK].add(v)
  adj_list[v][BLOCK].add(u)

print(adj_list)
ans = []

for i in range(1, N+1):
  visited = [False] * (N+1)
  visited[i] = True
  candidates = []
  for node in adj_list[i][FRIEND]:
    # node, level
    candidates.append((node, 0))

  cnt = 0
  cnt = dfs(i, candidates, visited, 0, 0)
  ans.append(cnt)

print(ans)

### FIXED CODE ###

class UF():
  def __init__(self, N):
    self.par = [-1] * N

  def union(self, x, y):
    p1,p2 = self.find(x), self.find(y)
    if p1 == p2: return

    if self.par[p1] > self.par[p2]:
      p1,p2 = p2,p1
    self.par[p1] += self.par[p2]
    self.par[p2] = p1

  def find(self, x):
    if self.par[x] < 0:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]

  def size(self, x):
    return -self.par[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

N,M,K = map(int,input().split())
uf = UF(N)
adj = [ [] for _ in range(N)]
for _ in range(M):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  adj[u].append(v)
  adj[v].append(u)
  uf.union(u,v)

res = []
for n in range(N):
  res.append(uf.size(n) - 1 - len(adj[n]))

for _ in range(K):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  if uf.same(u,v):
    res[u] -= 1
    res[v] -= 1

print(" ".join(map(str, res)))
X,t=map(int,input().split())
print(max(X-t, 0)

### FIXED CODE ###

X,t=map(int,input().split())
print(max(X-t,0))
X, Y, Z = input()
print(Z, X, Y)

### FIXED CODE ###

X, Y, Z = map(int, input().split())
print(Z, X, Y)
N = int(input())
lremain = []
rremain = []

for i in range(N):
	S = input()
	left = 0
	right = 0
	for c in S:
		if c == ".":
			left += 1
		else:
			if left == 0:
				right += 1
			else:
				left -= 1
	if left == 0 and right == 0:
		continue
	lremain.append(left)
	rremain.append(right)

N = len(lremain)

if sum(lremain) != sum(rremain):
	print("No")
	exit()

head = 0
tail = 0
removei = []
for i in range(N):
	if rremain[i] == 0:
		head += lremain[i]
		removei.append(i)
	if lremain[i] == 0:
		tail += rremain[i]
		removei.append(i)

lnr = []
for i in range(N):
	if not i in removei:
		lnr.append((lremain[i], rremain[i]))

N = len(lnr)
lnr.sort(key = lambda x: (x[1], -x[0]))

for i in range(N):
	if head < lnr[i][1]:
		print("No")
		exit()
	head -= lnr[i][1]
	head += lnr[i][0]

if head == tail:
	print("Yes")
else:
	print("No")
	
	
23, 31, 41, 43 wa
1, 2, 3, 4, tle

### FIXED CODE ###

N = int(input())
lremain = []
rremain = []

for i in range(N):
	S = input()
	left = 0
	right = 0
	for c in S:
		if c == "(":
			left += 1
		else:
			if left == 0:
				right += 1
			else:
				left -= 1
	if left == 0 and right == 0:
		continue
	lremain.append(left)
	rremain.append(right)

N = len(lremain)

if sum(lremain) != sum(rremain):
	print("No")
	exit()

head = 0
tail = 0
removei = set()
for i in range(N):
	if rremain[i] == 0:
		head += lremain[i]
		removei.add(i)
	if lremain[i] == 0:
		tail += rremain[i]
		removei.add(i)

lnr = []
for i in range(N):
	if not i in removei:
		lnr.append((lremain[i], rremain[i]))

N = len(lnr)
lnr.sort(key = lambda x: (x[1]-x[0]))

for i in range(N):
	if head < lnr[i][1]:
		print("No")
		exit()
	head -= lnr[i][1]
	head += lnr[i][0]

if head == tail:
	print("Yes")
else:
	print("No")
# coding: utf-8

N, C = map(int, input().split())
x_list = []
v_list = []
for i in range(N):
    xi, vi = map(int, input().split())
    x_list.append(xi)
    v_list.append(vi)
energy = [0 for i in range(N)]

# スタートから近い方向で回ったときに獲得するエネルギーを初期値とする
for i in range(N):
    if x_list[i] <= C/2:
        energy[i] = sum(v_list[0:i+1]) - x_list[i]
    else:
        energy[i] = sum(v_list[i:N]) - (C - x_list[i])

for i in range(1, N-1):
    # エネルギーが前より増えた地点があったら反対周りからのエネルギー獲得もチェックする
    if energy[i] < energy[i+1]:
        tmp_en = energy[i-1]

        if x_list[i-1] <= C/2:
            for j in range(N, i + 1, -1):
                tmp_en += (v_list[j] - (C - x_list[j]))

            if tmp_en > energy[i+1]:
                energy[i+1] = tmp_en
        else:
            for j in range(i+1):
                tmp_en += (v_list[j] - x_list[j])

            if tmp_en > energy[i+1]:
                energy[i+1] = tmp_en

ans = max(energy)

print(ans)

### FIXED CODE ###

# coding: utf-8

N, C = map(int, input().split())
x_list = []
v_list = []
for i in range(N):
    xi, vi = map(int, input().split())
    x_list.append(xi)
    v_list.append(vi)

e_clock = [0] * N
e_counter = [0] * N
e_clock0 = [0] * N # 時計回りしたあと、初期位置に戻った状態
e_counter0 = [0] * N # 反時計回りしたあと、初期位置に戻った状態

# 時計回り、反時計回りはそれぞれ多くて１回ずつである
# (何度も切り替えしても、距離だけ増えて効率的でない

# 時計回りに回ったときの各地点までの取得エネルギーで最大値を格納する
cal = 0
e = 0
e0 = 0
for i in range(N):
    cal += v_list[i]
    x = x_list[i]
    e = max(e, cal - x)
    e0 = max(e0, cal - 2*x)

    e_clock[i] = e
    e_clock0[i] = e0


# 反時計回りに回ったときの各地点までの取得エネルギーで最大値を格納する
cal = 0
e = 0
e0 = 0
for i in range(N-1, -1, -1):
    cal += v_list[i]
    x = C - x_list[i]
    e = max(e, cal - x)
    e0 = max(e0, cal - 2*x)
    e_counter[i] = e
    e_counter0[i] = e0

ans = 0

for i in range(N-1):
    # 時計回りのあと、反時計回りをしたとき
    e1 = e_clock0[i] + e_counter[i+1]
    # 反時計回りのあと、時計回りをしたとき
    e2 = e_counter0[i+1] + e_clock[i]

    ans = max(ans, e1, e2)

# 上はrange(N-1)のforなので
# 時計回りと反時計回りのそれぞれでまるまる１周した場合も加える
ans = max(ans, e_clock[N-1], e_counter[0])

print(ans)
nums = int(input().split())
count = 0
while all(num%2==0 for num in nums):
  for i in range(len(nums)):
    nums[i] = nums[i]/2
    count += 1
print(count)

### FIXED CODE ###

N = input()
nums = input().split()
count = 0
while all(int(num) % 2 == 0 for num in nums):
  for i in range(len(nums)):
    nums[i] = int(nums[i]) // 2
  count += 1
print(count)
import numpy as np

N = input()

num_paper = int(N) / 2
if (N % 2) > 0:
  num_paper += 1
else:
  pass

print(num_paper)


### FIXED CODE ###

N = input()
N = int(N)
num_paper = int(N / 2)
if (N % 2) > 0:
  num_paper += 1
else:
  pass

print(num_paper)
S=int(input())

def f(n): 
      
    # single line to find factorial 
    return 1 if (n==1 or n==0) else n * factorial(n - 1);

possibles=0

n=10**9+7
biggest_sub=S//3
for i in range(1,biggest_sub+1):
	possibles+=f(S-3*i+i-1)/f(i-1)/f(S-3*i)
	possibles%=n

n=10**9+7
print(possibles%n)

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
Q = 10**9+7
def cmb(n,r):
    if n-r < r: r = n-r
    if r == 0: return 1
    denominator = 1                       #分母
    numerator = 1                         #分子
    for i in range(r):
        numerator *= n-i
        numerator %= Q
        denominator *= i+1
        denominator %= Q
    return numerator*pow(denominator, Q-2, Q)%Q
 
def main():
    S = int( input())
    ans = 0
    for i in range(1, S//3+1):
        t = S - i*3
        ans += cmb(t+i-1,i-1)
        ans %= Q
    print(ans)
        
if __name__ == '__main__':
    main()
inp = raw_input().split("\n")
Size = inp[0]

Mml = [None, 0] + [None] * 8
Cij = [[0] * 10 for i in range(10)]
for i in xrange(10):
    for j, a in enumerate(map(int,inp[i + 1].split(" "))):
        Cij[i][j] = a
        #print a,
    #print

def sloveMm(n):
    global Mml
    if(Mml[n] != None):
        return Mml[n]
    Nmm = Cij[n][1]
    rourt = [[n, 0, Nmm,n]]
    while len(rourt) > 0:
        rl = len(rourt)
        new_rourt = []
        for rn in xrange(rl):
            r = rourt[rn]
            for i in xrange(10):
                if i != r[0]:
                    nm = r[1] + Cij[r[0]][i]
                    if nm < Nmm:
                        """if Mml[i] != None:
                            Mml[n] = nm + Mml[i]
                            return nm + Mml[i]"""
                        if i == 1:
                            #print r
                            Nmm = nm
                        new_rourt.append([i, nm, nm + Cij[i][1]] + r[3:] + [i] )
        rourt = new_rourt
    Mml[n] = Nmm
    return Nmm


NumberList = [0] * 10
for Ai in inp[11:]:
    #print Ai
    for A in Ai.split(" "):
        if A != "-1" and A != "":
            NumberList[int(A)] += 1

ans = 0
for i, n in enumerate(NumberList):
    if n > 0:
        ans += sloveMm(i) * n
        #print "AA",i,":",Cij[i][1],">>",Mml[i],"*", n
#print Mml
#print NumberList
print ans



### FIXED CODE ###


inp = []
inp.append(raw_input())
for i in xrange(10 + int(inp[0].split(" ")[0])):
    inp.append(raw_input())
Size = inp[0]

Mml = [None, 0] + [None] * 8
Cij = [[0] * 10 for i in range(10)]
for i in xrange(10):
    for j, a in enumerate(map(int,inp[i + 1].split(" "))):
        Cij[i][j] = a
        #print a,
    #print

def sloveMm(n):
    global Mml
    if(Mml[n] != None):
        return Mml[n]
    Nmm = Cij[n][1]
    rourt = [[n, 0, Nmm,n]]
    while len(rourt) > 0:
        rl = len(rourt)
        new_rourt = []
        for rn in xrange(rl):
            r = rourt[rn]
            for i in xrange(10):
                if i != r[0]:
                    nm = r[1] + Cij[r[0]][i]
                    if nm < Nmm:
                        """if Mml[i] != None:
                            Mml[n] = nm + Mml[i]
                            return nm + Mml[i]"""
                        if i == 1:
                            #print r
                            Nmm = nm
                        new_rourt.append([i, nm, nm + Cij[i][1]] + r[3:] + [i] )
        rourt = new_rourt
    Mml[n] = Nmm
    return Nmm


NumberList = [0] * 10
for Ai in inp[11:]:
    #print Ai
    for A in Ai.split(" "):
        if A != "-1" and A != "":
            NumberList[int(A)] += 1

ans = 0
for i, n in enumerate(NumberList):
    if n > 0:
        ans += sloveMm(i) * n
        #print "AA",i,":",Cij[i][1],">>",Mml[i],"*", n
#print Mml
#print NumberList
print ans
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    a = input()
    if a.isupper():
        print(A)
    else:
        print(a)

    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    a = input()
    if a.isupper():
        print("A")
    else:
        print("a")

    return

if __name__ == '__main__':
    main()
n = list(input().split())
print(n)

if n in ('1'):
    if n in ('9'):
        if n in ('7'):
            if n in ('4'):
                print('YES')
                exit(0)

print('NO')

### FIXED CODE ###

n = list(input().split())

if '1' in n:
    if '9' in n:
        if '7' in n:
            if '4' in n:
                print('YES')
                exit(0)

print('NO')
N = int(input())
A = list(map(int,input().split()))
count = 0
up = 0
down = 0
before = A[0]
tmp = 0
for i in range(1,N):
  tmp = A[i]
  if (up == 0) and (down == 0):
    if tmp > before:
      up = 1
      before = tmp
    elif tmp < before:
      down = 1
      before = tmp
    else:
      continue
  elif up == 1:
    if tmp < before:
      count += 1
      up = 0
      before = tmp
  elif down = 1:
    if tmp > before:
      count += 1
      down = 0
      before = tmp
count += 1
print(count)
      

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
count = 0
up = 0
down = 0
before = A[0]
tmp = 0
for i in range(1,N):
  tmp = A[i]
  if (up == 0) and (down == 0):
    if tmp > before:
      up = 1
      before = tmp
    elif tmp < before:
      down = 1
      before = tmp
    else:
      continue
  elif up == 1:
    if tmp < before:
      count += 1
      up = 0
      before = tmp
    else:
      before = tmp
  elif down == 1:
    if tmp > before:
      count += 1
      down = 0
      before = tmp
    else:
      before = tmp
count += 1
print(count)
import math
s = int(input())
r = math.floor(math.sqrt(s)) + 1 - 1
k = r**2 - s
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))

### FIXED CODE ###

import math
s = int(input())
r = math.floor(math.sqrt(s)) + 1
k = r**2 - s
if r == 10**9 + 1:
    print("{} {} {} {} {} {}".format(0, 0, 1,r - 1,r - 1, 0))
    exit()
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))
a = list(input().split())
if a[1] = "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

### FIXED CODE ###

a = input().split()
if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))
visited=[False]*(10**6+1)

N=int(input())
A=list(map(int,input().split()))
A.sort()

if A[1]==1:
  print(0)
  exit()
if A[0]==1:
  print(1)
  exit()
ans=0
for i in range(N):
  if visited[A[i]]:
    continue
  ans+=1
  index=1
  while A[i]*index<=10**6+1:
    visited[A[i]*index]=True
    index+=1
num=0
for i in range(1,N):
  if A[i]==A[i-1] and num!=A[i]:
    ans-=1
    num=A[i]
    
print(ans)

### FIXED CODE ###

visited=[False]*(10**6+1)

N=int(input())
A=list(map(int,input().split()))
A.sort()

if N>=2 and A[1]==1:
  print(0)
  exit()
if A[0]==1 or N == 1:
  print(1)
  exit()
  
ans=0
for i in range(N):
  if visited[A[i]]:
    continue
  if i < N-1 and A[i]==A[i+1]:
    index = 1
    while A[i]*index<=10**6:
      visited[A[i]*index]=True
      index+=1
    continue
  ans+=1
  index=1
  while A[i]*index<=10**6:
    visited[A[i]*index]=True
    index+=1
    
print(ans)
L, R = [int(i) for i in input().split()]
min = 2018
if (R-L)>=2019:
    a = R/2019
    R = R-2019*a
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if(mod<min):
            min = mod
print("{}".format(min))

### FIXED CODE ###

L, R = [int(i) for i in input().split()]
min = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if mod<min:
            min = mod
        if mod==0:
            print("{}".format(mod))
            exit()
print("{}".format(min))
a, b = map(int, input().split())
def S:
	return a*b
	return 2*(a+b)
print S

### FIXED CODE ###

a,b = list(map(int, input().split()))
print(a*b, 2*(a+b))
n = int(input())
A = [input().split() for _ in range(n)]
print("AC x "+ A.count("AC"))
print("WA x "+ A.count("WA"))
print("TLE x "+ A.count("TLE"))
print("RE x "+ A.count("RE"))


### FIXED CODE ###

n = int(input())
A = [input() for _ in range(n)]

print("AC x " + str(A.count("AC")))
print("WA x " + str(A.count("WA")))
print("TLE x " + str(A.count("TLE")))
print("RE x " + str(A.count("RE")))
N = int(input())
ans = []
check = 0
for i in range(N):
    num = int(input())
    for n in range(len(ans)):
        if ans[n] == num:
            check = -1
            break
        else:
            check = n
    if check == -1:
        ans.remove(num)
    else:
        ans.append(num)
print(len(ans))

### FIXED CODE ###

N = int(input())
ans = set()
for i in range(N):
    num = int(input())
    if num in ans:
        ans.remove(num)
    else:
        ans.add(num)
print(len(ans))
n=input()
s=input()

print(s.count("ABC"))

### FIXED CODE ###

K,X=map(int,input().split())
if 500*K>=X:
	print("Yes")
else:
  	print("No")
n = list(input().split())
s, t = list(input().split())

ans = []
for i in range(0, int(len(n)+1)):
  ans.append(s[i])
  ans.append(t[i])
  
print(''.join(map(str,ans)))

### FIXED CODE ###

n = list(input().split())
s, t = list(input().split())

ans = []
for i in range(0, int(n[0])):
  ans.append(s[i])
  ans.append(t[i])
  
print(''.join(map(str,ans)))
inport sys
for i in sys.stdin:
        a,b = map(int,i.split())
        if a == 0 and b == 0:
                 break;
        if a < b:
                 print(a,b)
        else:
                 print(b,a)

### FIXED CODE ###

import sys
for i in sys.stdin.readlines():
        a,b = i.strip().split()
        if a == "0" and b == "0":
                break

        if int(a) < int(b):
                print("{0} {1}".format(a,b))
        else:
                print("{1} {0}".format(a,b))
# ==================================================-
# 二分探索
# functionを満たす,search_listの最大の要素を出力
# 【注意点】searchリストの初めの方はfunctionを満たし、後ろに行くにつれて満たさなくなるべき
import math
import sys

sys.setrecursionlimit(10 ** 9)


def binary_research(start, end,function):
    if start == end:
        return start
    middle = math.ceil((start + end) / 2)
    if function(middle, k, a_sum, b_sum):
        start = middle
    else:
        end = middle - 1
    return binary_research(start, end, function)


# ==================================================-

n, m, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a_sum = [0]
b_sum = [0]
for book in a:
    a_sum.append(a_sum[-1] + book)
for book in b:
    b_sum.append(b_sum[-1] + book)


def can_read(num, k, a_sum, b_sum):
    min_read_time = 1000000000000
    sentou=
    for i in range(max(0, num - m), min(num+1,n+1)):
        a_num = i
        b_num = num - i
        min_read_time = min(min_read_time, a_sum[a_num] + b_sum[b_num])
    if min_read_time <= k:
        return True
    return False


start = 0
end = n + m

print(binary_research(start, end, can_read))

### FIXED CODE ###

n,m,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]

def make_sumlist(book_list):
    sumnum=0
    container=[0]
    for i in book_list:
        container.append(sumnum+i)
        sumnum+=i
    return container

total_a=make_sumlist(a)
total_b=make_sumlist(b)

# print(n,m,k)
# print(total_a)
# print(total_b)


#r個読めるか
def readable(r):
    #全部読んでも無理
    if r>n+m:
        return False
    if r==0:
        return True
    max_book=100000000000
    for a_n in range(max(0,r-m),min(n,r)+1):
        b_n=r-a_n
        # print(a_n,b_n)
        book_sum=total_a[a_n]+total_b[b_n]
        # print(book_sum)
        max_book=min(max_book,book_sum)
    if max_book<=k:
        return True
    return False

def nibuntansaku(start,end):
    if start==end:
        return start
    middle=(start+end)//2+1
    if readable(middle):
        start=middle
    else:
        end=middle-1
    return nibuntansaku(start,end)

print(nibuntansaku(0,k))
N = int(input())

for i in range(1, N):
    if i*i > N:
        break
        
    res = i * i

print(res)


### FIXED CODE ###

l = input()
m = input()
res = 'YES'


if l[0] != m[2]:
    res = 'NO'
    
if l[1] != m[1]:
    res = 'NO'
    
if l[2] != m[0]:
    res = 'NO'
        
print(res)
x = int(input())
ans = 10**9
def bfs(i,a):
    if a == x:
        global ans
        ans = min(ans,i-1)
    elif i<=x:
        bfs(i+1,a+i)
        bfs(i+1,a)
        bfs(i+1,a-i)
bfs(0,0)
print(ans)

### FIXED CODE ###

x = int(input())
ans = i = 0
while i<x:
    i += ans
    ans += 1
print(ans-1)
N,A,B = map(int, input().split())
l = []

for i in range(N):
    if i >= 10:
        keta_one = i //10
        keta_ten = i % 10
        sum = keta_one + keta_ten
    else:
        sum = i
    if 2 <= i <=5:
        l.append(i)
print(l)
print(sum(l))


### FIXED CODE ###

n, a, b = map(int, input().split())
 
sum = 0
for i in range(n+1) :
    count = 0
    for num in str(i) :
        count += int(num)
 
    if (count >= a) and (count <= b) :
        sum += i
            
print(sum)
n = input()
mod = 10**9 + 7
ans = (pow(10, n, mod) - ((2 * pow(9, n, mod)) % mod - pow(8, n, mod) + mod) % mod + mod) % mod
print(ans)

### FIXED CODE ###

n = int(input())
mod = 10**9 + 7
ans = (pow(10, n, mod) - ((2 * pow(9, n, mod)) % mod - pow(8, n, mod) + mod) % mod + mod) % mod
print(ans)
N,M =map(int,input().split())
a =list( map(int,input().split()) )
if N-sum(a) >=0:
    print(N-sum(a))
else :
    print(-1)    

### FIXED CODE ###

import math
R = int(input())
print(2*R*math.pi)
A, B, C, D = map(int, input().split())
print('Left' if A + B > C + D, else 'Balanced' if A + B == C + D else 'Right')

### FIXED CODE ###

A, B, C, D = map(int, input().split())
print('Left' if A + B > C + D else 'Balanced' if A + B == C + D else 'Right')
s,c = map(int,input().split())

if s*2 <= c:
    res = s
    c -= s*2
    s = 0
else:
    res += c//2
    m = 0

#print(res,s,c)

if c:
    res += c//4
print(res)

### FIXED CODE ###

s,c = map(int,input().split())
res = 0
if s*2 <= c:
    res = s
    c -= s*2
    s = 0
else:
    res += c//2
    c = 0

if c:
    res += c//4
print(res)
import math

n = int(input())
num_i = 0

for i in range(1,int(math.sqrt(n))):
    if n%i == 0:
        num_i = i

num_j = n//num_i
ans = (num_i-1)+(num_j-1)

print(ans)

### FIXED CODE ###

import math

n = int(input())
num_i = 0

for i in range(1,int(math.sqrt(n))+1):
    if n%i == 0:
        num_i = i

num_j = n//num_i
ans = (num_i-1)+(num_j-1)

print(ans)
N = input()
if N = N[::-1]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = input()
if N == N[::-1]:
  print('Yes')
else:
  print('No')
import sys
sys.setrecursionlimit(2*(10**5)+1)
def main():
    input = sys.stdin.readline
    N, Q = map(int,input().split())
    T = [[] for k in range(N)]
    V = [0]*N
    for _ in range(N-1):
        a, b = map(int,input().split())
        T[a-1].append(b-1)
        T[b-1].append(a-1)
    for q in range(Q):
        p, x = map(int,input().split())
        V[p-1] += x

    def dfs(mae,ima):
        for tsugi in T[ima]:
            if tsugi != mae:
                V[tsugi] += V[ima]
                dfs(ima,tsugi)
    dfs(-1,0)
    print(*V)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(200010)

def main():
    input = sys.stdin.readline
    N, Q = map(int,input().split())
    G = [[] for k in range(N+1)]
    for k in range(N-1):
        a, b = map(int,input().split())
        G[a].append(b)
    kyori = [0 for k in range(N+1)]
    for k in range(Q):
        p, x = map(int,input().split())
        kyori[p] -= x
    def dfs(now, dist):
        for tsugi in G[now]:
            if kyori[tsugi] <= 0:
                kyori[tsugi] = -kyori[tsugi]
                kyori[tsugi] += dist
                dfs(tsugi, kyori[tsugi])
    kyori[1] = -kyori[1]
    dfs(1,kyori[1])
    print(*kyori[1:], sep = " ")

if __name__ == '__main__':
    main()
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################


count = 0
for i in range(N):
    if i == (N-1):
        count += (i+1) % (1)
    else:
        count += (i+1) % (i+2)

print(count)


### FIXED CODE ###



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################


N = int(input())

# まず等差数列の和
n = N-2
count = (n*(4+(n-1)))//2

#print(count)

# 最終項
count += 1

print(count)
#A
n, a, b = map(int, input().split())
print(min(n*a,b))A

### FIXED CODE ###

#A
n, a, b = map(int, input().split())
print(min(n*a,b))
import decimal

A, B = map(input().split())
A = int(A)
B = decimal.Decimal(B)
print(int(A*B))

### FIXED CODE ###

import decimal

A, B = input().split()
A = int(A)
B = decimal.Decimal(B)
C = A * B
C = int(C)
print(C)