exec_outcome
stringclasses
1 value
code_uid
stringlengths
32
32
file_name
stringclasses
111 values
prob_desc_created_at
stringlengths
10
10
prob_desc_description
stringlengths
63
3.8k
prob_desc_memory_limit
stringclasses
18 values
source_code
stringlengths
117
65.5k
lang_cluster
stringclasses
1 value
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_time_limit
stringclasses
27 values
prob_desc_sample_outputs
stringlengths
2
796
prob_desc_notes
stringlengths
4
3k
lang
stringclasses
5 values
prob_desc_input_from
stringclasses
3 values
tags
listlengths
0
11
src_uid
stringlengths
32
32
prob_desc_input_spec
stringlengths
28
2.37k
difficulty
int64
-1
3.5k
prob_desc_output_spec
stringlengths
17
1.47k
prob_desc_output_to
stringclasses
3 values
hidden_unit_tests
stringclasses
1 value
PASSED
5d94291a1ff9a6255faa36903cc4dbad
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while(n-->0){ int a=sc.nextInt(); int b=sc.nextInt(); System.out.println(a+b); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
100ba3da6c75012676d338e02e6de7e2
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; import java.io.*; public class abc{ public static void main(String args[]) { Scanner a = new Scanner(System.in); int b = a.nextInt(); while(b-->0) { int c = a.nextInt(),d = a.nextInt(); System.out.println(c+d); } }}
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
db7143ebc9d0f121524f97dd4228f90f
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.Scanner; public class pb2 { public static void main(String args[]) { Scanner in = new Scanner(System.in); int t; t = in.nextInt(); for(int y=1; y<=t; y++) { int a,b; a = in.nextInt(); b = in.nextInt(); System.out.println(a+b); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
4e65ba97eaa00c6751f96dd31b2d5399
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); for (int i=0;i<N;i++){ int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a+b); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
ddb65e8761d6a319dadec3fa049cfe80
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Main { public static void main(String[] args) { Scanner sam = new Scanner(System.in); int t = sam.nextInt(); for(int i=1;i<=t;i++){ int a = sam.nextInt(); int b = sam.nextInt(); System.out.println(a+b); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
eceac47410d7e94835c9d488241726a6
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class trial{ public static void main(String args[])throws Exception{ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int a=sc.nextInt(); int b=sc.nextInt(); System.out.println(a+b); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
ed7b343bbf16b459fdf75929dafb2667
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class codeforces { public static int check(int n) { for(int i=3;i<=n/2;i++) if(n%i==0) return i; return n; } public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); for(int k=0;k<t;k++) { int b=s.nextInt(); int a=s.next...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
63271c69ad3d52a0ddc995298926aef8
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class file{ public static void main(String[] args){ Scanner s=new Scanner(System.in); int test =s.nextInt(); for(int i=0 ;i<test ;i++){ System.out.println(s.nextInt() + s.nextInt()); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
c1f65174d7336415b9ef02fa30beb037
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Main{ public static void main(String [] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ System.out.println(sc.nextInt()+sc.nextInt()); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
655ed15038c6b12c9bf03625d47cdff4
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class S706B{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int a=sc.nextInt(); int b=sc.nextInt(); System.out.println(a+b); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
fbe2733d0a547e53f44c89bb014cb29f
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Cf1351A { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t,a,b; t=sc.nextInt(); while(t>0) { a=sc.nextInt(); b=sc.nextInt(); System.out.println(a+b); t--; } sc.close(); } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
a8ad5be6870f1a94e0aeb301424483c0
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Yash { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) System.out.println(sc.nextInt() + sc.nextInt()); } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
7aca273d2f389e9447de3c31be07c830
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.io.InputStreamReader; import java.util.Scanner; public class AplusB { public static void main(String[] args) { Scanner sc=new Scanner(new InputStreamReader(System.in)); int casos= sc.nextInt(); while(casos-->0) { int a=sc.nextInt(); int b=sc.nextInt(); System.out.println(a+b); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
92a42d0570ea218797cf7e148e7c207f
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class HelloWorld { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t; t = in.nextInt(); while (t!=0) { int a,b; a=in.nextInt(); b=in.nextInt(); int c=a+b; Syste...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
674f6a61142082c0a799c46b9aef8000
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
/* Written by Kabir Kanha Arora @kabirkanha */ import java.util.*; public class Main { static int MOD = 998244353; static long[] fact; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); while (n-- > 0) { int a...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
2bf4b6d7621381cb83a4738514bb4e15
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.lang.*; import java.util.*; public class Main { public static void main(String args[]) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t!=0) { int a=s.nextInt(); int b=s.nextInt(); System.out.println(a+b); t--; ...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
3327dba64d3e8d6400619a4e6940fc5d
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.Scanner; public class A { public static void main(String main[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i<n;i++) { int n1=sc.nextInt(); int n2=sc.nextInt(); int sum=n1+n2; System.out.println(sum); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
efeccad7d16fc74be3aaad98322af025
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Solution{ static Scanner sc = new Scanner(System.in); public static void main(String[] args){ int t = sc.nextInt(); while(t-->0){ solve(); } } public static void solve(){ System.out.println(sc.nextInt() + sc.nextInt()); ...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
0087734b2040ecc977239a917a54270c
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ System.out.println(sc.nextInt() + sc.nextInt()); } } }
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
6660ad4d6df8804fea850a8737feebd0
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.io.*; import java.math.*; import java.util.*; import java.text.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int t; t = cin.nextInt(); while (t-- != 0) { int a, b; a ...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
1fad4d502095456568ae2033d51c3deb
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; import java.lang.*; import java.io.*; import java.util.Scanner; /** * * @author shravan */ public class Main { static boolean prime[]=new boolean[10000001]; public static void sieve() { int n=1000001; for(int i =0;i<n;i++) { prime[i]=true; ...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
164e68c10865219ac93d7b6f8ce39bb8
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.*; public class Main{ public static void main(String[] args){ Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while(t>0){ int a = scn.nextInt(); int b = scn.nextInt(); Syst...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
e41c6deed168229ac6b6d6eff0a9c5e3
train_002.jsonl
1624368900
You are given two integers $$$a$$$ and $$$b$$$. Print $$$a+b$$$.
512 MB
import java.util.Scanner; public final class CodeForces { private static void solution(String[] inputs) { for(String input : inputs) { String[] values = input.split(" "); try { System.out.println(Integer.parseInt(values[0]) + Integer.parseInt(values[1])); ...
Java
["4\n\n1 5\n\n314 15\n\n-99 99\n\n123 987"]
2.0 s
["6\n329\n0\n1110"]
null
Java 11
standard input
[ "implementation" ]
27ddccc777ef9040284ab6314cbd70e7
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a line of two integers $$$a$$$ and $$$b$$$ ($$$-1000 \le a, b \le 1000$$$).
800
Print $$$t$$$ integers — the required numbers $$$a+b$$$.
standard output
PASSED
6ea0605bc3232e6d2f6b9896a082c732
train_002.jsonl
1395502200
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes e...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int size = Integer.parseInt(scanner.nextLine()); String input = scanner.nextLine(); boolean lastLeft = true; int numStanding = 0; int c...
Java
["14\n.L.R...LR..L..", "5\nR....", "1\n."]
1 second
["4", "0", "1"]
NoteThe first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.In the second example case, all pieces fall down since the first piece topples all the other pieces.In the last example case, a single piece has not been pushed in either direction.
Java 11
standard input
[]
54c748dd983b6a0ea1af1153d08f1c01
The first line contains a single integer n (1 ≤ n ≤ 3000), the number of the dominoes in the line. The next line contains a character string s of length n. The i-th character of the string si is equal to "L", if the i-th domino has been pushed to the left; "R", if the i-th domino has been pushed to the right; ".",...
1,100
Output a single integer, the number of the dominoes that remain vertical at the end of the process.
standard output
PASSED
d058efc731fd029c8746342b152485b8
train_002.jsonl
1395502200
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes e...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class ar { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { ...
Java
["14\n.L.R...LR..L..", "5\nR....", "1\n."]
1 second
["4", "0", "1"]
NoteThe first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.In the second example case, all pieces fall down since the first piece topples all the other pieces.In the last example case, a single piece has not been pushed in either direction.
Java 11
standard input
[]
54c748dd983b6a0ea1af1153d08f1c01
The first line contains a single integer n (1 ≤ n ≤ 3000), the number of the dominoes in the line. The next line contains a character string s of length n. The i-th character of the string si is equal to "L", if the i-th domino has been pushed to the left; "R", if the i-th domino has been pushed to the right; ".",...
1,100
Output a single integer, the number of the dominoes that remain vertical at the end of the process.
standard output
PASSED
cbce0416f2d13993ea16fe136ae79a8a
train_002.jsonl
1395502200
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes e...
256 megabytes
import java.io.*; import java.util.*; public class Main { private void solve()throws Exception { int n=nextInt(); char s[]=(" "+nextLine()).toCharArray(); int cnt=n; int i=1; while(i<=n && (s[i]!='L' && s[i]!='R')) i++; if(i<=n && s[i]=='L') { cnt-=i; i++; } for(;i<=n;i++) { if(s[i]=...
Java
["14\n.L.R...LR..L..", "5\nR....", "1\n."]
1 second
["4", "0", "1"]
NoteThe first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.In the second example case, all pieces fall down since the first piece topples all the other pieces.In the last example case, a single piece has not been pushed in either direction.
Java 11
standard input
[]
54c748dd983b6a0ea1af1153d08f1c01
The first line contains a single integer n (1 ≤ n ≤ 3000), the number of the dominoes in the line. The next line contains a character string s of length n. The i-th character of the string si is equal to "L", if the i-th domino has been pushed to the left; "R", if the i-th domino has been pushed to the right; ".",...
1,100
Output a single integer, the number of the dominoes that remain vertical at the end of the process.
standard output
PASSED
e324fddc38eab9db9613cf4ee5b27dd0
train_002.jsonl
1395502200
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes e...
256 megabytes
import java.util.*; public class Domino { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int len = Integer.parseInt(scan.nextLine()); String dominoes = scan.nextLine(); int index = 0; int right = -1; int count = 0; int total =...
Java
["14\n.L.R...LR..L..", "5\nR....", "1\n."]
1 second
["4", "0", "1"]
NoteThe first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.In the second example case, all pieces fall down since the first piece topples all the other pieces.In the last example case, a single piece has not been pushed in either direction.
Java 11
standard input
[]
54c748dd983b6a0ea1af1153d08f1c01
The first line contains a single integer n (1 ≤ n ≤ 3000), the number of the dominoes in the line. The next line contains a character string s of length n. The i-th character of the string si is equal to "L", if the i-th domino has been pushed to the left; "R", if the i-th domino has been pushed to the right; ".",...
1,100
Output a single integer, the number of the dominoes that remain vertical at the end of the process.
standard output
PASSED
ba0cc0393f981905c5a1bec758922324
train_002.jsonl
1395502200
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes e...
256 megabytes
/* -------> Bismillahir Rahmanir Rahim <------*/ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class A { private static final FastScanner in = new FastScanner(); // private static final Scanner in = new Scanner(System.in); public s...
Java
["14\n.L.R...LR..L..", "5\nR....", "1\n."]
1 second
["4", "0", "1"]
NoteThe first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.In the second example case, all pieces fall down since the first piece topples all the other pieces.In the last example case, a single piece has not been pushed in either direction.
Java 11
standard input
[]
54c748dd983b6a0ea1af1153d08f1c01
The first line contains a single integer n (1 ≤ n ≤ 3000), the number of the dominoes in the line. The next line contains a character string s of length n. The i-th character of the string si is equal to "L", if the i-th domino has been pushed to the left; "R", if the i-th domino has been pushed to the right; ".",...
1,100
Output a single integer, the number of the dominoes that remain vertical at the end of the process.
standard output
PASSED
2ac73a26b38fcd53591001b89c3c746c
train_002.jsonl
1395502200
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes e...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Arrays; import java.util.Iterator; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug...
Java
["14\n.L.R...LR..L..", "5\nR....", "1\n."]
1 second
["4", "0", "1"]
NoteThe first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.In the second example case, all pieces fall down since the first piece topples all the other pieces.In the last example case, a single piece has not been pushed in either direction.
Java 11
standard input
[]
54c748dd983b6a0ea1af1153d08f1c01
The first line contains a single integer n (1 ≤ n ≤ 3000), the number of the dominoes in the line. The next line contains a character string s of length n. The i-th character of the string si is equal to "L", if the i-th domino has been pushed to the left; "R", if the i-th domino has been pushed to the right; ".",...
1,100
Output a single integer, the number of the dominoes that remain vertical at the end of the process.
standard output
PASSED
84d78ce6a7883cad20cff0e94b7b815b
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { try (BufferedInputStream in = new BufferedInputStream(System.in); PrintWriter out = new ...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
009b23edd0ce44a306592070d0a99c9a
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.lang.System; import java.util.Scanner; import java.lang.Math; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t>0){ int n=s.nextInt(); int []a=new int[n]; int coun...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
429c39c2fe58090c7e41a869ad0020a2
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class B { public static void main(String[] args) { FastScanner sc = new FastScanner(); int t = sc.nextInt(); for(int tt =0 ;tt < t ; tt++) { int n = sc.nextInt(); int a[] = sc.read...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
1126a593c877879bb5a99c65540311d6
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); for(int t=input.nextInt();t>0;t--){ int i=input.nextInt(); int a[]=new int[i]; int sum=0; for(int j=0;j<i;j++) { a[j]=input.nextInt(); } for(...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
7fb60663184dc304e871407cc64ded50
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t--!=0){ int a=sc.nextInt(), l=0,r=a-1,count=0; int[] arr = new int[a]; for(int i=0;i<a;i++){arr[i]= sc....
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
6e628c41695eb1132999587561df2739
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.*; public class prob { public static void main(String args[]) { Scanner d=new Scanner(System.in); int t,n,flag=0,k=0,m=0,i,j; t=d.nextInt(); while(t>0) { flag=0; k=0; m=0; j=0; n=d.nextInt(); ...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
a00ada1def36b3906070faa7059e594d
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.*; import java.io.*; public class October_virtual { public static void main(String args[]) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); StringBuilder sb=new StringBuilder(); while(t>0){ int n=I...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
5ebadc00d4d4cbf8156736ae44eec18b
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int tc = s.nextInt(); for(int t = 0;t < tc;t++) { int n = s.nextInt(); int[] input = new int[n]; for(int i = 0;i < n;i++) input[i] = s.nextInt...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
7b41770f14bf1dad7b527f06b3011f57
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.io.*; public class B { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while (t-- > 0) { int n = Integer.parseInt(br.readLine()); String[] in = br.readLine().split(" "...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
5c6e0b2c83d4436cc27eba15380fe658
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import javax.crypto.AEADBadTagException; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.nio.BufferOverflowException; import java.util.*; public class Main { public static void main(String[] args) throws IOException { ...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
ae948cbc849200d9ceeefb44794e36a0
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { static void iPA(int arr []){ for(int i=0; i<arr.length; i++){ System.out.print(arr[i]...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
c37934af7bb66d178dcaf11208b440f8
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.Scanner; public class test { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int numTest=sc.nextInt(); int counter=0; int[] output=new int[numTest]; while (counter<numTest) { int size=sc.nextInt(); int[] array=new int[size]; int check=0; int o...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
d7c08d7177fbbcb8781b37ccff3042ca
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { static void sort(int[] ar) { ArrayList<Integer> al=new ArrayList<>(); for (int i=0;i<ar.length;i++) al.add(ar[i]); Collections.sort(al); for (int i=0; i<ar.length; i++) ar[i]=al.get(i); } public static void main(String[] args) { // TODO Au...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
1457a2e25d6921809877941fc2ef5947
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.Scanner; public class Hackerrank { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int c=0,d=0,sifirsayi=0; int cases= scan.nextInt(); int a=cases; int elemansayi; int sonuc[]= new int[57]; for(int h=0;h<a;h++) { elemansayi= scan.nextInt(); ...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
d87fc50efd1e021a4d9a751f81e9f97b
train_002.jsonl
1603204500
There is a bookshelf which can fit $$$n$$$ books. The $$$i$$$-th position of bookshelf is $$$a_i = 1$$$ if there is a book on this position and $$$a_i = 0$$$ otherwise. It is guaranteed that there is at least one book on the bookshelf.In one move, you can choose some contiguous segment $$$[l; r]$$$ consisting of books ...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); // System.out.println("t" + t); for (int t_ = 0; t_ < t; t_++){ int n = in.nextInt(); // System.out.println("n" + n);...
Java
["5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1"]
1 second
["2\n0\n2\n4\n1"]
NoteIn the first test case of the example, you can shift the segment $$$[3; 3]$$$ to the right and the segment $$$[4; 5]$$$ to the right. After all moves, the books form the contiguous segment $$$[5; 7]$$$. So the answer is $$$2$$$.In the second test case of the example, you have nothing to do, all the books on the boo...
Java 11
standard input
[ "implementation", "greedy" ]
1c07882651ef6ebfc05e777d562e28b9
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of places on a bookshelf. The second line of the test case contains $$$n$$$ intege...
800
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
standard output
PASSED
a2f77d36e22145f3043105fb99062ba4
train_002.jsonl
1425279600
Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences.Let's assume that strings s and t have the same length n, then the function h(s, t) is defined as the number of positions in which ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static int arr[], N, K; static boolean adj[][]; static BigInteger dp[][]; static boolean reach[][]; static String str1[]; static String str2[]; static int mod =(int) (1e9 + 7); public static ...
Java
["1\nC", "2\nAG", "3\nTTT"]
2 seconds
["1", "4", "1"]
NotePlease note that if for two distinct strings t1 and t2 values ρ(s, t1) и ρ(s, t2) are maximum among all possible t, then both strings must be taken into account in the answer even if one of them can be obtained by a circular shift of another one.In the first sample, there is ρ("C", "C") = 1, for the remaining strin...
Java 11
standard input
[ "math", "strings" ]
f35c042f23747988f65c5b5e8d5ddacd
The first line of the input contains a single integer n (1 ≤ n ≤ 105). The second line of the input contains a single string of length n, consisting of characters "ACGT".
1,500
Print a single number — the answer modulo 109 + 7.
standard output
PASSED
eecea7cc17a1c33a99a68d8e821a7a4a
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.*; import java.util.ArrayList; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); int m = sc.next...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
2a485f145a6e2fb3671ef618d9f4ab16
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.*; import java.util.*; public class CP { public static void main(String[] args) throws Exception { /*new Thread(null, new Runnable() { @Override public void run() { try { new Solver().solve(); } catch (Exception e) {...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
306e04004e982bcd6eef71645ca5172d
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.*; import java.util.*; public class Solution { static int[][] arr; static int[][][] flagPoint; // mark start of flag part static int[][] length; static int n; public static void compress(int col) { ArrayList<Integer> data = new ArrayList<>(); ArrayList<Integer> s...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
160e107c94c6291a130385e5f66c6c5b
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringJoiner; import java.util.StringTokenizer; import java.util.function.Function; public class MainC { static int H, W; static char[][] B; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); H ...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
13b874b39e45ab23a739432d3e143896
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; public class CFlag { public static void main(String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String [] input = br.rea...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
f371f7dc5703ced29bf428a701a144cb
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static int count(int counts[][][], char ch, int startx, int starty, int endx, int endy) { int idx = ch - 'a'; int res = counts[endx][endy][idx]; if (startx - 1 >= 0) { res -...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
7a52f373c83368ee2674cad136577c74
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.*; import java.util.*; public class Main { private static void execute(ContestReader reader, PrintWriter out) { int n = reader.nextInt(); int m = reader.nextInt(); char[][] map = new char[n][]; for (int i = 0; i < n; i++) { map[i] = reader.next().toCharArray(); } out.prin...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
de215fdbaf9ed49fd86c4e62e561f042
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.reflect.Array; public class C { static final int MOD = 1000000007; // 1e9 + 7 static final boolean AUTO_FLUSH = false; // slow if true // int = num(); // long = ll(); // string = next(); // a string line = line(); // -------...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
7f1898010d63c497c077eecfbf2d3951
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Comparator; public class d extends PrintWriter{ static BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); // static Scanner...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
c466b40052be2b6bf1321076b13a2687
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.*; import java.io.*; import java.math.*; public class C { static class FastReader { StringTokenizer str; BufferedReader br; FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { if (str == null...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
84d0ee36b33db64eb9cdff208a51c06e
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author cunbidun */ public class M...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
8f2bf094f0c40b1935e2052db46e4f38
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.BigInteger; import java.util.regex.*; public class Myclass { static ArrayList a[]=new ArrayList[3000001]; static int[][][] dp; static int len[][]; static Segment seg[]; static boolean f(int i,int j) { re...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
058c07cb3d42d7b0fc8f9e44644536e8
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
//package learning; import java.util.*; import java.io.*; import java.lang.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Nitslocal { static ArrayList<String> s1; static boolean[] prime; static int n = (int)1e7; static void sieve() { Arrays.fill(prime , true); prime[...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
5a07ae2fd8f0acf92d470513dec0885e
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.*; import java.lang.*; public class Main { public static Scanner in ; public static int solve(int n,int m){ int res=0; int arr[][] = new int[n][m]; for(int i=0; i<n; i++){ char ch[] = in.next().toCharArray(); for(int j=0; j<m; j++){ arr[i][j]=ch[j]-'a'...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
0b470697793bde665c007df64d4e7ea1
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.*; import java.lang.*; public class Main { public static Scanner in ; public static int solve(int n,int m){ int res=0; int arr[][] = new int[n][m]; for(int i=0; i<n; i++){ char ch[] = in.next().toCharArray(); for(int j=0; j<m; j++){ arr[i][j]=ch[j]-'a'...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
c2d28233f21ca4d37d2d60e9407de2e8
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
b7676808f8266fdcadbfffd8abf68a9b
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
0f07d6eb2235b9765ad8bae1c20ee56e
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.stream.IntStream; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.util.stream.Stream; import ja...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
19ecb8b22c4a96148d13d4fe4fd9b01e
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*;...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
36ed854de2bb552bae9096f9b2b36945
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Vaibhav Pulastya */ public...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
b35b316126895f763b0615b3d0a1ce30
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { TaskA task = new TaskA(); task.solve(); } static class TaskA { Scanner scanner; long a, b, c; public void solve() { scanner = new Scanne...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
fbbc4e939c92b5d920ba32dfa10b620e
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.*; import java.math.BigInteger; public class Boss { //static long c=0; //static HashMap<Integer,Long> hm2=new HashMap<Integer,Long>(); public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); sc.nextLine(); char a[][]=new char[n]...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
43f2e909f662b1b329af4286f0f2126c
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.Scanner; public class Flag { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String[] line = scanner.nextLine().split(" "); int n = Integer.parseInt(line[0]); int m = Integer.parseInt(line[1]); char[][] blanket = new char[...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
39e2a080c9a76a54c00be778cf5cb75c
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Solution { public static void main(String[] args) { new Solution().run(); } public void run() { Scanner file = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int R = file.nextInt(); int C = file.nextInt(...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
e7199854e09d6668dd33923988b5658b
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author J...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
4d3a4ce19cf7229f3a4f91f496733d6a
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Random; import java.io.PrintWriter; /* Solution Created: 18:17:23 05/07/2019 Custom Compet...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
49511ff36a4e969dbefb2bf3854c2365
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.min; import static java.util.Collections.sort; public class Main { FastScanner in; PrintWriter out; private void solve() throws IOException { int n = in.nextInt(), m = in.nextInt(); char[][] s = new char[n][]; for ...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
8c63f9df7fcd304ea225603d4da01f7b
train_002.jsonl
1560677700
Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $$$n \cdot m$$$ colored pieces that form a rectangle with $$$n$$$ rows and $$$m$$$ columns. The colored pieces attracted Innokenty's attention so he immediate...
512 megabytes
import java.util.*; import java.io.*; public final class C1181 { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder str = new StringBuilder(); String[] split = br.readLine().split(" "); int n = Integer.par...
Java
["4 3\naaa\nbbb\nccb\nddd", "6 1\na\na\nb\nb\nc\nc"]
2 seconds
["6", "1"]
Note  The selected subrectangles are flags in the first example.
Java 8
standard input
[ "dp", "combinatorics", "implementation", "brute force" ]
edc54435b62e76287da94836ad3aa86b
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1\,000$$$) — the number of rows and the number of columns on the blanket. Each of the next $$$n$$$ lines contains $$$m$$$ lowercase English letters from 'a' to 'z' and describes a row of the blanket. Equal letters correspond to equal colors, di...
1,900
In the only line print the number of subrectangles which form valid flags.
standard output
PASSED
d2ad5d630603b6cfcc6718f53febd223
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.*; import java.util.*; public class Solution { private IO io; private int ioMode = -1; private String problemName = ""; private final String mjArgument = "master_j"; public static void main(String programArguments[]) throws IOException{ if(programArguments != null && program...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
9caa78eeec6574e7979581e0e1348df5
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.util.*; public class Main { static class Genre implements Comparable<Genre>{ final int n; int stress; Genre(int n, int stress){ this.n = n; this.stress = stress; } public int compareTo(Genre other){ int cmp = stress - other.stress; if (cmp == 0){ cmp = n - other.n; } return...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
a795a94f8c4b37c0501a481500e12268
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { private static String[] readInput() { String[] result = new String[2]; Scanner sc = new Scanner(System.in); result[0] = sc.nextLine(); result[1] = sc.nextLine(); sc.close...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
c680d62d62305eb27f4ce9376c9fcfe2
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
4415133ce4c16c4bdf15e5b75dcd7b9a
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import static java.lang.reflect.Array.*; import static java.util.Arrays.*; import java.io.*; import java.lang.reflect.*; import java.util.*; public class C { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; public C () { int N = sc.nextInt(); int K = sc.nextInt(); Integer...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
198375b1dd0245e38c4c231431956178
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.*; import java.lang.reflect.*; public class C { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; public C () { int N = sc.nextInt(); int K = sc.nextInt(); Integer [] A = sc.nextInts(); int [] C = new int [1+K]; int a = -1, b = -1, c = -1; for (in...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
e2d50234d5fb449145e36980d72988f4
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.*; import java.lang.reflect.*; public class C { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; public C () { int N = sc.nextInt(); int K = sc.nextInt(); Integer [] A = sc.nextInts(); int [] C = new int [1+K]; int a = A[0], b = -1; for (int i = 1...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
0e2ce17807176eddf94bb290a9430fed
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.File; import java.util.Arrays; import java.util.Formatter; import java.util.Scanner; import java.util.concurrent.CountDownLatch; // In the name of The Friend // CONTEST TEMPLATE ---- SmileToAzrael ......... bagherbal /** * * @author ali */ public class CC { public static void main(String[] arg...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
9254bbce0a7e27362dd73aca7476d6b4
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.util.*; import static java.lang.System.*; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] A = new int[n]; HashMap<Integer, Pair> hm = new HashMap<Integer, Pair>(); for(int i = 0; i < n; i++) ...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
da2c4b29042048a8e49da8b97ef0aac5
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.InputMismatchException; /** * http://codeforces.com/contest/447/problem/C * * @author sultan.of.swing * */ public class TaskC { public FasterScanner mFScanner; public PrintWriter m...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
47daf5b4aff00f1ded38c1f38ad51d87
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class CF250C { public static void main(String[] args) throws Exception { new CF250C().solve(); } private void solve() throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
120052ad3748b3f8b46a72af3ec2b040
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.Locale; import java.io.OutputStream; import java.io.PrintWriter; import java.util.RandomAccess; import java.util.AbstractList; import java.io.Writer; import java.util.List; import java.io.IOException; import java.math.BigDecimal; import ...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
fc0b1bd8b2ca99e818b087dee4b511b3
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.Locale; import java.util.StringTokenizer; public class c { void do_solve() { int n = nextInt(); int k = next...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
950d83627dcbe53d970ab2ca7e57f28f
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { public static void main(String[] augs) { Scanner cin=new Scanner(new BufferedInputStream(System.in)); int n=cin.nextInt(), k=cin.nextInt(), cnt[]=new int[k+2], ans=1; ...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
41c45854fa8852e25c30f450cb59fa83
train_002.jsonl
1353938400
A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.On the i-th day the festival will show a movie of genre ai. We know that a movie of each of k genres occurs in the festival programm...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { public static void main(String[] augs) { Scanner cin=new Scanner(new BufferedInputStream(System.in)); int n=cin.nextInt(), k=cin.nextInt(), cnt[]=new int[k+2], ans=1; ...
Java
["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2"]
2 seconds
["3", "1"]
NoteIn the first sample if we exclude the movies of the 1st genre, the genres 2, 3, 2, 3, 3, 3 remain, that is 3 stresses; if we exclude the movies of the 2nd genre, the genres 1, 1, 3, 3, 3, 1, 1, 3 remain, that is 3 stresses; if we exclude the movies of the 3rd genre the genres 1, 1, 2, 2, 1, 1 remain, that is 2 stre...
Java 7
standard input
[ "greedy" ]
6ef8200d05dd5eb729edceb62e393c50
The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 105), where n is the number of movies and k is the number of genres. The second line of the input contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ k), where ai is the genre of the i-th movie. It is guaranteed that each number fro...
1,600
Print a single number — the number of the genre (from 1 to k) of the excluded films. If there are multiple answers, print the genre with the minimum number.
standard output
PASSED
154d1f4a4f147ca4f275258326f70aed
train_002.jsonl
1567175700
Authors have come up with the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You are given two permutations of its indices (not necessary equal) $$$p$$$ and $$$q$$$ (both of length $$$n$$$). Recall that the permutation is the array of length $$$n$$$ which contains each integer from $$$1$$$ to $$$n$$$ exac...
256 megabytes
// Imports import java.util.*; import java.io.*; public class F1213 { static ArrayList<Integer>[] graph; static ArrayList<Integer>[] reverse; static Stack<Integer> ret; static boolean[] visited; public static void dfs1(int v) { for(int i : graph[v]) { if(!visited[i]) { ...
Java
["3 2\n1 2 3\n1 3 2"]
2 seconds
["YES\nabb"]
null
Java 8
standard input
[ "greedy", "graphs", "dsu", "implementation", "data structures", "dfs and similar", "strings" ]
591846c93bd221b732c4645e50fae617
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5, 1 \le k \le 26$$$) — the length of the string and the number of distinct characters required. The second line of the input contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are di...
2,100
If it is impossible to find the suitable string, print "NO" on the first line. Otherwise print "YES" on the first line and string $$$s$$$ on the second line. It should consist of $$$n$$$ lowercase Latin letters, contain at least $$$k$$$ distinct characters and suit the given permutations. If there are multiple answers,...
standard output
PASSED
fcc27214c151dcb284cd4dcc4eb097a8
train_002.jsonl
1567175700
Authors have come up with the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You are given two permutations of its indices (not necessary equal) $$$p$$$ and $$$q$$$ (both of length $$$n$$$). Recall that the permutation is the array of length $$$n$$$ which contains each integer from $$$1$$$ to $$$n$$$ exac...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class Codeforces{ public static void main(String[] args) { Scanner sc = new Scanner (System.in); final int n = sc.nextInt(); final int k = sc.nextInt(); ArrayList<ArrayList<Integer>> graph = new Arra...
Java
["3 2\n1 2 3\n1 3 2"]
2 seconds
["YES\nabb"]
null
Java 8
standard input
[ "greedy", "graphs", "dsu", "implementation", "data structures", "dfs and similar", "strings" ]
591846c93bd221b732c4645e50fae617
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5, 1 \le k \le 26$$$) — the length of the string and the number of distinct characters required. The second line of the input contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are di...
2,100
If it is impossible to find the suitable string, print "NO" on the first line. Otherwise print "YES" on the first line and string $$$s$$$ on the second line. It should consist of $$$n$$$ lowercase Latin letters, contain at least $$$k$$$ distinct characters and suit the given permutations. If there are multiple answers,...
standard output
PASSED
02c6855ece3fa7264b2f1207cc21b4ef
train_002.jsonl
1567175700
Authors have come up with the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You are given two permutations of its indices (not necessary equal) $$$p$$$ and $$$q$$$ (both of length $$$n$$$). Recall that the permutation is the array of length $$$n$$$ which contains each integer from $$$1$$$ to $$$n$$$ exac...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Stack; import java.util.StringTokenizer; public class B { static PrintWriter pw = new PrintWriter(System.out); static ArrayList<Integer>[] adjL...
Java
["3 2\n1 2 3\n1 3 2"]
2 seconds
["YES\nabb"]
null
Java 8
standard input
[ "greedy", "graphs", "dsu", "implementation", "data structures", "dfs and similar", "strings" ]
591846c93bd221b732c4645e50fae617
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5, 1 \le k \le 26$$$) — the length of the string and the number of distinct characters required. The second line of the input contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are di...
2,100
If it is impossible to find the suitable string, print "NO" on the first line. Otherwise print "YES" on the first line and string $$$s$$$ on the second line. It should consist of $$$n$$$ lowercase Latin letters, contain at least $$$k$$$ distinct characters and suit the given permutations. If there are multiple answers,...
standard output
PASSED
23b6a1d338e9406c31cf5f08ba32d244
train_002.jsonl
1567175700
Authors have come up with the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You are given two permutations of its indices (not necessary equal) $$$p$$$ and $$$q$$$ (both of length $$$n$$$). Recall that the permutation is the array of length $$$n$$$ which contains each integer from $$$1$$$ to $$$n$$$ exac...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Stack; import java.util.StringTokenizer; public class B { static PrintWriter pw = new PrintWriter(System.out); static ArrayList<Integer>[] adjList; public static void main(Strin...
Java
["3 2\n1 2 3\n1 3 2"]
2 seconds
["YES\nabb"]
null
Java 8
standard input
[ "greedy", "graphs", "dsu", "implementation", "data structures", "dfs and similar", "strings" ]
591846c93bd221b732c4645e50fae617
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5, 1 \le k \le 26$$$) — the length of the string and the number of distinct characters required. The second line of the input contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are di...
2,100
If it is impossible to find the suitable string, print "NO" on the first line. Otherwise print "YES" on the first line and string $$$s$$$ on the second line. It should consist of $$$n$$$ lowercase Latin letters, contain at least $$$k$$$ distinct characters and suit the given permutations. If there are multiple answers,...
standard output
PASSED
e0f744720f176d4829cf98f182ffff79
train_002.jsonl
1567175700
Authors have come up with the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You are given two permutations of its indices (not necessary equal) $$$p$$$ and $$$q$$$ (both of length $$$n$$$). Recall that the permutation is the array of length $$$n$$$ which contains each integer from $$$1$$$ to $$$n$$$ exac...
256 megabytes
import java.util.*; import java.io.*; public class F { public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = scanner.nextInt(); int k = scanner.nextInt(); int[] p = new int[n]; int[] q ...
Java
["3 2\n1 2 3\n1 3 2"]
2 seconds
["YES\nabb"]
null
Java 8
standard input
[ "greedy", "graphs", "dsu", "implementation", "data structures", "dfs and similar", "strings" ]
591846c93bd221b732c4645e50fae617
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5, 1 \le k \le 26$$$) — the length of the string and the number of distinct characters required. The second line of the input contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are di...
2,100
If it is impossible to find the suitable string, print "NO" on the first line. Otherwise print "YES" on the first line and string $$$s$$$ on the second line. It should consist of $$$n$$$ lowercase Latin letters, contain at least $$$k$$$ distinct characters and suit the given permutations. If there are multiple answers,...
standard output
PASSED
2af0612d5f20566265c6417c30a2701d
train_002.jsonl
1561710000
Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word...
256 megabytes
import java.util.*; import java.math.BigInteger; public class Boss { //static long c=0; //static HashMap<Integer,Long> hm2=new HashMap<Integer,Long>(); public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); double a[]=new double[n]; double b[]=new double[n]; doubl...
Java
["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"]
1 second
["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"]
NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
6059cfa13594d47b3e145d7c26f1b0b3
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| &lt; 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num...
1,500
In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|&lt;1$$$ must be met. If there are multiple answers, print any.
standard output
PASSED
76d62fbfa1c88bed4d74ae81e0ea2757
train_002.jsonl
1561710000
Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word...
256 megabytes
import java.util.*; import java.lang.Math; public class mainClass { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); double rem = 0.0; //String exportString=""; for (int i=0; i<n; i++) { double r=sc.nextDouble()...
Java
["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"]
1 second
["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"]
NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
6059cfa13594d47b3e145d7c26f1b0b3
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| &lt; 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num...
1,500
In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|&lt;1$$$ must be met. If there are multiple answers, print any.
standard output
PASSED
d3a00f51ec2d3de887ab205d5864be99
train_002.jsonl
1561710000
Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word...
256 megabytes
import java.util.*; import java.lang.Math; public class mainClass { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); double rem = 0.0; //String exportString=""; for (int i=0; i<n; i++) { double r=sc.nextDouble()...
Java
["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"]
1 second
["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"]
NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
6059cfa13594d47b3e145d7c26f1b0b3
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| &lt; 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num...
1,500
In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|&lt;1$$$ must be met. If there are multiple answers, print any.
standard output
PASSED
fe6a492404f9df3e6cbdded9ac73e14c
train_002.jsonl
1561710000
Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word...
256 megabytes
import java.util.*; import java.lang.*; // StringBuilder uses java.lang public class mainClass { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); double rem = 0.0; StringBuilder exportString= new StringBuilder(); for (int...
Java
["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"]
1 second
["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"]
NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
6059cfa13594d47b3e145d7c26f1b0b3
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| &lt; 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num...
1,500
In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|&lt;1$$$ must be met. If there are multiple answers, print any.
standard output
PASSED
39f33b2ebf70b79e26b6806473f87765
train_002.jsonl
1561710000
Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word...
256 megabytes
import java.util.*; import java.io.*; public class Dy { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new Data...
Java
["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"]
1 second
["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"]
NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
6059cfa13594d47b3e145d7c26f1b0b3
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| &lt; 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num...
1,500
In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|&lt;1$$$ must be met. If there are multiple answers, print any.
standard output
PASSED
1fcc931c052cc4badd09aa069c0730f0
train_002.jsonl
1561710000
Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Java
["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"]
1 second
["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"]
NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
6059cfa13594d47b3e145d7c26f1b0b3
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| &lt; 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num...
1,500
In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|&lt;1$$$ must be met. If there are multiple answers, print any.
standard output
PASSED
60efa253ab98de3c112e3d91a61b630f
train_002.jsonl
1561710000
Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class prime { static class Reader { final private int BUFFER_SIZE = 1 << 16; private Data...
Java
["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"]
1 second
["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"]
NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Java 8
standard input
[ "constructive algorithms", "greedy", "math" ]
6059cfa13594d47b3e145d7c26f1b0b3
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| &lt; 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num...
1,500
In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|&lt;1$$$ must be met. If there are multiple answers, print any.
standard output