Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,C = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]
c_set = set([])
for c_ in c:
    c_set |= set(c_)
ans = 1e9
for c_1 in range(C):
    for c_2 in range(C):
        for c_3 in range(C):
            if not (c_1 in c_set or c_2 in c_set or c_3 in c_set):
                continue
            if c_1==c_2 or c_1==c_3 or c_2==c_3:
                continue
            c_list = [c_1,c_2,c_3]
            k = 0
            for i in range(N):
                for j in range(N):
                    if not c[i][j]==c_list[(i+j)%3]:
                        k += d[c[i][j]-1][c_list[(i+j)%3]-1]
            ans = min(ans,k)
print(ans)

Fixed submission:
N,C = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]
c_set = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        c_set[(i+j)%3][c[i][j]-1] += 1
ans = 1e9
for c_1 in range(C):
    for c_2 in range(C):
        for c_3 in range(C):
            if c_1==c_2 or c_1==c_3 or c_2==c_3:
                continue
            c_list = [c_1,c_2,c_3]
            k = 0
            for i in range(C):
                for j in range(3):
                    k += d[i][c_list[j]-1]*c_set[j][i]
            ans = min(ans,k)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,C = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]
ans = 1e9
for c_1 in range(C):
    for c_2 in range(C):
        for c_3 in range(C):
            if c_1==c_2 or c_1==c_3 or c_2==c_3:
                continue
            c_list = [c_1,c_2,c_3]
            k = 0
            for i in range(N):
                for j in range(N):
                    if not c[i][j]==c_list[(i+j)%3]:
                        k += d[c[i][j]-1][c_list[(i+j)%3]-1]
            ans = min(ans,k)
print(ans)

Fixed submission:
N,C = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]
c_set = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        c_set[(i+j)%3][c[i][j]-1] += 1
ans = 1e9
for c_1 in range(C):
    for c_2 in range(C):
        for c_3 in range(C):
            if c_1==c_2 or c_1==c_3 or c_2==c_3:
                continue
            c_list = [c_1,c_2,c_3]
            k = 0
            for i in range(C):
                for j in range(3):
                    k += d[i][c_list[j]-1]*c_set[j][i]
            ans = min(ans,k)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
l = []
for i in range(1,len(s)-1):
    a = set(list(s[:i]))
    b = set(list(s[i:]))
    l.append(len(a & b))
print(max(l))

Fixed submission:
n = int(input())
s = input()
l = []
if n==2:
    if s[0]==s[1]:
        print(1)
    else:
        print(0)
else:
    for i in range(1,len(s)-1):
        a = set(list(s[:i]))
        b = set(list(s[i:]))
        l.append(len(a & b))
    print(max(l))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
l = []
for i in range(1,len(s)-1):
    a = set(list(s[:i]))
    b = set(list(s[i:]))
    l.append(len(a & b))
print(max(l))

Fixed submission:
n = int(input())
s = input()
l = []
if n==2:
    if s[0]==s[1]:
        print(1)
    else:
        print(0)
else:
    for i in range(1,len(s)-1):
        a = set(list(s[:i]))
        b = set(list(s[i:]))
        l.append(len(a & b))
    print(max(l))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = s[1:].count('E')
for i in range(1,len(s)-1):
    if s[i]==s[i-1]:
        continue
    ans = min(ans,s[:i].count('W')+s[i+1:].count('E'))
ans = min(ans,s[:len(s)].count('W'))
print(ans)

Fixed submission:
n = int(input())
s = input()
w = [0]
e = [0]
for i in range(len(s)):
    if s[i]=="W":
        w.append(w[i]+1)
        e.append(e[i])
    else:
        w.append(w[i])
        e.append(e[i]+1)
ans = 10**9
for i in range(0,len(s)):
    ans = min(ans,w[i]+e[-1]-e[i+1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = s[1:].count('E')
for i in range(1,len(s)-1):
    ans = min(ans,s[:i].count('W')+s[i+1:].count('E'))
ans = min(ans,s[:len(s)].count('W'))
print(ans)

Fixed submission:
n = int(input())
s = input()
w = [0]
e = [0]
for i in range(len(s)):
    if s[i]=="W":
        w.append(w[i]+1)
        e.append(e[i])
    else:
        w.append(w[i])
        e.append(e[i]+1)
ans = 10**9
for i in range(0,len(s)):
    ans = min(ans,w[i]+e[-1]-e[i+1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
ans = 1
for i in range(2,34):
    j = 2
    while True:
        if i**j>x:
            break
        ans = max(ans,i**j)
print(ans)


Fixed submission:
x = int(input())
ans = 1
for i in range(2,34):
    j = 2
    while True:
        if i**j>x:
            break
        ans = max(ans,i**j)
        j += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
s_list = []
for i in range(len(s)):
    for j in range(i,len(s)+1):
        if not s[i:j] in s_list:
            s_list.append(s[i:j])
s_list.sort()
print(s_list[k])

Fixed submission:
s = input()
k = int(input())
s_list = []
for i in range(len(s)):
    for j in range(i,i+6):
        if not s[i:j] in s_list:
            s_list.append(s[i:j])
s_list.sort()
print(s_list[k])
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            if s[i-1][j]=='#' or s[i+1][j]=='#' or s[i][j-1]=='#' or s[i][j+1]=='#':
                continue
            else:
                print('No')
                exit()
print('Yes')

Fixed submission:
h,w = map(int,input().split())
s = ['.'*(w+2)]+['.'+input()+'.' for _ in range(h)]+['.'*(w+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=='#':
            if s[i-1][j]=='#' or s[i+1][j]=='#' or s[i][j-1]=='#' or s[i][j+1]=='#':
                continue
            else:
                print('No')
                exit()
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
s = [0]
sum = 0
for i in range(len(a)):
    sum += a[i]
    s.append(sum)
ans = 0
for s_ in set(s):
    k = s.count(s_)
    ans += k*(k-1)//2
print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = [0]
sum = 0
for i in range(len(a)):
    sum += a[i]
    s += [sum]
s.sort()
ans = 0
k = 1
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        k+=1
        if i==len(s)-1:
            ans += k*(k-1)//2
    else:
        if k>1:
            ans += k*(k-1)//2
        k = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
a = [int(input()) for i in range(m)]
x_s = 0
x_l = 0
for i in range(m):
    if x>a[i]:
        x_l+=1
    else:
        x_s+=1
print(min(x_s,x_l))

Fixed submission:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
x_s = 0
x_l = 0
for i in range(m):
    if x>a[i]:
        x_l+=1
    else:
        x_s+=1
print(min(x_s,x_l))
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
x_ = x.copy()
x_.sort()
l = x_[len(x)//2-1]
r = x_[len(x)//2+1]
for i in range(len(x)):
    if x[i]<=l:
        print(r)
    else:
        print(l)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
x_ = x.copy()
x_.sort()
l = x_[len(x)//2-1]
r = x_[len(x)//2]
for i in range(len(x)):
    if x[i]<=l:
        print(r)
    else:
        print(l)
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input()split())
ans = []
for i in range(a,a+k+1):
    if i>b:
        break
    ans.append(i)
for i in range(b,b-k-1,-1):
    if i<a:
        break
    ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
    print(ans)

Fixed submission:
a,b,k=map(int,input().split())
ans = []
for i in range(a,a+k):
    if i>b:
        break
    ans.append(i)
for i in range(b,b-k,-1):
    if i<a:
        break
    ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
s = input()
l = list('abcdefghijklmnopqrstuvwxyz')
for s_ in s:
    l.remove(s_)
print(s+l[0])

Fixed submission:
s = input()
l = list('abcdefghijklmnopqrstuvwxyz')
for s_ in s:
    l.remove(s_)
if l==[]:
    l.append(s[-1])
    for i in range(len(s)-2,-1,-1):
        if s[i]<max(l):
            for k in l:
                if k>s[i]:
                    print(s[:i]+k)
                    exit()
        l.append(s[i])
    print(-1)
else:
    print(s+l[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
g1 = a[1::2]
g2 = a[::2]
ans1,ans2 = 0,0
l1,l2 = [],[]
for i in range(len(g1)):
    if g1[i]>0:
        ans1 += g1[i]
        l1.append(i*2+2)
for i in range(len(g2)):
    if g2[i]>0:
        ans2 += g2[i]
        l2.append(i*2+1)
length = n
if ans1>=ans2:
    print(ans1)
    list = []
    for i in range(n,l1[-1],-1):
        list.append(i)
    length -= n-l1[-1]
    for i in range(l1[-1],l1[0],-2):
        if not i in l1:
            list.append(i)
            length -= 2
    for i in range(l1[0]-1):
        list.append(1)
    length -= l1[0]
    for _ in range(length,0,-2):
        list.append(2)
    print(len(list))
    for i in list:
        print(i)
else:
    print(ans2)
    list = []
    for i in range(n,l2[-1],-1):
        list.append(i)
    length -= n-l2[-1]
    for i in range(l2[-1],l2[0],-2):
        if not i in l2:
            list.append(i)
            length -= 2
    for i in range(l2[0]-1):
        list.append(1)
    length -= l2[0]
    for _ in range(length,0,-2):
        list.append(2)
    print(len(list))
    for i in list:
        print(i)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
f = 1
for i in range(n):
    if a[i]>0:
        f = 0
if f:
    ind = a.index(max(a))
    print(max(a))
    list = []
    for i in range(n,ind+1,-1):
        list.append(i)
    for _ in range(ind):
        list.append(1)
    print(len(list))
    for i in list:
        print(i)
    exit()
g1 = a[1::2]
g2 = a[::2]
ans1,ans2 = 0,0
l1,l2 = [],[]
for i in range(len(g1)):
    if g1[i]>0:
        ans1 += g1[i]
        l1.append(i*2+2)
for i in range(len(g2)):
    if g2[i]>0:
        ans2 += g2[i]
        l2.append(i*2+1)
length = n
if ans1>=ans2:
    print(ans1)
    list = []
    for i in range(n,l1[-1],-1):
        list.append(i)
    length -= n-l1[-1]
    for i in range(l1[-1],l1[0],-2):
        if not i in l1:
            list.append(i)
            length -= 2
    for i in range(l1[0]-1):
        list.append(1)
    length -= l1[0]
    for _ in range(length,0,-2):
        list.append(2)
    print(len(list))
    for i in list:
        print(i)
else:
    print(ans2)
    list = []
    for i in range(n,l2[-1],-1):
        list.append(i)
    length -= n-l2[-1]
    for i in range(l2[-1],l2[0],-2):
        if not i in l2:
            list.append(i)
            length -= 2
    for i in range(l2[0]-1):
        list.append(1)
    length -= l2[0]
    for _ in range(length,0,-2):
        list.append(2)
    print(len(list))
    for i in list:
        print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(map(int,input().split()))
ans = 'Three'
for s_ in s:
    if s_=='Y':
        ans = 'Four'
print(ans)

Fixed submission:
n = int(input())
s = list(input().split())
ans = 'Three'
for s_ in s:
    if s_=='Y':
        ans = 'Four'
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]
dic = {0:[0]}
for i in range(1,d+1):
    list = []
    for j in range(i,h*w,d):
        for y in range(len(a)):
            if j in a[y]:
                for x in range(len(a[y])):
                    if a[y][x]==j:
                        if i==j:
                            list.append(0)
                            x_ = x
                            y_ = y
                            k = 0
                        else:
                            k += abs(x-x_)+abs(y-y_)
                            list.append(k)
                            x_ = x
                            y_ = y
    dic[i] = list
print(dic)
for l_ in l:
    if l_[0]%d==0:
        print(dic[d][(l_[1]-l_[0])//d])
    else:
        print(dic[l_[0]%d][(l_[1]-l_[0])//d])

Fixed submission:
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]
dic = {}
for i in range(len(a)):
    for j in range(len(a[i])):
        dic[a[i][j]] = (i,j)
sum = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    sum[i] = sum[i-d]+abs(dic[i][0]-dic[i-d][0])+abs(dic[i][1]-dic[i-d][1])
for l_ in l:
    print(sum[l_[1]]-sum[l_[0]])

Buggy python submission (verdict: Runtime Error):
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]
dic = {}
for i in range(1,h*w):
    list = []
    for j in range(i,h*w,d):
        for y in range(len(a)):
            if j in a[y]:
                for x in range(len(a[y])):
                    if a[y][x]==j:
                        if i==j:
                            list.append(0)
                            x_ = x
                            y_ = y
                            k = 0
                        else:
                            k += abs(x-x_)+abs(y-y_)
                            list.append(k)
                            x_ = x
                            y_ = y
    dic[i] = list
for l_ in l:
    print(dic[l_[0]][(l_[1]-l_[0])//d])

Fixed submission:
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]
dic = {}
for i in range(len(a)):
    for j in range(len(a[i])):
        dic[a[i][j]] = (i,j)
sum = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    sum[i] = sum[i-d]+abs(dic[i][0]-dic[i-d][0])+abs(dic[i][1]-dic[i-d][1])
for l_ in l:
    print(sum[l_[1]]-sum[l_[0]])
Buggy python submission (verdict: Runtime Error):
a,b = int(input())
s = input()
l = [str(i) for i in range(10)]
for i in range(a):
    if not s[i] in l:
        print('No')
        exit()
for i in range(b):
    if not s[a+i] in l:
        print('No')
        exit()
if not s[a]=='-':
    print('No')
    exit()
print('Yes')

Fixed submission:
a,b = map(int,input().split())
s = input()
l = [str(i) for i in range(10)]
for i in range(a):
    if not s[i] in l:
        print('No')
        exit()
for i in range(b):
    if not s[a+i+1] in l:
        print('No')
        exit()
if not s[a]=='-':
    print('No')
    exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]

def prime_table(n):
    list = [True for _ in range(n+1)]
    for i in range(2,int(n**0.5)+1):
        if list[i]:
            j = i*2
            while j<=n:
                list[j] = False
                j += i
    table = [i for i in range(n+1) if list[i] and i>=2]
    return table

table = prime_table(10**5)
table = set(table)
sim_sum = [0]*(10**5+1)

for i in range(len(table)):
    if table[i]*2-1 in table:
        sim_sum[table[i]*2-1] += 1
for i in range(1,10**5+1):
    sim_sum[i] += sim_sum[i-1]
for l_ in l:
    print(sim_sum[l_[1]]-sim_sum[max(l_[0]-2,0)])

Fixed submission:
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]

def prime_table(n):
    list = [True for _ in range(n+1)]
    for i in range(2,int(n**0.5)+1):
        if list[i]:
            j = i*2
            while j<=n:
                list[j] = False
                j += i
    table = [i for i in range(n+1) if list[i] and i>=2]
    return table

table = prime_table(10**5)
sim_sum = [0]*(10**5+1)

for i in range(len(table)):
    if table[i]*2-1 in table:
        sim_sum[table[i]*2-1] += 1
for i in range(1,10**5+1):
    sim_sum[i] += sim_sum[i-1]
for l_ in l:
    print(sim_sum[l_[1]]-sim_sum[max(l_[0]-2,0)])

Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]

def prime_table(n):
    list = [True for _ in range(n+1)]
    for i in range(2,int(n**0.5)+1):
        if list[i]:
            j = i*2
            while j<=n:
                list[j] = False
                j += i
    table = [i for i in range(n+1) if list[i] and i>=2]
    return table

table = prime_table(10**5)
sim_sum = [0]*(10**5+1)
sim_sum[3] = 1
for i in range(5,10**5,2):
    if i in table and (i+1)//2 in table:
        sim_sum[i] = 1
    sim_sum[i] += sim_sum[i-2]
for l_ in l:
    print(sim_sum[l_[1]]-sim_sum[max(l_[0]-2,0)])

Fixed submission:
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]

def prime_table(n):
    list = [True for _ in range(n+1)]
    for i in range(2,int(n**0.5)+1):
        if list[i]:
            j = i*2
            while j<=n:
                list[j] = False
                j += i
    table = [i for i in range(n+1) if list[i] and i>=2]
    return table

table = prime_table(10**5)
sim_sum = [0]*(10**5+1)

for i in range(len(table)):
    if table[i]*2-1 in table:
        sim_sum[table[i]*2-1] += 1
for i in range(1,10**5+1):
    sim_sum[i] += sim_sum[i-1]
for l_ in l:
    print(sim_sum[l_[1]]-sim_sum[max(l_[0]-2,0)])
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
    exit()
s = list(s)
t = list(t)
s_ = sorted(s)
t_ = sorted(t)
t_.reverse()
if ''.join(s_)<''.join(t_):
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
t = input()
s = list(s)
t = list(t)
s_ = sorted(s)
t_ = sorted(t)
t_.reverse()
if ''.join(s_)<''.join(t_):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
if s==t:
    print('No')
    exit()
s = list(s)
t = list(t)
s_ = sorted(s)
t_ = sorted(t)
t_.reverse()
print(s_)
print(t_)
for i in range(len(s_)):
    if s[i]<t[i]:
        print('Yes')
        exit()
    elif s[i]>t[i]:
        print('No')
        exit()
print('Yes')

Fixed submission:
s = input()
t = input()
s = list(s)
t = list(t)
s_ = sorted(s)
t_ = sorted(t)
t_.reverse()
if ''.join(s_)<''.join(t_):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = input()
f_x=0
for i in range(len(n)):
    f_x+=int(n[i])
if int(n)%f_n==0:
    print('Yes')
else:
    print('No')


Fixed submission:
n = input()
f_x=0
for i in range(len(n)):
    f_x+=int(n[i])
if int(n)%f_x==0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
f_x=0
for i in range(len(n)):
    f_x+=int(n[i])
if int(n)%f_n==0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = input()
f_x=0
for i in range(len(n)):
    f_x+=int(n[i])
if int(n)%f_x==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,c = map(int,input().split())
l = [[0]*(10**5+1) for _ in range(c+1)]
for _ in range(n):
    s,t,c = map(int,input().split())
    for i in range(s,t+1):
        l[c-1][i] = 1
ans = [0]*10**5
for i in range(len(l)):
    for j in range(len(l[i])):
        ans[j] += l[i][j]
print(max(ans))

Fixed submission:
n,c = map(int,input().split())
l = [[0]*(10**5+1) for _ in range(c+1)]
for _ in range(n):
    s,t,c = map(int,input().split())
    for i in range(s,t+1):
        l[c-1][i] = 1
ans = [0]*(10**5+1)
for i in range(len(l)):
    for j in range(len(l[i])):
        ans[j] += l[i][j]
print(max(ans))

Buggy python submission (verdict: Runtime Error):
n,c = map(int,input().split())
l = [[0]*10**5 for _ in range(c)]
for _ in range(n):
    s,t,c = map(int,input().split())
    for i in range(s,t+1):
        l[c-1][i] = 1
ans = [0]*10**5
for i in range(len(l)):
    for j in range(len(l[i])):
        ans[j] += l[i][j]
print(max(ans))

Fixed submission:
n,c = map(int,input().split())
l = [[0]*(10**5+1) for _ in range(c+1)]
for _ in range(n):
    s,t,c = map(int,input().split())
    for i in range(s,t+1):
        l[c-1][i] = 1
ans = [0]*(10**5+1)
for i in range(len(l)):
    for j in range(len(l[i])):
        ans[j] += l[i][j]
print(max(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
div = make_divisors(n)
for i in div[1:]:
    if n//(i-1)==n%(i-1):
        ans += i-1

print(ans)

Fixed submission:
n,c = map(int,input().split())
l = [[0]*(10**5+1) for _ in range(c+1)]
for _ in range(n):
    s,t,c = map(int,input().split())
    for i in range(s,t+1):
        l[c-1][i] = 1
ans = [0]*(10**5+1)
for i in range(len(l)):
    for j in range(len(l[i])):
        ans[j] += l[i][j]
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
def f(i):
    if i==0:
        return 2
    elif i==1:
        return 1
    else:
        return f(i-1)+f(i-2)
print(f(n))

Fixed submission:
n = int(input())
memo = [0]*87
def f(i):
    if memo[i]:
        return memo[i]
    if i==0:
        return 2
    elif i==1:
        return 1
    else:
        memo[i] = f(i-1)+f(i-2)
        return memo[i]
print(f(n))
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,list(input()))
for i in range(2):
    if i==0:
        ans=a+b
    else:
        ans=a-b
    for j in range(2):
        if j==0:
            ans+=c
        else:
            ans-=c
        for k in range(2):
            if k==0:
                ans+=d
            else:
                ans-=d
            if ans==7:
                ret=[i,j,k]
for i in range(len(ret)):
    if ret[i]==0:
        ret[i]='+'
    else:
        ret[i]='-'
print('{}{}{}{}{}{}{}=7'.format(a,ret[0],b,ret[1],c,ret[2],d))


Fixed submission:
a,b,c,d = map(int,list(input()))
for i in range(2):
    if i==0:
        ans=a+b
    else:
        ans=a-b
    r1=ans
    for j in range(2):
        ans=r1
        if j==0:
            ans+=c
        else:
            ans-=c
        r2=ans
        for k in range(2):
            ans=r2
            if k==0:
                ans+=d
            else:
                ans-=d
            if ans==7:
                ret=[i,j,k]
                for i in range(len(ret)):
                    if ret[i]==0:
                        ret[i]='+'
                    else:
                        ret[i]='-'
                print('{}{}{}{}{}{}{}=7'.format(a,ret[0],b,ret[1],c,ret[2],d))
                exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
import bisect
ans = 0
for i in range(len(a)):
    j = bisect.bisect_right(b,a[i])
    for k in range(j,len(b)):
        m = bisect.bisect_right(c,b[k])
        ans += n-m
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
import bisect
ans = 0
for j in range(len(b)):
    i = bisect.bisect_left(a,b[j])
    k = bisect.bisect_right(c,b[j])
    ans += i*(n-k)
print(ans)