Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]

ans = float("inf")
for i in range(2**D):
    sum = 0
    count = 0
    rem = set(range(1,D+1))
    for j in range(D):
        if (i >> j) & 1:
            sum += pc[j][0]*100*j+pc[j][1]
            count += pc[j][0]
            rem.discard(j+1)
    if sum < G:
        k = max(rem)-1
        n = min(pc[k][0],-(-(G-sum)//((k+1)*100))
        count += n
        sum += n*100*(k+1)
    if sum >= G:
        ans = min(ans,count)

print(ans)
        


Fixed submission:
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]

#print(pc)
ans = float("inf")

for i in range(2**D):
    sum = 0
    count = 0
    rem = set(range(1,D+1))
    for j in range(D):
        if (i >> j) & 1:
            sum += pc[j][0]*100*(j+1)+pc[j][1]
            count += pc[j][0]
            rem.discard(j+1)
    if sum < G:
        k = max(rem)-1
        n = min(pc[k][0],-(-(G-sum)//((k+1)*100)))
        count += n
        sum += n*100*(k+1)
    if sum >= G:
        ans = min(ans,count)

print(ans)
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

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

a = []
b = []

for i in range(M):
    ao,bo = map(int,input().split())
    a.append(ao)
    b.append(bo)

ab = sorted([(a[i],b[i]) for i in range(M)], key = itemgetter(1))

ans = 0
last = 0

for i in range(N):
    if last <= ab[i][0]:
        ans += 1
        last = ab[i][1]

print(ans)


Fixed submission:
from operator import itemgetter

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

a = []
b = []

for i in range(M):
    ao,bo = map(int,input().split())
    a.append(ao)
    b.append(bo)

ab = sorted([(a[i],b[i]) for i in range(M)], key = itemgetter(1))

ans = 0
last = 0

for i in range(M):
    if last <= ab[i][0]:
        ans += 1
        last = ab[i][1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

p = 10**6
q = [0]*N
for i in range(N):
    Sl = S[:i] if i > 0 else "0"
    Sr = S[i+1:] if i < N-1 else "0"
    q[i] = Sl.count("W") + Sr.count("E")

q.sort()

print(q[0])


Fixed submission:
N = int(input())
S = input()

listw = [0]
for i in range(N):
    listw.append(listw[-1]+1 if S[i] == "W" else listw[-1])

liste = [0]
for i in range(N):
    liste.append(liste[-1]+1 if S[i] == "E" else liste[-1])

list = [0]*N
for i in range(N):
    list[i] = listw[i] + liste[-1] - liste[i+1 if i != N-1 else -1]

list.sort()

print(list[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

p = 10**6
q = [0]*N
for i in range(N):
    Sl = S[:i] if i > 0 else "0"
    Sr = S[i+1:] if i < N-1 else "0"
    q[i] = Sl.count("W") + Sr.count("E")

print(min(q))


Fixed submission:
N = int(input())
S = input()

listw = [0]
for i in range(N):
    listw.append(listw[-1]+1 if S[i] == "W" else listw[-1])

liste = [0]
for i in range(N):
    liste.append(liste[-1]+1 if S[i] == "E" else liste[-1])

list = [0]*N
for i in range(N):
    list[i] = listw[i] + liste[-1] - liste[i+1 if i != N-1 else -1]

list.sort()

print(list[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

p = 10**6

for i in range(N):
    Sl = S[:i] if i > 0 else "0"
    Sr = S[i+1:] if i < N-1 else "0"
    if p > Sl.count("W") + Sr.count("E"):
        p = Sl.count("W") + Sr.count("E")

print(p)


Fixed submission:
N = int(input())
S = input()

listw = [0]
for i in range(N):
    listw.append(listw[-1]+1 if S[i] == "W" else listw[-1])

liste = [0]
for i in range(N):
    liste.append(liste[-1]+1 if S[i] == "E" else liste[-1])

list = [0]*N
for i in range(N):
    list[i] = listw[i] + liste[-1] - liste[i+1 if i != N-1 else -1]

list.sort()

print(list[0])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
from itertools import combinations
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)
@lru_cache(maxsize=None)

def kaijou(n):
    if n <= 1:
        return 1
    return kaijou(n-1)*n

def comb(n,m):
    return kaijou(n)/kaijou(m)/kaijou(n-m)

n = int(input())
a = list(map(int,input().split()))
A = [0]
for i in a:
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += comb(i,2)
print(int(ans))

Fixed submission:
from collections import Counter
n = int(input())
A = [0]
for i in map(int,input().split()):
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += int(i*(i-1)/2)
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
from itertools import combinations
from functools import lru_cache
@lru_cache(maxsize=None)

def kaijou(n):
    if n <= 1:
        return 1
    return kaijou(n-1)*n

def comb(n,m):
    return int(kaijou(n)/kaijou(m)/kaijou(n-m))

n = int(input())
a = list(map(int,input().split()))
A = [0]
for i in a:
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += comb(i,2)
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = [0]
for i in map(int,input().split()):
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += int(i*(i-1)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations
n = int(input())
a = list(map(int,input().split()))
A = [0]
for i in a:
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += len(tuple(combinations(range(i),r=2)))
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = [0]
for i in map(int,input().split()):
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += int(i*(i-1)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
n = int(input())
A = [0]+list(accumulate(map(int,input().split())))
ans = 0
for i in range(1,n+1):
    for j in range(n+1-i):
        if A[j+i]-A[j] == 0:
            ans += 1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = [0]
for i in map(int,input().split()):
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += int(i*(i-1)/2)
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
from functools import lru_cache

@lru_cache(maxsize=None)

def kaijou(n):
    if n <= 1:
        return 1
    return kaijou(n-1)*n

def comb(n,r):
    return kaijou(n)/kaijou(r)/kaijou(n-r)

n = input()
A = list(map(int,input().split()))
A.sort()
m = A[-1]
i = bisect.bisect_left(A,m//2)
if i == 0:
    if comb(m,A[i]) >= comb(m,A[i+1]):
        print(m,A[i])
    else:
        print(m,A[i+1])
else:
    if comb(m,A[i-1]) >= comb(m,A[i]):
        print(m,A[i-1])
    else:
        print(m,A[i])

Fixed submission:
import sys
import bisect
n = int(input())
A = list(map(int,input().split()))
A.sort()
m = A[-1]
if n == 2:
    print(A[-1],A[0])
    sys.exit()
i = bisect.bisect_left(A,m//2)
if i == 0:
    print(m,A[0])
else:
    if m - A[i] < A[i-1]:
        print(m,A[i-1])
    else:
        print(m,A[i])
Buggy python submission (verdict: Runtime Error):
from collections import deque

def bfs():
    d = [[float("inf") for i in range(W)] for j in range(H)]
    dx = [1,-1,0,0]
    dy = [0,0,1,-1]
    que = deque([])
    que.append((0,0))
    d[0][0] = 0
    while que:
        p = que.popleft()
        if p[0] == W-1 and p[1] == H-1:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0<=nx<W and 0<=ny<H and maze[ny][nx] != "#" and d[ny][nx] == float("inf"):
                que.append((nx,ny))
                d[ny][nx] = d[p[1]][p[0]] + 1
    return d[H-1][W-1]

H,W = map(int,input().split())
maze = [list(input()) for i in range(H)]

cnt = 1

for i in range(H):
    cnt += maze[i].count("#")

if d[H-1][W-1] == float("inf"):
    print(-1)
else:
    print(H*W-bfs()-cnt)


Fixed submission:
from collections import deque

def bfs():
    d = [[float("inf") for i in range(W)] for j in range(H)]
    dx = [1,-1,0,0]
    dy = [0,0,1,-1]
    que = deque([])
    que.append((0,0))
    d[0][0] = 0
    while que:
        p = que.popleft()
        if p[0] == W-1 and p[1] == H-1:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0<=nx<W and 0<=ny<H and maze[ny][nx] != "#" and d[ny][nx] == float("inf"):
                que.append((nx,ny))
                d[ny][nx] = d[p[1]][p[0]] + 1
    return d[H-1][W-1]

H,W = map(int,input().split())
maze = [list(input()) for i in range(H)]

cnt = 1

for i in range(H):
    cnt += maze[i].count("#")

if bfs() == float("inf"):
    print(-1)
else:
    print(H*W-bfs()-cnt)
Buggy python submission (verdict: Runtime Error):
a = list(input())
b = list(input())

a.sort()
b.sort(reverse=True)


for i in range(int(len(b))):
    c =(a[i],b[i])
    d = sorted(c)
    if i != int(len(b))-1:
        if a[i] == b[i]:
            continue
        elif c == d and a[i] != b[i]:
            print("No")
            break
        else:
            print("Yes")
            break
    if i == int(len(b))-1:
        if a[i] == b[i]:
            if int(len(a)) >= int(len(b)):
                print("No")
            else:
                print("Yes")
        elif c == d and a[i] != b[i]:
            print("No")
            break
        else:
            print("Yes")
            break


Fixed submission:
a, b = map(int, input().split())

c = a + b

if c % 2 == 0:
    print(int(c / 2))
else:
    print(int(int(c / 2) + 1))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

c = a + b

if c % 2 == 0
    print(int(c/2))
else:
    print(int(c // 2 + 1))


Fixed submission:
a, b = map(int, input().split())

c = a + b

if c % 2 == 0:
    print(int(c / 2))
else:
    print(int(int(c / 2) + 1))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

c = a + b

if c % 2 == 0
    print(int(c/2))
else:
    print(int(c // 2 + 1))


Fixed submission:
a, b = map(int, input().split())

c = a + b

if c % 2 == 0:
    print(int(c / 2))
else:
    print(int(int(c / 2) + 1))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

c = a + b

if c % 2 == 0
    print(int(c/2))
else:
    print(int(c // 2 + 1))


Fixed submission:
a, b = map(int, input().split())

c = a + b

if c % 2 == 0:
    print(int(c / 2))
else:
    print(int(int(c / 2) + 1))
Buggy python submission (verdict: Runtime Error):
a = list(input())
b = list(input())

a.sort()
b.sort(reverse=True)


for i in range(int(len(b))):
    c =(a[i],b[i])
    d = sorted(c)
    if i != int(len(b))-1:
        if a[i] == b[i]:
            continue
        elif c == d and a[i] != b[i]:
            print("No")
            break
        else:
            print("Yes")
            break
    if i == int(len(b))-1:
        if a[i] == b[i]:
            if int(len(a)) >= int(len(b)):
                print("No")
            else:
                print("Yes")
        elif c == d and a[i] != b[i]:
            print("No")
            break
        else:
            print("Yes")
            break


Fixed submission:
a = list(input())
b = list(input())

a.sort()
b.sort(reverse=True)
f = [int(len(b)), int(len(a))]
e = min(f)
for i in range(int(e)):
    c =[a[i],b[i]]
    d = sorted(c)
    if i != int(e)-1:
        if a[i] == b[i]:
            continue
        elif c != d:
            print("No")
            break
        else:
            print("Yes")
            break
    if i == int(e)-1:
        if a[i] == b[i]:
            if int(len(a)) >= int(len(b)):
                print("No")
            else:
                print("Yes")
        elif c != d:
            print("No")
            break
        else:
            print("Yes")
            break

Buggy python submission (verdict: Runtime Error):
a = list(input())
b = list(input())

a.sort()
b.sort(reverse=True)


for i in range(int(len(b))):
    c =(a[i],b[i])
    d = sorted(c)
    if i != int(len(b))-1:
        if a[i] == b[i]:
            continue
        elif c == d and a[i] != b[i]:
            print("Yes")
            break
        else:
            print("No")
            break
    if i == int(len(b))-1:
        if a[i] == b[i]:
            if int(len(a)) >= int(len(b)):
                print("No")
            else:
                print("Yes")
        elif c == d and a[i] != b[i]:
            print("Yes")
            break
        else:
            print("No")
            break


Fixed submission:
a = list(input())
b = list(input())

a.sort()
b.sort(reverse=True)
f = [int(len(b)), int(len(a))]
e = min(f)
for i in range(int(e)):
    c =[a[i],b[i]]
    d = sorted(c)
    if i != int(e)-1:
        if a[i] == b[i]:
            continue
        elif c != d:
            print("No")
            break
        else:
            print("Yes")
            break
    if i == int(e)-1:
        if a[i] == b[i]:
            if int(len(a)) >= int(len(b)):
                print("No")
            else:
                print("Yes")
        elif c != d:
            print("No")
            break
        else:
            print("Yes")
            break
Buggy python submission (verdict: Runtime Error):
n = int(input())
data1 = [list(map(int,input().split())) for _ in range(n)]
data2 = [list(map(int,input().split())) for _ in range(n)]
ans = []
trans = -1
for i in range(2**10):
    S = [0]*10
    l = 0
    for j in range(10):
        for k in range(n):
            S[k] += data1[k][j]*((i>>j)&1)
    for j in range(n):
        l += data2[j][S[j]]
    ans.append(l)
    if not i:
        trans = l
ans.sort()
print(ans[-1] if ans[-1] != trans else ans[-2])

Fixed submission:
n = int(input())
data1 = [list(map(int,input().split())) for _ in range(n)]
data2 = [list(map(int,input().split())) for _ in range(n)]
ans = []
trans = -1
for i in range(2**10):
    S = [0]*n
    l = 0
    for j in range(10):
        for k in range(n):
            S[k] += data1[k][j]*((i>>j)&1)
    for j in range(n):
        l += data2[j][S[j]]
    ans.append(l)
    if not i:
        trans = l
ans.sort()
print(ans[-1] if ans[-1] != trans else ans[-2])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 12:45:03 2020

@author: shinba
"""
import sys

S = list(input())

if S.count("K") != 1 and S.count("I") != 1 and S.count("H") != 1 and S.count("B") != 1 and S.count("R") != 1:
    print("NO")
    sys.exit()    

k = S.index("K")
i = S.index("I")
h = S.index("H")
b = S.index("B")
r = S.index("R")

if (0 <= k <= 1) and (i - k == 1) and (h - i == 1) and (0 <= b - h <= 1) and (0 <= r - b <= 1):
    if k < i < h < b < r:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


    
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 12:45:03 2020

@author: shinba
"""
import sys

S = list(input())

if S.count("K") != 1 or S.count("I") != 1 or S.count("H") != 1 or S.count("B") != 1 or S.count("R") != 1:
    print("NO")
    sys.exit()    

l = len(S)

k = S.index("K")
i = S.index("I")
h = S.index("H")
b = S.index("B")
r = S.index("R")

while "A" in S:
    S.remove("A")
    
if len(S) != 5:
    print("NO")
    sys.exit()
    

if (0 <= k <= 1) and (h - k == 2) and (1 <= b - h <= 2) and (1 <= r - b <= 2) and (l-2 <= r <= l-1):
    if k < i < h < b < r:
        print("YES")
    else:
        print("NO")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import collections

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

Adic = collections.Counter(A)

B = [n % 2 for n in Adic.values()]

while 0 in B:
    B.remove(0)

print(len(B))


Fixed submission:
import collections

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

Adic = collections.Counter(A)

B = [n % 2 for n in Adic.values()]

print(B.count(1))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

cnt = 0
X=[]
for n in A:
    X.append(n)
    X.append(n-1)
    X.append(n+1)

Y = set(X)

y = list(Y)

for x in y:
    transient = 0
    for a in A:
        if -1 <= a - x <= 1:
            transient += 1
    else:
        if transient > cnt:
            cnt = transient

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 11:55:25 2020

@author: shinba
"""

x,t = map(int,input().split())

if x <= t:
    print(0)
else:
    print(x-t)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

cnt = 0

for X in range(min(A),max(A)+1):
    transient = A.count(X-1) + A.count(X) + A.count(X+1)
    if transient > cnt:
        cnt = transient

print(cnt)


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

C = [0]*(10**5 + 2)

for i in A:
    C[i-1] += 1
    C[i] += 1
    C[i+1] += 1

print(max(C))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

cnt = 0

for x in range(min(A),max(A)):
    transient = A.count(X-1) + A.count(X) + A.count(X+1)
    if transient > cnt:
        cnt = transient

print(cnt)


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

C = [0]*(10**5 + 2)

for i in A:
    C[i-1] += 1
    C[i] += 1
    C[i+1] += 1

print(max(C))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

cnt = 0
X=[]
for n in A:
    X.append(n)
    X.append(n-1)
    X.append(n+1)

Y = set(X)

y = list(Y)

for x in y:
    transient = 0
    for a in A:
        if -1 <= a - x <= 1:
            transient += 1
    else:
        if transient > cnt:
            cnt = transient

print(cnt)


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

C = [0]*(10**5 + 2)

for i in A:
    C[i-1] += 1
    C[i] += 1
    C[i+1] += 1

print(max(C))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

cnt = 0

for X in range(min(A),max(A)+1):
    transient = 0
    for a in A:
        if -1 <= a -X <= 1:
            transient += 1
    else:
        if transient > cnt:
            cnt = transient

print(cnt)


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

C = [0]*(10**5 + 2)

for i in A:
    C[i-1] += 1
    C[i] += 1
    C[i+1] += 1

print(max(C))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

b = a[0]
li = [0]
c = 1

while b != 2:
    li += [b-1]
    b = a[b-1]
    if b-1 in li:
        print(-1)
        break
    else:
        c += 1
else:
    print(c)


Fixed submission:
N = int(input())

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

b = a[0]
li = [0]
c = 1

while b != 2:
    li += [b-1]
    b = a[b-1]
    c += 1
    if c > N:
        print(-1)
        break
else:
    print(c)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
s = input()
ans = s
while True:
    visited = [0]*(len(s))
    t = ""
    for i in range(len(s)-1):
        if not visited[i]:
            if s[i:i+2] == "()":
                visited[i+1] = 1
            else:
                t += s[i]
    if not visited[len(s)-1]:
        t += s[-1]
    s = t
    if not s:
        print(ans)
        sys.exit()
    if not "(" in s or not ")" in s:
        break
    for i in range(s.index(")(")+1,len(s)):
        if s[i] != "(":
            break
    else:
        break
print("("*s.count(")")+ans+")"*s.count("("))

Fixed submission:
n = int(input())
s = input()
d = [0]
cnt = 0
for i in range(n):
    if s[i] == "(":
        cnt += 1
    else:
        cnt -= 1
    d.append(cnt)
x = min(d)
print("("*(-x)+s+")"*(d[-1]-x))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = s
while True:
    visited = [0]*(len(s))
    t = ""
    for i in range(len(s)-1):
        if not visited[i]:
            if s[i:i+2] == "()":
                visited[i+1] = 1
            else:
                t += s[i]
    if not visited[len(s)-1]:
        t += s[-1]
    s = t
    if not "(" in s or not ")" in s:
        break
    for i in range(s.index(")(")+1,len(s)):
        if s[i] != "(":
            break
    else:
        break
print("("*s.count(")")+ans+")"*s.count("("))

Fixed submission:
n = int(input())
s = input()
d = [0]
cnt = 0
for i in range(n):
    if s[i] == "(":
        cnt += 1
    else:
        cnt -= 1
    d.append(cnt)
x = min(d)
print("("*(-x)+s+")"*(d[-1]-x))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 16:15:19 2020

@author: shinba
"""

n,t = map(int,input().split())

T = list(map(int,input().split()))
T.append(10**10)
R = []
for i in range(n-1):
    R.append(T[i+1]-T[i])

ans = 0
start = T[0]

for i in range(n):
    if R[i] <= t:
        continue
    ans += t+(T[i]-start)
    start = T[i+1]
    
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 16:15:19 2020

@author: shinba
"""

n,t = map(int,input().split())

T = list(map(int,input().split()))
T.append(10**10)
R = []
for i in range(n):
    R.append(T[i+1]-T[i])

ans = 0
start = T[0]

for i in range(n):
    if R[i] <= t:
        continue
    ans += t+(T[i]-start)
    start = T[i+1]
    
print(ans)
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
n = int(input())
data = []
s = input()
data.append(s)
S = set(list(s))
for i in range(n-1):
    s = input()
    S = S & set(list(s))
    data.append(s)
A = []
for i in S:
    ans = float("inf")
    for j in range(n-1):
        ans = min(ans,data[j].count(i))
    A.append([i,ans])
A.sort(key=itemgetter(0))
s = ""
for i in A:
    s += i[0]*i[1]
print(s)

Fixed submission:
from operator import itemgetter
import sys
n = int(input())
data = []
s = input()
if n == 1:
    L = list(s)
    L.sort()
    print("".join(L))
    sys.exit()
data.append(s)
S = set(list(s))
for i in range(n-1):
    s = input()
    S = S & set(list(s))
    data.append(s)
A = []
for i in S:
    ans = float("inf")
    for j in range(n-1):
        ans = min(ans,data[j].count(i))
    A.append([i,ans])
A.sort(key=itemgetter(0))
s = ""
for i in A:
    s += i[0]*i[1]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())

counter = 0

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                counter += 1

print(counter)


Fixed submission:
K,S = map(int,input().split())

counter = 0

for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= K:
            counter += 1

print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())

counter = 0

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                counter += 1

print(counter)


Fixed submission:
K,S = map(int,input().split())

counter = 0

for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= K:
            counter += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 12:41:57 2020

@author: shinba
"""

a,b,h = map(int,input().split())

print(int((a+b)*h/2))


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 12:41:57 2020

@author: shinba
"""

a = int(input())
b = int(input())
h = int(input())

print(int((a+b)*h/2))
Buggy python submission (verdict: Runtime Error):
N,L = map(int,input().split())
S = [input() for i in range(N)]

S.sort()

s = ""
for i in range(N):
    s += S[i]

print(s)


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 11:57:51 2020

@author: shinba
"""

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

B = [[5,5,7],[5,7,5],[7,5,5]]

if A in B:
    print("YES")
else:
    print("NO")