java – how to overcome problem in integer overflow even using long also wrong answers?

for input 2:100000,90000 getting wrong answer even i used long
import java.util.;
import java.io.
;
class Main
{
public static void main(String() args)
{
Scanner s = new Scanner(System.in);

        int a = s.nextInt();

        int arr() = new int(a);

        for(int i=0;i<a;i++)
            arr(i) = s.nextInt();

        Arrays.sort(arr);

        long sum=0;

        sum=(arr(a-1))*(arr(a-2)); 

        System.out.println(sum);

    }
}

how to overcome problem in integer overflow even using long also wrong answers ?

gmail – stick the email subject on top when scrolling down email with long body content?

Is there a way or at-least an extension that can make the gmail mail subject stick on top?

while we scroll down while reading the email long body content !

sometimes we have to follow up what the subject of mail is some information like a ticket number is always in the subject.

How long before expiration can one renew a French passport?

I.-En cas de demande de renouvellement, le passeport est délivré sur
production par le demandeur :

1° De son passeport, de son passeport de service ou de son passeport
de mission délivré en application des articles 4 à 17 du présent
décret, valide ou périmé depuis moins de cinq ans à la date de la
demande du renouvellement ; en pareil cas, sans préjudice, le cas
échéant, de la vérification des informations produites à l’appui de la
demande de cet ancien titre, le demandeur est dispensé d’avoir à
justifier de son état civil et de sa nationalité française ;

So there’s actually no mention of a maximum validity until expiration. There’s nothing here that prevent you to renew your passport the day after it was issued.

bash – ‘column: line too long’ when it doesn’t seem to

I’m using grep, sed and column to make a little makefile documentation, but I get the following error: column: line too long.

My attempt is the following:

## this is the documentation
yes:
  @echo hello

help:
  @grep -Pzo "##.*n(a-zA-Z0-9_-)+:" $(MAKEFILE_LIST) 
  | sed -z "s/n/,/"                                  
  | sed -n "s/##(.*),(.*)(:, 1)/21/p"           
  | column -t -s ','

I really don’t understand the problem here because when I run the command without the column I get a line size way below the 2049 (defined by MAXLINELEN in C code).

user expectation – Terminology: Long press or Touch & hold?

I would suggest “Touch and hold”. Many users tend not to understand the term “long” in longpress. Therefore “Press and (then) hold” is a better description of the action.


Edit

OK, due to the comments below, here is a more descriptive answer 🙂

“Longpress” means “press for a long time”.The word “long” comes first but that is the second action the user has to commit. We also have to tell the user how much time (s)he shall spend during that “long” time.

The word “longpress” is not (yet) a term that common people understand.

So, every term beginning with the word “long…” aught to be avoided.

“Press and hold” on the other hand tells the user to 1: press on the item and then 2: keep on doing so until something else happens, something that will inform the user (s)he can release his/her finger from the device.

usability – How to handle long text that should be also searchable

I have this row, where the content highlighted in red is searchable.
I expect it always to be visible, but we have some corner cases where this content can be quite long and hidden behind ellipsis (css line clamped).
However, we need this data to be present too, so I considered using tooltip for the rest of content hidden behind ellipsis. Do you think it’s a good idea or there are some other ways?
enter image description here

optimization – Why a query takes too long in statistics thread state in AWS Aurora MySQL?

The following query execution too long in statistics state and I couldn’t figure out why.

DB engine – 5.7.mysql_aurora.2.07.2

DB Size – db.r5.4xlarge

Sample Query Profile output

+--------------------------------+----------+
| Status                         | Duration |
+--------------------------------+----------+
| starting                       | 0.000023 |
| checking query cache for query | 0.000155 |
| checking permissions           | 0.000009 |
| checking permissions           | 0.000002 |
| checking permissions           | 0.000003 |
| checking permissions           | 0.000002 |
| checking permissions           | 0.000009 |
| Opening tables                 | 0.000035 |
| init                           | 0.000102 |
| System lock                    | 0.000035 |
| optimizing                     | 0.000004 |
| optimizing                     | 0.000003 |
| optimizing                     | 0.000011 |
| statistics                     | 0.224528 |
| preparing                      | 0.000030 |
| Sorting result                 | 0.000017 |
| statistics                     | 0.000041 |
| preparing                      | 0.000013 |
| Creating tmp table             | 0.000023 |
| optimizing                     | 0.000013 |
| statistics                     | 0.064207 |
| preparing                      | 0.000035 |
| Sorting result                 | 0.000025 |
| statistics                     | 0.000098 |
| preparing                      | 0.000018 |
| executing                      | 0.000011 |
| Sending data                   | 0.000007 |
| executing                      | 0.000003 |
| Sending data                   | 0.000251 |
| executing                      | 0.000007 |
| Sending data                   | 0.000003 |
| executing                      | 0.000002 |
| Sending data                   | 0.000526 |
| end                            | 0.000007 |
| query end                      | 0.000013 |
| removing tmp table             | 0.000007 |
| query end                      | 0.000004 |
| closing tables                 | 0.000003 |
| removing tmp table             | 0.000004 |
| closing tables                 | 0.000002 |
| removing tmp table             | 0.000005 |
| closing tables                 | 0.000002 |
| removing tmp table             | 0.000004 |
| closing tables                 | 0.000010 |
| freeing items                  | 0.000050 |
| storing result in query cache  | 0.000007 |
| cleaned up                     | 0.000004 |
| cleaning up                    | 0.000017 |
+--------------------------------+----------+

Query

select xo.ITEM, xo.VALUE
from (
         select pi.ITEM, pi.ITEM_GROUP, pi.VALUE
         from TABLE_2 pi
                  inner join (select max(ps.EXPORTED_DATE) as max_expo, ps.ITEM
                              from TABLE_2 ps
                                       inner join (
                                  select max(pp.EFFECTIVE_DATE) max_eff_TABLE_2, pp.ITEM
                                  from TABLE_2 pp
                                  where pp.EFFECTIVE_DATE <= '2020/07/17'
                                    and ITEM in
                                        ('20', '30', '40', '50', '110', '120', '320', '520', '720', '820', '920', '321',
                                         '275', '221')
                                  group by ITEM
                              ) a on ps.EFFECTIVE_DATE = a.max_eff_TABLE_2 and ps.ITEM = a.ITEM
                              group by a.ITEM) rr on rr.ITEM = pi.ITEM and rr.max_expo = pi.EXPORTED_DATE) xo

         inner join (
    select ea.ITEM, ea.CUSTOMER_ID, ea.ITEM_GROUP
    from TABLE_1 ea
             inner join (
        select MAX(e.EFFECTIVE_DATE) eat_max_eff, e.ITEM, e.CUSTOMER_ID
        from TABLE_1 e
        where e.CUSTOMER_ID = '20'
          and ITEM in ('20', '30', '40', '50', '110', '120', '320', '520', '720', '820', '920', '321', '275', '221')
          and EFFECTIVE_DATE <= '2020/07/17'
        group by e.ITEM
    ) aa
    where ea.ITEM = (aa.ITEM)
      and ea.CUSTOMER_ID = aa.CUSTOMER_ID
      and ea.EFFECTIVE_DATE = aa.eat_max_eff) lo
                    on lo.ITEM_GROUP = xo.ITEM_GROUP and lo.ITEM = xo.ITEM;

Indexes

Table 1

mysql> SHOW INDEX FROM T1;
+-------+------------+--------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name     | Seq_in_index | Column_name    | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+--------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| T1    |          0 | PRIMARY      |            1 | CUSTOMER_ID    | A         |     3297549 |     NULL | NULL   |      | BTREE      |         |               |
| T1    |          0 | PRIMARY      |            2 | ITEM           | A         |   687374784 |     NULL | NULL   |      | BTREE      |         |               |
| T1    |          0 | PRIMARY      |            3 | EFFECTIVE_DATE | A         |  1314196480 |     NULL | NULL   |      | BTREE      |         |               |
| T1    |          1 | t1_ix_item   |            1 | ITEM           | A         |     2151649 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+--------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

Table 2


mysql> SHOW INDEX FROM TABLE_2;
+-------+------------+-----------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name              | Seq_in_index | Column_name    | Collation | Cardinality | Sub_T2rt | T2cked | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| T2    |          0 | PRIMARY               |            1 | ITEM           | A         |           1 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          0 | PRIMARY               |            2 | ITEM_GROUP     | A         |       14265 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          0 | PRIMARY               |            3 | EFFECTIVE_DATE | A         |    63663076 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          0 | PRIMARY               |            4 | EXPORTED_DATE  | A         |    62464764 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_expo       |            1 | ITEM           | A         |      115823 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_expo       |            2 | EXPORTED_DATE  | A         |    13766454 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_date   |            1 | ITEM           | A         |      115823 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_date   |            2 | EFFECTIVE_DATE | A         |    13766454 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_ig     |            1 | ITEM           | A         |      115823 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_ig     |            2 | EFFECTIVE_DATE | A         |    13766454 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_ig     |            3 | ITEM_GROUP     | A         |    68216912 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_idx_effective_date |            1 | EFFECTIVE_DATE | A         |       79406 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+-----------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

According to this: statistics State in MySQL Processlist

I checked the innodb_buffer_pool_size.

mysql> SHOW VARIABLES LIKE "innodb_buffer_pool_size";
+-------------------------+-------------+
| Variable_name           | Value       |
+-------------------------+-------------+
| innodb_buffer_pool_size | 96223625216 |
+-------------------------+-------------+

In EXPLAIN output rows are minimal (Depends on the Item count in the query. If Item count is 10, the number of rows were 20). Even though the row counts are minimal why the query takes too long in statistics state?

dnd 5e – Do monsters with a spellcasting trait get spell slots back after a long rest?

Some monsters, like a lich, have the Spellcasting trait. This trait allows such monsters to cast spells using spell slots, much as spellcaster player characters do.

However, taking the lich as an example, the trait does not mention how spell slots are regained (I’m ignoring their Lair Actions for the purposes of this question). Looking at the general rules on monsters’ Spellcasting trait in the Special Traits section:

Spellcasting

A monster with the Spellcasting class feature has a spellcaster level and spell slots, which it uses to cast its spells of 1st level and higher. The spellcaster level is also used for any cantrips included in the feature.

The monster has a list of spells known or prepared from a specific class. The list might also include spells from a feature in that class, such as the Divine Domain feature of the cleric or the Druid Circle feature of the druid. The monster is considered a member of that class when attuning to or using a magic item that requires membership in the class or access to its spell list.

A monster can cast a spell from its list at a higher level if it has the spell slot to do so. For example, a drow mage with the 3rd-level lightning bolt spell can cast it as a 5th-level spell by using one of its 5th-level spell slots.

You can change the spells that a monster knows or has prepared, replacing any spell on its spell list with a spell of the same level and from the same class list. If you do so, you might cause the monster to be a greater or lesser threat than suggested by its challenge rating.

There is no mention of spells slots coming back on a long rest. Elsewhere in the general rules, this is explicitly mentioned for other traits (such as X/Day traits):

For example, “1/Day” means a special ability can be used once and that the monster must finish a long rest to use it again.

It’s reasonable to assume that monsters with the Spellcasting trait do probably get their spell slots back on a long rest because that’s how it works for PCs, but on the other hand, monsters and PCs don’t necessarily use the same rules. So, does anything explicitly state that monsters with the Spellcasting trait get their spell slots back on a long rest?

Deepin desktop takes long time to launch

After logging into ubuntu (where one type in the passwoed), it takes a long time (35-45s) to launch the deepin desktop. I read somewhere that deepin hogs a lot of memory. A check with my system monitor gives a 70% usage of my 4gb RAM with just the system monitor and firefox running. My laptop is an hp pavilion g4 series notebook with an i5 intel processor. Is it my laptop’s or the DDe’s fault?