teleren/devto huggingface dataset:
Python Input/Output for Competitive Programming
Tags: python, codenewbie, beginners, programming
Published: 2023-04-26 03:53:29

Python has become one of the most popular languages to use for algorithmic problem solving and competitive programming. Despite having some downsides due to its slower speed, its popularity is increasing due to the simplicity of python syntax and easier learning curve. 

In this post, we will learn how to take input and print output for various competitive programming problems. 

<!--
We will choose a codeforces problem. Then we will analyze the problem statement step by step to write python code. That code will be used to take input.

---

## Before We Begin

It's important to note that the simplest way to take input in python is to use the `input()` function.

```python
n = input()
```
But 2 important things to keep in mind:

1. The `input()` function will take everything as a string. So if we are taking integers, then we need to convert the input to integers.
2. The `input()` function will take 1 line of input each time it is called. If the line contains multiple variables, `5 2 3 5` then it will be taken as a single string `"5 2 3 5"`. We can not receive these integers one by one.
-->
---

## Example - 01


Problem Link: [1352C. K-th Not Divisible by n](https://codeforces.com/problemset/problem/1352/C)


![image of Codeforces 1352C. K-th Not Divisible by n](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vsqmdc101wy5b9ogzbd.png)


<!--- 
Let's write code to input **t**.

```python
t = input()
```

But as we know that `input()` takes everything as a string, we need to convert the input to an integer. We can use the `int()` function to do that.

```python
t = int(input())
```

Then there will be t lines of input. Each line will have 2 integers, **n** and **k**. 

Well, in this case we can run a loop t times. And in each turn, we can take 2 integers.

```python
t = int(input())
for i in range(t):
    n, k = map(int, input().split())
```

-->


The problem statement says that the first line will contain one integer `t`. Then there will be `t` lines. Each line will have 2 integers, `n` and `k`.

We can at first take `t` as input, then run a loop. In each turn of the loop, we can take `n` and `k`.

The output is a single number for each `n` and `k`. We can use the `print()` function to print the output.

Here is the code:

```python
t = int(input())

for i in range(t):
    
    n, k = map(int, input().split())
    
    # Solve the problem here
    
    # Write output here
    print(solution)
```

This is the complete solution to the problem:

```python
import math

t = int(input())

for i in range(t):
    
    n, k = map(int, input().split())
    
    solution = k + math.floor((k-1)/(n-1))
    
    print(solution)
```

---

## Example - 02


Problem Link: [1352C. K-th Not Divisible by n](https://codeforces.com/problemset/problem/1352/C)


![image of Codeforces 1352C. K-th Not Divisible by n](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vsqmdc101wy5b9ogzbd.png)
WP-CLI Example Guide
Tags: wordpress, wpcli, cli, wp
Published: 2023-04-26 03:52:47

## What is wp-cli?

* WP-CLI is the command line interface for WordPress.
* It is an extensible tool for installing and maintaining WordPress.
* Everything you can do from a browser, can also be done using the wp-cli.

---

In this guide we will learn some useful commands and create scripts to automate some common tasks.

---

## Here are some of the most useful commands:

* `wp plugin update --all` Update all plugins that can be updated.
* `wp db export` Export the database an an SQL dump.
* `wp checksum core` Verifies the integrity of the WordPress core and makes sure that the core files have not been tampered with.
* `wp plugin install user-switching --activate` Install and activate a wordpress plugin.
* `wp transient delete --all` Delete transient data.

---

Let's automate some common tasks using wp-cli:

---

## User Create/Update/Delete/Generate:

1. Create an `editor` named `bob` with the email `bob@example.com` and password `b0bp@s52@0#2$3`

`wp user create bob bob@example.com --role=editor --user_pass=b0bp@s52@0#2$3`

2. Generate 100 subscribers

`wp user generate --count=100 --role=subscriber`
How to check the status of an Angular Reactive Form’s Control
Tags: angular
Published: 2023-04-26 03:51:37

Sometimes, you may have a requirement to do something when the status of an Angular form control changes.  For example, you have a Login Form, and when the status of the Email control changes from valid to invalid and vice versa, you need to perform some actions. In this post, let us see how we can achieve that. 
 
We have a login form, 

```
fb = inject(FormBuilder);
loginForm: FormGroup;

  constructor() {

    this.loginForm = this.fb.group({
      email: [null, [Validators.required]],
      password: [null, [Validators.required]],
    })

 }

```
On the template, map the loginForm to the HTML Form element and FormControls to the input elements. 

```
<form (ngSubmit)="login()" [formGroup]="loginForm" novalidate>
<input type="text" formControlName="email" placeholder="Enter email" />
<br/>
<input type="password" formControlName="password" placeholder="Enter Password"/>
<br/>
<br/>
<button>Login</button>
</form>
```

Now whenever the status of the email field changes, you need to take some action.  For that, Angular AbstractControlDirective provides a getter of an observable type called statusChanges().


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6wal9pihz54mzicn2izk.png)

You can subscribe to the statusChanges() observable to work with the control’s status change. 

```
checkControlStatus(){
    const email = this.loginForm.get('email'); 
    email?.statusChanges.subscribe((status:any)=>{
       console.log(status);
    })
  }
```
And further, call the above function In the ngOnInit() life cycle hook. 

```
ngOnInit(): void {
    this.checkControlStatus();
  }

```
You can check the status for valid or invalid and apply conditional css or log to the API etc. I hope you find this post helpful. Thanks for reading.
3 Free Tools to Start a Local Database Instance on Mac
Tags: database, macos, tooling, todayilearned
Published: 2023-04-26 03:35:02

[Bytebase](https://www.bytebase.com/) is a Database CI/CD tool for DevOps teams. It currently supports 10+ databases including MySQL, PostgreSQL, Redis, and MariaDB. From development to testing, we need to deploy several different kinds of database instances, which can be rather time-consuming and labor-intensive if deployed one by one.

There are a handful of tools on the market to spin up local database instances quickly, and folks on my team have recommended several free tools, so I thought I'd do a round-up.

Some background info: I'm not a dev (am a developer-marketer, I would test/try out new features before they are rolled out) and I use a Mac.

## DBngin

[DBngin](https://dbngin.com/) currently supports PostgreSQL, MySQL and Redis. And it supports certain different versions of the same database, and can also run multiple versions of database instances on multiple ports at the same time, very convenient for testing!

![dbngin-ui](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/25jmwms5dv1385woapc8.png)

DBngin is [open source](https://github.com/TablePlus/DBngin), and they belong to the organization TablePlus (a database GUI tool), which means DBngin can be connected to TablePlus, and you can visually manage your local databases.

## Postgres.app

[Postgres.app](https://postgresapp.com/), as the name (and logo) implies, only supports Postgres.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kppgk6f7mhlfw0op8atc.png)


It's actually a complete PostgreSQL installer that packages Postgres into a standard Mac app, and it's perfectly fine if you don't know how to use the command line, because there's a super simple UI. So if you want to run PostgreSQL on your Mac, this is the one.

Postgres.app is also [open source](https://github.com/PostgresApp/PostgresApp) with active development.

## StackBricks

[StackBricks](https://stackbricks.app/) supports MariaDB (points for being the only tool in this round-up that supports MariaDB!), MySQL, PostgreSQL and Redis, and a wide range of their versions, as well as the ability to start multiple local databases on multiple ports.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wsoiebe9myi3fguooblh.png)


StackBricks is not open source (but still free to use), but there is an [Issue Tracker](https://github.com/tpetry/stackbricks-community) for your feature requests.

## My Thoughts

For me, as long as the tool suffices for testing purposes, I don't really have high requirements for performance, I would say a simple and easy-to-use UI & multiple database support are the differentiators. In fact, I have been using DBngin, but I tried StackBricks for the sake of writing this post, and it looks like StackBricks is quite good, so I'm gonna try it out for a while.

How do you spin up local database instances for testing?
My Portfolio
Tags: webdev, javascript, programming, tutorial
Published: 2023-04-26 02:56:54


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpcr8u1anjcl57mac70i.png)
**Home Page**

_Must vist once_

Link:- https://protfoliopuneet.netlify.app
Devloper - Puneet Kumar
age - 12
email - pk.mishra10102010@gmail.com


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxwoiu2b57022qyqx0qg.png)
**My skills**

I have created my new portfolio. 
I have shown my skills here if you want any idea then you can take form here and if u have any question then feel free to ask in comments
Purpose and function of a forEach Loop
Published: 2023-04-26 02:42:02

If you are new to coding then the idea of writing your own code may seem like a daunting task, especially if you aren't aware of all the awesome and powerful tools that are available to you. In your program or workplace environment you will often hear the term, "iterate through the array". If you have experience in coding then you know exactly what I mean when I say this, but for those of you just beginning your coding journey this may sound a little scary. I'm here to tell you that it isn’t nearly as difficult as it may sound.

First off, there are more than one way to iterate through an array, but today we will be focusing on the forEach() loop and when and why we would want to iterate through an array. Let's start with 'When', when do we want to iterate through an array? The reason why we would want to iterate through an array is because we would want to modify the elements or perform any of a number of actions on them, but as you know, arrays can hold an unlimited amount of data. Without a forEach() we would be stuck with needing to call each object by its index

For example, here is our array:
const movieGenres = ['action', 'comedy', 'romcom', 'horror', 'drama'}

and if we console log each index it would look like:
console.log(movieGenres[0])
//: action

console.log(movieGenres[1])
//: comedy

console.log(movieGenres[2])
//: romcom

and so on...

Luckily our array only contains five elements, but in cases when we are dealing with much larger arrays, it would be to our benefit to utilize the forEach() loop.

This brings us to our 'why'. Why do we want to iterate through an array. Essentially the main reason why we prefer using a forEach() is because it saves us a lot of time when we want to access each element in the array and perform a specific action on each one at once.

Our example array:
let movieGenres = ['action', 'comedy', 'romcom', 'horror', 'drama'}

now to iterate through the array we incorporate the forEach() into our function:
movieGenres.forEach(function(movieGenre) {
    console.log(movieGenre);
});

and the console would show the following:
action
comedy
romcom
horror
drama

As demonstrated above, the forEach() loop is one of a programmers strongest weapons as it allows them to work through their code quicker but it makes it look cleaner as well.
How to save user game data in Unity
Published: 2023-04-26 02:13:14

If you want to implement an energy system or record the player's highest score and always show it to him or so on, you need to save the player's information on player device.
here we can use PlayerPrefs.
in term of description : PlayerPrefs is a class that stores Player preferences between game sessions. It can store string, float and integer values into the user’s platform registry.
****warn**:Unity stores PlayerPrefs in a local registry, without encryption. Do not use PlayerPrefs data to store sensitive data.**
Here I put some codes to access this feature:
Unity-C# :
 

```
PlayerPrefs.SetInt(string key , int value);//To store numerical data in the player's device with a special label
PlayerPrefs.GetInt(string key , default value);//To get numerical information from the player's device.
```
#unity
#C_Sharp
Apache AGE Setup for Contributing
Tags: apacheage, postgres, beginners
Published: 2023-04-26 01:53:58

## **Introduction**
In this article, I will be discussing how to create a setup for contributing to the Apache AGE code. You must have a github account and PostgreSQL installed on your machine.

## **Tutorial**
The first step to setup AGE is to fork the Apache AGE repository on [Github](https://github.com/apache/age).

![Fork button at Apache AGE repository on Github](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/103xvhet3yq2sy58qnjh.png)

Then, clone the forked repository to your local machine using Git. You can run the following command in your terminal replacing `USER` with your Github user:
`git clone https://github.com/USER/apache-age.git`

Add the path/to/postgres/include directory to your IDE environment's include path. This will ensure that the compiler recognizes dependencies such as `postgres.h`.

Finally, you can begin making modifications to the code such as fixing issues and improving the performance of functions. After making the necessary changes, navigate to the folder where you cloned your forked repository and run the following commands:
`make clean`
`make PG_CONFIG=/path/to/postgres/bin/pg_config install`

For more details access [How to Contribute](https://age.apache.org/contribution/how/) and the [Contribution Guide](https://age.apache.org/contribution/guide/)
Apache AGE repository: https://github.com/apache/age
Apache AGE website: https://age.apache.org
7 Steps to master Blockchain as a DevOps Engineer
Tags: blockchain, devops, devjournal, beginners
Published: 2023-04-26 01:53:00

I got my first DevOps engineering job in a DeFi space. To be effective I had to learn Blockchain technology.  

Here are 7 steps I followed to master it within 3 months:

## 1. Start by learning the basics: 
Blockchain is a complex and evolving technology, and it is important to start by learning the basics, such as what blockchain is, how it works, and what it is used for. This will provide a foundation for learning more advanced concepts.


## 2. Understand the key concepts & technologies: 
Blockchain relies on a number of key concepts & technologies, such as distributed ledgers, consensus algorithms & cryptography. It is important to understand them for understanding how blockchain works and what it is used for.


## 3. Explore different blockchain platforms & networks: 
There are various blockchain platforms & networks, such as Bitcoin, Ethereum & Hyperledger. Each platform has its own features, capabilities & limitations & it is important to learn them to use blockchain effectively.


## 4. Hands-on experience with blockchain: 
It is one of the best ways to learn about blockchain. This can involve building and deploying blockchain applications, experimenting with different blockchain platforms, and working on real-world projects.


## 5. Learn about the integration of blockchain with other technologies: 
As a DevOps Engineer, you will need to understand how to integrate blockchain with other technologies, cloud platforms, databases & applications. It requires knowledge of different APIs, protocols & tools.


## 6. Understand the challenges and limitations of blockchain:
 Blockchain is not a silver bullet and it is important to understand the challenges and limitations of the technology. This will help you to determine when and how to use blockchain effectively & avoid common pitfalls.


## 7. Join a community or network of blockchain enthusiasts: 
Blockchain is a rapidly evolving field and it can be helpful to join a community or network of blockchain enthusiasts in order to stay up-to-date on the latest developments and to learn from others.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qdj2qfll35yi6ryj4po7.png)


Overall, mastering blockchain as a DevOps engineer will require you to get your hands dirty. 

I hope these steps can help you gain the knowledge & skills needed to effectively use blockchain in your work.

Thanks for reading this.

If you have an idea and want to build your product around it, schedule a call with [me](https://calendly.com/pragyanatvade).

If you want to learn more about DevOps and Backend space, [follow me](https://dev.to/pragyanatvade).

If you want to connect, reach out to me on [Twitter](https://twitter.com/pragyanatvade) and [LinkedIn](https://www.linkedin.com/in/pragyanatvade/).
System KPI-aided Diagnosis
Published: 2023-04-26 01:38:50

## Availability
This feature is available since openGauss 1.0.0.

## Introduction
KPIs are views of key performance indicators for kernel components or the entire system. Based on KPIs, users can learn about the real-time and historical running status of the system.

## Benefits
Summarized system load diagnosis

Precise alarms for system load exceptions (overload, stall, and SLA exceptions) and precise system load profile

Summarized system time model diagnosis

Instance-level and query-level time model segmentation, diagnosing the root causes of instance and query performance problems

Query performance diagnosis

Database-level query summary, including top SQL, SQL CPU usage, I/O consumption, execution plan, and excessive hard parsing

Diagnosis of disk I/O, index, and buffer performance problems

Diagnosis of connection and thread pool problems

Diagnosis of checkpoint and redo (RTO) performance problems

Diagnosis of system I/O, LWLock, and wait performance problems

Diagnosis of over 60 modules and over 240 key operation performance problems

Function-level performance monitoring and diagnosis (by GSTRACE)

Tracing of over 50 functions at the storage and execution layers

## Description
openGauss provides KPIs of 11 categories and 26 sub-categories, covering instances, files, objects, workload, communication, sessions, threads, cache I/O, locks, wait events, and clusters.

Figure 1 shows the distribution of kernel KPIs.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpewkqxfot0npila4atj.png)




## Enhancements
None.

## Constraints
Utility statements do not support normalization. Non-DML statements, such as CREATE, DROP, COPY, and VACUUM, are not supported.
Currently, only the top-level normalized SQL statements are recorded. SQL statements in a stored procedure are not normalized, and only the SQL statements that call the stored procedure are recorded.
Dependencies
None.
Gray Upgrade
Published: 2023-04-26 01:36:54

## Availability
This feature is available since openGauss 2.0.0.

## Introduction
Gray upgrade supports full-service operations. All nodes can be upgraded at a time.

## Benefits
Gray upgrade provides an online upgrade mode to ensure that all nodes are upgraded without interrupting services.

## Description
Gray upgrade is an online upgrade mode that upgrades all nodes. If only the binary files of the database need to be replaced during the gray upgrade, to minimize the impact on services, the two sets of binary files exist on the same node at the same time, and the soft connection switchover mode is used to switch the process version (one intermittent disconnection within 10 seconds).

## Enhancements
None.

## Constraints
For details about the gray upgrade constraints, see Before You Start.

Dependencies
None.
Two-City Three-DC DR
Published: 2023-04-26 01:26:32

## Availability
This feature is available since openGauss 3.1.0.

## Introduction
openGauss 3.1.0 supports two-city three-DC DR.

## Benefits
The services require the underlying database to provide cross-region DR capabilities to ensure data security and availability in case of extreme disasters.

## Description
Finance and banking industries require high data security. In the case of extreme disasters such as fires, earthquakes, and wars, data security must be ensured. Therefore, a cross-region DR solution is required. Cross-region DR refers to the scenario where the distance between the primary and standby data centers is greater than 200 km. When the primary data center encounters an extreme disaster, the standby data center can take over services. This feature provides a cross-region openGauss DR solution.

This feature provides the following solutions:

Streaming replication-based remote DR solution (This solution is provided in openGauss 3.1.0 and later versions.)

## Enhancements
In openGauss 3.1.0, the remote DR solution based on streaming replication is added for the two-city 3DC cross-region DR feature.

DR database failover
Planned switchover between the primary and standby database instances
Streaming replication-based remote DR solution:

For details about the constraints, see section “Two-City Three-DC DR” in Administrator Guide.

## Dependencies
None
Using a Standby Node to Build a Standby Node
Published: 2023-04-26 01:18:59

## Availability
This feature is available since openGauss 3.0.0.

## Introduction
A standby node can be built by another standby node to accelerate standby node recovery from faults. The I/O and bandwidth pressure of the primary node can be reduced.

## Benefits
When the service load is heavy, building a standby node by using the primary node increases the resource burden on the primary node. As a result, the performance of the primary node deteriorates and the build becomes slow. Building a standby node by using a standby node does not affect services on the primary node.

## Description
You can run the gs_ctl command to specify a standby node to build another standby node to be repaired. For details, see “Tools Used in the Internal System > gs_ctl” in Tool Reference.

## Enhancements
None.

## Constraints
A standby node can only be used to build another standby node. You can only use a specified IP address and port number to build the standby node. Before building the standby node, ensure that the logs of the standby node to be repaired are later than those of the standby node that sends data.

Dependencies
None.