ZhenlongDai/ACPR huggingface dataset:
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n=int(input())
ans=''
counter={}
for i in range(n):
    if i==0:
        s=input()
        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
acba
da`cb
acacbc

Expected output:
abc


Actual output:
acb


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 (PyPy3 (2.4.0), verdict: Wrong Answer):
import collections
n = int(input())
s = [[] for _ in range(n)]
l = [collections.defaultdict(lambda:0) for _ in range(n)]
for i in range(n):
    s[i] = list(input())
    for j in s[i]:
        l[i][j] += 1
    print(l)
mind = [float("inf")]*26
for i in range(26):
    for j in range(n):
        mind[i] = min(mind[i],l[j][chr(97+i)])
ans = ""
for i in range(26):
    ans += chr(97+i)*mind[i]
print(ans)

Failing test case input:
3
aaac
c`adc
acacac

Expected output:
ac


Actual output:
[defaultdict(<function <listcomp>.<lambda> at 0x7fd707188720>, {'a': 3, 'c': 1}), defaultdict(<function <listcomp>.<lambda> at 0x7fd7071893a0>, {}), defaultdict(<function <listcomp>.<lambda> at 0x7fd7071d14e0>, {})]
[defaultdict(<function <listcomp>.<lambda> at 0x7fd707188720>, {'a': 3, 'c': 1}), defaultdict(<function <listcomp>.<lambda> at 0x7fd7071893a0>, {'c': 2, '`': 1, 'a': 1, 'd': 1}), defaultdict(<function <listcomp>.<lambda> at 0x7fd7071d14e0>, {})]
[defaultdict(<function <listcomp>.<lambda> at 0x7fd707188720>, {'a': 3, 'c': 1}), defaultdict(<function <listcomp>.<lambda> at 0x7fd7071893a0>, {'c': 2, '`': 1, 'a': 1, 'd': 1}), defaultdict(<function <listcomp>.<lambda> at 0x7fd7071d14e0>, {'a': 3, 'c': 3})]
ac


Fixed submission (verdict: Accepted):
import collections
n = int(input())
s = [[] for _ in range(n)]
l = [collections.defaultdict(lambda:0) for _ in range(n)]
for i in range(n):
    s[i] = list(input())
    for j in s[i]:
        l[i][j] += 1
mind = [float("inf")]*26
for i in range(26):
    for j in range(n):
        mind[i] = min(mind[i],l[j][chr(97+i)])
ans = ""
for i in range(26):
    ans += chr(97+i)*mind[i]
print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

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

ans = ''
c = l[0]

for key, val in c.most_common():
    m = val
    for i in range(1, n):
        m = min(m, l[i][key])
    ans += key * m

print(ans)


Failing test case input:
3
caca
cca`d
acacac

Expected output:
acc


Actual output:
cca


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

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

ans = ''
c = sorted(l[0])

for key in c:
    m = l[0][key]
    for i in range(1, n):
        m = min(m, l[i][key])
    ans += key * m

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())
base = min(S, key = len)
ans = []
for i in range(len(base)):
    flag = True
    for k in range(len(S)):
        if base[i] not in S[k]:
            flag = False
    if flag:
        ans.append(base[i])
ans.sort()
char_ans = ''
for i in range(len(ans)):
    char_ans += ans[i]
print(char_ans)

Failing test case input:
3
caab
d`acc
cacaca

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):

n = int(input())
S = []
for i in range(n):
    S.append(input())
base = min(S, key = len)
S.remove(base)
ans = []
for i in range(len(base)):
    flag = True
    for k in range(len(S)):
        if base[i] not in S[k]:
            flag = False
        else:
            place = S[k].find(base[i])
            S[k] = S[k].replace(base[i], '', 1)            
    if flag:
        ans.append(base[i])
ans.sort()
char_ans = ''
for i in range(len(ans)):
    char_ans += ans[i]
print(char_ans)

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

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

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

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

print(ans)


Failing test case input:
3
bcac
cc`be
acacbc

Expected output:
bcc


Actual output:
[('a', 0), ('b', 1), ('c', 2), ('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)]
bcc


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 Counter
n = int(input())
S = [input() for _ in range(n)]

ans = Counter(S[0])
for i in range(1,n):
  tmp = Counter(S[i])
  for a in ans.keys():
    if a in tmp:
      ans[a] = min(ans[a],tmp[a])
    else:
      ans[a] = 0
x = ''
for a in ans.items():
  x += a[0]*a[1]
print(x)

Failing test case input:
3
cbaa
d`acc
acacac

Expected output:
ac


Actual output:
ca


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

ans = Counter(S[0])
for i in range(1,n):
  tmp = Counter(S[i])
  for a in ans.keys():
    if a in tmp:
      ans[a] = min(ans[a],tmp[a])
    else:
      ans[a] = 0
x = ''
for a in ans.items():
  x += a[0]*a[1]
print(''.join(sorted(x)))

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
s = []
s0 = list(input())
sc = Counter(s0)
for i in range(1,n):
    a = list(input())
    ac = Counter(a)
    for i,v in ac.items():
        if i not in sc:
            continue
        elif sc[i] > v:
            sc[i] = ac[i]
    for i,v in sc.items():
        if i not in ac.items():
            sc[i] = 0
sc2 = sorted(sc.items())
for i,v in sc2:
    for j in range(v):
        print(i,end='')

Failing test case input:
3
_``c
c_bcb
abaacd

Expected output:
c


Actual output:

Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
s = []
s0 = list(input())
sc = Counter(s0)
for i in range(1,n):
    a = list(input())
    ac = Counter(a)
    for i,v in ac.items():
        if i not in sc:
            continue
        elif sc[i] > v:
            sc[i] = ac[i]
    for i,v in sc.items():
        if i not in ac:
            sc[i] = 0
sc2 = sorted(sc.items())
for i,v in sc2:
    for j in range(v):
        print(i,end='')

Problem: p03761
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
ans=[]
mins=55
a=[list(input()) for _ in range(n)]
for i in range(n):
  if mins > len(a[i]):
    mins=min(mins,len(a[i]))
    m=i
for i in a[m]:
  flg=0
  for j in a:
    if i not in j:
      flg=1
  if flg==0:
    ans.append(i)
ans.sort()
print(*ans,sep='')

Failing test case input:
3
caaa
daacc
acacac

Expected output:
aac


Actual output:
aaac


Fixed submission (verdict: Accepted):
import copy
n=int(input())
ans=[]
mins=55
a=[list(input()) for _ in range(n)]
for i in a:
  if mins > len(i):
    mins=min(mins,len(i))
    m=copy.copy(i)
for i in m:
  flg=0
  for j in a:
    if i not in j:
      flg=1
  if flg==0:
    ans.append(i)
    for j in a:
      j.remove(i)
ans.sort()
print(*ans,sep='')
Problem: p03761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter

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

c = ctr[0]
print(c.items())
for i in range(1, n):
    for k, v in c.items():
        c[k] = min(ctr[i][k], c[k])

ans = ''
for k, v in sorted(c.items()):
    ans += k * v

print(ans)

Failing test case input:
3
caa_
b_ccc
abaacd

Expected output:
c


Actual output:
dict_items([('c', 1), ('a', 2), ('_', 1)])
c


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

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

c = ctr[0]
for i in range(1, n):
    for k, v in c.items():
        c[k] = min(ctr[i][k], c[k])

ans = ''
for k, v in sorted(c.items()):
    ans += k * v

print(ans)

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

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

and_ = set(input_list[0])
for lists in input_list:
    and_ = and_ & set(lists) 

ans = ""
for char in and_:
    f = [i.count(char) for i in input_list]
    ans += min(f) * char
print(ans)

Failing test case input:
3
aabc
bda`c
acacac

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):

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

and_ = set(input_list[0])
for lists in input_list:
    and_ = and_ & set(lists) 
and_ = list(and_)
and_.sort()

ans = ""
for char in and_:
    f = [i.count(char) for i in input_list]
    ans += min(f) * char
print(ans)

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



def lccc(c, cnts):
    m = 51 
    for cc in cnts:
        if (not c in cc):
            return 0
        if (cc[c] < m):
            m = cc[c]
    return m


def main():
    counter = dict()

    n = int(input())
    cnts = [Counter(list(input())) for i in range(n)]
    for c in list(string.ascii_lowercase):
        counter[c] = lccc(c, cnts)

    s = "".join([k * counter[k] for k in sorted(counter.keys())])
    if (len(s) >= n):
        print(s[:n])
    else:
        print()


if __name__ == '__main__':
    main()


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

Expected output:
c


Actual output:

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



def lccc(c, cnts):
    m = 51 
    for cc in cnts:
        if (not c in cc):
            return 0
        if (cc[c] < m):
            m = cc[c]
    return m


def main():
    counter = dict()

    n = int(input())
    cnts = [Counter(list(input())) for i in range(n)]
    for c in list(string.ascii_lowercase):
        counter[c] = lccc(c, cnts)

    print("".join([k * counter[k] for k in sorted(counter.keys())]))


if __name__ == '__main__':
    main()
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a = int(input())
b = []
c = []
ans = ""

for i in range(a):
    b.append(input())
    c.append(len(b[i]))

alpha = [chr(i) for i in range(97,97+26)]

if min(c) >= a:
    for ii in range(26):
        d = []
        for i in range(a):
            d.append(b[i].count(alpha[ii]))
        ans = ans + (alpha[ii] * min(d))
           
print(ans)

Failing test case input:
3
a
aa
a

Expected output:
a


Actual output:

Fixed submission (verdict: Accepted):

a = int(input())
b = []
c = []
ans = ""

for i in range(a):
    b.append(input())
    c.append(len(b[i]))

alpha = [chr(i) for i in range(97,97+26)]

for ii in range(26):
    d = []
    for i in range(a):
        d.append(b[i].count(alpha[ii]))
    ans = ans + (alpha[ii] * min(d))
           
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
d=dict()
for i in input():
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
for _ in range(n-1):
  dd=dict()
  for i in input():
    if i not in dd:
      dd[i]=1
    else:
      dd[i]+=1
  for i in d.keys():
    if i in dd:
      d[i]=min(d[i],dd[i])
ans=[]
for i in d.keys():
  for _ in range(d[i]):
    ans.append(i)
ans.sort()
a=""
for i in ans:
  a+=i
print(a)


Failing test case input:
3
caa`
bcb`c
dcaaba

Expected output:
c


Actual output:
`aac


Fixed submission (verdict: Accepted):
n=int(input())
d=dict()
for i in input():
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
for _ in range(n-1):
  dd=dict()
  for i in input():
    if i not in dd:
      dd[i]=1
    else:
      dd[i]+=1
  for i in d.keys():
    if i in dd:
      d[i]=min(d[i],dd[i])
    else:
      d[i]=0
ans=[]
for i in d.keys():
  for _ in range(d[i]):
    ans.append(i)
ans.sort()
a=""
for i in ans:
  a+=i
print(a)
Problem: p03761
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):


import sys

from collections import Counter


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    d = Counter(input())
    for _ in range(n - 1):
        s = Counter(input())
        for k, v in d.items():
            if k in s.keys():
                d[k] = min(d[k], v)
            else:
                d[k] = 0
    common_chr = sorted(d.items(), key=lambda x: x[0])
    ans = ""
    for s, cnt in common_chr:
        ans += s * cnt
    print(ans)
    return


if __name__ == "__main__":
    main()


Failing test case input:
3
baaa
cca`d
acacac

Expected output:
a


Actual output:
aaa


Fixed submission (verdict: Accepted):


import sys

from collections import Counter


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    d = Counter(input())
    for _ in range(n - 1):
        s = Counter(input())
        for k, v in d.items():
            if k in s.keys():
                d[k] = min(s[k], v)
            else:
                d[k] = 0
    common_chr = sorted(d.items(), key=lambda x: x[0])
    ans = ""
    for s, cnt in common_chr:
        ans += s * cnt
    print(ans)
    return


if __name__ == "__main__":
    main()

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = []
for _ in range(n):
    tmp_s = sorted(input())
    s.append("".join(tmp_s))

s.sort(key=len)
ans = ''
flag = True

for i in range(len(s[0])):
    count = 0
    for j in range(len(s) - 1):
        if s[0][i] in s[j+1]:
            count += 1

    if count == len(s) - 1:
        ans += s[0][i]

print(ans)


Failing test case input:
3
caab
d`acc
cacaca

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
n = int(input())
s = []
for _ in range(n):
    tmp_s = sorted(input())
    s.append("".join(tmp_s))

s.sort(key=len)
ans = ''

for i in range(len(s[0])):
    count = 0
    for j in range(len(s) - 1):
        if s[0][i] in s[j+1]:
            s[j+1] = s[j+1].replace(s[0][i], "", 1)
            count += 1

    if count == len(s) - 1:
        ans += s[0][i]

print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy

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

strlist=[]

B=copy.deepcopy(S)

for s1 in S:
    print(s1)
    for moji in s1:
        c=False
        for s2 in B:
            if moji not in s2:
                c=False
                break
            else: c=True
        if c:
            strlist.append(moji)
            [B[i].remove(moji) for i in range(n)]
strlist.sort()
print(''.join(strlist))
            

Failing test case input:
3
aa_c
bcb_c
abaacc

Expected output:
c


Actual output:
['a', 'a', '_', 'c']
['b', 'c', 'b', '_', 'c']
['a', 'b', 'a', 'a', 'c', 'c']
c


Fixed submission (verdict: Accepted):
import copy

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

strlist=[]

B=copy.deepcopy(S)

for s1 in S:
    for moji in s1:
        c=False
        for s2 in B:
            if moji not in s2:
                c=False
                break
            else: c=True
        if c:
            strlist.append(moji)
            [B[i].remove(moji) for i in range(n)]
strlist.sort()
print(''.join(strlist))

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

n = int(input())
L = [Counter(sorted(str(input()))) for _ in range(n)]
ans = ''
for k in L[0]:
    for i in range(n):
        m = L[0][k]
        if L[i][k] < L[0][k]:
            m = min(m, L[i][k])
    ans = ans + k * m
print(ans)


Failing test case input:
3
caa`
ccb_c
abaacd

Expected output:
c


Actual output:
aac


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

n = int(input())
L = [Counter(str(input())) for _ in range(n)]
C = sorted(L[0])
ans = ''
for k in C:
    m = L[0][k]
    for i in range(n):
        m = min(m, L[i][k])
    ans += k * m
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
L = [sorted(str(input())) for _ in range(n)]
m = float('inf')
for s in L:
    m = min(m, len(s))
ans = ''
for i in range(m):
    for j in range(1, n):
        if L[0][i] != L[j][i]:
            break
    else:
        ans = ans + L[0][i]
print(ans)


Failing test case input:
3
caaa
d`acc
cabaca

Expected output:
ac


Actual output:
a


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

n = int(input())
L = [Counter(str(input())) for _ in range(n)]
C = sorted(L[0])
ans = ''
for k in C:
    m = L[0][k]
    for i in range(n):
        m = min(m, L[i][k])
    ans += k * m
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())

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)
        print(s)

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

Failing test case input:
3
`a_c
c_bcb
abaacc

Expected output:
c


Actual output:
['`a_c', '_bcb', 'abaac']
c


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):
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):
        for k,v in Counter(S[i]).items():
            if k in dic:
                dic[k] = min(dic[k],v)
    ans = ''
    for k,v in sorted(dic.items()):
        ans += k*v
    return ans
print(solve())

Failing test case input:
3
_``c
c_bcb
abaacd

Expected output:
c


Actual output:
_``c


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.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(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
daacc
acacac

Expected output:
aac


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 = []
for _ in range(n):
    tmp_s = sorted(input())
    s.append("".join(tmp_s))

s.sort(key=len)
ans = ''

for i in range(len(s[0])):
    count = 0
    for j in range(len(s) - 1):
        if s[0][i] in s[j+1]:
            s[j+1] = s[j+1].replace(s[0][i], "", 1)
            count += 1

    if count == len(s) - 1:
        ans += s[0][i]

print(s)
print(ans)


Failing test case input:
3
cacb
ccabe
`cacbc

Expected output:
abcc


Actual output:
['abcc', 'e', '`c']
abcc


Fixed submission (verdict: Accepted):
n = int(input())
s = []
for _ in range(n):
    tmp_s = sorted(input())
    s.append("".join(tmp_s))

s.sort(key=len)
ans = ''

for i in range(len(s[0])):
    count = 0
    for j in range(len(s) - 1):
        if s[0][i] in s[j+1]:
            s[j+1] = s[j+1].replace(s[0][i], "", 1)
            count += 1

    if count == len(s) - 1:
        ans += s[0][i]

print(ans)

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] > k[i]:
      d[i] = k[i]

  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)

Failing test case input:
3
caba
da`cc
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 = []
a = ""
_min = 50
for i in range(n):
    b = input()
    if len(b) <= _min:
        _min = len(b)
        a = b
    s.append(b)

for i in range(len(s)):
    if s[i] == a:
        s.pop(i)
        break

ans = []
for i in range(len(a)):
    flag = False
    for j in range(n-1):
        for k in range(len(s[j])):
            if a[i] == s[j][k]:
                s[j] = s[j][:k]+s[j][k+1:]
                flag = True
                break
    if flag == True:
        ans += a[i]

ans.sort()
for a in ans:
    print(a, end="")


Failing test case input:
3
caaa
bcb_c
ccaaca

Expected output:
c


Actual output:
aaac

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

s = []
a = ""
_min = 50
for i in range(n):
    b = input()
    if len(b) <= _min:
        _min = len(b)
        a = b
    s.append(b)

for i in range(len(s)):
    if s[i] == a:
        s.pop(i)
        break

ans = []
for i in range(len(a)):
    flag = True
    for j in range(n-1):
        if a[i] in s[j]:
            for k in range(len(s[j])):
                if a[i] == s[j][k]:
                    s[j] = s[j][:k]+s[j][k+1:]
                    break
        else:
            flag = False

    if flag == True:
        ans += a[i]

ans.sort()
for a in ans:
    print(a, end="")

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]):
            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)

Failing test case input:
3
acba
da`cb
acacbc

Expected output:
abc


Actual output:
aabc


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 (Python (3.4.3), verdict: Wrong Answer):
import sys
n = int(input())
kind = set(list("abcdefghijklmnopqrstuvwxyz"))
S = str(input(n))
kind = set(S)
dic = {}
for k in kind:
    dic[k] = S.count(k)

for i in range(n-1):
    S = str(input())
    kind = set(S) & kind
    for k in kind:
        dic[k] = min(S.count(k),dic[k])
    if i == n-2:
        alp = sorted(list(kind))
        ans = ""
        for a in alp:
            ans += a*dic[a]
        print(ans)


Failing test case input:
3
cbaa
d`acc
acacac

Expected output:
ac


Actual output:
3ac


Fixed submission (verdict: Accepted):
import sys
n = int(input())
kind = set(list("abcdefghijklmnopqrstuvwxyz"))
S = str(input())
kind = set(S)
dic = {}
for k in kind:
    dic[k] = S.count(k)

for i in range(n-1):
    S = str(input())
    kind = set(S) & kind
    for k in kind:
        dic[k] = min(S.count(k),dic[k])

kind = sorted(list(kind))
ans = ""
for a in kind:
    ans += a*dic[a]
print(ans)

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 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[i] > k[i]:
      d[i] = k[i]

  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)

Failing test case input:
3
aaac
cda`c
adacac

Expected output:
ac


Actual output:
aaac


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 =[[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-1):
        a[j]=min(s[i][j],s[i+1][j])
for i in range(26):
    sa+=chr(ord('a')+i)*a[i]
print(sa)


Failing test case input:
3
`a_c
bcc_c
abaacc

Expected output:
c


Actual output:
bcc


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 (Python (3.8.2), verdict: Wrong Answer):
import collections as c
n=[c.Counter(input()) for _ in range(int(input()))];r=n[0]
for i in range(1,len(n)): r=r&n[i]
print(*[i*j for i,j in r.items()][::-1],sep='')

Failing test case input:
3
aaca
bda`c
cacaca

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
import collections as c
n=[c.Counter(input()) for _ in range(int(input()))];r=n[0]
for i in range(1,len(n)): r=r&n[i]
print(*sorted([i*j for i,j in r.items()]),sep='')

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ans = list(input())
for i in range(n - 1):
    t = list(input())
    j = 0
    while j < len(ans):
        k = 0
        while k < len(t):
            if ans[j] == t[k]:
                del t[k]
                break
            else:
                k += 1
        else:
            del ans[j]
        j += 1
ans.sort()
print("".join(ans))


Failing test case input:
3
caa_
c_bcb
dcaaba

Expected output:
c


Actual output:
ac


Fixed submission (verdict: Accepted):
n = int(input())
ans = list(input())
for i in range(n - 1):
    t = list(input())
    j = 0
    while j < len(ans):
        k = 0
        while k < len(t):
            if ans[j] == t[k]:
                del t[k]
                break
            else:
                k += 1
        else:
            del ans[j]
            j -= 1
        j += 1
ans.sort()
print("".join(ans))

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = 3
a = ["cbaa","daacc","acacac"]
s = ""
for c in a[0]:
    f = []
    for i in range(n-1):
        if c not in a[i+1]:
            break
        for d in range(len(a[i+1])):
            if c == a[i+1][d]:
                f.append(d)
                break
    else:
        s += str(c)
        for i in range(n-1):
            a[i+1] = a[i+1][:f[i]] +""+ a[i+1][f[i]+1:]
        
ns = "".join(sorted(s))
print(ns)

Failing test case input:
3
c_aa
ccb_c
acaacc

Expected output:
c


Actual output:
aac


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


s = ""
for c in a[0]:
    f = []
    for i in range(n-1):
        if c not in a[i+1]:
            break
        for d in range(len(a[i+1])):
            if c == a[i+1][d]:
                f.append(d)
                break
    else:
        s += str(c)
        for i in range(n-1):
            a[i+1] = a[i+1][:f[i]] +""+ a[i+1][f[i]+1:]
        
ns = "".join(sorted(s))
print(ns)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
str_list=[str(input()) for i in range(a)]

x=[]
for i in range(len(str_list[0])):
  check=True;
  for j in range(len(str_list)):
    if str_list[0][i] in str_list[j]:
      str_list[j].replace(str_list[0][i],"",1)
    else:
      check=False;
  if check:
    x.append(str_list[0][i])
if len(x) > 0:
  print(''.join(sorted(x)))
else:
  print('')  

Failing test case input:
3
aabc
cca`d
acacac

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
a=int(input())
str_list=[str(input()) for i in range(a)]
x=[]
for i in range(len(str_list[0])):
  check=True;
  for j in range(1,a):
    if str_list[0][i] in str_list[j]:
      str_list[j] = str_list[j].replace(str_list[0][i],'',1);
    else:
      check=False;
  if check:
    x.append(str_list[0][i])
if len(x) > 0:
  print(''.join(sorted(x)))
else:
  print('')

Problem: p03761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
from collections import Counter
n=int(input())
s0=Counter(input().strip()).items()
ans={}
for i in range(n-1):
    s=input().strip()
    for a,num in s0:
        ans[a]=min(num,s.count(a))
ans=sorted(list(ans.items()))
rep=""
for a,num in ans:
    for i in range(num):
        rep+=a
print(rep)


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

Expected output:
c


Actual output:
aac


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
from collections import Counter,defaultdict
n=int(input())
al=[float("inf")]*26
a=ord("a")

for i in range(n):
    s=input().strip()
    for i in range(26):
        al[i]=min(al[i],s.count(chr(i+a)))
rep=""
for i,k in enumerate(al):
    for j in range(k):
        rep+=chr(i+a)
print(rep)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
from sys import exit, stdin
N = int(stdin.readline().rstrip())
S = [Counter(stdin.readline().rstrip()) for _ in range(N)]
inter_chars = {}
for i in range(1, N):
    inter_chars = S[i].keys() & S[i-1].keys()
ans = {}
for i in range(N):
    for c in inter_chars:
        if c not in ans:
            ans[c] = S[i][c]
        elif S[i][c] < ans[c]:
            ans[c] = S[i][c]
print(''.join(k*v for k, v in ans.items()))

Failing test case input:
3
cacb
ccabe
`cacbc

Expected output:
abcc


Actual output:
ccab


Fixed submission (verdict: Accepted):
from collections import Counter
from sys import exit, stdin
N = int(stdin.readline().rstrip())
if N == 1:
    print(''.join(sorted(stdin.readline().rstrip())))
    exit()
S = [Counter(stdin.readline().rstrip()) for _ in range(N)]
inter_chars = {}
for i in range(0, N-1):
    inter_chars = S[i].keys() & S[i+1].keys()
ans = {}
for i in range(N):
    for c in inter_chars:
        if c not in ans:
            ans[c] = S[i][c]
        elif S[i][c] < ans[c]:
            ans[c] = S[i][c]
print(''.join(sorted(k*v for k, v in ans.items())))
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import string


n=int(input())
S=[]
for i in range (0,n):
  S.append(input())

count=0
for c in range(97,97+26):
  a=S[0].count(chr(c))
  for i in range(0,n):
    a=min(a,S[i].count(chr(c)))
  count+=a
print(count)


Failing test case input:
3
caa_
c_bcb
abaacd

Expected output:
c


Actual output:
1


Fixed submission (verdict: Accepted):
import string


n=int(input())
S=[]
for i in range (0,n):
  S.append(input())

count=0
ans=""
for c in range(97,97+26):
  a=S[0].count(chr(c))
  for i in range(0,n):
    a=min(a,S[i].count(chr(c)))
  for i in range (0,a):
    ans+=chr(c)
print(ans)

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

def main():
  n = int(input())
  ans = ""
  dics = []
  
  az = "abcdefghijklmnopqrstuwvxyz"

  for i in range(n):
    dic = {}
    s = input()
    for c in az:
      dic[c] = s.count(c)
    dics.append(dic)

  

  for c in az:
    can_use = True
    m = 50
    for dic in dics:
      if dic[c] == 0:
        can_use = False
        break

      m = min(m, dic[c])

    if(can_use):
      ans += c * min(m, n - len(ans))

    if(len(ans) >= n):
      break

  print(ans)

if __name__ == "__main__":
    main()

Failing test case input:
3
cacb
ccabe
`cacbc

Expected output:
abcc


Actual output:
abc


Fixed submission (verdict: Accepted):

def main():
  n = int(input())
  ans = ""
  dics = []
  
  az = "abcdefghijklmnopqrstuvwxyz"

  for i in range(n):
    dic = {}
    s = input()
    for c in az:
      dic[c] = s.count(c)
    dics.append(dic)

  for c in az:
    can_use = True
    m = 50

    for dic in dics:
      if dic[c] == 0:
        can_use = False
        break

      m = min(m, dic[c])

    if(can_use):
      ans += c * m

  print(ans)

if __name__ == "__main__":
    main()

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(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):
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
caaa
daacc
acacac

Expected output:
aac


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())
s = [input() for _ in range(n)]

min_len = float('inf')
short_s =""
for i in range(n):
  if min_len>len(s[i]):
    min_len = len(s[i])
    short_s = s[i]

c = []
for i in short_s:
  if all(i in s[j] for j in range(n)):
    c.append(i)

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

Failing test case input:
3
aaca
bda`c
cacaca

Expected output:
ac


Actual output:
aaac


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

min_len = float('inf')
short_s =[]
for i in range(n):
  if min_len>len(s[i]):
    min_len = len(s[i])
    for j in range(len(s[i])):
      short_s.append(s[i][j])

c = []
for i in range(len(short_s)):
  if all(short_s[i] in s[j] for j in range(n)):
    for k in range(n):
      s[k].remove(short_s[i])
    c.append(short_s[i])

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

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

N = int(input())

S = collections.Counter(list(input()))
for i in range(N-1):
    c = collections.Counter(list(input()))
    S &= c

print(sum(S.values()))

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

Expected output:
c


Actual output:
1


Fixed submission (verdict: Accepted):
import collections

N = int(input())

S = collections.Counter(list(input()))
for i in range(N-1):
    c = collections.Counter(list(input()))
    S &= c

ans = []
for i in S.items():
    ans += i[0]*i[1]
ans.sort()
print(*ans, sep="")
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s_common = list(input())

for i in range(n-1):
    s = list(input())
    for c in s_common:
        if c in s:
            s.remove(c)
        else:
            s_common.remove(c)

s_common.sort()
s_common = "".join(s_common)
print(s_common)


Failing test case input:
3
aaca
c`bcb
acdaac

Expected output:
c


Actual output:
ac


Fixed submission (verdict: Accepted):
n = int(input())
s_common = list(input())
s_common_pre = ""
for i in range(n-1):
    s = list(input())
    s_common_pre = s_common.copy()
    len_common = len(s_common_pre)
    for i in range(len_common):
        if s_common_pre[i] in s:
            s.remove(s_common_pre[i])
        else:
            s_common.remove(s_common_pre[i])

s_common.sort()
s_common = "".join(s_common)
print(s_common)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
s = []
s0 = list(input())
sc = Counter(s0)
for i in range(1,n):
    a = list(input())
    ac = Counter(a)
    for i,v in ac.items():
        if i not in sc:
            continue
        elif sc[i] < v:
            ac[i] = sc[i]
    sc = ac
sc2 = sorted(sc.items())
for i,v in sc2:
    for j in range(v):
        print(i,end='')

Failing test case input:
3
baaa
cca`d
acacac

Expected output:
a


Actual output:
acc

Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
s = []
s0 = list(input())
sc = Counter(s0)
for i in range(1,n):
    a = list(input())
    ac = Counter(a)
    for i,v in ac.items():
        if i not in sc:
            continue
        elif sc[i] > v:
            sc[i] = ac[i]
    for i,v in sc.items():
        if i not in ac:
            sc[i] = 0
sc2 = sorted(sc.items())
for i,v in sc2:
    for j in range(v):
        print(i,end='')

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

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

alphabet = set(s[0])

for i in range(1, n):
    alphabet = alphabet & set(s[i])

count_min = defaultdict(lambda: 10**9)
for a in sorted(alphabet):
    count_min[a] = min(count_min[a], s[0].count(a))

ans = ""

for k, v in sorted(count_min.items()):
    for i in range(v):
        ans += k
print(ans)

Failing test case input:
3
caaa
cca`d
acacac

Expected output:
ac


Actual output:
aaac


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

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

alphabet = set(s[0])

for i in range(1, n):
    alphabet = alphabet & set(s[i])

count_min = defaultdict(lambda: 10**9)
for a in sorted(alphabet):
    for i in range(n):
        count_min[a] = min(count_min[a], s[i].count(a))

ans = ""

for k, v in sorted(count_min.items()):
    for i in range(v):
        ans += k
print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
str_list=[str(input()) for i in range(a)]

x=[]
for i in range(len(str_list[0])):
  check=True;
  for j in range(len(str_list)):
    if str_list[0][i] in str_list[j]:
      str_list[j].replace(str_list[0][i],"",1)
    else:
      check=False;
  if check:
    x.append(str_list[0][i])
print(''.join(sorted(x)))
    

Failing test case input:
3
aaac
cca`d
cacaca

Expected output:
ac


Actual output:
aaac


Fixed submission (verdict: Accepted):
a=int(input())
str_list=[str(input()) for i in range(a)]
x=[]
for i in range(len(str_list[0])):
  check=True;
  for j in range(1,a):
    if str_list[0][i] in str_list[j]:
      str_list[j] = str_list[j].replace(str_list[0][i],'',1);
    else:
      check=False;
  if check:
    x.append(str_list[0][i])
if len(x) > 0:
  print(''.join(sorted(x)))
else:
  print('')

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = []
for i in range(N):
    S.append(input())
queue = []
S0len = len(S[0])

for j in range(S0len):
    flag = [0 for m in range(N)]
    for k in range(1,N):
        if S[0][j] in S[k]:
            flag[k] = 1
            
    if sum(flag) == N-1:
        queue.append(S[0][j])

queue = sorted(queue)
res = "".join(queue)
        
print(res)


Failing test case input:
3
aabc
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()))
queue = []
len = len(S[0])

for j in range(len):
    flag = [0 for m in range(N)]
    for k in range(1,N):
        if S[0][j] in S[k]:
            flag[k] = 1
            S[k].remove(S[0][j])
            
    if sum(flag) == N-1:
        queue.append(S[0][j])

queue = sorted(queue)
res = "".join(queue)
        
print(res)

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)

Failing test case input:
3
caca
cca`d
acacac

Expected output:
acc


Actual output:
a a c c


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=[]
for i in range(n):
    s.append(input())
ls = sorted(list(set(s[0])))
print(ls)
ans = ""
for l in ls:
    cnt = min ([s[i].count(l) for i in range(n)] )
    ans += l*cnt
print(ans)

Failing test case input:
3
aabc
cca`d
acacac

Expected output:
ac


Actual output:
['a', 'b', 'c']
ac


Fixed submission (verdict: Accepted):

n = int(input())
s=[]
for i in range(n):
    s.append(input())
ls = sorted(list(set(s[0])))
ans = ""
for l in ls:
    cnt = min ([s[i].count(l) for i in range(n)] )
    ans += l*cnt
print(ans)

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n=int(input())
ans=''
counter={}
for i in range(n):
    if i==0:
        s=input()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

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

print(ans)

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())
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())
abc=list("abcdefghijklmnopqrstuvwxyz")
D={}
for a in abc:
    D[a]=0

for i in range(n):
    s=input()
    for a in abc:
        now=D[a]
        num=s.count(a)
        if i==0:
            D[a]=num
        else:
            D[a]=min(now,num)
    

ans=""
print(ans)


Failing test case input:
3
`a_c
bcc_c
abaacc

Expected output:
c


Actual output:

Fixed submission (verdict: Accepted):
n=int(input())
abc=list("abcdefghijklmnopqrstuvwxyz")

D={}
for a in abc:
    D[a]=0

for i in range(n):
    s=input()
    for a in abc:
        now=D[a]
        num=s.count(a)
        if i==0:
            D[a]=num
        else:
            D[a]=min(now,num)
ans=""

for s,v in D.items():
    ans+=s*v
ans="".join(sorted(ans))
print(ans)