Harryxun/stf_run huggingface dataset:
n,m = map(int,input().split())
up = [input().split() for i in range(m)]

wa,ac = 0,0
if m==0:
    print(0,0)
else:
    k = [[] for i in range(2)]
    f=0
    temp=up[0]
    for t in up:
        if not temp[0]==t[0]:
            f+=1
        k[f].append(t)
        temp=t
    temp = False
    for qrs in k:
        for qr in qrs:
            if qr[1] == "WA":
                wa+=1
            elif qr[1] == "AC" and not temp:
                ac+=1
                break
    print(ac,wa)


### FIXED CODE ###

n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if d[p][1]:
      pass
    else:
      if s=="WA":
          d[p][0]+=1
      elif s=="AC":
          d[p][1]=True
          ac+=1
          wa+=d[p][0]
  else:
    if s=="WA":
      d[p]=[1,False]
    elif s=="AC":
      d[p]=[0,True]
      ac+=1
print(ac,wa)
N,K = map(int, input().split())
List = list(map(int, input().split()))

a=[]

for i in range(N):
    a.append(-1)
#print(a)
b=1
for i in range(N):
    if a[b-1]==-1:
        a[b-1]=i+1
        b=List[b-1]
        
    else:
        c=i
        break
#print(a)
#print(b,c)

num=a[b-1]-1
T=c-num
#print(T)
e=1
if K<num:
    for i in range(K):
        e=List(e-1)
    print(e)
else:
    qw=(K-num)%T
    List_new=[]
    for i in range(T):
        List_new.append(b)
        b=List[b-1]
    print(List_new[qw])

### FIXED CODE ###

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

a=[]

for i in range(N):
    a.append(-1)
#print(a)
b=1
for i in range(N):
    if a[b-1]==-1:
        a[b-1]=i+1
        b=List[b-1]
        
    else:
        c=i
        break
#print(a)
#print(b,c)

num=a[b-1]-1
T=c-num
#print(T)
e=1
if K<num:
    for i in range(K):
        e=List[e-1]
    print(e)
else:
    qw=(K-num)%T
    List_new=[]
    for i in range(T):
        List_new.append(b)
        b=List[b-1]
    print(List_new[qw])
N=int(input())
a=[0]*N
maxim=[0]*N
for i in range(N):
    a[i]=int(input())
maxim=sorted(list(a), reverse=True)
for k in range(N):
    if a[k]!=maxim[0]:
        print(maxim[0])
    else:
        print(maxim[1])

### FIXED CODE ###

r=int(input())
print(r*r*3)
#!/usr/bin/env python3
import sys
import numpy as np


def solve(X: int, N: int, p: "List[int]"):
    ii = [i for i in range(-101,101)]
    iii = sorted(list(set(ii) - set(p)))
    idx = np.searchsorted(iii, X, side='left')
    #print(iii)
    if idx>0:
        if iii[idx]-X >= X-iii[idx-1]:
            print(iii[idx-1])
        else:
            print(iii[idx])
    else:
        print(iii[idx])
    return


# Generated by 1.1.7.1 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()
    X = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(X, N, p)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np


def solve(X: int, N: int, p: "List[int]"):
    ii = [i for i in range(-10,110)]
    iii = sorted(list(set(ii) - set(p)))
    idx = np.abs(np.asarray(iii) - X).argmin()
    print(iii[idx])
    return


# Generated by 1.1.7.1 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()
    X = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(X, N, p)

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

N,*datas = [int(i) for i in stdin.readlines()]
now_max = max(datas[1:])
max_index = (N-1) - datas[::-1].index(now_max)
now_min = min(datas)
min_index = datas.index(_min)

if max_index > min_index:
    diff = now_max - _min
else:
    diff = now_max - datas[0]
    
    for i in range(1,N-1):
        if i == max_index:
            now_max = max(datas[i+1:])
            max_index = datas.index(now_max,i+1)
        new_diff = now_max - datas[i]
        if diff < new_diff:
            diff = new_diff

print(diff)


### FIXED CODE ###

from sys import stdin

N,*datas = [int(i) for i in stdin.readlines()]
now_max = max(datas[1:])
max_index = datas.index(now_max)
diff = now_max - datas[0]

for i in range(1,N-1):
    if i == max_index:
        now_max = max(datas[i+1:])
        max_index = datas.index(now_max,i+1)
    new_diff = now_max - datas[i]
    if diff < new_diff:
        diff = new_diff

print(diff)
a1,a2,a4=0,0,0

for i in range(1):
    # Start Input code ---------------------------------------
    n=int(input())
    for i in range(n):
        x=int(input())
        if x%4==0:
            a4+=1
        elif x%2==0:
            a2=1
        else:
            a1+=1
ans='Yes' if a1+a2<=a4+1 else 'No'
print(ans)


### FIXED CODE ###

a1,a2,a4=0,0,0

for i in range(1):
    # Start Input code ---------------------------------------
    n=int(input())
    y=map(int,input().split())
    for x in y:
        
        if x%4==0:
            a4+=1
        elif x%2==0:
            a2=1
        else:
            a1+=1
ans='Yes' if a1+a2<=a4+1 else 'No'
print(ans)
n=input()
for i in range(3):
  if n[i]=='1':
    n[i]='9'
  if n[i]=='9':
    n[i]='1'
print(n)

### FIXED CODE ###

n=list(input())
for i in range(3):
  if n[i]=='1':
    n[i]='9'
  elif n[i]=='9':
    n[i]='1'
ans=''
for i in range(3):
  ans+=n[i]
print(ans)
K,X = [map(int,input().split())]
if K*500>=X:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

K,X = map(int,input().split())
if K*500>=X:
    print("Yes")
else:
    print("No")
import sys

if __name__ == '__main__':
  
  x, a = sys.argv[1].split(' ')
  if (x < a):
    printf('0')
  else:
    printf('10')

### FIXED CODE ###

import sys                                                                      
 
if __name__ == '__main__':
    s = input().strip().split(' ')
    x = int(s[0])
    a = int(s[1])
    if (x < a): 
        print('0')
    else:
        print('10')
a, b, c = map(int,input().split())
if a == 7:
 if b == c and c ==5:
  print("YES")
 else:
  print("NO")
elif a == 5:
 if b ==7 and c == 5:
  print("YES")
 ellif b == 5 and c ==7:
  print("YES")
 else:
  print("NO")
else:
 print("NO")

### FIXED CODE ###

ABC = list(map(int,input().split()))
ABC.sort()
if ABC[0] == 5 and ABC[1] == 5 and ABC[2] == 7:
 print("YES")
else:
 print("NO")
ilne = input().split(' ')
print(int(line[0])*((int(line[0])-1)**(int(line[1])-1))

### FIXED CODE ###

line = input().split(' ')
print(int(line[1])*((int(line[1])-1)**(int(line[0])-1)))
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(w)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][i] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(h)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][j] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

#nCrの計算。nこの中から、r個を取り出す。
import import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

#読み込みの高速化
input = sys.stdin.readline

#nCrの計算。nこの中から、r個を取り出す。
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


n = int(input())
a = list(map(int,input().split()))

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

c = [0]*(n+1)
c = copy.copy(b)
c = list(set(c))
#print(c)

ans = 0

for i in c:
	#print(i)
	chk = b.count(i)
	#print(chk)
	if chk >= 2:
		ans = ans + combinations_count(chk,2)

print(ans)



def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


n = int(input())
a = list(map(int,input().split()))

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

c = [0]*(n+1)
c = copy.copy(b)
c = list(set(c))
#print(c)

ans = 0

for i in c:
	#print(i)
	chk = b.count(i)
	#print(chk)
	if chk >= 2:
		ans = ans + combinations_count(chk,2)

print(ans)




### FIXED CODE ###

import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)


#nCrの計算。nこの中から、r個を取り出す。
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


n = int(input())
a = list(map(int,input().split()))

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

#c = [0]*(n+1)
#c = copy.copy(b)
#c = list(set(c))
#print(c)

import collections
c = collections.Counter(b)
#print(c)
#print(c.values())

ans = 0

for i in c.values():
	#print(i)
	#chk = b.count(i)

	#print(chk)
	if i >= 2:
		ans = ans + i*(i-1)//2

print(ans)
print("{}:{}:{}".format(input()/60, input()/3600, input()%3600)

### FIXED CODE ###

i = int(input())
print("{}:{}:{}".format(int(i/(60*60)), int((i%(60*60))/(60)), i%60))
#coding=UTF-8

def search(jun):
    global ans
    global R
    global Kost
    tmpans=0
    if len(jun)==R:
        mae=jun[0]
        for idx in range(1,R,1):
            ba=jun[idx]
            tmpans += Kost[r[mae]][r[ba]]
            mae=ba

        if ans==None or tmpans<ans:
            ans=tmpans
    else:
        for me in range(0,R,1):
            if not (me in jun):
                search(jun+[me])

mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
M=int(hyo[1])
R=int(hyo[2])

mozir=input()
hyo=mozir.split(' ')
r=[(int(mono)-1) for mono in hyo]

Kost=[]
for idx in range(0,N,1):
    Kost.append([None]*N)

for idx in range(0,N,1):
    Kost[idx][idx]=0


for idx in range(0,M,1):
    mozir=input()
    hyo=mozir.split(' ')
    A=int(hyo[0])-1
    B=int(hyo[1])-1
    C=int(hyo[2])

    Kost[A][B]=C
    Kost[B][A]=C

changed=True
while changed:
    changed=False
    for idx in range(0,N,1):
        for idt in range(0,N,1):
            if bool(Kost[idx][idt]) == False:
                continue
            else:
                zen=Kost[idx][idt]
                for idy in range(0,N,1):
                    tmpKost=zen+Kost[idt][idy]
                    if Kost[idx][idy]==None or Kost[idx][idy]>tmpKost:
                        Kost[idx][idy]=tmpKost
                        changed=True

#for gyo in Kost:
#    print(gyo)

ans=None
search([])
print(ans)


### FIXED CODE ###

#coding=UTF-8

def search(jun):
    global ans
    global R
    global r
    global rCost
    tmpans=0
    if len(jun)==R:
        mae=jun[0]
        for idx in range(1,R,1):
            ba=jun[idx]
            tmpans += rCost[mae][r[ba]]
            mae=ba

        if ans==None or tmpans<ans:
            ans=tmpans
    else:
        for me in range(0,R,1):
            if not (me in jun):
                search(jun+[me])


mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
M=int(hyo[1])
R=int(hyo[2])

mozir=input()
hyo=mozir.split(' ')
r=[(int(mono) -1 ) for mono in hyo]

michi=[]
for idx in range(0,N,1):
    michi.append([])

for idx in range(0,M,1):
    mozir=input()
    hyo=mozir.split(' ')
    A=int(hyo[0])-1
    B=int(hyo[1])-1
    C=int(hyo[2])
    michi[A].append((B,C))
    michi[B].append((A,C))


rCost=[]
for idr in range(0,R,1):
    Cost=[None]*N
    Cost[r[idr]]=0
    miru=[r[idr]]
    while miru:
        nextmiru=[]
        for toshi in miru:
            preCost=Cost[toshi]
            for (saki,sakiCost) in michi[toshi]:
                tmpCost=preCost+sakiCost
                if Cost[saki]==None or tmpCost < Cost[saki]:
                    Cost[saki]=tmpCost
                    nextmiru.append(saki)

        miru=list(set(nextmiru))
    rCost.append(Cost)

#for ko in rCost:
#    print(ko)

ans=None
search([])
print(ans)
def func(n):
  if n==1:return 1
  if n==0:return 1
  if dp[n]!=-1:return dp[n]
  f1=func(n-1) if n-1 not in a else 0
  f2=func(n-2) if n-2 not in a else 0
  tmp=(f1+f2)%1000000007
  dp[n]=tmp
  return tmp
import sys
sys.setrecursionlimit(1002)
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[-1]*(n+1)
print(func(n)%1000000007)

### FIXED CODE ###

def func(n):
  if n==1:return 1
  if n==0:return 1
  if dp[n]!=-1:return dp[n]
  f1=func(n-1) if n-1 not in a else 0
  f2=func(n-2) if n-2 not in a else 0
  tmp=(f1+f2)%1000000007
  dp[n]=tmp
  return tmp
import sys
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
a={int(input()) for i in range(m)}
dp=[-1]*(n+1)
print(func(n)%1000000007)
n,k=map(int,input().split())
s=input()
from collections import deque
l=deque()
c=1
for i in range(1,n):
    if s[i]!=s[i-1]:
        l.append([s[i-1],c])
        c=1
    else:
        c+=1
l.append([s[-1],c])
if l[0][0]=="1":
    a,c=l.popleft()
    l[0][1]+=c
if l[-1][0]=="1":
    a,c=l.pop()
    l[-1][1]+=c

ll=[]
for i in range(len(l)):
    ll.append(l[i][1])

ans=0
for i in range(len(ll)-2*k+1):
    ans=max(ans,sum(ll[i:i+2*k]))
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
s=input()
wa=[]
now=1
cnt=0
for i in range(n):
    if s[i]==str(0+now):
        cnt+=1
    else:
        wa.append(cnt)
        now=1-now
        cnt=1
if cnt!=0:
    wa.append(cnt)

if len(wa)%2==0:
    wa.append(0)

add=2*k+1
ans=0

left=0
right=0
tmp=0
for i in range(0,len(wa),2):
    nextleft=i
    nextright=min(i+add, len(wa))

    while nextleft > left:
        tmp-=wa[left]
        left+=1
    while nextright > right:
        tmp+=wa[right]
        right+=1

    ans=max(tmp,ans)
print(ans)
a,b = map(int,input().split())
if a%2=0:print("Even")
  elif b%2=0:print("Even")
    elif print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
if (a)%2 == 0:
  print("Even")
elif (b)%2 == 0:
	print("Even")
else:
  print("Odd")
def answer(n, m, taro, hanako):
    for t in sorted(taro):
        fot h in (hanako):
            if sum(taro) - t + h == sum(hanako) - h + t:
                return f'{t} {h}'
    return -1
    
    
while True:
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        break
    taro = []
    hanako = []
    for i in range(n):
        taro.append(int(input()))
    for i in range(m):
        hanako.append(int(input()))
    print(answer(n, m, taro, hanako))




### FIXED CODE ###

def answer(n, m, taro, hanako):
    for t in sorted(taro):
        for h in sorted(hanako):
            if sum(taro) - t + h == sum(hanako) - h + t:
                return f'{t} {h}'
    return -1


while True:
    n, m = map(int, input().split()) # 組み込み関数input()は標準入力から読み込まれた1行を返す．
    if n == 0 and m == 0:
        break
    taro = []
    hanako = []
    for i in range(n):
        taro.append(int(input()))
    for i in range(m):
        hanako.append(int(input()))
    print(answer(n, m, taro, hanako))
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


    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)


### 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()
H = int(input())
cnt = H
B = [H]

if H == 1:
    ans == 10000000001
else:
    for i in range(100000000000):
        cnt = cnt//2
        B.append(cnt)
        if cnt == 1:
            break

C =[1]
for i in range(1,1001):
    C.append(C[i-1]*2)

if ans == 10000000001:
    print('0')
else:
    ans= 0
    for i in range(len(B)):
        ans +=C[i]
print(ans)

### FIXED CODE ###

H = int(input())
cnt = H
ans = 0
B = [H]

if H == 1:
    ans == 'NA'
else:
    for i in range(100000000000):
        cnt = cnt//2
        B.append(cnt)
        if cnt == 1:
            break

C =[1]
for i in range(1,1001):
    C.append(C[i-1]*2)

if ans == 'NA':
    print('0')
else:
    for i in range(len(B)):
        ans +=C[i]
print(ans)
import math

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

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

print(lcm(a, b))

### FIXED CODE ###

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

print(int(A*B/fractions.gcd(A,B)))
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for _ in range(n):
    a = list(map(int, input().split()))
    if a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + c > 0:
        ans += 1
print(ans)


### FIXED CODE ###

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for ai in a:
    absum = 0
    for i in range(m):
        absum += ai[i] * b[i]
    if absum + c > 0:
        ans += 1
print(ans)
n, k, q = list(input())
alist = [int(input()) for i in range(n)]

for i in range(1, n + 1):
    if n - alist.count(i) >= k:
        print('No')
    else:
        print('Yes')


### FIXED CODE ###

n, k, q = map(int, input().split())
alist = [int(input()) for i in range(q)]
ans = [k - q] * n

for Ai in alist:
    ans[Ai - 1] += 1

for Ai in ans:
    print('Yes') if Ai > 0 else print('No')
N, X, M = map(int, input().split())
if X == 0:
    print(0)
    exit()
if X == 1:
    print(N)
    exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
    A = (A**2)%M
    if check[A] != 0:
        last_count = sum(check)
        target_value = A
        break
    check[A] += 1
A2 = X
first_count = 0
while True:
    first_count += 1
    A2 = (A2**2)%M
    if A2 == target_value:
        break

roop_count = last_count-first_count
A3 = target_value
mass = A3
for i in range(roop_count-1):
    A3 = (A3**2)%M
    mass += A3
if roop_count == 0:
    pass

ans = X
A = X
for i in range(min(N,first_count)-1):
    A = (A**2)%M
    ans += A
if N > first_count:
    ans += ((N-first_count)//roop_count)*mass
    A4 = target_value
    if (N-first_count)%roop_count >= 1:
        ans += A4
    for i in range(((N-first_count)%roop_count)-1):
        A4 = (A4**2)%M
        ans += A4

print(ans)

### FIXED CODE ###

N, X, M = map(int, input().split())
if X <= 1:
    print(X*N)
    exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
    A = (A**2)%M
    if check[A] != 0:
        last_count = sum(check)
        target_value = A
        break
    check[A] += 1
A2 = X
first_count = 0
while A2 != target_value:
    first_count += 1
    A2 = (A2**2)%M

roop_count = last_count-first_count

A3 = target_value
mass = A3
for i in range(roop_count-1):
    A3 = (A3**2)%M
    mass += A3
if roop_count == 0:
    print(N*X)
    exit()
if first_count != 0:
    ans = X
    A = X
    for i in range(min(N,first_count)-1):
        A = (A**2)%M
        ans += A
else:
    ans = 0
if N > first_count:
    ans += ((N-first_count)//roop_count)*mass
    A4 = target_value
    if (N-first_count)%roop_count >= 1:
        ans += A4
    for i in range(((N-first_count)%roop_count)-1):
        A4 = (A4**2)%M
        ans += A4
print(ans)
import math

K = input()
distance = list(map(int,input().split()))

for i in range(distance[1]-distance[0]+1):
    if (distance[0]+i) % K == 0:
        print("OK")

print("NG")


### FIXED CODE ###

import math
import sys

K = int(input())
distance = list(map(int,input().split()))


for i in range(distance[1]-distance[0]+1):
    if (distance[0]+i) % K == 0:
        print("OK")
        sys.exit()

print("NG")
n = input()
digit = n % 10
if(digit == 3)
  print "bon"
elif(digit == 0 and digit == 1 and digit == 6 and digit == 8)
  print "pon"
else:
  print "hon"


### FIXED CODE ###

ninput = input() #これはstr型
n = int(ninput) #これでint型に直す
digit = n % 10
if digit == 3:
  print('bon')
elif digit == 0 or digit == 1 or digit == 6 or digit == 8:
  print('pon')
else:
  print('hon')
N = int(input())
S = 0
n = N

while n != 1:
  S += n % 10
  n //= 10
  
if N % S == 0:
  print("Yes")
else: print("No")


### FIXED CODE ###

N = int(input())
S = 0
n = N

while n != 0:
  S += n % 10
  n //= 10
  
if N % S == 0:
  print("Yes")
else: print("No")
import math
 
a,b,n = map(int,input().split())
 
ans = 0
pre = 0
for i in range(1, n+1):
  now = math.floor(a*i / b) - a * math.floor(i / b)
  if now > pre:
    ans = i
    pre = now
  elif not now == 0:
    break
    
print(pre)

### FIXED CODE ###

k = int(input())
 
a, b = map(int, input().split())
ngcounter = 0
for i in range(a, b+1):
  if i % k == 0:
    break
  else:
    ngcounter += 1
    
if ngcounter == b - a + 1:
  print("NG")
else :
  print("OK")