ZhenlongDai/ACPR huggingface dataset:
Problem: p02391
Buggy submission (Python3, verdict: Wrong Answer):
a,b = map(int,input().split())
if a < b:
    print("{} < {}".format(a,b))
elif a > b:
    print("{} > {}".format(a,b))
else:
    print("{} == {}".format(a,b))

Failing test case input:
9 19

Expected output:
a < b


Actual output:
9 < 19


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")

Problem: p02391
Buggy submission (Python3, verdict: Wrong Answer):
n = input().split()
print(n[0])
print(n[1])
if n[0] < n[1]:
	print("a < b")
elif n[0] > n[1]:
	print("a > b")
elif n[0] == n[1]:
	print("a == b")

Failing test case input:
4 -9

Expected output:
a > b


Actual output:
4
-9
a > b


Fixed submission (verdict: Accepted):
n = input().split()
a = int(n[0])
b = int(n[1])
if a < b:
	print("a < b")
elif a > b:
	print("a > b")
elif a == b:
	print("a == b")

Problem: p02391
Buggy submission (Python3, verdict: Wrong Answer):
a,b = list(map(int,input().split()))

if a < b:
    print("a<b")
elif a > b:
    print("a<b")
else:
    print("a==b")

Failing test case input:
4 -9

Expected output:
a > b


Actual output:
a<b


Fixed submission (verdict: Accepted):
a,b = list(map(int,input().split()))

if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")

Problem: p02391
Buggy submission (Python3, verdict: Wrong Answer):
a, b = map(int, input().split())
if a<b:
    print(int(a),"<",int(b))

elif a>b:
    print(int(a),">",int(b))

else:
    print(int(a),"==",int(b))

Failing test case input:
3 -7

Expected output:
a > b


Actual output:
3 > -7


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
if a<b:
    print("a < b")

elif a>b:
    print("a > b")

else:
    print("a == b")

Problem: p02391
Buggy submission (Python3, verdict: Wrong Answer):
a,b = map(int,input().split())

if a<b:
    print('{0} < {1}'.format(a,b))
elif a>b:
    print('{0} > {1}'.format(a,b))
else:
     print('{0} == {1}'.format(a,b))



Failing test case input:
-12 -3

Expected output:
a < b


Actual output:
-12 < -3


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())

if a<b:
    print('{0} < {1}'.format('a','b'))
elif a>b:
    print('{0} > {1}'.format('a','b'))
else:
     print('{0} == {1}'.format('a','b'))

Problem: p02391
Buggy submission (Python3, verdict: Wrong Answer):
c = input()
a, b = map(int, c.split())

if a > b:
    print("a > b")
elif a < b:
    print("a > b")
else:
    print("a==b")




Failing test case input:
-9 4

Expected output:
a < b


Actual output:
a > b


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
if a > b:
    print("a > b")
elif a < b:
    print("a < b")
else:
    print("a == b")
Problem: p02391
Buggy submission (Python3, verdict: Wrong Answer):
a,b = input().split(' ')
if int(a) > int(b):
	print('a > b')
elif int(a) < int(b):
	print('a > b')
else:
	print('a == b')

Failing test case input:
-12 -3

Expected output:
a < b


Actual output:
a > b


Fixed submission (verdict: Accepted):
a,b = input().split(' ')
if int(a) > int(b):
	print('a > b')
elif int(a) < int(b):
	print('a < b')
else:
	print('a == b')

Problem: p02391
Buggy submission (Python3, verdict: Wrong Answer):
a,b = map(int,input().split())
if a < b :
    print(str(a) + "<" + str(b))
elif a > b :
    print(str(a) + ">" + str(b))
else:
    print(str(a) + "==" + str(b))




Failing test case input:
3 -7

Expected output:
a > b


Actual output:
3>-7


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
if a < b :
    print("a" + " < " + "b")
elif a > b :
    print("a" + " > " + "b")
elif a == b: 
    print("a" + " == " + "b")
Problem: p03751
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
S = [input() for _ in range(N)]
T = input() 
best = []
worse = []
for s in S:
    best.append(s.replace('?', 'z'))
    worse.append(s.replace('?', 'a'))
for i in range(bisect.bisect_left(best,T)+1,bisect.bisect_right(worse,T)+2):
    print(i)
           

Failing test case input:
2
rsrunug
drrs
e

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
S = [input() for _ in range(N)]
T = input() 
best = []
worse = []
for s in S:
    best.append(s.replace('?', 'z'))
    worse.append(s.replace('?', 'a'))
ans=[]
best.sort()
worse.sort()
for i in range(bisect.bisect_left(best,T)+1,bisect.bisect_right(worse,T)+2):
    ans.append(i)
print(*ans)

Problem: p03751
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s_list = list()
for i in range(n):
    s_list.append(input())
t = input()

s_list_a = [s.replace("?","a") for s in s_list]
s_list_a.append(t)
s_list_a.sort()
index_a = [i+1 for i,x in enumerate(s_list_a) if x == t]

s_list_z = [s.replace("?","z") for s in s_list]
s_list_z.append(t)
s_list_z.sort()
index_z = [i+1 for i,x in enumerate(s_list_z) if x == t]

indexes = [i for i in range(index_z[0],index_a[-1]+1)]

print(indexes)

Failing test case input:
2
ssvuior
etss
d

Expected output:
1


Actual output:
[1]


Fixed submission (verdict: Accepted):
n = int(input())
s_list = list()
for i in range(n):
    s_list.append(input())
t = input()

s_list_a = [s.replace("?","a") for s in s_list]
s_list_a.append(t)
s_list_a.sort()
index_a = [i+1 for i,x in enumerate(s_list_a) if x == t]

s_list_z = [s.replace("?","z") for s in s_list]
s_list_z.append(t)
s_list_z.sort()
index_z = [i+1 for i,x in enumerate(s_list_z) if x == t]

indexes = [str(i) for i in range(index_z[0],index_a[-1]+1)]

answer = ' '.join(indexes)

print(answer)

Problem: p03751
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
S = [input() for _ in range(N)]
T = input() 
best = []
worse = []
for s in S:
    best.append(s.replace('?', 'z'))
    worse.append(s.replace('?', 'a'))
ans=[]
for i in range(bisect.bisect_left(best,T)+1,bisect.bisect_right(worse,T)+2):
    ans.append(i)
print(*ans)
           


Failing test case input:
2
ssrunug
drrs
e

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
S = [input() for _ in range(N)]
T = input() 
best = []
worse = []
for s in S:
    best.append(s.replace('?', 'z'))
    worse.append(s.replace('?', 'a'))
ans=[]
best.sort()
worse.sort()
for i in range(bisect.bisect_left(best,T)+1,bisect.bisect_right(worse,T)+2):
    ans.append(i)
print(*ans)
Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
n, m = map(int, input().split())
a = [[False]*n for i in range(n)]
rootList = [-1] * n

for i in range(m):
    s, t = map(int, input().split())
    if rootList[s] < 0:
        rootList[s] = s
    if rootList[t] < 0:
        rootList[t] = t
    if rootList[s] != rootList[t]:
        rootList[s] = min(rootList[s], rootList[t])
        rootList[t] = min(rootList[s], rootList[t])
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print("yes" if rootList[s] == rootList[t] != -1 else "no")

Failing test case input:
16 9
0 1
0 2
6 4
5 7
5 2
3 7
6 13
7 8
8 9
3
0 1
5 9
1 3

Expected output:
yes
yes
yes


Actual output:
yes
no
no


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
rootList = [-1 for i in range(n)]
 
def getRoot(x):
    if rootList[x] < 0:
        rootList[x] = x
    elif rootList[x] != x:
        rootList[x] = getRoot(rootList[x])
    return rootList[x]
 
 
def setSameRoot(x, y):
    x = getRoot(x)
    y = getRoot(y)
    if x != y:
        rootList[x], rootList[y] = min(x, y), min(x, y)
 
for i in range(m):
    s, t = map(int, input().split())
    setSameRoot(s, t)
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print("yes" if getRoot(s) == getRoot(t) != -1 else "no")

Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
n, m = map(int, input().split())
relations = [[] for _ in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    if s > t:
        s, t = t, s
    relations[s] += [t]
friend_id = [None] * n
for s, t in enumerate(relations):
    if t:
        queue = [s]
        while len(queue):
            k = queue.pop()
            friend_id[k] = s
            queue += relations[k]
            relations[k] = []

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print('yes' if friend_id[s] != None and friend_id[s] == friend_id[t] else'no')

Failing test case input:
16 9
0 1
0 2
6 4
5 7
5 2
3 7
6 13
7 8
8 9
3
0 1
5 9
1 3

Expected output:
yes
yes
yes


Actual output:
yes
yes
no


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
relations = [[] for _ in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    relations[s] += [t]
    relations[t] += [s]
friend_id = [None] * n
for s, t in enumerate(relations):
    if t:
        queue = [s]
        while len(queue):
            k = queue.pop()
            friend_id[k] = s
            queue += relations[k]
            relations[k] = []

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print('yes' if friend_id[s] != None and friend_id[s] == friend_id[t] else'no')
Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
n, m = map(int, input().split())
a = [[False]*n for i in range(n)]
rootList = [-1] * n

for i in range(m):
    s, t = map(int, input().split())
    if rootList[s] < 0:
        rootList[s] = s
    if rootList[t] < 0:
        rootList[t] = t
    if rootList[s] != rootList[t]:
        rootList[s] = min(rootList[s], rootList[t])
        rootList[t] = min(rootList[s], rootList[t])
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print("yes" if rootList[s] == rootList[t] else "no")

Failing test case input:
16 9
0 2
1 2
3 4
2 7
5 6
3 7
0 13
7 8
8 9
3
1 0
4 2
2 3

Expected output:
yes
yes
yes


Actual output:
yes
no
yes


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
rootList = [-1 for i in range(n)]
 
def getRoot(x):
    if rootList[x] < 0:
        rootList[x] = x
    elif rootList[x] != x:
        rootList[x] = getRoot(rootList[x])
    return rootList[x]
 
 
def setSameRoot(x, y):
    x = getRoot(x)
    y = getRoot(y)
    if x != y:
        rootList[x], rootList[y] = min(x, y), min(x, y)
 
for i in range(m):
    s, t = map(int, input().split())
    setSameRoot(s, t)
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print("yes" if getRoot(s) == getRoot(t) != -1 else "no")

Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
n, m = map(int, input().split())
friend = [[] for i in range(n)]
for i in range(m):
    s, t = map(int, input().split())
    friend[s].append(t)
    friend[t].append(s)

def are_connected(s, t):
    q = [s]
    checked = [False] * n
    checked[s] = True

    while q:
        user = q.pop(0)
        for f in friend[user]:
            if f == t:
                print(f, user)
                return True
            elif not checked[f]:
                q.append(f)
                checked[f] = True
    return False

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    if are_connected(s, t):
        print('yes')
    else:
        print('no')

Failing test case input:
16 9
0 1
0 2
3 8
5 7
5 6
3 7
6 8
7 8
8 9
3
0 1
5 9
1 3

Expected output:
yes
yes
no


Actual output:
1 0
yes
9 8
yes
no


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
friend = [[] for i in range(n)]
for i in range(m):
    s, t = map(int, input().split())
    friend[s].append(t)
    friend[t].append(s)

group = [-1 for i in range(n)]
for u in range(n):
    if group[u] == -1:
        group[u] = u
        q = [u]
        while q:
            u1 = q.pop()
            for u2 in friend[u1]:
                if group[u2] == -1:
                    group[u2] = u
                    q.append(u2)

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    if group[s] == group[t]:
        print('yes')
    else:
        print('no')
Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
def dfs(s):
    global t
    if s == t:
        return True
    DP[s]=1
    for i in F[s]:
        if not DP[i]:
            if dfs(i):
                return True
    return False
    
n,m = [int(i) for i in input().split()]
F = [{}]*n
for _ in range(m):
    i,j = [int(i) for i in input().split()]
    F[i][j] = 1
    F[j][i] = 1
q = int(input())
for i in range(q):
    DP = [0]*n
    s,t = [int(i) for i in input().split()]
    if dfs(s):
        print("yes")
    else:
        print("no")


Failing test case input:
16 9
0 1
0 2
5 4
5 7
5 6
3 0
11 7
0 8
1 9
3
0 2
1 9
1 4

Expected output:
yes
yes
no


Actual output:
yes
yes
yes


Fixed submission (verdict: Accepted):
from collections import deque
n,m = [int(i) for i in input().split()]
F = [{} for i in range(n)]
for _ in range(m):
    i,j = [int(i) for i in input().split()]
    F[i][j] = 1
    F[j][i] = 1
q = int(input())
DP = [0 for i in range(n)]
c = 1
d = deque()
for i in range(n):
    if not DP[i]:
        d.append(i)
    while(len(d)>0):
        tmp = d.pop()
        DP[tmp] = c
        for i in F[tmp]:
            if not DP[i]:
                d.append(i)
    c+=1

for i in range(q):
    s,t = [int(i) for i in input().split()]
    if DP[s] == DP[t]:
        print("yes")
    else:
        print("no")

Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
n, m = map(int, input().split())
relations = [[] for _ in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    if s > t:
        s, t = t, s
    relations[s] += [t]
friend_id = [None] * n
for s, t in enumerate(relations):
    if t:
        queue = [s]
        while len(queue):
            k = queue.pop()
            friend_id[k] = s
            queue += relations[k]
            relations[k] = []

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print('yes' if friend_id[s] and friend_id[s] == friend_id[t] else'no')

Failing test case input:
16 9
0 2
0 2
3 4
2 7
5 6
3 11
6 13
7 8
8 9
3
0 0
5 9
1 3

Expected output:
yes
no
no


Actual output:
no
no
no


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
relations = [[] for _ in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    relations[s] += [t]
    relations[t] += [s]
friend_id = [None] * n
for s, t in enumerate(relations):
    if t:
        queue = [s]
        while len(queue):
            k = queue.pop()
            friend_id[k] = s
            queue += relations[k]
            relations[k] = []

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print('yes' if friend_id[s] != None and friend_id[s] == friend_id[t] else'no')
Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
def bfs(s, t):
  q = [s]
  while len(q) > 0:
    v = q.pop(0)
    if v == t: return True
    if len(G[v]) > 0:
      q.extend(sorted(G[v]))
      G[v] = []
  return False

u, n = map(int, input().split())
G = [[] for _ in range(u)]
for _ in range(n):
  a, b = map(int, input().split())
  if b not in G[a]: G[a].append(b)
  if a not in G[b]: G[b].append(a)

q = int(input())
for _ in range(q):
  s, t = map(int, input().split())
  if bfs(s, t):
    print("yes")
  else:
    print("no")

Failing test case input:
16 9
0 1
0 2
3 4
1 7
5 6
5 7
6 13
7 8
8 9
3
0 1
2 13
1 3

Expected output:
yes
yes
no


Actual output:
yes
no
no


Fixed submission (verdict: Accepted):
def grouping(G):
  gid_list = [0] * len(G)

  gid = 1
  for i, _ in enumerate(G):
    if gid_list[i] > 0: continue
    q = [i]
    while len(q) > 0:
      v = q.pop(0)
      gid_list[v] = gid
      for v in sorted(G[v]):
        if gid_list[v] <= 0: q.append(v)
    gid += 1
  return gid_list

u, n = map(int, input().split())
G = [[] for _ in range(u)]
for _ in range(n):
  a, b = map(int, input().split())
  if b not in G[a]: G[a].append(b)
  if a not in G[b]: G[b].append(a)

gid_list = grouping(G)

q = int(input())
for _ in range(q):
  s, t = map(int, input().split())
  if gid_list[s] == gid_list[t]:
    print("yes")
  else:
    print("no")

Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
def dfs(s):
    global t
    if s == t:
        return True
    DP[s]=1
    for i in F[s]:
        if not DP[i]:
            if dfs(i):
                return True
    return False
    
n,m = [int(i) for i in input().split()]
F = [{}]*n
for _ in range(m):
    i,j = [int(i) for i in input().split()]
    F[i][j] = 1
q = int(input())
for i in range(q):
    DP = [0]*n
    s,t = [int(i) for i in input().split()]
    if dfs(s):
        print("yes")
    else:
        print("no")


Failing test case input:
16 9
0 1
0 2
3 4
5 7
5 2
3 7
6 13
11 12
8 9
3
0 1
5 9
1 3

Expected output:
yes
no
yes


Actual output:
yes
yes
no


Fixed submission (verdict: Accepted):
from collections import deque
n,m = [int(i) for i in input().split()]
F = [{} for i in range(n)]
for _ in range(m):
    i,j = [int(i) for i in input().split()]
    F[i][j] = 1
    F[j][i] = 1
q = int(input())
DP = [0 for i in range(n)]
c = 1
d = deque()
for i in range(n):
    if not DP[i]:
        d.append(i)
    while(len(d)>0):
        tmp = d.pop()
        DP[tmp] = c
        for i in F[tmp]:
            if not DP[i]:
                d.append(i)
    c+=1

for i in range(q):
    s,t = [int(i) for i in input().split()]
    if DP[s] == DP[t]:
        print("yes")
    else:
        print("no")
Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
def connected(G,s,t):
    checked = [False]*len(G)
    def main(G,s,t):
        if t in G[s]: return True
        checked[s] = True
        for f in G[s]:
            if checked[f]: continue
            if main(G,f,t): return True
        return False
    return main(G,s,t)


if __name__=='__main__':
    n,m = list(map(int,input().split()))
    G = [[] for _ in range(n)]
    for _ in range(m):
        s,t = list(map(int,input().split()))
        G[s].append(t)
        G[t].append(s)
    q = int(input())
    for _ in range(q):
        s,t = list(map(int,input().split()))
        print('Yes' if connected(G,s,t) else 'No')

Failing test case input:
16 9
0 1
0 2
6 4
5 7
5 2
3 7
6 13
7 8
8 9
3
0 1
5 9
1 3

Expected output:
yes
yes
yes


Actual output:
Yes
Yes
Yes


Fixed submission (verdict: Accepted):
import sys
 
def make_connected_group(G):
    C = [None]*len(G)
    group = 0
    for i,p in enumerate(C):
        if p != None: continue
        friends = [i]
        while len(friends) > 0:
            f = friends.pop()
            if C[f] == None:
                C[f] = group
                friends += G[f]
        group += 1
    return C
 
 
if __name__=='__main__':
    n,m = list(map(int,sys.stdin.readline().split()))
    G = [[] for _ in range(n)]
    for _ in range(m):
        s,t = list(map(int,input().split()))
        G[s].append(t)
        G[t].append(s)
    C = make_connected_group(G)
    q = int(input())
    for j,line in enumerate(sys.stdin):
        if not j < q: break
        s,t = list(map(int,line.split()))
        print('yes' if C[s] == C[t] else 'no')

Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):
n, m = map(int, input().split())
relations = [[] for _ in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    if s > t:
        s, t = t, s
    relations[s] += [t]
friend_id = [None] * n
id = 0
for s, t in enumerate(relations):
    if t:
        queue = [s]
        while len(queue):
            k = queue.pop()
            friend_id[k] = id
            queue += relations[k]
            relations[k] = []
    id += 1

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print('yes' if friend_id[s] == friend_id[t] else'no')

Failing test case input:
16 9
0 1
0 2
6 4
5 7
5 2
3 7
6 13
7 8
8 9
3
0 1
5 9
1 3

Expected output:
yes
yes
yes


Actual output:
yes
yes
no


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
relations = [[] for _ in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    relations[s] += [t]
    relations[t] += [s]
friend_id = [None] * n
for s, t in enumerate(relations):
    if t:
        queue = [s]
        while len(queue):
            k = queue.pop()
            friend_id[k] = s
            queue += relations[k]
            relations[k] = []

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print('yes' if friend_id[s] != None and friend_id[s] == friend_id[t] else'no')
Problem: p02240
Buggy submission (Python3, verdict: Wrong Answer):

n, m = map(int, input().split())
ALL = [0] * n
Graph = []
for i in range(m):
    s, t = map(int, input().split())
    if ALL[s] == 0 and ALL[t] == 0:
        Graph.append(set([s, t]))
    elif ALL[s] == 0:
        for g in Graph:
            if t in g:
                g.add(s)
                break
    elif ALL[t] == 0:
        for g in Graph:
            if s in g:
                g.add(t)
                break
    ALL[s] = 1
    ALL[t] = 1

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    for g in Graph:
        if s in g and t in g:
            print('yes')
            break
    else:
        print('no')

Failing test case input:
16 9
0 1
0 3
5 4
5 7
10 6
3 0
11 9
0 8
1 9
2
0 2
1 9
1 4

Expected output:
no
yes


Actual output:
no
no


Fixed submission (verdict: Accepted):


def set_color(i, ci, e, color):
    color[i] = ci
    next_i = set(e[i])
    while len(next_i):
        s = next_i.pop()
        if color[s] != ci:
            color[s] = ci
            next_i.update(e[s])


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

e = [set() for i in range(n)]
color = [None] * n

for i in range(m):
    s, t = map(int, input().split())
    e[s].add(t)
    e[t].add(s)

ci = 0
for i in range(n):
    if color[i] == None:
        set_color(i, ci, e, color)
        ci += 1

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    if color[s] == color[t]:
        print('yes')
    else:
        print('no')
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import sys
a='abcdefghijklmnopqrstuvwxy'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)


Failing test case input:
wnly lw wki tmgxyvi xxdl n orsx rm xli .tmwx

Expected output:
sjhu hs sge picture ttzh j knot ni the .pist


Actual output:
sjhu hs sge picture ttyh j knot ni the .pist


Fixed submission (verdict: Accepted):
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):

import sys
import re

def move(char, num):
    if ord(char) + num <= ord('z'):
        return ord(char) + num
    else:
        return ord(char) + num - (ord('z') - ord('a') + 1)

def shift(s, num):
    new = ""
    for i in range(0, len(s)):
        if s[i].isalpha():
            new += str(chr(move(s[i], num)));
        else:
            new += s[i]
    return new

def decrypt(s):
    for i in range(1, 26):
        decrypted = shift(s, i)
        if re.search('the|this|that', decrypted):
            print(decrypted)

if __name__ == '__main__':
    for line in sys.stdin:
        print(decrypt(line))

Failing test case input:
wmly wm xli tmgxyvi xldx l nssx rm ilx xwmt.

Expected output:
sihu si the picture thzt h joot ni eht tsip.


Actual output:
sihu si the picture thzt h joot ni eht tsip.

None


Fixed submission (verdict: Accepted):

import sys
import re

def move(char, num):
    if ord(char) + num <= ord('z'):
        return ord(char) + num
    else:
        return ord(char) + num - (ord('z') - ord('a') + 1)

def shift(s, num):
    new = ""
    for i in range(0, len(s)):
        if s[i].isalpha():
            new += str(chr(move(s[i], num)));
        else:
            new += s[i]
    return new

def decrypt(s):
    for i in range(0, 26):
        decrypted = shift(s, i)
        if re.search('the|this|that', decrypted):
            return decrypted

if __name__ == '__main__':
    lines = []
    for line in sys.stdin:
        lines.append(line)
    for line in lines:
        print(decrypt(line), end="")
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def caesar_decrypt(N, cipher):
    text = ""
    for char in cipher:
        if 'a' <= char <= 'z':
            k = (ord(char) - 97 - N) % 26
            text += chr(97 + k)
        else:
            text += char
    return text

cipher = input().strip()
for k in range(26):
    decrypted = caesar_decrypt(k, cipher)
    if "this" in decrypted and "the" in decrypted and "that" in decrypted:
        print(decrypted)
        break

Failing test case input:
wmly lw xli tmgxyui xxdl m ossx rm lix xwmt.

Expected output:
sihu hs the pictuqe ttzh i koot ni het tsip.


Actual output:

Fixed submission (verdict: Accepted):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def caesar_decrypt(N, cipher):
    text = ""
    for char in cipher:
        if 'a' <= char <= 'z':
            k = (ord(char) - 97 - N) % 26
            text += chr(97 + k)
        else:
            text += char
    return text


for cipher in sys.stdin:
    cipher = cipher.strip()
    for k in range(26):
        decrypted = caesar_decrypt(k, cipher)
        if "this" in decrypted or "the" in decrypted or "that" in decrypted:
            print(decrypted)
            break

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import sys


def decrypt(c, i):
    
    if c.isalpha():
        t = ord(c) - i
        if t < ord('a'):
            t = ord('z') - i + 1
        return chr(t)
    else:
        return c


if __name__ == '__main__':
    
    for line in sys.stdin:

        
        found = ''  
        for i in range(0, 26):
            decrypted = ''.join([decrypt(x, i) for x in line.strip()])
            
            if 'the' in decrypted or 'this' in decrypted or 'that' in decrypted:
                found = decrypted
                break

        
        if found:
            print(found)

Failing test case input:
wmlx wm xli tmgxyvi xldx l ossx rm ilx xwmt.

Expected output:
siht si the picture thzt h koot ni eht tsip.


Actual output:
siht si the picture thwt h koot ni eht tsip.


Fixed submission (verdict: Accepted):
import sys


def decrypt(c, i):
    
    if c.isalpha():
        t = ord(c) - i
        if t < ord('a'):
            t += 26
        return chr(t)
    else:
        return c


if __name__ == '__main__':
    
    for line in sys.stdin:

        
        found = ''  
        for i in range(0, 26):
            decrypted = ''.join([decrypt(x, i) for x in line.strip()])
            
            if ' the ' in decrypted or ' this ' in decrypted or ' that ' in decrypted or \
                    decrypted.startswith('the ') or decrypted.startswith('this ') or decrypted.startswith('that '):
                found = decrypted
                break

        
        if found:
            print(found)
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
from sys import stdin

def ascii2num(ascii):
    return ord(ascii) - 96

def num2ascii(num):
    return chr(num + 96)

def slide(word,num):
    return ''.join([num2ascii((ascii2num(ascii) + num) % 26) if ascii != '.' else '.' for ascii in word])

def includekeyword(words):
    for word in words:
        if word in keywords:
            return True
    return False

keywords = ['the', 'this', 'that']


decode = []
for row in stdin:
    words = row.split()
    for num in range(1,27):
        tmp = [slide(word,num) for word in words]
        if includekeyword(tmp):
            decode = tmp
            print(' '.join(decode))

Failing test case input:
wmly wm xli tmgxyvi xxdl m ossx rm ilx xwmt.

Expected output:
sihu si the picture ttzh i koot ni eht tsip.


Actual output:
sihu si the picture tt`h i koot ni eht tsip.


Fixed submission (verdict: Accepted):
from sys import stdin

def ascii2num(ascii):
    return ord(ascii) - 96

def num2ascii(num):
    return chr(num + 96)

def slide(word,num):
    return ''.join([num2ascii((ascii2num(ascii) - num) % 26 + 1) if ascii != '.' else '.' for ascii in word])

def includekeyword(words):
    for word in words:
        if word in keywords:
            return True
    return False

keywords = ['the', 'this', 'that']

decode = []
for row in stdin:
    words = row.split()
    for num in range(1,27):
        tmp = [slide(word,num) for word in words]
        if includekeyword(tmp):
            decode = tmp
            print(' '.join(decode))
            break

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def caesar_decrypt(N, cipher):
    text = ""
    for char in cipher:
        if 'a' <= char <= 'z':
            k = (ord(char) - 97 - N) % 26
            text += chr(97 + k)
        else:
            text += char
    return text

cipher = input()
for k in range(26):
    decrypted = caesar_decrypt(k, cipher)
    if "this" in decrypted and "the" in decrypted and "that" in decrypted:
        print(decrypted)
        break

Failing test case input:
wmly lw xli tmgxyvi xxdl m orsx rm xli .tmwx

Expected output:
sihu hs the picture ttzh i knot ni the .pist


Actual output:

Fixed submission (verdict: Accepted):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def caesar_decrypt(N, cipher):
    text = ""
    for char in cipher:
        if 'a' <= char <= 'z':
            k = (ord(char) - 97 - N) % 26
            text += chr(97 + k)
        else:
            text += char
    return text


for cipher in sys.stdin:
    cipher = cipher.strip()
    for k in range(26):
        decrypted = caesar_decrypt(k, cipher)
        if "this" in decrypted or "the" in decrypted or "that" in decrypted:
            print(decrypted)
            break
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
a='abcdefghijklmnopqrstuvwxy'
b=input()
for i in range(26):
 c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
 if any(('the 'in c,'this 'in c,'that 'in c)):print(c);break


Failing test case input:
wmly lw ilx tmgxyvi xxdl m orsx rm xli .tmwx

Expected output:
sihu hs eht picture ttzh i knot ni the .pist


Actual output:
sihu hs eht picture ttyh i knot ni the .pist


Fixed submission (verdict: Accepted):
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
def cshift(w):
    r = ""
    for c in w:
        if c == 'z':
            r += 'a'
        else:
            r += chr(ord(c)+1)
    return r
while True:
    try:
        sent = input()
    except EOFError:
        break
    
    words = sent[:-1].split()
    while ("the" not in words) and ("this" not in words) and ("that" not in words):
        for i, w in enumerate(words):
            words[i] = cshift(w)
    print(" ".join(words)+".")

Failing test case input:
wmlx mw xli tngxyvi xlew l orsx mr ilx .tmwx

Expected output:
siht is the pjcture thas h knot in eht .pist


Actual output:
siht is the pjcture thas h knot in eht Dpis.


Fixed submission (verdict: Accepted):
def cshift(w):
    r = ""
    for c in w:
        if c == 'z':
            r += 'a'
        elif c == '.':
            r += '.'
        else:
            r += chr(ord(c)+1)
    return r
while True:
    try:
        sent = input()
    except EOFError:
        break
    
    words = sent.split()
    while ("the" not in words) and ("this" not in words) and ("that" not in words):
        for i, w in enumerate(words):
            words[i] = cshift(w)
    print(" ".join(words))
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
from sys import stdin

def ascii2num(ascii):
    return ord(ascii) - 96

def num2ascii(num):
    return chr(num + 96)

def slide(word,num):
    return ''.join([num2ascii((ascii2num(ascii) + num) % 26) if ascii != '.' else '.' for ascii in word])

def includekeyword(words):
    for word in words:
        if word in keywords:
            return True
    return False

keywords = ['the', 'this', 'that']

decode = []
for row in stdin:
    words = row.split()
    for num in range(1,27):
        tmp = [slide(word,num) for word in words]
        if includekeyword(tmp):
            decode = tmp
            print(' '.join(decode))
            break

Failing test case input:
wmly lw xli tmgxyvi xxdl m xsso rm ilx xwmt.

Expected output:
sihu hs the picture ttzh i took ni eht tsip.


Actual output:
sihu hs the picture tt`h i took ni eht tsip.


Fixed submission (verdict: Accepted):
from sys import stdin

def ascii2num(ascii):
    return ord(ascii) - 96

def num2ascii(num):
    return chr(num + 96)

def slide(word,num):
    return ''.join([num2ascii((ascii2num(ascii) - num) % 26 + 1) if ascii != '.' else '.' for ascii in word])

def includekeyword(words):
    for word in words:
        if word in keywords:
            return True
    return False

keywords = ['the', 'this', 'that']

decode = []
for row in stdin:
    words = row.split()
    for num in range(1,27):
        tmp = [slide(word,num) for word in words]
        if includekeyword(tmp):
            decode = tmp
            print(' '.join(decode))
            break

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
a='abcdefghijklmnopqrstuvwxy'
b=input()
for i in range(26):
 c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
 if any(('the'in c,'this'in c,'that'in c)):print(c);break


Failing test case input:
wmlx wm xli tmgxyvi xldx l ossx qm ilx xwmt.

Expected output:
siht si the picture thzt h koot mi eht tsip.


Actual output:
siht si the picture thyt h koot mi eht tsip.


Fixed submission (verdict: Accepted):
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import fileinput
import string

alphabetArray = list(string.ascii_lowercase)


for data in fileinput.input():
    for n in range(-25, 26):
        replacedStr = data.replace('\n', '').replace('\r', '')
        for i in range(0, 26):
            if n > 0:
                replacedStr = replacedStr.replace(alphabetArray[i], alphabetArray[(i + n) % 26])
            else:
                replacedStr = replacedStr.replace(alphabetArray[i], alphabetArray[i + n])
        if "this" in replacedStr or "the" in replacedStr or "that" in replacedStr:
            print(replacedStr)
            break

Failing test case input:
wmly lw xli tmgxyvi xxdl m orsx rm ily .tmwx

Expected output:
sihu hs the picture ttzh i knot ni ehu .pist


Actual output:
sihu hs the picture ttvh i knot ni ehu .pist


Fixed submission (verdict: Accepted):
import fileinput
import string

alphabetArray = list(string.ascii_lowercase)

for data in fileinput.input():
    for n in range(-26, 27):
        replacedStrAry = list(data.replace('\n', '').replace('\r', ''))
        for index in range(0, len(replacedStrAry)):
            if not replacedStrAry[index] in alphabetArray:
                continue
            if n >= 0:
                replacedStrAry[index] = alphabetArray[(alphabetArray.index(replacedStrAry[index]) + n) % 26]
            else:
                replacedStrAry[index] = replacedStrAry[index] = alphabetArray[alphabetArray.index(replacedStrAry[index]) + n]
        replacedStr = "".join(replacedStrAry)
        replacedStrSplitedBySpace = replacedStr.split(' ')
        if "the" in replacedStrSplitedBySpace or "this" in replacedStrSplitedBySpace or "that" in replacedStrSplitedBySpace:
            print(replacedStr)
            break
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import sys


def decrypt(c, i):
    
    if c.isalpha():
        t = ord(c) - i
        if t < ord('a'):
            t = ord('z') - i + 1
        return chr(t)
    else:
        return c


if __name__ == '__main__':
    
    for line in sys.stdin:

        
        found = ''  
        for i in range(0, 26):
            decrypted = ''.join([decrypt(x, i) for x in line.strip()])
            
            if ' the ' in decrypted or ' this ' in decrypted or ' that ' in decrypted or \
                    decrypted.startswith('the ') or decrypted.startswith('this ') or decrypted.startswith('that '):
                found = decrypted
                break

        
        if found:
            print(found)

Failing test case input:
ylmw lw ilx tmgxyvi xxdl o orsy rm xli .tmwx

Expected output:
uhis hs eht picture ttzh k knou ni the .pist


Actual output:
uhis hs eht picture ttwh k knou ni the .pist


Fixed submission (verdict: Accepted):
import sys


def decrypt(c, i):
    
    if c.isalpha():
        t = ord(c) - i
        if t < ord('a'):
            t += 26
        return chr(t)
    else:
        return c


if __name__ == '__main__':
    
    for line in sys.stdin:

        
        found = ''  
        for i in range(0, 26):
            decrypted = ''.join([decrypt(x, i) for x in line.strip()])
            
            if ' the ' in decrypted or ' this ' in decrypted or ' that ' in decrypted or \
                    decrypted.startswith('the ') or decrypted.startswith('this ') or decrypted.startswith('that '):
                found = decrypted
                break

        
        if found:
            print(found)

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import string
import sys

line = input()
alpha = string.ascii_lowercase

for line in sys.stdin:
    for i in range(len(alpha)):
        cipher_str = ""
        for s in line:
            if s in alpha:
                cipher_str += alpha[(alpha.index(s)+i) % len(alpha)]
            else:
                cipher_str += s

        if ("the" or "this" or "that") in cipher_str:
            print(cipher_str)
            break
    else:
        print(line)

Failing test case input:
wmly lw xli tmgxyvi xlcw m orsx rm xli .tmwx

Expected output:
sihu hs the picture thys i knot ni the .pist


Actual output:

Fixed submission (verdict: Accepted):
import string
import sys

alpha = string.ascii_lowercase

for line in sys.stdin:
    for i in range(len(alpha)):
        cipher_str = ""
        for s in line:
            if s in alpha:
                cipher_str += alpha[(alpha.index(s)+i) % len(alpha)]
            else:
                cipher_str += s

        if "the" in cipher_str or "this" in cipher_str or "that" in cipher_str:
            print(cipher_str, end="")
            break
    else:
        print(line, end="")
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):

import re

def move(char, num):
    if ord(char) + num <= ord('z'):
        return ord(char) + num
    else:
        return ord(char) + num - (ord('z') - ord('a') + 1)

def shift(s, num):
    new = ""
    for i in range(0, len(s)):
        if s[i].isalpha():
            new += str(chr(move(s[i], num)));
        else:
            new += s[i]
    return new

def decrypt(s):
    for i in range(1, 26):
        decrypted = shift(s, i)
        if re.search('the|this|that', decrypted):
            print(decrypted)

if __name__ == '__main__':
    crypted = input()
    print(decrypt(crypted))

Failing test case input:
wmlx wm xli tmgxyvi xlex l ossw rm ilx xwmt.

Expected output:
siht si the picture that h koos ni eht tsip.


Actual output:
siht si the picture that h koos ni eht tsip.
None


Fixed submission (verdict: Accepted):

import sys
import re

def move(char, num):
    if ord(char) + num <= ord('z'):
        return ord(char) + num
    else:
        return ord(char) + num - (ord('z') - ord('a') + 1)

def shift(s, num):
    new = ""
    for i in range(0, len(s)):
        if s[i].isalpha():
            new += str(chr(move(s[i], num)));
        else:
            new += s[i]
    return new

def decrypt(s):
    for i in range(0, 26):
        decrypted = shift(s, i)
        if re.search('the|this|that', decrypted):
            return decrypted

if __name__ == '__main__':
    lines = []
    for line in sys.stdin:
        lines.append(line)
    for line in lines:
        print(decrypt(line), end="")

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
a='abcdefghijklmnopqrstuvwxy'
b=input()
for i in range(26):
 c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
 if any(('the'in c,'this'in c,'that'in c)):print(c)


Failing test case input:
wmly lw xli tmgxyui xxdl m ossx rm lix xwmt.

Expected output:
sihu hs the pictuqe ttzh i koot ni het tsip.


Actual output:
sihu hs the pictuqe ttyh i koot ni het tsip.


Fixed submission (verdict: Accepted):
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import sys


def decrypt(c, i):
    
    if c.isalpha():
        t = ord(c) - i
        if t < ord('a'):
            t = ord('z') - i + 1
        return chr(t)
    else:
        return c


if __name__ == '__main__':
    
    for line in sys.stdin:

        
        found = ''  
        for i in range(1, 25):
            decrypted = ''.join([decrypt(x, i) for x in line])
            
            if 'the' in decrypted or 'this' in decrypted or 'that' in decrypted:
                found = decrypted
                break

        
        if found:
            print(found)

Failing test case input:
ylmw lw xli tmgxyvi xxdl m sorx rm ilx .tmwx

Expected output:
uhis hs the picture ttzh i oknt ni eht .pist


Actual output:
uhis hs the picture ttwh i oknt ni eht .pist



Fixed submission (verdict: Accepted):
import sys


def decrypt(c, i):
    
    if c.isalpha():
        t = ord(c) - i
        if t < ord('a'):
            t += 26
        return chr(t)
    else:
        return c


if __name__ == '__main__':
    
    for line in sys.stdin:

        
        found = ''  
        for i in range(0, 26):
            decrypted = ''.join([decrypt(x, i) for x in line.strip()])
            
            if ' the ' in decrypted or ' this ' in decrypted or ' that ' in decrypted or \
                    decrypted.startswith('the ') or decrypted.startswith('this ') or decrypted.startswith('that '):
                found = decrypted
                break

        
        if found:
            print(found)

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import sys


def decrypt(c, i):
    
    if c.isalpha():
        t = ord(c) - i
        if t < ord('a'):
            t = ord('z') - i + 1
        return chr(t)
    else:
        return c


if __name__ == '__main__':
    
    for line in sys.stdin:

        
        found = ''  
        for i in range(1, 25):
            decrypted = ''.join([decrypt(x, i) for x in line.strip()])
            
            if 'the' in decrypted or 'this' in decrypted or 'that' in decrypted:
                found = decrypted
                break

        
        if found:
            print(found)

Failing test case input:
wmly lw xli tmgxyvi xxdl m orsx rm xli .tmwx

Expected output:
sihu hs the picture ttzh i knot ni the .pist


Actual output:
sihu hs the picture ttwh i knot ni the .pist


Fixed submission (verdict: Accepted):
import sys


def decrypt(c, i):
    
    if c.isalpha():
        t = ord(c) - i
        if t < ord('a'):
            t += 26
        return chr(t)
    else:
        return c


if __name__ == '__main__':
    
    for line in sys.stdin:

        
        found = ''  
        for i in range(0, 26):
            decrypted = ''.join([decrypt(x, i) for x in line.strip()])
            
            if ' the ' in decrypted or ' this ' in decrypted or ' that ' in decrypted or \
                    decrypted.startswith('the ') or decrypted.startswith('this ') or decrypted.startswith('that '):
                found = decrypted
                break

        
        if found:
            print(found)
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import string
import sys

str = input()
alpha = string.ascii_lowercase

for str in sys.stdin:
    for i in range(len(alpha)):
        cipher_str = ""
        for s in str:
            if s in alpha:
                cipher_str += alpha[(alpha.index(s)+i) % len(alpha)]
            else:
                cipher_str += s

        if ("the" or "this" or "that") in cipher_str:
            print(cipher_str)
            break

Failing test case input:
wmlx mw xli tmgxyvi xxel l ossw rm jlx xwmt.

Expected output:
siht is the picture ttah h koos ni fht tsip.


Actual output:

Fixed submission (verdict: Accepted):
import string
import sys

alpha = string.ascii_lowercase

for line in sys.stdin:
    for i in range(len(alpha)):
        cipher_str = ""
        for s in line:
            if s in alpha:
                cipher_str += alpha[(alpha.index(s)+i) % len(alpha)]
            else:
                cipher_str += s

        if "the" in cipher_str or "this" in cipher_str or "that" in cipher_str:
            print(cipher_str, end="")
            break
    else:
        print(line, end="")

Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
t = ord("t")
z = ord("z")
a = ord("a")

def _decode(tv, v):
    spam = ord(v)
    if not (a <= spam <= z):
        return v

    x = t - ord(tv)
    y = spam + x

    if y > z:
        y = a + (y % z)
    elif y < a:
        y = z - (a - y)

    return chr(y)

while 1:
    try:
        txt = input()
        for s in [x for x in txt.split() if len(x) <= 4 and len(x) >= 3]:
            tv = s[0]
            dec_val = ''.join(list(map(lambda x:_decode(tv,x),s)))

            if (dec_val in ('this', 'the', 'that')):
                print(''.join(list(map(lambda x:_decode(tv,x),txt))))
                break
    except:
        break

Failing test case input:
wmly lw xli tmgxyvi xxcl m orsx rm xli .tmwx

Expected output:
sihu hs the picture ttyh i knot ni the .pist


Actual output:
sihu hs the picture ttxh i knot ni the .pist


Fixed submission (verdict: Accepted):
t = ord("t")
z = ord("z")
a = ord("a")

def _decode(tv, v):
    spam = ord(v)
    if not (a <= spam <= z):
        return v

    x = t - ord(tv)
    y = spam + x

    if y > z:
        y = a + (y % z) - 1
    elif y < a:
        y = z - (a - y - 1)

    return chr(y)

while 1:
    try:
        txt = input()
        for s in [x for x in txt.split() if 3 <= len(x) <= 4]:
            tv = s[0]
            dec_val = ''.join(list(map(lambda x:_decode(tv,x),s)))

            if (dec_val in ('this', 'the', 'that')):
                print(''.join(list(map(lambda x:_decode(tv,x),txt))))
                break
    except:
        break
Problem: p00017
Buggy submission (Python3, verdict: Wrong Answer):
import sys
a='abcdefghijklmnopqrstuvwxy'
for b in sys.stdin:
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)


Failing test case input:
wnly lw wki tmgxyvi xxdl n orsx rm xli .tmwx

Expected output:
sjhu hs sge picture ttzh j knot ni the .pist


Actual output:
sjhu hs sge picture ttyh j knot ni the .pist



Fixed submission (verdict: Accepted):
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)