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
18c4877eaba69d3bd51905f2fbaf3775
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
//package cp; import java.io.*; import java.util.*; import java.util.Map.Entry; public class CF { static FastReader sc = new FastReader(); public static void main(String[] args) { int t = sc.nextInt(); while (t-- > 0) { solve(); } //solve(); } //@Suppr...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
690c5c86b7eebc1135cccaacce0a0852
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
//package cp; import java.io.*; import java.util.*; import java.util.Map.Entry; public class CF { static FastReader sc = new FastReader(); public static void main(String[] args) { int t = sc.nextInt(); while (t-- > 0) { solve(); } //solve(); } static void s...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
23225fa9b55069f3fa51b1a21ee29471
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.awt.dnd.InvalidDnDOperationException; import java.io.*; import java.lang.reflect.Array; import java.nio.charset.CharsetEncoder; import java.util.*; public class Main { private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; private static final boolean OFFLINE_WITHOU...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
0978da6ae4439f466170521230c3e7c0
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.io.*; import java.util.*; public class ques1 { public static void main(String[] args)throws Exception{ new ques1().run();} long mod=1000000000+7; void solve() throws Exception { for(int ii=ni();ii>0;ii--) { int N=ni(); String s[]=new String[N]; long c[]=new long[26]; for (int i = 0; ...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
416ccdc9ae64cfe24f269746fadaade4
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int t=scan.nextInt(); while(t-->0) { int n=scan.nextInt(); int[] arr = new int[26]; for(int ...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
2c7897536ad6235e3ed7f7124ea1f921
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class CP{ public static OutputStream out=new BufferedOutputStream(System.out); static Scanner sc=new Scanner(System.in); static long mod=1000000007l; static int INF=10000000; static int[] rr=new int[]{1, 0, -1, 0}; ...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
0868e9ff2a6211ade6cbb376812014bc
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while (t-- > 0) { int n = scn.nextInt(); String[] arr = new String[n]; for (int i = 0; i < n; i+...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
3486915bc48ea068162441a87c934f56
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
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){ int n = sc.nextInt(); HashMap<Character,Integer> map = new HashMap<Character,Integer>(); for(int p=0;p<n;p++){ ...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
a071bfeb4b59ecee9acde31744bdd876
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws Exception { BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(buffer.readLine()); while(N-- > 0){ int size = Integer.p...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
dc95829b144c699491bb4c88e1b79b16
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.*; public class A { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); x:while(t-->0) { int n = scan.nextInt(); // String a[] = new String[n]; String s = ""; for(int i =0;i<n;i++) s += scan.next(); HashMap<Character,Intege...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
8c98a0fe170146c3b3cae5ce58208cb7
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
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 { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader ...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
cbb59ab510c1f1fa16c74f5600139142
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.io.*; import java.util.*; import java.util.Map.Entry; public class A { public static void main(String[] agrs) { FastScanner sc = new FastScanner(); int yo = sc.nextInt(); while(yo-->0) { int n = sc.nextInt(); String[] arr = new String[n]; String sum = ""; for(int i = 0; i < n; i++) { ...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
f8241da0df96d0c776be23f8146207ac
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.io.*; import java.util.*; public class Ishu { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int t=scan.nextInt(); while(t-->0) { int n=scan.nextInt(); String str; int[] a = new int[26]; int i; for(i=0;i<n;++i) { str=scan.next(); for(int j=0;j<str.len...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
f028e2d80aab7bfe3f30b5aa74a3f787
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A { public static void main(String[] args) { FastReader reader = new FastReader(); int tests = reader.nextInt(); for(int test = 1; test <= tests; test...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
995a542ec451f1c3285756fcdad03a82
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.Scanner; public class Main { public static String check(int[] ascii,int n) { for(int i=0;i<ascii.length;i++) { if(ascii[i]%n!=0) { return "NO"; } } return "YES"; } public static void main(String[] args) { Scanner sc=new ...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
a758761d3fdfd9b284d527b4e35e27dc
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.*; import java.util.function.LongFunction; public class test{ public static void main(String args[]) { Scanner take=new Scanner(System.in); int t=take.nextInt(); String s[]; int n,i,j,a[],k; while(t--!=0) { n=take.nextInt(); s=new String[n]; a=new int[26]; for(i=0;i<n;i++) s[i...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
ed36c9dc7d00a1760ae129720bb51876
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.*; import java.util.function.LongFunction; public class test{ public static void main(String args[]) { Scanner take=new Scanner(System.in); int t=take.nextInt(); String s[]; int n,i,j,a[]; while(t--!=0) { n=take.nextInt(); s=new String[n]; a=new int[26]; for(i=0;i<n;i++) s[i]=...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
b5555133bc1e6215b00a0d54ad3c2296
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /* javac Main.java java Main <input.txt> output.txt */ public class Main { public static void process()throws IOException { int n=ni(); int p=n; int freq[]=new int[26]; Arrays.fill(freq,0); while(n-->0) { St...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
c96c6e293775be3f6c826515c2c8133d
train_000.jsonl
1598798100
You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it po...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t>0){ t--; int n= sc.nextInt(); String s[] = new String[n] ; for(int i=0;i<n;i++){ s[i] = sc.n...
Java
["4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first test case, you can do the following: Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the firs...
Java 11
standard input
[ "greedy", "strings" ]
3d6cd0a82513bc2119c9af3d1243846f
The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths ...
800
If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.
standard output
PASSED
8fe0dd472a76d1fbce7731c6196e7884
train_000.jsonl
1336145400
The Great Mushroom King descended to the dwarves, but not everyone managed to see him. Only the few chosen ones could see the King.We know that only LCM(k2l + 1, k2l + 1 + 1, ..., k2r + 1) dwarves can see the Great Mushroom King. Numbers k, l, r are chosen by the Great Mushroom King himself in some complicated manner w...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util...
Java
["2\n3 1 10 2\n5 0 4 3"]
3 seconds
["0\n0"]
NoteWe consider that LCM(a1, a2, ..., an) represents the least common multiple of numbers a1, a2, ..., an.We consider that x0 = 1, for any x.
Java 8
standard input
[ "number theory", "math" ]
1c0dbbcfbf5e9ded42e86660272dc8e3
The first line contains the single integer t (1 ≤ t ≤ 105) — the number of the King's visits. Each of the following t input lines contains four space-separated integers ki, li, ri and pi (1 ≤ ki ≤ 106; 0 ≤ li ≤ ri ≤ 1018; 2 ≤ pi ≤ 109) — the numbers, chosen by the Great Mushroom King and the prime module, correspondin...
2,600
For each visit print the answer on a single line — the remainder of dividing the number of the dwarves who can see the King this time, by number pi. Print the answers for the visits in the order, in which the visits are described in the input.
standard output
PASSED
35a85b7dc2bafd3ad1ed1352c75bb957
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 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; import java.util.List; import java.util.PriorityQueue; public class Main { public static PriorityQueue<WeightedEdge> pq; public static int ...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
e740796916c8c018be9ea8d921b83444
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
import java.io.*; import java.util.*; public final class alphaRnd20_C { static Scanner sc=new Scanner(System.in); static PrintWriter out=new PrintWriter(System.out); static ArrayList<Node>[] a; static int n,m; static long[] dis; static int[] prev; static void print(int k) { if(prev[k]!=-1) { print(prev...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
efa24c5c4c6af1c1b0a087728f183d37
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
import java.io.*; import java.util.*; public class Main { static BufferedReader in; static PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) throws IOException { try { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(ne...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
3452f0f0489dfdc6f27e0a46c7d2377b
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
import java.io.*; import java.util.*; public class Main { static BufferedReader in; static PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) throws IOException { try { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(ne...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
971b38e35f3523fddc640507cb77848f
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
/** * Created by beej on 2/4/17. */ import java.util.*; import java.lang.*; public class prob20c { public static class Node implements Comparable<Node> { boolean visited; List<Edge> neighbors; Node route; long cost; int val; public Node(int val) { thi...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
feb9769a48a6a312549b6f57611d4ac4
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
/** * Created by beej on 2/4/17. */ import java.util.*; import java.lang.*; public class prob20c { public static class Node implements Comparable<Node> { boolean visited; List<Edge> neighbors; Node route; long cost; int val; public Node(int val) { thi...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
1dfd2072a12a5b00d12b2ebda9ea6a29
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayDeque; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Dijkstra { static ArrayDeque<Node>[] graph; static int nodes, edges; ...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
8d5b0f94a1818885980b5ae100db6baa
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Dijkstra { static ArrayDeque<Node>[] graph; static int nodes, edges; static int[] Parent; static long[] cost; public static...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
f90a379ae49825d2c4e7e32ccde6a968
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.PriorityQueue; import java.util.StringTokenizer; public class A { static int nodes, edges; static ArrayList<Node>[] graph; static int[] parent; static long[] totalCos...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
c7bd152dfc8ddd52d6d80e9ffe5428cc
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Dijkstra { static ArrayDeque<Node>[] graph; static int nodes, edges; static int[] Parent; static long[] Cost; public static...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
e474ac6b98220fdacd4462732b45336f
train_000.jsonl
1276875000
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
64 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Main { static class Node { int node; long cost; public Node(i...
Java
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
1 second
["1 4 3 5", "1 4 3 5"]
null
Java 8
standard input
[ "shortest paths", "graphs" ]
bda2ca1fd65084bb9d8659c0a591743d
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
1,900
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
standard output
PASSED
902021b0326e18c713a3f0058f12c139
train_000.jsonl
1292140800
In a far away galaxy there are n inhabited planets numbered with numbers from 1 to n. One day the presidents of all the n planets independently from each other came up with an idea of creating the Galaxy Union. Now they need to share this wonderful idea with their galaxymates, that’s why each president is busy working ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.ArrayList; public class G { static StreamTokenizer st; static class Adge {...
Java
["3\n1 2 3\n2 3 2\n1 3 1", "3\n1 2 3\n2 3 2\n1 3 5", "4\n1 2 3\n2 3 2\n3 4 1\n4 1 4"]
3 seconds
["4 5 3", "8 5 7", "12 8 8 8"]
null
Java 6
standard input
[ "dp", "two pointers", "trees" ]
00480885be97002dca98fe98a4238aee
The first line contains an integer n (3 ≤ n ≤ 200000) which represents the number of planets in the Galaxy and the number of communication channels equal to it. The next n lines contain three integers each ai, bi and ti (1 ≤ ai, bi ≤ n, ai ≠ bi, 1 ≤ ti ≤ 103) that represent the numbers of planet joined by a communicati...
2,700
In the first line output n integers — the durations of the supposed negotiations for each president. Separate the numbers by spaces.
standard output
PASSED
ee48bcb50608541c7dfd1343933aa0ff
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.FileReader; 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 CHelper plug-in * Actual solution is ...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
0386885cb15ca327f0cee03cec53aacf
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.FileReader; 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 CHelper plug-in * Actual solution is ...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
b754d01422c94336329b4644041d38fe
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import static java.util.Arrays.*; import java.text.*; public class C { public C () { int N = sc.nextInt(), Z = 1 << N; Integer [] A = new Integer [Z], B = new Integer [Z]; for (int i : rep(Z)) B[Z-1-i] = A[i] = sc.nextInt(); long X = 0; long [] S = new long [N+1]; for (int i : req(1, N)) X += S[...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
8871731ae75c7ea624455b6b745d9a15
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.*; import java.util.*; public class CF { FastScanner in; PrintWriter out; long[] inv1, inv2; int[] tmp = new int[1 << 21]; void go(int[] a, int l, int r, int h) { if (l == r) { return; } else { int m = (l + r) >> 1; m++; ...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
6d639ffbc2c30be3d403281e4b102cdb
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.*; import java.util.*; public class cf414c { static FastIO in = new FastIO(), out = in; static long[] count1, count2; public static void main(String[] args) { int n = in.nextInt(); int[] v = new int[1<<n]; for(int i=0; i<1<<n; i++) v[i] = in.nextInt(); count1 = new long[n+1]; ...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
5757ad85394772dfef3ce5ca69ba3a59
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.InputMismatchException; import java.io.PrintStream; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
9fe0d0154ceff6a128e488edba775a25
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C { static long[] inversions; static long[] oddversions; public static void main(String[] args) throws Exception{ int n = readInt(); inversions = new long[n+1]; oddversions = new long[n+1]; int n...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
080291caa5882b01bd8bc1741c798fec
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.util.*; import java.io.*; public class C { public static long time = 0; public static void main(String[] args) throws Exception { time = System.currentTimeMillis(); IN = System.in; OUT = System.out; in = new BufferedReader(new InputStreamReader(IN)); ...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
02abde9f9378d93fdc49d9bf07084918
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.util.*; import java.io.*; public class C { public static long time = 0; public static void main(String[] args) throws Exception { time = System.currentTimeMillis(); IN = System.in; OUT = System.out; in = new BufferedReader(new InputStreamReader(IN)); ...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
4609da63cbf4ad56a3df0eee70a6de2a
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.BufferedReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static ...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
85eb179afbbe68d020367df27dc56c86
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.*; import java.util.*; public class R240QeMashmokhAndReverseOperations { static int n; static int a[]; static long inv[],other[]; static long globalEq; public static void main(String args[] ) throws Exception { InputReader4 in = new InputReader4(System.in); PrintWriter w = new Print...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
4c3f517930309c34b90a9d77dea59ae3
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the to...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
7dcdcc8f97d80db24e46ff5909a6befd
train_000.jsonl
1396798800
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog...
512 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.InputMismatchException; import java.io.PrintStream; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * ...
Java
["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"]
4 seconds
["0\n6\n6\n0", "0\n1\n0"]
NoteIf we reverse an array x[1], x[2], ..., x[n] it becomes new array y[1], y[2], ..., y[n], where y[i] = x[n - i + 1] for each i.The number of inversions of an array x[1], x[2], ..., x[n] is the number of pairs of indices i, j such that: i &lt; j and x[i] &gt; x[j].
Java 7
standard input
[ "combinatorics", "divide and conquer" ]
ea7f8bd397f80ba7d3add6f9609dcc4a
The first line of input contains a single integer n (0 ≤ n ≤ 20). The second line of input contains 2n space-separated integers a[1], a[2], ..., a[2n] (1 ≤ a[i] ≤ 109), the initial array. The third line of input contains a single integer m (1 ≤ m ≤ 106). The fourth line of input contains m space-separated integers q1...
2,100
Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query.
standard output
PASSED
b17ea381e4e9e1d5b711258a4a35c72d
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.util.HashMap; import java.util.Scanner; /** * * @author interoperabilidad */ public class GeometricProgression { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner scanner= new Scanner(System.in); int n = scanner.nextInt();...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
c541c4806a7d85034a7537fd16ccd1f4
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.*; import java.util.*; public class Program { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; static final int MOD = 1000000007; static final double INF = 10000000000.0; void solve() throws IOException { long n, k, a[]; n = nextInt(); k = nextIn...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
05923ca1ce93c9955f3b83671296c00c
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.StringTokenizer; public class R314Div2C { public static void main(String[] args) { FastScanner in=new FastScanner(); int n=in.nextInt(); long k=in.nextLong(); long[] a=new long[n]; for(int i=0;i<n;i++...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
468865b81639b5e7a607fae366976884
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class MainC { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
583533500590efaabcc673373278f973
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy ...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
637eac36fbbcb633824d07000e7e7a2c
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class MainC { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
14f70ce691b8181805b11cfe5c399d5d
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Hashtable; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; ...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
21059ddad2c1a35f93078f652a25c027
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.HashMap; /** * @author: Ashok Rajpurohit * problem: Geometric Progression * Link: http://codeforces.com/contest/567/problem/C */ public class CPiC { private static PrintWriter ou...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
6b93311c394d26cd3aee5dc255523026
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.HashMap; /** * @author: Ashok Rajpurohit * problem: Geometric Progression * Link: http://codeforces.com/contest/567/problem/C */ public class CPiC { private static PrintWriter ou...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
0a9b9d342c7a0b95daffdf0c89b3f20b
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; public class Main { public static void solve() { int n = IO.readInt(); int k = IO.readInt(); Map<Integer, Long> s = new HashMap<Integer, Long>(); Map<Integer, Long> p = new Hash...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
d3cb460b388c8c6efcb600fc87b3a19c
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub int n, k; long ans = 0; Map <Long, Long> l = new HashMap<Long, Long> (); Map <Long, Long> r = new Hash...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
11a76f2c282e72457530558e88a5c9b5
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.*; import java.io.PrintWriter; import java.util.*; import java.io.InputStream; import java.io.DataInputStream; public class Main {//static{ System.out.println("hello");} public static void main(String[] args) throws IOException { InputStream inputStream = System.in; Output...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
3871439b2236713b69874d9171daf76c
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Hashtable; import java.util.InputMismatchException; import java.util.PriorityQueue; import java.util.Scanner; import java.util.TreeSet; public class Solution { public static void main(String args[]) { FasterScanner ...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
c67117d843e364edb0b3d35522778929
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Map; import java.util.HashMap; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /**...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
86b55afbbd9c71e3efa130395b91de61
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.StringTokenizer; public class Main { public static void main(String [] args) throws IOException{ BufferedReader input = new BufferedReader(new InputStreamR...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
77e11aae933f5a22afcbd7474cdf40f4
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.util.*; import java.util.Map.Entry; import java.io.*; import java.lang.*; import java.math.*; import static java.lang.Math.*; public class Solution implements Runnable { void solve() throws Exception { int n = sc.nextInt(); int k = sc.nextInt(); HashMap<Integer, Long>[] cnt = new Hash...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
858252124a6fcf07671a0c36471a9497
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.awt.Point; import java.awt.Rectangle; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.ObjectInputStream.GetField; import java.lang.reflect.Array; import java.math.BigIntege...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
e057c2ed678ccc4f0486158127d24edd
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public void solve() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int K = scanner.nextInt(); int[] a = new int[N]; for (int i = 0; i < N; i++) { a[i] = scanner.nextInt(); } scann...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
eedb761df226ee0fccf25a2bc2e18e63
train_000.jsonl
1438790400
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.He wants to know how many subsequences of length three can be selected from a, so that they form a geometric pro...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.text.*; public class Main3 { public static int n, k, nk, b; public static void fact(int value) { nk = 0; if ( value != 0) { while( value % k == 0 ) ...
Java
["5 2\n1 1 2 2 4", "3 1\n1 1 1", "10 3\n1 2 6 2 3 6 9 18 3 9"]
1 second
["4", "1", "6"]
NoteIn the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
Java 7
standard input
[ "dp", "binary search", "data structures" ]
bd4b3bfa7511410c8e54658cc1dddb46
The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.
1,700
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.
standard output
PASSED
19c8c46338b1478c70d99f3b006d53cc
train_000.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; public class Main { static int[] wins; static int[] pwins; static int[] gwins; static boolean...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 8
standard input
[ "binary search" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
85b68bca8b8482aae1155f21aa38c747
train_000.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 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.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.io.Writer; impo...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 8
standard input
[ "binary search" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
afd9c5469b7e18d8d9c4168986ee8c38
train_000.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; public class Main { //removing columns // public static char[][] readEntrance() throws IOException { // BufferedReader br = new BufferedReader(new InputStreamR...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 6
standard input
[ "binary search" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
193692e8638d14bde8281db6c2a138db
train_000.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Scanner; public class CF283D1 { private static class Result implements Comparable<Result> { Integer s; Integer t; public Result(final Integer s, final Integer t) { this.s = s; ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 6
standard input
[ "binary search" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
03c7d588494ed278276e5d8dac6dcbf7
train_000.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.Scanner; import java.util.List; import java.io.IOException; import java.util.ArrayList; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collections; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top *...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 6
standard input
[ "binary search" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
fd2e4742242d6ecaf090acf52561a78c
train_000.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
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 Solution { static class an implements Comparable<an> { int s,t; public an(int s, int t) { this.s=s; this.t=t; } public...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 6
standard input
[ "binary search" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
e89f31c8a35e4b302ac22e1b88a4d3b7
train_000.jsonl
1294733700
The Hedgehog likes to give presents to his friend, but no less he likes to receive them.Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in the cupboard. He will have to choose another shelf, but which one should he cho...
256 megabytes
import java.util.*; //warm-up public class Presents { static Set<Integer> s = new HashSet<Integer>(); static void solve(){ Scanner sc = new Scanner(System.in); int n=sc.nextInt(), k=sc.nextInt(),NOC=sc.nextInt(),i=0,no=0,gap=1; while (NOC-->0) s.add(sc.nextInt()); while (++...
Java
["5 2\n1 3", "10 1\n3 6 7 8"]
2 seconds
["3", "10"]
null
Java 11
standard input
[ "implementation" ]
07b750dbf7f942eab80d4260103c7472
The first line contains integers N and K (1 ≤ N ≤ 365, 1 ≤ K ≤ N). The second line contains a number C which represents the number of holidays (0 ≤ C ≤ N). Then in the same line follow C numbers ranging from 1 to N which are the numbers of holiday days. The numbers are given in the increasing order, without repeating n...
1,300
Print a single number — the minimal number of presents the Hedgehog will receive over the following N days.
standard output
PASSED
e8e697b31f61deff4faefe824ed88d92
train_000.jsonl
1294733700
The Hedgehog likes to give presents to his friend, but no less he likes to receive them.Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in the cupboard. He will have to choose another shelf, but which one should he cho...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.util.InputMismatchException; import java.io.InputStreamReader; import java.io.BufferedOutputStream; import java.util.StringTokenizer; import java.io.Closeable; import...
Java
["5 2\n1 3", "10 1\n3 6 7 8"]
2 seconds
["3", "10"]
null
Java 11
standard input
[ "implementation" ]
07b750dbf7f942eab80d4260103c7472
The first line contains integers N and K (1 ≤ N ≤ 365, 1 ≤ K ≤ N). The second line contains a number C which represents the number of holidays (0 ≤ C ≤ N). Then in the same line follow C numbers ranging from 1 to N which are the numbers of holiday days. The numbers are given in the increasing order, without repeating n...
1,300
Print a single number — the minimal number of presents the Hedgehog will receive over the following N days.
standard output
PASSED
dd9e2780e59c7e85cd0bcbea28a21c11
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.Scanner; public class CodeForce { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t>0) { String n = s.next(); System.out.println(n.length...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
4572d810772d50f0bb925cf05c1e73b1
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.Scanner; public class cp2 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int i = 0;i<t;i++) { String n = in.next(); int l = n.length(); System.out.println(l); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
fbbb546aa2dd1ea532c013978474014b
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.math.BigInteger; import java.util.*; import java.util.Scanner; public class StrangeFunctions { public static int getCount(BigInteger number) { double factor = Math.log(2) / Math.log(10); int Count = (int) (factor * number.bitLength() + 1); if (BigInteger.TEN.pow(Count - 1).compareTo(number) ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
56c285445720b577db43cfdd9a7569dd
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class Main{ public static void main(String[]args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); String z=sc.nextLine(); while(t-->0){ String n=sc.nextLine(); System.out.println(n.length()); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
a716178ad8e2f89283603380c24926d0
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class problems { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>0) { String s=sc.next(); solve(s); t--; } } static void solve(String n) { System.out.println(n.length()); } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
952e79e495d92d27bd64c9c9d7f1cebb
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class A { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
2240fca3d13541a129a98f79b2b0e2d2
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class E { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int t,i,j,sum=0,c=0; BigInteger n; t=sc.nextInt(); while(t-->0) { n=sc.nextBigInteger(); while(!n.equals(BigInteg...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
b87f31991d2e212e1f3dad915bf2d59f
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; // import java.lang.*; import java.io.*; // THIS TEMPLATE MADE BY AKSH BANSAL. public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in))...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
4da29ba0852684bc5c892302cdb7db9e
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.Scanner; import java.math.BigDecimal; import java.util.Arrays; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); long t=sc.nextLong(); while(t>0){ String n=sc.next(); long sum=0; long len=n.length(); for(;len!=0;sum++) { len--; } ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
d379d6b26b26e76898bc31e22a6beeb2
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.Scanner; public class Codeforces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); while(t-- >0){ String str = sc.nextLine(); int len = str.length(); System.out...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
34dbbb43bafda5eca5feafc3d73b217e
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class strange { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // Scann...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
8a2898e604832f8ee947bedacbf3d021
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
// Rezk import java.util.Scanner; public class Codeforces { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n,m; String str; n = input.nextInt(); str = input.nextLine(); for(int i=0;i<n;++i){ str = input.nextLine();/...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
4be838af8f560fc209ad19f314263e54
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.*; public class abc { public static void main(String arg[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); StringBuilder sb=new StringBuilder(); w...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
9998b05e1eb5575ab597cb28d8fa2ce4
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
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 Codeforces { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader buf=new BufferedReader(new InputSt...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
c6dd7b3c8893b3c281475dfeeff34270
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.*; public class Func { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { String n=sc.next(); int c=n.length(); char ch=n.charAt(0); System.out.println(c); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
a4098dc6074867d507a7abed1d489b9d
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.math.BigInteger; //public class eferf { // //} import java.util.Scanner; public class eferf { public static void main(String args[]) { Scanner s = new Scanner(System.in); long t = s.nextLong(); for (int i=0;i<t;i++) { BigInteger n = s.nextBigInteger(); BigInteger A = new BigInteger("10...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
908b5a65a832be6c4006aa57cca4ac6a
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class hello { public static void main(String args[]) { Scanner sc= new Scanner(System.in); int t=sc.nextInt(); sc.nextLine(); while(t-->0) { String s=sc.nextLine(); System.out.println(s.length()); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
d1cfdbacd1edc7b2d8e31221c368dcd0
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static int total(BigInteger a){ BigInteger temp = a; int b = 0; int r = 10; do{ temp = temp.divide(BigInteger.valueOf(r)); b ++; }while (temp != BigInteger.ZERO); ...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
bbfd62d4db4de8c769eb62d36bec150e
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class function { public static void main(String args[]){ Scanner sc = new Scanner (System.in); int t = sc.nextInt(); while (t-- > 0){ int count=0; String n = sc.next(); System.out.println(n.length()); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
ec7baf4e1300033564917c3d5ca805e4
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
//package codeforcesEC99; import java.util.Scanner; public class A { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); StringBuilder answer = new StringBuilder(); int t = sc.nextInt(); sc.nextLine(); while(t-->0) { String s = sc.nextLine(...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
27c2c55a210c47cad7b09e18e9548b3e
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.PriorityQueue; import java.util.Stack; import java.util.StringTokenizer...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
f48d572c77c2d4445f8bc62931cf986c
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.*; public class bye { static class InputReader { BufferedReader reader; StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } String next() { // reads in the next str...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
0920370c97371a3317721f415b571f3c
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class Test { public static void main(String[] args) { Scanner in=new Scanner (System.in); int t=in.nextInt(); for (int i = 0; i < t; i++) { String s=in.next(); System.out.println(s.length()); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
de0e06861b2ae7b94ee2f5f32facdba7
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.*; public class stf { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=0; t=Integer.parseInt(br.readLine()); while(t-->0) { String a=br.readLine().trim(); System.out.println(a.le...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
05fd54d660c73f2ed0ed2c5264e942f8
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.io.*; import java.util.*; public class Main { InputStream is; PrintWriter out; String INPUT = ""; void solve(int TC) throws Exception { pn(ns().length()); } boolean TestCases = true; public static void main(String[] args) throws Exception { new Main().run(); } void holds(boolea...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
7a76df80d7e16e8db9f79133bc437ca9
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t; String s; t = sc.nextInt(); for (int i = 1; i <= t; i++) { s = sc.next(); System.out.println(s.length()); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
65b96174c8f1f141fe8584ca0df21506
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int t=in.nextInt(); in.nextLine(); for(int z=0;z<t;z++) { String n=in.nextLine(); long sum=n.length(); System.out.println(sum); } } }
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output
PASSED
bfdf6e9ca0f083f1756e0ef398d7da10
train_000.jsonl
1606746900
Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \df...
256 megabytes
import java.util.Scanner; public class Always_Newbie { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int iop=0;iop<t;iop++) { String s = sc.next(); System.out.println(s.length()); } }...
Java
["5\n4\n37\n998244353\n1000000007\n12345678901337426966631415"]
2 seconds
["1\n2\n9\n10\n26"]
NoteExplanations for the two first test cases of the example: if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$; if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
ea011f93837fdf985f7eaa7a43e22cc8
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n &lt; 10^{100}$$$). This integer is given without leading zeroes.
null
For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.
standard output