Chef Tobby is playing a rapid fire with Bhuvan. He gives Bhuvan a string S and each time, Bhuvan has to guess whether there exists 2 equal subsequences in the string or not.
Bhuvan got a perfect score in the game with Chef Tobby. However, Chef Tobby has now asked Bhuvan to write a program that will do this automatically given a string S. Bhuvan is an intelligent man but he does not know how to write a code. Can you help him?
Find two different subsequences such that they are equal in their value, more formally, find two sequences of indices (a1, a2, ..., ak-1, ak) and (b1, b2, ..., bk-1, bk) such that:

- 1≤ ai, bi ≤ |S|
- ai < ai+1 for all valid i
- bi < bi+1 for all valid i
- Sai = Sbi for all valid i
- there exist at least one i such that ai is not equal to bi

-----Input section-----
The first line contains T, the number of test cases.
Each of the next T lines contain one string S each.
Input will only consist of lowercase english characters

-----Output section-----
For each test case, output "yes" or "no" (without quotes) as the solution to the problem.

-----Input constraints-----
1 ≤ T ≤ 1000
1 ≤ length of S ≤ 100

-----Sample Input-----
4
likecs
venivedivici
bhuvan
codechef

-----Sample Output-----
no
yes
no
yes

-----Explanation-----
In test case 2, one of the possible equal subsequence is "vi" and "vi". (one at position {0, 3} and other at {4, 7}, assuming 0-based indexing).
In test case 4, one of the possible equal subsequence is "ce" and "ce". (one at position {0, 3} and other at {4, 6}, assuming 0-based indexing).

Difficulty: EASY
Tags: Complete search
Skill types: Complete search

Starter code:

Solutions:
from collections import Counter
for _ in range(int(input())):
	s = list(input())
	d = dict(Counter(s))
	f = 0
	for i in d.values():
		if i >= 2:
			f = 1
			break
	if f:
		print('yes')
	else:
		print('no')


for t in range(int(input())):
	s = input()
	r = set(s)
	if len(s) != len(r):
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	s = input()
	temp = list(set(s))
	flag = False
	for j in temp:
		if s.count(j) > 1:
			flag = True
			break
	print('yes' if flag else 'no')


t = int(input())
for i in range(t):
	s = input()
	h = set(s)
	if len(h) < len(s):
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	s = input()
	s = list(s)
	c = 0
	for i in s:
		if s.count(i) >= 2:
			c = 1
			print('yes')
			break
	if c == 0:
		print('no')


for _ in range(int(input())):
	s = input()
	n = len(s)
	d = {}
	ans = 'no'
	for i in range(n):
		d[s[i]] = d.setdefault(s[i], 0) + 1
		if d[s[i]] > 1:
			ans = 'yes'
			break
	print(ans)


for _ in range(int(input())):
	S = input()
	for i in list(set(S)):
		if S.count(i) > 1:
			print('yes')
			break
	else:
		print('no')


for i in range(int(input())):
	s = input()
	p = set(s)
	q = len(s)
	r = len(p)
	if r < q:
		print('yes')
	else:
		print('no')


for T in range(int(input())):
	A = input()
	set_A = list(set(A))
	result = 'no'
	for i in range(len(set_A)):
		if A.count(set_A[i]) > 1:
			result = 'yes'
			break
	print(result)


t = int(input())
for i in range(t):
	input_string = input()
	unique_string = set(input_string)
	if len(input_string) != len(unique_string):
		print('yes')
	else:
		print('no')


T = int(input())
while T > 0:
	s = input()
	flg = 0
	for i in range(len(s) - 1):
		if s.find(s[i], i + 1) != -1:
			flg = 1
	if flg == 0:
		print('no')
	else:
		print('yes')
	T = T - 1


for _ in range(int(input())):
	s = list(input())
	letters = set()
	flag = False
	for letter in s:
		if letter not in letters:
			letters.add(letter)
		else:
			flag = True
			break
	if flag:
		print('yes')
	else:
		print('no')


t = input()
for c in range(0, int(t)):
	s = input()
	arr = []
	for x in s:
		arr.append(x)
	found = 0
	for y in range(0, len(arr)):
		if s.count(arr[y]) > 1:
			found = found + 1
		if found == 2:
			print('yes')
			break
	if found < 2:
		print('no')


t = int(input())
for _ in range(t):
	s = [x for x in input()]
	freq = {}
	for i in s:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	flag = 0
	for (keys, values) in freq.items():
		if values >= 2:
			flag = 1
			break
	if flag == 0:
		print('no')
	else:
		print('yes')


from math import *
import sys

def input():
	return sys.stdin.readline().replace('\n', '').strip()
sys.setrecursionlimit(10 ** 9)
for _ in range(int(input())):
	l = list(input())
	if len(set(l)) == len(l):
		print('no')
	else:
		print('yes')


a = int(input(''))
for i in range(a):
	t = input('')
	k = list(t)
	ans = set(k)
	if len(ans) == len(k):
		print('no')
	else:
		print('yes')


t = int(input())
while t > 0:
	x = input()
	y = ''
	for i in x:
		if i not in y:
			y += i
	if len(x) == len(y):
		print('no')
	else:
		print('yes')
	t -= 1


for i in range(int(input())):
	s = list(input())
	e = [j for j in s if s.count(j) > 1]
	if len(e) >= 2:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	s = input()
	ans = 1
	for j in s:
		if s.count(j) > 1:
			ans = 0
			break
	if ans == 0:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	s = input()
	l1 = len(s)
	l2 = len(set(s))
	if l1 != l2:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	s = input()
	list1 = []
	flag = 0
	for i in range(len(s)):
		list1.append(s[i])
	set1 = set(list1)
	dict1 = dict()
	for i in set1:
		dict1[i] = 0
	for i in list1:
		dict1[i] += 1
		if dict1[i] > 1:
			print('yes')
			flag = 1
			break
	if flag == 0:
		print('no')


t = int(input())
for i in range(t):
	string = input()
	set_string = list(set(list(string)))
	flag = False
	for s in set_string:
		if string.count(s) > 1:
			flag = True
			break
	print('yes' if flag else 'no')


t = int(input())
for i in range(t):
	s = input()
	l = [0 for i in range(26)]
	for j in range(len(s)):
		l[ord(s[j]) - 97] += 1
	f = 0
	for j in range(26):
		if l[j] > 1:
			f = 1
			break
	if f == 1:
		print('yes')
	else:
		print('no')


def Cook(S):
	Counter = dict()
	for i in S:
		if i not in Counter.keys():
			Counter[i] = 0
		Counter[i] += 1
	for i in Counter.values():
		if i > 1:
			return 'yes'
	return 'no'
for T in range(int(input())):
	S = input()
	print(Cook(S))


for i in range(int(input())):
	s = input()
	some = set(s)
	if len(s) != len(some):
		print('yes')
	else:
		print('no')


t = int(input())
for t in range(t):
	s = input()
	flag = 0
	for i in range(len(s)):
		res = s.count(s[i])
		if res > 1:
			flag = 1
			break
	if flag == 1:
		print('yes')
	else:
		print('no')


for item in range(int(input())):
	n = input()
	l = []
	for j in range(len(n)):
		x = n.count(n[j])
		if x > 1:
			l.append(n[j])
	if len(l) >= 2:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	S = input()
	set_S = list(set(list(S)))
	flag = False
	for s in set_S:
		if S.count(s) > 1:
			flag = True
			break
	print('yes' if flag else 'no')


for _ in range(int(input())):
	s = input()
	flag = False
	for i in s:
		if s.count(i) > 1:
			flag = True
			break
	if flag:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	a = input()
	b = list(a)
	c = 0
	for i in b:
		if a.count(i) > 1:
			c = c + 1
	if c >= 1:
		print('yes')
	else:
		print('no')


for t in range(int(input())):
	s = input()
	d = {}
	f = 0
	if len(s) >= 27:
		f = 1
	else:
		for i in s:
			if i not in d:
				d[i] = 1
			else:
				f = 1
				break
	if f == 1:
		print('yes')
	else:
		print('no')


n = int(input())
for i in range(n):
	s = input()
	coun = 0
	for j in s:
		if s.count(j) > 1:
			coun = coun + 1
	if coun >= 2:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	s = input()
	m = set(s)
	if len(m) < len(s):
		print('yes')
	else:
		print('no')


t = int(input())
while t != 0:
	s = input()
	c = 0
	for k in range(len(s)):
		if s.index(s[k]) != k:
			c += 1
			break
	if c == 1:
		print('yes')
	else:
		print('no')
	t -= 1


for i in range(int(input())):
	n = input()
	set_S = list(set(list(n)))
	flag = False
	for s in set_S:
		if n.count(s) > 1:
			flag = True
			break
	print('yes' if flag else 'no')


for _ in range(int(input())):
	s = sorted(list(input()))
	n = len(s)
	k = s[0]
	x = 0
	for i in s[1:n]:
		if k == i:
			print('yes')
			x = 1
			break
		else:
			k = i
	if x == 0:
		print('no')


t = int(input())
for i in range(t):
	l = list(input())
	s = list(set(l))
	if len(l) == len(s):
		print('no')
	else:
		print('yes')


for _ in range(int(input())):
	s = input()
	l = []
	for i in s:
		q = s.count(i)
		if q > 1:
			l.append(i)
	if len(l) >= 2:
		print('yes')
	else:
		print('no')


def func(s):
	if len(list(s)) == len(set(s)):
		return 'no'
	return 'yes'
for _ in range(int(input())):
	s = input()
	print(func(s))


for _ in range(int(input())):
	s = input()
	cnt = [0] * 27
	for i in s:
		o = ord(i) - 96
		cnt[o] = cnt[o] + 1
		if cnt[o] > 1:
			print('yes')
			break
	else:
		print('no')


t = int(input())
for _ in range(t):
	flag = 0
	s = input()
	mydict = {}
	for i in s:
		mydict[i] = s.count(i)
		if mydict[i] > 1:
			flag += 1
	if flag > 0:
		print('yes')
	else:
		print('no')


from collections import Counter as ct
for _ in range(int(input())):
	s = input()
	s = ct(s)
	count = 0
	for i in s.values():
		if i > 1:
			count += 1
	if count > 0:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	s = input()
	n = len(s)
	c = 0
	if n != len(set(s)):
		print('yes')
	else:
		print('no')


T = int(input())
for _ in range(0, T):
	s = str(input())
	flag = False
	for i in range(0, len(s)):
		s1 = s[i]
		for j in range(i + 1, len(s)):
			if s.count(s1) > 1:
				flag = True
				break
			s1 += s[j]
	if flag:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	(s, d, k) = (input(), {}, set())
	for i in s:
		if i in d:
			d[i] += 1
			k.add(i)
		else:
			d[i] = 1
	if len(k) >= 1:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	s = input()
	d = {}
	for i in s:
		if i in d:
			d[i] += 1
			break
		else:
			d[i] = 1
	v = list(d.values())
	if max(v) > 1:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	inps = input()
	print('yes' if len(inps) > len(set(inps)) else 'no')


for _ in range(int(input())):
	(s, d, k) = (input(), {}, 0)
	for i in s:
		if i in d:
			d[i] += 1
			k += 1
			break
		else:
			d[i] = 1
	if k >= 1:
		print('yes')
	else:
		print('no')


T = int(input())
for i in range(T):
	s = input()
	l = len(s)
	se = set(s)
	l1 = len(se)
	if l == l1:
		print('no')
	else:
		print('yes')


try:
	for _ in range(int(input())):
		s = input()
		l1 = len(s)
		l2 = len(set(s))
		if l1 != l2:
			print('yes')
		else:
			print('no')
except:
	pass


T = int(input())
for _ in range(T):
	s = input()
	s1 = set(s)
	if len(s) != len(s1):
		print('yes')
	else:
		print('no')


for j in range(int(input())):
	x = input()
	r = []
	for i in set(x):
		if x.count(i) >= 2:
			print('yes')
			break
	else:
		print('no')


for h in range(int(input())):
	s = input()
	l = list(s)
	s1 = set(s)
	if len(s1) == len(l):
		print('no')
	else:
		print('yes')


for t in range(int(input())):
	string = input()
	unique = []
	for ch in string:
		if ch not in unique:
			unique.append(ch)
	if len(string) == len(unique):
		print('no')
	else:
		print('yes')


for i in range(int(input())):
	s = input()
	s1 = set(s)
	l = []
	for j in s1:
		l.append(s.count(j))
	if max(l) >= 2:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	s = list(input())
	p = len(set(s))
	n = len(s)
	if n <= 2:
		print('no')
	elif n >= 3:
		if 1 < p < n:
			print('yes')
		else:
			print('no')


tests = int(input())
for i in range(tests):
	ans = 'no'
	string = input()
	for j in string:
		if string.count(j) > 1:
			ans = 'yes'
			break
	print(ans)


for t in range(int(input())):
	s = input()
	q = []
	for i in list(s):
		q.append(s.count(i))
	if max(q) > 1:
		print('yes')
	else:
		print('no')


t = int(input())
while t > 0:
	s = input()
	l = len(s)
	se = set(s)
	l1 = len(se)
	if l == l1:
		print('no')
	else:
		print('yes')
	t -= 1


t = int(input())
for i in range(t):
	s = input()
	s1 = list(s)
	n = len(s1)
	l = []
	for i in range(n):
		if s1.count(s[i]) > 1:
			l.append(s[i])
	if len(l) >= 2:
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	n = input()
	l = set(n)
	if len(n) != len(l):
		print('yes')
	else:
		print('no')


def check(s):
	s = list(s)
	for i in s:
		if s.count(i) > 1:
			return 'yes'
	return 'no'
for _ in range(int(input())):
	s = input()
	print(check(s))


t = int(input())
for _ in range(t):
	s = input()
	for i in set(s):
		if s.count(i) >= 2:
			print('yes')
			break
	else:
		print('no')


def check(h):
	for n in h:
		if n > 1:
			return 'yes'
	return 'no'
for _ in range(int(input())):
	s = input()
	h = [0] * 26
	for c in s:
		h[ord(c) - ord('a')] += 1
	print(check(h))