Harryxun/stf_run huggingface dataset:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    x = [int(i) for i in input().split()]
    a = x[0] // x[2]
    b = x[1] // x[1]
    
    print(b-a)

### FIXED CODE ###

import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    x = [int(i) for i in input().split()]
    a = (x[0]-1) // x[2]
    b = x[1] // x[2]

    print(b-a)
s = input()
t = input()
if len(t - s) == 1:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

s = input()
t = input()

same = 0
for i in range(len(s)):
	if s[i] == t[i]:
		same += 1

if same == len(s) and len(t) - len(s) == 1:
	print("Yes")

else:
	print("No")
A = int(input())
B = int(input())

if (A == 1 and B == 2) or (A == 2 and B == 1):
    print(3)
elif (A == 1 and B == 3) or (A == 3 and B == 1):
    print(2)
elif (A == 2 and B == 3) or (A == 3) and B == 2):
    print(1)

### FIXED CODE ###

A = int(input())
B = int(input())

if (A == 1 and B == 2) or (A == 2 and B == 1):
    print(3)
elif (A == 1 and B == 3) or (A == 3 and B == 1):
    print(2)
elif (A == 2 and B == 3) or (A == 3 and B == 2):
    print(1)
def fill0(s,x,y):
	if 0 <= x <= W-1 and 0 <= y <= H-1 and A[y][x] == s:
		A[y][x] = 0
		fill0(s,x+1,y); fill0(s,x,y+1); fill0(s,x-1,y); fill0(s,x,y-1)

while 1:
	H,W = map(int,raw_input().split())
	if H == 0: break
	A = [list(raw_input()) for i in range(H)]
	ans = 0
	for y in range(H):
		for x in range(W):
			if A[y][x] in ["#","@","*"]:
				fill0(A[y][x],x,y)
				ans += 1
	print ans

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)
def solve(h,w,count,c):
    if 0 <= h < H and 0 <= w < W and A[h][w] == c:
        A[h][w] = count
        for dh,dw in zip([1,0,-1,0],[0,1,0,-1]):
            solve(h+dh,w+dw,count,c)
while 1:
    H,W = map(int,raw_input().split())
    if H == W == 0: break
    A = [list(raw_input()) for _ in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if type(A[h][w]) is not int:
                solve(h,w,count,A[h][w])
                count += 1
    print count
import collections

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

c = collections.Counter(a)
d = list(c.keys())
e = list(c.values())

if n == 1:
    print(1)
    exit()
elif n == 2:
    if a[0] == a[1] or abs(a[0] - a[1]) == 1:
        print(2)
        exit()
    else:
        print(1)
        exit()
elif len(d) == 1:
    print(e[0])
    exit()
elif len(d) == 2:
    if d[0] == d[1] or abs(d[0] - d[1]) == 1:
        print(e[0] + e[1])
        exit()
    else:
        print(max(e[0], e[1]))


for i in range(n-2):
    if abs(d[i] - d[i+1]) == 1 and abs(d[i] - d[i+2]) == 2:
        num = e[i] + e[i+1] + e[i+2]
    elif abs(d[i] -d[i+1]) == 1:
        num = e[i] + e[i+1]
    else:
        num = e[i]
    if num > ans:
        ans = num

if d[-2] == d[-1] or abs(d[-2] - d[-1]) == 1:
    num = e[-2] + e[-1]
else:
    num = max(e[-2], e[-1])

if num > ans:
    ans = num

print(ans)

### FIXED CODE ###

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

t = max(a)
num_list = [0] * (t + 2)

for i in range(n):
    num_list[a[i]] += 1
    if a[i] == 0:
        continue
    else:
        num_list[a[i]-1] += 1
    if a[i] == t:
        continue
    else:
        num_list[a[i]+1] += 1

print(max(num_list))
A, B = map(int, input().sprit())
print(A*B,2*(A+B))


### FIXED CODE ###

number = int(input())
print(number**3)
import itertools

n, a, b = map(int, input().split())
if n < 2 and a != b:
    print(0)
elif n == 1:
    print(1)
else:
    c = set()
    for i in itertools.combinations_with_replacement(range(a, b + 1), n - 2):
        c.add(sum(i))
    print(len(c))

### FIXED CODE ###

n, a, b = map(int, input().split())
print(max(b - a + 1 + (b - a) * (n - 3), 0))
import collections
import numpy as np

N = int(input())

xy = []
for _ in range(N):
    xy.append(list(map(int, input().split())))

xy = np.array(xy)

diff_xy = []

for i in range(N-1):
    for j in range(i+1, N):
        diff_xy.append(list(xy[j] - xy[i]))

cs = []
for c in diff_xy:
    cs.append(diff_xy.count(c))
    
print(1 + (N - (max(cs) + 1)))

### FIXED CODE ###

import collections
import numpy as np

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

xy = np.array(xy)

dic_xy = {}

for i in range(N):
    for j in range(N):
        if i != j:
            diff_xy = xy[i] - xy[j]
            diff_xy = tuple(diff_xy)
            
            if dic_xy.get(diff_xy) is None:
                dic_xy[diff_xy] = 1
            else:
                dic_xy[diff_xy] += 1

max_diff = 0
for x in dic_xy:
    max_diff = max(max_diff, dic_xy[x])
    
print(N - max_diff)
s = int(input())
f = []
i = 0
n = s
while(i<1000000):
  if n % 2 == 0:
    f.append(n/2)
  else:
    f.append(3*n+1)
  n = f[i]
  i = i + 1
f_ = list(dict.fromkeys(f))
f.pop(f.index(f_[0]))
print(f.index(f_[0])+1)

### FIXED CODE ###

s = int(input())
f = []
n = s
while(1):
  f.append(n)
  if n % 2 == 0:
    n = int(n/2)
  else:
    n = 3*n+1
  
  if n in f:
    break
    
print(len(f)+1)
a*b = c
if c / 2 == 0:
  print(Even)
else:
  print(Odd)

### FIXED CODE ###

a,b = map(int, input(). split())
if (a*b) % 2 == 0 :
  print("Even")
else:
  print('Odd')
a,b,c,d=map(int,input().split())
if a+b > c+d:
print("Left")
elif a+b == c+d:
print("Balanced")
elif a+b < c+d:
print("Right")


### FIXED CODE ###

a,b,c,d=map(int,input().split())
if a+b > c+d:
    print("Left")
elif a+b == c+d:
    print("Balanced")
else:
    print("Right")
50 100 120

### FIXED CODE ###

a, b, c = map(int, input().split())
if a + b >= c:
    print("Yes")
else:
    print("No")
def f(n,s,x):
  if n == s == 0:
    return 1
  elif n == 0 or x == 0:
    return 0
  else:
    a = 0
    for i in range(x):
      a += f(n-1,s-i,i)
    return a
while True:
  n,s = map(int,raw_input().split())
  if n == s == 0:
    break
  print(f(n,s,10))

### FIXED CODE ###

def f(n,s,x):
  if n == s == 0:
    return 1
  elif n == 0 or x == 0:
    return 0
  else:
    a = 0
    for i in range(x):
      a += f(n-1,s-i,i)
    return a
while True:
  n,s = map(int,input().split())
  if n == s == 0:
    break
  print(f(n,s,10))
S=list(input())
count=0

if  s='o':
  count+=1

print(count*100+700)

### FIXED CODE ###

S=list(input())
count=0

if S[0]=='o':
  count+=1
if S[1]=='o':
  count+=1
if S[2]=='o':
  count+=1
  
print(count*100+700)
N, M = map(int, input().split())
A = list(map(int, input().split()))
rewritelist = []
for i in range(0, M):
	rewritelist.append(map(int, input().split()))
A.sort()
rewritelist.sort(key = lambda val: val[1], reverse = True)
cardlist = []
for i in range(0, N):
	if rewritelist == []: break
	cardlist.append(rewritelist[0][1])
	rewritelist[0][0] -= 1
	if rewritelist[0][0] == 0: rewritelist.pop(0)
for i in range(0, len(cardlist)):
	if cardlist[i] <= A[i]: break
	A[i] = cardlist[i]
sum = 0
for i in range(0, N):
	sum += A[i]
print(sum)

### FIXED CODE ###

def smaller(x, y):
	if x < y: return x
	return y
def larger(x, y):
	if x > y: return x
	return y

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Asum = []
sum = 0
for i in range(0, N):
	sum += A[i]
	Asum.append(sum)
controllist = []
for i in range(0, M):
	controllist.append(list(map(int, input().split())))
controllist.sort(key = lambda v: v[1], reverse = True)
addlist = []
flag = False
for i in range(0, M):
	for j in range(0, controllist[i][0]):
		addlist.append(controllist[i][1])
		if len(addlist) == N:
			flag = True
			break
	if flag: break
sum = 0
for i in range(0, smaller(N, len(addlist))):
	sum += larger(A[i], addlist[i])
for i in range(len(addlist), N):
	sum += A[i]
print(sum)
import sys
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)**0.5
    if a - a//1 == 0:
      cnt += 1
print(cnt)

### FIXED CODE ###

import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, _ = rm()
li = np.array([np.array(rl()) for _ in range(n)])
cnt = 0
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)**0.5
    if a - a//1 == 0:
      cnt += 1
print(cnt)
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (i-1 >= 0 and tmp[i-1][j] == '#')or(i+1 <= h-1 and tmp[i+1][j] == '#') or(j-1 >= 0 and tmp[i][j-1] == '#')or(j+1 <= w-1 and tmp[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')


### FIXED CODE ###

import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

H, W = map(int, input().split())
s = [None]*H
for i in range(H):
    s[i] = input()
    # print(s[i])
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            #print(i, j)
            if (i != 0 and s[i-1][j] == '#') or(i != H-1 and s[i+1][j] == '#')or(j != 0 and s[i][j-1] == '#') or(j != W-1 and s[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')
N = int(input())
set = {}
for i in range(N):
    A = str(input())
    set.add(A)

print(len(set))


### FIXED CODE ###

N = int(input())
list = {}
for i in range(N):
    A = str(input())
    list[A] = 1

print(len(list))
n = int(input())
s = input()
cou = 0
if "#" not in s:
  print(0)
else:
  a = s.index("#")
  s_r = s[::-1]
  a1 = s_r.index(".")
  a3 = n-a1
  s1 = s[a:a3]
  b = s1.count(".")
  c = s1.count("#")
  print(min(b,c))

### FIXED CODE ###

from itertools import accumulate
n = int(input())
s = input()
l = []
for i in s:
  if i==".":
    l.append(0)
  else:
    l.append(1)
l1 = list(accumulate([0]+l))
#print(l1)
l = []
for i in s[::-1]:
  if i==".":
    l.append(1)
  else:
    l.append(0)
l2 = list(accumulate([0]+l))[::-1]
#print(l2)
cou = 10**6
if "#" not in s or "." not in s :
  print(0)
else:
  #左が"."　右が"#"  左は#の個数調べて右は.の個数調べる
  for j,k in zip(l1,l2):
    a = j+k
    cou = min(cou,a)
  print(cou)
N = int(input())
S = input()
max_cnt = 0
for i in range(101):
  li1 = [0]*26
  li2 = [0]*26
  cnt = 0
  for j in S[i:]:
    li[ord(j)-97]+=1
  for j in S[:i]:
    li[ord(j)-97]+=1
  for j in range(26):
    if(li1[j]>0 and li2[j]>0):
      cnt += 1
  max_cnt = max(max_cnt,cnt)
print(max_cnt)
      

### FIXED CODE ###

N = int(input())
S = input()
max_cnt = 0
for i in range(N):
  li1 = [0]*26
  li2 = [0]*26
  cnt = 0
  for j in S[i:]:
    li1[ord(j)-97]+=1
  for j in S[:i]:
    li2[ord(j)-97]+=1
  for j in range(26):
    if(li1[j]>0 and li2[j]>0):
      cnt += 1
  max_cnt = max(max_cnt,cnt)
print(max_cnt)
n=int(input())
s=input()
ans=1

for i in range(n-1):
  flag=s[0]
  if s[i+1]!=flag:
    ans+=flag
    flag=s[i+1]
print(flag)
    

### FIXED CODE ###

n=int(input())
s=input()
ans=1
flag=s[0]

for i in range(n-1):
  if s[i+1]!=flag:
    ans+=1
    flag=s[i+1]
print(ans)
k=int(input())
import math

for p in range(1,k+1):
    for q in range(1,k+1):
        for r in range(1,k+1):
            ans=p
            ans = math.gcd(ans, q)
            ans = math.gcd(ans, r)
            sum_g+=ans
            ans=0
print(sum_g)


### FIXED CODE ###

import math

K=int(input())
sum=0


for i in range(1,K+1):
    for j in range(1,K+1):
        a=math.gcd(i,j)
        for k in range(1,K+1):
            b=math.gcd(a, k)
            sum = sum + b

print(sum)
k,n = map(int,input().split())
     
    s = list(map(int,input().split()))
    longest = 0
    for i in range(n-1):
        long = s[i+1] - s[i]
        if long > longest:
            longest = long
    if longest >= k - s[n-1] + s[0]:
        print(k - longest)
    else:
        print(s[n-1] - s[0])

### FIXED CODE ###

k, n = map(int, input().split())

s = list(map(int, input().split()))
longest = 0
for i in range(n - 1):
    long = s[i + 1] - s[i]
    if long > longest:
        longest = long
if longest >= k - s[n - 1] + s[0]:
    print(k - longest)
else:
    print(s[n - 1] - s[0])
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

S.sort（）
str1=''
for i in range (H):
    str1=str1+S[i] 
print(str1)

### FIXED CODE ###

H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

S.sort()
str1=''
for i in range (H):
    str1=str1+S[i] 
print(str1)
a = str(input())
if a[0] = a[1] = a[2] or a[1] = a[2] = a[3]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = str(input())
if a[0] == a[1] == a[2] or a[1] == a[2] == a[3]:
    print("Yes")
else:
    print("No")
from sys import stdin
S = stdin.readline().rstrip()
print(x*len(S))

### FIXED CODE ###

from sys import stdin
S = stdin.readline().rstrip()
print('x'*len(S))
A, B, C = list(map(int, input()))
K = int(input())

ans = max(A, B, C) * (2 ** K)

### FIXED CODE ###

A, B, C = list(map(int, input().split()))
K = int(input())

ans = max([A, B, C]) * (2 ** K) - max([A, B, C])

print(ans + A + B + C)
import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    print (a, b, inv)

    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)


### FIXED CODE ###

import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx >= 0 and xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)
s=input()
t=input()
ans="z"*len(s)
flag=0
for i in range(2**len(t)):
  K=str(bin(i))[2:].zfill(5)
  T=""
  for j in range(len(t)):
    if K[j]=="0":
      T+="?"
    else:
      T+=t[j]
  for k in range(len(s)-len(t)+1):
    if s[k:k+len(t)]==T:
      Key=s[:k]+t+s[k+len(t):]
      ans=min(ans,Key.replace("?","a"))
      flag=1
print(ans if flag==1 else "UNRESTORABLE")

### FIXED CODE ###

s=input()
t=input()
ns,nt,nd=len(s),len(t),len(s)-len(t)
ans="z"*ns
flag=0
for i in range(nd+1):
  judge=True
  for j in range(nt):
    ss=s[i+j]
    tt=t[j]
    if ss!="?" and ss!=tt:
      judge=False
  if judge:
    Key=s[:i]+t+s[i+nt:]
    ans=min(ans,Key.replace("?","a"))
    flag=1
print(ans if flag==1 else "UNRESTORABLE")
k, n = (int(i) for i in input().split())
st [int(i) for i in input().split()]

st = sorted(st)
st.append(st[0] + k)

diffs = [st[i+1] - st[i] for i in range(n)]

print(k - max(diffs))


### FIXED CODE ###

def main():
    k, n = (int(i) for i in input().split())
    st = [int(i) for i in input().split()]

    st = sorted(st)
    st.append(st[0] + k)

    diffs = [st[i+1] - st[i] for i in range(n)]

    print(k - max(diffs))

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

li=[A,B,C]

max_num=max(li)
max_num2=-10000

for i in range(3):
    if max_num!=i and max_num2<i:
        max_num2=i
        
num1=str(max_num)+str(max_num2)
li.remove(max_num)
li.remove(max_num2)

print(int(num1)+li[0])

### FIXED CODE ###

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

li=[A,B,C]

max_num=max(li)
max_num2=min(li)

for i in li:
    if max_num!=i and max_num2<i:
        max_num2=i
        
num1=int(str(max_num)+str(max_num2))
li.remove(max_num)
li.remove(max_num2)

print(int(num1)+li[0])
n,w = map(int,input().split())
wv=[]
for _ in range(n):
  w,v=map(int,input().split())
  wv.append([w,v])

dp=[[0 for i in range(w+1)]for j in range(n+1)]
for i in range(1,n+1):
  for j in range(1,w+1):
    if j-wv[i-1][0]<0:
      dp[i][j]=dp[i-1][j]
    else:
      dp[i][j]=max(dp[i-1][j-wv[i][1]],dp[i-1][j])

print(dp[n][w])

### FIXED CODE ###

n,w=map(int,input().split())
P=[]
for _ in range(n):
  iw,iv=map(int,input().split())
  P.append([iw,iv])
INF=float('inf')
 
dp=[[0 for i in range(w+1)] for j in range(n+1)]
 
for i in range(1,n+1):
  for j in range(1,w+1):
    if j-P[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-P[i-1][0]]+P[i-1][1])
    else:
      dp[i][j]=dp[i-1][j]
print(dp[n][w])
# C
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans = N - 1
lst = make_divisors(N)
for i in range(0, len(lst), 2):
    num = lst[i] + lst[i+1] - 2
    ans = min(ans,num)

print(ans)

### FIXED CODE ###

# C
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans = N - 1
lst = make_divisors(N)
if (len(lst) % 2 == 0):
    for i in range(0, len(lst), 2):
        num = lst[i] + lst[i+1] - 2
        ans = min(ans,num)
else:
    for i in range(0, len(lst)-1, 2):
        num = lst[i] + lst[i+1] - 2
        ans = min(ans,num)
    ans = min(ans,2*lst[-1] - 2)
print(ans)
n,m=map(int,input().split())
l=[]
for i in range(m):
  a,b=map(int,input().split())
  l.append([a,b])
for i in range(10**(n-1)-1,10**n):
  x=str(i)
  c=0
  for i in range(m):
    if x[l[i][0]-1]==str(l[i][1]):
      c+=1
  if c==m:
    print(x)
    quit()
print(-1)

### FIXED CODE ###

n,m=map(int,input().split())
l=[]
for i in range(m):
  a,b=map(int,input().split())
  l.append([a,b])
for i in range(10**n):
  x=str(i)
  if len(x)<n:pass
  else:
    c=0
    for i in range(m):
      if x[l[i][0]-1]==str(l[i][1]):
        c+=1
    if c==m:
      print(x)
      quit()
print(-1)
val, size = map(int, input().split())
disabledList = [int(x) for x in input().split()] # number
enableList = list(set(range(10)) - set(disabledList)) # number
resultList = [] # str, must reverse
isTenOver = False
for char in reversed(list(str(val))):
  targetInt = int(char)
  if isTenOver:
    targetInt += 1
  if targetInt in enableList:
    isTenOver = False
    resultList.append(str(targetInt))
    continue
  resultList = [str(min(enableList))] * len(resultList)
  if targetInt > max(enableList):
    isTenOver = True
    resultList.append(str(min(enableList)))
  else:
    isTenOver = False
    minNum = min(filter(lambda x:x > targetInt, enableList))
    resultList.append(str(minNum))

if isTenOver:
  minNum = min(filter(lambda x:x > 0, enableList))
  resultList.append(str(minNum))
print(''.join(reversed(resultList)))

### FIXED CODE ###

numList = input().split()

if len(numList) != 3:
  print('NO')
elif numList.count('5') != 2:
  print('NO')
elif numList.count('7') != 1:
  print('NO')
else:
  print('YES')
c, a, b = map(int, input().split())
d = 0

while a <= b :
    if a % c == 0:
        d = d + 1;

    a = a + 1;
    
if d == 0:
    print("NG");

else:
    print("OK");

### FIXED CODE ###

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

while a <= b :
    if a % c == 0:
        d = d + 1;

    a = a + 1;
    
if d == 0:
    print("NG");

else:
    print("OK");
S = input()
s = ""
i = 0
for c in S:
  if c == '0' or c == '1':
    s[i] = c
    i += 1
  else:
    if i > 0:
      s[i] = ''
      i -= 1

### FIXED CODE ###

S = input()
s = ['' for c in S]
i = 0
for c in S:
  if c == '0' or c == '1':
    s[i] = c
    i += 1
  else:
    if i > 0:
      i -= 1
      s[i]=''
print(''.join(s))
def grid_coloring():
	h,w = map(int, raw_input().split(" "))
	n = int(raw_input())
	a = map(int, raw_input().split(" "))
	_current_color = 1
	ans = np.zeros((h,w), dtype=int)
	for i in range(h):
		if i%2==0:
			for j in reversed(range(w)):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
		else:
			for j in range(w):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
	for i in range(h):
		print " ".join(map(str, ans[i]))


if __name__ == "__main__":
	grid_coloring()

### FIXED CODE ###

import numpy as np

def grid_coloring():
	h,w = map(int, raw_input().split(" "))
	n = int(raw_input())
	a = map(int, raw_input().split(" "))
	_current_color = 1
	ans = np.zeros((h,w), dtype=int)
	for i in range(h):
		if i%2==0:
			for j in reversed(range(w)):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
		else:
			for j in range(w):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
	for i in range(h):
		print " ".join(map(str, ans[i]))


if __name__ == "__main__":
	grid_coloring()
N=int(input())
W=[]
S=set()
for i in range(N):
    w=input()
    W.append(w)
    last=W[0][-1]
S.add(W[0])
    
for i in range(1,N):
    if W[i][0]==last and not W[i] in S:
        pass
    else:
        print("No")
        exit()
    S.add(w[i])
    last=w[i][-1] #ケツ追加した
print("Yes")



### FIXED CODE ###

def main():
    n = int(input())
    
    tmp = ""
    f = True
    st = []
    for i in range(n):
        w = input()
        st.append(w)
        if i > 0:
            if tmp[-1] == w[0]:
                pass
            else:
                f = False
        tmp = w
    if len(list(set(st))) != n:
        f = False
    
    print("Yes" if f else "No")

if __name__ == "__main__":
    main()
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print("{0} {1} {2}".format(i, j, (n - i - j)))
            exit(0)

### FIXED CODE ###

n = int(input())
print(len(set(map(int, [input() for _ in range(n)]))))