qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from collections import Counter
from string import ascii_lowercase


n = int(input())
dic = {c: 50 for c in ascii_lowercase}
print(dic)
for _ in range(n):
    tmp = Counter(input())
    for c in ascii_lowercase:
        dic[c] = min(dic[c], tmp.get(c, 0))
print(''.join(c * dic[c] for c in ascii_lowercase))

Fixed code:
from collections import Counter
from string import ascii_lowercase


n = int(input())
dic = {c: 50 for c in ascii_lowercase}
for _ in range(n):
    tmp = Counter(input())
    for c in ascii_lowercase:
        dic[c] = min(dic[c], tmp.get(c, 0))
print(''.join(c * dic[c] for c in ascii_lowercase))
Buggy code:
n=int(input())
s=[input() for i in range(n)]
l=list("abcdefghijklmnopqrstuvwxyz")
c_tmp=[]
for j in l:
  for i in s:
    c_tmp.append(i.count(j))
  print(j*min(c_tmp),end="")

Fixed code:
n=int(input())
s=[input() for i in range(n)]
l=list("abcdefghijklmnopqrstuvwxyz")
c_tmp=[]
for j in l:
  for i in s:
    c_tmp.append(i.count(j))
  print(j*min(c_tmp),end="")
  c_tmp.clear()
Buggy code:
from collections import Counter

n = int(input())
S = [input() for i in range(n)]
set_char = set()
num_char = dict()
for s in S:
    for c in s:
        set_char.add(c)
    cnt = Counter(s)
    for c in set_char:
        if c not in num_char:
            num_char[c] = cnt[c]
        elif cnt[c] < num_char[c]:
            num_char[c] = cnt[c]
res = str()
for c in set_char:
    for i in range(num_char[c]):
        res = res + c
print("".join(sorted(res)))

Fixed code:
from collections import Counter

n = int(input())
S = [input() for i in range(n)]
set_char = set([c for c in S[0]])
num_char = dict()
for s in S:
    set_tmp = set()
    for c in s:
        set_tmp.add(c)
    set_char = set_char & set_tmp
    cnt = Counter(s)
    for c in set_char:
        if c not in num_char:
            num_char[c] = cnt[c]
        elif cnt[c] < num_char[c]:
            num_char[c] = cnt[c]
res = str()
for c in set_char:
    for i in range(num_char[c]):
        res = res + c
print("".join(sorted(res)))
Buggy code:
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)


Fixed code:
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)
Buggy code:
import sys
input = sys.stdin.readline
from collections import Counter,defaultdict
n=int(input())
al=[float("inf")]*26
a=ord("a")
print(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)


Fixed code:
import sys
input = sys.stdin.readline
from collections import Counter,defaultdict
n=int(input())
al=[float("inf")]*26
a=ord("a")
#print(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)
Buggy code:
from collections import Counter, defaultdict
n = int(input())
s = [input() for i in range(n)]

cnt = defaultdict(lambda :[0, 0])
for S in s:
    temp = Counter(S)
    for key, val in temp.items():
        if cnt[key] == [0, 0]:
            cnt[key] = [val, 1]
            continue
        if cnt[key][0] > val:cnt[key][0] = val
        cnt[key][1] = cnt[key][1] + 1

ans = ''
for key, val in cnt.items():
    if val[1] == n:
        ans += key * val[0]
print(ans)
#print(cnt)

Fixed code:
from collections import Counter, defaultdict
n = int(input())
s = [input() for i in range(n)]

cnt = defaultdict(lambda :[0, 0])
for S in s:
    temp = Counter(S)
    for key, val in temp.items():
        if cnt[key] == [0, 0]:
            cnt[key] = [val, 1]
            continue
        if cnt[key][0] > val:cnt[key][0] = val
        cnt[key][1] = cnt[key][1] + 1

ans = []
for key, val in cnt.items():
    if val[1] == n:
        ans += key * val[0]
print(*sorted(ans), sep='')
#print(cnt)
Buggy code:
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)))

Fixed code:
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)))
Buggy code:
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)

Fixed code:
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)
Buggy code:
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])):
            #print(i,j,tmp,k,onaji)
            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)

Fixed code:
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])):
            #   print(i,j,tmp,k,onaji)
            if tmp+k >= len(s[i]):
                break
            if onaji[j] == sort_s[i][tmp+k]:
                new.append(onaji[j])
                tmp = tmp+k+1
                break
    #tmp = 0
    onaji = new
    #new = []
            
print(*onaji,sep="")
Buggy code:
_,*s=open(0)
for c in sorted(s[0]):print(c*min(t.count(c)for t in s),end='')

Fixed code:
_,*s=open(0)
for c in sorted(set(s[0])):print(c*min(t.count(c)for t in s),end='')
Buggy code:
n = int(input())
s = [input() for i in range(n)]
ans = ''
for i in range(97,97+26):
    count=float("inf")
    for j in range(n):
        count=min(count,a[j].count(chr(i)))
    ans += chr(i)*count

print(ans)

Fixed code:
n = int(input())
s = [input() for i in range(n)]
ans = ''
for i in range(97,97+26):
    count=float("inf")
    for j in range(n):
        count=min(count,s[j].count(chr(i)))
    ans += chr(i)*count

print(ans)
Buggy code:
#
from collections import Counter as cn

d = int(input())
l = []
for k in range(d):
  r = input()
   
  l.append(Counter(r))

oi = l[0]

for g in range(1,d):
    oi = oi & l[g]
    
    
print("".join(sorted(oi.elements())))



Fixed code:

from collections import Counter

d = int(input())
l = []
for k in range(d):
  r = input()
   
  l.append(Counter(r))

oi = l[0]

for g in range(1,d):
    oi = oi & l[g]
    
    
print("".join(sorted(oi.elements())))
Buggy code:
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='')


Fixed code:
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='')
Buggy code:
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)


Fixed code:
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)
Buggy code:
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)

Fixed code:
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)
Buggy code:
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
ans=''
l='abcdefghijklmnopqrstuvwxyz'
for i in range(len(l)):
  c=10**9
  for j in range(n):
    c=min(c,s.count(l[i]))
  for j in range(c):
    ans+=l[i]
print(ans)

Fixed code:
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
ans=''
l='abcdefghijklmnopqrstuvwxyz'
for i in range(len(l)):
  c=10**9
  for j in range(n):
    c=min(c,s[j].count(l[i]))
  for j in range(c):
    ans+=l[i]
print(ans)
Buggy code:
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)

Fixed code:
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)
Buggy code:
import sys
import numpy as np
import string

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

dict = string.ascii_lowercase#abc...xyz

data_list = np.zeros((N,26))

for i in range(0,N):
	list = []
	for j in range(0,26):
		list.append(S[i].count(str(dict[j])))
	data_list[i] = np.array(list)
data_min = data_list.min(axis = 0)

del list
gc.collect()

a = np.nonzero(data_min)
size = np.nonzero(data_min)[0].size
b = a[0]
kotae = ""
for i in range(size):
	Moji = dict[b[i]]*int(data_min[b[i]])
	kotae = kotae + Moji
	pass
del data_min
gc.collect()

print(kotae)



Fixed code:
import sys
import numpy as np
import string

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

dict = string.ascii_lowercase#abc...xyz

data_list = np.zeros((N,26))

for i in range(0,N):
	list = []
	for j in range(0,26):
		list.append(S[i].count(str(dict[j])))
	data_list[i] = np.array(list)
data_min = data_list.min(axis = 0)

a = np.nonzero(data_min)
size = np.nonzero(data_min)[0].size
b = a[0]
kotae = ""
for i in range(size):
	Moji = dict[b[i]]*int(data_min[b[i]])
	kotae = kotae + Moji
	pass
print(kotae)
Buggy code:
from collections import Counter

N = int(input())
C = Counter(input())

for n in range(N-1):
    C&=Counter(input())

print(*C.elements(),sep="")

Fixed code:
from collections import Counter

N = int(input())
C = Counter(input())

for n in range(N-1):
    C&=Counter(input())

print(*sorted(C.elements()),sep="")
Buggy code:
n = int(input())
S = [input() for i in range(n)]
check = set()

for i in S:
    for j in i:
        check.add(j)

check = sorted(check)
print(check)
num_list = []
for i in check:
    num = float('inf')
    for j in S:
        num = min(num, j.count(i))
    num_list.append(num)

ans = [check[i] * num_list[i] for i in range(len(check))]

print(''.join(ans))

Fixed code:
n = int(input())
S = [input() for i in range(n)]
check = set()

for i in S:
    for j in i:
        check.add(j)

check = sorted(check)
num_list = []
for i in check:
    num = float('inf')
    for j in S:
        num = min(num, j.count(i))
    num_list.append(num)

ans = [check[i] * num_list[i] for i in range(len(check))]

print(''.join(ans))
Buggy code:
n = int(input())
S = [input() for i in range(n)]
check = set(S[i])
ans = []

for c in check:
    num = float('inf')
    for s in S:
        num = min(num, s.count(c))
        
    ans.append(num*c)
print(''.join(sorted(''.join(ans))))

Fixed code:
n = int(input())
S = [input() for i in range(n)]
check = set(S[0])
ans = []

for c in check:
    num = float('inf')
    for s in S:
        num = min(num, s.count(c))
        
    ans.append(num*c)
print(''.join(sorted(''.join(ans))))
Buggy code:
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))

Fixed code:
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))
Buggy code:
strs = []
inter1 = {}
for _ in range(n):
    strs.append(input())

for char in strs[0]:
    if char in inter1:
        inter1[char] +=1
    else:
        inter1[char] = 1
        
for i in range(1,n):
    inter2 = {}
    for char in strs[i]:
        if (char in inter1):
            if char in inter2:
                if inter2[char] < inter1[char]:
                    inter2[char] +=1
            else:
                inter2[char] =1 
    inter1 = inter2

inter = sorted(inter1.items())
ans = ''
for char,i in inter:
    for _ in range(i):
        ans +=char
print(ans)

Fixed code:
n = int(input())
strs = []
inter1 = {}
for _ in range(n):
    strs.append(input())

for char in strs[0]:
    if char in inter1:
        inter1[char] +=1
    else:
        inter1[char] = 1
        
for i in range(1,n):
    inter2 = {}
    for char in strs[i]:
        if (char in inter1):
            if char in inter2:
                if inter2[char] < inter1[char]:
                    inter2[char] +=1
            else:
                inter2[char] =1 
    inter1 = inter2

inter = sorted(inter1.items())
ans = ''
for char,i in inter:
    for _ in range(i):
        ans +=char
print(ans)
Buggy code:
n=int(input())
s=[input() for i in range(n)]
dic={}
for i in range(n):
  for j in s[i]:
    if not(j in dic[s[i]]):
      dic[j]=[0 for i in range(n)]
    dic[j][i]+=1
ans=[]
for i in dic.keys():
  ans.append(i*min(dic[i]))
ans.sort()
print(ans,sep='')

Fixed code:
n=int(input())
s=[input() for i in range(n)]
dic={}
for i in range(n):
  for j in s[i]:
    if not(j in dic):
      dic[j]=[0 for i in range(n)]
    dic[j][i]+=1
ans=[]
for i in dic.keys():
  ans.append(i*min(dic[i]))
ans.sort()
print(*ans,sep='')
Buggy code:
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
#print(max_str)
ans = ""
for k, v in sorted(max_str.items()):
  ans += k * v
print(ans)


Fixed code:
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
#print(max_str)
ans = ""
for k, v in sorted(max_str.items()):
  ans += k * v
print(ans)
Buggy code:
import string
from collections
n=int(input())
A=list(string.ascii_lowercase)
d={}
for _ in range(n):
    s=input()
    c=collections.Counter(s)
    for i in A:
        if i in c.keys():
            if i not in d:
                d[i]=c[i]
            else:
                d[i]=min(d[i],c[i])
        else:
            d[i]=0
ans=[]
for i in d:
    ans+=i*d[i]
ans.sort()
print(*ans,sep='')

Fixed code:
import string
import collections
n=int(input())
A=list(string.ascii_lowercase)
d={}
for _ in range(n):
    s=input()
    c=collections.Counter(s)
    for i in A:
        if i in c.keys():
            if i not in d:
                d[i]=c[i]
            else:
                d[i]=min(d[i],c[i])
        else:
            d[i]=0
ans=[]
for i in d:
    ans+=i*d[i]
ans.sort()
print(*ans,sep='')
Buggy code:
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)


Fixed code:
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)
Buggy code:
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('')



Fixed code:
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('')
Buggy code:
n=int(input())
l=[defaultdict(int) for i in range(n)]
for i in range(n):
    S=input()
    for s in S:
        l[i][s]+=1
t=""
for i in range(26):
    a=10**30
    for j in range(n):
        a=min(a,l[j][chr(i+ord("a"))])
    t+=chr(i+ord("a"))*a
print(t)


Fixed code:
from collections import defaultdict

n=int(input())
l=[defaultdict(int) for i in range(n)]
for i in range(n):
    S=input()
    for s in S:
        l[i][s]+=1
t=""
for i in range(26):
    a=10**30
    for j in range(n):
        a=min(a,l[j][chr(i+ord("a"))])
    t+=chr(i+ord("a"))*a
print(t)
Buggy code:
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]

Fixed code:
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])
#    print(j, ans[j], tmp[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)
Buggy code:
N=int(input())
from collections import Counter,defaultdict
s=input()
ddict=defaultdict(int)
for c in s:
  ddict[c]+=1
for i in range(N-1):
  s=input()
  cnt=Counter[s]
  for k in cnt.keys():
    ddict[k]=min(ddict[k],cnt[k])
ans=""
for k in range(26):    
  c =chr(ord("a")+k)
  ans+=c*ddict[c]
print(ans)
  

Fixed code:
N=int(input())
from collections import Counter,defaultdict
s=input()
ddict=defaultdict(int)
for c in s:
  ddict[c]+=1
for i in range(N-1):
  s=input()
  cnt=Counter(s)
  for k in cnt.keys():
    ddict[k]=min(ddict[k],cnt[k])
  for k in ddict.keys():
    if not k in cnt.keys():
      ddict[k]=0
ans=""
for k in range(26):    
  c =chr(ord("a")+k)
  ans+=c*ddict[c]
print(ans)
Buggy code:
n=int(input())
d = {}
for i in range(26):
  d[chr(ord("a")+i)]=10**9
for i in range(n):
  s=input()
  for j in range(26):
    d[chr(ord("a")+i)]=min(d[chr(ord("a")+i)], s.count(chr(ord("a")+i)))

ans = ""
for e in d.items():
  ans+=e[0]*e[1]
print(ans)
  
  

Fixed code:
n=int(input())
d = {}
for i in range(26):
  d[chr(ord("a")+i)]=10**9
for i in range(n):
  s=input()
  for j in range(26):
    d[chr(ord("a")+j)]=min(d[chr(ord("a")+j)], s.count(chr(ord("a")+j)))

ans = ""
for e in d.items():
  ans+=e[0]*e[1]
print(ans)
Buggy code:
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(D)
for s,v in D.items():
    ans+=s*v
    #print(s)
#ans="".join(sorted(ans))
print(ans)

        


Fixed code:
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)
Buggy code:
# https://atcoder.jp/contests/abc058/tasks/arc071_a

import sys
# sys.setrecursionlimit(100000)
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 = ""
    print(common_chr)
    for s, cnt in common_chr:
        ans += s * cnt
    print(ans)
    return


if __name__ == "__main__":
    main()


Fixed code:
# https://atcoder.jp/contests/abc058/tasks/arc071_a

import sys
# sys.setrecursionlimit(100000)
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()