Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
sum=0
for i in range(n-1):
    for j in range(i+1,n):
         sum += a[i]*a[j]
print(sum%mod)

Fixed submission:
n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
allsum = sum(a)
s = 0
for i in range(n):
    allsum = allsum -a[i]
    s += a[i]*allsum
print(s%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
s = 0
MOD = 10**9 + 7
rea = [num%MOD for num in a]
while len(rea) != 1:
    firstnum = rea.pop()
    for i in rea:
        b = firstnum * i
        s += b
s %= MOD
print(s)

Fixed submission:
n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
allsum = sum(a)
s = 0
for i in range(n):
    allsum = allsum -a[i]
    s += a[i]*allsum
print(s%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
s = 0
MOD = 10**9 + 7
while len(a) != 1:
    firstnum = a.pop()
    for i in a:
        b = (firstnum * i)%MOD
        s += b
s %= MOD
print(s)

Fixed submission:
n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
allsum = sum(a)
s = 0
for i in range(n):
    allsum = allsum -a[i]
    s += a[i]*allsum
print(s%mod)
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = list(map(int,input().split()))
dis = x
cnt = 0
def zet(x):
    if x >= 0:
        return x
    else:
        return -x
while cnt<k:
    if zet(dis)<d:
        recnt = k -cnt
        if recnt%2==0:
            pass
        else:
            dis = d-zet(dis)
        break
    elif dis>=0:
        dis = dis - d
    else:
        dis = dis + d
    cnt += 1
print(zet(dis))

Fixed submission:
x,k,d = list(map(int,input().split()))
x = abs(x)
point =x % d
num = x//d
if num<k:
    rest = k - num
    if rest%2==0:
        pass
    else:
        point = d -point
else:
    point = x - k*d
print(point)

Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = list(map(int,input().split()))
dis = x
cnt = 0
while cnt<k:
    if abs(dis)<d:
        recnt = k -cnt
        if recnt%2==0:
          pass
        else:
            dis = d-abs(dis)
        break
    elif dis>=0:
        dis = dis - d
    else:
        dis = dis + d
    cnt += 1
print(abs(dis))

Fixed submission:
x,k,d = list(map(int,input().split()))
x = abs(x)
point =x % d
num = x//d
if num<k:
    rest = k - num
    if rest%2==0:
        pass
    else:
        point = d -point
else:
    point = x - k*d
print(point)

Buggy python submission (verdict: Runtime Error):
x,k,d = list(map(int,input().split()))
dis = x
cnt = 0
while cnt<k:
    if abs(dis)<d:
        recnt = k -cnt
        if recnt%2==0:
        else:
            dis = d-abs(dis)
        break
    elif dis>=0:
        dis = dis - d
    else:
        dis = dis + d
    cnt += 1
print(abs(dis))

Fixed submission:
x,k,d = list(map(int,input().split()))
x = abs(x)
point =x % d
num = x//d
if num<k:
    rest = k - num
    if rest%2==0:
        pass
    else:
        point = d -point
else:
    point = x - k*d
print(point)

Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = list(map(int,input().split()))
cnt = 0
dis = x
while cnt<k:
    if dis>=0:
        dis = dis - d
    else:
        dis = dis + d
    cnt += 1
print(abs(dis))

Fixed submission:
x,k,d = list(map(int,input().split()))
x = abs(x)
point =x % d
num = x//d
if num<k:
    rest = k - num
    if rest%2==0:
        pass
    else:
        point = d -point
else:
    point = x - k*d
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans=1
for i in a:
    ans*=i
if ans>10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans=1
if 0 in a:
    ans=0
else:
    for i in a:
        ans*=i
        if ans>10**18:
            ans=-1
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 20:18:10 2020

@author: liang
"""
#D
N, K = map(int, input().split())
areas = list()
for i in range(K):
    l, r = map(int,input().split())
    areas.append((l,r))
areas_sum = [0] * N 

d = [0] * N
d[0] = 1
for i in range(N):
    for j in range(K):
        l, r = areas[j]
        if i-l >= 0:
            areas_sum[j] += d[i-l]
        if i-r-1 >= 0:
            areas_sum[j] -= d[i-r-1]
    d[i] += sum(areas_sum)
    d[i] %= 998244353 

#print(d)
ans = d[N-1]
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 20:18:10 2020

@author: liang
"""
#D
N, K = map(int, input().split())
areas = list()
for i in range(K):
    l, r = map(int,input().split())
    areas.append((l,r))
#areas_sum = [0] * N 
tmp = 0
d = [0] * N
#check = [0] * N
#check[0] = 1
d[0] = 1
for i in range(N):
    for j in range(K):
        l, r = areas[j]
        if i-l >= 0:
            #areas_sum[j] += d[i-l]
            tmp += d[i-l]
        if i-r-1 >= 0:
            #areas_sum[j] -= d[i-r-1]
            tmp -= d[i-r-1]
    d[i] += tmp
    #check[i] += tmp
    d[i] %= 998244353 
    tmp  %= 998244353 
    #t.append(tmp)

#print(d)
#print(check)
ans = d[N-1]
print(ans)
#print(tmp)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 20:41:22 2020

@author: liang
"""
from scipy.special import comb
#D
key = 10**9 + 7
S = int(input())

#かご
n = S//3

ans = 0
for i in range(1,n+1):
    #玉
    a = S - 3*i 
    tmp = int(comb(i-1+a,i-1))
    tmp %= key
    ans += tmp
    ans %= key
    #print("print:",i,ans,tmp)
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 20:41:22 2020

@author: liang
"""
"""
float => int への変換誤差あり。
scipy.special.comb()は返り値がfloat
math.factorial()で自分で実装する。（大きな値のとき）
"""
#from scipy.special import comb
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#D
key = 10**9 + 7
S = int(input())

#かご
n = S//3

ans = 0
for i in range(1,n+1):
    #玉
    a = S - 3*i 
    #tmp = int(comb(i-1+a,i-1))
    tmp = combinations_count(i-1+a,i-1)
    tmp %= key
    ans += tmp
    ans %= key
    #print("print:",i,ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 11:05:00 2020

@author: liang
"""

"""
片側を固定して、それぞれのケースに対して最適解を求める
それぞれのケースについて
index(b_i) =< index(b_i-1)
であるから、bの最大値bestを保存して探索することで重複探索を回避できる
"""
N, M, K = map(int, input().split())

A = [0] + [int(x) for x in input().split()]
B = [0] + [int(x) for x in input().split()]

s_b = 0
for i in range(M+1):
    s_b += B[i]
    if s_b > K:
        s_b -= B[i]
        best = i - 1
        break
res = best
#print(res)
s_a = 0
for i in range(N+1):
   # print("i", i)
    s_a += A[i]
    if s_a > K:
        break
    for j in reversed(range(best+1)):
        #print("j",j)
        if s_b <= K - s_a:
            if i + j > res:
                res = i + j
            best = j
            #print(i, j, s_a, s_b)
            break
        else:
            s_b -= B[j]

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 11:05:00 2020

@author: liang
"""

"""
片側を固定して、それぞれのケースに対して最適解を求める
それぞれのケースについて
index(b_i) =< index(b_i-1)
であるから、bの最大値bestを保存して探索することで重複探索を回避できる
"""
N, M, K = map(int, input().split())

A = [0] + [int(x) for x in input().split()]
B = [0] + [int(x) for x in input().split()]

s_b = 0
for i in range(M+1):
    s_b += B[i]
    if s_b > K:
        s_b -= B[i]
        best = i - 1
        break
else:
    best = M
res = best
#print(res)
s_a = 0
for i in range(N+1):
   # print("i", i)
    s_a += A[i]
    if s_a > K:
        break
    for j in reversed(range(best+1)):
        #print("j",j)
        if s_b <= K - s_a:
            if i + j > res:
                res = i + j
            best = j
            #print(i, j, s_a, s_b)
            break
        else:
            s_b -= B[j]
        
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt

N = int(input())

ans = 0

for i in range(1,N+1):
    t = sqrt(i)
    #平方数の除外
    if t //1 == t :
        ans += i
        
    j = 1
    while j < t:
        if i%j == 0:
            ans += 2*i
        j += 1
   # print(ans)
print(ans)

Fixed submission:
N = int(input())

ans = 0
for i in range(1, N+1):
    ans += i*(N//i*(N//i+1))//2
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(float,input().split())
A = int(A)
B = int(B*1000)
ans = A*B//1000
print (ans)

Fixed submission:

N = int(input())
A = list(map(int,input().split()))

t = 1
ans = 1
count = 0

if 0 in A:
    ans = 0
else:  
    for a in A:
        ans *= a
        t *= a
        while t >= 10:
            t /= 10
            count += 1
            if count >= 19:
                ans = -1 
                break

if ans > 10**18:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 21:01:07 2020

@author: liang
"""

import math

N = int(input())
A = list(map(int,input().split()))
B  = [math.log10(x) for x in A]

ans = 1
if sum(B) > 18:
    ans = -1
else:
    for a in A:
        ans *= a

if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:

N = int(input())
A = list(map(int,input().split()))

t = 1
ans = 1
count = 0

if 0 in A:
    ans = 0
else:  
    for a in A:
        ans *= a
        t *= a
        while t >= 10:
            t /= 10
            count += 1
            if count >= 19:
                ans = -1 
                break

if ans > 10**18:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input().split()))
B  = [math.log10(x) for x in A]

ans = 1
if sum(B) > 18:
    ans = -1
else:
    for a in A:
        ans *= a

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:

N = int(input())
A = list(map(int,input().split()))

t = 1
ans = 1
count = 0

if 0 in A:
    ans = 0
else:  
    for a in A:
        ans *= a
        t *= a
        while t >= 10:
            t /= 10
            count += 1
            if count >= 19:
                ans = -1 
                break

if ans > 10**18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):

A,B=input().split()
B=B[:-3]+B[-2]
print(A＊B)


Fixed submission:
split = input().split()
A = int(split[0])
B = int(float(split[1])*1000)
ans = A*B//1000
print (ans)
Buggy python submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans = 0

if(N>1):
    Q = factorization(N)
    "print(Q)"
    A = [ b for [a,b] in Q]
    for a in A:
        i = 1
        while(a >= i):
            a -= i
            i += 1
            ans += 1
    print(ans)

else:
    print(0)

Fixed submission:
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans = 0

if(N>1):
    Q = factorization(N)
    A = [ b for [a,b] in Q]
    for a in A:
        i = 1
        while(a >= i):
            a -= i
            i += 1
            ans += 1
    print(ans)

else:
    print(0)
Buggy python submission (verdict: Runtime Error):
A, B , C, K = map(int,input().split())
al = [1]* A
bl = [0] * B
cl = [-1]* C
l = al + bl + cl

ans = sum(l[:K])
print(ans)

Fixed submission:
A, B , C, K = map(int,input().split())
if K <= A:
    ans = K
elif K <= A + B:
    ans = A
elif K <= A + B + C:
    ans = A - (K - A - B)
else :
    ans = A - C
print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())
fact = [(i,i**5) for i in range(-10**2,10**2)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B)

Fixed submission:
X = int(input())
fact = [(i,i**5) for i in range(-10**3,10**3)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B)

Buggy python submission (verdict: Runtime Error):
X = int(input())
fact = [(i,i**5) for i in range(-10**3,10**3)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B

Fixed submission:
X = int(input())
fact = [(i,i**5) for i in range(-10**3,10**3)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B)

Buggy python submission (verdict: Runtime Error):
X = int(input())
fact = [(i,i**5) for i in range(-10**2,10**2)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B)

Fixed submission:
X = int(input())
fact = [(i,i**5) for i in range(-10**3,10**3)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

flag = False
res = 1
for a in A:
    a /= 2
    res *= a//gcd(res,a)
    if res > M:
        flag = True
        break
    #print(res)
"""
存在チェック
２で割り切れる個数同じ？
"""

for a in A:
    if int(res/a) == res/a:
        flag = True
        
if flag:
    ans = 0
    print(ans)
else:
    #ans = (M - res(A)//2)//res + 1
    #ans = (M-1)//res//2 + 1
    ans= (M//res + 1)//2
    print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

flag = False
res = 1
for a in A:
    a //= 2
    res *= a//gcd(res,a)
    if res > M:
        flag = True
        break
    #print(res)
"""
存在チェック
２で割り切れる個数同じ？
"""

for a in A:
    if int(res/a) == res/a:
        flag = True
        
if flag:
    ans = 0
    print(ans)
else:
    #ans = (M - res(A)//2)//res + 1
    #ans = (M-1)//res//2 + 1
    ans= (M//res + 1)//2
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

res = 1
for i in range(N):
    res *= A[i]//2//gcd(res,A[i]//2)
    #print(res)
"""
存在チェック
２で割り切れる個数同じ？
"""
flag = False
for a in A:
    if int(res/a) == res/a:
        flag = True
        
if flag:
    ans = 0
else:
    #ans = (M - res(A)//2)//res + 1
    #ans = (M-1)//res//2 + 1
    ans= (M//res + 1)//2
    print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

flag = False
res = 1
for a in A:
    a //= 2
    res *= a//gcd(res,a)
    if res > M:
        flag = True
        break
    #print(res)
"""
存在チェック
２で割り切れる個数同じ？
"""

for a in A:
    if int(res/a) == res/a:
        flag = True
        
if flag:
    ans = 0
    print(ans)
else:
    #ans = (M - res(A)//2)//res + 1
    #ans = (M-1)//res//2 + 1
    ans= (M//res + 1)//2
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 01:55:56 2020

@author: liang
"""

import math
N = int(input())
key = int(math.sqrt(N))

ans = 10**12
for i in range(1,N+1):
    if N%i == 0:
        tmp = i-1 + N//i -1
        if ans > tmp:
            ans = tmp
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 01:55:56 2020

@author: liang
"""

import math
N = int(input())
key = int(math.sqrt(N))

ans = 10**12
for i in reversed(range(1,key+1)):
    if N%i == 0:
        ans = i-1 + N//i -1
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 20:56:06 2020

@author: liang
"""

N = int(input())
L = [int(x) for x in input().split()]

L.sort()
ans = 0
#print(L)
for i in range(N-2):
    p = i+2
    for j in range(i+1,N-1):
        while p < N and L[p] < L[i] + L[j] :
            p += 1
        ans += len(L[j+1:p])
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 20:56:06 2020

@author: liang
"""

N = int(input())
L = [int(x) for x in input().split()]

L.sort()
ans = 0
#print(L)
for i in range(N-2):
    #print("1:",i)
    p = i+2
    for j in range(i+1,N-1):
        #print("2",i,j)
        while p < N and L[p] < L[i] + L[j] :
            p += 1
            #print("up")
        #print(p)
        ans += len(L[j+1:p])
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 15:18:03 2020

@author: liang
"""
N, K, Q = map(int, input().split())
A = [0]*N
for i in range(Q):
    t = int(input())
    A[t-1] += 1

for i in range(Q):
    if Q - A[i] > K:
        print("Yes")
    else:
        print("No")

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 15:18:03 2020

@author: liang
"""
N, K, Q = map(int, input().split())
A = [0]*N
for i in range(Q):
    t = int(input())
    A[t-1] += 1

#print(A)
for i in range(N):
   # print(Q-A[i])
    if Q - A[i] <  K:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = [0]*N
for i in range(Q):
    t = int(input())
    A[t] += 1

for i in range(Q):
    if Q - A[i] > K:
        print("Yes")
    else:
        print("No")

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 15:18:03 2020

@author: liang
"""
N, K, Q = map(int, input().split())
A = [0]*N
for i in range(Q):
    t = int(input())
    A[t-1] += 1

#print(A)
for i in range(N):
   # print(Q-A[i])
    if Q - A[i] <  K:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 14 00:57:13 2020

@author: liang
"""

N, Q = map(int, input().split())
S = input()
lis = list()
for i in range(len(S) - 1):
    if S[i:i+2] == "AC":
        lis.append(i)
    #print(lis[i:i+2])
#print(lis)
for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ans = 0
    for t in lis:
        if l <= t < r:
            ans += 1
    print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 14 00:57:13 2020

@author: liang
"""

N, Q = map(int, input().split())
S = input()
S += "a"
d = [0]*(N+1)
count = 0
for i in range(len(S)-1):
    if S[i:i+2] == "AC":
        count += 1
    #print(i)
    d[i+1] = count
#print(lis)
#print(d)
for i in range(Q):
    l, r = map(int, input().split())
    ans = d[r-1] - d[l-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 02:42:27 2020

@author: liang
"""

N, M = map(int, input().split())
drinks = list()

for i in range(N):
    a, b = map(int,input().split())
    for j in range(b):
        drinks.append(a)

drinks.sort()

ans = sum(drinks[:M])

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 02:42:27 2020

@author: liang
"""

N, M = map(int, input().split())
drinks = list()

for i in range(N):
    a, b = map(int,input().split())
    drinks.append((a,b))

drinks.sort(key = lambda x: x[0])
#print(drinks)
ans = 0
while M > 0:
    a, b = drinks.pop(0)
    if M <= b:
        ans += a*M
        M = 0
    else:
        ans += a*b
        M -= b
    #print(ans,M)
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""
###煩雑 => 列挙して最小値を出力
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        if A < 2 * C:
            ans = Y * C * 2 + abs(X-Y) * A
        else:
            ans = X * C * 2  ##
    else:
        if B < 2 * C:
            ans = X * C * 2 + abs(X-Y) * B
        else:
            ans = Y * C * 2 ##
else:
    ans = X * A + Y * B 
print(ans)
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    ans1 = max(X,Y) * C * 2  #条件分岐が減る
    if X > Y :
        if A < 2 * C:
            ans2 = Y * C * 2 + abs(X-Y) * A           
    else:
        if B < 2 * C:
            ans2 = X * C * 2 + abs(X-Y) * B  
    print(min(ans1,ans2)) #print()が分岐する
else:   
    ans = X * A + Y * B 
    print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""

A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        if A < 2 * C:
            ans = Y * C * 2 + abs(X-Y) * A
        else:
            ans = X * C * 2
    else:
        if B < 2 * C:
            ans = X * C * 2 + abs(X-Y) * B
        else:
            ans = Y * C * 2
else:
    ans = X * A + Y * B 
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""
###煩雑 => 列挙して最小値を出力
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        if A < 2 * C:
            ans = Y * C * 2 + abs(X-Y) * A
        else:
            ans = X * C * 2  ##
    else:
        if B < 2 * C:
            ans = X * C * 2 + abs(X-Y) * B
        else:
            ans = Y * C * 2 ##
else:
    ans = X * A + Y * B 
print(ans)
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    ans1 = max(X,Y) * C * 2  #条件分岐が減る
    if X > Y :
        if A < 2 * C:
            ans2 = Y * C * 2 + abs(X-Y) * A           
    else:
        if B < 2 * C:
            ans2 = X * C * 2 + abs(X-Y) * B  
    print(min(ans1,ans2)) #print()が分岐する
else:   
    ans = X * A + Y * B 
    print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""

A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        if A < 2 * C:
            ans = Y * C * 2 + abs(X-Y) * A
        else:
            ans = X * C * 2
    else:
        if B < 2 * C:
            ans = X * C * 2 + abs(X-Y) * B
        else:
            ans = Y * C * 2
else:
    ans = X * A + Y * B 
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 29 14:54:30 2020

@author: liang
"""

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

ans = [100]*26

for i in range(n):
    tmp = [0]*26
    for s in S[i]:
        key = ord(s)-ord('a')
        if tmp[key] < ans[key]:
            tmp[key] += 1
    ans = tmp.copy()

res = ""
for i in range(n):
    res += chr(ord('a') + i)*tmp[i]
print(res)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 29 14:54:30 2020

@author: liang
"""

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

ans = [100]*26

for i in range(n):
    tmp = [0]*26
    for s in S[i]:
        key = ord(s)-ord('a')
        if tmp[key] < ans[key]:
            tmp[key] += 1
    ans = tmp.copy()

res = ""
for i in range(26):
    res += chr(ord('a') + i)*tmp[i]
print(res)