src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringclasses 256
values | from stringclasses 1
value |
|---|---|---|---|
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
public class B1177 {
public static void main(String[] args) throws Exception {
// BufferedReader br = new BufferedReader(new FileReader("F:/books/input.txt"));
BufferedReader br = new ... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
/**
* Created by IntelliJ IDEA.
* User: SONY
* Date: 27.05.12
* Time: 18:25
* To change this template use File | Settings | File Templates.
*/
import java.io.*;
import java.util.*;
public class TaskA extends Thread {
public TaskA(String inputFileName, String outputFileName) {
try {
if (i... | constant | 199_A. Hexadecimal's theorem | CODEFORCES |
import java.util.*;
import java.io.*;
public class a {
static long mod = 1000000007;
static boolean[][] blacks;
public static void main(String[] args) throws IOException
{
input.init(System.in);
PrintWriter out = new PrintWriter(new PrintStream(System.out));
//Scanner input = new Scanner(new File("input.txt")... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.Fi... | nlogn | 1015_C. Songs Compression | CODEFORCES |
import java.io.*;
import java.util.*;
public class DD {
public static void main(String[] args)throws Throwable {
MyScanner sc=new MyScanner();
PrintWriter pw=new PrintWriter(System.out);
int n=sc.nextInt();
int [] a=new int [n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
int c=0;
for(int i=0;i<n;i++)
... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Inet4Address;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* Created by shirsh.bansal on 07/08/16.
*/
public class Main {
public static void main(String[] args) throws IOException {
... | np | 11_D. A Simple Task | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a, b, min, max, result = 0, temp;
while(n-->0){
a = sc.nextInt();
b = sc.nextInt();
max = Math.max(a, b);
min = Math.min(a, b);
result = 0;
... | constant | 267_A. Subtractions | CODEFORCES |
import java.util.*;
import java.io.*;
import java.lang.Math.*;
public class Main{
static long s;
static boolean check(long n){
int sum = 0;
long storen=n;
while(n>0){
int k = (int)(n%10);
n /=10;
sum+=k;
}
return storen-(long)sum >= s;
}
public static void main(String args[]){
PrintWriter pw=n... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
// Scanner scan = new Scanner(System.in);
PrintWriter out = new P... | linear | 1067_C. Knights | CODEFORCES |
import java.util.*;
import java.io.*;
public class RGBSubstring {
public static void main(String[] args) {
FastScanner scanner = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int Q = scanner.nextInt();
while(Q-->0) {
int N = scanner.nextInt();
... | quadratic | 1196_D1. RGB Substring (easy version) | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;
public class A {
private void solve() throws IOException {
int n = nextInt();
Integer[] a = new Integer[n];
... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.util.*;
import java.io.*;
public class A{
static int N, M, K;
static String s;
static StringTokenizer st;
static int[] d;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
... | linear | 1000_A. Codehorses T-shirts | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class Twins {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] val = new int[n];
for (int i=0; i<n; i++)
val[i] = in.nextInt();
Arrays.sort(val);
... | nlogn | 160_A. Twins | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Pradyumn
*/
public class M... | logn | 1019_B. The hat | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main
{
static final long mod=(int)1e9+7;
public static void main(String[] args) throws Exception
{
FastReader in=new FastReader();
PrintWriter pw=new PrintWriter(System.out);
int n=in.nextInt();
int[] arr=ne... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class D implements Runnable{
public static void main (String[] args) {new Thread(null, new D(), "_cf", 1 << 28).start();}
public void run() {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
System.err.... | nlogn | 903_D. Almost Difference | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class bhaa {
InputStream is;
PrintWriter o;
/////////////////// CODED++ BY++ ++ ++ ++ BHAVYA++ ARORA++ ++ ++ ++ FROM++ JAYPEE++ INSTITUTE++ OF++ INFORMATION++ TECHNOLOGY++ ////////////////
///////////////////////// Make it work, make it rig... | constant | 1080_A. Petya and Origami | CODEFORCES |
import java.util.*;
import java.io.*;
public class E1 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//optimizaciones que parece que solo son necesarias para java
ArrayList<Integer>[] reps = new ArrayList[13]; //representa... | np | 1209_E2. Rotate Columns (hard version) | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | cubic | 1515_E. Phoenix and Computers | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Scanner;
import java.util.Vector;
public class Main {
private static final int SIM = 1;
private static final int NAO = 2;
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedRead... | np | 1102_F. Elongated Matrix | CODEFORCES |
import java.util.*;
import java.io.*;
public class Template {
public static void main(String[] args) throws IOException {
st = new StringTokenizer(rd.readLine());
n = Long.parseLong(st.nextToken());
m = Long.parseLong(st.nextToken());
k = Long.parseLong(st.nextToken());
long s = n - m;
s = Math.min(s, m /... | logn | 338_A. Quiz | CODEFORCES |
import java.io.InputStreamReader;
import java.io.IOException;
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 top
* @author Sunits789
*/
public class M... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.io.*;
import java.util.*;
public class C138B
{
private static StringTokenizer st;
public static void nextLine(BufferedReader br) throws IOException
{
st = new StringTokenizer(br.readLine());
}
public static int nextInt()
{
return Integer.parseInt(st.nextTo... | linear | 224_B. Array | CODEFORCES |
import java.math.BigInteger;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Sagimbekov_MA
*/
public class A483 {
public static void... | constant | 483_A. Counterexample | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class A implements Runnable {
private void Solution() throws IOException {
int n = nextInt();
if (n % 7 == 0 || n % 4 == 0 || n % 47 == 0 || n % 74 == 0 || n % 747 == 0 || n % ... | constant | 122_A. Lucky Division | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Jenish
*/
public class Ma... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
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.math.BigInteger;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Locale;
import java.... | linear | 1_B. Spreadsheets | CODEFORCES |
import java.awt.Point;
import java.util.Scanner;
public class p105b {
static int[] b, l;
static int n;
static int A;
static boolean[] masks;
static double max;
public static double work(int index, int k, int mask) {
if (index == n) {
if (Integer.bitCount(mask) * 2 <= n) {
... | np | 105_B. Dark Assembly | CODEFORCES |
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
public class Main {
public static void main(String[] args) {
solve(System.in,System.out);
}
static void solve(InputStream inStream, PrintStream printStream) {
Scanner in = new Scanner(inStream)... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int N = sc.nextInt();
long dest = sc.nextLong();
long max = (long)... | nlogn | 1098_C. Construct a tree | CODEFORCES |
//package round168;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class A {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni(), K = n... | nlogn | 274_A. k-Multiple Free Set | CODEFORCES |
import java.io.IOException;
import java.util.Scanner;
/**
* TODO: describe
*
* @author keks
*/
public class A {
public static void main(String[] args) throws IOException {
final Scanner sc = new Scanner(System.in);
final int n = sc.nextInt();
if (n % 2 == 0) {
System.out.pri... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main implements Runnable {
private final String problemname = "";
private final String FILE_IN = problemname + ".in";
private final String FILE_OUT = problemname + ".out";
public void run() {
// in = new BufferedReader(new Fil... | constant | 84_A. Toy Army | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution i... | np | 1242_C. Sum Balance | CODEFORCES |
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
public class A {
public A() throws Exception {
int n = in.nextInt();
int[] arr = new int[n];
for (int i=0; i<n; i++) arr[i] = in.nextInt();
int... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
public class C implements Runnable {
private void Solution() throws IOException {
int n = nextInt(), max = 0, maxi = 0;
ArrayLis... | nlogn | 135_A. Replacement | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
System.out.println(n * 6 / 4);
}
} | constant | 84_A. Toy Army | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st = new StringTokenizer("");
... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.io.*;
import java.util.*;
public class C {
static int n, m, a[][];
static int[][] memo;
static int[] getCol(int col, int shift) {
int[] ans = new int[n];
for (int i = 0, j = shift; i < n; i++, j = (j + 1) % n) {
ans[i] = a[j][col];
}
return ans;
}
static int dp(int col, int msk) {
if ... | np | 1209_E1. Rotate Columns (easy version) | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
public class Main {
public static void main(String[] args) throws IOException {
(new Main()).solve();
}
public void Main() {
}
void solve() throws IOException {
// BufferedReader in = new BufferedReader(new
// I... | constant | 199_A. Hexadecimal's theorem | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class CodeChef2 {
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in))... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;
/**
* @author Egor Kulikov (egor@egork.net)
* Created on 14.03.2010
*/
public class TaskD implements Runnable {
private InputRea... | np | 11_D. A Simple Task | CODEFORCES |
import java.util.*;
import java.io.*;
public class C{
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main (String[] args) throws IOException {
int t = ... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class CF {
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=null;
private void solution() th... | constant | 122_A. Lucky Division | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStrea... | np | 1185_G1. Playlist for Polycarp (easy version) | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class cf2 {
static final double EPS = 1e-9;
public static void main(String[] args) thro... | constant | 994_C. Two Squares | CODEFORCES |
import java.util.*;
import java.io.*;
public class two {
public static void main(String[] args) throws IOException, FileNotFoundException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//BufferedReader in = new BufferedReader(new FileReader("two"));
HashSet<Integer> good = new Ha... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[][] x = new int [200010][10];
String a = sc.nextLine();
String b = sc.nextLine();
int n = a.length();
int m = b.length();
for (int i = 1; i <= m; i++) {
... | linear | 608_B. Hamming Distance Sum | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
static BufferedReader reader;
static StringTokenizer tokenizer;
static PrintWriter writer;
static String nextToken() throws IOE... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.*;
import java.util.*;
public class C {
int removeSq(int x) {
for (int i = 2; i * i <= x; i++) {
while (x % (i * i) == 0) {
x /= i * i;
}
}
return x;
}
void submit() {
int n = nextInt();
HashMap<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < n; i++) {
int x =... | cubic | 840_C. On the Bench | CODEFORCES |
import java.util.*;
import java.math.*;
import java.io.*;
public class b2 {
public static void main(String[] args) throws IOException
{
input.init(System.in);
int n = input.nextInt(), x = input.nextInt(), y = input.nextInt(), c = input.nextInt();
long lo = 0, hi = 2*n;
while(hi > lo+1)
{
lo... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class TaskA {
void Run() throws IOException {
int n=ReadInt();
int[] arr=new int[n];
for(int i=0;i<n;++i)
arr[i]=ReadInt();
Arrays.sort(arr);
boolean one=true;
for(int x : arr)
if(x!=1) {
one=false;
break;
}
if(one) {
f... | nlogn | 135_A. Replacement | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader reader
= new BufferedReader(new InputStreamReader(System.in));
static StringBuilder out = new StringBuilder();
public static void main(String[] args){
solve();
return;
}
// the following... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
new Main().go();
}
PrintWriter out;
Reader in;
BufferedReader br;
Main() throws IOException {
try {
//br = new BufferedReader( new FileReader("in... | quadratic | 1015_E2. Stars Drawing (Hard Edition) | CODEFORCES |
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public Main() {
super();
}
public static void main(String... args) {
Main main = new Main();
main.start();
}
public void start() {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
do... | np | 16_E. Fish | CODEFORCES |
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
long a,b;
a = scn.nextLong();
b = scn.nextLong();
long diff = ... | logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Scanner sc = new Scanner(new InputStreamReader(System.in));
int n = sc.nextInt(),even = 0,odd = 0,evI =... | linear | 25_A. IQ test | CODEFORCES |
import java.io.*;
import java.util.*;
public class TaskA {
BufferedReader br;
PrintWriter out;
StringTokenizer stok;
String nextToken() throws IOException {
while (stok == null || !stok.hasMoreTokens()) {
String s = br.readLine();
if (s == null) {
return "-1";
}
stok = new StringTokenizer(s);
... | nlogn | 135_A. Replacement | CODEFORCES |
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(new InputStreamReader(System.in));
PrintWriter out=new PrintWrite... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
public class Main{
static InputReader sc;
static PrintWriter pw;
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
sc = new Input... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int len = s.length();
for(int i=len-1; i>=1; --i) {
for(int j=0; j<=len - i; ++j) {
String ss = s.substring(j, j+i);
if(s.substring(j+1).ind... | cubic | 23_A. You're Given a String... | CODEFORCES |
//package codeforces.cf156;
import java.io.*;
import java.util.Arrays;
public class ProblemB {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
long[] readInts() throws IOException {
String[] str... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.util.*;
import java.io.*;
public class NewYearAndCurling {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
StringTokenizer t = new StringTokenizer(in.readLine());
in... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
static StringBuilder data = new StringBuilder();
final static FastReader in = new FastReader();
public static void main(String[] args) {
int n = in.nextInt();
int a[] = new int[n];
for (int i = 0; i < n; i++) {
... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class ElevatorOrStairs {
private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
private static final OutputStreamWriter writer = new OutputStreamWriter(System.out);
... | constant | 1054_A. Elevator or Stairs? | CODEFORCES |
import java.io.*;
import java.util.*;
public class ayyyyyy
{
public static void main(String[] args) { new ayyyyyy(); }
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t, n;
int[] a;
ayyyyyy()
{
t = in.nextInt();
while (t --> 0)
{
a = new int[n = in.nextInt()]... | nlogn | 1197_A. DIY Wooden Ladder | CODEFORCES |
import java.util.*;
public class r220a {
public static void main(String args[]) {
Scanner in =new Scanner(System.in);
int N = in.nextInt();
ArrayList<Integer> list = new ArrayList<Integer>();
ArrayList<Integer> sort = new ArrayList<Integer>();
for(int i = 0; i < N; i++) {
int k = in.nextInt();
list.add... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
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.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Map;
import java.io.Writer;
import ... | linear | 1000_A. Codehorses T-shirts | CODEFORCES |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class BetaRound15_A implements Runnable {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void init() throws IOException {
i... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.util.Scanner;
public class FUck {
public static void main(String args[])
{
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int k=scan.nextInt();
String t=scan.next();
int mx=0;
for(int i=1;i<n;i++)
{
int gd=1;
for(int j=0;j<i;j++)
{
if(t.charAt(j... | quadratic | 1029_A. Many Equal Substrings | CODEFORCES |
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class A {
static Scanner scan = new Scanner (System.in);
static PrintStream out = System.out;
static void go (int n) {
if (n == 0) {
System.out.println (0 + " " + 0 + " " + 0);
return;
}
int a = 0, b = 1;
int c = a + b;
while ... | constant | 199_A. Hexadecimal's theorem | CODEFORCES |
import java.io.*;
import java.util.*;
public class c {
static boolean used[][];
static int n;
static int m;
static int a[][];
public static void main(String args[])throws Exception{
Scanner in =new Scanner(new File("input.txt"));//System.in);//
PrintWriter out=new PrintWriter(new File("output.txt"));//... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class A25 {
public void run() {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine().trim());
String[] toks = in.readLine().trim().split("[ ]+");
int counter = 0;... | linear | 25_A. IQ test | CODEFORCES |
/**
* author: derrick20
* created: 11/11/20 1:45 PM
*/
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class OnTheBenchAlt {
public static void main(String[] args) {
setupCombo(301);
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System... | cubic | 840_C. On the Bench | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class Task15a {
public static class House implements Comparable<House>{
int x, s;
public House(int x, int s) {
super();
this.x = x;
this.s = s;
}
public int compareTo(House o) {
return x - o.x;
}
}
public static void main(S... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
public class Main implements Runnable {
void randomShuffle(int[] arr) {
Random rnd = new Random();
for (int i = arr.length - 1; i >= 0; i--) {
int pos = rnd.nextInt(i + 1);
int temp = arr[pos];
arr[pos] = arr[i];... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream... | logn | 713_B. Searching Rectangles | CODEFORCES |
import java.io.*;
import java.util.*;
public class Solution{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
... | quadratic | 1011_B. Planning The Expedition | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
public class Es1
{
static IO io = new IO();
public static void main(String[] args)
{
int n = io.getInt();
int[] a = new int[n];
for(int i=0; i<n; i++)
a[i] = io.getInt();
Arrays.sort(a);
int[] color = new int[n];
int num = 1;
for... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.util.*;
public class B
{
static long sumN(long n)
{
return n * (n + 1) / 2;
}
static int binSearchPuts(int n, int k)
{
int L = 1;
int U = n;
int M = (L + U) / 2;
while(L <= U)
{
long left = sumN(M) - (n - M);
if(left < k)
{
L = M + 1;
}
else if(left > k)
{
U... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Main implements Runnable
{
boolean multiiple = false;
void solve() throws Exception
{
int n = sc.nextInt();
ArrayList<Integer> list = new ArrayList<>();
f... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.*;
import java.util.*;
public class ayyyyyy
{
public static void main(String[] args) { new ayyyyyy(); }
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t, n;
int[] a;
ayyyyyy()
{
t = in.nextInt();
while (t --> 0)
{
a = new int[n = in.nextInt()]... | nlogn | 1197_A. DIY Wooden Ladder | CODEFORCES |
import java.io.*;
import java.util.*;
public class E implements Runnable {
public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();}
HashMap<Integer, Integer> valToNode, nodeToVal, whichBox;
int N, ptsTo[], cycleMask[], dfsStack[], tempList[];
ArrayDeque<Integer> stack = new Arr... | np | 1242_C. Sum Balance | CODEFORCES |
import jdk.nashorn.internal.objects.NativeArray;
import javax.swing.JOptionPane ;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.sql.SQLSyntaxErrorException;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;
import static jdk.nashorn.i... | linear | 1159_A. A pile of stones | CODEFORCES |
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
public static void main(String[] args) throws IOException {
InputStream input = System.in;
OutputStream output = System.out;
InputReader in = new InputReader(new FileReader(new File("input.txt")));
PrintWr... | cubic | 35_C. Fire Again | CODEFORCES |
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking inter... | logn | 1080_D. Olya and magical square | CODEFORCES |
import java.util.Scanner;
public class Main3 implements Runnable {
public static void main(String[] args) {
new Thread(null, new Main3(), "", 128 * 1024 * 1024).start();
}
private static Scanner in = new Scanner(System.in);
public void run() {
int n = in.nextInt();
int m = 1_... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.io.*;
import java.util.*;
public class codeforces2 {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
// Scanner scan = new Scanner(System.in);
//for (int i = 1; i <= 10; i++) {
// System.out.println(... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.io.*;
import java.util.*;
import java.lang.*;
import static java.lang.Math.*;
// _ h _ r _ t r _
// _ t _ t _ s t _
public class TaskA implements Runnable {
long m = (int)1e9+7;
PrintWriter w;
InputReader c;
final int MAXN = (int)1e6 + 100;
public void run() {
c = new Input... | linear | 527_B. Error Correct System | CODEFORCES |
import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t = sc.nextInt();
int[][] xa = new int[n][2];
for(int i=0; i<n; ++i) {
xa[i][0] = sc.nextInt();
xa[i][1] = sc.nextInt();
}
... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
// Petya and Spiders
// 2011/9/3
public class P111C{
Scanner sc=new Scanner(System.in);
int INF=1<<28;
int n, m;
void run(){
n=sc.nextInt();
m=sc.nextInt();
solv... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.io.*;
import java.util.*;
public class My {
public static void main(String[] args) {
new My().go();
}
void go() {
Scanner in = new Scanner(System.in);
long n = in.nextLong();
int k = in.nextInt();
int mn = 0, mx = k + 1;
while (mn < mx) {
int mid = (mn + mx) / 2;
... | logn | 287_B. Pipeline | CODEFORCES |
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;
public class B176 {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedInputStream(System.in));
PrintWriter out = new PrintWriter(new BufferedOut... | logn | 287_B. Pipeline | CODEFORCES |
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
int n = nextInt();
String nn = Integer.toString(n);
if(n >= 0){
println(n);
} else {
println(Math.max(Integer.parseInt(nn.substring(0,nn.length() - 1)), Integer.parseInt(nn.substring(0, nn.length() - 2) ... | constant | 313_A. Ilya and Bank Account | CODEFORCES |
import java.io.*;
import java.util.*;
public class Template implements Runnable {
private void solve() throws IOException {
int n = nextInt();
int m = nextInt();
boolean[][] g = new boolean[n][n];
for (int i = 0; i < m; ++i) {
int a = nextInt() - 1;
int b = n... | np | 11_D. A Simple Task | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.io.IOException;
import java.util.Comparator;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
... | cubic | 840_C. On the Bench | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.InputMismatchException;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class D {
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new O... | quadratic | 1179_B. Tolik and His Uncle | CODEFORCES |
import java.util.*;
import java.io.*;
public class FirstClass {
public static void main(String[] args)throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int n = Integer.parseInt(br.readLine());
int arr[] = new ... | linear | 1054_B. Appending Mex | CODEFORCES |
import java.util.*;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long l = sc.nextLong();
long h = sc.nextLong();
sc.close();
if(h-l<2) {
System.out.println(-1);
return ;
}
if(h-l==2 && l%2==1) {
System.out.println(-1);
return ;
... | constant | 483_A. Counterexample | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.