Harryxun/stf_run huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
sum_a = sum(a)
cumsum = list(itertools.accumulate(a))
ans = [0] * n
cnt = 0
if cumsum[m] / sum_a >= 1 / (n * m):
    cnt += 1
for i in range(1, n - m + 1):
    if (cumsum[m + i - 1] - cumsum[i - 1]) / sum_a >= 1 / (n * m):
        cnt += 1
    if cnt >= m:
        print('Yes')
        exit()
if cnt >= m:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
sum_a = sum(a)
cnt = 0
for i in range(n):
    if a[i] / sum_a >= 1 / (4 * m):
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')
N, K = map(int, input().split())
S = [i for i in input()]

for i in range(65, 65+26):
    if S[K]==chr(i):
        S[K]=chr(i+32)

print(''.join(S))

### FIXED CODE ###

N, K = map(int, input().split())
S = [i for i in input()]

for i in range(65, 65+26):
    if S[K-1]==chr(i):
        S[K-1]=chr(i+32)

print(''.join(S))
I = [int(input()) for _ in range(6)]

I[0] = a
I[4] = e
I[5] = k

if e-a > k:
	print(':(')
else :
	print('Yay!')

### FIXED CODE ###

I =[int(input())for i in range(6)]

if I[4] - I[0] > I[5] :
	print(":(")
else :
	print("Yay!")
N = int(input())
b = n**0.5//1.0
while True:
    if N%b != 0:
        b -= 1
    else:
        break
print(int(b+N/b-2))

### FIXED CODE ###


N = int(input())
b = N**0.5//1.0
while True:
    if N%b != 0:
        b -= 1
    else:
        break
print(int(b+N/b-2))
N, M = map(int, input().split())
#リスト内包表記でaに入れる
a = [int(input()) for _ in range(M)]

#MODに1000000007を入れる
MOD = 10**9 + 7
#Zに集合を作成する
Z = set(a)
 
#i段目までにたどりつく方法を順に求める
dp = [0 for _ in range(N + 1)]
#0段目の場合1とする
dp[0] = 1
#1段目の場合は集合の中に1が含まれていないかどうか、含まれていない:1、含まれている:0
dp[1] = int(1 not in Z)
#2段目以降の場合
for i in range(2, N + 1):
  #集合の中にiが含まれていない場合
    if i not in Z:
      #i段目に1段か2段で上ってきた経路数を足して、MODで割る、dp[i]に蓄積する
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
#ansに答えを入れる
ans = dp[i]
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
#リスト内包表記でaに入れる
a = [int(input()) for _ in range(m)]

#MODに'1000000007'を入れる
MOD = 10**9 + 7
#zに集合を作成する
z = set(a)
 
#i段目までにたどりつく方法を順に求める
x = [0 for _ in range(n + 1)]
#0段目の場合1とする
x[0] = 1
#1段目の場合は集合の中に1が含まれていないかどうか、含まれていない:1、含まれている:0
x[1] = int(1 not in z)
#2段目以降の場合
for i in range(2, n + 1):
#集合の中にiが含まれていない場合
    if i not in z:
#i段目に1段か2段で上ってきた経路数を足して、MODで割る、dp[i]に蓄積する
        x[i] = (x[i - 1] + x[i - 2]) % MOD
print(x[n])
def detectGroup(parents,x):
    if parents[x]!=x:
        return detectGroup(parents,parents[x])
    else:
        return x
    
N,M=map(int,input().split())
AB=[[int(x)-1 for x in input().split()] for i in range(M)][::-1]
parents=[i for i in range(N)]
groupsize=[1 for i in range(N)]
inconv=N*(N-1)/2
result = []
for i in range(M):
    result.append(str(int(inconv))+'\n')
    groupA=detectGroup(parents,AB[i][0])
    groupB=detectGroup(parents,AB[i][1])
    print(groupA,groupB,inconv)
    if groupA!=groupB:
        inconv-=groupsize[groupA]*groupsize[groupB]
        groupsize[groupA]+=groupsize[groupB]
    parents[groupB] = groupA
print("".join(result[::-1]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def detectGroup(parents,x):
    if parents[x]!=x:
        parents[x]=detectGroup(parents,parents[x])
        return parents[x]
    else:
        return x
    
N,M=map(int,input().split())
AB=[[int(x)-1 for x in input().split()] for i in range(M)][::-1]
parents=[i for i in range(N)]
groupsize=[1 for i in range(N)]
inconv=N*(N-1)/2
result = []
for i in range(M):
    result.append(str(int(inconv))+'\n')
    groupA=detectGroup(parents,AB[i][0])
    groupB=detectGroup(parents,AB[i][1])
    if groupA!=groupB:
        inconv-=groupsize[groupA]*groupsize[groupB]
        groupsize[groupA]+=groupsize[groupB]
    parents[groupB] = groupA
print("".join(result[::-1]))
= list(map(int, input().split()))
a = a.sort
b = [str(a[2]), str(a[1])]
c = ''.join(b)
print(int(c) + a[0])

### FIXED CODE ###

a = list(map(int, input().split()))
a = sorted(a)
b = [str(a[2]), str(a[1])]
c = ''.join(b)
print(int(c) + a[0])
import math
x = int(input())
ans = (int(math.sqrt(X)))**2
for i in range(1,int(math.sqrt(x)+2)):
  for j in range(2,10):
    if i ** j <= x and i**j > ans:
      ans = i**j

print(ans)

### FIXED CODE ###

import math
X = int(input())
n = (int(math.sqrt(X)))**2
for b in range(2, int(math.sqrt(X))+2):
    for p in range(1, 10):
        if (b**p > n) and (b**p <= X):
            n = b**p
print(n)
A = str(input())
S = []
for s in A:
    S.append(s)
ACGT = ["A","C","G","T"]
X = []
cnt = 0
ans = []
for i in range(len(S)):
    if S[i] in ACGT:
        cnt += 1
        continue
    else:
        ans.append(cnt)
        cnt = 0

print(max(ans))


### FIXED CODE ###

A = str(input())
S = []
for s in A:
    S.append(s)
ACGT = ["A","C","G","T"]
X = []
cnt = 0
ans = []
for i in range(len(S)):
    if S[i] in ACGT:
        cnt += 1
        continue
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))
A, B = map(int, input())

print(max(0, A-2*B))

### FIXED CODE ###

A, B = map(int, input().split())

print(max(0, A-2*B))
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
        
        self.par = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        tmpx,tmpy=x,y
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
            self.par[tmpy]  =tmpx

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            self.par[tmpx]  = tmpy
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


def cur(n):
    if memo[n]==-1: memo[n]=cur(tree.par[n])+1
    return memo[n]

N=int(input())
tree=UnionFind(N)


for i in range(N-1):
    u,v,w=map(int,input().split())
    tree.Unite(u,v)

memo=[-1]*(N+1)
memo[tree.Find_Root(0)]=0
for i in range(1,N+1):
    if cur(i)%2==0: print(0)
    else: print(1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

def cur(current,e,dist,color):
    for it in e[current]:
        if color[it]!=-1: continue
        color[it]=(color[current]+dist[(it,current)])%2
        cur(it,e,dist,color)

N=int(input())
e=[[] for i in range(N+1)]
dist={}
for i in range(N-1):
    u,v,w=map(int,input().split())
    e[u].append(v)
    e[v].append(u)
    dist[(u,v)],dist[(v,u)]=w,w
memo=[-1]*N




color=[-1]*(N+1)
color[1]=0
cur(1,e,dist,color)

for i in range(1,N+1):
    print(color[i])
n = input()
flag = True
s = []
w1 = input()
e = w1[-1]
for i in range(n-1):
  wi = input()
  if e != wi[-1]:
    flag = False
  
  e = wi[-1]
  
if flag:
  print("Yes")
  
else:
  print("No")

### FIXED CODE ###

n = int(input())
flag = True
s = []
words = []
w1 = input()
words.append(w1)
e = w1[-1]

for i in range(n-1):
    wi = input()
    if e != wi[0]:
        flag = False
    for w in words:
        if w == wi:
            flag = False
    words.append(wi)
    e = wi[-1]


if flag:
  print("Yes")
else:
  print("No")
A, B, C, D, E, F = tuple(map(int, input().split()))
max_con = 0
res = None
for l in range(100*A, F+1, 100):
    if l % (100 * A) == 0 or l % (100 * B) == 0:
        for e in range(1, E*(l//100)+1):
            if (e % C == 0 or e % D == 0) and  l + e <= F:
                if max_con < e / (l + e):
                    max_con = e / (l + e)
                    res = (l+e, e)
print(*res)

### FIXED CODE ###

A, B, C, D, E, F = tuple(map(int, input().split()))
max_con = 0
res = (100 * A, 0)
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        if i == 0 and j == 0:
            continue
        wat = (A * i + B * j)
        x = 100 * wat
        if F < x:
            continue
        for k in range(wat * E // C + 1):
            for l in range(wat * E // D + 1):
                y = C * k + D * l
                if wat * E < y:
                    continue
                total = x + y
                if F < total:
                    continue
                if max_con < y / total:
                    max_con = y / total
                    res = (total, y)
                    # print(x + y, y)
print(*res)
n=int(input())
a=[list(map(input().split())) for _ in range(n)]
x=input()
cnt='x'
for i in a:
  if cnt!='x':
    z=int(i[1])
    cnt+=z
    if i[0]==x:
      cnt=0
print(cnt)

### FIXED CODE ###

n=int(input())
a=[(input().split()) for _ in range(n)]
x=input()
cnt='x'
for i in a:
  if cnt!='x':
    z=int(i[1])
    cnt+=z
  if i[0]==x:
    cnt=0
print(cnt)
import bisect

n,q = (int(num) for num in input().split())
par = [i for i in range(n)]
nex = [[] for _ in range(n)]
ch = [0] * n
rank = [1] * n
val = [0] * n
ab = []
for i in range(n-1):
    a,b = (int(num)-1 for num in input().split())
    if a > b:
        a,b = b,a
    ab.append((a,b))
ab.sort(key = lambda x: x[0])
    
for item in ab:
    a = item[0]
    b = item[1]
    if rank[a] > rank[b]:
        par[b] = a
        nex[a].append(b)
    elif rank[a] < rank[b]:
        par[a] = b
        nex[b].append(a)
    elif a < b:
        par[b] = a
        nex[a].append(b)
        rank[a] += 1
    else:
        par[a] = b
        nex[b].append(a)
        rank[b] += 1
        
#print(par)
#print(nex)
#print(rank)

for _ in range(q):
    p,x = (int(num) for num in input().split())
    p -= 1
    val[p] += x
    
def calc(idx,nex,val,bias):
    val[idx] += bias
    if nex[idx] == []:
        return
    else:
        for i in nex[idx]:
            calc(i,nex,val,val[idx])
        
calc(0,nex,val,0)    
ans = ""    
for num in val:
    ans += str(num) + " "
print(ans)




### FIXED CODE ###

n,q = (int(num) for num in input().split())
par = [n] * n
visited = [0] * n
val = [0] * n
ab = []
for i in range(n-1):
    a,b = (int(num)-1 for num in input().split())
    par[b] = a
    
for _ in range(q):
    p,x = (int(num) for num in input().split())
    p -= 1
    val[p] += x

for i in range(1,n):
    val[i] += val[par[i]]
    
ans = ""
for num in val:
    ans += str(num) + " "
print(ans)
s=input()
cnt=0

if len(s)%2==0:
  for i in range(len(s)/2):
    if s[i]!=s[len(s)-i]:
      cnt+=1
else:
  for i in range((len(s)+1)/2):
    if s[i]!=s[len(s)-i]:
      cnt+=1
print(cnt)

### FIXED CODE ###

s = input()
 
cnt = 0
b = int(len(s))
 
for a in range(int(b/2)):
    if s[a] != s[(b-a-1)]:
       cnt = cnt +1
print(cnt)
numbers = []
n = raw_input()
for i in range(int(n)):
    input_num = raw_input()
    numbers.append(int(input_num))
count = 0
for num in numbers:
    if num == 2:
        count += 1
    for i in range(2, int(math.sqrt(num)) + 1):
        if num % i == 0:
            break
        count += 1
print count

### FIXED CODE ###

import math

numbers = []
n = raw_input()
for i in range(int(n)):
    input_num = raw_input()
    numbers.append(int(input_num))

count = 0
for num in numbers:
    prime_frag = True
    for i in range(2, int(math.sqrt(num)) + 1):
        if num % i == 0:
            prime_frag = False
            break
    if prime_frag:
        count += 1
print count
while 1;
 H = input()
 W = input()

  for i in range(H);{
    for k in range(W);{
      print'#'
     }
      print"/n"
  }
  if(H =0 and W =0);
    break

### FIXED CODE ###

while 1:
  H, W = map(int, raw_input().split())
  
  if W == 0 and H == 0:
    break
  
  for i in range(H):
    print "#" * W
  print""
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import ceil
    K=int(input())
    X,Y=map(int,input().split())

    # defaultは 0 <= Y <= X
    def trans(u,v):
        if(abs(X)<abs(Y)): u,v=v,u
        if(X<0): u=-u
        if(Y<0): v=-v
        return u,v

    x,y=max(abs(X),abs(Y)),min(abs(X),abs(Y))
    if(K%2==0 and (X+Y)&1):
        print(-1)
        return

    # x+y<K
    if(x+y<K and (x+y)&1):
        print(3)
        print(*trans(x,-K+x))
        print(*trans(x+(K+x-y)//2,-(K-x-y)//2))
        print(*trans(x,y))
        return
    if(x+y<K and (not (x+y)&1)):
        print(2)
        print(*trans((x+y)//2,-k+(x+y)//2))
        print(*trans(x,y))
        return

    # x+y>=K
    c=(-x-y)%K
    n=ceil((x+y)/K)+(c&1)
    l=(K*n-x-y)//2
    print(n)
    nx,ny=K-l,-l
    print(*trans(nx,ny))
    while(nx+K<=x):
        nx+=K
        print(*trans(nx,ny))
    nx,ny=x,ny+(x-nx)
    print(*trans(nx,ny))
    while(ny+K<=y):
        ny+=K
        print(*trans(nx,ny))
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import ceil
    K=int(input())
    X,Y=map(int,input().split())
    # defaultは 0 <= Y <= X
    def trans(u,v):
        if(abs(X)<abs(Y)): u,v=v,u
        if(X<0): u=-u
        if(Y<0): v=-v
        return u,v

    x,y=max(abs(X),abs(Y)),min(abs(X),abs(Y))
    if(K%2==0 and (X+Y)&1):
        print(-1)
        return

    # x+y<K
    if(x+y<K and (x+y)&1):
        print(3)
        print(*trans(x,-K+x))
        print(*trans(x+(K+x-y)//2,-(K-x-y)//2))
        print(*trans(x,y))
        return
    if(x+y<K and (not (x+y)&1)):
        print(2)
        print(*trans((x+y)//2,-K+(x+y)//2))
        print(*trans(x,y))
        return

    # x+y=K
    if(x+y==K):
        print(1)
        print(*trans(x,y))
        return
    
    # x+y>K
    c=(-x-y)%K
    n=ceil((x+y)/K)+(c&1)
    l=(K*n-x-y)//2
    print(n)
    nx,ny=K-l,-l
    print(*trans(nx,ny))
    while(nx+K<=x):
        nx+=K
        print(*trans(nx,ny))
    nx,ny=x,ny+(K-(x-nx))
    print(*trans(nx,ny))
    while(ny+K<=y):
        ny+=K
        print(*trans(nx,ny))
resolve()
A = input()
B = input()

ans = [1,2,3]
ans.remove(A)
ans.remove(B)
print(ans[0])

### FIXED CODE ###

A = int(input())
B = int(input())
ans = [1,2,3]
ans.remove(A)
ans.remove(B)
print(ans[0])
# D
import itertools
from scipy.special import comb
N = int(input())
ans_list = []
K = 0
for i in range(N):
    perm_list = ['a'] * (N - 1 - i)
    perm_list += ['x'] * (i)
    tmp_list = []
    al = [chr(ord('b') + j) for j in range(i)]

    K += comb(N-1, i)

    for v in itertools.permutations(perm_list, len(perm_list)):
        tmp = 'a'
        for j in range(len(perm_list)):
            tmp += v[j]
        tmp_list.append(tmp)
    tmp_list = list(set(tmp_list))
    
    n = len(tmp_list)
    for j in range(n):
        cnt = 0
        for k in range(N):
            if tmp_list[j][k] == "x":
                tmp_list[j] = tmp_list[j].replace("x", al[cnt], 1)
                cnt += 1
        ans_list.append(tmp_list[j])
ans_list.sort()
K = int(K)
for i in range(K):
    print(ans_list[i])

### FIXED CODE ###

# D
N = int(input())

al = [chr(ord('a') + i) for i in range(26)]

def dfs(S, i):
    if len(S) == N:
        yield ''.join(S)
        return
    for j in range(i):
        for w in dfs(S + [al[j]], i):
            yield w
    for w in dfs(S + [al[i]], i + 1):
        yield w

for w in dfs([], 0):
    print(w)
import sys
def main():
    input=sys.stdin.readline
    S=input()
    dp=[[0,0] for i in range(len(S)+1)]
    dp[0][1]=1
    for i in range(1,len(S)+1):
        for j in (0,1):
            if j==0:
                dp[i][0]=min(dp[i-1][0]+int(S[i-1]),dp[i-1][1]+10-int(S[i-1]))
            elif j==1:
                dp[i][1]=min(dp[i-1][0]+int(S[i-1])+1,dp[i-1][1]+10-int(S[i-1])-1)

    print(dp[len(S)][0])

if __name__=="__main__":
    main()

### FIXED CODE ###

import sys
def main():
    input=sys.stdin.readline
    S=input().strip()
    dp=[[0,0] for i in range(len(S)+1)]
    dp[0][1]=1
    for i in range(1,len(S)+1):
        for j in (0,1):
            if j==0:
                dp[i][0]=min(dp[i-1][0]+int(S[i-1]),dp[i-1][1]+10-int(S[i-1]))
            elif j==1:
                dp[i][1]=min(dp[i-1][0]+int(S[i-1])+1,dp[i-1][1]+10-int(S[i-1])-1)

    print(dp[len(S)][0])

if __name__=="__main__":
    main()
from bisect import bisect

def solve():
    N = int(input())
    A = sorted(map(int,input().split()))


    if A[0] >= 0:
        res = []
        x = A[0]
        for a in A[1:-1]:
            res.append((x,a))
            x -= a
        res.append((A[-1],x))
        x = A[-1]-x
        return (x,res)
    if A[-1] <= 0:
        res = []
        x = A[-1]
        for a in A[-1]:
            res.append((x,a))
            x -= a
        return (x,res)

    res = []
    p = bisect(A,0)-1
    x = A[p]
    for a in A[p+1:N-1]:
        res.append((x,a))
        x -= a
    res.append((A[-1],x))
    x = A[-1]-x
    for a in A[:p]:
        res.append((x,a))
        x -= a
    return (x,res)



s,res = solve()
print(s)
print('\n'.join(f'{a} {b}' for a,b in res))

### FIXED CODE ###

import bisect

N = int(input())
A = sorted(map(int,input().split()))

i = bisect.bisect_left(A, 0)
j = bisect.bisect_right(A, 0)
if i == j:
    if i == 0:
        negatives = A[:1]
        positives = A[1:]
    elif i == N:
        negatives = A[:-1]
        positives = A[-1:]
    else:
        negatives = A[:i]
        positives = A[i:]

else:
    m = max((i+j)//2, 1)
    negatives = A[:m]
    positives = A[m:]


score = sum(positives) - sum(negatives)
print(score)

def it():

    def balanced(pos, neg):
        y = neg.pop()
        x = pos.pop()
        yield (x,y)
        y = x-y
        while pos and neg:
            x = neg.pop()
            yield (x,y)
            y = x-y
            x = pos.pop()
            yield (x,y)
            y = x-y

    if len(positives) < len(negatives):

        x = positives.pop()

        while len(positives)+1 < len(negatives):
            y = negatives.pop()
            yield (x,y)
            x -= y
        positives.append(x)
    elif len(positives) > len(negatives):
        x = negatives.pop()

        while len(negatives)+1 < len(positives):
            y = positives.pop()
            yield (x,y)
            x -= y
        negatives.append(x)

    for x,y in balanced(positives, negatives):
        yield x,y


for x,y in it():
    print(x,y)
from collections import deque
import numpy as np

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    a = np.array([0])
    p = rec(a,A)

    for m in M:
        print "yes" if m in p else "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        a = np.append(a,a+A.popleft())
        return rec(a,A)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()
a,b=input().split()
print a-b if a-b>0 else 0

### FIXED CODE ###

a,b=map(int,input().split())
print(a-b if a-b>0 else 0)
strings = ["dream","dreamer","erase","eraser"]

def isDaydream(s):
    if s == "":
        return True
    for string in strings:
        if s.endswith(string):
            if(isDaydream(s[:len(string)*-1])):
                return True
    return False
if(isDaydream(input())):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

def isDaydream(s):
    while s != "":
        if s.endswith("dream"):
            s = s[:-5]
        elif s.endswith("dreamer"):
            s = s[:-7]
        elif s.endswith("erase"):
            s = s[:-5]
        elif s.endswith("eraser"):
            s = s[:-6]
        else :
            return False
    return True

if(isDaydream(input())):
    print("YES")
else:
    print("NO")
N=int(input())
 
A=list(map(int,input().split()))
#B=[]
#C=[]
D=[0]*1000000
E=[0]*1000000
 
ans=0
 
for i in range(N):
  if A[i]<1000000:
  #B.append(A[i]+i+1)
  #C.append(-A[i]+i+1)
  	D[A[i]+i]+=1
  	E[-A[i]+i]+=1
 
for i in range(1000000):
  #ans+=C.count(i)
  ans+=D[i]*E[i]
 
print(ans)

### FIXED CODE ###

N=int(input())
 
A=list(map(int,input().split()))
#B=[]
#C=[]
D=[0]*1000000
E=[0]*1000000
 
ans=0
 
for i in range(N):
  if A[i]<500000:
  #B.append(A[i]+i+1)
  #C.append(-A[i]+i+1)
  #if -A[i]+i>=0:
  	D[A[i]+i]+=1
  	E[-A[i]+i]+=1
   #print(E[-A[i]+i],-A[i]+i)

for i in range(1000000):
  #ans+=C.count(i)
  ans+=D[i]*E[i]
 
print(ans)
N, Q=map(int, input().split())
T=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  T[a-1].append(b-1)
  T[b-1].append(a-1)
P=[0]*N
ans=[0]*N
for i in range(Q):
  p,x=map(int, input().split())
  P[p-1]+=x

def dfs(start, pre_node, pre_val):
  now_val=(pre_val+P[start])
  ans[start]=now_val
  
  for next_node in T[start]:
    if next_node==pre_node:
      continue
    dfs(next_node, start,now_val)
    
dfs(0,-1,0)   
for a in ans:
  print(a, end=" ")

### FIXED CODE ###

from collections import deque 
N,Q=map(int, input().split())
G=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
X=[0]*N
for i in range(Q):
    p,x=map(int, input().split())
    X[p-1]+=x
que=deque([(0,-1)])
#print(que)
while que:
    now, pre=que.pop()
    for nex in G[now]:
        if nex==pre:
            continue
        else:
            X[nex]+=X[now]
            que.append((nex,now))

print(" ".join(map(str, X)))
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
for j in range(m):
  if a[0] >= a[1]:
    a[0] //= 2
  else:
    a[1] //= 2
  if max(a[0], a[1]) < a[2]:
    a.sort(reverse=True)
print(sum(a))

### FIXED CODE ###

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)

if n > 1:
    a.append(0)
    biggest = a[0]
    now = 0
    while m > 0:
        a[now] = a[now]//2
        m -= 1
        biggest = a[0]
        for i in range(n-1):
            if a[i+1] >= biggest and m > 0:
                a[i+1] = a[i+1]//2
                m -= 1
            else:
                a.sort(reverse=True)
                break
    else:
        quit

else:
  for j in range(m):
    a[0] //= 2

print(sum(a))
S = input()
K = "CODEFESTIVAL2016"
sum = 0
for i in range(len(S)):
  if S[i] != K[i]
  sum += 1
print(sum)

### FIXED CODE ###

S = input()
K = "CODEFESTIVAL2016"
sum = 0
for i in range(len(S)):
  if S[i] != K[i]:
    sum += 1
print(sum)
N, A, B = map(int , input().split())

L = []
i = 0
k = 0
j = 0
 
for k in range(10**100):
    for i in range(A):
        L.append('b')
        if len(L) >= N:
            L = L[0:N]
            print(L.count('b'))
            exit()
        elif A == 0:
            print(A)
            exit()
        elif A == 1:
            print(N // B)
            exit()
    
    for j in range(B):
        L.append('r')
        if len(L) >= N:
            L = L[0:N]
            print(L.count('b'))
            exit()
        elif B == 0:
            print(N)
            exit()

### FIXED CODE ###

N, A, B = map(int , input().split())
 
L = []
i = 0
k = 0
j = 0
P = N // (A + B)
Q = N % (A + B)

if A > Q:
    print((P * A) + Q)
else:
    print((P * A) + A)