ZhenlongDai/ACPR huggingface dataset:
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
S = input()
T = input()

if T in S:
    print(0)
    sys.exit(0)

ans = []
for i in range(len(S)-len(T)+1):
    s = S[i:len(T)]
    cnt = 0
    for x, y in zip(s, T):
        if x == y:
            cnt += 1
    ans.append(cnt)
    
print(len(T)-max(ans))

Failing test case input:
codefsrceo
atdrceo

Expected output:
3


Actual output:
6


Fixed submission (verdict: Accepted):
import sys
S = input()
T = input()

if T in S:
    print(0)
    sys.exit(0)

ans = []
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    cnt = 0
    for x, y in zip(s, T):
        if x == y:
            cnt += 1
    ans.append(cnt)
    
print(len(T)-max(ans))

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

ans=len(T)

itti=0
for i in range(len(S)-len(T)):
    cnt=0
    for j in range(i,i+len(T)):
        if S[j]==T[j-i]:
            cnt+=1
    itti = max(itti,cnt)

print(len(T)-itti)


Failing test case input:
oecqsdefpa
btdqepa

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
S = input()
T = input()

ans=len(T)

itti=0
for i in range(len(S)-len(T)+1):
    cnt=0
    for j in range(i,i+len(T)):
        if S[j]==T[j-i]:
            cnt+=1
    itti = max(itti,cnt)

print(len(T)-itti)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()

scnt = len(s)
tcnt = len(t)

change = 10**3

for i in range (0, scnt - tcnt):
  cnt = 0
  for j in range(tcnt):
    if s[i+j] != t[j]:
      cnt += 1
  if change > cnt:
    change = cnt

print(change)

Failing test case input:
cbc`cd
`ab

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
s = input()
t = input()

scnt = len(s)
tcnt = len(t)

change = 10**3

for i in range (0, scnt - tcnt + 1):
  cnt = 0
  for j in range(tcnt):
    if s[i+j] != t[j]:
      cnt += 1
  if change > cnt:
    change = cnt

print(change)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
slen = len(s)
tlen = len(t)
ans = tlen
temp = 0

for start in range(0,slen-tlen):
    for i in range(0,tlen):
        if t[i] != s[start+i]:
            temp += 1
    ans = min(ans,temp)
    temp = 0

print(ans)



Failing test case input:
apfedqsceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
s = input()
t = input()
slen = len(s)
tlen = len(t)
ans = 10**20
temp = 0

for start in range(0,slen-tlen+1):
    temp = 0
    for i in range(0,tlen):
        if t[i] != s[start+i]:
            temp += 1
    ans = min(ans,temp)
print(ans)
Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S,T = input(),input()
num = len(T)
ans = num
for i in range(num):
    for j in range(i+1,num+1):
        str = T[i:j]
        if str in S[i:-(num-j)]:
            ans = min(ans,num - len((T[i:j])))
        

print(ans)


Failing test case input:
cbcaac
bba

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S,T = input(),input()
ans = len(T)

for i in range(len(S)-len(T)+1):
    sum = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:sum+=1
        
    ans = min(ans,len(T)-sum)
print(ans)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s = input()
t = input()
ans = 0
for i in range(len(t)):
    if s.count(t[i:]) != 0:
        ans = (len(t[i:]))
        break
if s.count(t[1:]) != 0:
    ans = max((len(t[1:])),ans)
print(len(t)-ans)

Failing test case input:
apfedsqceo
btpqcda

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
t = input()
ans = 1000
for i in range(len(s)-len(t)+1):
    tmp = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            tmp += 1
    ans = min(tmp, ans)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
mx = float('-inf')
for i in range(0, len(s)-len(t)+1):
    
    k = 0
    cnt = 0
    for j in t:
        
        if s[i+k]==j:
            cnt+=1
            mx = max(cnt, mx)
        k+=1
print(len(t)-mx)

Failing test case input:
oeectfpcat
albs`tb

Expected output:
7


Actual output:
inf


Fixed submission (verdict: Accepted):
s = input()
t = input()
mx = 0
for i in range(0, len(s)-len(t)+1):
    
    k = 0
    cnt = 0
    for j in t:
        
        if s[i+k]==j:
            cnt+=1
            mx = max(cnt, mx)
        k+=1
print(len(t)-mx)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def check(a,b):
    cnt=0
    for x in range(len(a)):
        if a[x]!=b[x]:
            cnt+=1
    return cnt        
s=input()
t=input()
k=len(t)
ans=k
for x in range(len(s)-len(t)):
    ans=min(ans,check(s[x:x+k],t))
print(ans)    

    

Failing test case input:
oecqsdefpa
btdqepa

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
def check(a,b):
    cnt=0
    for x in range(len(a)):
        if a[x]!=b[x]:
            cnt+=1
    return cnt        
s=input()
t=input()
k=len(t)
ans=k
for x in range(len(s)-len(t)+1):
    ans=min(ans,check(s[x:x+k],t))
print(ans)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
minCount = len(t)
i = 0
while i < len(s):
    countSame = 0
    j = 0
    while j < len(t) and i+j < len(s):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)


Failing test case input:
oeectfpcat
albs`tb

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
t = input()
minCount = len(t)
i = 0
while i < len(s) and i + len(t) <= len(s):
    countSame = 0
    j = 0
    while j < len(t):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

ans = 0
l = len(T)
for m in range (len(S)-l):
    diff = 0
    for i in range (l):
        if S[m+i] != T[i]:
            diff+=1
    ans = min(ans, diff)

print(ans)

Failing test case input:
oecqsdefpa
btdqep`

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
S = input()
T = input()

ans = len(T)
l = len(T)
for m in range (len(S)-l+1):
    diff = 0
    for i in range (l):
        if S[m+i] != T[i]:
            diff+=1
    ans = min(ans, diff)

print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()
t = input()

ans = 10**5

len_s = len(s)
len_t = len(t)

S = []

for i in range(len_s):
    S.append(s[i])

for i in range(len_s - len_t):
    tmp = 0
    ss = S[i:i+len_t]
    for j in range(len_t):
        if t[j] != ss[j]:
            tmp += 1
    if tmp < ans:
        ans = tmp

print(ans)

Failing test case input:
apfeesrceo
cdarotb

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()
t = input()

ans = 10**5

len_s = len(s)
len_t = len(t)

S = []

for i in range(len_s):
    S.append(s[i])

for i in range(len_s - len_t+1):
    tmp = 0
    ss = S[i:i+len_t]
    for j in range(len_t):
        if t[j] != ss[j]:
            tmp += 1
    if tmp < ans:
        ans = tmp

print(ans)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
n = len(s)
l = len(t)
ans = l
for i in range(n - l):
    tmp = 0
    for j in range(l):
        if s[i + j] != t[j]:
            tmp += 1
    ans = min(ans, tmp)
print(ans)


Failing test case input:
apfedsqceo
btpqcda

Expected output:
5


Actual output:
7


Fixed submission (verdict: Accepted):
s = input()
t = input()
n = len(s)
l = len(t)
ans = l
for i in range(n - l + 1):
    tmp = 0
    for j in range(l):
        if s[i + j] != t[j]:
            tmp += 1
    ans = min(ans, tmp)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
t=input()
num=len(s)-len(t)
res=[]
for n1 in range(0,num+1):
    count=0
    for n2 in range(0,len(t)):
        if(t[n2]!=s[n1+n2]):
            count+=1
    print(count)
    res.append(count)
print(min(res))

Failing test case input:
cpfedsqbdo
apeqdtb

Expected output:
5


Actual output:
5
5
7
6
5


Fixed submission (verdict: Accepted):
s=input()
t=input()
num=len(s)-len(t)
res=[]
for n1 in range(0,num+1):
    count=0
    for n2 in range(0,len(t)):
        if(t[n2]!=s[n1+n2]):
            count+=1
    res.append(count)
print(min(res))

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

N = len(T)

s_list = []
for i in range(len(S) - N + 1):
    s = S[i: i + N]
    s_list.append(s)

answer = N
for s in s_list:
    counter = 0
    for i in range(N):
        if s[i] != T[i]:
            counter += 1

answer = min(answer, counter)

print(answer)

Failing test case input:
cabacc
abb

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):

S = input()
T = input()

N = len(T)

s_list = []
for i in range(len(S) - N + 1):
    s = S[i: i + N]
    s_list.append(s)

answer = N
for s in s_list:
    counter = 0
    for i in range(N):
        if s[i] != T[i]:
            counter += 1

    answer = min(answer, counter)

print(answer)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = list(input())
t = list(input())
cnt = len(t)
diff = cnt

for i in range(len(s)):
    for j in range(len(t)):
        if len(s) <= i+j:
            break
        elif s[i+j] == t[j]:
            cnt -= 1
    if cnt < diff:
        diff = cnt
    cnt = len(t)
print(diff)


Failing test case input:
oeectfpcat
albs`tb

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
s = list(input())
t = list(input())
cnt = len(t)
diff = cnt

for i in range(len(s)):
    for j in range(len(t)):
        if len(s) <= i+j:
            cnt = len(t)
            break
        elif s[i+j] == t[j]:
            cnt -= 1
    if cnt < diff:
        diff = cnt
    cnt = len(t)
print(diff)
Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s = list(input())
t = list(input())
n = len(s)
k = len(t)
ans = float("Inf")
for i in range(n-k):
    p = 0
    for j in range(k):
        if s[i+j] != t[j]:
            p += 1
            
    ans = min(ans, p)
    
print(ans)

Failing test case input:
ccbaac
aac

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
s = list(input())
t = list(input())
n = len(s)
k = len(t)
ans = float("Inf")
for i in range(n-k+1):
    p = 0
    for j in range(k):
        if s[i+j] != t[j]:
            p += 1
            
    ans = min(ans, p)
    
print(ans)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S = input()
T = input()
def same(U):
    k = 0
    for i in range(len(U)):
        if U[i] == T[i]:
            k += 1
    return k
ans = 0
for i in range(len(S)-len(T)):
    ans = max(ans,same(S[i:i+len(T)]))
print(len(T)-ans)

Failing test case input:
codefsqceo
atdrceo

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
S = input()
T = input()
def same(U):
    k = 0
    for i in range(len(U)):
        if U[i] == T[i]:
            k += 1
    return k
ans = 0
for i in range(len(S)-len(T)+1):
    ans = max(ans,same(S[i:i+len(T)]))
print(len(T)-ans)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):



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

s = input()
t = input()
ans = 100000
for i in range(len(s)-len(t)):
    u = s[i:i+len(t)]
    cnt = 0
    for j in range(len(t)):
        if u[j] != t[j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)



Failing test case input:
apfeeqsceo
btorcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):



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

s = input()
t = input()
ans = 100000
for i in range(len(s)-len(t)+1):
    u = s[i:i+len(t)]
    cnt = 0
    for j in range(len(t)):
        if u[j] != t[j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()

t_len = len(t)
s_len = len(s)
max_ = 0
temp = 0

for i in range(s_len - t_len):
  for j in range(t_len):
    if s[i + j] == t[j]:
      temp += 1
  if max_ < temp:
    max_ = temp
  temp = 0
print(t_len - max_ + 1)

Failing test case input:
cpfedsqaeo
btdqep`

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
s = input()
t = input()

t_len = len(t)
s_len = len(s)
max_ = 0
temp = 0

for i in range(s_len - t_len + 1):
  for j in range(t_len):
    if s[i + j] == t[j]:
      temp += 1
  if max_ < temp:
    max_ = temp
  temp = 0

print(t_len - max_)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
ans = len(t)


for start in range(len(s)-len(t)):
    l = 0
    for j in range(len(t)):
        if s[j+start] != t[j]:
            l += 1
    ans = min(ans,l)
print(ans)

Failing test case input:
apfedsqceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
s = input()
t = input()
ans = len(t)


for start in range(len(s)-len(t)+1):
    l = 0
    for j in range(len(t)):
        if s[j+start] != t[j]:
            l += 1
    ans = min(ans,l)
print(ans)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s = input()
t = input()
ans = 10**10
for i in range(len(s)-len(t)):
    b = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            b += 1
    ans = min(ans,b)
print(ans)

Failing test case input:
apfedsqceo
btpqcda

Expected output:
5


Actual output:
7


Fixed submission (verdict: Accepted):
s = input()
t = input()
ans = 10**10
for i in range(len(s)-len(t)+1):
    b = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            b += 1
    ans = min(ans,b)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

S = input()
T = input()
ans = 10**9
for i in range(len(S)-len(T)):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
        else:
            pass
    if ans >= count:
        ans = count
    else:
        pass
print(ans)

Failing test case input:
oecqsdefpa
btdqepa

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):

S = input()
T = input()
ans = 10**9
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
        else:
            pass
    if ans >= count:
        ans = count
    else:
        pass
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
ans = 1000
for i in range(len(s)-len(t)):
    temp = 0
    sub = s[i:i+len(t)]
    for j in range(len(t)):
        if sub[j] != t[j]:
            temp += 1
    if temp < ans:
        ans = temp
print(ans)

Failing test case input:
oecqsdefpa
btdqep`

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
t = input()
ans = 1000
for i in range(len(s)-len(t)+1):
    temp = 0
    sub = s[i:i+len(t)]
    for j in range(len(t)):
        if sub[j] != t[j]:
            temp += 1
    if temp < ans:
        ans = temp
print(ans)
Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys, bisect, math, itertools, string, queue, copy
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

s = input()
t = input()

m = 0
for i in range(len(s)):
    tmp = 0
    for j in range(len(t)):
        if(j + i >= len(s)):
            break
        if(s[j + i] == t[j]):
            tmp += 1
        m = max(m, tmp)
print(len(t) - m)


Failing test case input:
oeectfpcat
albs`tb

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
import sys, bisect, math, itertools, string, queue, copy
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

s = input()
t = input()

m = 0
for i in range(len(s)):
    tmp = 0
    for j in range(len(t)):
        if(j + i >= len(s)):
            tmp = 0
            break
        if(s[j + i] == t[j]):
            tmp += 1
    m = max(m, tmp)
print(len(t) - m)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=list(input())
t=list(input())
S=len(s)
T=len(t)
count=0
ans=1000
for i in range(S-T):
  count=0
  for j in range(T):
    if s[i+j]!=t[j]:
      count+=1
  ans=min(ans,count)
print(ans)

Failing test case input:
apfedqsceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
s=list(input())
t=list(input())
S=len(s)
T=len(t)
count=0
ans=1000
for i in range(S-T+1):
  count=0
  for j in range(T):
    if s[i+j]!=t[j]:
      count+=1
  ans=min(ans,count)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

max_cnt = 0
max_ind = 0
for i in range(len(S)-len(T)):
  cnt = 0
  for j in range(len(T)):
    if S[i+j] == T[j]:
      cnt += 1
    max_cnt = max(max_cnt, cnt)
print(len(T) - max_cnt)

Failing test case input:
ccbaac
aac

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
S = input()
T = input()

max_cnt = 0
for i in range(len(S)-len(T)+1):
  cnt = 0
  for j in range(len(T)):
    if S[i+j] == T[j]:
      cnt += 1
    max_cnt = max(max_cnt, cnt)
print(len(T) - max_cnt)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()
N, M = len(S), len(T)
S += "_" * M
ma = 0
for i in range(N):
    c = 0
    for j in range(M):
        if S[i+j] == T[j]:
            c += 1
    ma = max(ma, c)

print(M - ma)

Failing test case input:
cpfedsqaeo
btdqep_

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
S = input()
T = input()
N, M = len(S), len(T)
ma = 0
for i in range(N-M+1):
    c = 0
    for j in range(M):
        if S[i+j] == T[j]:
            c += 1
    ma = max(ma, c)

print(M - ma)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S = input()
T = input()


max_diff = 0
window = len(T)
for i in range(0, len(S) - window + 1):
    x = S[i: i+window]
    count = 0
    for a, b in zip(T, x):
        if a != b:
            count += 1
    max_diff = max(count, max_diff)
print(max_diff)

Failing test case input:
cpfedsqbdo
paeqdtb

Expected output:
4


Actual output:
7


Fixed submission (verdict: Accepted):
S = input()
T = input()


min_diff = 10000
window = len(T)
for i in range(0, len(S) - window + 1):
    x = S[i: i+window]
    count = 0
    for a, b in zip(T, x):
        if a != b:
            count += 1
    min_diff = min(count, min_diff)
print(min_diff)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()
ans = len(S)
for i in range(len(T)):
    c = 0
    for j in range(i, len(S)):
        if T[i] == S[j]:
            c += 1
    tmp = len(T) - c
    ans = min(ans, tmp)
print(ans)

Failing test case input:
cpdefsqbeo
ctdqfao

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
S = input()
T = input()
ans = len(T)
for i in range(len(S)-len(T)+1):
    c = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            c += 1
    ans = min(ans, c)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
minr = len(t)
s_t_d = len(s) - len(t)
for i in range(s_t_d):
    cnt = 0
    for ss, ts in zip(s[i:i + len(t)], t):
        if ss != ts:
            cnt += 1
    minr = min(minr, cnt)
print(minr)

Failing test case input:
codefsqceo
atdrceo

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
t = input()
minr = len(t)
s_t_d = len(s) - len(t)
for i in range(s_t_d + 1):
    cnt = 0
    for ss, ts in zip(s[i:i + len(t)], t):
        if ss != ts:
            cnt += 1
    minr = min(minr, cnt)
print(minr)
Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def resolve():
    S = input()
    T = input()
    mincnt = float("inf")
    for ptr in range(len(S)-len(T)):
        cnt = 0
        for i in range(len(T)):
            sptr = ptr + i
            if S[sptr] != T[i]:
                cnt += 1
        mincnt = min(cnt, mincnt)
    print(mincnt)



    
if '__main__' == __name__:
    resolve()

Failing test case input:
oeaqsdefpc
btdqep_

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
def resolve():
    S = input()
    T = input()
    mincnt = float("inf")
    for ptr in range(len(S)-len(T)+1):
        cnt = 0
        for i in range(len(T)):
            sptr = ptr + i
            if S[sptr] != T[i]:
                cnt += 1
        mincnt = min(cnt, mincnt)
    print(mincnt)



    
if '__main__' == __name__:
    resolve()

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def core(s, t):
  if t in s:
    return 0
  for i in range(1, len(t)):
    for j in range(i+1):
      tempt = t[j:len(t)-i+j]
      temps = s[j:len(s)-i+j]
      if tempt in temps:
        return i
  return len(t)
  
if __name__ == "__main__":
  strings = [input() for i in range(2)]
  print(core(strings[0], strings[1]))


Failing test case input:
cpdefsqceo
atdrfco

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
def core(s, t):
  result = len(t)
  for start in range(len(s) - len(t) + 1):
    diff = 0
    for i in range(len(t)):
      if t[i] != s[start + i]:
        diff += 1
    result = min([diff, result])
  
  return result
if __name__ == "__main__":
  strings = [input() for i in range(2)]
  print(core(strings[0], strings[1]))

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

S = input()
T = input()
ans = []
for i in range(0, (len(S)-len(T) + 1)):
    if S[i] == T[0]:
        tmp = 0
        for j in range(1, len(T)):
            if T[j] != S[i + j]:
                tmp += 1
        ans.append(tmp)
        
print(min(ans)) if len(ans) != 0 else print(len(T))
        

Failing test case input:
caacbc
baa

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):

S = input()
T = input()
ans = []
for i in range(0, (len(S)-len(T) + 1)):
    tmp = 0
    
    for j in range(0, len(T)):
        if T[j] != S[i +j]:
            tmp += 1
            
        
    ans.append(tmp)
        
print(min(ans))

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
T=input()
k = len(T)
ans=k
lim=0
for i in range(len(S)-len(T)+1):
  for j in range(k):
    if S[i+j]==T[j]:
      lim+=1
  if lim<=ans:
    ans=len(T)-lim
  lim=0
print(ans)

Failing test case input:
cbacbc
b`a

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
S=input()
T=input()
k = len(T)
ans=k
lim=0
for i in range(len(S)-len(T)+1):
  for j in range(k):
    
    if S[i+j]!=T[j]:
      lim+=1
  if lim<=ans:
    ans=lim
  lim=0
print(ans)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
ans = len(s)
for i in range(len(s)-len(t)):
    diff = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            diff+=1
    ans = min(diff,ans)
print(ans)

Failing test case input:
cbc`cd
`aa

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
    diff = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            diff+=1
    ans = min(diff,ans)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
t=input()
ans = 0
c = 0
m = 1001

for i in range(len(s)-len(t)+1):
    tmp = s[i:i+len(t)]
    
    for j in range(len(t)):
        
        if tmp[j] != t[j]:
            c+=1
        
    if m > c:
        ans = c
    c=0

print(ans)

Failing test case input:
cacabc
`ab

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
s=input()
t=input()
ans = 0
c = 0
m = 1001

for i in range(len(s)-len(t)+1):
    tmp = s[i:i+len(t)]
    
    for j in range(len(t)):
        
        if tmp[j] != t[j]:
            c+=1
        
    if m > c:
        m = c
        ans = c
    c=0

print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

s = len(S)
t = len(T)

ans = 0

for i in range(s - t + 1):
    c = 0
    for j in range(t):
        if S[i + j] == T[j]:
            c += 1
    ans = max(ans, c)

print(t - c)

Failing test case input:
cc`cbc
ba`

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
S = input()
T = input()

s = len(S)
t = len(T)

ans = 0

for i in range(s - t + 1):
    c = 0
    for j in range(t):
        if S[i + j] == T[j]:
            c += 1
    ans = max(ans, c)

print(t - ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

def main():
    S = sys.stdin.readline().rstrip()
    T = sys.stdin.readline().rstrip()

    ans = len(T)

    for i in range(len(S) - len(T)):
        cnt = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)

    print(ans)


main()

Failing test case input:
cbc`cd
`aa

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import sys


def main():
    S = sys.stdin.readline().rstrip()
    T = sys.stdin.readline().rstrip()

    ans = len(T)

    for i in range(len(S) - len(T) + 1):
        cnt = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)

    print(ans)


main()
Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
n = len(s)
t = list(input())
m = len(t)
res = n
for i in range(n):
    if i+m > n: break
    cnt = 0
    for j in range(m):
        if s[i+j] != t[j]:
            cnt += 1
    res = min(res, cnt)
print(cnt)

Failing test case input:
fabccc
aac

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
n = len(s)
t = list(input())
m = len(t)
res = m
for i in range(n):
    if i+m > n: break
    cnt = 0
    for j in range(m):
        if s[i+j] != t[j]:
            cnt += 1
    res = min(res, cnt)
print(res)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
T=input()
count=0
min=1000000
for i in range(len(S)):
    count = 0
    if i + len(T) < len(S):
        for j in range(len(T)):
            if T[j] != S[i + j]:
                count += 1
    else:
        break

    if count<min:
        min=count

print(min)

Failing test case input:
cbc`cd
`ab

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
S=input()
T=input()
count=0
min=1000000
for i in range(len(S)):
    count = 0
    if i + len(T) <= len(S):
        for j in range(len(T)):
            if T[j] != S[i + j]:
                count += 1
    else:
        break

    if count<min:
        min=count

print(min)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

n, m = len(S), len(T)
maximum = 0
for i in range(n - m):
    count = 0
    for j in range(m):
        if S[j + i] == T[j]:
            count += 1
    maximum = max(maximum, count)

ans = m - maximum

print(ans)

Failing test case input:
apfeeqsceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
S = input()
T = input()

n, m = len(S), len(T)
maximum = 0
for i in range(n - m + 1):
    count = 0
    for j in range(m):
        if S[j + i] == T[j]:
            count += 1
    maximum = max(maximum, count)

ans = m - maximum

print(ans)
Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S = list(input())
T = list(input())
defolt = 1000
for i in range(len(S)-len(T)):
    ans = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            ans += 1
    defolt = min(defolt,ans)
print(defolt)

Failing test case input:
apfedqsceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
S = list(input())
T = list(input())
defolt = 1000
for i in range(len(S)-len(T)+1):
    ans = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            ans += 1
    defolt = min(defolt,ans)
print(defolt)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a = input()
b = input()

l = []
for i in range(len(a)):
    cnt = 0
    for j in range(len(b)):
        if i + j < len(a) and b[j] == a[i + j]:
            cnt += 1
    l.append(cnt)


print(len(b) - max(l))

Failing test case input:
oeectfpcat
albs`tb

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
a = input()
b = input()

l = []
for i in range(len(a) - len(b) + 1):
    cnt = 0
    for j in range(len(b)):
        if b[j] == a[i + j]:
            cnt += 1
    l.append(cnt)


print(len(b) - max(l))

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s = input()
t = input()

slen = len(s)
tlen = len(t)

now = 0

for i in range(slen):
    count=0
    for j in range (tlen):
        if i + j > slen-1:
            continue
        if (s[i+j]) == t[j]:
            count+=1
    if now < count:
        now = count

print(tlen-now)


Failing test case input:
oeectfpcat
albs`tb

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
t = input()

slen = len(s)
tlen = len(t)

now = 0
fg=0

for i in range(slen):
    count=0
    for j in range (tlen):
        if i + j > slen-1:
            fg = 1
            continue
        if (s[i+j]) == t[j]:
            count+=1
    if fg == 1:
        break
    if now < count:
        now = count

print(tlen-now)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
S = input()
T = input()
score_list = []
for i in range(len(S) - len(T) + 1):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_list))


Failing test case input:
cbbaac
caa

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
S = input().strip()
T = input().strip()
score_list = []
for i in range(len(S) - len(T) + 1):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_list))
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
ans = 10**10
l = len(s) - len(t)
for i in range(l):
  tans = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      tans += 1
  ans = min(ans, tans)
print(ans)

Failing test case input:
apfedsqceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
s = input()
t = input()
ans = 10**10
l = len(s) - len(t) + 1
for i in range(l):
  tans = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      tans += 1
  ans = min(ans, tans)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

S = input()
T = input()
def counter(A,B):
    tmp = 0
    for j in range(len(A)):
        if A[j]==B[j]:
            tmp += 1
    return tmp
result = 0
for i in range(len(S)-len(T)):
    kaburi = counter(S[i:i+len(T)],T)
    if kaburi > result:
        result = kaburi
print(len(T)-result)

Failing test case input:
apfedqsceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):

S = input()
T = input()
def counter(A,B):
    tmp = 0
    for j in range(len(A)):
        if A[j]==B[j]:
            tmp += 1
    return tmp
result = 0
if S == T:
    result = len(T)
else:
    for i in range(len(S)-len(T)+1):
        if counter(S[i:i+len(T)],T) > result:
            result = counter(S[i:i+len(T)],T)
print(len(T)-result)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
T=input()

if T in S:
  print(0)
  exit()

def f(s1,s2):
  print(s1, s2)
  r=0
  for i,j in zip(s1,s2):
    if i != j: r += 1
  return r

a=len(S)
for i in range(len(S)-len(T)+1):
  r = f(S[i:i+len(T)],T)
  if a > r: a = r

print(a)

Failing test case input:
f`bccc
caa

Expected output:
2


Actual output:
f`b caa
`bc caa
bcc caa
ccc caa
2


Fixed submission (verdict: Accepted):
S=input()
T=input()

if T in S:
  print(0)
  exit()

def f(s1,s2):
  r=0
  for i,j in zip(s1,s2):
    if i != j: r += 1
  return r

a=len(S)
for i in range(len(S)-len(T)+1):
  r = f(S[i:i+len(T)],T)
  if a > r: a = r

print(a)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

S = list(S)
T = list(T)

result = len(T)-1
x = 0

for i in range(len(S)-len(T)-1):
    for j in range(len(T)):
        if S[i+j] != T[j]:
            x += 1
    if result > x:
        result = x
    x = 0

print(result)


Failing test case input:
cbbaac
caa

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S = input()
T = input()

S = list(S)
T = list(T)

result = len(T)
x = 0

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] != T[j]:
            x += 1
    if result > x:
        result = x
    x = 0

print(result)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

max_num = 0
count = 0

for i in range(len(S)-len(T)):
  count = 0
  for j in range(len(T)):
    if S[i+j] == T[j]:
      count += 1
  if max_num < count:
    max_num = count
    

print(len(T)-max_num)

Failing test case input:
apfedsqceo
btdqcpa

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
S = input()
T = input()

max_num = 0
count = 0

for i in range(len(S)-len(T)+1):
  count = 0
  for j in range(len(T)):
    if S[i+j] == T[j]:
      count += 1
  if max_num < count:
    max_num = count
    

print(len(T)-max_num)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S = list(input())
T = list(input())
lt = len(T)

result = 10**5
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for s, t in zip(S[i: (i + lt)], T):
        if s != t:
            cnt += 1
    result = max(cnt, result)
print(result)

Failing test case input:
cpdefsqceo
atdrfco

Expected output:
5


Actual output:
100000


Fixed submission (verdict: Accepted):
S = list(input())
T = list(input())
lt = len(T)

result = 10**5
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for s, t in zip(S[i: (i + lt)], T):
        if s != t:
            cnt += 1
    result = min(cnt, result)
print(result)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input();T=input()
N=len(S);M=len(T);fg=0
for j in range(M):
  for i in range(M):
    if T[j:M-i] in S:
      print(i);fg=1;break
  if fg==1:break

Failing test case input:
dc`cbc
`ab

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S=input();T=input()
N=len(S);NP=len(T);M=len(T)
for i in range(N-M+1):
  cnt=0
  for j in range(M):
    if T[j]==S[j+i]:cnt+=1
  if NP>M-cnt: NP=M-cnt
print(NP)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

c = len(S) - len(T)

m = 1000
for i in range(c):
    count = 0
    for s, t in zip(S[i:], T):
        if s != t:
            count += 1
    m = min(m, count)
print(m)

Failing test case input:
e`bccc
caa

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
S = input()
T = input()

c = len(S) - len(T)

m = 10000
for i in range(c + 1):
    count = 0
    for s, t in zip(S[i:], T):
        if s != t:
            count += 1
    m = min(m, count)
print(m)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def cin():  return list(map(int,input().split()))

S = input()
T = input()

ans = 10 ** 9 + 7
l1 = len(S)
l2 = len(T)
for i in range(l1 - l2):
    cnt = 0
    for j in range(l2):
        if S[i + j] != T[j]:  cnt += 1
    ans = min(ans, cnt)
print(ans)

Failing test case input:
ccbaac
aac

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
def cin():  return list(map(int,input().split()))

S = input()
T = input()

ans = 10 ** 9 + 7
l1 = len(S)
l2 = len(T)
for i in range(l1 - l2 + 1):
    cnt = 0
    for j in range(l2):
        if S[i + j] != T[j]:  cnt += 1
    ans = min(ans, cnt)
print(ans)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()

ls = len(s)
lt = len(t)

max_char = lt

for i in range(0, ls - lt):
    s2 = s[i:i + lt]
    count = 0
    for cs, ct in zip(s2, t):
        if cs != ct:
            count += 1
    max_char = min(count, max_char)
print(max_char)


Failing test case input:
oeaqsdefpc
btdqep_

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
t = input()

ls = len(s)
lt = len(t)

max_char = lt

for i in range(0, ls - lt+1):
    s2 = s[i:i + lt]
    
    count = 0
    for cs, ct in zip(s2, t):
        if cs != ct:
            count += 1
    max_char = min(count, max_char)
print(max_char)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
ans = 1000
hoge = 0

s = input()
t = input()

sl = len(s)
tl = len(t)
for i in range(sl-tl):
    for j in range(tl):
        if s[i+j] != t[j]:
            hoge = hoge + 1
    if ans > hoge:
        ans = hoge
    hoge = 0

print(ans)

Failing test case input:
cbc`cd
`aa

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
ans = 1000
hoge = 0

s = input()
t = input()

sl = len(s)
tl = len(t)
for i in range(sl-tl+1):
    hoge = 0
    for j in range(tl):
        if s[i+j] != t[j]:
            hoge = hoge + 1
    if hoge == 0:
        ans = 0
        break
    if ans > hoge:
        ans = hoge
print(ans)
Problem: p03763
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
li = []
ans_li = []
d = {}
for i in range(n):
    li.append(input())

for i in range(ord('a'),ord('z')+1):
    tmp = chr(i)
    d[tmp] = 10**5

for i in range(n):
    for j in range(ord('a'),ord('z')+1):
        tmp = chr(j)
        if li[i].count(tmp) < d[tmp]:
            d[tmp] = li[i].count(tmp)

for kk in d.keys():
    print(kk)
    if d[kk] != 0:
        for i in range(d[kk]):
            ans_li.append(kk)

print("".join(sorted(ans_li)))


Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
aac


Fixed submission (verdict: Accepted):
n = int(input())
li = []
ans_li = []
d = {}
for i in range(n):
    li.append(input())

for i in range(ord('a'),ord('z')+1):
    tmp = chr(i)
    d[tmp] = 10**5

for i in range(n):
    for j in range(ord('a'),ord('z')+1):
        tmp = chr(j)
        if li[i].count(tmp) < d[tmp]:
            d[tmp] = li[i].count(tmp)

for kk in d.keys():
    if d[kk] != 0:
        for i in range(d[kk]):
            ans_li.append(kk)

print("".join(sorted(ans_li)))

Problem: p03763
Buggy submission (Python (3.4.3), verdict: Wrong Answer):





n=int(input())
S=[input() for i in range(n)]
alphabet_dict={chr(97+i):100 for i in range(26)}
for s in S:
	temp={chr(97+i):0 for i in range(26)}
	for i in s:
		temp[i]+=1
	for key in alphabet_dict.keys():
		if alphabet_dict[key]>temp[key]:
			alphabet_dict[key]=temp[key]
result=""
for item in alphabet_dict.items():
	for i in range(item[1]):
		result+=item[0]
print(alphabet_dict)





Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
{'a': 2, 'b': 0, 'c': 1, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}


Fixed submission (verdict: Accepted):






n=int(input())
S=[input() for i in range(n)]
alphabet_dict={chr(97+i):100 for i in range(26)}
for s in S:
	temp={chr(97+i):0 for i in range(26)}
	for i in s:
		temp[i]+=1

	for key in alphabet_dict.keys():
		if alphabet_dict[key]>temp[key]:
			alphabet_dict[key]=temp[key]
result=""
alphabet=[chr(97+i) for i in range(26)]
for item in alphabet:
	for i in range(alphabet_dict[item]):
		result+=item
if result=="":
	print("\n")
else:
	print(result)

Problem: p03763
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
Sn = [input() for i in range(n)]

res = []


for s in Sn:
    res = list(set(s) - set(res))

result = ""
for r in res:
    tmp = 10000
    for s in Sn:
        tmp = min(tmp, s.count(r))
    result += r*tmp
    
print(result)




Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
caa


Fixed submission (verdict: Accepted):
n = int(input())
Sn = [input() for i in range(n)]

res = []


for s in Sn:
    res = sorted(list(set(s) or set(res)))

result = ""
for r in res:
    tmp = 10000
    for s in Sn:
        tmp = min(tmp, s.count(r))
    result += r*tmp

print(result)
Problem: p03763
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

def solve():
    N = int(input())
    
    counter = Counter(input())
    for _ in range(N-1):
        counter_ = Counter(input())
        counter = {k:min(counter[k],counter_[k]) for k in counter_.keys() & counter.keys()}
        
    print(''.join([k*v for k,v in counter.items()]))
    
solve()

Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
caa


Fixed submission (verdict: Accepted):
from collections import Counter

def solve():
    N = int(input())
    
    counter = Counter(input())
    for _ in range(N-1):
        counter_ = Counter(input())
        counter = {k:min(counter[k],counter_[k]) for k in counter_.keys() & counter.keys()}
        
    print(''.join([k*v for k,v in sorted(counter.items())]))
    
solve()

Problem: p03763
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
count_maps = [{} for i in range(N)]
for i in range(N):
        S = input()
        for c in S:
            if c in count_maps[i]:
                count_maps[i][c] += 1
            else:
                count_maps[i][c] = 1
                
ans = ""
for c in count_maps[0].keys():
    max_inclusion = count_maps[0][c]
    for i in range(N):
        if c in count_maps[i]:
            max_inclusion = min(max_inclusion, count_maps[i][c])
        else:
            max_inclusion = 0
            break
    ans += c * max_inclusion
      
print(ans)

Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
caa


Fixed submission (verdict: Accepted):
N = int(input())
count_maps = [{} for i in range(N)]
for i in range(N):
        S = input()
        for c in S:
            if c in count_maps[i]:
                count_maps[i][c] += 1
            else:
                count_maps[i][c] = 1
                
ans = ""
for c in count_maps[0].keys():
    max_inclusion = count_maps[0][c]
    for i in range(N):
        if c in count_maps[i]:
            max_inclusion = min(max_inclusion, count_maps[i][c])
        else:
            max_inclusion = 0
            break
    ans += c * max_inclusion
      
print("".join(sorted(list(ans))))

Problem: p03763
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
dic = {}
for i in range(n):
    s = input()
    c = Counter(s)
    for k, v in c.items():
        if i == 0:
            dic[k] = v
        else:
            dic[k] = min(dic[k], v) if k in dic else 0
ans =''
for k, v in sorted(dic.items()):
    ans += k * v
print(ans)

Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
aabc


Fixed submission (verdict: Accepted):

from collections import Counter
n = int(input())
dic = {}
for i in range(n):
    s = input()
    c = Counter(s)
    for j in range(26):
        x = chr(ord('a') + j)
        if i == 0:
            dic[x] = c[x] if x in c else 0
        else:
            dic[x] = min(dic[x], c[x]) if x in dic else 0
ans = ''
for k, v in sorted(dic.items()):
    ans += k * v
print(ans)
Problem: p03763
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter

n = int(input())
C = [Counter(input()) for _ in range(n)]
ret = ''
for k, v in C[0].items():
  count = v
  for c in C[1:]:
    count = min(c.get(k, 0), count)
  if count > 0:
    ret += k * count
print(ret)

Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
caa


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())
C = [Counter(input()) for _ in range(n)]
ret = ''
for k, v in C[0].items():
  count = v
  for c in C[1:]:
    count = min(c.get(k, 0), count)
  if count > 0:
    ret += k * count
print(''.join(sorted(ret)))

Problem: p03763
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = [input() for i in range(n)]
ans = [float("inf")] * 26
for i in range(n):
  tmp = [0] * 26
  for j in s[i]:
    tmp[ord(j)-ord("a")] += 1
  for j in range(26):
    ans[j] = min(ans[j],tmp[j])
res = 0
for j in ans:
  if j != float("inf"):
    res += j
print(res)

Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
s = [input() for i in range(n)]
ans = [float("inf")] * 26
for i in range(n):
  tmp = [0] * 26
  for j in s[i]:
    tmp[ord(j)-ord("a")] += 1
  for j in range(26):
    ans[j] = min(ans[j],tmp[j])
res = ""
for j in range(26):
  if ans[j] != float("inf"):
    res += chr(97+j)*ans[j]
print(res)

Problem: p03763
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

n = int(input())
S = [input() for i in range(n)]

counter = [defaultdict(lambda: 0) for i in range(n)]
for i in range(n):
    for c in S[i]:
        counter[i][c] += 1
        
all_counter = defaultdict(lambda: 0)
for s in counter[0]:
    all_counter[s] += counter[0][s]
    
for i in range(1,n):
    for s in all_counter:
        if counter[i][s] != 0 and all_counter[s] != 0:
            all_counter[s] = min(counter[i][s], all_counter[s])
        else:
            all_counter[s] = 0
    
for s in all_counter:
    print(s* all_counter[s], end='')

Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
caa

Fixed submission (verdict: Accepted):
from collections import defaultdict

n = int(input())
S = [input() for i in range(n)]

counter = [defaultdict(lambda: 0) for i in range(n)]
for i in range(n):
    for c in S[i]:
        counter[i][c] += 1
        
all_counter = defaultdict(lambda: 0)
for s in counter[0]:
    all_counter[s] += counter[0][s]
    
for i in range(n):
    for s in all_counter:
        all_counter[s] = min(counter[i][s], all_counter[s])

for s in sorted(all_counter, key=lambda x: x[0]):
    print(s* all_counter[s], end='')