ZhenlongDai/ACPR huggingface dataset:
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
N = int(input())
SRR = []

for i in range(N):
    SRR.append(input())

def calculate(n, srr):
    
    

    
    

    res = collections.Counter(srr[0])


    for sr in srr:
        sr = collections.Counter(sr)
        res = sr & res

    result = ""
    for key in res.keys():
        result += key * res.get(key)

    print(result)

calculate(N, SRR)


Failing test case input:
3
aaca
bda`c
cacaca

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
import collections

N = 3
SRR = [
    "cbaa",
    "daacc",
    "acacac"
]

N = 3
SRR = [
    "a",
    "aa",
    "b",
]

N = 3
SRR = [
    "addc",
    "dda",
    "da",
]

N = int(input())
SRR = []

for i in range(N):
    SRR.append(input())

def calculate(n, srr):
    
    

    
    

    res = collections.Counter(srr[0])


    for sr in srr:
        sr = collections.Counter(sr)
        res = sr & res

    
    result = ""
    for key in sorted(res.keys()):
        result += key * res.get(key)

    print(result)

calculate(N, SRR)

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

s={}
for i in range(len(l[0])):
    if l[0][i] in s.keys():
        s[l[0][i]]+=1
    else:
        s[l[0][i]]=1

for i in l:
    d={}
    for j in range(len(i)):
        if i[j] in d.keys():
            d[i[j]]+=1
        else:
            d[i[j]]=1
    for k in s.keys():
        for l in d.keys():
            if k==l:
                min(s[k],d[l])
                break
        else:
            s[k]=0
s=sorted(s.items())

a=''
for i in s:
    if i[1]!=0:
        a+=i[0]*i[1]
print(a)

Failing test case input:
3
aabc
bda`c
acacac

Expected output:
ac


Actual output:
aac


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

s={}
for i in range(len(l[0])):
    if l[0][i] in s.keys():
        s[l[0][i]]+=1
    else:
        s[l[0][i]]=1

for i in l:
    d={}
    for j in range(len(i)):
        if i[j] in d.keys():
            d[i[j]]+=1
        else:
            d[i[j]]=1
    for k in s.keys():
        for l in d.keys():
            if k==l:
                s[k]=min(s[k],d[l])
                break
        else:
            s[k]=0
s=sorted(s.items())

a=''
for i in s:
    if i[1]!=0:
        a+=i[0]*i[1]
print(a)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)))

Failing test case input:
3
aa_c
bcb_c
abaacc

Expected output:
c


Actual output:
bc


Fixed submission (verdict: Accepted):
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)))

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

from collections import Counter as cn

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

oi = l[0]

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



Failing test case input:
3
c_aa
bcb_c
abaacc

Expected output:
c


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


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())
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 = {}
for a in sorted(alphabet):
    count_min[a] = s[0].count(a)

ans = ""

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

Failing test case input:
3
caa`
`cacd
cacaca

Expected output:
ac


Actual output:
aac


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 (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)
         print(m)
    list.append(alphabet[k]*m)

print(list)



Failing test case input:
3
caa_
c_bcb
dcaaba

Expected output:
c


Actual output:
2
0
3
0
2
1
1
2
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
['aaa', 'b', 'c', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']


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):
al=[chr(ord('a') + i) for i in range(26)]
from collections import Counter

n=int(input())
S=[0]*n
d=[0]*n
for i in range(n):
  S[i]=input()
  d[i]=dict(Counter(S[i]))
  
  
maxi=dict()
for str in d[0]:
  maxi[str] = d[0][str]
  for i in range(1,n):
    if str in d[i]:
      maxi[str]= min(d[0][str],d[i][str])
    else:
      maxi[str]=0
      break


ans=[]
for str in maxi:
  for i in range(maxi[str]):
    ans.append(str)
ans.sort()
print("".join(ans))

Failing test case input:
3
caab
d`acc
cacaca

Expected output:
ac


Actual output:
aac


Fixed submission (verdict: Accepted):
al=[chr(ord('a') + i) for i in range(26)]
from collections import Counter

n=int(input())
S=[0]*n
d=[0]*n
for i in range(n):
  S[i]=input()
  d[i]=dict(Counter(S[i]))
  
  
maxi=dict()
for str in d[0]:
  maxi[str] = d[0][str]
  for i in range(1,n):
    if str in d[i]:
      maxi[str]= min(maxi[str],d[i][str])
    else:
      maxi[str]=0
      break


ans=[]
for str in maxi:
  for i in range(maxi[str]):
    ans.append(str)
ans.sort()
print("".join(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())])
    print(s[:n] if len(s) >= n else "")


if __name__ == '__main__':
    main()


Failing test case input:
3
acaa
ccb_c
ccaaca

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

from collections import Counter as cn

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

oi = l[0]

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



Failing test case input:
3
aabc
cca`d
acacac

Expected output:
ac


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


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

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(n):
            s[j].replace(s[0][i], "", 1)

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

Failing test case input:
3
caaa
daacc
cacaca

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())
ss = []
for i in range(n):
    s = list(input())
    s.sort()
    ss.append(s)
ans = []
ans = ss[0]
for i in range(n):
    for j in ans:
        if ss[i].count(j) < ans.count(j):
            ans.remove(j)
print(''.join(ans))


Failing test case input:
3
`a_c
bcb_c
abaacc

Expected output:
c


Actual output:
ac


Fixed submission (verdict: Accepted):
n = int(input())
ss = []
for i in range(n):
    s = list(input())
    s.sort()
    ss.append(s)
ans = []
ans = ss[0]
for i in range(n):
    for j in ans:
        if ss[i].count(j) < ans.count(j):
            ans.remove(j)
for i in range(n):
    for j in ans:
        if ss[i].count(j) < ans.count(j):
            ans.remove(j)
print(''.join(ans))

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 = ''
    same = False
    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
_aac
c_bcb
abaacd

Expected output:
c


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

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]:
            count += 1

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

print(ans)


Failing test case input:
3
a`ca
c`bcb
caacca

Expected output:
c


Actual output:
`c


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):
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="")

Failing test case input:
3
cbaa
d`acc
acacac

Expected output:
ac


Actual output:
a

Fixed submission (verdict: Accepted):
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()

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():
            d[k] = min(s[k], v)
    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()


Failing test case input:
3
acba
da`cb
acacbc

Expected output:
abc


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


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 (PyPy3 (7.3.0), verdict: Wrong Answer):

N = int(input())
S = []
nagasa = 51
for i in range(N):
    dam = input()
    S.append(dam)
    if len(list(dam)) < nagasa:
        nagasa = len(list(dam))
        saisyo=i


flg=[0]*len(S[saisyo])
for i in range(len(S[saisyo])):
    for j in range(1,N):
        for k in range(len(S[j])):
            if S[saisyo][i] == S[j][k]:
                flg[i] +=1
                break

out=[]
for i in range(len(S[saisyo])):
    if flg[i]==N-1:
        out.append(S[saisyo][i])
out=sorted(out)

print(''.join(out))


Failing test case input:
3
aaac
cda`c
acacac

Expected output:
ac


Actual output:
aaac


Fixed submission (verdict: Accepted):

N = int(input())
S = []
nagasa = 51
for i in range(N):
    dam = input()
    S.append(dam)
    if len(list(dam)) < nagasa:
        nagasa = len(list(dam))
        saisyo=i


flg=[0]*len(S[saisyo])
for i in range(len(S[saisyo])):
    for j in range(N):
        if j==saisyo:
            continue
        else:
            for k in range(len(S[j])):
                if S[saisyo][i] == S[j][k]:
                    flg[i] +=1
                    l = list(S[j])
                    l[k] = 'A'
                    S[j] = ''.join(l)
                    
                    break

out=[]
for i in range(len(S[saisyo])):
    if flg[i]==N-1:
        out.append(S[saisyo][i])
out=sorted(out)

print(''.join(out))

Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
3
cbaa
d`acc
acacac

Expected output:
ac


Actual output:
ca


Fixed submission (verdict: Accepted):
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='')
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+1
                break
    tmp = 0
    onaji = new
    new = []
            
print(*onaji,sep="")

Failing test case input:
3
caa`
`cacd
cacaca

Expected output:
ac


Actual output:
aac


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 (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import Counter
n = int(input())
x = []
for i in range(n):
    s = input()
    t = Counter(s)
    x.append(t)
ans = ""
for i in "abcdefghijklmnopqrstuvwxyz":
    tmp = []
    for j in x:
        tmp.append(j[i])
        print(tmp)
    ans += i*min(tmp)
print(ans)

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

Expected output:
c


Actual output:
[2]
[2, 0]
[2, 0, 3]
[0]
[0, 1]
[0, 1, 1]
[1]
[1, 3]
[1, 3, 1]
[0]
[0, 0]
[0, 0, 1]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
[0]
[0, 0]
[0, 0, 0]
c


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
x = []
for i in range(n):
    s = input()
    t = Counter(s)
    x.append(t)
ans = ""
for i in "abcdefghijklmnopqrstuvwxyz":
    tmp = []
    for j in x:
        tmp.append(j[i])
    ans += i*min(tmp)
print(ans)
Problem: p03761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[]
for i in range(n):
    s=list(str(input()))
    s.sort()
    a.append(s)
a.sort()

ans=''
for j in range(len(a[0])):
    for i in range(1,n):
        if a[0][j] not in a[i]:
            break
    else:
        ans+=a[0][j]
b=list(set(ans))


ANS=''
for i in range(len(b)):
    c=[]
    for j in range(n):
        c.append(a[j].count(b[i]))
    ANS+=min(c)*b[i]
print(ANS)

Failing test case input:
3
caca
cca`d
acacac

Expected output:
acc


Actual output:
cca


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

ans=''
for j in range(len(a[0])):
    for i in range(1,n):
        if a[0][j] not in a[i]:
            break
    else:
        ans+=a[0][j]
b=list(set(ans))


ANS=[]
for i in range(len(b)):
    c=[]
    for j in range(n):
        c.append(a[j].count(b[i]))
    ANS.append(min(c)*b[i])
ANS.sort()
ANS=''.join(map(str,ANS))
print(ANS)

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
cbaa
d`acc
acacac

Expected output:
ac


Actual output:
aaaccc


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



n = int(input())
arr = []
for i in range(n):
    arr.append(sorted(list(input())))
    
common = arr[0]
for i in range(1,n):
    ind = []
    for c in common:
        if c in arr[i]:
            continue
        else:
            ind.append(common.index(c))
    for j in sorted(ind,reverse=True):
        common.pop(j)

print("".join(common))
        



Failing test case input:
3
caaa
`cacd
cacaca

Expected output:
ac


Actual output:
aaac


Fixed submission (verdict: Accepted):


import collections
n = int(input())
arr = []
for i in range(n):
    arr.append(collections.Counter(input()))
    
common = arr[0]
for key, value in common.items():
    for i in range(1,n):
        if arr[i][key] < common[key]:
            common[key] = arr[i][key]

ans = ''
for key, value in common.items():
    ans += key*value

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

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

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

intersection = mset(inputs.pop(0))

for w in inputs:
    intersection = mset(w) & intersection

print(''.join(list(intersection.elements())))

Failing test case input:
3
caaa
daacc
cacaca

Expected output:
aac


Actual output:
caa


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

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

intersection = mset(inputs.pop(0))

for w in inputs:
    intersection = mset(w) & intersection

print(''.join(sorted(list(intersection.elements()))))

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))
        if len(ans) > a:
            break

if len(ans) < a:
    ans = ""
else:
    ans[0:a-1]
            
print(ans)

Failing test case input:
3
acaa
bcb_c
ccaaca

Expected output:
c


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):
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 dics[0].items():
        mincnt = v
        for i in range(1,N):
            mincnt = min(v,dics[i][k])
        ans += k*mincnt
    ans = ''.join(sorted(list(ans)))
    return ans
print(solve())

Failing test case input:
3
caaa
bcb_c
ccaaca

Expected output:
c


Actual output:
aaac


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

x=list(input())
l=len(x)

for k in range(n-1):
    a=list(input())
    m=len(a)
    for i in range(l-1,-1,-1):
        for j in range(m):
            if x[i]==a[j]:
                break
        else:
            del x[i]
            l-=1

x.sort()
   
print(''.join(x))


Failing test case input:
3
caaa
daacc
cacaca

Expected output:
aac


Actual output:
aaac


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

x=list(input())
l=len(x)

for k in range(n-1):
    a=list(input())
    m=len(a)
    for i in range(l-1,-1,-1):
        for j in range(m-1,-1,-1):
            if x[i]==a[j]:
                del a[j]
                m-=1
                break
        else:
            del x[i]
            l-=1

x.sort()
   
print(''.join(x))

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

for i in range(n):
	s = list(input())
	S.append(s)

ans = ''
S[0].sort()

for i in range(len(S[0])):
	a = S[0][i]
	l = 0
	for j in range(n - 1):
		if a in S[j + 1]:
			l += 1
		if l == n - 1:
			ans += a
print(ans)

Failing test case input:
3
caa`
`cacd
cacaca

Expected output:
ac


Actual output:
aac


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


S[0].sort()

for i in range(len(S[0])):
	if n == 1:
		ans = ''.join(S[0])
	a = S[0][i]
	l = 0
	for j in range(n - 1):
		if a in S[j + 1]:
			S[j + 1].remove(a)
			l += 1
		if l == n - 1:
			ans += a


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])
  for k, v in max_str.items():
    if k in tmp:
      max_str[k] = min(max_str[k], v)
    else:
      max_str[k] = 0
ans = ""
for k, v in sorted(max_str.items()):
  ans += k * v
print(ans)


Failing test case input:
3
aaac
cca`d
acacac

Expected output:
ac


Actual output:
aaac


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.4.3), verdict: Wrong Answer):
import collections
n=int(input())
f={}
for i in range(n):
  S=input() 
  c=collections.Counter(S)
  for j in range(len(c)):
    x=c.most_common()[j][0]
    y=c.most_common()[j][1]
    if i==0:
      f.setdefault(x,y)
  try:      
    if f[x]>y:
      f[x]=y
  except:
    pass
A=sorted(f)
li=[a*f[a] for a in A]
print("".join(li))

Failing test case input:
3
aaca
bcb`c
acacac

Expected output:
c


Actual output:
aaac


Fixed submission (verdict: Accepted):
import collections
n=int(input())
f={}
for i in range(n):
  S=input() 
  s=list(S)
  c=collections.Counter(S)
  for j in range(len(c)):
    x=c.most_common()[j][0]
    y=c.most_common()[j][1]
    if i==0:
      f.setdefault(x,y)
    else:
      for k in f.keys():
        if k not in s:
          f[k]=0
        else:
          if f[k]>s.count(k):
            f[k]=s.count(k)
A=sorted(f)
li=[a*f[a] for a in A]
print("".join(li))

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
result = sorted(result)
print(result)

Failing test case input:
3
caab
d`acc
cacaca

Expected output:
ac


Actual output:
a, c

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

s_1 = list(strings.pop(0))
for s in strings:
    for s_tmp in s_1:
        if s_tmp not in s:
            s_1.remove(s_tmp)
s_1.sort()
print(''.join(s_1))

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

Expected output:
c


Actual output:
ac


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


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

ans = ""
c = ord("a")

for i in S[0]:
    flag = True
    for j in range(n):
        if i not in S[j]:
            flag = False
            break

    if flag:
        ans += i

print(ans)


Failing test case input:
3
caaa
cda`c
acacac

Expected output:
ac


Actual output:
aaac


Fixed submission (verdict: Accepted):


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

ans = ""

for i in S[0]:
    flag = True
    for j in range(n):
        if i not in S[j]:
            flag = False
            break

    if flag:
        ans += i
        for j in range(n):
            S[j] = S[j][0:S[j].index(i)] + S[j][S[j].index(i)+1:]

print(ans)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

list = []
for i in range(len(a)-1):
    for j in range(len(b)-1):
        if j >= i:
            sub = b[j]-a[i]
            list.append(sub)
print(max (list))


Failing test case input:
3
-42
0
2

Expected output:
44


Actual output:
42


Fixed submission (verdict: Accepted):
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

maxv = -1000000000
minv = a[0]
for i in range(len(a)):
    maxv = max(maxv,b[i]-minv)
    minv = min(minv,b[i])
print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())

R = []

for i in range(0,n):
    R.insert(i, int(input()))

m = min(R[0:2])
MAX = R[1] - R[0]
for r in range(1, n-1):
    if(R[r] < m):
        m = R[r]
    MAX = R[r+1] - m

print(MAX)

Failing test case input:
3
-33
0
-2

Expected output:
33


Actual output:
31


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

R = []

for i in range(0,n):
    R.insert(i, int(input()))

m = min(R[0:2])
MAX = R[1] - R[0]
for r in range(2, n):
    if(R[r-1] < m):
        m = R[r-1]
    MAX2 = R[r] - m
    if(MAX2 > MAX):
        MAX = MAX2

print(MAX)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
i, j = int(input()), 0
nmin = i
a = 0
for h in range(n - 1):
    j = int(input())
    if j < nmin:
        nmin = j
        continue

    if j - nmin > a:
        a = j - nmin

print(a)

Failing test case input:
3
2
1
-1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
i, j = int(input()), 0
nmin = i
a = -2 * 10 ** 9
for h in range(n - 1):
    j = int(input())
    a = max(a, j - nmin)
    if j < nmin:
        nmin = j

print(a)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
maxn=0
minn=int(input())

for j in range(1, n):
    r = int(input())
    maxn = max(maxn, r - minn)
    minn = min(minn, r)
    
print(maxn)


Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
maxn=-10**12
minn=int(input())

for j in range(1, n):
    r = int(input())
    maxn = max(maxn, r - minn)
    minn = min(minn, r)
    
print(maxn)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import math
 
n = int(input())
tmp = int(input())
tmpmin = tmp
t1 = int(input())
if t1 < tmp: tmpmin = t1
tmpmax = t1 - tmp
ans = 0
 
 
for i in range(2,n):
    tmp = int(input())
  
    if tmp - tmpmin > ans: ans = tmp - tmpmin
    if tmp < tmpmin: tmpmin = tmp
     
print(int(ans))  


Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
import math
 
n = int(input())
tmp = int(input())
tmpmin = tmp
t1 = int(input())
if t1 < tmp: tmpmin = t1
ans = t1 - tmp
 
 
for i in range(2,n):
    tmp = int(input())
  
    if tmp - tmpmin > ans: ans = tmp - tmpmin
    if tmp < tmpmin: tmpmin = tmp
     
print(int(ans))
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
input_line = []
for i in range(N):
    input_line.append(int(input()))

print(input_line)
maxv = input_line[1] - input_line[0]
minv = input_line[0]
for j in range(1, N):
    maxv = max(maxv, input_line[j] - minv)
    minv = min(minv, input_line[j])
print(maxv)

Failing test case input:
3
-47
-1
-2

Expected output:
46


Actual output:
[-47, -1, -2]
46


Fixed submission (verdict: Accepted):
N = int(input())
input_line = []
for i in range(N):
    input_line.append(int(input()))

maxv = input_line[1] - input_line[0]
minv = input_line[0]
for j in range(1, N):
    maxv = max(maxv, input_line[j] - minv)
    minv = min(minv, input_line[j])
print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
M, m = 1, 10 ** 9
for _ in range(N):
    n = int(input())
    M = n if M < n else M
    m = n if m > n else m
print(M - m)

Failing test case input:
3
4
1
3

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
P, m = - 10 ** 9, int(input())
for _ in range(1, N):
    n = int(input())
    P = n - m if n - m > P else P
    m = n if m > n else m
print(P)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
data = [int(input()) for i in range(n)]

min_value = data.pop(0)
max_value = -100000000
print(data)
for d in data:
    max_value = max(d, max_value)
    min_value = min(d, min_value) 
print(max_value - min_value)

Failing test case input:
6
5
1
0
2
-40
0

Expected output:
40


Actual output:
[1, 0, 2, -40, 0]
42


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

min_value = data.pop(0)
earn_value = -1000000000000
for d in data:
    earn_value = max(d - min_value, earn_value)
    min_value = min(d, min_value) 
print(earn_value)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())

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

maxv =  int(-20000000)
minv = int(r[0])

for i in range(n):
    maxv = int(max(maxv, r[i]-minv))
    minv = int(min(minv, r[i]))

print(maxv)



Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
0


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

maxv = -10**18
minv = 10**18

for i in range(n):
    r= int(input())
    maxv = max(maxv, r - minv)
    minv = min(minv, r)

print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
R = [int(input(i)) for i in range(N)]


maxv = -20000000000

minv = R[0]

for i in range(1, N):
    
    maxv = max(R[i] - minv, maxv)
    
    minv = min(R[i], minv)

print(maxv)

Failing test case input:
6
2
21
-2
4
4
0

Expected output:
19


Actual output:
01234519


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

maxv = -20000000000
minv = R[0]

for i in range(1, N):
    maxv = max(R[i] - minv, maxv)
    minv = min(R[i], minv)

print(maxv)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
R = [int(input()) for _ in range(n)]
bottom = R[0]
ans = R[1] - bottom
for i in range(2, n):
    ans = max(ans, R[i] - bottom)
    if R[i] < bottom:
        bottom = R[i]
print(ans)

Failing test case input:
3
1
-3
9

Expected output:
12


Actual output:
8


Fixed submission (verdict: Accepted):
n = int(input())
R = [int(input()) for _ in range(n)]
ans = R[1] - R[0]
bottom = min(R[0], R[1])
for i in range(2, n):
    ans = max(ans, R[i] - bottom)
    if R[i] < bottom:
        bottom = R[i]
print(ans)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import math

N = int(input())
R = [int(input().strip()) for _ in range(N)]

maxv = -math.inf
minv = R[0]
for i in range(1, N-1):

    tmp_maxv = R[i] - minv 
    
    if maxv < tmp_maxv:
        maxv = tmp_maxv

    
    if R[i] < minv:
        minv = R[i]

print(maxv)


Failing test case input:
3
2
-2
4

Expected output:
6


Actual output:
-4


Fixed submission (verdict: Accepted):
import math

N = int(input())
R = [int(input().strip()) for _ in range(N)]

maxv = -math.inf
minv = R[0]
for i in range(1, N):

    tmp_maxv = R[i] - minv 
    
    if maxv < tmp_maxv:
        maxv = tmp_maxv

    
    if R[i] < minv:
        minv = R[i]

print(maxv)

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





import sys


def solve():
    
    max_profit = 0
    min_stock = prices[0]
    for price in prices[1:]:
        max_profit = max(max_profit, price - min_stock)
        min_stock = min(min_stock, price)
    return max_profit if max_profit else -1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    p_num = int(_input[0])
    prices = list(map(int, _input[1:]))
    print(solve())

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
-1


Fixed submission (verdict: Accepted):





import sys


def solve():
    
    max_profit = -1 * float('inf')
    min_stock = prices[0]
    for price in prices[1:]:
        max_profit = max(max_profit, price - min_stock)
        min_stock = min(min_stock, price)
    return max_profit


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    p_num = int(_input[0])
    prices = list(map(int, _input[1:]))
    print(solve())

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

mini = a[0]
b = -100000

for i in a:
    if mini > i:
        mini = i
    if b < i - mini:
        b = i - mini

print(b)




Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
0


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

mini = a[0]
b = -10000000000
del a[0]
for i in a:
    if b < i - mini:
        b = i - mini
    if mini > i:
        mini = i

print(b)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
minv = -1000000000
maxv = 1000000000

for _ in range(int(input())) :
    num	= int(input())
    maxv = max(maxv,num	- minv)
    minv = min(minv,num)
print(maxv)



Failing test case input:
6
6
3
-1
14
1
6

Expected output:
15


Actual output:
1000000014


Fixed submission (verdict: Accepted):
maxv = -10000000000
minv = 10000000000

for _ in range(int(input())) :
    num	= int(input())
    maxv = max(maxv,num	- minv)
    minv = min(minv,num)
print(maxv)

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


N = int(input())

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

ans = set()

maxv = -9999999999
minv = a[0]
for i in range(1,N-1):
    if (a[i] - minv) > maxv:
        maxv = a[i] - minv
    if a[i] < minv:
        minv = a[i]

print(maxv)

Failing test case input:
3
5
0
10

Expected output:
10


Actual output:
-5


Fixed submission (verdict: Accepted):


N = int(input())

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

ans = set()

maxv = -9999999999
minv = a[0]
for i in range(1,N):
    if (a[i] - minv) > maxv:
        maxv = a[i] - minv
    if a[i] < minv:
        minv = a[i]

print(maxv)

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


n = int(input())
R = []
max_num = 0
min_num = 10 ** 9

for i in range(n):
    R.append(int(input()))

for i in range(len(R)):
    max_num = max(max_num, (R[i] - min_num))
    min_num = min(min_num, R[i])

print(max_num)



Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
0


Fixed submission (verdict: Accepted):


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

for i in range(n):
    R.append(int(input()))

max_num = 1 - 10 ** 9
min_num = R[0]

for i in range(1, len(R)):
    max_num = max(max_num, (R[i] - min_num))
    min_num = min(min_num, R[i])

print(max_num)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

min_v = 1000000000
max_p = -1000000000
for i in range(1,n):
    max_p = max(max_p,r[i]-min_v)
    min_v = min(min_v,r[i])
print(max_p)

Failing test case input:
6
-17
61
2
1
-3
8

Expected output:
78


Actual output:
11


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

min_v = r[0]
max_p = -1000000000
for i in range(1,n):
    max_p = max(max_p,r[i]-min_v)
    min_v = min(min_v,r[i])
print(max_p)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
a = []

for i in range(N):
	a.append(int(input()))

maxv = -10e10
minv = 10e10

for i in range(1, N-1):
	maxv = a[i] - minv if maxv < a[i] - minv else maxv
	minv = a[i] if minv > a[i] else minv

print(maxv)


Failing test case input:
3
-66
-2
-2

Expected output:
64


Actual output:
-100000000000.0


Fixed submission (verdict: Accepted):
N = int(input())
a = []

for i in range(N):
	a.append(int(input()))

maxv = -10e10
minv = a[0]

for i in range(1, N):
	maxv = a[i] - minv if maxv < a[i] - minv else maxv
	minv = a[i] if minv > a[i] else minv

print(maxv)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
R = [int(input()) for _ in range(n)]
minv, maxv = R[0], R[1]-R[0]
for j in range(1, n-1):
    maxv = max(maxv, R[j]-minv)
    minv = min(minv, R[j])
print(maxv)

Failing test case input:
3
5
0
10

Expected output:
10


Actual output:
-5


Fixed submission (verdict: Accepted):
n = int(input())
R = [int(input()) for _ in range(n)]
minv, maxv = R[0], R[1]-R[0]
for j in range(1, n):
    maxv = max(maxv, R[j]-minv)
    minv = min(minv, R[j])
print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N=int(input())

a=int(input())
b=int(input())
min_number=min(a,b)
profit=b-a


for i in range(N-2):
	c=int(input())
	if min_number>c:
		min_number=c
	if profit<c-min_number:
		profit=c-min_number

print(profit)

Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


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

a=int(input())
b=int(input())
min_number=min(a,b)
profit=b-a


for i in range(N-2):
	c=int(input())
	if profit<c-min_number:
		profit=c-min_number	
	if min_number>c:
		min_number=c


print(profit)

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

def get_maximum_profit():
    element_number = int(input())
    v0 = int(input())
    v1 = int(input())

    min_v = min(v0, v1)
    max_profit = v1-v0

    for i in range(element_number-2):
        v = int(input())
        max_profit = max(max_profit, v-min_v)
        min_v = min(min_v, v)
        print(min_v, max_profit)

    print(max_profit)

if __name__ == '__main__':
    get_maximum_profit()

Failing test case input:
3
-66
-2
-2

Expected output:
64


Actual output:
-66 64
64


Fixed submission (verdict: Accepted):
import sys

def get_maximum_profit():
    element_number = int(input())
    v0 = int(input())
    v1 = int(input())

    min_v = min(v0, v1)
    max_profit = v1-v0

    for i in range(element_number-2):
        v = int(input())
        max_profit = max(max_profit, v-min_v)
        min_v = min(min_v, v)

    print(max_profit)

if __name__ == '__main__':
    get_maximum_profit()

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

max = numbers[2] - numbers[1]


for i in range(1, len(numbers) - 1 ):
	for j in range(i + 1, len(numbers) - 1):
		if numbers[j] - numbers[i] > max :
			max = numbers[j] - numbers[i]
print(max)


Failing test case input:
3
3
0
9

Expected output:
9


Actual output:
-3


Fixed submission (verdict: Accepted):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]
tmp_min = numbers[1]
for target in range(2, len(numbers)):
	answer =  max(numbers[target] - tmp_min ,answer)
	tmp_min = min(numbers[target] , tmp_min)

print(answer)