ZhenlongDai/ACPR huggingface dataset:
Problem: p03761
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
d={}
for i in range(n):
    s=input()
    d[i]={}
    for c in s:
        if c in d[i]:
            d[i][c]+=1
        else:
            d[i][c]=1
k={chr(i)for i in range(97,123)}
for e in d:
    k&=set(d[e].keys())
for t in k:
    m=float('inf')
    for e in d:
        m=min(m,d[e][t])
    print(t*m,end='')
print('')


Failing test case input:
3
aaac
cda`c
adacac

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
n=int(input())
d={}
for i in range(n):
    s=input()
    d[i]={}
    for c in s:
        if c in d[i]:
            d[i][c]+=1
        else:
            d[i][c]=1

k={chr(i)for i in range(97,123)}
for e in d:
    k&=set(d[e].keys())

for t in sorted(k):
    m=float('inf')
    for e in d:
        m=min(m,d[e][t])
    print(t*m,end='')
print('')

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

n = int(input())
l = []

for i in range(n):
    s = input()
    l.append(Counter(s))
    
cnt = l[0]
for i in range(1,n):
        cnt = cnt & l[i]
        
if cnt:
    ans = ""
    for k,v in cnt.items():
        ans = k*v + ans
    
    print(ans)    
else:
    print()

Failing test case input:
3
aaac
cda`c
acacac

Expected output:
ac


Actual output:
ca


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

n = int(input())
l = []

for i in range(n):
    s = input()
    l.append(Counter(s))
    
cnt = l[0]
for i in range(1,n):
        cnt = cnt & l[i]
        
print("".join(sorted(cnt.elements())))

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
strings = [list(input()) for _ in range(n)]

s_1 = list(strings.pop(0))
for s in strings:
    for s_tmp in s_1:
        tmp = []
        if s_tmp in s:
            tmp.append(s_tmp)
            s.remove(s_tmp)
    else:
        s_1 = tmp
s_1.sort()
print(''.join(s_1))

Failing test case input:
3
caaa
cca`d
acacac

Expected output:
ac


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
strings = [list(input()) for _ in range(n)]

s_1 = list(strings.pop(0))
for s in strings:
    tmp = []
    for s_tmp in s_1:
        if s_tmp in s:
            tmp.append(s_tmp)
            s.remove(s_tmp)
    else:
        s_1 = tmp
s_1.sort()
print(''.join(s_1))
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
    N = int(input())
    dics = [0]*N
    S = [input() for _ in range(N)]
    for i in range(N):
        dics[i] = defaultdict(lambda:0)
        for s in S[i]:
            dics[i][s] += 1
    ans = ''
    for k,v in sorted(dics[0].items()):
        mincnt = v
        for i in range(1,N):
            mincnt = min(v,dics[i][k])
        ans += k*mincnt
    for i in range(len(ans),-1,-1):
        for p in permutations(list(ans),i):
            string = ''.join(list(p))
            if string not in S:
                return string
print(solve())

Failing test case input:
3
_a_b
c_bcb
abcada

Expected output:
b


Actual output:
ab


Fixed submission (verdict: Accepted):
from itertools import groupby, accumulate, product, permutations, combinations
from collections import Counter
def solve():
    N = int(input())
    dics = [0]*N
    S = [input() for _ in range(N)]
    dic = Counter(S[0])
    for i in range(1,N):
        new_dic = Counter(S[i])
        for k in dic.keys():
            if k in new_dic:
                dic[k] = min(dic[k],new_dic[k])
            else:
                dic[k] = 0
    ans = ''
    for k,v in sorted(dic.items()):
        ans += k*v
    return ans
print(solve())

Problem: p03761
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
ans = list(input())
for i in range(n-1):
    s = list(input())
    for j in ans:
        if j in s:
            s.remove(j)
        else:
            ans.remove(j)
ans.sort()
print("".join(ans))

Failing test case input:
3
acaa
bcb_c
c`acca

Expected output:
c


Actual output:
ac


Fixed submission (verdict: Accepted):
n = int(input())
ans = list(input())
for i in range(n-1):
    s = list(input())
    t = []
    for j in ans:
        if j in s:
            s.remove(j)
            t.append(j)
    ans = t
ans.sort()
print("".join(ans))

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
data = [k for k in input()]

ans = Counter(data)
for i in range(n-1):
  tmp = Counter([k for k in input()])
  for j in set(data):
    ans[j] = min(ans[j], tmp[j])
ans_list = list(ans.elements())
ans_list.sort()
answer = ""
for i in ans_list:
  answer += i*ans[i]

Failing test case input:
3
aaac
cca`d
cacaca

Expected output:
ac


Actual output:

Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
data = [k for k in input()]

ans = Counter(data)
for i in range(n-1):
  tmp = Counter([k for k in input()])
  for j in set(data):
    ans[j] = min(ans[j], tmp[j])

ans_list = list(set(list(ans.elements())))
ans_list.sort()
answer = ""
for i in ans_list:
  answer += i*ans[i]
print(answer)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
d = defaultdict(int)

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

for s in S[0]:
  d[s] += 1

for s in S:
  k = defaultdict(int)

  for i in s:
    k[i] += 1

  for t in k:
    if d[i] != 0 and d[i] > k[i]:
      d[i] = k[i]

  for t in d:
    if k[t] == 0:
      d[t] = 0

li = sorted(d)
ans = ""
for i in li:
  if d[i] == 0:
    continue

  ans += i * d[i]

ans = sorted(ans)
ans = "".join(ans)
print(ans)

Failing test case input:
3
cbaa
d`acc
acacac

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
from collections import defaultdict
d = defaultdict(int)

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

for s in S[0]:
  d[s] += 1

for index, s in enumerate(S):
  if index == 0:
    continue
  
  k = defaultdict(int)

  for i in s:
    k[i] += 1

  for t in k:
    if d[t] > k[t]:
      d[t] = k[t]

  for t in d:
    if k[t] == 0:
      d[t] = 0

ans = ""
for i in d:
  if d[i] == 0:
    continue

  ans += i * d[i]

ans = sorted(ans)
ans = "".join(ans)
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = []
for i in range(n):
    s.append(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
    cnt = 0
    for ss in s:
        cnt = min(cnt,ss.count(a))
    for i in range(cnt):
        ans += a
print(ans)


Failing test case input:
3
aad_
bdb_c
ababcd

Expected output:
d


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
s = []
for i in range(n):
    s.append(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
    cnt = 1e10
    for ss in s:
        cnt = min(cnt,ss.count(a))
    for i in range(cnt):
        ans += a
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ns = list(list(input()) for i in range(n))
ns_set = set()
for i in range(n):
    ns_set |= set(ns[i])
from collections import defaultdict
dic = defaultdict(lambda : 50)
for i in range(n):
    for s in ns_set:
        if s in ns[i]:
            dic[s] = min(dic[s], ns[i].count(s))
        else:
            dic[s] = 0
result = ''
for key, value in dic.items():
    result += key*value
print(result)

Failing test case input:
3
caaa
cca`d
acacac

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
n = int(input())
ns = list(list(input()) for i in range(n))
ns_set = set()
for i in range(n):
    ns_set |= set(ns[i])
from collections import defaultdict
dic = defaultdict(lambda : 50)
for i in range(n):
    for s in ns_set:
        if s in ns[i]:
            dic[s] = min(dic[s], ns[i].count(s))
        else:
            dic[s] = 0
result = ''
for key, value in sorted(dic.items(), key=lambda x: x[0]):
    result += key*value
print(result)
Problem: p03761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
words = []
for i in range(n):
  words.append(input())
for i in words:
  i = sorted(i)
words = sorted(words)
word = ""
for i in words[0]:
  if i not in word:
    word+=i
result = ""
for i in word:
  minim = 51
  for j in words:
    if j.count(i)<minim:
      minim = j.count(i)
  result+=i*minim
print(result)

Failing test case input:
3
acba
da`cb
acacbc

Expected output:
abc


Actual output:
acb


Fixed submission (verdict: Accepted):
n = int(input())
words = []
for i in range(n):
  words.append(input())
for i in words:
  i = "".join(sorted(i))
words = sorted(words)
word = ""
for i in words[0]:
  if i not in word:
    word+=i
result = ""
for i in word:
  minim = 51
  for j in words:
    if j.count(i)<minim:
      minim = j.count(i)
  result+=i*minim
result = "".join(sorted(result))
print(result)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
if N == 1:
    u = ''.join(sorted(list(input())))
    print(u)
else:
    os = input()
    news = ''
    l = [0] * len(os)
    for _ in range(N-1):
        s = input()
        for i,c in enumerate(os):
            for j,d in enumerate(s):
                if c == d:
                    if j in l:pass
                    else:
                        l[i] = j
                        news = news + c
                        break
        os = news
        news = ''
        l = [0] * len(os)
    u = ''.join(sorted(list(os)))
    print(u)

Failing test case input:
3
_ab_
bda_c
aacadb

Expected output:
ab


Actual output:
a


Fixed submission (verdict: Accepted):
N = int(input())
if N == 1:
    u = ''.join(sorted(list(input())))
    print(u)
else:
    os = input()
    news = ''
    l = [-1] * len(os)
    for _ in range(N-1):
        s = input()
        for i,c in enumerate(os):
            for j,d in enumerate(s):
                if c == d:
                    if j in l:pass
                    else:
                        l[i] = j
                        news = news + c
                        break
        os = news
        news = ''
        l = [-1] * len(os)
    u = ''.join(sorted(list(os)))
    print(u)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = [input() for _ in range(n)]
a = "abcdefghijklmnopqrstuvwxyz"
cnt = []
for i in a:
    mi = 50
    for j in s:
        print(i, j, j.count(i))
        mi = min(mi, j.count(i))
    cnt.append(mi)
ans = ""
for i in range(26):
    ans += a[i] * cnt[i]
print(ans)


Failing test case input:
3
caaa
ccb_c
abaacd

Expected output:
c


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


Fixed submission (verdict: Accepted):
n = int(input())
s = [input() for _ in range(n)]
a = "abcdefghijklmnopqrstuvwxyz"
cnt = []
for i in a:
    mi = 50
    for j in s:
        mi = min(mi, j.count(i))
    cnt.append(mi)
ans = ""
for i in range(26):
    ans += a[i] * cnt[i]
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
alphabet = Counter(input())
for i in range(n-1):
  s = Counter(input())
  for x in alphabet:
    if alphabet[x] > s[x]:
      alphabet[x] = s[x]
ans = str()
for key, value in alphabet.items():
  ans = key*value + ans
print(ans)

Failing test case input:
3
ba`c
bcb`c
abdbcb

Expected output:
bc


Actual output:
cb


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
alphabet = Counter(input())
for i in range(n-1):
  s = Counter(input())
  for x in alphabet:
    if alphabet[x] > s[x]:
      alphabet[x] = s[x]
print("".join(sorted(alphabet.elements())))
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

s = [input() for i in range(n)]

sort_s = []

for i in range(n):
    sort_s.append(sorted(s[i]))
    
onaji = sort_s[0]
new = []
tmp = 0

for i in range(1,n):
    new = []
    
    for j in range(len(onaji)):
        tmp = 0
        for k in range(len(s[i])):
            
            if tmp+k >= len(s[i]):
                break
            if onaji[j] == sort_s[i][tmp+k]:
                new.append(onaji[j])
                tmp = k+1
                break
    
    onaji = new
    
            
print(*onaji,sep="")

Failing test case input:
3
caca
cca`d
acacac

Expected output:
acc


Actual output:
aacc


Fixed submission (verdict: Accepted):
n = int(input())

s = [input() for i in range(n)]

sort_s = []

for i in range(n):
    sort_s.append(sorted(s[i]))
    
onaji = sort_s[0]
new = []
tmp = 0

for i in range(1,n):
    new = []
    tmp = 0
    
    for j in range(len(onaji)):
        for k in range(len(s[i])):
            
            if tmp+k >= len(s[i]):
                break
            if onaji[j] == sort_s[i][tmp+k]:
                new.append(onaji[j])
                tmp = tmp+k+1
                break
    
    onaji = new
    
            
print(*onaji,sep="")

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

n = int(input())
keys = set()
S = []
ans = {}
for i in range(n):
    counter = Counter(input())
    keys = keys.intersection(counter.keys())
    for k in keys:
        ans[k] = min(ans.get(k, 100), counter[k])

s = ''
for k in ans.keys():
    s += k * ans[k]
s = sorted(s)
sa = ''
for i in s:
    sa += i
print (sa)

Failing test case input:
3
caaa
bcb_c
acaacc

Expected output:
c


Actual output:

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

n = int(input())
keys = set()
S = []
ans = {}
for i in range(n):
    counter = Counter(input())
    if i == 0:
        keys = set(counter.keys())
    else:
        keys = keys.intersection(counter.keys())
    tmp = {}
    for k in keys:
        tmp[k] = min(ans.get(k, 100), counter[k])
    ans = tmp
        
s = ''
for k in ans.keys():
    s += k * ans[k]
s = sorted(s)
sa = ''
for i in s:
    sa += i
print (sa)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = [input() for _ in range(n)]
l = [""]
for i in s[0]:
    
    if all(i in s[j] for j in range(n)):
        l.append(i)
    
    
print("".join(sorted(l)))

Failing test case input:
3
caaa
daacc
cacaca

Expected output:
aac


Actual output:
aaac


Fixed submission (verdict: Accepted):
n = int(input())
s = [input() for _ in range(n)]
t = ""
for i in set(s[0]):
    
    if all(i in s[j] for j in range(n)):
        t += i * min(s[k].count(i) for k in range(len(s)))
    
    
print(''.join(sorted(t)))
Problem: p03761
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter

n = int(input())
s = [Counter(input()) for _ in range(n)]

cnt = s[0]
for scnt in s:
    for str in (scnt | cnt):
        print(str)
        cnt[str] = min(cnt[str], scnt[str])

a = ord('a')
ans = [chr(a + i) * cnt[chr(a + i)] for i in range(25)]
print(*ans, sep='')


Failing test case input:
3
acaa
bdb`c
acacac

Expected output:
c


Actual output:
a
c
b
d
`
c
a
a
c
c


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

n = int(input())
s = [Counter(input()) for _ in range(n)]

cnt = s[0]
for scnt in s:
    for str in (scnt | cnt):
        cnt[str] = min(cnt[str], scnt[str])

a = ord('a')
ans = [chr(a + i) * cnt[chr(a + i)] for i in range(26)]
print(*ans, sep='')

Problem: p03761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
words = []
for i in range(n):
  words.append(input())
for i in words:
  i = sorted(i)

word = ""
for i in words[0]:
  if i not in word:
    word+=i
result = ""
for i in word:
  minim = 51
  for j in words:
    if j.count(i)<minim:
      minim = j.count(i)
  result+=i*minim
print(result)

Failing test case input:
3
caaa
cda`c
acacac

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
n = int(input())
words = []
for i in range(n):
  words.append(input())
for i in words:
  i = "".join(sorted(i))
words = sorted(words)
word = ""
for i in words[0]:
  if i not in word:
    word+=i
result = ""
for i in word:
  minim = 51
  for j in words:
    if j.count(i)<minim:
      minim = j.count(i)
  result+=i*minim
result = "".join(sorted(result))
print(result)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s =[[0]*26 for i in range(n)]
a =[0]*26
sa=''
for i in range(n):
    s1=list(input())
    for j in s1:
        s[i][ord(j)-ord('a')]+=1
for j in range(26):
    for i in range(n):
        if a[j]==0:
            a[j]=s[i][j]
        elif a[j]>s[i][j]:
            a[j]=s[i][j]
for i in range(26):
    sa+=chr(ord('a')+i)*a[i]
print(sa)


Failing test case input:
3
c`aa
bc_bc
acaacc

Expected output:
c


Actual output:
aaac


Fixed submission (verdict: Accepted):
n = int(input())
s =[[0]*26 for i in range(n)]
a =[50]*26
sa=''
for i in range(n):
    s1=list(input())
    for j in s1:
        s[i][ord(j)-ord('a')]+=1
for j in range(26):
    for i in range(n):
        if a[j]>s[i][j]:
            a[j]=s[i][j]
for i in range(26):
    sa+=chr(ord('a')+i)*a[i]
print(sa)
Problem: p03761
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
S_list = []
min_length = 10000
for _ in range(N):
    st = input()
    S_list.append(st)
    min_length = min(min_length, len(st))
char_list = list("abcdefghijklmnopqrstuvwxyz")
total_counter = {char: 1e4 for char in char_list}
for i in range(N):
    string = S_list[i]
    for char in char_list:
        total_counter[char] = min(total_counter[char], string.count(char))


ans = ""
print(total_counter)
for char, count in total_counter.items():
    ans += char*count
    
print(ans)

Failing test case input:
3
aa_c
bcb_c
abaacc

Expected output:
c


Actual output:
{'a': 0, '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}
c


Fixed submission (verdict: Accepted):
N = int(input())
S_list = []
min_length = 10000
for _ in range(N):
    st = input()
    S_list.append(st)
    min_length = min(min_length, len(st))
char_list = list("abcdefghijklmnopqrstuvwxyz")
total_counter = {char: 1e4 for char in char_list}
for i in range(N):
    string = S_list[i]
    for char in char_list:
        total_counter[char] = min(total_counter[char], string.count(char))


ans = ""

for char, count in total_counter.items():
    ans += char*count
    
print(ans)

Problem: p03761
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter
n = int(input())
S = []

for i in range(n):
    s=input()
    S.append(s)
    if i==0:
        res=Counter(list(s))
    else:
        c=Counter(list(s))
        for key in res.keys():
            if key in c.keys():
                res[key] = min(res[key], c[key])
            else:
                res[key] = 0
print(res)
for key in sorted(res.keys()):
    if res[key]>0:
        print(key*res[key],end='')
print('')



Failing test case input:
3
c`aa
bcb_c
acaacc

Expected output:
c


Actual output:
Counter({'c': 1, '`': 0, 'a': 0})
c


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
S = []

for i in range(n):
    s=input()
    S.append(s)
    if i==0:
        res=Counter(list(s))
    else:
        c=Counter(list(s))
        for key in res.keys():
            if key in c.keys():
                res[key] = min(res[key], c[key])
            else:
                res[key] = 0

for key in sorted(res.keys()):
    if res[key]>0:
        print(key*res[key],end='')
print('')
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
data = [k for k in input()]

ans = Counter(data)
for i in range(n-1):
  tmp = Counter([k for k in input()])
  for j in set(data):
    ans[j] = min(ans[j], tmp[j])

ans_list = list(ans.elements())
ans_list.sort()
answer = ""
for i in set(ans_list):
  answer += i*ans[i]
print(answer)

Failing test case input:
3
caaa
d`acc
cacaca

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
data = [k for k in input()]

ans = Counter(data)
for i in range(n-1):
  tmp = Counter([k for k in input()])
  for j in set(data):
    ans[j] = min(ans[j], tmp[j])

ans_list = list(set(list(ans.elements())))
ans_list.sort()
answer = ""
for i in ans_list:
  answer += i*ans[i]
print(answer)

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

n,*S = open(0).read().split()
c = Counter(S[0])
for s in S[1:]:
    temp = Counter(s)
    remove = set()
    for x in c.items():
        if temp[x[0]] > 0:
            c[x[0]] = min(c[x[0]],x[1])
        else:
            remove.add(x[0])
    for x in remove:
        del c[x]
if len(c) == 0:
    print('\n')
else:
    s = sorted([x for x in c.items()])
    ans = []
    for x in s:
        ans.append(x[0]*x[1])
    print(''.join(ans))

Failing test case input:
3
aaca
bda`c
acacac

Expected output:
ac


Actual output:
aaac


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

n,*S = open(0).read().split()
c = Counter(S[0])
for s in S[1:]:
    temp = Counter(s)
    remove = set()
    for x in c.items():
        if temp[x[0]] > 0:
            c[x[0]] = min(c[x[0]],temp[x[0]])
        else:
            remove.add(x[0])
    for x in remove:
        del c[x]
if len(c) == 0:
    print('\n')
else:
    s = sorted([x for x in c.items()])
    ans = []
    for x in s:
        ans.append(x[0]*x[1])
    print(''.join(ans))

Problem: p03761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
Cands = list(input())
for i in range(n-1):
  temp = []
  S = list(input())
  for cand in Cands:
    if cand in S:
      temp.append(cand)
  Cands = temp
Cands = sorted(Cands)
print(*Cands, sep="")

Failing test case input:
3
caa`
`cacd
cacaca

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
n = int(input())
Cands = list(input())
for i in range(n-1):
  temp = []
  S = list(input())
  for cand in Cands:
    if cand in S:
      temp.append(cand)
      S.pop(S.index(cand))
  Cands = temp
Cands = sorted(Cands)
print(*Cands, sep="")
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

s = []
for i in range(n):
    s.append(input())

ans = ""

for i in range(len(s[0])):
    check = 0
    for j in range(1,n):
        if not s[0][i] in s[j]:
            check = 1
    if check == 0:
        ans = ans + s[0][i]

ans = ''.join(sorted(ans))
print(ans)

Failing test case input:
3
caaa
d`acc
cabaca

Expected output:
ac


Actual output:
aaac


Fixed submission (verdict: Accepted):
n = int(input())

s = []
for i in range(n):
    s.append(input())

ans = ""

for i in range(len(s[0])):
    check = 0
    for j in range(n):
        if not s[0][i] in s[j]:
            check = 1
    if check == 0:
        ans = ans + s[0][i]
        for j in range(1,n):
            re = s[0][i]
            s[j] = s[j].replace(re , '', 1)

ans = ''.join(sorted(ans))
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = [input() for _ in range(n)]
l = []
for i in s[0]:
    
    if all(i in s[j] for j in range(n)):
        l.append(i)
    
    
print("".join(sorted(l)))

Failing test case input:
3
aabc
bda`c
acacac

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
n = int(input())
s = [input() for _ in range(n)]
t = ""
for i in set(s[0]):
    
    if all(i in s[j] for j in range(n)):
        t += i * min(s[k].count(i) for k in range(len(s)))
    
    
print(''.join(sorted(t)))

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

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for (word, cnt)in counter.items():
    ans=ans+word*cnt

print(str(ans))

Failing test case input:
3
caa`
`cacd
cacaca

Expected output:
ac


Actual output:
ca


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

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for c in [chr(i) for i in range(ord('a'), ord('z')+1)]:
    ans=ans+c*counter[c]
print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

n = int(input())
s = [input() for i in range(n)]
if n == 1:
    print("".join(sorted(s[0])))
else:
    c = []
    for i in s:
        c.append(collections.Counter(i))
    a = c[0]
    for i in range(1, n):
        a &= c[i]
    ans = []
    a = a.most_common()
    print(a)
    
    for i in a:
        for j in range(i[1]):
            ans.append(i[0])
    print("".join(sorted(ans)))

Failing test case input:
3
caab
d`acc
cacaca

Expected output:
ac


Actual output:
[('c', 1), ('a', 1)]
ac


Fixed submission (verdict: Accepted):
import collections

n = int(input())
s = [input() for i in range(n)]
if n == 1:
    print("".join(sorted(s[0])))
else:
    c = []
    for i in s:
        c.append(collections.Counter(i))
    a = c[0]
    for i in range(1, n):
        a &= c[i]
    ans = []
    a = a.most_common()
    
    for i in a:
        for j in range(i[1]):
            ans.append(i[0])
    print("".join(sorted(ans)))

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[list(map(str,input().split())) for i in range(n)]


ans=[]
cnt=0

for i in range(len(a[0][0])):
    cnt=0
    for k in range(1,n):
        if (a[0][0][i] in a[k][0]):
            cnt+=1
    if cnt==n-1:
        ans.append(a[0][0][i])
ans.sort()
res=''
for x in ans:
    res+=x
print(res)

Failing test case input:
3
aaca
bda`c
cacaca

Expected output:
ac


Actual output:
aaac


Fixed submission (verdict: Accepted):
n=int(input())
a=[list(map(str,input().split())) for i in range(n)]


ans=[]
cnt=0






for i in range(len(a[0][0])):
    cnt=0
    for k in range(1,n):
        if (a[0][0][i] in a[k][0]):
            a[k][0]=a[k][0].replace(a[0][0][i],'',1)
            
            cnt+=1
            
    if cnt==n-1:
        ans.append(a[0][0][i])
ans.sort()
res=''
for x in ans:
    res+=x
print(res)

Problem: p03761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
words = []
for i in range(n):
  words.append(input())
for i in words:
  i = "".join(sorted(i))
words = sorted(words)
word = ""
for i in words[0]:
  if i not in word:
    word+=i
result = ""
for i in word:
  minim = 51
  for j in words:
    if j.count(i)<minim:
      minim = j.count(i)
  result+=i*minim
print(result)

Failing test case input:
3
caaa
d`acc
cacaca

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
n = int(input())
words = []
for i in range(n):
  words.append(input())
for i in words:
  i = "".join(sorted(i))
words = sorted(words)
word = ""
for i in words[0]:
  if i not in word:
    word+=i
result = ""
for i in word:
  minim = 51
  for j in words:
    if j.count(i)<minim:
      minim = j.count(i)
  result+=i*minim
result = "".join(sorted(result))
print(result)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
         countw += 1
         li[j].replace(w, '', 1)
         break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)

Failing test case input:
3
aaac
c`adc
acacac

Expected output:
ac


Actual output:
aaac


Fixed submission (verdict: Accepted):
N = int(input())
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
        countw += 1
        li[j] = li[j].replace(w, '', 1)
        break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=input()
if n!=1:
  b=input()
  m=[]
  for i in a:
    for j in b:
      if i==j:
        m.append(i)
        break
  for _ in range(n-2):
    s=input()
    l=[]
    for i in m:
      for j in s:
        if i==j:
          l.append(i)
          break
    m=l
  print(''.join(sorted(m)))  
else:
  print(a)

Failing test case input:
3
caab
d`acc
cacaca

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
n=int(input())
a=input()
if n!=1:
  b=input()
  m=[]
  if len(a)>len(b):
    a,b=b,a
  b=list(b)
  for i in a:
    for j in range(len(b)):
      if i==b[j]:
        m.append(i)
        b[j]=''
        break
  for _ in range(n-2):
    s=list(input())
    l=[]
    for i in m:
      for j in range(len(s)):
        if i==s[j]:
          l.append(i)
          s[j]=''
          break
    m=l
  print(''.join(sorted(m)))  
else:
  print(''.join(sorted(a)))

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

n = int(input())
s = []
t = []
a = defaultdict(int)
for i in range(n):
    d = defaultdict(int)
    st = list(input())
    st.sort()
    for j in range(len(st)):
        d[st[j]]+=1    
    if i==0:
        t = set(st)
        for j in t:
            a[j] = d[j]
    else:
        u = set(st)
        t = t & u 
        for j in t:
            a[j] = min(a[j],d[j])
    s.append(st)
ans = ""
for i in t:
    for j in range(a[i]):
        ans = ans + i
print(ans)

Failing test case input:
3
caaa
daacc
acacac

Expected output:
aac


Actual output:
caa


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

n = int(input())
s = []
t = []
a = defaultdict(int)
for i in range(n):
    d = defaultdict(int)
    st = list(input())
    st.sort()
    for j in range(len(st)):
        d[st[j]]+=1    
    if i==0:
        t = set(st)
        for j in t:
            a[j] = d[j]
    else:
        u = set(st)
        t = t & u 
        for j in t:
            a[j] = min(a[j],d[j])
ans = ""
t = list(t)
t.sort()
for i in t:
    for j in range(a[i]):
        ans = ans + i
print(ans)
Problem: p03761
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import Counter
N = int(input())
S=[]

for n in range(N):
    S.append(Counter(list(input())))

S_=dict(S[0])
for s in S:
    if len(S_) > len(s):
        S_=dict(s)

for s in S:
    for s_ in S_.keys():
        S_[s_]=min(s[s_],S_[s_])

S_key=list(S_.keys())
S_key.sort()

ans=''
for k in S_key:
    ans += k*S_[k]
ans

Failing test case input:
3
aad`
caacc
acadac

Expected output:
aa


Actual output:

Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
S=[]

for n in range(N):
    S.append(Counter(list(input())))

S_=dict(S[0])
for s in S:
    if len(S_) > len(s):
        S_=dict(s)

for s in S:
    for s_ in S_.keys():
        S_[s_]=min(s[s_],S_[s_])

S_key=list(S_.keys())
S_key.sort()

ans=''
for k in S_key:
    ans += k*S_[k]
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import string
import collections

N = int(input())
S = [input() for _ in range(N)]
max_str = collections.Counter(S[0])
for i in range(N-1):
  tmp = collections.Counter(S[i+1])
  print(tmp)
  for k, v in max_str.items():
    if k in tmp:
      max_str[k] = min(v, tmp[k])
    else:
      max_str[k] = 0

ans = ""
for k, v in sorted(max_str.items()):
  ans += k * v
print(ans)


Failing test case input:
3
caaa
bcb_c
ccaaca

Expected output:
c


Actual output:
Counter({'b': 2, 'c': 2, '_': 1})
Counter({'c': 3, 'a': 3})
c


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

N = int(input())
S = [input() for _ in range(N)]
max_str = collections.Counter(S[0])
for i in range(N-1):
  tmp = collections.Counter(S[i+1])
  
  for k, v in max_str.items():
    if k in tmp:
      max_str[k] = min(v, tmp[k])
    else:
      max_str[k] = 0

ans = ""
for k, v in sorted(max_str.items()):
  ans += k * v
print(ans)

Problem: p03761
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections
n = int(input())
s = list(input())
s_cnt = collections.Counter(s)

for i in range(n-1):
  tmp = input()
  for k in s_cnt:
    tmp_cnt = tmp.count(k)
    if tmp_cnt < s_cnt[k]:
      s_cnt[k] = tmp_cnt 

ans =""      
for k in s_cnt:
  ans += k*s_cnt[k]
print(ans[::-1])

Failing test case input:
3
aaac
c`adc
acacac

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
import collections
n = int(input())
s = list(input())
s_cnt = collections.Counter(s)

for i in range(n-1):
  tmp = input()
  for k in s_cnt:
    s_cnt[k] = min(s_cnt[k],tmp.count(k))

s_cnt=dict(sorted(s_cnt.items(), key=lambda x:x[0]))
ans = ""      
for k in s_cnt:
  ans += k*s_cnt[k]
print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s_list = list()
for i in range(n):
    s_list.append(input())

dictionary_list = list()
    
for s in s_list:
    dictionary = dict()
    for w in s:
        if w in dictionary:
            dictionary[w] += 1
        else:
            dictionary[w] = 1
    dictionary_list.append(dictionary)

first = dictionary_list[0]
pop_list = list()

for key,value in first.items():
    for dictionary in dictionary_list[1:]:
        if key in dictionary:
            first[key] = min(first[key],dictionary[key])
        else:
            pop_list.append(key)

for p in pop_list:
    if p in first:
        first.pop(p)
            
t = ""
for k,v in first.items():
    t += k*v
print(t)

Failing test case input:
3
caaa
d`acc
cabaca

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
from collections import OrderedDict
n = int(input())
s_list = list()
for i in range(n):
    s_list.append(input())

dictionary_list = list()
    
for s in s_list:
    dictionary = dict()
    for w in s:
        if w in dictionary:
            dictionary[w] += 1
        else:
            dictionary[w] = 1
    dictionary_list.append(dictionary)

first = dictionary_list[0]
pop_list = list()

for key,value in first.items():
    for dictionary in dictionary_list[1:]:
        if key in dictionary:
            first[key] = min(first[key],dictionary[key])
        else:
            pop_list.append(key)

for p in pop_list:
    if p in first:
        first.pop(p)
          
first = OrderedDict(sorted(first.items(),key=lambda x: x[0]))
t = ""
for k,v in first.items():
    t += k*v
print(t)

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

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for (word, cnt)in counter.items():
    ans=ans+word*cnt

if len(ans)==0:
    ans2=""
else:
    ans2=str(ans)

print(ans2)


Failing test case input:
3
cacb
ccabe
`cacbc

Expected output:
abcc


Actual output:
ccab


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

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for c in [chr(i) for i in range(ord('a'), ord('z')+1)]:
    ans=ans+c*counter[c]
print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=[]
for i in range(n):
    s.append(list(input()))
l=''
for i in range(26):
    t=n+2
    for j in range(n):
        t=min(n,s[j].count(chr(97+i)))
    for j in range(t):
        l=l+chr(97+i)
print(l)

Failing test case input:
3
aaca
c_bcb
caacca

Expected output:
c


Actual output:
aaaccc


Fixed submission (verdict: Accepted):

n=int(input())
s=[]
for i in range(n):
    s.append(list(input()))
l=''
for i in range(26):
    t=n+2
    for j in range(n):
        t=min(t,s[j].count(chr(97+i)))
    for j in range(t):
        l=l+chr(97+i)
print(l)

Problem: p03761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
h = [input() for d in range (n)]
alphabet=['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']
list=[]


for k in range(26):
    for i in range (n):
         m=50
         x =h[i].count(alphabet[k])
         m =min(x,m)
    list.append(alphabet[k]*m)

print(''.join(list))


Failing test case input:
3
caa`
ccb`c
abcacd

Expected output:
c


Actual output:
aabccd


Fixed submission (verdict: Accepted):
n=int(input())
h = [input() for d in range (n)]
alphabet=['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']
list=[]


for k in range(26):
    m=50
    for i in range (n):
         x =h[i].count(alphabet[k])
         m =min(x,m)
    list.append(alphabet[k]*m)

print(''.join(list))

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from collections import Counter

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [input().rstrip() for _ in range(N)]

C = [Counter(a) for a in A]



tmp = {}

for k, v in C[0].items():
	tmp[k] = v
	for i in range(1, N):
		
		tmp[k] = min(v, C[i][k])

tmp = sorted(tmp.items(), key=lambda x:x[0])


ans = ''
for k, v in tmp:
	ans += k * v

print(ans)

Failing test case input:
3
`a_c
bcc_c
abaacc

Expected output:
c


Actual output:
ac


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

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [input().rstrip() for _ in range(N)]

C = [Counter(a) for a in A]



tmp = {}

for k, v in C[0].items():
	tmp[k] = v
	for i in range(N):
		tmp[k] = min(tmp[k], C[i][k])

tmp = sorted(tmp.items(), key=lambda x:x[0])


ans = ''
for k, v in tmp:
	ans += k * v

print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
S = []
for i in range(n):
    S.append(list(input()))

match = []
for i in range(n):
    if i == 0: match = S[i][:]
    else:
        match_tmp = []
        for j in match:
            for k in range(min(len(S[i]), len(match))):
                if j == S[i][k]:
                    match_tmp.append(S[i][k])
                    S[i][k] = "out"
        match = match_tmp[:]

print("".join(sorted(match)))


Failing test case input:
3
caaa
cca`d
acacac

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
n = int(input())
S = []
for i in range(n):
    S.append(list(input()))

match = []
for i in range(n):
    if i == 0: match = S[i][:]
    else:
        match_tmp = []
        for j in match:
            for k in range(len(S[i])):
                if j == S[i][k]:
                    match_tmp.append(S[i][k])
                    S[i][k] = "out"
                    break
        match = match_tmp[:]

print("".join(sorted(match)))

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n=int(input())
S=[]
for i in range(n):
  s=list(input())
  S+=[s]
ANS=[]
if n==1:
  ANS=S[0]
  ANS.sort()
  ans="".join(ANS) 
  print(ans)
  sys.exit()
for k in range(len(S[0])):
  if S[0][k] in S[1]:
    ANS+=[S[0][k]]
    S[1].remove(S[0][k])
for i in ANS:
  flag=0
  rem=[]
  for k in range(2,n):
    if i in S[k]:
      S[k].remove(i)
    elif flag!=1:
      rem+=[i]
      flag=1
for i in rem:
  ANS.remove(i)
ANS.sort()      
ans="".join(ANS)  
print(ans)

Failing test case input:
3
ba`c
bcb`c
abdbcb

Expected output:
bc


Actual output:
`bc


Fixed submission (verdict: Accepted):
import sys
n=int(input())
S=[]
for i in range(n):
  s=list(input())
  S+=[s]
ANS=[]
if n==1:
  ANS=S[0]
  ANS.sort()
  ans="".join(ANS) 
  print(ans)
  sys.exit()
for k in range(len(S[0])):
  if S[0][k] in S[1]:
    ANS+=[S[0][k]]
    S[1].remove(S[0][k])
rem=[]
for i in ANS:
  flag=0
  for k in range(2,n):
    if i in S[k]:
      S[k].remove(i)
    elif flag!=1:
      rem+=[i]
      flag=1
for i in rem:
  ANS.remove(i)
ANS.sort()      
ans="".join(ANS)  
print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

s = [input() for i in range(n)]

sort_s = []

for i in range(n):
    sort_s.append(sorted(s[i]))
    
onaji = sort_s[0]
new = []
tmp = 0

for i in range(1,n):
    for j in range(len(onaji)):
        for k in range(len(s[i])):
            
            if tmp+k >= len(s[i]):
                break
            if onaji[j] == sort_s[i][tmp+k]:
                new.append(onaji[j])
                tmp = k
                break
    onaji = new
    new = []
            
print(*onaji,sep="")

Failing test case input:
3
caaa
cca`d
cacaca

Expected output:
ac


Actual output:
aaac


Fixed submission (verdict: Accepted):
n = int(input())

s = [input() for i in range(n)]

sort_s = []

for i in range(n):
    sort_s.append(sorted(s[i]))
    
onaji = sort_s[0]
new = []
tmp = 0

for i in range(1,n):
    new = []
    tmp = 0
    
    for j in range(len(onaji)):
        for k in range(len(s[i])):
            
            if tmp+k >= len(s[i]):
                break
            if onaji[j] == sort_s[i][tmp+k]:
                new.append(onaji[j])
                tmp = tmp+k+1
                break
    
    onaji = new
    
            
print(*onaji,sep="")

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

s = [input() for i in range(n)]

sort_s = []

for i in range(n):
    sort_s.append(sorted(s[i]))
    
onaji = sort_s[0]
new = []
tmp = 0

for i in range(1,n):
    new = []
    tmp = 0
    
    for j in range(len(onaji)):
        for k in range(len(s[i])):
            
            if tmp+k >= len(s[i]):
                break
            if onaji[j] == sort_s[i][tmp+k]:
                new.append(onaji[j])
                tmp = k+1
                break
    
    onaji = new
    
            
print(*onaji,sep="")

Failing test case input:
3
caaa
daacc
acacac

Expected output:
aac


Actual output:
aaac


Fixed submission (verdict: Accepted):
n = int(input())

s = [input() for i in range(n)]

sort_s = []

for i in range(n):
    sort_s.append(sorted(s[i]))
    
onaji = sort_s[0]
new = []
tmp = 0

for i in range(1,n):
    new = []
    tmp = 0
    
    for j in range(len(onaji)):
        for k in range(len(s[i])):
            
            if tmp+k >= len(s[i]):
                break
            if onaji[j] == sort_s[i][tmp+k]:
                new.append(onaji[j])
                tmp = tmp+k+1
                break
    
    onaji = new
    
            
print(*onaji,sep="")
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from string import ascii_lowercase

n = int(input())
strings = [input() for _ in range(n)]
alphabets = [a for a in ascii_lowercase]

counts = []
for a in alphabets:
    for i in range(n):
        count = strings[i].count(a)
        if count == 0:
            counts.append((a, 0))
            break
        if i == 0:
            m = count
            continue
        m = min(m, count)
    else:
        counts.append((a, m))
print(counts)

ans = ''
for count in counts:
    ans += count[0] * count[1]

print(ans)


Failing test case input:
3
aabc
bda`c
acacac

Expected output:
ac


Actual output:
[('a', 1), ('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)]
ac


Fixed submission (verdict: Accepted):
from string import ascii_lowercase

n = int(input())
strings = [input() for _ in range(n)]
alphabets = [a for a in ascii_lowercase]

counts = []
for a in alphabets:
    for i in range(n):
        count = strings[i].count(a)
        if count == 0:
            break
        if i == 0:
            m = count
            continue
        m = min(m, count)
    else:
        counts.append((a, m))

ans = ''
for count in counts:
    ans += count[0] * count[1]

print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
def solve():
    N = int(input())
    dics = [0]*N
    for i in range(N):
        S = input()
        dics[i] = defaultdict(lambda:0)
        for s in S:
            dics[i][s] += 1
    ans = ''
    for k,v in sorted(dics[0].items()):
        mincnt = v
        for i in range(1,N):
            mincnt = min(v,dics[i][k])
        ans += k*mincnt
    return ans
print(solve())

Failing test case input:
3
aabc
cca`d
acacac

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
from itertools import groupby, accumulate, product, permutations, combinations
from collections import Counter
def solve():
    N = int(input())
    dics = [0]*N
    S = [input() for _ in range(N)]
    dic = Counter(S[0])
    for i in range(1,N):
        new_dic = Counter(S[i])
        for k in dic.keys():
            if k in new_dic:
                dic[k] = min(dic[k],new_dic[k])
            else:
                dic[k] = 0
    ans = ''
    for k,v in sorted(dic.items()):
        ans += k*v
    return ans
print(solve())