diff --git a/lib/production/CompetitiveProgramming/AtCoder/contest212/A.class b/lib/production/CompetitiveProgramming/AtCoder/contest212/A.class new file mode 100644 index 0000000..ef67272 Binary files /dev/null and b/lib/production/CompetitiveProgramming/AtCoder/contest212/A.class differ diff --git a/lib/production/CompetitiveProgramming/AtCoder/contest212/B.class b/lib/production/CompetitiveProgramming/AtCoder/contest212/B.class new file mode 100644 index 0000000..cbbbd42 Binary files /dev/null and b/lib/production/CompetitiveProgramming/AtCoder/contest212/B.class differ diff --git a/lib/production/CompetitiveProgramming/AtCoder/contest212/c.class b/lib/production/CompetitiveProgramming/AtCoder/contest212/c.class new file mode 100644 index 0000000..d215614 Binary files /dev/null and b/lib/production/CompetitiveProgramming/AtCoder/contest212/c.class differ diff --git a/lib/production/CompetitiveProgramming/AtCoder/twoonethree/A.class b/lib/production/CompetitiveProgramming/AtCoder/twoonethree/A.class new file mode 100644 index 0000000..fc95eda Binary files /dev/null and b/lib/production/CompetitiveProgramming/AtCoder/twoonethree/A.class differ diff --git a/lib/production/CompetitiveProgramming/AtCoder/twoonethree/B.class b/lib/production/CompetitiveProgramming/AtCoder/twoonethree/B.class new file mode 100644 index 0000000..9357582 Binary files /dev/null and b/lib/production/CompetitiveProgramming/AtCoder/twoonethree/B.class differ diff --git a/lib/production/CompetitiveProgramming/AtCoder/twoonethree/C.class b/lib/production/CompetitiveProgramming/AtCoder/twoonethree/C.class new file mode 100644 index 0000000..9399f72 Binary files /dev/null and b/lib/production/CompetitiveProgramming/AtCoder/twoonethree/C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/A.class b/lib/production/CompetitiveProgramming/Codeforces/A.class new file mode 100644 index 0000000..bf06065 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/B.class b/lib/production/CompetitiveProgramming/Codeforces/B.class new file mode 100644 index 0000000..9963a7b Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/C.class b/lib/production/CompetitiveProgramming/Codeforces/C.class new file mode 100644 index 0000000..0c99b4f Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Hello.class b/lib/production/CompetitiveProgramming/Codeforces/Hello.class new file mode 100644 index 0000000..cd92bc0 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Hello.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1033A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1033A.class new file mode 100644 index 0000000..63b8d89 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1033A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1036A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1036A.class new file mode 100644 index 0000000..edf900f Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1036A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1037B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1037B.class new file mode 100644 index 0000000..e4b755c Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1037B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1040A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1040A.class new file mode 100644 index 0000000..c55f28c Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1040A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1041B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1041B.class new file mode 100644 index 0000000..5940356 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1041B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1051B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1051B.class new file mode 100644 index 0000000..e3b5c49 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1051B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1054B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1054B.class new file mode 100644 index 0000000..d8d39c6 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1054B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1057A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1057A.class new file mode 100644 index 0000000..061da4e Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1057A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1073A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1073A.class new file mode 100644 index 0000000..c796cbf Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1073A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1073B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1073B.class new file mode 100644 index 0000000..61edd79 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1073B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1077B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1077B.class new file mode 100644 index 0000000..5699a51 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1077B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1084A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1084A.class new file mode 100644 index 0000000..fbd69a4 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1084A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1088B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1088B.class new file mode 100644 index 0000000..5ea94a0 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1088B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1090M.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1090M.class new file mode 100644 index 0000000..afe6338 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1090M.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1092B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1092B.class new file mode 100644 index 0000000..b0d9c71 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1092B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1101A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1101A.class new file mode 100644 index 0000000..52dfcfd Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1101A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1107B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1107B.class new file mode 100644 index 0000000..26d823d Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1107B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem112A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem112A.class new file mode 100644 index 0000000..25d2268 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem112A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1133A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1133A.class new file mode 100644 index 0000000..0f1fc11 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1133A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1136B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1136B.class new file mode 100644 index 0000000..9ef1916 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1136B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1139B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1139B.class new file mode 100644 index 0000000..180a0d7 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1139B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1141A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1141A.class new file mode 100644 index 0000000..ed4e1e4 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1141A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1144C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1144C.class new file mode 100644 index 0000000..e29532a Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1144C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1165B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1165B.class new file mode 100644 index 0000000..52de47a Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1165B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem116A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem116A.class new file mode 100644 index 0000000..ba976df Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem116A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem118A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem118A.class new file mode 100644 index 0000000..954a174 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem118A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem118B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem118B.class new file mode 100644 index 0000000..289d3ff Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem118B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1195B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1195B.class new file mode 100644 index 0000000..fc33926 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1195B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1206B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1206B.class new file mode 100644 index 0000000..8f612b2 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1206B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1213B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1213B.class new file mode 100644 index 0000000..7e604e1 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1213B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem122A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem122A.class new file mode 100644 index 0000000..c550ea2 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem122A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1234B1.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1234B1.class new file mode 100644 index 0000000..3cca521 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1234B1.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem124A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem124A.class new file mode 100644 index 0000000..70286dd Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem124A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1294C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1294C.class new file mode 100644 index 0000000..8c81049 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1294C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1325B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1325B.class new file mode 100644 index 0000000..f922293 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1325B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem133A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem133A.class new file mode 100644 index 0000000..415fb52 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem133A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1363B$FastReader.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1363B$FastReader.class new file mode 100644 index 0000000..ccad943 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1363B$FastReader.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1363B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1363B.class new file mode 100644 index 0000000..36c3d69 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1363B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1381A1.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1381A1.class new file mode 100644 index 0000000..ddee50a Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1381A1.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem139A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem139A.class new file mode 100644 index 0000000..3b5c6f5 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem139A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem141A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem141A.class new file mode 100644 index 0000000..91f24fd Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem141A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1453A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1453A.class new file mode 100644 index 0000000..2689fc7 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1453A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1453B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1453B.class new file mode 100644 index 0000000..88df7f0 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1453B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1462A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1462A.class new file mode 100644 index 0000000..c244182 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1462A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1462B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1462B.class new file mode 100644 index 0000000..78db350 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1462B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1462C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1462C.class new file mode 100644 index 0000000..a35c827 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1462C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1462D.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1462D.class new file mode 100644 index 0000000..2e61af8 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1462D.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1465A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1465A.class new file mode 100644 index 0000000..541e943 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1465A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1466C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1466C.class new file mode 100644 index 0000000..28ba759 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1466C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1468B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1468B.class new file mode 100644 index 0000000..54d7933 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1468B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1473B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1473B.class new file mode 100644 index 0000000..cfdfbcc Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1473B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem148A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem148A.class new file mode 100644 index 0000000..a20349f Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem148A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem149A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem149A.class new file mode 100644 index 0000000..354cf99 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem149A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1520C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1520C.class new file mode 100644 index 0000000..79d10e9 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1520C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1521A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1521A.class new file mode 100644 index 0000000..c3154ae Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1521A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1537A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1537A.class new file mode 100644 index 0000000..8ece3d7 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1537A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1537B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1537B.class new file mode 100644 index 0000000..92ef5fa Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1537B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1537C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1537C.class new file mode 100644 index 0000000..63e0678 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1537C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1537D.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1537D.class new file mode 100644 index 0000000..56b9206 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1537D.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1538A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1538A.class new file mode 100644 index 0000000..9474953 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1538A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1538C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1538C.class new file mode 100644 index 0000000..528bfb3 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1538C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1538b.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1538b.class new file mode 100644 index 0000000..0e99342 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1538b.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1539A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1539A.class new file mode 100644 index 0000000..0e15eee Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1539A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1539B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1539B.class new file mode 100644 index 0000000..5c9b205 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1539B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1541B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1541B.class new file mode 100644 index 0000000..f6d77bc Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1541B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1546B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1546B.class new file mode 100644 index 0000000..a2ab47c Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1546B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1547B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1547B.class new file mode 100644 index 0000000..305ae3f Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1547B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1547C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1547C.class new file mode 100644 index 0000000..4d27d5b Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1547C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1553C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1553C.class new file mode 100644 index 0000000..0d7c001 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1553C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1554A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1554A.class new file mode 100644 index 0000000..8492b1e Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1554A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1554B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1554B.class new file mode 100644 index 0000000..cee5a08 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1554B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1557B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1557B.class new file mode 100644 index 0000000..38ab523 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1557B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1559C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1559C.class new file mode 100644 index 0000000..85dfc4d Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1559C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem155A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem155A.class new file mode 100644 index 0000000..9945e7a Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem155A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1560A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1560A.class new file mode 100644 index 0000000..506ddf8 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1560A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1560B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1560B.class new file mode 100644 index 0000000..680636c Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1560B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1560C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1560C.class new file mode 100644 index 0000000..7d714ca Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1560C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1562A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1562A.class new file mode 100644 index 0000000..0e77af5 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1562A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1562B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1562B.class new file mode 100644 index 0000000..d62d5cb Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1562B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem158A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem158A.class new file mode 100644 index 0000000..f5d9f4a Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem158A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem160A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem160A.class new file mode 100644 index 0000000..18bb8ff Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem160A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem160B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem160B.class new file mode 100644 index 0000000..ffa59dd Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem160B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem165A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem165A.class new file mode 100644 index 0000000..ed025e5 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem165A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem166A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem166A.class new file mode 100644 index 0000000..b7ccb0b Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem166A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem189A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem189A.class new file mode 100644 index 0000000..e0e0cbe Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem189A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem199A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem199A.class new file mode 100644 index 0000000..f46caed Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem199A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem1B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem1B.class new file mode 100644 index 0000000..487d39b Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem1B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem200B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem200B.class new file mode 100644 index 0000000..a2263b2 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem200B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem205A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem205A.class new file mode 100644 index 0000000..e7b3e6c Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem205A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem208A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem208A.class new file mode 100644 index 0000000..0d69d24 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem208A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem214A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem214A.class new file mode 100644 index 0000000..7489813 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem214A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem218B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem218B.class new file mode 100644 index 0000000..3593c19 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem218B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem219A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem219A.class new file mode 100644 index 0000000..9e07875 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem219A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem224A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem224A.class new file mode 100644 index 0000000..bd5f23c Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem224A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem227B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem227B.class new file mode 100644 index 0000000..1e82668 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem227B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem228A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem228A.class new file mode 100644 index 0000000..1fe4a88 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem228A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem230A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem230A.class new file mode 100644 index 0000000..9ef1f13 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem230A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem230B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem230B.class new file mode 100644 index 0000000..04feb75 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem230B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem231A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem231A.class new file mode 100644 index 0000000..26257cf Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem231A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem236A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem236A.class new file mode 100644 index 0000000..8c98962 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem236A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem236B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem236B.class new file mode 100644 index 0000000..9f7bc5d Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem236B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem237A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem237A.class new file mode 100644 index 0000000..07b6001 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem237A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem239A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem239A.class new file mode 100644 index 0000000..c63fae8 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem239A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem242B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem242B.class new file mode 100644 index 0000000..2c75c1e Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem242B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem248A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem248A.class new file mode 100644 index 0000000..6ce0929 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem248A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem253A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem253A.class new file mode 100644 index 0000000..82bd127 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem253A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem25A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem25A.class new file mode 100644 index 0000000..26ba133 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem25A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem263A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem263A.class new file mode 100644 index 0000000..f945bd6 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem263A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem266A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem266A.class new file mode 100644 index 0000000..7c3ec42 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem266A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem268A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem268A.class new file mode 100644 index 0000000..14370be Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem268A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem272A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem272A.class new file mode 100644 index 0000000..8fed335 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem272A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem279B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem279B.class new file mode 100644 index 0000000..4283af8 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem279B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem281A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem281A.class new file mode 100644 index 0000000..191e56c Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem281A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem282A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem282A.class new file mode 100644 index 0000000..c0694da Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem282A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem298B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem298B.class new file mode 100644 index 0000000..38de186 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem298B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem298C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem298C.class new file mode 100644 index 0000000..9055429 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem298C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem313B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem313B.class new file mode 100644 index 0000000..4039c03 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem313B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem318A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem318A.class new file mode 100644 index 0000000..60206d5 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem318A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem320A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem320A.class new file mode 100644 index 0000000..df733a9 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem320A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem327B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem327B.class new file mode 100644 index 0000000..9f1f267 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem327B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem32B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem32B.class new file mode 100644 index 0000000..7c78588 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem32B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem339A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem339A.class new file mode 100644 index 0000000..55594bb Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem339A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem339B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem339B.class new file mode 100644 index 0000000..c525498 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem339B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem344A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem344A.class new file mode 100644 index 0000000..2a0a374 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem344A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem349A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem349A.class new file mode 100644 index 0000000..8003119 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem349A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem34A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem34A.class new file mode 100644 index 0000000..0a17d3e Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem34A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem34B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem34B.class new file mode 100644 index 0000000..3625ee6 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem34B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem352A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem352A.class new file mode 100644 index 0000000..541de8a Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem352A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem352B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem352B.class new file mode 100644 index 0000000..193245b Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem352B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem353A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem353A.class new file mode 100644 index 0000000..356304a Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem353A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem363B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem363B.class new file mode 100644 index 0000000..0cda896 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem363B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem368B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem368B.class new file mode 100644 index 0000000..d3bbcca Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem368B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem433A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem433A.class new file mode 100644 index 0000000..546bf61 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem433A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem433B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem433B.class new file mode 100644 index 0000000..ffa35fe Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem433B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem43A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem43A.class new file mode 100644 index 0000000..543d821 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem43A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem443A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem443A.class new file mode 100644 index 0000000..410d701 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem443A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem450A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem450A.class new file mode 100644 index 0000000..3a52dfd Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem450A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem451A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem451A.class new file mode 100644 index 0000000..7f95838 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem451A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem459B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem459B.class new file mode 100644 index 0000000..1d5bc7e Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem459B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem466A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem466A.class new file mode 100644 index 0000000..b025090 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem466A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem467A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem467A.class new file mode 100644 index 0000000..7cb261f Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem467A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem467B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem467B.class new file mode 100644 index 0000000..5cfae1b Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem467B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem469A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem469A.class new file mode 100644 index 0000000..c5ffadb Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem469A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem474B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem474B.class new file mode 100644 index 0000000..6899674 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem474B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem476B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem476B.class new file mode 100644 index 0000000..560acf3 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem476B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem486A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem486A.class new file mode 100644 index 0000000..8f3d995 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem486A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem492B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem492B.class new file mode 100644 index 0000000..5bcebdd Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem492B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem499B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem499B.class new file mode 100644 index 0000000..281c6ea Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem499B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem4A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem4A.class new file mode 100644 index 0000000..f9cd5a3 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem4A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem4C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem4C.class new file mode 100644 index 0000000..a37f243 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem4C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem515C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem515C.class new file mode 100644 index 0000000..5c785a4 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem515C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem519B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem519B.class new file mode 100644 index 0000000..0f77955 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem519B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem519C.class b/lib/production/CompetitiveProgramming/Codeforces/Problem519C.class new file mode 100644 index 0000000..3874c23 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem519C.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem520A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem520A.class new file mode 100644 index 0000000..b857ef2 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem520A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem545D.class b/lib/production/CompetitiveProgramming/Codeforces/Problem545D.class new file mode 100644 index 0000000..9684ce2 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem545D.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem546A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem546A.class new file mode 100644 index 0000000..e661947 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem546A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem59A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem59A.class new file mode 100644 index 0000000..584c66b Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem59A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem617A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem617A.class new file mode 100644 index 0000000..073601d Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem617A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem61A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem61A.class new file mode 100644 index 0000000..514e8ea Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem61A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem677A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem677A.class new file mode 100644 index 0000000..a7ee345 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem677A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem688B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem688B.class new file mode 100644 index 0000000..7e33dbd Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem688B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem69A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem69A.class new file mode 100644 index 0000000..a31cab8 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem69A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem705A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem705A.class new file mode 100644 index 0000000..aded6d5 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem705A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem71A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem71A.class new file mode 100644 index 0000000..ac3de89 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem71A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem734A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem734A.class new file mode 100644 index 0000000..c01e9c2 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem734A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem734B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem734B.class new file mode 100644 index 0000000..5c7b04d Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem734B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem766B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem766B.class new file mode 100644 index 0000000..a390783 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem766B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem913B$Node.class b/lib/production/CompetitiveProgramming/Codeforces/Problem913B$Node.class new file mode 100644 index 0000000..1024c02 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem913B$Node.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem913B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem913B.class new file mode 100644 index 0000000..c8870b4 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem913B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem96A.class b/lib/production/CompetitiveProgramming/Codeforces/Problem96A.class new file mode 100644 index 0000000..14ba5de Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem96A.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem977B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem977B.class new file mode 100644 index 0000000..5279f05 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem977B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Problem978B.class b/lib/production/CompetitiveProgramming/Codeforces/Problem978B.class new file mode 100644 index 0000000..1609026 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Problem978B.class differ diff --git a/lib/production/CompetitiveProgramming/Codeforces/Sample.class b/lib/production/CompetitiveProgramming/Codeforces/Sample.class new file mode 100644 index 0000000..1ebc023 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Codeforces/Sample.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/LinkedList.class b/lib/production/CompetitiveProgramming/LinkedList/LinkedList.class new file mode 100644 index 0000000..3a410de Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/LinkedList.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LinkedListDeletion$Node.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LinkedListDeletion$Node.class new file mode 100644 index 0000000..c1d7473 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LinkedListDeletion$Node.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LinkedListDeletion.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LinkedListDeletion.class new file mode 100644 index 0000000..ebf500a Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LinkedListDeletion.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LoopInLL$Node.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LoopInLL$Node.class new file mode 100644 index 0000000..ceda619 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LoopInLL$Node.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LoopInLL.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LoopInLL.class new file mode 100644 index 0000000..ab654af Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/LoopInLL.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/MiddleOfLL$Node.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/MiddleOfLL$Node.class new file mode 100644 index 0000000..bd31249 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/MiddleOfLL$Node.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/MiddleOfLL.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/MiddleOfLL.class new file mode 100644 index 0000000..a6060a8 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/MiddleOfLL.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/NthNodeFromEnd$Node.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/NthNodeFromEnd$Node.class new file mode 100644 index 0000000..6f48235 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/NthNodeFromEnd$Node.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/NthNodeFromEnd.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/NthNodeFromEnd.class new file mode 100644 index 0000000..e274397 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/NthNodeFromEnd.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/PalindromeLL$Node.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/PalindromeLL$Node.class new file mode 100644 index 0000000..0c0b032 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/PalindromeLL$Node.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/PalindromeLL.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/PalindromeLL.class new file mode 100644 index 0000000..4228ac4 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/PalindromeLL.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/RemoveDuplicates$Node.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/RemoveDuplicates$Node.class new file mode 100644 index 0000000..cbed717 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/RemoveDuplicates$Node.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/RemoveDuplicates.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/RemoveDuplicates.class new file mode 100644 index 0000000..231b86c Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/RemoveDuplicates.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/SinglyLinkedList$Node.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/SinglyLinkedList$Node.class new file mode 100644 index 0000000..c233457 Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/SinglyLinkedList$Node.class differ diff --git a/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/SinglyLinkedList.class b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/SinglyLinkedList.class new file mode 100644 index 0000000..3fe4c1e Binary files /dev/null and b/lib/production/CompetitiveProgramming/LinkedList/SinglyLinkedList/SinglyLinkedList.class differ diff --git a/lib/production/CompetitiveProgramming/Notes/GCD.md b/lib/production/CompetitiveProgramming/Notes/GCD.md new file mode 100644 index 0000000..61880c9 --- /dev/null +++ b/lib/production/CompetitiveProgramming/Notes/GCD.md @@ -0,0 +1,38 @@ +# GCD OF A Number / HCF +If we subtract smaller number from the greater number, the GCD +of the number doesn't change. Hence this is the concept of the +basic euclidean algorithm +```` +static int gcd(int a, int b) + { + // Everything divides 0 + if (a == 0) + return b; + if (b == 0) + return a; + + // base case + if (a == b) + return a; + + // a is greater + if (a > b) + return gcd(a-b, b); + return gcd(a, b-a); + } +```` + +##Extended Euclidean Algorithm +Now instead of subtraction, we find the mod of the number and stop +when the number/remainder becomes 0. + +``` Euclidiean Algorithm +//Euclidiean algorithm + static long gcd(long a, long b){ + + if(b == 0){ + return a; + } + return gcd(b, a%b); + } +``` \ No newline at end of file diff --git a/lib/production/CompetitiveProgramming/Notes/SieveofEratosthenes.md b/lib/production/CompetitiveProgramming/Notes/SieveofEratosthenes.md new file mode 100644 index 0000000..10716c4 --- /dev/null +++ b/lib/production/CompetitiveProgramming/Notes/SieveofEratosthenes.md @@ -0,0 +1,24 @@ +##Sieve of Eratoshenes +Complexity: O(NloglogN) + +The basic idea is to mark the numbers as composite which are multiple or factors +of some other numbers. + +``` +private static boolean[] generatePrime() { + boolean a[] = new boolean[1000000]; + for (int i = 0; i < a.length; i++) { + a[i] = true; + } + + for (int p = 2; p * p < a.length; p++) { + if (a[p]) { + for (int i = p * p; i < a.length; i+=p) { + a[i] = false; + } + } + } + + return a; + } +``` \ No newline at end of file diff --git a/lib/production/CompetitiveProgramming/Problem1472B.class b/lib/production/CompetitiveProgramming/Problem1472B.class new file mode 100644 index 0000000..b683442 Binary files /dev/null and b/lib/production/CompetitiveProgramming/Problem1472B.class differ diff --git a/lib/production/CompetitiveProgramming/Suneet.class b/lib/production/CompetitiveProgramming/Suneet.class new file mode 100644 index 0000000..f86fb0a Binary files /dev/null and b/lib/production/CompetitiveProgramming/Suneet.class differ diff --git a/src/AtCoder/contest212/A.java b/src/AtCoder/contest212/A.java new file mode 100644 index 0000000..1d9facf --- /dev/null +++ b/src/AtCoder/contest212/A.java @@ -0,0 +1,19 @@ +package AtCoder.contest212; + +import java.util.Scanner; + +public class A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + if (a == 0 && b>0) { + System.out.println("Silver"); + }else if(b==0 && a>0) { + System.out.println("Gold"); + }else{ + System.out.println("Alloy"); + } + + } +} diff --git a/src/AtCoder/contest212/B.java b/src/AtCoder/contest212/B.java new file mode 100644 index 0000000..caa1f2d --- /dev/null +++ b/src/AtCoder/contest212/B.java @@ -0,0 +1,29 @@ +package AtCoder.contest212; + +import java.util.Scanner; + +public class B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String s = sc.next(); + if(s.charAt(0)==s.charAt(1) && s.charAt(1)==s.charAt(2) && s.charAt(2) == s.charAt(3)){ + System.out.println("Weak"); + }else { + //check for follows + boolean weak = true; + for (int i = 0; i < s.length()-1; i++) { + int a = s.charAt(i)-48; + int b = s.charAt(i+1)-48; + if((a+1) % 10 != b %10){ + weak = false; + } + + } + if(weak){ + System.out.println("Weak"); + }else{ + System.out.println("Strong"); + } + } + } +} diff --git a/src/AtCoder/contest212/c.java b/src/AtCoder/contest212/c.java new file mode 100644 index 0000000..c3b48dc --- /dev/null +++ b/src/AtCoder/contest212/c.java @@ -0,0 +1,19 @@ +package AtCoder.contest212; + +import java.util.Scanner; + +public class c { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int m = sc.nextInt(); + int a[] =new int[n]; + int b[] = new int[m]; + for (int i = 0; i < n; i++) { + a[i] = sc.nextInt(); + } + for (int i = 0; i < m; i++) { + b[i] = sc.nextInt(); + } + } +} diff --git a/src/AtCoder/twoonethree/A.java b/src/AtCoder/twoonethree/A.java new file mode 100644 index 0000000..c3efc43 --- /dev/null +++ b/src/AtCoder/twoonethree/A.java @@ -0,0 +1,13 @@ +package AtCoder.twoonethree; + +import java.util.Scanner; + +public class A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + int c = a^b; + System.out.println(c); + } +} diff --git a/src/AtCoder/twoonethree/B.java b/src/AtCoder/twoonethree/B.java new file mode 100644 index 0000000..1669fe6 --- /dev/null +++ b/src/AtCoder/twoonethree/B.java @@ -0,0 +1,24 @@ +package AtCoder.twoonethree; + +import java.util.Arrays; +import java.util.Scanner; + +public class B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long arr[] = new long[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextLong(); + } + long[] b = arr.clone(); + Arrays.sort(b); + int i = 0; + for (i = 0; i < n; i++) { + if(arr[i] == b[b.length-2]) { + break; + } + } + System.out.println(i+1); + } +} \ No newline at end of file diff --git a/src/AtCoder/twoonethree/C.java b/src/AtCoder/twoonethree/C.java new file mode 100644 index 0000000..42ed8fa --- /dev/null +++ b/src/AtCoder/twoonethree/C.java @@ -0,0 +1,21 @@ +package AtCoder.twoonethree; + +import java.util.Arrays; +import java.util.Scanner; + +public class C { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + long h = sc.nextLong(); + long w = sc.nextLong(); + long n = sc.nextLong(); + int x[] = new int[(int)n]; + int y[] = new int[(int)n]; + for (int i = 0; i < n; i++) { + x[i] = sc.nextInt(); + y[i] = sc.nextInt(); + } + Arrays.sort(x); + Arrays.sort(y); + } +} diff --git a/src/Codeforces/A.java b/src/Codeforces/A.java new file mode 100644 index 0000000..5c8ad11 --- /dev/null +++ b/src/Codeforces/A.java @@ -0,0 +1,16 @@ +package Codeforces; + +import java.util.Scanner; +import java.util.Stack; + +public class A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + + } + } + + +} diff --git a/src/Codeforces/B.java b/src/Codeforces/B.java new file mode 100644 index 0000000..53c468a --- /dev/null +++ b/src/Codeforces/B.java @@ -0,0 +1,14 @@ +package Codeforces; + +import java.util.Scanner; + +public class B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + + } + } + +} diff --git a/src/Codeforces/C.java b/src/Codeforces/C.java new file mode 100644 index 0000000..979d4e3 --- /dev/null +++ b/src/Codeforces/C.java @@ -0,0 +1,46 @@ +package Codeforces; + +import java.util.Scanner; + +public class C { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + long number[] = new long[t]; + long sum = 0; + long max = Long.MIN_VALUE; + long min = Long.MAX_VALUE; + for (int i = 0; i < t; i++) { + long a = sc.nextLong(); + sum = sum + a; + if (a < min) { + min = a; + } + if (a > max) { + max = a; + } + } + int m = sc.nextInt(); + for (int i = 0; i < m; i++) { + long x = sc.nextLong(); + long y = sc.nextLong(); + long sumEqual = sum; + long coins = 0; + if (x < max) { + } else { + coins = x - max; + sum = sum+coins; + } + sum = sum-x; + + if (y < sum) { + } else { + long coins2 = y - sum; + coins += coins2; + } + sum = sumEqual; + System.out.println(coins); + } + } +} diff --git a/src/Codeforces/D.java b/src/Codeforces/D.java new file mode 100644 index 0000000..e6c75a4 --- /dev/null +++ b/src/Codeforces/D.java @@ -0,0 +1,14 @@ +package Codeforces; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; + +public class D { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + } + } +} diff --git a/src/Codeforces/E1.java b/src/Codeforces/E1.java new file mode 100644 index 0000000..0224ee3 --- /dev/null +++ b/src/Codeforces/E1.java @@ -0,0 +1,45 @@ +package Codeforces; + +import java.util.ArrayList; +import java.util.Scanner; + +public class E1 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + ArrayList arr = new ArrayList(); + for (int i = 0; i < n; i++) { + arr.add(sc.nextLong()); + } + long length = 0; + long finalnumber = 0; + for (int i = 0; i < n; i++) { + long addingToBeg = (long) (Math.pow(10, length) * arr.get(i)); + long addingToEnd = (long) (Math.pow(10, 1) * finalnumber); + if (addingToBeg + finalnumber > addingToEnd + arr.get(i)) { + finalnumber = addingToEnd + arr.get(i); + } else { + finalnumber = addingToBeg + finalnumber; + } + length++; + } + ArrayList finalAns = new ArrayList<>(); + long ff = finalnumber; + while (ff != 0) { + finalAns.add(0, ff % 10); + ff = ff / 10; + } + + if (finalAns.size() == 0) { + System.out.println(arr.get(0)); + } else { + for (int i = 0; i < finalAns.size(); i++) { + System.out.print(finalAns.get(i) + " "); + } + System.out.println(); + } + } + } +} diff --git a/src/Codeforces/Problem1033A.java b/src/Codeforces/Problem1033A.java new file mode 100644 index 0000000..b71d7fc --- /dev/null +++ b/src/Codeforces/Problem1033A.java @@ -0,0 +1,23 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1033A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int q1 = sc.nextInt(); + int q2 = sc.nextInt(); + int k1 = sc.nextInt(); + int k2 = sc.nextInt(); + int c1 = sc.nextInt(); + int c2 = sc.nextInt(); + if ((c1 > q1 && k1 > q1 && c2 > q2 && k2 > q2) || (k1 < q1 && k2 > q2 && c1 < q1 && c2 > q2) || + (c1 < q1 && k1 < q1 && c2 < q2 && k2 < q2) || + (k1>q1 && c1>q1 && k2s) { + count += a[i]-s; + }else if(a[n-1-i] treeSet = new TreeSet<>(); + int arr[] = new int[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + } + int min = 0; + int max = -1; + boolean br = false; + int i; + for (i = 0; i < n; i++) { + if (arr[0] != 0) { + br = true; + break; + } else { + if (arr[i] >= min && arr[i]<=max+1) { + max = Math.max(max, arr[i]); + min = Math.min(min, arr[i]); + }else{ + br = true; + break; + } + } + } + if (i == n) { + System.out.println("-1"); + } else { + System.out.println(i + 1); + } + + } +} diff --git a/src/Codeforces/Problem1073A.java b/src/Codeforces/Problem1073A.java new file mode 100644 index 0000000..3277b81 --- /dev/null +++ b/src/Codeforces/Problem1073A.java @@ -0,0 +1,24 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1073A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + String s = sc.next(); + String res = ""; + for (int i = 1; i < n; i++) { + if(s.charAt(i)!= s.charAt(i-1)){ + res = res+s.charAt(i-1)+s.charAt(i); + break; + } + } + if(res.isEmpty()){ + System.out.println("NO"); + }else { + System.out.println("YES"); + System.out.println(res); + } + } +} diff --git a/src/Codeforces/Problem1073B.java b/src/Codeforces/Problem1073B.java new file mode 100644 index 0000000..cc105ec --- /dev/null +++ b/src/Codeforces/Problem1073B.java @@ -0,0 +1,41 @@ +package Codeforces; + +import java.util.HashSet; +import java.util.Scanner; +import java.util.Set; + +public class Problem1073B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int [] books = new int[n+1]; + for (int i = 1; i <= n; i++) { + books[i] = sc.nextInt(); + } + int [] steps = new int[n]; + for (int i = 0; i < n; i++) { + steps[i] = sc.nextInt(); + } + int track = 0; + boolean[] u = new boolean[n+1]; + for (int i = 0; i < n; i++) { + if(track == n || u[(steps[i])]){ + System.out.print("0 "); + }else{ + int position = getPosition(track, u, books, steps[i]); + System.out.print(position-track+" "); + track = position; + } + } + } + + private static int getPosition(int track, boolean[] u, int[] books, int element) { + for (int i = track; i <=books.length ; i++) { + u[books[i]] = true; + if(books[i] == element){ + return i; + } + } + return -1; + } +} \ No newline at end of file diff --git a/src/Codeforces/Problem1077B.java b/src/Codeforces/Problem1077B.java new file mode 100644 index 0000000..7a90a32 --- /dev/null +++ b/src/Codeforces/Problem1077B.java @@ -0,0 +1,29 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1077B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int arr[] = new int[n]; + int a[] = new int[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + a[i] = arr[i]; + } + int c= 0; + int c1= 0; + for (int i = 2; i < n; i++) { + if(arr[i]==1 && arr[i-1]==0 && arr[i-2]==1){ + arr[i-2]=0; + c++; + } + if(a[i]==1 && a[i-1]==0 && a[i-2]==1){ + a[i]=0; + c1++; + } + } + System.out.println(Math.min(c,c1)); + } +} diff --git a/src/Codeforces/Problem1084A.java b/src/Codeforces/Problem1084A.java new file mode 100644 index 0000000..b73235b --- /dev/null +++ b/src/Codeforces/Problem1084A.java @@ -0,0 +1,21 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1084A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int arr[] = new int[n]; + long electricity = 0; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + } + int count = 4; + for (int i = 1; i < n; i++) { + electricity += arr[i] * count; + count+=4; + } + System.out.println(electricity); + } +} diff --git a/src/Codeforces/Problem1088B.java b/src/Codeforces/Problem1088B.java new file mode 100644 index 0000000..478d5d4 --- /dev/null +++ b/src/Codeforces/Problem1088B.java @@ -0,0 +1,60 @@ +package Codeforces; + +import java.util.Arrays; +import java.util.Scanner; + +public class Problem1088B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int k = sc.nextInt(); + long arr[] = new long[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextLong(); + } + Arrays.sort(arr); + int index = 0; + for (int i = 0; i < k; i++) { + if (arr[i] > 0) { + index = i; + break; + } + } + long sum = 0; + //System.out.println(Arrays.toString(arr)); + for (int i = 0; i < k; i++) { + if (index < n) { + arr[index] = arr[index] - sum; + sum = sum + arr[index]; + if (arr[index] <= 0) { + if (index + 1 < n) { + for (int j = index + 1; j < n; j++) { + if (arr[j]-sum > 0) { + index = j; + break; + }else{ + index++; + } + } + if(index= 1) { + long l = sc.nextLong(); + long r = sc.nextLong(); + long d = sc.nextLong(); + long ans = 0; + long b = (d); + long e = ((r / d) + 1) * d; + if(br){ + System.out.println(e); + } + } + } +} diff --git a/src/Codeforces/Problem1107B.java b/src/Codeforces/Problem1107B.java new file mode 100644 index 0000000..e8f37ac --- /dev/null +++ b/src/Codeforces/Problem1107B.java @@ -0,0 +1,15 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1107B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + while (n-- >= 1) { + long k = sc.nextLong(); + long x = sc.nextLong(); + System.out.println(((9*(k-1))+x)); + } + } +} diff --git a/src/Codeforces/Problem1133A.java b/src/Codeforces/Problem1133A.java new file mode 100644 index 0000000..90e7777 --- /dev/null +++ b/src/Codeforces/Problem1133A.java @@ -0,0 +1,19 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1133A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String s1 = sc.next(); + String s2 = sc.next(); + int h1 = Integer.parseInt(s1.substring(0,2)); + int m1 = Integer.parseInt(s1.substring(3)); + int h2 = Integer.parseInt(s2.substring(0,2)); + int m2 = Integer.parseInt(s2.substring(3)); + int t1 = (h1*60)+m1; + int t2 = (h2*60)+m2; + int t3 = (t1+t2)/2; + System.out.printf("%02d:%02d",(t3/60),(t3%60)); + } +} diff --git a/src/Codeforces/Problem1136B.java b/src/Codeforces/Problem1136B.java new file mode 100644 index 0000000..0b9e714 --- /dev/null +++ b/src/Codeforces/Problem1136B.java @@ -0,0 +1,13 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1136B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int k = sc.nextInt(); + int total = 3*n+Math.min(n-k,k-1); + System.out.println(total); + } +} diff --git a/src/Codeforces/Problem1139B.java b/src/Codeforces/Problem1139B.java new file mode 100644 index 0000000..05b445d --- /dev/null +++ b/src/Codeforces/Problem1139B.java @@ -0,0 +1,26 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1139B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long arr[] = new long[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextLong(); + } + long sum = arr[n-1]; + long max = arr[n-1]-1; + long s = 0; + for (int i = n-2; i >=0 ; i--) { + s = Math.min(arr[i],max); + if ( s==0){ + break; + } + sum = sum+s; + max = s-1; + } + System.out.println(sum); + } +} diff --git a/src/Codeforces/Problem1141A.java b/src/Codeforces/Problem1141A.java new file mode 100644 index 0000000..9a0e117 --- /dev/null +++ b/src/Codeforces/Problem1141A.java @@ -0,0 +1,29 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1141A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + long n = sc.nextLong(); + long m = sc.nextLong(); + if(n == m){ + System.out.println("0"); + }else { + System.out.println(count(n, m, 0)); + } + + } + + private static int count(long n, long m, int count) { + if (n > m) { + return -1; + } + if (n == m) { + return count; + } + int c1 = count(n * 2, m, count + 1); + int c2 = count(n * 3, m, count + 1); + return Math.max(c1,c2); + } +} diff --git a/src/Codeforces/Problem1144C.java b/src/Codeforces/Problem1144C.java new file mode 100644 index 0000000..077a5b4 --- /dev/null +++ b/src/Codeforces/Problem1144C.java @@ -0,0 +1,42 @@ +package Codeforces; + +import java.util.*; + +public class Problem1144C { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int arr[] = new int[n]; + int cnt[] = new int[2*100000+1]; + int max = 0; + int count = 0; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + cnt[arr[i]]++; + if(cnt[arr[i]]==2){ + count++; + } + max = Math.max(max, cnt[arr[i]]); + } + if(max>=3){ + System.out.println("NO"); + return; + }else{ + System.out.println("YES"); + } + System.out.println(count); + for (int i = 0; i < cnt.length; i++) { + if (cnt[i] == 2) { + System.out.print(i+" "); + cnt[i]--; + } + } + System.out.println(); + System.out.println(n-count); + for (int i = cnt.length-1; i >=0; i--) { + if(cnt[i]==1) { + System.out.print(i + " "); + } + } + } +} diff --git a/src/Codeforces/Problem1165B.java b/src/Codeforces/Problem1165B.java new file mode 100644 index 0000000..6be1380 --- /dev/null +++ b/src/Codeforces/Problem1165B.java @@ -0,0 +1,60 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1165B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long arr[] = new long[n]; + for (int i = 0; i < n; i++) { + arr[i]= sc.nextInt(); + } + arr = sort(arr, 0, n-1); + int pos = 1; + for (int i = 0; i < n; i++) { + if(arr[i]>=pos){ + pos++; + } + } + System.out.println(pos-1); + } + + private static long[] sort(long arr[], int si, int ei) { + if (si == ei) { + return new long[]{arr[si]}; + } + int mid = (si + ei) / 2; + long[] first = sort(arr, si, mid); + long[] second = sort(arr, mid + 1, ei); + return merge(first, second); + } + + private static long[] merge(long[] first, long[] second) { + long merged[] = new long[first.length+ second.length]; + int k = 0; + int l = 0; + int m = 0; + while(k0 ; j--) { + System.out.print(" "); + } + for (int j = 0; j < i; j++) { + System.out.print(j+" "); + } + for (int j = i; j >=0 ; j--) { + if(j==0){ + System.out.print(j); + }else { + System.out.print(j + " "); + } + } + System.out.println(); + } + for (int i = n-1; i >=0; i--) { + for (int j = n; j >i ; j--) { + System.out.print(" "); + } + for (int j = 0; j <=i; j++) { + if(i == 0){ + System.out.print(j); + }else { + System.out.print(j + " "); + } + } + for (int j = i-1; j >=0 ; j--) { + if (j ==0){ + System.out.print(j); + }else { + System.out.print(j + " "); + } + } + System.out.println(); + } + } +} diff --git a/src/Codeforces/Problem1195B.java b/src/Codeforces/Problem1195B.java new file mode 100644 index 0000000..358dd31 --- /dev/null +++ b/src/Codeforces/Problem1195B.java @@ -0,0 +1,23 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1195B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + long n = sc.nextLong(); + long k = sc.nextLong(); + if (n == 1 && k == 1) { + System.out.println("0"); + } else { + long sum = 0; + for (int i = 1; i <= n; i++) { + sum = sum+i; + if(sum-(n-i)==k){ + System.out.println(n-i); + break; + } + } + } + } +} diff --git a/src/Codeforces/Problem124A.java b/src/Codeforces/Problem124A.java new file mode 100644 index 0000000..323da5a --- /dev/null +++ b/src/Codeforces/Problem124A.java @@ -0,0 +1,13 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem124A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int a = sc.nextInt(); + int b = sc.nextInt(); + System.out.println(Math.min(n-a, b+1)); + } +} diff --git a/src/Codeforces/Problem1381A1.java b/src/Codeforces/Problem1381A1.java new file mode 100644 index 0000000..ac41290 --- /dev/null +++ b/src/Codeforces/Problem1381A1.java @@ -0,0 +1,29 @@ +package Codeforces; + +import java.util.ArrayList; +import java.util.Scanner; + +public class Problem1381A1 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + String a = sc.next(); + String b = sc.next(); + ArrayList operations = new ArrayList<>(); + for (int i = 0; i < n; i++) { + if ((int)a.charAt(i) != (int)b.charAt(i)) { + if (i > 0) { + operations.add(i + 1); + } + operations.add(1); + if(i>0){ + operations.add(i + 1); + } + } + } + System.out.println(operations.toString()); + } + } +} diff --git a/src/Codeforces/Problem139A.java b/src/Codeforces/Problem139A.java new file mode 100644 index 0000000..1e6e674 --- /dev/null +++ b/src/Codeforces/Problem139A.java @@ -0,0 +1,28 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem139A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int pages = sc.nextInt(); + int read[] = new int[7]; + int index = -1; + int sum = 0; + for (int i = 0; i <= 6; i++) { + read[i] = sc.nextInt(); + } + int i = 0; + while (sum <= pages) { + sum = sum + read[i]; + if(sum>=pages){ + break; + } + i++; + if (i == 7) { + i = 0; + } + } + System.out.println(i + 1); + } +} diff --git a/src/Codeforces/Problem141A.java b/src/Codeforces/Problem141A.java new file mode 100644 index 0000000..d4f1052 --- /dev/null +++ b/src/Codeforces/Problem141A.java @@ -0,0 +1,41 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem141A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String name1 = sc.next(); + String name2 = sc.next(); + String permuted = sc.next(); + if (name1.length() + name2.length() == permuted.length()) { + char [] names = new char[26]; + char [] ans = new char[26]; + for (int i = 0; i < name1.length(); i++) { + names[name1.charAt(i)-65]++; + } + + for (int i = 0; i < name2.length(); i++) { + names[name2.charAt(i)-65]++; + } + + for (int i = 0; i < permuted.length(); i++) { + ans[permuted.charAt(i)-65]++; + } + boolean flag = false; + for (int i = 0; i < 26; i++) { + if(names[i] != ans[i]){ + flag =true; + break; + } + } + if(flag){ + System.out.println("NO"); + }else{ + System.out.println("YES"); + } + } else { + System.out.println("NO"); + } + } +} diff --git a/src/Codeforces/Problem1453A.java b/src/Codeforces/Problem1453A.java new file mode 100644 index 0000000..06fffbd --- /dev/null +++ b/src/Codeforces/Problem1453A.java @@ -0,0 +1,27 @@ +package Codeforces; + +import java.util.HashSet; +import java.util.Scanner; +import java.util.Set; + +public class Problem1453A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + int m = sc.nextInt(); + Set set = new HashSet<>(); + for (int i = 0; i < n; i++) { + set.add(sc.nextInt()); + } + int c = 0; + for (int j = 0; j < m; j++) { + if (set.contains(sc.nextInt())) { + c++; + } + } + System.out.println(c); + } + } +} diff --git a/src/Codeforces/Problem1453B.java b/src/Codeforces/Problem1453B.java new file mode 100644 index 0000000..e8ea877 --- /dev/null +++ b/src/Codeforces/Problem1453B.java @@ -0,0 +1,27 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1453B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + long a[] = new long[(int) n]; + for (int i = 0; i < n; i++) { + a[i] = sc.nextLong(); + } + long total = 0; + for (int i = 1; i < n; i++) { + total = total + Math.abs(a[i] - a[i - 1]); + } + long max = Math.max(a[1]-a[0],a[n-1]-a[n-2]); + for (int i = 1; i < n-1; i++) { + max = Math.max(max, Math.abs(a[i]-a[i-1])+Math.abs(a[i+1]-a[i])-Math.abs(a[i+1]-a[i-1])); + } + System.out.println(total-max); + + } + } +} diff --git a/src/Codeforces/Problem1462A.java b/src/Codeforces/Problem1462A.java new file mode 100644 index 0000000..0bc9c14 --- /dev/null +++ b/src/Codeforces/Problem1462A.java @@ -0,0 +1,29 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1462A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + long a[] = new long[n]; + for (int i = 0; i < n; i++) { + a[i] = sc.nextLong(); + } + String s = ""; + int start = 0; + int end = n - 1; + while (start < end) { + s = s + a[start] + " " + a[end] + " "; + start++; + end--; + } + if (n % 2 != 0) { + s = s + a[n / 2]; + } + System.out.println(s.trim()); + } + } +} diff --git a/src/Codeforces/Problem1462B.java b/src/Codeforces/Problem1462B.java new file mode 100644 index 0000000..8d47b80 --- /dev/null +++ b/src/Codeforces/Problem1462B.java @@ -0,0 +1,27 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1462B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + String s = sc.next(); + int c =0; + for (int i = 0; i <= 4; i++) { + if ((s.substring(0, i) + s.substring(n - 4 + i, n)) + .equalsIgnoreCase("2020")) { + c = 1; + } + } + if(c==1){ + System.out.println("YES"); + }else { + System.out.println("NO"); + } + + } + } +} diff --git a/src/Codeforces/Problem1462C.java b/src/Codeforces/Problem1462C.java new file mode 100644 index 0000000..01be15a --- /dev/null +++ b/src/Codeforces/Problem1462C.java @@ -0,0 +1,34 @@ +package Codeforces; + +import java.util.HashSet; +import java.util.Scanner; +import java.util.Set; + +public class Problem1462C { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + int[] digits = new int[]{9, 8, 7, 6, 5, 4, 3, 2, 1}; + while (t-- >= 1) { + String number = ""; + long sum = 0; + int i = 0; + int x = sc.nextInt(); + + while (sum < x && i < digits.length) { + number = number + Math.min(x - sum, digits[i]); + sum = sum + digits[i]; + i++; + } + + if (sum < x) { + System.out.println("-1"); + } else { + System.out.println(new StringBuilder(number).reverse().toString()); + } + + + } + } +} diff --git a/src/Codeforces/Problem1462D.java b/src/Codeforces/Problem1462D.java new file mode 100644 index 0000000..6646834 --- /dev/null +++ b/src/Codeforces/Problem1462D.java @@ -0,0 +1,19 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1462D { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + int a[] = new int[n]; + long sum = 0; + for (int i = 0; i < n; i++) { + a[i] = sc.nextInt(); + + } + } + } +} diff --git a/src/Codeforces/Problem1465A.java b/src/Codeforces/Problem1465A.java new file mode 100644 index 0000000..34f2dfe --- /dev/null +++ b/src/Codeforces/Problem1465A.java @@ -0,0 +1,26 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1465A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + String s = sc.next(); + int c=0, i; + for (i = n - 1; i >= 0; i--) { + if (s.charAt(i)>='a' && s.charAt(i)<='z'){ + break; + } + c++; + } + if(n-c= 1) { + String s = sc.next(); + int total = 0; + for (int i = 0; i < s.length() - 1; i++) { + if(i!=s.length()-1 && s.charAt(i)==s.charAt(i+1)){ + total++; + if(i!=s.length()-2 && s.charAt(i)==s.charAt(i+2)){ + total++; + i++; + } + i++; + }else if(i!= s.length()-1 && i!=s.length()-2 && s.charAt(i)==s.charAt(i+2)){ + total++; + if(i!=s.length()-3 && s.charAt(i+1)==s.charAt(i+3)) { + total++; + i++; + } + i=i+2; + } + + } + System.out.println(total); + } + } +} diff --git a/src/Codeforces/Problem1468B.java b/src/Codeforces/Problem1468B.java new file mode 100644 index 0000000..ef7a44a --- /dev/null +++ b/src/Codeforces/Problem1468B.java @@ -0,0 +1,22 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1468B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int a = sc.nextInt(); + int b = sc.nextInt(); + int c = sc.nextInt(); + int d = sc.nextInt(); + int ans = 0; + int ans1 = Math.min(a,b)*Math.min(c,d); + int ans2 = Math.min(a,c)*Math.min(b,d); + int ans3 = Math.min(a,d)*Math.min(b,c); + ans = Math.max(ans1, Math.max(ans2,ans3)); + System.out.println(ans); + } + } +} diff --git a/src/Codeforces/Problem1472B.java b/src/Codeforces/Problem1472B.java new file mode 100644 index 0000000..dc88337 --- /dev/null +++ b/src/Codeforces/Problem1472B.java @@ -0,0 +1,43 @@ +//package Codeforces; + +import java.util.Scanner; + +public class Problem1472B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + int arr[] = new int[n]; + int el = -1; + boolean same = false; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + if (el == -1) { + el = arr[i]; + continue; + } + } + long sum = 0; + long max = 0; + int j = 0; + for (int i = 0; i < n; i++) { + sum = 0; + sum = sum + arr[i]; + j = (int) (i + arr[i]); + while (j < n) { + sum = sum + arr[j]; + j = (int) (j + arr[j]); + } + max = Math.max(sum, max); + if(same){ + break; + } + } + System.out.println(max); + + } + } +} + + diff --git a/src/Codeforces/Problem1473B.java b/src/Codeforces/Problem1473B.java new file mode 100644 index 0000000..45c9e71 --- /dev/null +++ b/src/Codeforces/Problem1473B.java @@ -0,0 +1,46 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1473B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + String first = sc.next(); + String second = sc.next(); + if (first.length() < second.length()) { + String temp = first; + first = second; + second = temp; + } + int lcm = lcm(first.length(), second.length()); + int firstLcm = lcm/first.length(); + int secondLcm = lcm/second.length(); + String firstWith = "", secondWith = ""; + for (int i = 1; i <= firstLcm; i++) { + firstWith+= first; + } + for (int i = 1; i <= secondLcm; i++) { + secondWith+=second; + } + if(firstWith.equalsIgnoreCase(secondWith)){ + System.out.println(firstWith); + }else{ + System.out.println("-1"); + } + } + } + + private static int lcm(int a, int b) { + return (a * b) / gcd(a, b); + } + + private static int gcd(int a, int b) { + if (a == 0) { + return b; + } else { + return gcd(b % a, a); + } + } +} diff --git a/src/Codeforces/Problem148A.java b/src/Codeforces/Problem148A.java new file mode 100644 index 0000000..0572986 --- /dev/null +++ b/src/Codeforces/Problem148A.java @@ -0,0 +1,21 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem148A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int k = sc.nextInt(); + int l = sc.nextInt(); + int m = sc.nextInt(); + int n = sc.nextInt(); + int d = sc.nextInt(); + int c = 0; + for (int i = 1; i <= d; i++) { + if(i%k == 0 || i%l == 0 || i%m == 0 || i%n == 0){ + c++; + } + } + System.out.println(c); + } +} diff --git a/src/Codeforces/Problem149A.java b/src/Codeforces/Problem149A.java new file mode 100644 index 0000000..d0429d7 --- /dev/null +++ b/src/Codeforces/Problem149A.java @@ -0,0 +1,47 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem149A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int arr[] = new int[12]; + for (int i = 0; i < 12; i++) { + arr[i] = sc.nextInt(); + } + sort(arr); + int sum = 0; + int count =0 ; + if(n == 0){ + System.out.println(sum); + + }else { + for (int i = 0; i < 12; i++) { + sum = sum+arr[i]; + count++; + if(sum>=n){ + break; + } + } + if(sum < n){ + System.out.println("-1"); + }else { + System.out.println(count); + } + } + } + + //bubble sort + private static void sort(int arr[]) { + for (int i = 0; i < arr.length-1; i++) { + for (int j = 0; j < arr.length-i-1; j++) { + if(arr[j]= 1) { + int n = sc.nextInt(); + if (n == 1) { + System.out.println("1"); + } else if (n == 2) { + System.out.println("-1"); + } else { + int k = 1; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if(k>n*n){ + k = 2; + } + System.out.print(k+" "); + k = k+2; + } + System.out.println(); + } + } + } + } +} diff --git a/src/Codeforces/Problem1521A.java b/src/Codeforces/Problem1521A.java new file mode 100644 index 0000000..50e7b59 --- /dev/null +++ b/src/Codeforces/Problem1521A.java @@ -0,0 +1,23 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1521A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + while(n-->=1){ + long a= sc.nextLong(); + long b = sc.nextLong(); + long c = a*(b-1); + long d = (a*b); + long e = c+d; + if(e%(a*b) != 0) { + System.out.println("YES"); + System.out.println(c + " " + d+" " + e); + }else{ + System.out.println("NO"); + } + } + } +} diff --git a/src/Codeforces/Problem1537A.java b/src/Codeforces/Problem1537A.java new file mode 100644 index 0000000..6ee45d1 --- /dev/null +++ b/src/Codeforces/Problem1537A.java @@ -0,0 +1,26 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1537A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- >=1) { + int n = sc.nextInt(); + int arr[] = new int[n]; + long sum = 0; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + sum += arr[i]; + } + if(sum < n){ + System.out.println("1"); + }else if(sum == n){ + System.out.println("0"); + }else{ + System.out.println(Math.abs(sum-n)); + } + } + } +} diff --git a/src/Codeforces/Problem1537B.java b/src/Codeforces/Problem1537B.java new file mode 100644 index 0000000..8374e0f --- /dev/null +++ b/src/Codeforces/Problem1537B.java @@ -0,0 +1,17 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1537B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- >=1) { + int n = sc.nextInt(); + int m = sc.nextInt(); + int i = sc.nextInt(); + int j = sc.nextInt(); + System.out.println("1 1 " + n + " " + m); + } + } +} diff --git a/src/Codeforces/Problem1537C.java b/src/Codeforces/Problem1537C.java new file mode 100644 index 0000000..c6ec0fd --- /dev/null +++ b/src/Codeforces/Problem1537C.java @@ -0,0 +1,40 @@ +package Codeforces; + +import java.util.Arrays; +import java.util.Scanner; + +public class Problem1537C { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + long[] arr = new long[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextLong(); + } + Arrays.sort(arr); + if(n==2){ + System.out.println(arr[0]+" " + +arr[1]); + continue; + } + long min = Long.MAX_VALUE; + int pos = -1; + for (int i = 1; i < n; i++) { + if(arr[i]-arr[i-1]=1){ + long n = sc.nextLong(); + int count = 1; + long div = 0; + while(n>1 && n%2 == 0){ + div = n/2; + if(div>1 && div=1) { + int n = sc.nextInt(); + int max = Integer.MIN_VALUE; + int min = Integer.MAX_VALUE; + int maxindex = -1;int minIndex = -1; + int arr[] = new int[n]; + for(int i=0; imax){ + max = a; + maxindex = i; + } + if(a= 1) { + int n = sc.nextInt(); + long arr[] = new long[n]; + long l = sc.nextLong(); + long r = sc.nextLong(); + for (int i = 0; i < n; i++) { + long a = sc.nextLong(); + arr[i] = a; + } + Arrays.sort(arr); + long count = 0; + int low = 0; + int high = n - 1; + long sum = 0; + while (low < high) { + sum = arr[low]+arr[high]; + if(sum>=l && sum<=r){ + count++; + } + + if(sum>r){ + high--; + }else{ + low++; + } + + } + System.out.println(count); + } + } +} diff --git a/src/Codeforces/Problem1538b.java b/src/Codeforces/Problem1538b.java new file mode 100644 index 0000000..e9d1b49 --- /dev/null +++ b/src/Codeforces/Problem1538b.java @@ -0,0 +1,31 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1538b { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->=1){ + int n = sc.nextInt(); + int arr[] = new int[n]; + int avg = 0; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + avg = avg+arr[i]; + } + if(avg%n != 0){ + System.out.println("-1"); + }else{ + int ans = 0; + avg = avg/n; + for (int i = 0; i < n; i++) { + if(arr[i]>avg){ + ans++; + } + } + System.out.println(ans); + } + } + } +} diff --git a/src/Codeforces/Problem1539A.java b/src/Codeforces/Problem1539A.java new file mode 100644 index 0000000..39ebbbb --- /dev/null +++ b/src/Codeforces/Problem1539A.java @@ -0,0 +1,22 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1539A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int k = sc.nextInt(); + while (k-- >= 1) { + long n = sc.nextLong(); + long x = sc.nextLong(); + long t= sc.nextLong(); + long ans = Math.min(n-1,t/x); + if(ans == 0){ + System.out.println(ans); + }else{ + long ans1 = Math.max(0, ans*(ans-1)/2)+ ans*(n-ans); + System.out.println(ans1); + } + } + } +} diff --git a/src/Codeforces/Problem1539B.java b/src/Codeforces/Problem1539B.java new file mode 100644 index 0000000..e155f45 --- /dev/null +++ b/src/Codeforces/Problem1539B.java @@ -0,0 +1,23 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1539B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int q = sc.nextInt(); + String s = sc.next(); + while (q-- >= 1) { + int startIndex = sc.nextInt(); + int endIndex = sc.nextInt(); + String substring = s.substring(startIndex-1, endIndex); + int length = 0; + for (int i = 0; i < substring.length(); i++) { + char ch = substring.charAt(i); + length += ch-96; + } + System.out.println(length); + } + } +} diff --git a/src/Codeforces/Problem1541B.java b/src/Codeforces/Problem1541B.java new file mode 100644 index 0000000..54cd57c --- /dev/null +++ b/src/Codeforces/Problem1541B.java @@ -0,0 +1,28 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1541B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + long arr[] = new long[n + 1]; + for (int i = 1; i <= n; i++) { + arr[i] = sc.nextInt(); + } + int count = 0; + for (int i = 1; i <= n; i++) { + for (long j = arr[i] - i; j <= n; j += arr[i]) { + if (j >= 0 && i= 1) { + int n = sc.nextInt(); + int m = sc.nextInt(); + String arr[] = new String[n]; + String res[] = new String[n-1]; + for (int i = 0; i < n; i++) { + arr[i] = sc.next(); + } + for (int i = 0; i < n-1; i++) { + res[i] = sc.next(); + } + String ans = ""; + for (int i = 0; i < n; i++) { + char a = arr[i].charAt(m/2); + boolean find = false; + for (int j = 0; j < n-1; j++) { + char b = res[j].charAt(m/2); + if(a==b){ + find = true; + break; + } + } + if(!find) { + ans = arr[i]; + break; + } + } + System.out.println(ans); +// System.out.flush(); + } + } +} diff --git a/src/Codeforces/Problem1547B.java b/src/Codeforces/Problem1547B.java new file mode 100644 index 0000000..17aafdb --- /dev/null +++ b/src/Codeforces/Problem1547B.java @@ -0,0 +1,64 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1547B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int xa = sc.nextInt(); + int xy = sc.nextInt(); + int yx = sc.nextInt(); + int yy = sc.nextInt(); + int fx = sc.nextInt(); + int fy = sc.nextInt(); + int steps = 0; + if (xa == fx) { + steps = steps + 4; + steps = Math.abs(fy - xy) + Math.abs(yy - fy) + steps; + } else if (xy == fy) { + + } + System.out.println(steps); + + + + + +// String s = sc.next(); +// int index = s.indexOf("a"); +// if (index == -1) { +// System.out.println("NO"); +// } else { +// if (s.length() == 1 && s.charAt(0) == 'a') { +// System.out.println("YES"); +// } else { +// int b = 1; +// int startIndex = index - 1; +// int endIndex = index + 1; +// boolean loop = true; +// int count = 1; +// while (count= 0 && s.charAt(startIndex) == 'a' + b) { +// startIndex--; +// count++; +// } else if (endIndex < s.length() && s.charAt(endIndex) == 'a' + b) { +// endIndex++; +// count++; +// } else { +// loop = false; +// break; +// } +// b++; +// } +// if (!loop) { +// System.out.println("NO"); +// } else { +// System.out.println("YES"); +// } +// } +// } + } + } +} diff --git a/src/Codeforces/Problem1547C.java b/src/Codeforces/Problem1547C.java new file mode 100644 index 0000000..21468cb --- /dev/null +++ b/src/Codeforces/Problem1547C.java @@ -0,0 +1,59 @@ +package Codeforces; + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.Scanner; + +public class Problem1547C { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int k = sc.nextInt(); + int n = sc.nextInt(); + int m = sc.nextInt(); + int[] mono = new int[n]; + int[] poly = new int[m]; + for (int i = 0; i < n; i++) { + mono[i] = sc.nextInt(); + } + for (int i = 0; i < m; i++) { + poly[i] = sc.nextInt(); + } + int[] arr = new int[n + m]; + boolean loop = true; + int i = 0; + int j = 0; + int index =0; + while (i < n || j < m) { + if (i < n && mono[i] == 0) { + k++; + arr[index] = mono[i]; + i++;index++; + } else if (i < n && k >= mono[i]) { + arr[index] = mono[i]; + i++;index++; + } else if (j < m && poly[j] == 0) { + k++; + arr[index] = poly[j]; + j++;index++; + } else if (j < m && k >= poly[j]) { + arr[index] = poly[j]; + j++;index++; + } else { + loop = false; + break; + } + + } + if (!loop) { + System.out.println("-1"); + } else { + for (int l = 0; l < arr.length; l++) { + System.out.print(arr[l]+" "); + } + System.out.println(); + } + } + } +} diff --git a/src/Codeforces/Problem1549A.java b/src/Codeforces/Problem1549A.java new file mode 100644 index 0000000..efb938a --- /dev/null +++ b/src/Codeforces/Problem1549A.java @@ -0,0 +1,15 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1549A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->=1){ + long n = sc.nextLong(); + long rem = n%2; + System.out.println("2"+" "+(n-rem)); + } + } +} diff --git a/src/Codeforces/Problem1553C.java b/src/Codeforces/Problem1553C.java new file mode 100644 index 0000000..db1056e --- /dev/null +++ b/src/Codeforces/Problem1553C.java @@ -0,0 +1,69 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1553C { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + String s = sc.next(); + int a = 0; + int b = 0; + int ans = 9; + int remA = 0; + int remB = 0; + + //match for a + for (int i = 0; i < 10; i++) { + if (i % 2 == 0) { + remB++; + //odd places + if (s.charAt(i) == '1') { + b++; + } + } else { + remA++; + if (s.charAt(i) == '1' || s.charAt(i) == '?') { + a++; + } + } + if (a > (b + (5 - remB))) { + ans = Math.min(ans, i); + } + if (b > (a + (5 - remA))) { + ans = Math.min(ans, i); + } + } + + a = 0; + b= 0; + remA = 0; + remB = 0; + //match for b + //match for a + for (int i = 0; i < 10; i++) { + if (i % 2 == 0) { + remB++; + //odd places + if (s.charAt(i) == '1' || s.charAt(i) == '?') { + b++; + } + } else { + remA++; + if (s.charAt(i) == '1') { + a++; + } + } + if (a > (b + (5 - remB))) { + ans = Math.min(ans, i); + } + if (b > (a + (5 - remA))) { + ans = Math.min(ans, i); + } + } + System.out.println(ans + 1); + + } + } +} diff --git a/src/Codeforces/Problem1554A.java b/src/Codeforces/Problem1554A.java new file mode 100644 index 0000000..4ac7c0e --- /dev/null +++ b/src/Codeforces/Problem1554A.java @@ -0,0 +1,22 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1554A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->=1) { + int n = sc.nextInt(); + long arr[] = new long[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextLong(); + } + long max = 0; + for (int i = 1; i < n; i++) { + max = Math.max(max, arr[i]*arr[i-1]); + } + System.out.println(max); + } + } +} diff --git a/src/Codeforces/Problem1554B.java b/src/Codeforces/Problem1554B.java new file mode 100644 index 0000000..3744f24 --- /dev/null +++ b/src/Codeforces/Problem1554B.java @@ -0,0 +1,27 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1554B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + int k = sc.nextInt(); + long arr[] = new long[n + 1]; + for (int i = 1; i <= n; i++) { + arr[i] = sc.nextLong(); + } + long min = Long.MIN_VALUE, ans; + int minI = Math.max(1, n - 500); + for (int i = minI; i <= n; i++) { + for (int j = i+1; j <=n ; j++) { + ans = (((long) i * j) - (k * (arr[i] | arr[j]))); + min = Math.max(min, ans); + } + } + System.out.println(min); + } + } +} diff --git a/src/Codeforces/Problem1557B.java b/src/Codeforces/Problem1557B.java new file mode 100644 index 0000000..c368fe8 --- /dev/null +++ b/src/Codeforces/Problem1557B.java @@ -0,0 +1,38 @@ +package Codeforces; + + +import java.util.*; + +public class Problem1557B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + int k = sc.nextInt(); + int arr[] = new int[n]; + Map map = new TreeMap<>(); + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + map.put(arr[i], i); + } + int c = 0; + Iterator i = map.values().iterator(); + while(i.hasNext()){ + arr[c] = (int) i.next(); + c++; + } + c = 1; + for (int j = 1; j < n; j++) { + if(arr[j-1]+1 != arr[j]){ + c++; + } + } + if(c<=k){ + System.out.println("Yes"); + }else{ + System.out.println("No"); + } + } + } +} diff --git a/src/Codeforces/Problem1559C.java b/src/Codeforces/Problem1559C.java new file mode 100644 index 0000000..69cd457 --- /dev/null +++ b/src/Codeforces/Problem1559C.java @@ -0,0 +1,47 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1559C { + private static Scanner sc = new Scanner(System.in); + + public static void main(String[] args) { + int t = sc.nextInt(); + while (t-- >= 1) { + solve(); + System.out.println(); + } + } + + private static void solve() { + int n = sc.nextInt(); + int arr[] = new int[n + 2]; + for (int i = 1; i <= n; i++) { + arr[i] = sc.nextInt(); + } + if (arr[1] == 1) { + System.out.print(n + 1 + " "); + for (int i = 1; i <= n; i++) { + System.out.print(i + " "); + } + return; + } + for (int i = 1; i < n; i++) { + if (arr[i] == 0 && arr[i + 1] == 1) { + for (int k = 1; k <= i; k++) { + System.out.print(k + " "); + } + System.out.print(n + 1 + " "); + for (int k = i + 1; k <= n; k++) { + System.out.print(k + " "); + } + return; + } + } + + for (int i = 1; i <= n; i++) { + System.out.print(i + " "); + } + System.out.print(n + 1); + } +} diff --git a/src/Codeforces/Problem155A.java b/src/Codeforces/Problem155A.java new file mode 100644 index 0000000..4194034 --- /dev/null +++ b/src/Codeforces/Problem155A.java @@ -0,0 +1,27 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem155A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int arr[] = new int[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + } + int min = arr[0]; + int max = arr[0]; + int amazing = 0; + for (int i = 1; i < n; i++) { + if(arr[i]>max){ + amazing++; + max = arr[i]; + }else if(arr[i]= 1) { + int n= sc.nextInt(); + System.out.println(arr[n-1]); + } + } + + private static void perform(int arr[]) { + int index = 0; + int count = 1; + while (index < 1000) { + if (count % 3 != 0 && count%10 !=3) { + arr[index] = count; + index++; + } + count++; + } + } +} diff --git a/src/Codeforces/Problem1560B.java b/src/Codeforces/Problem1560B.java new file mode 100644 index 0000000..f55ce1f --- /dev/null +++ b/src/Codeforces/Problem1560B.java @@ -0,0 +1,38 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1560B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + long a = sc.nextLong(); + long b = sc.nextLong(); + long c = sc.nextLong(); + if (a > b) { + long te = a; + a = b; + b = te; + } + long diff = b - a; + if (diff == 1) { + System.out.println("-1"); + } else { + long totalElements = ((diff - 1) * 2) + 2; + if(c>totalElements || b>totalElements ){ + System.out.println("-1"); + }else{ + if(c+diff<=totalElements) { + System.out.println(c + diff); + }else if(c-diff>=0){ + System.out.println(c-diff); + }else{ + System.out.println("-1"); + } + } + } + + } + } +} diff --git a/src/Codeforces/Problem1560C.java b/src/Codeforces/Problem1560C.java new file mode 100644 index 0000000..88997ad --- /dev/null +++ b/src/Codeforces/Problem1560C.java @@ -0,0 +1,46 @@ +package Codeforces; + +import java.util.ArrayList; +import java.util.Scanner; + +public class Problem1560C { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + long no = sc.nextLong(); + if ((no & no - 1) == 0) { + System.out.println("0"); + } else { + ArrayList list = new ArrayList<>(); + for (int i = 0; i <= 60; i++) { + list.add((long)Math.pow(2,i)+""); + } + String no1 = no + ""; + int ans = Integer.MAX_VALUE; + for (int i = 0; i <= 60; i++) { + String no2 = list.get(i); + int j = 0; + int k = 0; + int res = 0; + while (j < no1.length() && k < no2.length()) { + if (no1.charAt(j) == no2.charAt(k)) { + j++; + k++; + } else { + j++; + res++; + } + } + if (j == no1.length() && k != no2.length()) { + res = res + (no2.length() - k); + } else if (j != no1.length() && k == no2.length()) { + res = res + (no1.length() - j); + } + ans = Math.min(ans, res); + } + System.out.println(ans); + } + } + } +} diff --git a/src/Codeforces/Problem1562A.java b/src/Codeforces/Problem1562A.java new file mode 100644 index 0000000..a75291e --- /dev/null +++ b/src/Codeforces/Problem1562A.java @@ -0,0 +1,28 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1562A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + long l = sc.nextLong(); + long r = sc.nextLong(); + long ans = Integer.MIN_VALUE; + l = Math.max(l,r/2); + while (l < r) { + ans = Math.max(ans, r % l); + if(r%l set = generateNonPrime(prime); + int t = sc.nextInt(); + while (t-- >= 1) { + int k = sc.nextInt(); + String s = sc.next(); + for (int j = 0; j < set.size(); j++) { + String no = set.get(j)+""; + int count = 0; + int index =0; + for (int i = 0; i < s.length(); i++) { + if(s.charAt(i) == no.charAt(index)){ + count++; + index++; + } + if(count == no.length()){ + break; + } + } + if(count == no.length()){ + System.out.println(count); + System.out.println(no); + break; + } + } + + } + } + + private static ArrayList generateNonPrime(boolean[] prime) { + ArrayList set = new ArrayList<>(); + set.add(1); + for (int i = 2; i < 1000000; i++) { + if (!prime[i]) { + set.add(i); + } + } + return set; + } + + private static boolean[] generatePrime() { + boolean a[] = new boolean[1000000]; + for (int i = 0; i < a.length; i++) { + a[i] = true; + } + + for (int p = 2; p * p < a.length; p++) { + if (a[p]) { + for (int i = p * p; i < a.length; i += p) { + a[i] = false; + } + } + } + + return a; + } +} diff --git a/src/Codeforces/Problem1566A.java b/src/Codeforces/Problem1566A.java new file mode 100644 index 0000000..6ff084e --- /dev/null +++ b/src/Codeforces/Problem1566A.java @@ -0,0 +1,24 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1566A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + long n = sc.nextLong(); + long s = sc.nextLong(); + double n1 = n; + double medianIndex = Math.ceil(n1 / 2); + if (n == 1) { + System.out.println(s); + } else { + long index = (n - (medianIndex - 1)) > 0 ? (long) (n - (medianIndex - 1)) : n; + long maxValue = (long) ((s) / (index)); + System.out.println( maxValue); + } + + } + } +} diff --git a/src/Codeforces/Problem1566B.java b/src/Codeforces/Problem1566B.java new file mode 100644 index 0000000..fd8a384 --- /dev/null +++ b/src/Codeforces/Problem1566B.java @@ -0,0 +1,30 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1566B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + String s = sc.next(); + long sum = 0; + int c = -1; + for (int i = 0; i < s.length(); i++) { + if(c!= -1 && s.charAt(i)-48 == c){ + continue; + }else{ + c = s.charAt(i)-48; + if(c==0){ + sum = sum+1; + } + } + + } + if(sum>2){ + sum = 2; + } + System.out.println(sum); + } + } +} diff --git a/src/Codeforces/Problem1566C.java b/src/Codeforces/Problem1566C.java new file mode 100644 index 0000000..6ca0235 --- /dev/null +++ b/src/Codeforces/Problem1566C.java @@ -0,0 +1,53 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1566C { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + String s = sc.next(); + String s1 = sc.next(); + int arr[][] = new int[2][n]; + for (int i = 0; i < 2; i++) { + for (int j = 0; j < n; j++) { + if (i == 1) { + arr[i][j] = s1.charAt(j) - 48; + } else { + arr[i][j] = s.charAt(j) - 48; + } + } + } + long max = 0; + for (int i = 0; i < 1; i++) { + for (int j = 0; j < n; ) { + if ((arr[0][j] == 1 && arr[1][j] == 0)|| (arr[0][j] == 0 && arr[1][j] == 1)) { + max = max + 2; + j++; + } else if (j + 1 < n && arr[0][j] == 1 && arr[0][j + 1] == 0) { + max = max + 2; + j = j + 2; + } + else if (j + 1 < n && arr[0][j] == 0 && arr[0][j + 1] == 1) { + if(arr[1][j+1] == 1) { + max = max + 2; + j = j + 2; + }else{ + max = max+1; + j++; + } + } + else if (arr[0][j] == 0 && arr[1][j] == 0) { + max = max + 1; + j++; + } else { + j++; + } + } + } + System.out.println(max); + } + } +} diff --git a/src/Codeforces/Problem1566D1.java b/src/Codeforces/Problem1566D1.java new file mode 100644 index 0000000..823e2a2 --- /dev/null +++ b/src/Codeforces/Problem1566D1.java @@ -0,0 +1,30 @@ +package Codeforces; + +import java.util.ArrayList; +import java.util.Scanner; + +public class Problem1566D1 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + int m = sc.nextInt(); + int arr[] = new int[n * m]; + for (int i = 0; i < n * m; i++) { + arr[i] = sc.nextInt(); + } + int con = 0; + ArrayList arrayList = new ArrayList<>(); + for (int i = 0; i < n * m; i++) { + for (int j = 0; j < arrayList.size(); j++) { + if (arr[i] > arrayList.get(j)) { + con++; + } + } + arrayList.add(arr[i]); + } + System.out.println(con); + } + } +} diff --git a/src/Codeforces/Problem1567A.java b/src/Codeforces/Problem1567A.java new file mode 100644 index 0000000..95a10ab --- /dev/null +++ b/src/Codeforces/Problem1567A.java @@ -0,0 +1,25 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1567A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int l = sc.nextInt(); + String s = sc.next(); + String ns = ""; + for (int i = 0; i < s.length(); i++) { + if(s.charAt(i)=='D'){ + ns = ns+'U'; + }else if(s.charAt(i) == 'U'){ + ns = ns+'D'; + }else{ + ns = ns+s.charAt(i); + } + } + System.out.println(ns); + } + } +} diff --git a/src/Codeforces/Problem1567B.java b/src/Codeforces/Problem1567B.java new file mode 100644 index 0000000..b05e1b3 --- /dev/null +++ b/src/Codeforces/Problem1567B.java @@ -0,0 +1,32 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1567B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int a = sc.nextInt(); + int b = sc.nextInt(); + int xor = 0; + int length = a; + for (int i = 1; i < a; i++) { + xor = xor ^ i; + } + System.out.println(xor); + if (xor != b) { + if (a == 1 && b == 1) { + length = length + 2; + } else { + if(xor == 1 && b!=0){ + length = length+2; + }else{ + length = length+1; + } + } + } + System.out.println(length); + } + } +} diff --git a/src/Codeforces/Problem1567C.java b/src/Codeforces/Problem1567C.java new file mode 100644 index 0000000..c71d18f --- /dev/null +++ b/src/Codeforces/Problem1567C.java @@ -0,0 +1,29 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1567C { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->=1) { + int n = sc.nextInt(); + int i = 1; + int a = 0, b = 0; + int c1 = 1, c2 = 1; + while (n > 0) { + int r = n % 10; + if (i % 2 == 0) { + a = c1 * r + a; + c1 = c1 * 10; + } else { + b = c2 * r + b; + c2 = c2 * 10; + } + i++; + n = n / 10; + } + System.out.println(((a+1)*(b+1))-2); + } + } +} diff --git a/src/Codeforces/Problem1569A.java b/src/Codeforces/Problem1569A.java new file mode 100644 index 0000000..7779634 --- /dev/null +++ b/src/Codeforces/Problem1569A.java @@ -0,0 +1,42 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1569A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + String s = sc.next(); + int i = 0; + int j = 0; + if (n == 1) { + i = -1; + j = -1; + } else { + char ch = s.charAt(i); + i = 0; + boolean find = false; + for (int k = 1; k < n; k++) { + if(ch != s.charAt(k)){ + j = k; + find = true; + break; + }else{ + i++; + } + } + i++; + j++; + if(!find){ + i = -1; + j = -1; + } + } + System.out.println(i+" "+j); + } + } + + +} diff --git a/src/Codeforces/Problem1569B.java b/src/Codeforces/Problem1569B.java new file mode 100644 index 0000000..a58d58d --- /dev/null +++ b/src/Codeforces/Problem1569B.java @@ -0,0 +1,60 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1569B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + int arr[] = new int[n]; + String s = sc.next(); + int ones = 0, twos = 0; + for (int i = 0; i < s.length(); i++) { + arr[i] = s.charAt(i)-48; + if (arr[i] == 1) { + ones++; + } else { + twos++; + } + } + if (twos == 2 || twos == 1) { + System.out.println("NO"); + continue; + } + System.out.println("YES"); + // 1 = zero loses, 2 = one win + char game[][] = new char[n][n]; + for (int i = 0; i < n; i++) { + int x = 1; + for (int j = i; j < n; j++) { + if (i == j) { + game[i][j] = 'X'; + continue; + } + if (arr[i] == 1) { + game[i][j] = '='; + game[j][i] = '='; + } else { + if (x == 1 && arr[j] == 2) { + game[i][j] = '+'; + game[j][i] = '-'; + x = 2; + }else{ + game[i][j] = '-'; + game[j][i] = '+'; + } + } + } + } + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + System.out.print(game[i][j]); + } + System.out.println(); + } + } + } +} diff --git a/src/Codeforces/Problem1574A.java b/src/Codeforces/Problem1574A.java new file mode 100644 index 0000000..e8ec30f --- /dev/null +++ b/src/Codeforces/Problem1574A.java @@ -0,0 +1,37 @@ +package Codeforces; + +import java.util.Scanner; +import java.util.Stack; + +public class Problem1574A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + Stack s = new Stack(); + generateParenthesis(n, 0,0, "",s); + for (int i = 0; i < n; i++) { + System.out.println(s.get(i)); + } + } + } + + static void generateParenthesis(int n, int open, int close, String s, Stack ans){ + if(ans.size()>n){ + return; + } + if(open==n && close==n){ + ans.push(s); + return; + } + + if(open= 1) { + String s = sc.next(); + int a = 0, b = 0, c = 0; + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == 'A') { + a++; + } else if (s.charAt(i) == 'B') { + b++; + } else { + c++; + } + } + if (a > b) { + a = a - b; + b = 0; + } else { + b = b - a; + a = 0; + } + if (b > c) { + b = b - c; + c = c - c; + } else { + c = c - b; + b = 0; + } + if(a == 0 && b== 0 && c == 0){ + System.out.println("YES"); + }else{ + System.out.println("NO"); + } + } + } +} diff --git a/src/Codeforces/Problem1579B.java b/src/Codeforces/Problem1579B.java new file mode 100644 index 0000000..acb7521 --- /dev/null +++ b/src/Codeforces/Problem1579B.java @@ -0,0 +1,4 @@ +package Codeforces; + +public class Problem1579B { +} diff --git a/src/Codeforces/Problem1579D.java b/src/Codeforces/Problem1579D.java new file mode 100644 index 0000000..0434e3a --- /dev/null +++ b/src/Codeforces/Problem1579D.java @@ -0,0 +1,53 @@ +package Codeforces; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; + +public class Problem1579D { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + int n = sc.nextInt(); + ArrayList ans = new ArrayList<>(); + ArrayList integers = new ArrayList<>(); + for (int i = 0; i < n; i++) { + long a = sc.nextLong(); + integers.add(a); + } + int start = 0; + int end = integers.size() - 1; + while (start < end ) { + if(integers.get(start) == 0){ + start++; + continue; + }else if(integers.get(end) == 0){ + end--; + continue; + } + long i1 = integers.get(start); + long i2 = integers.get(end); + boolean endIndex = true; + if (i1 < i2) { + endIndex = false; + long temp = i1; + i1 = i2; + i2 = temp; + } + for (int i = 0; i < i2; i++) { + ans.add((start + 1) + " " + (end + 1)); + } + integers.set(start, integers.get(start) - i2); + integers.set(end, integers.get(end) - i2); + if (endIndex) { + end--; + } else { + start++; + } + } + System.out.println(ans.size()); + System.out.println(Arrays.toString(ans.toArray())); + } + } +} diff --git a/src/Codeforces/Problem160B.java b/src/Codeforces/Problem160B.java new file mode 100644 index 0000000..ffdea36 --- /dev/null +++ b/src/Codeforces/Problem160B.java @@ -0,0 +1,49 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem160B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + String s = sc.next(); + String first = s.substring(0,n); + String second = s.substring(n); + String reverse = new StringBuilder(second).reverse().toString(); + //for first and second comparison + boolean ans = findAns(first, second, n); + boolean ansReverse = findAns(first, reverse, n); + if(ans || ansReverse){ + System.out.println("YES"); + }else{ + System.out.println("NO"); + } + } + + private static boolean findAns(String first, String second, int n) { + boolean ans = false; + int firstElement = first.charAt(0)-48; + int secondElement = second.charAt(0)-48; + boolean greater = firstElement>secondElement; + for (int i = 1; i < n; i++) { + firstElement = first.charAt(i)-48; + secondElement = second.charAt(i)-48; + if(greater){ + if(firstElement<=secondElement){ + ans = false; + break; + }else{ + ans = true; + } + }else{ + if(firstElement>=secondElement){ + ans = false; + break; + }else{ + ans = true; + } + } + } + return ans; + } +} diff --git a/src/Codeforces/Problem165A.java b/src/Codeforces/Problem165A.java new file mode 100644 index 0000000..63c1108 --- /dev/null +++ b/src/Codeforces/Problem165A.java @@ -0,0 +1,44 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem165A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int xy[][] = new int[n][3]; + for (int i = 0; i < n; i++) { + int x = sc.nextInt(); + int y = sc.nextInt(); + xy[i][0] = x; + xy[i][1] = y; + } + int count = 0; + for (int i = 0; i < n; i++) { + int l=0,r=0,d=0,u = 0; + for (int j = 0; j < n; j++) { + if(i == j){ + continue; + } + if(xy[j][0] == xy[i][0] && xy[j][1]>xy[i][1]){ + //y above + u++; + }else if(xy[j][0] == xy[i][0] && xy[j][1]xy[i][0]) { + //x above + r++; + }else if(xy[j][1] == xy[i][1] && xy[j][0]0 && l>0 && r>0 && d>0){ + count++; + } + } + System.out.println(count); + + } +} diff --git a/src/Codeforces/Problem166A.java b/src/Codeforces/Problem166A.java new file mode 100644 index 0000000..d6d4417 --- /dev/null +++ b/src/Codeforces/Problem166A.java @@ -0,0 +1,33 @@ +package Codeforces; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Scanner; + +public class Problem166A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int k = sc.nextInt(); + int arr[] = new int[n]; + HashMap map = new HashMap<>(); + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + int value = sc.nextInt(); + if (map.containsKey(arr[i])) { + map.put(arr[i], map.get(arr[i]) + 1); + } else { + map.put(arr[i], 1); + } + } + Arrays.sort(arr); + int count = 0; + for (int i = n - 1; i >= 0; i--) { + count++; + if(count == k){ + System.out.println(map.get(arr[i])); + break; + } + } + } +} diff --git a/src/Codeforces/Problem189A.java b/src/Codeforces/Problem189A.java new file mode 100644 index 0000000..dee078b --- /dev/null +++ b/src/Codeforces/Problem189A.java @@ -0,0 +1,36 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem189A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int a = sc.nextInt(); + int b = sc.nextInt(); + int c = sc.nextInt(); + int max = 0; + if (n % a == 0) { + max = Math.max(max, n / a); + } + if (n % b == 0) { + max = Math.max(max, n / b); + } + if (n % c == 0) { + max = Math.max(max, n / c); + } + if ((n/a) + (n/b) == n) { + max = Math.max(max, 2); + } + if (a + c == n) { + max = Math.max(max, 2); + } + if (a + b + c == n) { + max = Math.max(max, 2); + } + if (b + c == n) { + max = Math.max(max, 2); + } + System.out.println(max); + } +} diff --git a/src/Codeforces/Problem199A.java b/src/Codeforces/Problem199A.java new file mode 100644 index 0000000..664b43b --- /dev/null +++ b/src/Codeforces/Problem199A.java @@ -0,0 +1,11 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem199A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + System.out.println("0 0 "+n); + } +} diff --git a/src/Codeforces/Problem1B.java b/src/Codeforces/Problem1B.java new file mode 100644 index 0000000..150300e --- /dev/null +++ b/src/Codeforces/Problem1B.java @@ -0,0 +1,62 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem1B { + private static char character[] = new char[]{'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'}; + private static String az = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + while (n-- >= 1) { + String s = sc.next(); + if (s.charAt(0) == 'R' && Character.isDigit(s.charAt(1))) { + //R23C55 + convertToCYRX(s); + } else { + //BC23 + convertToRXCY(s); + } + } + } + + private static void convertToRXCY(String s) { + int indexOfDigit = 0; + for (int i = 0; i < s.length(); i++) { + if (Character.isDigit(s.charAt(i))) { + indexOfDigit = i; + break; + } + } + String columnNumber = s.substring(0, indexOfDigit); + String rowNumber = s.substring(indexOfDigit); + int pow = 0; + long val = 0; + for (int i = columnNumber.length() - 1; i >= 0; i--) { + val = (long) (val + (Math.pow(26, pow) * ((int) az.indexOf(columnNumber.charAt(i)) + 1))); + pow++; + } + System.out.println("R" + rowNumber + "C" + val); + } + + private static void convertToCYRX(String s) { + String rowNumber = s.substring(1, s.indexOf('C')); + long colNumber = Long.parseLong(s.substring(s.indexOf('C') + 1)); + String finalString = ""; + while (colNumber != 0) { + if (colNumber % 26 == 0) { + finalString = "Z" + finalString; + colNumber = colNumber / 26; + colNumber--; + } else { + finalString = character[(int)colNumber % 26 - 1] + finalString; + colNumber = colNumber / 26; + } + + } + finalString = finalString + rowNumber; + System.out.println(finalString); + } +} diff --git a/src/Codeforces/Problem205A.java b/src/Codeforces/Problem205A.java new file mode 100644 index 0000000..8645435 --- /dev/null +++ b/src/Codeforces/Problem205A.java @@ -0,0 +1,73 @@ +package Codeforces; + +import java.util.*; + +public class Problem205A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long arr[] = new long[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextLong(); + } + long sorted[] = arr; + long sort[] = sort(sorted, 0, n-1); + boolean containDuplicate = false; + for (int i = 1; i =0) { + n1 = n1-arr[index]; + min = min+((arr[index]*(arr[index]+1))/2); + arr[index] = 0; + index++; + }else{ + n1--; + min = min+arr[index]; + arr[index]--; + } + } + n1 = n; + index = m-1; + while(n1 != 0) { + + } + System.out.println(min); + + } +} diff --git a/src/Codeforces/Problem219A.java b/src/Codeforces/Problem219A.java new file mode 100644 index 0000000..136ac1f --- /dev/null +++ b/src/Codeforces/Problem219A.java @@ -0,0 +1,33 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem219A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int k = sc.nextInt(); + String str = sc.next(); + char [] ch = new char[26]; + for (int i = 0; i < str.length(); i++) { + ch[str.charAt(i)-'a']++; + } + boolean possible = true; + for (int i = 0; i < 26; i++) { + if(ch[i] != 0 && ch[i]%k != 0){ + possible = false; + break; + } + } + if(!possible){ + System.out.println("-1"); + }else{ + for (int i = 0; i < k; i++) { + for (int j = 0; j < 26; j++) { + if(ch[j]!=0) { + System.out.print((char)(j+'a')); + } + } + } + } + } +} diff --git a/src/Codeforces/Problem224A.java b/src/Codeforces/Problem224A.java new file mode 100644 index 0000000..ab8eebf --- /dev/null +++ b/src/Codeforces/Problem224A.java @@ -0,0 +1,16 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem224A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int s1 = sc.nextInt(); + int s2 = sc.nextInt(); + int s3 = sc.nextInt(); + int a = (int) Math.sqrt((s1*s3)/s2); + int b = (int) Math.sqrt((s1*s2)/s3); + int c = (int) Math.sqrt((s2*s3)/s1); + System.out.println(4*(a+b+c)); + } +} diff --git a/src/Codeforces/Problem227B.java b/src/Codeforces/Problem227B.java new file mode 100644 index 0000000..f91692d --- /dev/null +++ b/src/Codeforces/Problem227B.java @@ -0,0 +1,36 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem227B { + + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int a; + int pos[] = new int[n+1]; + for (int i = 0; i < n; i++) { + a = sc.nextInt(); + pos[a] = i + 1; + } + int m = sc.nextInt(); + long vasya = 0, petya = 0; + while (m-- >= 1) { + int query = sc.nextInt(); + vasya += pos[query]; + petya += n - pos[query] + 1; + } + System.out.println(vasya+" "+petya); + } + + private static int search(int arr[], int n) { + for (int i = 0; i < arr.length; i++) { + if (arr[i] == n) { + return i; + } + } + return 0; + } + +} diff --git a/src/Codeforces/Problem230A.java b/src/Codeforces/Problem230A.java new file mode 100644 index 0000000..9a1a646 --- /dev/null +++ b/src/Codeforces/Problem230A.java @@ -0,0 +1,17 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem230A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int s = sc.nextInt(); + int n = sc.nextInt(); + int arr[][] = new int[n][2]; + for (int i = 0; i < n; i++) { + arr[i][0] = sc.nextInt(); + arr[i][1] = sc.nextInt(); + } + boolean pass = true; + } +} diff --git a/src/Codeforces/Problem236B.java b/src/Codeforces/Problem236B.java new file mode 100644 index 0000000..820ba55 --- /dev/null +++ b/src/Codeforces/Problem236B.java @@ -0,0 +1,45 @@ +package Codeforces; + +import java.util.HashMap; +import java.util.Scanner; + +public class Problem236B { + private static HashMap map = new HashMap(); + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + int c = sc.nextInt(); + int sum = 0; + for (int i = 1; i <= a; i++) { + for (int j = 1; j <= b; j++) { + for (int k = 1; k <= c; k++) { + sum = sum+count(i*j*k); + } + } + } + System.out.println(sum%1073741824); + } + + private static int count(int j){ + int count =0; + if(map.containsKey(j)){ + return map.get(j); + } + for (int i = 1; i <= Math.sqrt(j); i++) + { + if (j % i == 0) { + // If divisors are equal, + // count only one + if (j / i == i) + count++; + + else // Otherwise count both + count = count + 2; + } + } + map.put(j, count); + return count; + } + +} diff --git a/src/Codeforces/Problem237A.java b/src/Codeforces/Problem237A.java new file mode 100644 index 0000000..0784444 --- /dev/null +++ b/src/Codeforces/Problem237A.java @@ -0,0 +1,28 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem237A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int lastHr = -1; + int lastMin = -1; + int count = 1; + int maxCount = 1; + for (int i = 0; i < n; i++) { + int hour = sc.nextInt(); + int min = sc.nextInt(); + if(hour == lastHr && min == lastMin){ + count++; + maxCount = Math.max(maxCount, count); + } + else{ + count = 1; + } + lastHr = hour; + lastMin = min; + } + System.out.println(maxCount); + } +} diff --git a/src/Codeforces/Problem239A.java b/src/Codeforces/Problem239A.java new file mode 100644 index 0000000..fdc3a91 --- /dev/null +++ b/src/Codeforces/Problem239A.java @@ -0,0 +1,35 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem239A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + long y = sc.nextLong(); + long k = sc.nextLong(); + long n = sc.nextLong(); + boolean printed= false; + if(y >= n){ + System.out.println("-1"); + }else{ + double divi = y/k; + int lowerbound = (int) Math.ceil(divi); + int upperBound = (int) (n/k); + if(lowerbound>upperBound){ + System.out.println("-1"); + } + for(int i=lowerbound; i<=upperBound;i++){ + long x = (i*k)-y; + if(x>=1 && x+y<=n){ + System.out.print(x+" "); + printed = true; + }else if(x+y>n){ + break; + } + } + if(!printed){ + System.out.println("-1"); + } + } + } +} diff --git a/src/Codeforces/Problem242B.java b/src/Codeforces/Problem242B.java new file mode 100644 index 0000000..d5cd3c1 --- /dev/null +++ b/src/Codeforces/Problem242B.java @@ -0,0 +1,33 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem242B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long min = Long.MAX_VALUE; + long max = -1; + int index = -1; + long arr[][] = new long[n][2]; + for (int i = 0; i < n; i++) { + long a = sc.nextLong(); + long b = sc.nextLong(); + arr[i][0] = a; + arr[i][1] = b; + if(amax){ + max = b; + } + } + for (int i = 0; i < n; i++) { + if(arr[i][0]==min && arr[i][1] == max){ + index = i+1; + break; + } + } + System.out.println(index); + } +} diff --git a/src/Codeforces/Problem248A.java b/src/Codeforces/Problem248A.java new file mode 100644 index 0000000..19b80c8 --- /dev/null +++ b/src/Codeforces/Problem248A.java @@ -0,0 +1,40 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem248A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[][] leftRight = new int[n][2]; + for (int i = 0; i < n; i++) { + for (int j = 0; j < 2; j++) { + leftRight[i][j] = sc.nextInt(); + } + } + + //left count + int c1 = 0,c0=0, t=0; + for (int i = 0; i < n; i++) { + if(leftRight[i][0] == 0){ + c0++; + }else{ + c1++; + } + + } + t = t+Math.min(c0,c1); + c1 = 0;c0=0; + for (int i = 0; i < n; i++) { + if(leftRight[i][1] == 0){ + c0++; + }else{ + c1++; + } + } + t = t+Math.min(c0,c1); + + System.out.println(t); + + } +} diff --git a/src/Codeforces/Problem253A.java b/src/Codeforces/Problem253A.java new file mode 100644 index 0000000..7c7d969 --- /dev/null +++ b/src/Codeforces/Problem253A.java @@ -0,0 +1,24 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem253A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); //boys + int m = sc.nextInt(); //girls + while(m-->=1 && n-->=1){ + if(m>n) { + System.out.print("GB"); + }else{ + System.out.print("BG"); + } + } + while(m-->=1){ + System.out.print("G"); + } + while(n-->=1){ + System.out.print("B"); + } + } +} diff --git a/src/Codeforces/Problem272A.java b/src/Codeforces/Problem272A.java new file mode 100644 index 0000000..f7f7d8e --- /dev/null +++ b/src/Codeforces/Problem272A.java @@ -0,0 +1,21 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem272A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int sum = 0; + int ways = 0; + for (int i = 0; i < n; i++) { + sum = sum+sc.nextInt(); + } + for (int i = 1; i <= 5; i++) { + if((sum+i)%(n+1) != 1){ + ways++; + } + } + System.out.println(ways); + } +} diff --git a/src/Codeforces/Problem298B.java b/src/Codeforces/Problem298B.java new file mode 100644 index 0000000..62b98d8 --- /dev/null +++ b/src/Codeforces/Problem298B.java @@ -0,0 +1,61 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem298B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + long sx = sc.nextLong(); + long sy = sc.nextLong(); + long ex = sc.nextLong(); + long ey = sc.nextLong(); + String s = sc.next(); + int index = -1; + for (int i = 0; i < s.length(); i++) { + char ch =s.charAt(i); + switch (ch){ + case 'S':{ + if(sy>ey){ + sy = sy-1; + } + break; + } + case 'E': { + if(sxex){ + sx = sx-1; + } + break; + } + + case 'N': { + if(sy= countB) { + System.out.println("YES"); + } else { + System.out.println("NO"); + } + } +} diff --git a/src/Codeforces/Problem320A.java b/src/Codeforces/Problem320A.java new file mode 100644 index 0000000..c3b0fcf --- /dev/null +++ b/src/Codeforces/Problem320A.java @@ -0,0 +1,28 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem320A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String s = sc.next(); + boolean yes = true; + for (int i = 0; i < s.length();) { + if(i+2 < s.length() && s.charAt(i) == '1' && s.charAt(i+1) == '4' && s.charAt(i+2)=='4') { + i = i+3; + }else if(i+1 < s.length() && s.charAt(i) == '1' && s.charAt(i+1) == '4'){ + i = i+2; + }else if(s.charAt(i) == '1'){ + i = i+1; + }else{ + yes = false; + break; + } + } + if(yes) { + System.out.println("YES"); + }else{ + System.out.println("NO"); + } + } +} diff --git a/src/Codeforces/Problem327B.java b/src/Codeforces/Problem327B.java new file mode 100644 index 0000000..6f0a3da --- /dev/null +++ b/src/Codeforces/Problem327B.java @@ -0,0 +1,36 @@ +package Codeforces; + +import java.util.Arrays; +import java.util.Scanner; + +public class Problem327B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int count = 0; + boolean[] prime = new boolean[100001]; + findPrime(prime); + for (int i = 2; i < prime.length; i++) { + if (count >= n) { + break; + } + if (prime[i]) { + System.out.print(i + " "); + count++; + } + } + + } + + private static boolean[] findPrime(boolean[] prime) { + Arrays.fill(prime, true); + for (int i = 2; i * i < prime.length; i++) { + if (prime[i]) { + for (int j = i * i; j < prime.length; j = j + i) { + prime[j] = false; + } + } + } + return prime; + } +} diff --git a/src/Codeforces/Problem32B.java b/src/Codeforces/Problem32B.java new file mode 100644 index 0000000..ad12cbc --- /dev/null +++ b/src/Codeforces/Problem32B.java @@ -0,0 +1,32 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem32B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String s = sc.next(); + System.out.println(parse(s)); + } + + public static String parse(String s) { + char one = '.'; + char two = '-'; + String ans = ""; + for (int i = 0; i < s.length(); ) { + if(i<=s.length()-2 && s.charAt(i) == two && s.charAt(i+1) == two){ + ans = ans+"2"; + i = i+2; + }else if(i<=s.length()-2 && s.charAt(i) == two && s.charAt(i+1) == one){ + ans = ans+"1"; + i = i+2; + }else if(s.charAt(i) == one){ + ans = ans+"0"; + i++; + }else{ + i++; + } + } + return ans; + } +} diff --git a/src/Codeforces/Problem339B.java b/src/Codeforces/Problem339B.java new file mode 100644 index 0000000..a00568e --- /dev/null +++ b/src/Codeforces/Problem339B.java @@ -0,0 +1,22 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem339B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int m = sc.nextInt(); + int arr[] = new int[m]; + for (int i = 0; i < m; i++) { + arr[i] = sc.nextInt(); + } + int initialHouse = 1; + long count = 0; + for (int i = 0; i < m; i++) { + count = count+((arr[i]-initialHouse)+n)%n; + initialHouse = arr[i]; + } + System.out.println(count); + } +} diff --git a/src/Codeforces/Problem349A.java b/src/Codeforces/Problem349A.java new file mode 100644 index 0000000..ebb222d --- /dev/null +++ b/src/Codeforces/Problem349A.java @@ -0,0 +1,47 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem349A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int arr[] = new int[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + } + int count25 = 0; + int count50 = 0; + boolean pass = true; + for (int i = 0; i < n; i++) { + if (arr[i] == 25) { + count25++; + } else if (arr[i] == 50) { + if (count25 >= 1) { + count25--; + count50++; + } else { + pass = false; + break; + } + } else { + //if arrr[i] = 100 + //give 25 50 + if (count25 >= 1 && count50 >= 1) { + count25--; + count50--; + } else if (count25 >= 3) { + count25 = count25 - 3; + } else { + pass = false; + break; + } + } + } + if (pass) { + System.out.println("YES"); + } else { + System.out.println("NO"); + } + } +} diff --git a/src/Codeforces/Problem34A.java b/src/Codeforces/Problem34A.java new file mode 100644 index 0000000..e52e061 --- /dev/null +++ b/src/Codeforces/Problem34A.java @@ -0,0 +1,29 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem34A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int arr[] = new int[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + } + int min = Integer.MAX_VALUE; + int minIndex = -1; + int minIndex2 = -1; + for (int i = 1; i < n; i++) { + if (Math.abs(arr[i]-arr[i-1])> map = new TreeMap<>(); + for (int i = 0; i < n; i++) { + if(!map.containsKey(ar[i])){ + Set set = new HashSet<>(); + set.add(i); + map.put(ar[i], set); + }else{ + map.get(ar[i]).add(i); + } + } + TreeMap ans = new TreeMap<>(); + map.forEach((integer, integers) -> { + if(integers.size() == 1){ + ans.put(integer, 0); + }else{ + int diff = -1; + boolean breakLoop = false; + Integer [] arr = integers.toArray(new Integer[]{}); + for (int i = 1; i < arr.length; i++) { + if(diff == -1){ + diff = arr[i]-arr[i-1]; + }else{ + if(arr[i]-arr[i-1] != diff){ + breakLoop = true; + break; + } + } + } + if(!breakLoop){ + ans.put(integer, diff); + } + } + }); + System.out.println(ans.size()); + ans.forEach((integer, integer1 )-> { + System.out.println(integer+" "+integer1); + }); + } + } +} diff --git a/src/Codeforces/Problem353A.java b/src/Codeforces/Problem353A.java new file mode 100644 index 0000000..c385f8d --- /dev/null +++ b/src/Codeforces/Problem353A.java @@ -0,0 +1,51 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem353A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int sumA = 0; + int sumB = 0; + int a, b; + int arr[][] = new int[n][2]; + for (int i = 0; i < n; i++) { + a = sc.nextInt(); + b = sc.nextInt(); + arr[i][0] = a; + arr[i][1] = b; + sumA+=a; + sumB+=b; + } + + if(sumA%2 ==0 && sumB%2==0){ + System.out.println("0"); + }else if(n == 1){ + System.out.println("0"); + }else { + //sumB is odd, find the odd element in A + int count = 0; + for (int i = 0; i < n; i++) { + if (arr[i][0] == 1 || arr[i][0] == 3 || arr[i][0] == 5) { + sumA = sumA - arr[i][0]; + sumB = sumB - arr[i][1]; + sumA = sumA + arr[i][1]; + sumB = sumB + arr[i][0]; + count++; + if (sumA % 2 == 0 && sumB % 2 == 0) { + break; + } + } + } + if (count == 0) { + System.out.println("-1"); + } else { + System.out.println(count); + } + + } + + + } +} diff --git a/src/Codeforces/Problem433A.java b/src/Codeforces/Problem433A.java new file mode 100644 index 0000000..b63fa47 --- /dev/null +++ b/src/Codeforces/Problem433A.java @@ -0,0 +1,40 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem433A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int hundred = 0; + int two = 0;int a; + while(n-->=1){ + a = sc.nextInt(); + if(a == 100){ + hundred++; + }else{ + two++; + } + } + // + if(hundred%2 == 0 && two % 2 ==0){ + System.out.println("YES"); + }else { + //odd odd + if(hundred%2!=0 && two%2 !=0) { + System.out.println("NO"); + }else if(hundred%2 != 0) { + //100 odd 200even + System.out.println("NO"); + }else { + //100 even 200 odd + if(hundred!=0 && two!=0 &&Math.abs(hundred-two)%2==1){ + System.out.println("YES"); + }else{ + System.out.println("NO"); + } + } + + } + } +} diff --git a/src/Codeforces/Problem433B.java b/src/Codeforces/Problem433B.java new file mode 100644 index 0000000..774b864 --- /dev/null +++ b/src/Codeforces/Problem433B.java @@ -0,0 +1,82 @@ +package Codeforces; + +import java.util.Arrays; +import java.util.Scanner; + +public class Problem433B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long arr[] = new long[n+1]; + long z[] = new long[n+1]; + long sortedarry[] = new long[n+1]; + for (int i = 1; i <= n; i++) { + arr[i] = sc.nextLong(); + z[i] = arr[i]; + sortedarry[i] = arr[i]; + + } + sortedarry = sort(sortedarry, 0,n); + for (int i = 1; i <=n; i++) { + z[i] += z[i-1]; + sortedarry[i]+=sortedarry[i-1]; + } + int m = sc.nextInt(); + int ques,l,r; + while(m-->=1) { + ques = sc.nextInt(); + l = sc.nextInt(); + r = sc.nextInt(); + switch (ques) { + case 1: { + System.out.println(z[r]-z[l-1]); + break; + } + case 2: { + System.out.println(sortedarry[r]-sortedarry[l-1]); + break; + } + } + } + } + + private static long[] sort(long arr[], int si, int ei) { + if (si == ei) { + return new long[]{arr[si]}; + } + int mid = (si + ei) / 2; + long[] first = sort(arr, si, mid); + long[] second = sort(arr, mid + 1, ei); + return merge(first, second); + } + + private static long[] merge(long[] first, long[] second) { + long merged[] = new long[first.length+ second.length]; + int k = 0; + int l = 0; + int m = 0; + while(k= 1) { + input = sc.next(); + if (first == null) { + first = input; + a++; + } else if (input.equals(first)) { + a++; + } else if (second == null) { + second = input; + b++; + } else if (second.equals(input)) { + b++; + } + } + System.out.println((a > b) ? first : second); + } +} diff --git a/src/Codeforces/Problem450A.java b/src/Codeforces/Problem450A.java new file mode 100644 index 0000000..413b386 --- /dev/null +++ b/src/Codeforces/Problem450A.java @@ -0,0 +1,24 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem450A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int m = sc.nextInt(); + int arr[] = new int[n]; + int max = -1; + int maxIndex = 0; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + int ceil = (int) Math.ceil(arr[i] / m); + if (ceil >= max) { + max = ceil; + maxIndex = i; + } + } + System.out.println(maxIndex + 1); + + } +} diff --git a/src/Codeforces/Problem459B.java b/src/Codeforces/Problem459B.java new file mode 100644 index 0000000..8f77801 --- /dev/null +++ b/src/Codeforces/Problem459B.java @@ -0,0 +1,35 @@ +package Codeforces; + +import java.util.Arrays; +import java.util.Scanner; + +public class Problem459B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long arr[] = new long[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextLong(); + } + Arrays.sort(arr); + long min = arr[0]; + long max = arr[n-1]; + long count = 0; + long countMax = 0; + long countMin = 0; + if(min == max) { + count = (long) n *(n-1); + count = count/2; + }else{ + for (int i = 0; i < n; i++) { + if(arr[i]==max){ + countMax++; + }else if(arr[i] == min){ + countMin++; + } + } + count = countMax*countMin; + } + System.out.println(max-min+" "+count); + } +} diff --git a/src/Codeforces/Problem466A.java b/src/Codeforces/Problem466A.java new file mode 100644 index 0000000..d567c35 --- /dev/null +++ b/src/Codeforces/Problem466A.java @@ -0,0 +1,20 @@ +package Codeforces; + +import java.util.Scanner; + +public class Problem466A { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + float m = sc.nextInt(); + int a = sc.nextInt(); + int b = sc.nextInt(); + float aRides = n*a; + double bRide=Math.ceil(b/m); + float bRides = (float) (n*bRide); + float ans = Math.min(aRides, bRides); + int aa = (int) Math.ceil(ans); + System.out.println(aa); + + } +} diff --git a/src/Codeforces/Problem492B.java b/src/Codeforces/Problem492B.java new file mode 100644 index 0000000..43d11aa --- /dev/null +++ b/src/Codeforces/Problem492B.java @@ -0,0 +1,23 @@ +package Codeforces; + +import java.util.Arrays; +import java.util.Scanner; + +public class Problem492B { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long l = sc.nextLong(); + long arr[] = new long[n]; + for (int i = 0; i < n; i++) { + arr[i] = sc.nextLong(); + } + Arrays.sort(arr); + double mmaxDiff = 2*Math.max(arr[0],arr[n-1]-l); + for (int i = 1; i < n; i++) { + mmaxDiff = Math.max(mmaxDiff, arr[i]-arr[i-1]); + } + System.out.println(mmaxDiff/2); + } + +} diff --git a/src/Codeforces/Sample.java b/src/Codeforces/Sample.java new file mode 100644 index 0000000..8634dbb --- /dev/null +++ b/src/Codeforces/Sample.java @@ -0,0 +1,27 @@ +package Codeforces; + +import java.util.Scanner; + + +public class Sample { + + + static long gcd(long a, long b) { + if (b == 0) { + return a; + } + return gcd(b, a % b); + } + + private static void solve() { + + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- >= 1) { + solve(); + } + } +} diff --git a/src/Notes/GCD.md b/src/Notes/GCD.md new file mode 100644 index 0000000..61880c9 --- /dev/null +++ b/src/Notes/GCD.md @@ -0,0 +1,38 @@ +# GCD OF A Number / HCF +If we subtract smaller number from the greater number, the GCD +of the number doesn't change. Hence this is the concept of the +basic euclidean algorithm +```` +static int gcd(int a, int b) + { + // Everything divides 0 + if (a == 0) + return b; + if (b == 0) + return a; + + // base case + if (a == b) + return a; + + // a is greater + if (a > b) + return gcd(a-b, b); + return gcd(a, b-a); + } +```` + +##Extended Euclidean Algorithm +Now instead of subtraction, we find the mod of the number and stop +when the number/remainder becomes 0. + +``` Euclidiean Algorithm +//Euclidiean algorithm + static long gcd(long a, long b){ + + if(b == 0){ + return a; + } + return gcd(b, a%b); + } +``` \ No newline at end of file diff --git a/src/Notes/SieveofEratosthenes.md b/src/Notes/SieveofEratosthenes.md new file mode 100644 index 0000000..10716c4 --- /dev/null +++ b/src/Notes/SieveofEratosthenes.md @@ -0,0 +1,24 @@ +##Sieve of Eratoshenes +Complexity: O(NloglogN) + +The basic idea is to mark the numbers as composite which are multiple or factors +of some other numbers. + +``` +private static boolean[] generatePrime() { + boolean a[] = new boolean[1000000]; + for (int i = 0; i < a.length; i++) { + a[i] = true; + } + + for (int p = 2; p * p < a.length; p++) { + if (a[p]) { + for (int i = p * p; i < a.length; i+=p) { + a[i] = false; + } + } + } + + return a; + } +``` \ No newline at end of file