Harryxun/stf_run huggingface dataset:
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().rsplit()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n, q = LI()
point = [0]*n
graph = [[] for i in range(n)]
visited = [False]*n


def dfs(n):
    visited[n-1] = True
    for node in graph[n-1]:
        if visited[node-1]:
            continue
        point[node-1] += point[n-1]
        dfs(node)


def main():

    for i in range(n - 1):
        a, b = LI()
        graph[a - 1].append(b)
        graph[b - 1].append(a)

    for i in range(q):
        p, x = LI()
        point[p - 1] += x

    dfs(1)

    print(*point)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
 
N, Q = map(int, input().split())
root = [[] for _ in range(N)]
ans = [0]*N
 
for _ in range(N-1):
  a,b=map(int, input().split())
  a,b=a-1,b-1
  root[a].append(b)
  root[b].append(a)

for _ in range(Q):
  p,x=map(int, input().split())
  ans[p-1]+=x
  
visited=[False]*N
def dfs(v):
  visited[v] = True
  for go in root[v]:
    if visited[go]:
      continue
    ans[go] += ans[v]
    dfs(go)

dfs(0)
print(*ans)
s = [input() for i in range(6)]
if s[4]-s[0]>s[5]:
  print(":(")
else:
  print("Yay!")
  

### 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(":(")
else:
  print("Yay!")
#A
#n = int(input())
#print(3*n**2)
#B
n, d = map(int, input().split())
canseerange = 2*d+1
if n % canseerange == 0:
    print(int(n/canseerange))
else:
    print(int(n/canseerange)+1
#C
#n = int(input())
#ans = 0
#most1 = 0
#most2 = 0
#ed = False
#for i in range(n):
#    t = int(input())
#    ed = False
#    if most1 <= t:
#        most2 = most1
#        most1 = t
#        ans = i
#        ed = True
#    elif most2 <= t and ed == False:
#        most2 = t
#for i in range(n):
#    if i==ans:print(most2)
#    else:print(most1)
#D


### FIXED CODE ###

#A
#n = int(input())
#print(3*n**2)
#B
n, d = map(int, input().split())
canseerange = 2*d+1
if n % canseerange == 0:
    print(int(n/canseerange))
else:
    print(int(n/canseerange)+1)
N=int(input())
from collections import defaultdict
dic=defaultdict(int)
import math
mod=1000000007
for _ in range(N):
    A,B=map(int,input().split())
    if A<0:
        A,B=-A,-B
    if A==0:
        if B==0:
            dic[(0,0)]+=1
        else:
            dic[(0,1)]+=1
    elif B==0:
        dic[(1,0)]+=1
    else:
        gcd=math.gcd(A,B)
        A,B=A//gcd,B//gcd
        dic[(A,B)]+=1

ans=1
N-=dic[(0,0)]
for k,v in dic.items():
    if k==(0,0) or k==(0,1):
        continue
    if k==(1,0):
        v_dash=dic[(0,1)]
        ans*=((pow(2,v,mod)-1)+(pow(2,v_dash,mod)-1)+1)
        ans%=mod
        N-=v+v_dash
        continue
    a,b=k
    if not (b,-a) in dic:
        continue
    v_dash=dic[(b,-a)]
    ans*=((pow(2,v,mod)-1)+(pow(2,v_dash,mod)-1)+1)
    ans%=mod
    N-=v+v_dash
ans*=pow(2,N,mod)
ans+=dic[(0,0)]-1
ans%=mod
print(ans)


### FIXED CODE ###

N=int(input())
from collections import defaultdict
dic=defaultdict(int)
dic[(0,0)]=dic[(0,1)]=0
import math
mod=1000000007
for _ in range(N):
    A,B=map(int,input().split())
    if A<0:
        A,B=-A,-B
    if A==0:
        if B==0:
            dic[(0,0)]+=1
        else:
            dic[(0,1)]+=1
    elif B==0:
        dic[(1,0)]+=1
    else:
        gcd=math.gcd(A,B)
        A,B=A//gcd,B//gcd
        dic[(A,B)]+=1

ans=1
N-=dic[(0,0)]
for k,v in dic.items():
    if k==(0,0) or k==(0,1):
        continue
    if k==(1,0):
        v_dash=dic[(0,1)]
        ans*=((pow(2,v,mod)-1)+(pow(2,v_dash,mod)-1)+1)
        ans%=mod
        N-=v+v_dash
        continue
    a,b=k
    if not (b,-a) in dic:
        continue
    v_dash=dic[(b,-a)]
    ans*=((pow(2,v,mod)-1)+(pow(2,v_dash,mod)-1)+1)
    ans%=mod
    N-=v+v_dash
ans*=pow(2,N,mod)
ans+=dic[(0,0)]-1
ans%=mod
print(ans)
def main():
    n = int(input())
    S = sorted([input() for s in range(n)])
    D = list(set(S))
    count = []*len(D)
    for i in range(len(D)):
        count[i] = S.count(D[i])
    maxi = max(count)
    for i in range(len(D)):
        if(count[i]==maxi):
            print(D[i])
main()

### FIXED CODE ###

def main():
    a = set(map(int,input().split()))
    if (len(a)==2):
        print("Yes")
    else:
        print("No")
main()
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N

for i in range(M):
  p,s=input().split()
  if s=="WA" and ac(int(p)-1)==0:
    wa[int(p)-1]+=1
  elif s=="AC" and ac(int(p)-1)==0:
    ac[int(p)-1]+=1

penalty=[w(k) for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" %())

### FIXED CODE ###

N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N

for i in range(M):
  p,s=input().split()
  if s=="WA" and ac[int(p)-1]==0:
    wa[int(p)-1]+=1
  elif s=="AC" and ac[int(p)-1]==0:
    ac[int(p)-1]+=1

penalty=[wa[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" % (sum(ac),sum(penalty)))
N, M = list(map(int, input().split()))
num_array = list(map(int, input().split()))

max_exp = 0
for i in range(len(num_array) - M + 1):
    tmp = sum(processed[i:i+M])
    if max_exp < tmp:
        max_exp = tmp

print((max_exp+1)*3/2) 

### FIXED CODE ###

import numpy as np

N, M = list(map(int, input().split()))
num_array = np.cumsum(list(map(lambda x: (x+1)/2, list(map(int, input().split())))))

max_exp = num_array[M-1]
for i in range(len(num_array)-M):
    tmp = num_array[i+M] - num_array[i]
    if max_exp < tmp:
        max_exp = tmp

print(max_exp)
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = solve(n, a)
    print(*ans)


def solve(n, a):
    m = 8
    colors = [0 for i in range(m + 1)]
    for i in range(n):
        for j in range(m):
            if a[i] < 400 * (j + 1):
                colors[j] += 1
                break
        else:
            colors[m] += 1
    usedcolors = sum([1 for i in colors[:m] if i > 0])
    ans = [max(1,usedcolors), min(usedcolors + colors[m])]

    return ans


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = solve(n, a)
    print(*ans)


def solve(n, a):
    m = 8
    colors = [0 for i in range(m + 1)]
    for i in range(n):
        for j in range(m):
            if a[i] < 400 * (j + 1):
                colors[j] += 1
                break
        else:
            colors[m] += 1
    usedcolors = sum([1 for i in colors[:m] if i > 0])
    ans = [max(1,usedcolors), usedcolors + colors[m]]

    return ans


if __name__ == '__main__':
    main()
import sys
from pprint import pprint

H, W = map(int, sys.stdin.readline().strip().split())

if H % 2 == 0 or W % 2 == 0:
    print(H * W // 2)
else:
    print((H * W // 2 + 1)

### FIXED CODE ###

import sys

H, W = map(int, sys.stdin.readline().strip().split())

if H == 1 or W == 1:
    print(1)
elif H % 2 == 0 or W % 2 == 0:
    print(H * W // 2)
else:
    print(H * W // 2 + 1)
n,m,q=map(int,input().split())
t=[list(map(int,input().split())) for _ in range(q)]
ans=0
import itertools
for p in itertools.permutations(range(1,m+1),m-n):
    a=[]
    for i in range(1,m+1):
        if i not in p:
            a+=[i]
    d=0
    for i in t:
        if a[i[1]-1]-a[i[0]-1]==i[2]:
            d+=i[3]
    ans=max(d,ans)        
print(ans) 

### FIXED CODE ###

n,m,q=map(int,input().split())
t=[list(map(int,input().split())) for _ in range(q)]
ans=0
import itertools
for p in itertools.combinations_with_replacement(range(1,m+1),n):
    d=0
    for i in t:
        if p[i[1]-1]-p[i[0]-1]==i[2]:
            d+=i[3]
    ans=max(d,ans)        
print(ans)
import pandas as pd
N, M = map(int,input().split())
A = pd.Series(list(map(int,input().split())))
if A[A >= A.sum()/(4*M)].count()>=M:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import numpy as np
N, M = map(int,input().split())
A = np.array(list(map(int,input().split())))
if len(A[A >= A.sum()/(4*M)])>=M:
    print('Yes')
else:
    print('No')
# -*- coding: utf-8 -*-

# input
S = input()
# S = "abcdefghijklmnopqrstuvwzyx"

s = list(S)
ss = []
for i in range(len(s)):
    ss.append(ord(s[i]))
a = list(ss)

t = [chr(i) for i in range(97, 97+26)]
tt = [i for i in range(97, 97+26)]
b = list(tt)


def func(s_):
    ss_ = []
    for i in range(len(s_)):
        ss_.append(chr(s_[i]))
    ss_ = ''.join(ss_)
    return ss_


# solve
if (len(ss) < 26):
    for i in range(len(s)):
        b.remove(ss[i])
    a.append(min(b))
    print(func(a))

if (len(ss) == 26):
    if (S == "zyxwvutsrqponmlkjihgfedcba"):
        print(-1)
    else:
        for i in range(len(s)):
            if (a[i] == b[i]):
                continue
            else:
                c = a[0:i] + [b[i]]
                break
        print(func(c))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect

# input
S = input()
# S = "abcdefghijklmnopqrstuvwzyx"
# S = "atcoder"
# S = "qpwoeirutyalskdjfhgzmxnvcb"

s = list(S)
a = []
for i in range(len(s)):
    a.append(ord(s[i]))

t = [chr(i) for i in range(97, 97+26)]
b = [i for i in range(97, 97+26)]


# function
def func(s_):
    ss_ = []
    for i in range(len(s_)):
        ss_.append(chr(s_[i]))
    ss_ = ''.join(ss_)
    return ss_


# solve
if (len(s) < 26):
    for i in range(len(s)):
        b.remove(a[i])
    a.append(min(b))
    print(func(a))

if (len(s) == 26):
    for i in reversed(range(len(s))):
        if (a[i] < a[i-1]):
            if (i == 1):
                print(-1)
                break
            else:
                continue
        else:
            c = a[0:i]
            d = a[i:len(a)]
            d = sorted(d)
            # a[i-1]よりも大きくて最も小さいものを探す
            num = c.pop()
            ind = bisect.bisect_left(d, num)
            c.append(d[ind])
            print(func(c))
            break
a=int(input())
b=a%100
c=a//100
if b<=c*11:
  print(c*111)
else:
  print()c+1)*111)

### FIXED CODE ###

a=int(input())
b=a%100
c=a//100
if b<=c*11:
  print(c*111)
else:
  print((c+1)*111)
N = int(input())
A = 10000 - N
a = str(A)
print(a[-3]+a[-2]+a[-1])

### FIXED CODE ###

N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)
import sys

l = []
for line in sys.stdin:
  l.append([int(i) for i in line.split()])

a, b, c = l
if b >= a * c:
  print(c)
else:
  print(b//a)
         

### FIXED CODE ###

import sys
 
l = []
for line in sys.stdin:
  l.append([int(i) for i in line.split()])
 
a, b, c = l[0]
if b >= a * c:
  print(c)
else:
  print(b//a)
def to_bin(number):
    return bin(number)[2:].zfill(45)


def xor(num1, num2):

    num1_str = to_bin(num1)
    num2_str = to_bin(num2)

    result = [0] * 45

    for digit in range(0, 45):
        result[digit] += int(num1_str[digit])
        result[digit] += int(num2_str[digit])

    result_str = ''

    for digit in result:

        if digit % 2 == 0:
            result_str += '0'
        else:
            result_str += '1'
    return int(result_str,2)


def f(a, b):
    return xor(g(a - 1), g(b))


def g(num):

    others = 0

    if num % 2 == 0:
        if (num // 2) % 2 != 0:
            others = 1

        return xor(num, others)
    else:
        if ((num - 1) // 2) % 2 != 0:
            others = 1

        return xor(xor(num, others), num - 1)


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

result = f(A, B)

print(result)


### FIXED CODE ###

def to_bin(number):

    return bin(number)[2:].zfill(45)


def xor(num1, num2):

    num1_str = to_bin(num1)
    num2_str = to_bin(num2)

    result_list = [0] * 45

    for digit in range(0, 45):
        result_list[digit] += int(num1_str[digit])
        result_list[digit] += int(num2_str[digit])

    result_str = ''

    for digit in result_list:

        if digit % 2 == 0:
            result_str += '0'
        else:
            result_str += '1'
    return int(result_str, 2)


def f(a, b):
    if a > 0:
        a -= 1

    return xor(g(a), g(b))


def g(num):

    others = 0

    if num % 2 == 0:
        if (num // 2) % 2 != 0:
            others = 1

        return xor(num, others)
    else:
        if ((num - 1) // 2) % 2 != 0:
            others = 1

        return xor(xor(num, others), num - 1)


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

result = f(A, B)

print(result)
def solution():
    n, m = map(int, input().split())
    cs = [list(map(int, input().split())) for i in range(m)]
    if m == 0:
        if n > 1:
            print("-1")
        else:
            print("0")
        return
    ans = [-1 for i in range(n)]
    for w in cs:
        s = w[0]
        c = w[1]
        if (s == 1) and (c == 0) and (n > 1):
            print('-1')
            return
        if ans[s-1] == -1:
            ans[s-1] = c
        elif ans[s-1] != c:
            print('-1')
            return
    ansb = [str(i) if i != -1 else str(0) for i in ans]
    if ansb[0] == '0':
        ansb[0] = '1'
    for s in ansb:
        anss = anss + s
    print(int(anss))

solution()


### FIXED CODE ###

def solution():
    n, m = map(int, input().split())
    cs = [list(map(int, input().split())) for i in range(m)]
    if m == 0:
        if n > 1:
            print(10**(n-1))
        else:
            print("0")
        return
    ans = [-1 for i in range(n)]
    for w in cs:
        s, c = w[0], w[1]
        if (s == 1) and (c == 0) and (n > 1):
            print('-1')
            return
        if ans[s-1] == -1:
            ans[s-1] = c
        elif ans[s-1] != c:
            print('-1')
            return
    ansb = [str(i) if i != -1 else str(0) for i in ans]
    if (ansb[0] == '0') and (len(ansb) > 1):
        ansb[0] = '1'
    anss = ''
    for s in ansb:
        anss = anss + s
    print(anss)

solution()
n=int(input())
a=list(map(int, input().split()))
 
ans=[0]*n
for i, a in enumerate(A):
    ans[a-1]=i+1
 
print(*ans)

### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))
 
ans=[0]*n
for i, a in enumerate(a):
    ans[a-1]=(i+1)
 
print(*ans)
n = int(input())
for i in range(n):
  if i = 2**a and 2**a < n and n < 2**(a+1):
    print(i)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(8):
  if 2**i <= n:
    ans=2**i
print(ans)
from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
al=0

def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
    
for bits in product((0,1),repeat=h+w):
  

### FIXED CODE ###

from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
clis=[]
al=0
k_score=0
def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  clis.append(tmp)
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
uu=product((0,1),repeat=h+w)
for bits in uu:
  idd=[]
  coll=[]
  for i in range(h):
    if bits[i]==1:idd.append(i)
  
  for i in range(w):
    if bits[i+h]==1:coll.append(i)
  
  s=al
  if not coll:
    for x in idd:s-=idxs[x]
  elif not idd:
    for y in coll:s-=cols[y]
  else:
    for x in idd:s-=idxs[x]
    for y in coll:s-=cols[y]
    for x in idd:
      for y in coll:
        s+=clis[x][y]
        
  if s==k:k_score+=1
    
print(k_score)
S = input()
K = int(input())
for i in S:
    if i != '1':
        print(i)
        break
    K -= 1
    if K == 0:
        print(1)
        break

### FIXED CODE ###

A, B = [ int(i) for i in input().split()]
print(A*B - A - B + 1)
n,m,k = map(int,input().split())
rks = [None] *n
fgraph = [list() for i in range(n)]
bgraph = [list() for i in range(n)]
cgraph = [list() for i in range(n)]
for i in range(m):
        a,b = map(int, input().split())
        fgraph[a-1].append(b)
        fgraph[b-1].append(a)
def dfs(graph,s,r):
    if rks[s] is None:
        rks[s] = r
    for i in range(len(graph[s])):
        if rks[graph[s][i]-1] is not None:
            continue
        dfs(graph, graph[s][i]-1,r)
c = -1
for i in range(n):
    if rks[i] is None:
        c += 1
        dfs(fgraph, i, c)
for i in range(k):
        c,d = map(int, input().split())
        if rks[c-1] == rks[d-1]:
            bgraph[d-1].append(c)
            bgraph[c-1].append(d)
for i in range(n):
        print(rks.count(rks[i]) - len(fgraph[i]) - len(bgraph[i]) - 1)

### FIXED CODE ###

n,m,k = map(int,input().split())
import sys
rks = [None] *n
sys.setrecursionlimit(10**9)
fgraph = [list() for i in range(n)]
bgraph = [list() for i in range(n)]
cgraph = [list() for i in range(n)]
g = [[]for i in range(n)]
for i in range(m):
        a,b = map(int, input().split())
        fgraph[a-1].append(b)
        fgraph[b-1].append(a)
def dfs(graph,s,r):
    if rks[s] is None:
        rks[s] = r
    for i in range(len(graph[s])):
        if rks[graph[s][i]-1] is not None:
            continue
        g[r].append(0)
        dfs(graph, graph[s][i]-1,r)
c = -1
for i in range(n):
    if rks[i] is None:
        c += 1
        dfs(fgraph, i, c)
for i in range(k):
        c,d = map(int, input().split())
        if rks[c-1] == rks[d-1]:
            bgraph[d-1].append(c)
            bgraph[c-1].append(d)
for i in range(n):
        print(len(g[rks[i]]) - len(fgraph[i]) - len(bgraph[i]) )
import math
from functools import reduce

N, X = map(int, input().split())
a = list(map(int, input().split()))
y = []

def gcd_list(num):
    return reduce(math.gcd, num)

for i in a:
    y.append(abs(X-i))

print(gcd_list(y))

### FIXED CODE ###

import fractions
from functools import reduce

N, X = map(int, input().split())
a = list(map(int, input().split()))
y = []

def gcd_list(num):
    return reduce(fractions.gcd, num)

for i in a:
    y.append(abs(X-i))

print(gcd_list(y))
n,q = input().split()
n = int(n)
q = int(q)
T = [0] * (n+1)
A = [0] * (n+1)
B = [0] * (n+1)
P = [0] * (q+1)
X = [0] * (q+1)
for i in range(1,n):
    A[i],B[i] = [int(j) for j in input().split()]
for i in range(1,q+1):
    P[i],X[i] = [int(j) for j in input().split()]

NIL = -1

class node:
    def __init__(self):
        self.value = 0
        self.child = []
        self.parent = NIL

def childadd(T,x):
    for i in range(len(T[x].child)):
        T[T[x].child[i]].value += T[x].value
        if T[T[x].child[i]].child != []:
            childadd(T,T[x].child[i])

for i in range(1,n+1):
    T[i] = node()

for i in range(1,n):
    T[A[i]].child.append(B[i])

for i in range(1,q+1):
    T[P[i]].value += X[i]

childadd(T,1)

for i in range(1,n+1):
    print(T[i].value,end = " ")


### FIXED CODE ###

from collections import deque

n,q = input().split()
n = int(n)
q = int(q)
T = [0] * (n+1)

to = [[] for i in range(n+1)]
cnt = [0] * (n)
for i in range(1,n):
    a,b = [int(j) for j in input().split()]
    to[a].append(b)
    to[b].append(a)
for i in range(1,q+1):
    P,X = [int(j) for j in input().split()]
    T[P] += X
NIL = -1

q =deque()
q.append((1,0,NIL))
while len(q)>0:
    p,x,prev = q.pop()
    x += T[p]
    cnt[p-1] = x
    for i in to[p]:
        if i != prev:
            q.append((i,x,p))
print(*cnt)
N = int(input())
A = map(int, input().split())
dif = 0
sum = 0

for i in range(N - 1):
  if A[i] > A[i +1]:
    dif = A[i] - A[i + 1]
    sum += dif
    A[i +1] = A[i + 1] + dif
    
  else:
    
print(sum)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
dif = 0
sum = 0

for i in range(N - 1):
  if A[i] > A[i + 1]:
    dif = A[i] - A[i + 1]
    sum += dif
    A[i +1] = A[i + 1] + dif
    
print(sum)
s = input()
n = int(input())

for i in range(n):
    command = input().split()
    if command[0] == 'replace':
        a,b = map(int,command[1:3])
        s = s[:a]+ command[3] + s[b+1:]
    elif command[0] == 'reverse':
        a,b = map(int,command[1:3])
        s[a:b] = s[b:a]
    elif command[0] == 'print':  
        a,b = map(int,command[1:3])
        print(s[a:b+1])


### FIXED CODE ###

s = input()
n = int(input())

for i in range(n):
    command = input().split()
    if command[0] == 'replace':
        a,b = map(int,command[1:3])
        s = s[:a]+ command[3] + s[b+1:]
    elif command[0] == 'reverse':
        a,b = map(int,command[1:3])
        s = s[0:a] + s[a:b+1][::-1] + s[b+1:]
    elif command[0] == 'print':  
        a,b = map(int,command[1:3])
        print(s[a:b+1])
n,k = int(imput().split()) 
a = list(map(int,imput().split()))
b = 0
for c in a:
    if c>=k:
        b = b+1
print(b)


### FIXED CODE ###

n,k = input().split() 
k = int(k)
a = list(map(int,input().split()))
b = 0
for c in a:
    if c>=k:
        b = b+1
print(b)
N = input().rsplit().split('')
N1 = N[0]
N2 = N[1]

if N1 >=10 or N2 >= 10:
  print(-1)
  
else:
  print(N1 * N2)

### FIXED CODE ###

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

if a >= 10:
    print(-1)
elif b >= 10:
    print(-1)
else:
    print(a*b)
import sys
#input = sys.stdin.readlines

list={"A":"T","T":"A","G":"C","C":"G"}
b = sys.stdin.readlines()
print(list[b])

### FIXED CODE ###

#import sys
#input = sys.stdin.readline

list={"A":"T","T":"A","G":"C","C":"G"}
b = input()
print(list[b])
import sys
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, csgraph_from_dense

input = sys.stdin.readline


def main():
    N = int(input())
    edge = [[0] * N for j in range(N)]
    for _ in range(N - 1):
        a, b, c = [int(x) for x in input().split()]
        edge[a - 1][b - 1] = c
        edge[b - 1][a - 1] = c

    G = csgraph_from_dense(edge, null_value=0)
    d = floyd_warshall(G)

    Q, K = [int(x) for x in input().split()]
    for _ in range(Q):
        x, y = [int(x) for x in input().split()]
        print(int(d[x - 1][K - 1] + d[K - 1][y - 1]))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

input = sys.stdin.readline

d = []
ABC = []

sys.setrecursionlimit(10 ** 8)


def solve(i, dis):
    global d
    global ABC
    d[i] = dis

    for n, c in ABC[i]:
        if d[n] == -1:
            solve(n, dis + c)


def main():
    N = int(input())
    global ABC
    ABC = [[] for _ in range(N + 1)]
    global d
    d = [-1] * (N + 2)
    for _ in range(N - 1):
        a, b, c = [int(x) for x in input().split()]
        ABC[a - 1].append([b - 1, c])
        ABC[b - 1].append([a - 1, c])

    Q, K = [int(x) for x in input().split()]

    solve(K - 1, 0)

    for _ in range(Q):
        x, y = [int(x) for x in input().split()]
        print(d[x - 1] + d[y - 1])


if __name__ == '__main__':
    main()
Copy
a,b,c,k = map(int,input().split())
 
ans = 0
 
if k <= a:
  ans = a
  print(ans)
elif a< k <= a+b:
  ans = a
  print(ans)
else:
  ans = a-(K-a-b)
  if ans < 0:
    ans = 0
  print(ans)

### FIXED CODE ###

a,b,c,k = map(int,input().split())
 
ans = 0
 
if 0< k <= a:
  ans = k
  print(ans)
elif a+1 <= k <= a+b:
  ans = a
  print(ans)
else:
  ans = a-(k-a-b)
  print(ans)
n = int(input()) 
row = map(int, input().split())
max = row[0]
min = 0

for i in range(n-1):
    if(row[i] < row[i+1]):
        max = row[i+1]

for i in range(n-1):
    if(row[i] > row[i+1]):
        min = row[i+1]

print(max-min)
    




### FIXED CODE ###

n = int(input())

if (n%2 == 0):
    print(n)
else:
    print(2*n)