prob_desc_description stringlengths 63 3.8k | prob_desc_output_spec stringlengths 17 1.47k β | lang_cluster stringclasses 2
values | src_uid stringlengths 32 32 | code_uid stringlengths 32 32 | lang stringclasses 7
values | prob_desc_output_to stringclasses 3
values | prob_desc_memory_limit stringclasses 19
values | file_name stringclasses 111
values | tags listlengths 0 11 | prob_desc_created_at stringlengths 10 10 | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_notes stringlengths 4 3k β | exec_outcome stringclasses 1
value | difficulty int64 -1 3.5k β | prob_desc_input_from stringclasses 3
values | prob_desc_time_limit stringclasses 27
values | prob_desc_input_spec stringlengths 28 2.42k β | prob_desc_sample_outputs stringlengths 2 796 | source_code stringlengths 42 65.5k | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers).The key in football is to divide into teams fairly before the ga... | On the first line print an integer x β the number of boys playing for the first team. On the second line print x integers β the individual numbers of boys playing for the first team. On the third line print an integer y β the number of boys playing for the second team, on the fourth line print y integers β the individu... | C | 0937a7e2f912fc094cc4275fd47cd457 | 662a6ae945dc4867bfb3b97e984be918 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy",
"math"
] | 1328886000 | ["3\n1 2 1", "5\n2 3 3 1 1"] | NoteLet's consider the first sample test. There we send the first and the second boy to the first team and the third boy to the second team. Let's check all three conditions of a fair division. The first limitation is fulfilled (all boys play), the second limitation on the sizes of groups (|2β-β1|β=β1ββ€β1) is fulfilled... | PASSED | 1,500 | standard input | 1 second | The first line contains the only integer n (2ββ€βnββ€β105) which represents the number of guys in the yard. The next line contains n positive space-separated integers, ai (1ββ€βaiββ€β104), the i-th number represents the i-th boy's playing skills. | ["2\n1 2 \n1\n3", "3\n4 1 3 \n2\n5 2"] | #include <stdio.h>
#include <stdlib.h>
struct pos{
int indice;
int valor;
};
typedef struct pos pos;
void quicksort(pos v[],int primero,int ultimo);
int main()
{
int n,i,cont=0,equipo1,equipo2,p,u;
scanf("%d",&n);
while (n>100000 || n<2)
{
scanf("%d",&n);
}
pos v[n];
equip... | |
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers).The key in football is to divide into teams fairly before the ga... | On the first line print an integer x β the number of boys playing for the first team. On the second line print x integers β the individual numbers of boys playing for the first team. On the third line print an integer y β the number of boys playing for the second team, on the fourth line print y integers β the individu... | C | 0937a7e2f912fc094cc4275fd47cd457 | e133c54b3a890b62e8f2df04df17f0d4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy",
"math"
] | 1328886000 | ["3\n1 2 1", "5\n2 3 3 1 1"] | NoteLet's consider the first sample test. There we send the first and the second boy to the first team and the third boy to the second team. Let's check all three conditions of a fair division. The first limitation is fulfilled (all boys play), the second limitation on the sizes of groups (|2β-β1|β=β1ββ€β1) is fulfilled... | PASSED | 1,500 | standard input | 1 second | The first line contains the only integer n (2ββ€βnββ€β105) which represents the number of guys in the yard. The next line contains n positive space-separated integers, ai (1ββ€βaiββ€β104), the i-th number represents the i-th boy's playing skills. | ["2\n1 2 \n1\n3", "3\n4 1 3 \n2\n5 2"] | #include <stdio.h>
struct play{
int skill;
int position;
};
typedef struct play player;
typedef int (*compfn)(const void*, const void*);
int compare(player *, player *);
int main(){
int n, x=0, y=0;
int i, j;
scanf("%d", &n);
player players[n];
for(i=0; i<n; i++){
scanf("%d", &... | |
This is the hard version of the problem. You can find the easy version in the Div. 2 contest. Both versions only differ in the number of times you can ask your friend to taste coffee.This is an interactive problem.You're considering moving to another city, where one of your friends already lives. There are $$$n$$$ cafΓ©... | null | C | 5e02c236446027bca0b32db48766228e | c24a20d22c71652e0897fd066b27390b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"interactive",
"graphs"
] | 1580652300 | ["4 2\nN\nN\nY\nN\nN\nN\nN", "8 8\nN\nN\nN\nN\nY\nY"] | NoteIn the first example, the array is $$$a = [1, 4, 1, 3]$$$. The city produces $$$3$$$ different varieties of coffee ($$$1$$$, $$$3$$$ and $$$4$$$).The successive varieties of coffee tasted by your friend are $$$1, 4, \textbf{1}, 3, 3, 1, 4$$$ (bold answers correspond to Y answers). Note that between the two ? 4 asks... | PASSED | 3,000 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 1024$$$, $$$k$$$ and $$$n$$$ are powers of two). It is guaranteed that $$$\dfrac{3n^2}{2k} \le 15\ 000$$$. | ["? 1\n? 2\n? 3\n? 4\nR\n? 4\n? 1\n? 2\n! 3", "? 2\n? 6\n? 4\n? 5\n? 2\n? 5\n! 6"] | #include <stdio.h>
#define N 1024
int min(int a, int b) { return a < b ? a : b; }
int query(int i) {
if (i == -1) {
printf("R\n"), fflush(stdout);
return 0;
} else {
static char s[2];
printf("? %d\n", i + 1), fflush(stdout);
scanf("%s", s);
return s[0] == 'N';
}
}
int ii_[N], cnt1_;
int solve(int *... | |
This is the hard version of the problem. You can find the easy version in the Div. 2 contest. Both versions only differ in the number of times you can ask your friend to taste coffee.This is an interactive problem.You're considering moving to another city, where one of your friends already lives. There are $$$n$$$ cafΓ©... | null | C | 5e02c236446027bca0b32db48766228e | 82701b6850f3ce682bfc2324341eea66 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"interactive",
"graphs"
] | 1580652300 | ["4 2\nN\nN\nY\nN\nN\nN\nN", "8 8\nN\nN\nN\nN\nY\nY"] | NoteIn the first example, the array is $$$a = [1, 4, 1, 3]$$$. The city produces $$$3$$$ different varieties of coffee ($$$1$$$, $$$3$$$ and $$$4$$$).The successive varieties of coffee tasted by your friend are $$$1, 4, \textbf{1}, 3, 3, 1, 4$$$ (bold answers correspond to Y answers). Note that between the two ? 4 asks... | PASSED | 3,000 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 1024$$$, $$$k$$$ and $$$n$$$ are powers of two). It is guaranteed that $$$\dfrac{3n^2}{2k} \le 15\ 000$$$. | ["? 1\n? 2\n? 3\n? 4\nR\n? 4\n? 1\n? 2\n! 3", "? 2\n? 6\n? 4\n? 5\n? 2\n? 5\n! 6"] | /* upsolve using zigzag */
/* https://codeforces.com/blog/entry/73563 */
#include <stdio.h>
#include <string.h>
#define N 1024
int query(int i) {
if (i == -1) {
printf("R\n"), fflush(stdout);
return 0;
} else {
static char s[2];
printf("? %d\n", i + 1), fflush(stdout);
scanf("%s", s);
return s[0] == 'N... | |
The only difference between easy and hard versions are constraints on $$$n$$$ and $$$k$$$.You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $$$k$$$ most recent conversations with your friends. Initially, the screen is empty (i.e. the number of displayed conver... | In the first line of the output print one integer $$$m$$$ ($$$1 \le m \le min(n, k)$$$) β the number of conversations shown after receiving all $$$n$$$ messages. In the second line print $$$m$$$ integers $$$ids_1, ids_2, \dots, ids_m$$$, where $$$ids_i$$$ should be equal to the ID of the friend corresponding to the con... | C | 485a1ecf8f569b85327b99382bda9466 | 04f16d87292f534613dc4bf76dd0b7b6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"implementation"
] | 1569940500 | ["7 2\n1 2 3 2 1 3 2", "10 4\n2 3 3 1 1 2 1 2 3 3"] | NoteIn the first example the list of conversations will change in the following way (in order from the first to last message): $$$[]$$$; $$$[1]$$$; $$$[2, 1]$$$; $$$[3, 2]$$$; $$$[3, 2]$$$; $$$[1, 3]$$$; $$$[1, 3]$$$; $$$[2, 1]$$$. In the second example the list of conversations will change in the following way... | PASSED | 1,300 | standard input | 2 seconds | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n, k \le 200)$$$ β the number of messages and the number of conversations your smartphone can show. The second line of the input contains $$$n$$$ integers $$$id_1, id_2, \dots, id_n$$$ ($$$1 \le id_i \le 10^9$$$), where $$$id_i$$$ is the ID... | ["2\n2 1", "3\n1 3 2"] | #include <stdio.h>
#include <stdlib.h>
#define N 200000
#define K 200000
int aa[N];
int compare(const void *a, const void *b) {
int i = *(int *) a;
int j = *(int *) b;
return aa[i] - aa[j];
}
int main() {
static int ii[N], aa_[N], qq[N];
static char used[N];
int n, k, i, n_, head, cnt;
scanf("%d%d", &n, &k... | |
There is a string s, consisting of capital Latin letters. Let's denote its current length as |s|. During one move it is allowed to apply one of the following operations to it: INSERT pos ch β insert a letter ch in the string s in the position pos (1ββ€βposββ€β|s|β+β1,βAββ€βchββ€βZ). The letter ch becomes the pos-th symbo... | In the first line print the number of moves k in the given sequence of operations. The number should be the minimal possible one. Then print k lines containing one operation each. Print the operations in the format, described above. If there are several solutions, print any of them. | C | 3cef1144dbd24e3e3807ab097b022c13 | 8b870387855e7fd72628760de2cb3ec3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"dp"
] | 1295626200 | ["ABA\nABBBA", "ACCEPTED\nWRONGANSWER"] | null | PASSED | 2,100 | standard input | 2 seconds | The first line contains s, the second line contains t. The lines consist only of capital Latin letters, their lengths are positive numbers from 1 to 1000. | ["2\nINSERT 3 B\nINSERT 4 B", "10\nREPLACE 1 W\nREPLACE 2 R\nREPLACE 3 O\nREPLACE 4 N\nREPLACE 5 G\nREPLACE 6 A\nINSERT 7 N\nINSERT 8 S\nINSERT 9 W\nREPLACE 11 R"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <stdint.h>
// N = 1000 + \n + \0
#define N 1002
enum action { NOTHING, REPLACE, INSERT, DELETE };
typedef struct entry {
uint16_t dist : 10;
int8_t y : 2;
int8_t x : 2;
} entry;
typedef struct move {
enum action ... | |
There is a string s, consisting of capital Latin letters. Let's denote its current length as |s|. During one move it is allowed to apply one of the following operations to it: INSERT pos ch β insert a letter ch in the string s in the position pos (1ββ€βposββ€β|s|β+β1,βAββ€βchββ€βZ). The letter ch becomes the pos-th symbo... | In the first line print the number of moves k in the given sequence of operations. The number should be the minimal possible one. Then print k lines containing one operation each. Print the operations in the format, described above. If there are several solutions, print any of them. | C | 3cef1144dbd24e3e3807ab097b022c13 | c24b5f08c24c75f3cec16ea7d04f0b54 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"dp"
] | 1295626200 | ["ABA\nABBBA", "ACCEPTED\nWRONGANSWER"] | null | PASSED | 2,100 | standard input | 2 seconds | The first line contains s, the second line contains t. The lines consist only of capital Latin letters, their lengths are positive numbers from 1 to 1000. | ["2\nINSERT 3 B\nINSERT 4 B", "10\nREPLACE 1 W\nREPLACE 2 R\nREPLACE 3 O\nREPLACE 4 N\nREPLACE 5 G\nREPLACE 6 A\nINSERT 7 N\nINSERT 8 S\nINSERT 9 W\nREPLACE 11 R"] | #include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#define max(x, y) ((x > y) ? x : y)
enum action { REPLACE, NOTHING, INSERT, DELETE };
struct edit {
uint16_t dist : 14;
enum action parent : 2;
};
struct trace {
enum action action : 2;
uint16_t pos : 10;
char ch : 8;... | |
There is a string s, consisting of capital Latin letters. Let's denote its current length as |s|. During one move it is allowed to apply one of the following operations to it: INSERT pos ch β insert a letter ch in the string s in the position pos (1ββ€βposββ€β|s|β+β1,βAββ€βchββ€βZ). The letter ch becomes the pos-th symbo... | In the first line print the number of moves k in the given sequence of operations. The number should be the minimal possible one. Then print k lines containing one operation each. Print the operations in the format, described above. If there are several solutions, print any of them. | C | 3cef1144dbd24e3e3807ab097b022c13 | c0b39bf66ec4bb5f9cbfe7e2601ab8fb | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"dp"
] | 1295626200 | ["ABA\nABBBA", "ACCEPTED\nWRONGANSWER"] | null | PASSED | 2,100 | standard input | 2 seconds | The first line contains s, the second line contains t. The lines consist only of capital Latin letters, their lengths are positive numbers from 1 to 1000. | ["2\nINSERT 3 B\nINSERT 4 B", "10\nREPLACE 1 W\nREPLACE 2 R\nREPLACE 3 O\nREPLACE 4 N\nREPLACE 5 G\nREPLACE 6 A\nINSERT 7 N\nINSERT 8 S\nINSERT 9 W\nREPLACE 11 R"] | #include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#define max(x, y) ((x > y) ? x : y)
enum action { REPLACE, NOTHING, INSERT, DELETE };
struct edit {
uint16_t dist : 10;
uint16_t parent : 2;
};
struct trace {
enum action action : 2;
uint16_t pos : 10;
char ch : 8;
};... | |
Arpa has found a list containing n numbers. He calls a list bad if and only if it is not empty and gcd (see notes section for more information) of numbers in the list is 1.Arpa can perform two types of operations: Choose a number and delete it with cost x. Choose a number and increase it by 1 with cost y. Arpa can ap... | Print a single integer: the minimum possible cost to make the list good. | C | 41a1b33baa83aea57423b160247adcb6 | d93ac37a6a9efef458b633b6a53091b9 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"number theory"
] | 1504535700 | ["4 23 17\n1 17 17 16", "10 6 2\n100 49 71 73 66 96 8 60 41 63"] | NoteIn example, number 1 must be deleted (with cost 23) and number 16 must increased by 1 (with cost 17).A gcd (greatest common divisor) of a set of numbers is the maximum integer that divides all integers in the set. Read more about gcd here. | PASSED | 2,100 | standard input | 2 seconds | First line contains three integers n, x and y (1ββ€βnββ€β5Β·105, 1ββ€βx,βyββ€β109)Β β the number of elements in the list and the integers x and y. Second line contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β106)Β β the elements of the list. | ["40", "10"] | //Preface Version -- 2017.9.14
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long
#define uL unsigned long
#define uC unsigned char
#define NODES 1000007
#define NNNN 3000007
#define MemoryStackTotal 100
#define error 1e-8
static unsigned char BakaMemoryStack... | |
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car... | In a single line, print the maximum possible total joy of the hares Inna can get by feeding them. | C | 99cf10673cb275ad3b90bcd3757ecd47 | 4d62a8b0125bba06e517db2141937fb4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy"
] | 1382715000 | ["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"] | null | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1,βb2,β...,βbn. The third line contains c1,βc2,β...,βcn. The following limits are fulfilled: 0ββ€βai,βbi,βciββ€β1... | ["13", "44", "4"] | # include <stdio.h>
# include <string.h>
int list[3002][3];
int din[3][3002], n;
int max(int a, int b) { return a > b ? a : b; }
int solve(int comido, int position ){
int res = 0;
if( position == n ) return 0;
if( din[comido][position] != -1 ) return din[comido][position];
if( comido == 0){
if( posi... | |
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car... | In a single line, print the maximum possible total joy of the hares Inna can get by feeding them. | C | 99cf10673cb275ad3b90bcd3757ecd47 | 515157fe71376bf48e153ff413aea265 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy"
] | 1382715000 | ["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"] | null | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1,βb2,β...,βbn. The third line contains c1,βc2,β...,βcn. The following limits are fulfilled: 0ββ€βai,βbi,βciββ€β1... | ["13", "44", "4"] | #include<stdio.h>
int s[3000],m[3000];
main()
{
int n,i,temp1,temp2;
scanf("%d",&n);
int a[n],b[n],c[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
for(i=0;i<n;i++)
scanf("%d",&c[i]);
if(n==1)
{
printf("%d",a[0]);
return 0;
}
s[0]=b[0];m... | |
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car... | In a single line, print the maximum possible total joy of the hares Inna can get by feeding them. | C | 99cf10673cb275ad3b90bcd3757ecd47 | 5aaaeb83822f9696ca77fe6e1cd34e2f | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy"
] | 1382715000 | ["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"] | null | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1,βb2,β...,βbn. The third line contains c1,βc2,β...,βcn. The following limits are fulfilled: 0ββ€βai,βbi,βciββ€β1... | ["13", "44", "4"] | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main(){
int n;
int a[3000], b[3000], c[3000];
int dp[3001];
int i, j, add, go;
scanf("%d",&n);
rep(i,n) scanf("%d",a+i);
rep(i,n) scanf("%d",b+i);
rep(i,n) scan... | |
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car... | In a single line, print the maximum possible total joy of the hares Inna can get by feeding them. | C | 99cf10673cb275ad3b90bcd3757ecd47 | 5eb6c563da544c52dc89bd8caadf7811 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy"
] | 1382715000 | ["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"] | null | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1,βb2,β...,βbn. The third line contains c1,βc2,β...,βcn. The following limits are fulfilled: 0ββ€βai,βbi,βciββ€β1... | ["13", "44", "4"] | #include<stdio.h>
#include<string.h>
#define max(a,b) (a > b ? a : b)
int n,a[3005],b[3005],c[3005];
int dp[3005][2];
int rec(int ind, int last)
{
if(ind==n-1) return (last==1 ? b[ind] : a[ind]);
if(dp[ind][last]!=-1) return dp[ind][last];
if(last)
return dp[ind][last] = max(b[ind]+rec(ind+1,1),c... | |
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car... | In a single line, print the maximum possible total joy of the hares Inna can get by feeding them. | C | 99cf10673cb275ad3b90bcd3757ecd47 | 0a6ac31006d9e6b0a92183dcce85ff3b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy"
] | 1382715000 | ["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"] | null | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1,βb2,β...,βbn. The third line contains c1,βc2,β...,βcn. The following limits are fulfilled: 0ββ€βai,βbi,βciββ€β1... | ["13", "44", "4"] |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* Author : Sarvesh Mahajan
IIIT, Hyderabad */
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include<stdio.h>
#include<string.h>
#include<ma... | |
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car... | In a single line, print the maximum possible total joy of the hares Inna can get by feeding them. | C | 99cf10673cb275ad3b90bcd3757ecd47 | 7d70229b98c54d2bbb8d54a727121b50 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy"
] | 1382715000 | ["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"] | null | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1,βb2,β...,βbn. The third line contains c1,βc2,β...,βcn. The following limits are fulfilled: 0ββ€βai,βbi,βciββ€β1... | ["13", "44", "4"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int max(int a, int b) {
return (a > b) ? a : b;
}
int n;
int data[3001][3];
int cache[3001][2][2];
void init() {
scanf("%d", &n);
int i;
int j;
for (j = 0; j < 3; j++) {
for (i = 1; i <= n; i++) {
scanf("%d", &data[i][j]);
}
}
fo... | |
PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses.You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, if ... | In a single line of print the answerΒ β "YES" if PolandBall wins and "NO" otherwise. Both Balls play optimally. | C | 4b352854008a9378551db60b76d33cfa | c7a877da49e5f408eb08f73e1d6a961b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"games",
"sortings",
"data structures",
"binary search",
"strings"
] | 1484499900 | ["5 1\npolandball\nis\na\ncool\ncharacter\nnope", "2 2\nkremowka\nwadowicka\nkremowka\nwiedenska", "1 2\na\na\nb"] | NoteIn the first example PolandBall knows much more words and wins effortlessly.In the second example if PolandBall says kremowka first, then EnemyBall cannot use that word anymore. EnemyBall can only say wiedenska. PolandBall says wadowicka and wins. | PASSED | 1,100 | standard input | 1 second | The first input line contains two integers n and m (1ββ€βn,βmββ€β103)Β β number of words PolandBall and EnemyBall know, respectively. Then n strings follow, one per lineΒ β words familiar to PolandBall. Then m strings follow, one per lineΒ β words familiar to EnemyBall. Note that one Ball cannot know a word more than once (... | ["YES", "YES", "NO"] | #include<stdio.h>
#include<string.h>
#define Max_limit 500
main(){
long int n,m;
scanf("%ld %ld",&n,&m);
char arr1[n][Max_limit]; //storing n words each with character not more than 500 in an array.
for(long int i=0;i<n;i++){
scanf("%s",arr1[i]);
}
char arr2[m][Max_limit]; //storing m words each with ch... | |
PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses.You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, if ... | In a single line of print the answerΒ β "YES" if PolandBall wins and "NO" otherwise. Both Balls play optimally. | C | 4b352854008a9378551db60b76d33cfa | 7a0c9ef5330d3d484215366a489ee07f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"games",
"sortings",
"data structures",
"binary search",
"strings"
] | 1484499900 | ["5 1\npolandball\nis\na\ncool\ncharacter\nnope", "2 2\nkremowka\nwadowicka\nkremowka\nwiedenska", "1 2\na\na\nb"] | NoteIn the first example PolandBall knows much more words and wins effortlessly.In the second example if PolandBall says kremowka first, then EnemyBall cannot use that word anymore. EnemyBall can only say wiedenska. PolandBall says wadowicka and wins. | PASSED | 1,100 | standard input | 1 second | The first input line contains two integers n and m (1ββ€βn,βmββ€β103)Β β number of words PolandBall and EnemyBall know, respectively. Then n strings follow, one per lineΒ β words familiar to PolandBall. Then m strings follow, one per lineΒ β words familiar to EnemyBall. Note that one Ball cannot know a word more than once (... | ["YES", "YES", "NO"] | #include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int n,m,i;
scanf("%d %d",&n,&m);
char str[n][501];
char str1[m][501];
for(i=0;i<n;i++)
{
scanf("%s",str[i]);
}
for(i=0;i<m;i++)
{
scanf("%s",str1[i]);
}
int j,common=0;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
i... | |
PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses.You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, if ... | In a single line of print the answerΒ β "YES" if PolandBall wins and "NO" otherwise. Both Balls play optimally. | C | 4b352854008a9378551db60b76d33cfa | c046600447c343167bb897feda9d3ab3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"games",
"sortings",
"data structures",
"binary search",
"strings"
] | 1484499900 | ["5 1\npolandball\nis\na\ncool\ncharacter\nnope", "2 2\nkremowka\nwadowicka\nkremowka\nwiedenska", "1 2\na\na\nb"] | NoteIn the first example PolandBall knows much more words and wins effortlessly.In the second example if PolandBall says kremowka first, then EnemyBall cannot use that word anymore. EnemyBall can only say wiedenska. PolandBall says wadowicka and wins. | PASSED | 1,100 | standard input | 1 second | The first input line contains two integers n and m (1ββ€βn,βmββ€β103)Β β number of words PolandBall and EnemyBall know, respectively. Then n strings follow, one per lineΒ β words familiar to PolandBall. Then m strings follow, one per lineΒ β words familiar to EnemyBall. Note that one Ball cannot know a word more than once (... | ["YES", "YES", "NO"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 501
typedef struct {
int count;
char word[N];
} item;
item A[2001];
int main() {
int p, v;
char s[501];
int i, j;
scanf("%d %d", &p, &v);
for (i = 0; i < p; i++) {
scanf("%s", s);
//(A[i]).word = s;... | |
PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses.You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, if ... | In a single line of print the answerΒ β "YES" if PolandBall wins and "NO" otherwise. Both Balls play optimally. | C | 4b352854008a9378551db60b76d33cfa | 91418075fe8e261bd02c5710771a5548 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"games",
"sortings",
"data structures",
"binary search",
"strings"
] | 1484499900 | ["5 1\npolandball\nis\na\ncool\ncharacter\nnope", "2 2\nkremowka\nwadowicka\nkremowka\nwiedenska", "1 2\na\na\nb"] | NoteIn the first example PolandBall knows much more words and wins effortlessly.In the second example if PolandBall says kremowka first, then EnemyBall cannot use that word anymore. EnemyBall can only say wiedenska. PolandBall says wadowicka and wins. | PASSED | 1,100 | standard input | 1 second | The first input line contains two integers n and m (1ββ€βn,βmββ€β103)Β β number of words PolandBall and EnemyBall know, respectively. Then n strings follow, one per lineΒ β words familiar to PolandBall. Then m strings follow, one per lineΒ β words familiar to EnemyBall. Note that one Ball cannot know a word more than once (... | ["YES", "YES", "NO"] | #include <stdio.h>
#include <string.h>
int main()
{
int n, m, i, j, e, common;
scanf("%i %i", &n, &m);
while (getchar() != '\n')
;
char a[n][500], b[m][500];
for (i = 0; i < n; i++)
gets(a[i]);
for (i = 0; i < m; i++)
gets(b[i]);
if (n < m)
{
for (i = ... | |
PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses.You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, if ... | In a single line of print the answerΒ β "YES" if PolandBall wins and "NO" otherwise. Both Balls play optimally. | C | 4b352854008a9378551db60b76d33cfa | 1b73357d4e1b6b3eb6150077e6ad628f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"games",
"sortings",
"data structures",
"binary search",
"strings"
] | 1484499900 | ["5 1\npolandball\nis\na\ncool\ncharacter\nnope", "2 2\nkremowka\nwadowicka\nkremowka\nwiedenska", "1 2\na\na\nb"] | NoteIn the first example PolandBall knows much more words and wins effortlessly.In the second example if PolandBall says kremowka first, then EnemyBall cannot use that word anymore. EnemyBall can only say wiedenska. PolandBall says wadowicka and wins. | PASSED | 1,100 | standard input | 1 second | The first input line contains two integers n and m (1ββ€βn,βmββ€β103)Β β number of words PolandBall and EnemyBall know, respectively. Then n strings follow, one per lineΒ β words familiar to PolandBall. Then m strings follow, one per lineΒ β words familiar to EnemyBall. Note that one Ball cannot know a word more than once (... | ["YES", "YES", "NO"] |
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
int i, j, n, m, x = 0;
scanf("%d%d", &n, &m);
char p[n][500], e[m][500], s[500];
gets(s);
for (i = 0; i < n; i++) {
gets(p[i]);
}
for (i = 0; i < m; i++) {
gets(e[i]);
}
if (n < m) {
p... | |
PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses.You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, if ... | In a single line of print the answerΒ β "YES" if PolandBall wins and "NO" otherwise. Both Balls play optimally. | C | 4b352854008a9378551db60b76d33cfa | 4f9f1e23f3282e23bd24d0164fb2a666 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"games",
"sortings",
"data structures",
"binary search",
"strings"
] | 1484499900 | ["5 1\npolandball\nis\na\ncool\ncharacter\nnope", "2 2\nkremowka\nwadowicka\nkremowka\nwiedenska", "1 2\na\na\nb"] | NoteIn the first example PolandBall knows much more words and wins effortlessly.In the second example if PolandBall says kremowka first, then EnemyBall cannot use that word anymore. EnemyBall can only say wiedenska. PolandBall says wadowicka and wins. | PASSED | 1,100 | standard input | 1 second | The first input line contains two integers n and m (1ββ€βn,βmββ€β103)Β β number of words PolandBall and EnemyBall know, respectively. Then n strings follow, one per lineΒ β words familiar to PolandBall. Then m strings follow, one per lineΒ β words familiar to EnemyBall. Note that one Ball cannot know a word more than once (... | ["YES", "YES", "NO"] | #include<stdio.h>
int main()
{
int n,m,k=0,i,j,d;
scanf("%d %d",&n,&m);
char S[n][501],T[m][501];
for(i=0;i<n;i++)
{
scanf("%s",S[i]);
}
for(j=0;j<m;j++)
{
scanf("%s",T[j]);
for(i=0;i<n;i++)
{
d=strcmp(S[i],T[j]);
{
... | |
Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long intege... | In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part mu... | C | 695418026140545863313f5f3cc1bf00 | c12bed68e2e1a843452c9467281644c6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"number theory",
"brute force",
"math",
"strings"
] | 1416733800 | ["116401024\n97 1024", "284254589153928171911281811000\n1009 1000", "120\n12 1"] | null | PASSED | 1,700 | standard input | 1 second | The first line of the input contains the public key of the messenger β an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1ββ€βa,βbββ€β108). | ["YES\n11640\n1024", "YES\n2842545891539\n28171911281811000", "NO"] | #include<string.h>
#include<math.h>
#include<stdlib.h>
typedef long long ll;
#define mod 1000000007
#define tam 10000010
char string [tam];
int left[tam],right[tam];
int main(){
int a,b,size;
int n = 1;
int i,k = 0;
int flag = 0;
scanf("%s",string);
scanf("%lld %lld",&a,&b);
size =... | |
Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long intege... | In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part mu... | C | 695418026140545863313f5f3cc1bf00 | a52219af080f7511e756088cb2771460 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"number theory",
"brute force",
"math",
"strings"
] | 1416733800 | ["116401024\n97 1024", "284254589153928171911281811000\n1009 1000", "120\n12 1"] | null | PASSED | 1,700 | standard input | 1 second | The first line of the input contains the public key of the messenger β an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1ββ€βa,βbββ€β108). | ["YES\n11640\n1024", "YES\n2842545891539\n28171911281811000", "NO"] | #include <stdio.h>
#include <string.h>
#define MAXL 1048576
char in[MAXL], *input = in;
int mod_b[MAXL];
int main() {
int a, b;
scanf("%s%d%d", input, &a, &b);
long long left = 0, right = 0;
int len = strlen(input);
/* if the string length is smaller than 1, it's impossible to parse
the string into two parts... | |
Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long intege... | In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part mu... | C | 695418026140545863313f5f3cc1bf00 | dd2acf3f4d4b3741d62933cc6f4be3b2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"number theory",
"brute force",
"math",
"strings"
] | 1416733800 | ["116401024\n97 1024", "284254589153928171911281811000\n1009 1000", "120\n12 1"] | null | PASSED | 1,700 | standard input | 1 second | The first line of the input contains the public key of the messenger β an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1ββ€βa,βbββ€β108). | ["YES\n11640\n1024", "YES\n2842545891539\n28171911281811000", "NO"] | /* practice with Dukkha */
#include <stdio.h>
#include <string.h>
#define N 1000000
int main() {
static char cc[N + 1], aa[N], bb[N];
int n, a, b, d, i, p, q;
scanf("%s%d%d", cc, &a, &b);
n = strlen(cc);
for (i = 0, p = 0; i < n; i++) {
d = cc[i] - '0';
p = (p * 10 + d) % a;
aa[i] = p == 0;
}
for (i = ... | |
Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long intege... | In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part mu... | C | 695418026140545863313f5f3cc1bf00 | c5f980dc1c3fdde291e164a338aa0c76 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"number theory",
"brute force",
"math",
"strings"
] | 1416733800 | ["116401024\n97 1024", "284254589153928171911281811000\n1009 1000", "120\n12 1"] | null | PASSED | 1,700 | standard input | 1 second | The first line of the input contains the public key of the messenger β an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1ββ€βa,βbββ€β108). | ["YES\n11640\n1024", "YES\n2842545891539\n28171911281811000", "NO"] | #include <stdio.h>
#include <string.h>
int main()
{
char Str[1000001];
char StrA[1000001];
int ModBy10N[1000000];
int dataA[11], dataB[11];
int A, B, CurModA, CurModB, FinalModB, i, L;
char flag = 0;
scanf("%s %d %d", Str, &A, &B);
for(i = 0; i < 11; ++i) {
dataA[i] = i % A;
... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 7a0785885f713476725bb1d69716078a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include<string.h>
int main()
{
char s[1000000];
int i,flag=0;
scanf("%s",s);
int l=strlen(s);
for(i=0;i<l;i++)
{
if(s[i]!='a')
{
s[i]+=-1;
flag=1;
if(s[i+1]=='a')
break;
}
}
if(flag==0)
{
s[l-1]='z';
printf("%s",s);
}
else
printf("%s",s);
}
| |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 884726eb317d264817ccfc1d6414778e | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
void fun(char *);
void fun(char *s)
{
int i,flag=0;
int len=strlen(s);
for(i=0;s[i]!='\0';i++)
{
if(s[i]=='a')
{
flag=1;
}
}
if(flag==0)
{
for(i=0;s[i]!='\0';i++)
{
s[i]=s[... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 74432e2f8f141e29cad107c1295cd87d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
return ( *(long long*)a - *(long long*)b );
}
int main(void){
long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,b,count1=0,a2,b2;
char a[10000... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | f1a3c645ff7ff36e94ca3147c6a846ae | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include <stdio.h>
#include <string.h>
char s[123456];
int main() {
scanf("%s", s);
int n = strlen(s);
int k = strlen(s) - 1;
for (int i = 0; i < n; i++) {
if (s[i] != 'a') {
k = i;
break;
}
}
s[k] = (((s[k] - 'a') + 25) % 26) + 'a';
k++;
while (k < n && s[k] != 'a') {
s[k] = (... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 4c709b47bbe2ac3b83042ccdc7e314ab | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include<string.h>
int main()
{
int i,j=0,n;
char SS[1000003];
fgets(SS,sizeof(SS),stdin);
n=strlen(SS)-1;
for(i=0;i<n;i++)
{
if(SS[i]!='a')
{
SS[i]=SS[i]-1;
j++;
}
else
{
if(i!=0&&j!=0)
... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 17421c8fb1be7bd494519f8d5b038872 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include<string.h>
int main()
{
int i,a=0,n;
char x[100002];
gets(x);
n=strlen(x);
for(i=0;i<n;i++)
if(x[i]!='a') break;
if(i==n) x[n-1]='z';
else
{for(i=0;i<n;i++)
{
if(a&&x[i]=='a') break;
else if(x[i]>'a'){x[i]-=... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 11ac61a0b3bdf2595b88a12d13a541a4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include<string.h>
int main()
{
int i,a=0,n;
char x[100002];
gets(x);
n=strlen(x);
for(i=0;i<n;i++)
{
if(a&&x[i]=='a') break;
else if(x[i]>'a'){x[i]-=1; a=1;}
if(!a&&i==n-1) x[i]='z';
}
puts(x);
}
| |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | c1282364d1e31b152d9d0773ab75db36 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
char str[100000];
int i=0,j=0;
int c,d,e;
char k;
int m;
int g=0;
int count=0;
scanf("%s",str);
while(str[i]!='\0'){
if(str[i+1]!='\0'){
if((str[i]=='a'&&count==0)&&str[i+1]!='a'){
count++;
... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 5278e1d8114652676c7dffcd2301948f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char s[100000];
int k=0;int l=1;
scanf("%s",&s);
int n=strlen(s);
int i,j;
if(n==1){
if(s[0]==97)s[0]=122;
else s[0]=s[0]-1;
}
else
{for(i=0;i<n;i++)
{
if(s[i]==97)l=0;
else
{l=1;
break;
}
}
if(l==0)
{
s[n-1]=... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | f7984ad72f504bbe79d359e79aec2f03 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | //
// main.c
// CodeForce
//
// Created by Yash Agarwal on 11/17/19.
// Copyright Β© 2019 Yash Agarwal. All rights reserved.
//
#include <stdio.h>
#include <stdio.h>
#include <string.h>
int main()
{
char s[100000];
scanf("%s",s);
int start=0,end =0, n =(int)strlen(s);
while(s[start]=='a') // s... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | b1b0a551e1483edcafcb7973a518d34f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | d4a2d7cb4d2559f26a4bac05431ac78b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main() {
char *p, *string = (char*) calloc(100001, sizeof(char));
scanf("%s", string);
long len = strlen(string);
p = string;
while(*(p++) == 'a' && (len--)> 0);
if(len == 0) {
*(p-2) = 'z';
... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 6725132b6314909c3a6497e6d289758e | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
int main()
{
char s[100001];
scanf("%s",s);
int n=strlen(s),f=0,g=0,l=0,r=0;
for(int i=0;i<n;i++)
{
if(s[i]!='a')
{
f=1;
l=i;
break;
}
}
//printf("%d %d",l,f);
if(f==0)
{
for(int i=0;i<n-1;i++)
printf("%c",s[i]);
printf("%c",'z')... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 5e8e465b6956b7c067e63a866b460a46 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include <string.h>
int main()
{
int j=-1,k=-1,l,i;
char s[100005];
scanf("%s",&s);
l=strlen(s);
for( i=0;i<l;i++)
{
if((s[i]!='a')&&(j==-1))
j=i;
else if((s[i]=='a')&&(j!=-1)&&(k==-1))
k=i;
}
if(k==-1)
k=l;
if(j==-1)
{
s[l-1]='z';
printf("%s",s);
return 0;... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 8542391dc4f8ecad482c1c7068ebf11b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include<stdio.h>
#include<string.h>
int main()
{
int i,j=0,l,x=0;
char s[100005];
gets(s);
l=strlen(s);
for(i=0;i<l;i++){
if(s[i]!='a'){
j=i;
break;
}
}
for(i=j;i<l;i++){
if(s[i]=='a'){
break;
}
s[i]=s[i]-1;
... | |
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.What is the le... | Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring. | C | e70708f72da9a203b21fc4112ede9268 | 5437e4d90abc9601cbc404291f648ef3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy",
"strings"
] | 1472056500 | ["codeforces", "abacaba"] | NoteString s is lexicographically smaller than some other string t of the same length if there exists some 1ββ€βiββ€β|s|, such that s1β=βt1,βs2β=βt2,β...,βsiβ-β1β=βtiβ-β1, and siβ<βti. | PASSED | 1,200 | standard input | 1 second | The only line of the input contains the string s (1ββ€β|s|ββ€β100β000) consisting of lowercase English letters. | ["bncdenqbdr", "aaacaba"] | #include <stdio.h>
#define MAX 100001
int main(void) {
char s[MAX];
int i = 0;
do {
scanf("%c", &s[i]);
i++;
} while (s[i-1] != '\n');
s[i-1] = '\0';
i = 0;
while (s[i] != '\0' && s[i] == 'a') i++;
if (s[i] == '\0') s[i-1] = 'z';
while (s[i] != '\0' && s[i] != 'a') ... | |
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup... | If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the... | C | 7bfc0927ea7abcef661263e978612cc5 | 3cb2aa87185b9a29a614d9f1fd0a4a7d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1311346800 | ["5\n270\n250\n250\n230\n250", "5\n250\n250\n250\n250\n250", "5\n270\n250\n249\n230\n250"] | null | PASSED | 1,300 | standard input | 0.5 second | The first line contains integer n β the number of cups on the royal table (1ββ€βnββ€β1000). Next n lines contain volumes of juice in each cup β non-negative integers, not exceeding 104. | ["20 ml. from cup #4 to cup #1.", "Exemplary pages.", "Unrecoverable configuration."] | #include"stdio.h"
long n;
long f[1011];
long solve()
{
long i,j,k,r,w,sum=0,mid=0,num=0,ok = 1;
long a,b,c;
scanf("%ld",&n);
for(i=1;i<=n;i++) { scanf("%ld",&f[i]); sum += f[i]; }
mid = sum / n;
if(mid * n != sum) { return -1; }
for(i=1;i<=n;i++)
if(f[i] - mid != 0)
{ ... | |
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup... | If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the... | C | 7bfc0927ea7abcef661263e978612cc5 | 621b967ed9d3f917a78af3752157b578 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1311346800 | ["5\n270\n250\n250\n230\n250", "5\n250\n250\n250\n250\n250", "5\n270\n250\n249\n230\n250"] | null | PASSED | 1,300 | standard input | 0.5 second | The first line contains integer n β the number of cups on the royal table (1ββ€βnββ€β1000). Next n lines contain volumes of juice in each cup β non-negative integers, not exceeding 104. | ["20 ml. from cup #4 to cup #1.", "Exemplary pages.", "Unrecoverable configuration."] | #include"stdio.h"
long n;
long f[1011];
long solve()
{
long i,j,k,r,w,sum=0,mid=0,num=0,ok = 1;
long a,b,c;
scanf("%ld",&n);
for(i=1;i<=n;i++) { scanf("%ld",&f[i]); sum += f[i]; }
mid = sum / n;
if(mid * n != sum) { return -1; }
for(i=1;i<=n;i++)
if(f[i] - mid != 0)
{ ... | |
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup... | If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the... | C | 7bfc0927ea7abcef661263e978612cc5 | 0af1bc0a48c68200984de2b30c6521db | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1311346800 | ["5\n270\n250\n250\n230\n250", "5\n250\n250\n250\n250\n250", "5\n270\n250\n249\n230\n250"] | null | PASSED | 1,300 | standard input | 0.5 second | The first line contains integer n β the number of cups on the royal table (1ββ€βnββ€β1000). Next n lines contain volumes of juice in each cup β non-negative integers, not exceeding 104. | ["20 ml. from cup #4 to cup #1.", "Exemplary pages.", "Unrecoverable configuration."] | #include<stdio.h>
int main()
{
int i,n,a[1002],sum,q=-1,w=-1,ave,t;
scanf("%d",&n);
for (i=sum=0; i<n; i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
t=sum;
ave=sum/n;
for (i=sum=0; i<n; i++)
{
if (a[i]!=ave)
{
++sum;
if (q==-1)
... | |
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup... | If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the... | C | 7bfc0927ea7abcef661263e978612cc5 | 914e765291311bfa375ed2a2af27d5b7 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1311346800 | ["5\n270\n250\n250\n230\n250", "5\n250\n250\n250\n250\n250", "5\n270\n250\n249\n230\n250"] | null | PASSED | 1,300 | standard input | 0.5 second | The first line contains integer n β the number of cups on the royal table (1ββ€βnββ€β1000). Next n lines contain volumes of juice in each cup β non-negative integers, not exceeding 104. | ["20 ml. from cup #4 to cup #1.", "Exemplary pages.", "Unrecoverable configuration."] | #include<stdio.h>
#include<stdlib.h>
int cmp(const void *a, const void *b){
const int *ia = (const int *)a;
const int *ib = (const int *)b;
return *ib - *ia;
}
int find_index(int x,int *b,int n){
int i;
for(i=0;i<n;i++){
//printf("%d ",b[i]);
if(b[i] == x){
//printf("Hi::%d::",(i+1));
retur... | |
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup... | If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the... | C | 7bfc0927ea7abcef661263e978612cc5 | e5bd92d6e1a3d8f7a56428b6252370d3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1311346800 | ["5\n270\n250\n250\n230\n250", "5\n250\n250\n250\n250\n250", "5\n270\n250\n249\n230\n250"] | null | PASSED | 1,300 | standard input | 0.5 second | The first line contains integer n β the number of cups on the royal table (1ββ€βnββ€β1000). Next n lines contain volumes of juice in each cup β non-negative integers, not exceeding 104. | ["20 ml. from cup #4 to cup #1.", "Exemplary pages.", "Unrecoverable configuration."] | #include <stdio.h>
int main()
{
int n,s=0,i,j,f,k,r;
int ara[1000][1];
int a[1000];
int b[1000];
scanf("%d",&n);
for (i=0;i<n;i++){
scanf("%d",&ara[i][0]);
s=s+ara[i][0];
}
if (s%n!=0){
printf("Unrecoverable configuration.");
}
else{
r=s/n;
k=0;
f=0;
for (i=0;i<n;i++){
if (ara[i][0]!=r){
... | |
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup... | If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the... | C | 7bfc0927ea7abcef661263e978612cc5 | f50e37689b0b4362e322fca71162434a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1311346800 | ["5\n270\n250\n250\n230\n250", "5\n250\n250\n250\n250\n250", "5\n270\n250\n249\n230\n250"] | null | PASSED | 1,300 | standard input | 0.5 second | The first line contains integer n β the number of cups on the royal table (1ββ€βnββ€β1000). Next n lines contain volumes of juice in each cup β non-negative integers, not exceeding 104. | ["20 ml. from cup #4 to cup #1.", "Exemplary pages.", "Unrecoverable configuration."] | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
int s,n,t,c,a[1000],i,j,m=1e6,M;
main(){
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&t);
s+=t;
if(m>t)m=t;
if(M<t)M=t;
a[i]=t;
}
if(m==M){
... | |
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup... | If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the... | C | 7bfc0927ea7abcef661263e978612cc5 | 51be8f6ecc0d27b4f4dbae2500756a98 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1311346800 | ["5\n270\n250\n250\n230\n250", "5\n250\n250\n250\n250\n250", "5\n270\n250\n249\n230\n250"] | null | PASSED | 1,300 | standard input | 0.5 second | The first line contains integer n β the number of cups on the royal table (1ββ€βnββ€β1000). Next n lines contain volumes of juice in each cup β non-negative integers, not exceeding 104. | ["20 ml. from cup #4 to cup #1.", "Exemplary pages.", "Unrecoverable configuration."] | #include <stdio.h>
int main()
{
int n, sum = 0, f = 0, x = 0, y = 0, i;
int a[1000];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
if (sum % n != 0) {
puts("Unrecoverable configuration.");
return 0;
}
for (i = 0; i < n; i++) {
if... | |
A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | C | 98c08a3b5e5b5bb78804ff797ba24d87 | b1395a8a5a5bbc13381073a650b81cb3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"greedy"
] | 1575556500 | ["3\na???cb\na??bbc\na?b?c"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | PASSED | 1,000 | standard input | 1 second | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$)Β β the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | ["ababcb\n-1\nacbac"] | #include <stdio.h>
#include <string.h>
int main ()
{
int t;
scanf ("%d", &t);
while (t--) {
char seq [100001];
scanf ("%s", seq);
char str [] = "abc";
int i, j, l;
int flag = 0;
l = strlen (seq);
for (i = 0; i < l-1; i++) {
if (seq [i] ==... | |
A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | C | 98c08a3b5e5b5bb78804ff797ba24d87 | de77b737225238951105966b89127a76 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"greedy"
] | 1575556500 | ["3\na???cb\na??bbc\na?b?c"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | PASSED | 1,000 | standard input | 1 second | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$)Β β the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | ["ababcb\n-1\nacbac"] | #include<stdio.h>
#include<string.h>
int main()
{
int t,n,i,j,k,l,len;
char a[100001],b[100001];
scanf("%d\n",&t);
for(i=0;i<t;i++)
{
k=1;
gets(a);
len=strlen(a);
//printf("%s\n",a);
// printf("%d ",len);
for(j=0;j<len;j++)
{
if((j!... | |
A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | C | 98c08a3b5e5b5bb78804ff797ba24d87 | f52efaceda67f7dee29f300a4a042108 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"greedy"
] | 1575556500 | ["3\na???cb\na??bbc\na?b?c"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | PASSED | 1,000 | standard input | 1 second | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$)Β β the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | ["ababcb\n-1\nacbac"] | #include<stdio.h>
#include<string.h>
int main()
{
char str[100010];
int t,i,j,c,l;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%s",&str);
c=0;
l=strlen(str);
for(j=0;j<(l-1);j++)
{
if((str[j]==str[j+1])&&str[j]!='?'&&str[j+1]!='?')
{
... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | 1efd7fdc573493819aa69ba085dcc82b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char *x;
char a[100005], b[]="AB",c[]="BA";
gets(a);
if((x=strstr(a,b)) && strstr(x+2,c))
printf("YES");
else if((x=strstr(a,c)) && strstr(x+2,b))
printf("YES");
else printf("NO");
return 0;
}
| |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | 3dac842e776f0b89003ce3fe24a5908b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include <stdio.h>
int main ()
{
char c[100000];
scanf("%s",&c);
int i, flag1=0, found=0,flag2=0;
for (i=0; c[i]!='\0'; i++)
{
if (c[i] == 'A' && c[i+1] == 'B' && flag1 == 0)
{
flag1 = 1;
}
else if (c[i] == 'B' && c[i+... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | 82c8f0354d6ea52aacb6672fc5a59448 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char s[100000];
gets(s);
long i,j, n = strlen(s),a=0,b=0,c=0;
for(i=0;i<n;i++)
{
if((s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='A')||(s[i]=='B'&&s[i+1]=='A'&&s[i+2]=='B')&&i<n-2)
{
c++;i+=2;
}
... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | d801d7e5f3954ebce783080266a2447e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<string.h>
#include<stdio.h>
int main () {
char d[100005];
int i,u,k=0,s=0,s1=0,j=0;
scanf("%s",d);
u=strlen(d);
for(i=0;i<u;i++){
if(d[i]=='B'&& d[i+1]=='A'&&s==0){
k++;
i++;
s++;
if(d[i+1]=='B'){
j++;
k--;
s--;
i++;
}
continue;
}
if(d[i]=='A'&& d[i+1]=='B'&&s1==0){... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | b31d4ac3bdc294f17a29734900084eb2 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<stdio.h>
#include<string.h>
int main()
{
char a[1000006];
int i,j,l,t=0;
scanf("%s",a);
l=strlen(a);
for(i=0;i<l-1;i++)
{
if(a[i]=='A' && a[i+1]=='B')
{
for(j=i+2;j<l-1;j++)
{
if(a[j]=='B' && a[j+1]=='A')
{
... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | d6164cbdb8e8b397c99deb5b8396a33f | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include <stdio.h>
#include<string.h>
int main()
{
char s[100005],*p;
int x;
scanf("%s",s);
if((p=strstr(s,"AB"))&&(strstr(p+2,"BA"))){
{printf("YES");}
}
else if((p=strstr(s,"BA"))&&(strstr(p+2,"AB"))){
{printf("YES");}
}
else{
printf("NO");
}
return 0;
... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | 82f9327ba8ed9923f68ba0688d4112c3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
char a[100001];
int main()
{
int b=0,i=0,c=0,j=0,d=0,e=0;
scanf("%s",a);
int x = strlen(a);
for(i=0; i<x; i++)
{
if(a[i]=='A')
{
if(a[i+1]=='B')
{
e = 1;
for(j=i+... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | 6b42d59ef2c7d63e21758b93b784ad1e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<stdio.h>
#include<string.h>
int main(void)
{
int i,n,flag,j;
char s[100001];
gets(s);
for (i=0, n=strlen(s);i<n;i++)
{
if (s[i]=='A'&&s[i+1]=='B')
{
flag=i+1;
for (j=strlen(s)-1;j>0;j=j-1)
{
if (s[j]=='A'&&s[j-1]=='B')
... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | e1b1f6cfe561bab98c20deb060f40c40 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int x=0,y=0;
char n[100001];
scanf("%s", &n);
for(int i=0; i<strlen(n)-1; i++){
if(n[i]=='A'&&n[i+1]=='B'&&!x){
x++;
}
if(n[i]=='B'&&n[i+1]=='A'&&!y){
y++;
}
if(n[i]=='A'&&n[i+1]=='B'&&x&&y... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | fd7a68f33bb3f71b7a0b71a28102b6d8 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<stdio.h>
#include<string.h>
int main()
{
char ch[100005];
scanf("%s",ch);
int len=strlen(ch);
int flag=0;
int i;
for(i=0;i<len-1;i++)
{
if(ch[i]=='A' && ch[i+1]=='B')
{
// found left substring
i=i+2;
while(i<len-1)
{
... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | e103b726ea08dee2958b6702e59f89c1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include <stdio.h>
#include <string.h>
int main() {
char p[100001], *s;
scanf("%s",p);
if((s=strstr(p,"AB"))!=NULL && strstr(s+2,"BA")!=NULL)
printf("YES");
else if((s=strstr(p,"BA"))!=NULL && strstr(s+2,"AB")!=NULL)
printf("YES");
else
printf("NO");
return 0;
}
| |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | 35b6b4836716dde7f18523c0130da03a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<stdio.h>
#include<string.h>
char arr[100001];
int ln,i;
int posa[2],posb[2];
char flga,flgb;
int main()
{
posa[0]=posb[0]=100002;
posa[1]=posb[1]=-1;
flga=flgb=0;
scanf("%s",arr);
ln=strlen(arr);
for(i=0;i<ln;++i)
{
if(arr[i]=='A')
{
if(flgb=... | |
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | Print "YES" (without the quotes), if string s contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | C | 33f7c85e47bd6c83ab694a834fa728a2 | 6bef7e20287984afdc35aae6331d3372 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"greedy",
"implementation",
"brute force",
"strings"
] | 1433435400 | ["ABA", "BACFAB", "AXBYBXA"] | NoteIn the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".In the second sample test there are the following occurrences of the substrings: BACFAB.In the third sample test there is no substring "AB" nor substring "BA". | PASSED | 1,500 | standard input | 2 seconds | The only line of input contains a string s of length between 1 and 105 consisting of uppercase Latin letters. | ["NO", "YES", "NO"] | #include<string.h>
#include<stdio.h>
int main()
{
char s[1000000];
scanf("%s",s);
int f=0,i,l=0,k=0,q=-1,a=0,g=0;
int p[1000001]={};
for(i=0;i<strlen(s);i++)
{
if(s[i]=='A'&&s[i+1]=='B')
{
g++;
p[i]=1;
}
}
int sp=0,we=0;
for(i=0;i<strlen(s);i++)
{
if(s[i]=='B'&&s[i+1]=='A')
{ f=2;
we++;
}... | |
There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and iβ+β1 are neighbours for all i from 1 to nβ-β1. Sharks n and 1 are neighbours too.Each shark will grow some number of flowers si. For i-th shark value si is random integer equiprobably chosen in range from l... | Print a single real number β the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10β-β6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correc... | C | 5aad0a82748d931338140ae81fed301d | 478a3ebdbded745ab7a02c3afe3aef1b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"combinatorics",
"number theory",
"probabilities",
"math"
] | 1454249100 | ["3 2\n1 2\n420 421\n420420 420421", "3 5\n1 4\n2 3\n11 14"] | NoteA prime number is a positive integer number that is divisible only by 1 and itself. 1 is not considered to be prime.Consider the first sample. First shark grows some number of flowers from 1 to 2, second sharks grows from 420 to 421 flowers and third from 420420 to 420421. There are eight cases for the quantities o... | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and p (3ββ€βnββ€β100β000,β2ββ€βpββ€β109)Β β the number of sharks and Wet Shark's favourite prime number. It is guaranteed that p is prime. The i-th of the following n lines contains information about i-th sharkΒ β two space-separated integers li and ri (1ββ€β... | ["4500.0", "0.0"] | #include <stdio.h>
long double e(int l1, int r1, int l2, int r2, int p)
{
long long n1 = r1 / p - (l1 - 1) / p, d1 = r1 - l1 + 1;
long long n2 = r2 / p - (l2 - 1) / p, d2 = r2 - l2 + 1;
return 2000.0L * (1.0L - (long double) ((d1 - n1) * (d2 - n2)) / (d1 * d2));
}
int main(void)
{
int n, p, l0, r0;
... | |
There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and iβ+β1 are neighbours for all i from 1 to nβ-β1. Sharks n and 1 are neighbours too.Each shark will grow some number of flowers si. For i-th shark value si is random integer equiprobably chosen in range from l... | Print a single real number β the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10β-β6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correc... | C | 5aad0a82748d931338140ae81fed301d | d13fe6d1e46cfbdb82d8ea72642d2919 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"combinatorics",
"number theory",
"probabilities",
"math"
] | 1454249100 | ["3 2\n1 2\n420 421\n420420 420421", "3 5\n1 4\n2 3\n11 14"] | NoteA prime number is a positive integer number that is divisible only by 1 and itself. 1 is not considered to be prime.Consider the first sample. First shark grows some number of flowers from 1 to 2, second sharks grows from 420 to 421 flowers and third from 420420 to 420421. There are eight cases for the quantities o... | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and p (3ββ€βnββ€β100β000,β2ββ€βpββ€β109)Β β the number of sharks and Wet Shark's favourite prime number. It is guaranteed that p is prime. The i-th of the following n lines contains information about i-th sharkΒ β two space-separated integers li and ri (1ββ€β... | ["4500.0", "0.0"] | #include <stdio.h>
#include <ctype.h>
int getint(void)
{
int c, v = 0;
while (isdigit(c = getchar()))
v = 10 * v + c - '0';
return v;
}
long double e(int l1, int r1, int l2, int r2, int p)
{
long long n1 = r1 / p - (l1 - 1) / p, d1 = r1 - l1 + 1;
long long n2 = r2 / p - (l2 - 1) / p, d2 = ... | |
There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and iβ+β1 are neighbours for all i from 1 to nβ-β1. Sharks n and 1 are neighbours too.Each shark will grow some number of flowers si. For i-th shark value si is random integer equiprobably chosen in range from l... | Print a single real number β the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10β-β6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correc... | C | 5aad0a82748d931338140ae81fed301d | 74ed5f61826de3b7df111de66d2fbad5 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"combinatorics",
"number theory",
"probabilities",
"math"
] | 1454249100 | ["3 2\n1 2\n420 421\n420420 420421", "3 5\n1 4\n2 3\n11 14"] | NoteA prime number is a positive integer number that is divisible only by 1 and itself. 1 is not considered to be prime.Consider the first sample. First shark grows some number of flowers from 1 to 2, second sharks grows from 420 to 421 flowers and third from 420420 to 420421. There are eight cases for the quantities o... | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and p (3ββ€βnββ€β100β000,β2ββ€βpββ€β109)Β β the number of sharks and Wet Shark's favourite prime number. It is guaranteed that p is prime. The i-th of the following n lines contains information about i-th sharkΒ β two space-separated integers li and ri (1ββ€β... | ["4500.0", "0.0"] | /* practice with Dukkha */
#include <stdio.h>
#define N 100000
int main() {
static double pp[N];
int n, p, i, l, r;
double sum;
scanf("%d%d", &n, &p);
for (i = 0; i < n; i++) {
scanf("%d%d", &l, &r);
pp[i] = (double) (r / p - (l - 1) / p) / (r - l + 1);
}
sum = 0;
for (i = 0; i < n; i++)
sum += 1 - (1 ... | |
There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and iβ+β1 are neighbours for all i from 1 to nβ-β1. Sharks n and 1 are neighbours too.Each shark will grow some number of flowers si. For i-th shark value si is random integer equiprobably chosen in range from l... | Print a single real number β the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10β-β6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correc... | C | 5aad0a82748d931338140ae81fed301d | 814afb157938bd3bae831b898f23cdd9 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"combinatorics",
"number theory",
"probabilities",
"math"
] | 1454249100 | ["3 2\n1 2\n420 421\n420420 420421", "3 5\n1 4\n2 3\n11 14"] | NoteA prime number is a positive integer number that is divisible only by 1 and itself. 1 is not considered to be prime.Consider the first sample. First shark grows some number of flowers from 1 to 2, second sharks grows from 420 to 421 flowers and third from 420420 to 420421. There are eight cases for the quantities o... | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and p (3ββ€βnββ€β100β000,β2ββ€βpββ€β109)Β β the number of sharks and Wet Shark's favourite prime number. It is guaranteed that p is prime. The i-th of the following n lines contains information about i-th sharkΒ β two space-separated integers li and ri (1ββ€β... | ["4500.0", "0.0"] | #include<stdio.h>
typedef long long ll;
ll n,p,ar[100009][2];
int main()
{
scanf("%lld%lld",&n,&p);
ll i,f1,nf1,a1,b1,f2,nf2,a2,b2,j;
for(i=0;i<n;i++)
scanf("%lld%lld",&ar[i][0],&ar[i][1]);
long double ans=0.0,aa;
for(i=0;i<n;i++)
{
j=i+1;
j=j%n;
a1=((ar[i][0]+p-1)/p)*p;
b1=(ar[i][1]/p)*p;
a2=((ar[j... | |
There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and iβ+β1 are neighbours for all i from 1 to nβ-β1. Sharks n and 1 are neighbours too.Each shark will grow some number of flowers si. For i-th shark value si is random integer equiprobably chosen in range from l... | Print a single real number β the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10β-β6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correc... | C | 5aad0a82748d931338140ae81fed301d | 346282810a1c6ef0bcfd473bc7b02b71 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"combinatorics",
"number theory",
"probabilities",
"math"
] | 1454249100 | ["3 2\n1 2\n420 421\n420420 420421", "3 5\n1 4\n2 3\n11 14"] | NoteA prime number is a positive integer number that is divisible only by 1 and itself. 1 is not considered to be prime.Consider the first sample. First shark grows some number of flowers from 1 to 2, second sharks grows from 420 to 421 flowers and third from 420420 to 420421. There are eight cases for the quantities o... | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and p (3ββ€βnββ€β100β000,β2ββ€βpββ€β109)Β β the number of sharks and Wet Shark's favourite prime number. It is guaranteed that p is prime. The i-th of the following n lines contains information about i-th sharkΒ β two space-separated integers li and ri (1ββ€β... | ["4500.0", "0.0"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int i,n,p,c,d;
int a[100001][2],b[100001];
double sum,s,e[100001];
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
scanf... | |
There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and iβ+β1 are neighbours for all i from 1 to nβ-β1. Sharks n and 1 are neighbours too.Each shark will grow some number of flowers si. For i-th shark value si is random integer equiprobably chosen in range from l... | Print a single real number β the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10β-β6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correc... | C | 5aad0a82748d931338140ae81fed301d | 6b5a60d9873794984c41b6e8496c48b4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"combinatorics",
"number theory",
"probabilities",
"math"
] | 1454249100 | ["3 2\n1 2\n420 421\n420420 420421", "3 5\n1 4\n2 3\n11 14"] | NoteA prime number is a positive integer number that is divisible only by 1 and itself. 1 is not considered to be prime.Consider the first sample. First shark grows some number of flowers from 1 to 2, second sharks grows from 420 to 421 flowers and third from 420420 to 420421. There are eight cases for the quantities o... | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and p (3ββ€βnββ€β100β000,β2ββ€βpββ€β109)Β β the number of sharks and Wet Shark's favourite prime number. It is guaranteed that p is prime. The i-th of the following n lines contains information about i-th sharkΒ β two space-separated integers li and ri (1ββ€β... | ["4500.0", "0.0"] | #include <stdio.h>
int main()
{
int p,n,i,t,l,r;
double ans=0,x[100100];
scanf("%d%d",&n,&p);
t=0;
for(i=1;i<=n;i++)
{
scanf("%d%d",&l,&r);
t=r/p-l/p;
if(l%p==0) t++;
x[i]=1-(double)t/(r-l+1);
}
for(i=1;i<n;i++)
ans+=1-x[i]*x[i+1];
ans+=1-x[n]*x[1];
ans*=2000;
printf("%.9f\n",ans);
return 0;
}
| |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 8c0511470f631334afa576572c50cf1c | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main(){
long long int d;
int n,count=0;
scanf("%d",&n);
scanf("%lld",&d);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(a[j]-a[i]>=(-d) && a[j]-a[i]<=d)
count+=1;}
}
printf("%d",count-n);
return 0;
}... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | ee8a0e757fa479548c1f13acd719f937 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
#include<math.h>
#define max 1000000
int main()
{
long long int i,j,n,m,l,k=0,a[max];
scanf("%lld%lld",&n,&m);
for(i=0;i<n;i++)
scanf("%lld",&a[i]);
for(i=0;i<n-1;i++)
{
l=i;
for(j=i+1;j<n;j++)
{
if(fabs(a[l]-a[j])<=m)
{
k++;
... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 8a75e3679786477496216224fa6b382d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
#include <math.h>
int a[1001],n,i,j, count, d;
int main()
{
scanf("%d %d", &n, &d);
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (i = 1; i < n; i++)
for (j = 1 + i; j <= n; j++)
if (abs(a[j] - a[i]) <= d) count+=2;
printf("%d", count);
} | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 445a2ce633f1016d0d29524ba70fc214 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main()
{int n,i,j,temp,count=0;
long long int d;
scanf("%d%I64d",&n,&d);
int a[n];
for(i=0;i<n;i++)
{scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{ if(i!=j)
{if((a[i]-a[j])<=d&&(a[i]-a[j])>=(-d))
count++;
}
}
}
printf("%d",count);
return 0;
}
| |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | d9a020d0abba53743658fc88da418967 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
#include<math.h>
int main(){
int n,d;
scanf("%d %d",&n,&d);
int a[n],i,j,k=0;
for(i=0;i<n;i++) scanf("%d",&a[i]);
for(i=0;i<n;i++){
for(j=0;j<n;j++)if(j!=i && abs(a[i]-a[j])<=d) k++;
}
printf("%d",k);
return 0;
}
| |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | ae4a57b8b34ce4cf30fb5d73bce40be4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main()
{int n,i,j,temp,count=0;
long long int d;
scanf("%d%lld",&n,&d);
int a[n];
for(i=0;i<n;i++)
{scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{ if(i!=j)
{if((a[i]-a[j])<=d&&(a[i]-a[j])>=(-d))
count++;
}
}
}
printf("%d... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 3c5f1097bfce6beffba40dd872131ad3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
#include <stdlib.h>
int main(){
int n, d, i, j, k, count=0;
scanf("%d%d",&n,&d);
int arr[n];
for(i=0;i<n;i++){
scanf("%d",&arr[i]);
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
k=abs(arr[i]-arr[j]);
if(k<=d){
count+=1;
... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 4d3df921c9e7707f5ac3f9baaa970d82 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
#include<stdlib.h>
int main(void)
{
int n,p;
scanf("%d %d",&n,&p);
int ara[n];
int i,j,k,l;
for(i=0; i<n; i++)
scanf("%d",&ara[i]);
int count=0;
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
if(abs(ara[i]-ara[j])<=p && i!=j)
... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 5cdc65deef8cd08cb6df56056b7b2332 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
int main()
{long long int n,d;
scanf("%lld%lld",&n,&d);
long long int a[n+3],i,j,sum=0;
for(i=0;i<n;i++)
{scanf("%lld",&a[i]);}
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{if(a[i]-a[j]<=d && a[i]-a[j]>=(-d) && i!=j)
sum=sum+1;}}
printf("%lld",sum);
} | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 32d006162b89c5408e3b65de104b8c8b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N_LIMIT 1001 // 1e5+1
typedef long long ll;
int a[N_LIMIT];
int comparator(const void *p, const void *q)
{
return (*(int *)p-*(int*)q);
}
int main(int argc, char *argv)
{
int n, d;
int i, j, k;
int count = 0;
scanf("%d %d", &... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 99670a086291304f58db5140a9c568cc | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
int main()
{
int n,d,a[1000],x,j,i;
long long int ans=0;
scanf("%d %d",&n,&d);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
x = abs(a[j]-a[i]);
if(x <= d)
{
... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 4395821179c4fa202ec99b5dca2da5d0 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main()
{int n,i,j,temp,count=0;
long long int d;
scanf("%d%lld",&n,&d);
int a[n];
for(i=0;i<n;i++)
{scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{ if(i!=j)
{if((a[i]-a[j])<=d&&(a[i]-a[j])>=(-d))
count++;
}
}
}
printf("%d... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | c3e511c38123302c908e1c3389e437ee | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int i,j,a[1001],d,n,c = 0;
scanf("%d%d",&n,&d);
for(i = 0; i < n; i++)
{
scanf("%d",&a[i]);
}
for(i = 0; i < n; i++)
{
for(j = i+1; j < n; j++)
{
if(abs(a[i]-a[j]) <= d)
{
c++;
... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | d2843dd11ed96451fe4712fd550071e7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
int main()
{
int n,d;
scanf("%d%d",&n,&d);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
int k=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
if(abs(a[i]-a[j])<=d && i!=j)
k++;
}
printf("%d\n",k);
} | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 611336e95d3320f791f0c0c7a67f0e42 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
#include<stdlib.h>
int main()
{int n,d,nb,i,j;
scanf("%d",&n);
scanf("%d",&d);
int t[n];
for(i=0;i<n;i++)
scanf("%d",t+i);
for(i=0,nb=0;i<(n-1);i++)
for(j=i+1;j<n;j++)
if (abs(t[i]-t[j])<=d) nb++;
printf("%d",2*nb);
return 0;
} | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | ef3e45770479855e25756a0324018aff | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
#include<stdlib.h>
int main()
{int *n,*d,*t,nb,i,j;
n=(int*)malloc(sizeof(int));
d=(int*)malloc(sizeof(int));
scanf("%d",n);
t=(int*)malloc(sizeof(int)*(*n));
scanf("%d",d);
for(i=0;i<(*n);i++)
scanf("%d",t+i);
for(i=0,nb=0;i<((*n)-1);i++)
for(j=i+1;j<(*n);j++)
if (abs(t[i]-t[j])<=*d) ... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 84695fa8aee07aa8b125349d33374363 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #pragma warning(disable:4996)
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
int lol(const void *x1, const void *x2)
{
return *(int*)x1 - *(int*)x2;
}
/*
int main(void)
{
int n,x,y, flag =1;
scanf("%i", &n);
for (x = 4; x <= 999996 && flag; x+=2)
for (y = 999996; y >= 4 && flag; y-=2... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | d1d92282b6f2c7a7965f26133f41eb9b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int rec_for(int a[],int,int);
int main()
{
int n;long d;
scanf("%d%lu",&n,&d);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
int c=rec_for(a,n,d);
printf("%d",c);
return 0;
}
int rec_for(int a[],int n,int d){
int f=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(a[j]-a[i]... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 6f6fc8a07da7c3ebef7ecfe32d14d50d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
#include <stdlib.h>
int cm(const void *a, const void *b){if ( *(long long int*)a-*(long long int *)b > 0) return 1; else return -1;}
int main(){
int i,n;
long long int d,a[1001],ans = 0LL;
scanf("%i%lli",&n,&d);
for(i=0;i<n;i++)
scanf("%lli",a+i);
qsort(a,n,sizeof a[0],cm)... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | ec23a06bef5ecd16c575be02e4b037dd | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
#include<stdlib.h>
int fun(int [],int ,int );
int fun(int a[],int n,int d)
{
int i,j,ans=0;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(abs(a[j]-a[i])<=d)
{
ans=ans+2;
}
}
}
return ans;
}
int main()
{
... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 3699d5d78ec03ee26838f64af215de2d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
int n,m,i,j,x,c=0;
scanf("%d %d",&n,&m);
int a[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
for(j=0;j<n;j++)
{
x=((a[i]-a[j])>0?(a[i]-a[j]):(a[j]-a[i]));
{
... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | ac672a7c26272bcac6bc4f2b4a23725a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] |
#include<stdio.h>
int main()
{
int n,i=0,j,count=0;
long int d;
scanf("%d",&n);
scanf("%ld",&d);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if((a[i]-a[j])<=d && (a[i]-a[j])>0)
count... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | eea56aa6ed90844931d0c0369435e6df | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main(){
int n,d,j,i,count=0,a[100000];
scanf("%d %d",&n,&d);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(abs(a[j]-a[i])<=d)
count++;
}
}
printf("%d",2*count);
} | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 5a9dee6f0c23b1bea6b876b4632f461a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main()
{int n,i,j,temp,count=0;
long long int d;
scanf("%d%lld",&n,&d);
int a[n];
for(i=0;i<n;i++)
{scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{ if(i!=j)
{if((a[i]-a[j])<=d&&(a[i]-a[j])>=(-d))
count++;
}
}
}
printf("%d... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 6c0716c75d03e112ab7430ed56632c61 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int n,i,j,d,count=0;
scanf("%d%d",&n,&d);
int ara[1005];
for(i=0; i<n; i++)
{
scanf("%d",&ara[i]);
}
for(i=0; i<n; i++)
{
for(j=i+1; j<n; j++)
{
if((ara[i]-ara[j]<=d && ara[i]-ara[j] ... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 1ae1b87e11faa848a0a33a3677d233b0 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main()
{int n,i,j,temp,count=0;
long long int d;
scanf("%d%lld",&n,&d);
int a[n];
for(i=0;i<n;i++)
{scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{ if(i!=j)
{if((a[i]-a[j])<=d&&(a[i]-a[j])>=(-d))
count++;
}
}
}
printf("%d... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | ff92f54d46afcbbceb0d1ffbe6dcaea2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main()
{long long n,temp,count=0;
long long d;
scanf("%lld%lld",&n,&d);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=0;i<n;i++)
{for(int j=0;j<n;j++)
{ if(i!=j)
{if((a[i]-a[j])<=d&&(a[i]-a[j])>=(-d))
count++;
}
}
}
printf... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | 78770573031ecb1885f9f2e3406d6dc3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
long d;
int n,diff,ctd=0;
int main()
{
scanf("%d %ld",&n,&d);
int a[n];
for(int i=0;i<n;i++)
{
scanf(" %d",&a[i]);
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
diff=(a[i]-a[j])>0?(a[i]-a[j]):(a[j]-a[i]);
if((i!=j)&&(diff<=d))
{
ctd++;
}
}
}
printf("%d",ctd);
}
| |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | aba572eaacc87e091665350f0b399131 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include<stdio.h>
int main()
{
int n,m,a[100000],s=0,j,c,i;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j]){c=a[i];a[i]=a[j];a[j]=c; }
}
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
... | |
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,βa2,β...,βan centimeters. Some soldiers are ... | Output one number β amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d. | C | d7381f73ee29c9b89671f21cafee12e7 | c152766bdc871aae4f9a1ea3c4ebac12 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"brute force"
] | 1286002800 | ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains two integers n and d (1ββ€βnββ€β1000,β1ββ€βdββ€β109) β amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers β heights of all the soldiers in Bob's detachment. These numbers don't exceed 109. | ["6", "6"] | #include <stdio.h>
#include<stdlib.h>
int main() {
int n,d;
scanf("%d %d",&n,&d);
int arr[n];
for(int i=0;i<n;i++){
scanf("%d",&arr[i]);
}
int cnt=0;
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
if(abs(arr[i]-arr[j])<=d){
cnt++;
}
}
}
printf("%d",2*cnt);
return... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.