src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringclasses 256
values | from stringclasses 1
value |
|---|---|---|---|
public class D {
public Object solve() {
long N = sc.nextLong(), K = sc.nextLong() - 1;
if (N >= 32)
return print("YES", N-1);
long A = 1L << (N-1), C = 4, T = (A*A - 1) / 3;
while (A > 1 && K > T) {
A /= 2;
K -= (C-1);
C *= 2;
T += (C-3) * (A*A - 1) / 3;
}
if (K >= 0 && K <= T)
retur... | logn | 1080_D. Olya and magical square | CODEFORCES |
import java.io.*;
import java.math.*;
import java.util.*;
import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;
public class C35
{
public static int mod = 1000000007;
public static long INF = (1L << 60);
static int n... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class... | nlogn | 528_B. Clique Problem | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Main {
static PrintWriter out;
static Reader in;
public static void main(String[] args) throws IOException {
input_output();
Main solver = new Main();
solver.solve();
out.close();
... | cubic | 1497E2 | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
long fib[] = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309,... | constant | 199_A. Hexadecimal's theorem | CODEFORCES |
/**
* Created by IntelliJ IDEA.
* User: Taras_Brzezinsky
* Date: 8/14/11
* Time: 9:53 PM
* To change this template use File | Settings | File Templates.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileReader;
import java.util.StringTokenizer;
imp... | np | 16_E. Fish | CODEFORCES |
import java.awt.Point;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class Contest35_3 {
public static void main(String[] args) throws IOException {
BufferedReader in = new Buffe... | cubic | 35_C. Fire Again | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
private static int[] a;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
a = new int[101];
for (int i = 0; i < m; i++) {
... | nlogn | 1011_B. Planning The Expedition | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class TheyAreEverywhere {
static StringTokenizer st;
static BufferedReader bf = new BufferedReade... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.StringTokenizer;
public class D {
public static void main(String[] args){
FastScanner scan = new FastScanner();
PrintWri... | nlogn | 903_D. Almost Difference | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
public class Task235A {
public static void main(String... args) throws NumberFormatException,
IOException {
... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
import java.math.*;
public class Main {
void run() throws IOException {
int n = in.nextInt();
char[] c = in.next().toCharArray();
int[][] t = new int[n][n];
int[][] h = n... | linear | 46_C. Hamsters and Tigers | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
public class A {
private static StreamTokenizer in;
private static PrintWriter out;
private static int nextInt() throws Exception{
in.nextToken();
return (int)in... | constant | 84_A. Toy Army | CODEFORCES |
import java.util.Scanner;
public class Flatwile {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t = sc.nextInt();
int[] c = new int[n];
int[] a = new int[n];
for (int i=0; i<n; i++){
c[i] = sc.n... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
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 at... | nlogn | 166_A. Rank List | CODEFORCES |
import java.util.Scanner;
public class SimpleTask {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
boolean[][] graph = new boolean[n][n];
for (int i = 0; i < m; i++) {
int u = scan.nextInt() - 1;
int v = scan.nextInt() ... | np | 11_D. A Simple Task | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class CFTest6 {
static BufferedReader br;
public static void main(String[] args) {
br = new BufferedReader(new InputStreamReader(System.in));
try {
int[] a1 = readIntArr();
int[]... | nlogn | 257_A. Sockets | CODEFORCES |
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.util.ArrayLi... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class A {
static class Entity implements Comparable {
public Entity(int x, int a) {
this.x = x;
this.a = a;
}
public int x, a;
public int compareTo(Object t) {
... | nlogn | 15_A. Cottage Village | 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.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class C {
static int N;
static char[... | quadratic | 909_C. Python Indentation | 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.io.*;
import java.util.*;
public class Main {
public static void main (String[] args) throws java.lang.Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
long n = Long.parseLong(st.nextT... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.util.*;
import java.io.*;
public class E
{
public static void main(String[] args) throws IOException
{new E();}
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n, m, oo = 1 << 28;
int[] dp, cost;
int[][] to;
char[] w;
E() throws IOException
{
... | np | 1238_E. Keyboard Purchase | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
public static boolean check(BigInteger a, BigInteger b){
long n = 0;
String aStr = a.toString();
for (int i=0; i < aStr.length() ;i++ ) {
n += Long.valueOf(aStr.charAt(i)-'0');
}
return a.subtract(BigInteger.valu... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.util.*;
public class q1
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int[] arr1=new int[9];
int[] arr2=new int[9];
String ss;
s.nextLine();
for(int i=0;i<n;i++)
{
ss=s.nextLine();
if(ss.equals("M"))
arr1[0]++;
else if(ss.equa... | linear | 1000_A. Codehorses T-shirts | CODEFORCES |
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;
pub... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
public static InputStream IN;
public static OutputStream OUT;
public static PrintWriter out;
public static BufferedReader in;
public static StringTokenizer st = null;
public static int ni() throws Exception {
... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Scanner;
public class CF_2020_GlobalRound_E {
static boolean verb=true;
static void log(Object X){if (verb) System.err.println(X);}
static void log(Obj... | cubic | 1515_E. Phoenix and Computers | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public class CodeForces
{
public static void main(String[] args)
{
Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
System.out.println(input.nextInt() / 2 + 1);
}
} | constant | 964_A. Splits | CODEFORCES |
import java.util.*;
public class ehab4 {
public static void main( String[] args ) {
Scanner in = new Scanner( System.in );
int a = 0, b = 0;
System.out.println( "? 0 0 " );
System.out.flush();
int c = in.nextInt();
for ( int i = 29; i >= 0; i-- ) {
System.out.println( "? " + ( a + ( 1 << i ) ) + ... | logn | 1088_D. Ehab and another another xor problem | CODEFORCES |
//package codeforces;
import java.util.Scanner;
public class ex5 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String S [] = new String[3];
int m=0,s=0,p=0;
int temp=0;
for (int i = 0; i < S.length; i++) {
S[i]=scan.next();
if(S[i].indexOf('m')!=-1) m++;
if(S[i].indexO... | constant | 1191_B. Tokitsukaze and Mahjong | CODEFORCES |
import java.util.*;
import java.io.*;
public class SolutionC{
public static void main(String[] args) throws Exception{
Scanner sc=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int t=sc.nextInt();
int[] arr=new int[10000002];
for(int i=0;i<arr... | cubic | 1497E2 | CODEFORCES |
import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;
public class Solution implements Runnable{
private static BufferedReader br = null;
private static PrintWriter out = null;
private static StringTokenizer stk = null;
public static void main(String[] args) {
br =... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
public class Solver {
StringTokeniz... | nlogn | 169_A. Chores | CODEFORCES |
//package arbuz;
import java.util.Scanner;
public class Arbuz {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n % 4 == 0 || n % 7 == 0 || n % 47 == 0 || n % 74 == 0 || n % 444 == 0 || n % 447 == 0 || n % 474 == 0 || n % 477 == 0) {... | constant | 122_A. Lucky Division | CODEFORCES |
//2021 global14
// jzzhao
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
int tc = sc.ni();
for (int rep = 0; rep < tc; rep++) {
... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* Date 22.11.2011
* Time 17:49:45
* Author Woodey
* $
*/
public class A15 {
final double eps = 10e-9;
class Pair implements Comparable<Pair>{
int x;
... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class C_138B {
private static BufferedReader i... | linear | 224_B. Array | CODEFORCES |
import java.util.*;
public class Main
{
public static void main(String[]args)
{
Scanner input=new Scanner (System.in);
while(input.hasNext())
{
long n=input.nextLong();
if(n==1||n==2)
System.out.println(n);
else if(n%2==1)
... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.util.*;
public class A {
int n;
int[] arr;
void run(){
Scanner s = new Scanner(System.in);
n = s.nextInt();
arr = new int[n];
int even, odd;
even = 0;
odd = 0;
for (int i = 0; i < n; i++) {
arr[i] = s.nextInt();
... | linear | 25_A. IQ test | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
static class FastScanner {
private BufferedReader bufferedReader;
private StringTokenizer stringTokenizer;
public FastScanner(InputStream inputStream) {
bufferedReader = new BufferedReader(new InputStreamReader(inputStre... | logn | 1195_B. Sport Mafia | CODEFORCES |
/**
* Created by IntelliJ IDEA.
* User: piyushd
* Date: 3/26/11
* Time: 10:53 PM
* To change this template use File | Settings | File Templates.
*/
public class TaskB {
int[] levels;
int[] loyalty;
int n, k, A;
double ans = Double.NEGATIVE_INFINITY;
void rec(int ix, int sweets, int[] loya... | np | 105_B. Dark Assembly | CODEFORCES |
/*
* Created on 17.05.2019
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Wolfgang Weck
*/
public class C01Easy {
public static void main(String[] args) {
try (BufferedReader r = new BufferedReader(new InputStreamReader(System.in))) {
final Strin... | linear | 958_C1. Encryption (easy) | CODEFORCES |
import java.util.Scanner;
public class Iq {
static void metod() throws Exception {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] m = new int[n];
for (int i = 0; i < n; i++)
m[i] = in.nextInt();
byte k = 0;
if (m[0] % 2 == 0) {
... | linear | 25_A. IQ test | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @autho... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.Random;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {
... | np | 1209_E2. Rotate Columns (hard version) | CODEFORCES |
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
while (n-- > 0) {
int a = in.nextInt();
int b = in.nextInt();
int k = 0;
while (a != 0 && b != 0) {
if (a > b) {
int ... | constant | 267_A. Subtractions | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Main implements Runnable {
int n;
boolean inBound (int x, int y) {
return x >= 1 && y >= 1 && x <= n && y <= n;
}
void solve() throws Exception {
n = sc.nextInt();
int y = sc.... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
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 Main implements Runnable {
... | np | 16_E. Fish | CODEFORCES |
import java.util.*;
import java.io.*;
public class Songs {
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new D... | np | 1185_G1. Playlist for Polycarp (easy version) | CODEFORCES |
import java.io.*;
import java.util.*;
public class CF1141F {
static class V {
int l, r, a;
V(int l, int r, int a) {
this.l = l; this.r = r; this.a = a;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter p... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class B {
BufferedReader reader;
StringTokenizer tokenizer;
PrintWriter out;
public void solve() throws IOException {
int N = nextInt();
int... | linear | 468_B. Two Sets | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
FastScanner sc=new FastScanner();
PrintWriter pw=new PrintWriter(System.out);
double eps=1e-12;
while(sc.hasNext()){
int n=sc.nextInt();
int r=sc.nextInt();
... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.io.*;
import static java.lang.Math.*;
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;
public class Main {
final static boolean debug = false;
final static String fileName = "";
final static boolean useFiles = false;
public static void main(String[] args) throws Fil... | constant | 630_A. Again Twenty Five! | CODEFORCES |
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class C {
public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String[] line = in.readLine().split(" ");... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.io.*;
import java.util.*;
public class B {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
long f(int x, int y, int sz) {
if (x > y) {
int tmp = x;
x = y;
y = tmp;
}
if (sz <= x)
return (long) sz * (sz + 1) / 2;
if (sz >= x + y - 1)
return (long) x * y;
... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long k = sc.nextLong();
System.out.println(solve(n, k));
sc.close();
}
static long solve(long n, long k) {
return Math.max(0, Math.min(n, k - 1) - ((k + ... | constant | 1023_B. Pair of Toys | CODEFORCES |
import java.util.Scanner;
/**
* @author Alexander Grigoryev
* Created on 01.08.11
*/
public
class Main
{
static Scanner in = new Scanner(System.in);
public static
void main(String[] args)
{
String s = in.nextLine();
int k, ans = 0;
for(int i = 0; i < s.length(); i++... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args)throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
//idea 1 : K/2번까지만 ... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.util.*;
public class A {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
String s = sc.next();
for (int l = s.length(); l > 0; --l) {
HashSet<String> set = new HashSet<String>();
for (int i = 0; i < s.length() - l + 1; +... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.util.*;
import java.io.*;
public class CFEdu23C
{
static long sum(long n)
{
long ans=0;
while(n>0)
{
ans+=(n%10);
n/=10;
}
return ans;
}
static long BS(long l,long h,long s)
{
if(l<=h)
{
long m=(l+h)/2l;
if(m-sum(m)>=s && (m==1 || (m-1)-sum(m-1)<s))
return m;
else if(... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.util.*;
import java.io.*;
public class EdF {
static long[] mods = {1000000007, 998244353, 1000000009};
static long mod = mods[0];
public static MyScanner sc;
public static PrintWriter out;
public static void main(String[] havish) throws Exception{
// TODO Auto-generated method stub
sc = new MyS... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.io.*;
import java.util.*;
public class C {
void run() throws IOException {
int n = ni(), m = ni(), k = ni(), q = n * m, h = 0, t = 0, inf = 123456;
int[] x = new int[q], y = new int[q];
int[][] d = new int[n][m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
d[i][j] = inf;
for ... | cubic | 35_C. Fire Again | CODEFORCES |
/*
* Hello! You are trying to hack my solution, are you? =)
* Don't be afraid of the size, it's just a dump of useful methods like gcd, or n-th Fib number.
* And I'm just too lazy to create a new .java for every task.
* And if you were successful to hack my solution, please, send me this test as a message or to Abr... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.util.Scanner;
public class GenerateLogin {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String a = scan.next();
String b = scan.next();
char last = b.charAt(0);
String ans = ""+a.charAt(0);
for(int i = 1;i<a.length();i++){
if(a.charAt(i)>=last)break;
a... | linear | 909_A. Generate Login | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
public class KingEscape {
public static void main(String[] args) {
Reader read = new Reader();
int n = read.nextInt();
int a1 = read.nextInt();
... | constant | 1033_A. King Escape | CODEFORCES |
import java.util.Scanner;
public class Main{
static final double eps = 1e-10;
public static void main(String []args){
Scanner cin = new Scanner(System.in);
double a,v;
double l,d,w;
double time;
a = cin.nextDouble();
v = cin.nextDouble();
l = cin.nextDouble();
d = cin.nextDouble();
w = cin.ne... | constant | 5_D. Follow Traffic Rules | 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.ArrayList;
import java.util.List;
i... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
//Author: Patel Rag
//Java version "1.8.0_211"
import java.util.*;
import java.io.*;
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); }
String next()
{
while (st == null |... | constant | 1075_A. The King's Race | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class A {
public static void main(String[] args) throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
String input;
while ((input = reader.readLine()) != n... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;
import javafx.util.Pair;
public class Solve6 {
public static void main(String[] args) throws IOException... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
pu... | cubic | 1515_E. Phoenix and Computers | CODEFORCES |
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Round1TaskB implements Runnable {
static PrintWriter pw = null;
static BufferedReader br = null;
StringTokenizer st = null;
public static void main(String[] args) throws IOException {
pw = new PrintWriter(new Ou... | linear | 1_B. Spreadsheets | CODEFORCES |
// LM10: The next Ballon d'or
import java.util.*;
import java.io.*;
import java.math.*;
import javafx.util.Pair;
public class Main
{
static class FastReader
{
private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public FastReader() { this(System.in); }public FastRead... | linear | 1038_D. Slime | 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;
import java.util.TreeMap;
import java.util.TreeSet;
public class Main {
static void insert(TreeMa... | nlogn | 528_A. Glass Carving | CODEFORCES |
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
private static final int MAX = 5000 + 10,mod = 1000000007;
private static char [] S;
private static int n;
private static Integer [] [] dp = new Integer[MAX][MAX];
private static int solve(int pos,int open){
if... | quadratic | 909_C. Python Indentation | CODEFORCES |
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.util.StringTokenizer;
public class A {
static StringTokenizer st;
static BufferedReader br;
static PrintWriter pw;
... | linear | 1004_A. Sonya and Hotels | CODEFORCES |
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.HashSet;
public class C {
public static void main(Str... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.util.*;
import java.io.*;
public class solve {
Scanner in;
PrintWriter out;
public void solve() throws IOException {
int n = in.nextInt();
long k = in.nextLong();
int[] a = new int[n];
Set<Long> b = new TreeSet<Long>();
for (int i = 0; i < n; i++) {
a[i] = in.nextInt();
}
Arrays.sort(a... | nlogn | 274_A. k-Multiple Free Set | CODEFORCES |
import java.util.*;
import java.io.*;
public class e{
int n;
double f[];
double a[][];
public void run(){
Locale.setDefault(Locale.US);
Scanner in = new Scanner(System.in);
n = in.nextInt();
a = new double[n][n];
for(int i=0;i<n;i++) for(int j=0;j<n;j++) a[i][j] = in.nextDouble();
f = ... | np | 16_E. Fish | CODEFORCES |
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class C2 {
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(new File("input.txt"));
PrintWriter pw = new PrintWriter(new File("output.txt"));
in... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;
/**... | np | 1102_F. Elongated Matrix | CODEFORCES |
import java.io.*;
import java.util.*;
public class Problem_A {
public static void main(String[] args) {
MyScanner scan = new MyScanner();
int n = scan.nextInt();
int[] elements = new int[n];
for (int i = 0; i < n; i++)
elements[i] = scan.nextInt();
int x = 0;
Arrays.sort(elements);
while(n > ... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.IOException;
import java.util.StringTokenizer;
/*
* @author Tnascimento
*/
public class MaeDosDragoes {
// public static StringTokenizer tokenizer;
// public static BufferedReader rea... | np | 839_E. Mother of Dragons | CODEFORCES |
import java.io.*;
import java.util.*;
public class Solution {
private static StringTokenizer st;
private static int n;
private static int k;
private static boolean[][] graph;
private static int[] dp;
private static int maxCliqueSize;
public static void main(String[] args) throws Exception {
BufferedReader ... | np | 839_E. Mother of Dragons | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
static class Reader
{
private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
public int read() {if (nu... | logn | 1019_B. The hat | CODEFORCES |
import java.util.*;
import java.io.*;
import java.text.DecimalFormat;
public class Main{
final long mod = (int)1e9+7, IINF = (long)1e19;
final int MAX = (int)1e6+1, MX = (int)1e7+1, INF = (int)1e9;
DecimalFormat df = new DecimalFormat("0.0000000000000");
FastReader in;
PrintWriter out;
static ... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
/**
* Created by IntelliJ IDEA.
* User: Taras_Brzezinsky
* Date: 9/16/11
* Time: 1:27 PM
* To change this template use File | Settings | File Templates.
*/
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.Queue;
import java.util.StringTok... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
FastScanner in;
PrintWriter out;
void solve() {
int tc = in.nextInt();
for (int t = 0; t < tc; t++) {
int n = in.nextInt();
int m = in.nextInt();
O[] a = new O[n * m];
int[][] cols = new ... | np | 1209_E2. Rotate Columns (hard version) | CODEFORCES |
import java.util.*;
public class Main{
public static void main(String[]args){
for(Scanner cin=new Scanner(System.in);cin.hasNextLong();System.out.println(Math.max(0,(Long.highestOneBit(cin.nextLong()^cin.nextLong())<<1)-1)));
}
}
| logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
import java.util.*;
import java.io.*;
public class Solution{
public static long page(long p,long k){
return (p-1)/k;
}
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
i... | linear | 1191_C. Tokitsukaze and Discard Items | CODEFORCES |
import java.util.*;
public class A {
static int [] reverse = new int [257];
public static void main (String [] arg) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int [] A =new int [n];
for (int i = 0; i<A.length; ++i) A[i] = sc.nextInt();
Arrays.sort(A);
if (n == 1) {
System.out.println(... | nlogn | 135_A. Replacement | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class A {
void run(){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
boolean dif = false;
for(int i=0;i<n;i++)a[i]=sc.nextInt();
Arrays.sort(a);
if(n==1){
... | nlogn | 135_A. Replacement | CODEFORCES |
import java.io.*;
import java.util.*;
public class C
{
String line;
StringTokenizer inputParser;
BufferedReader is;
FileInputStream fstream;
DataInputStream in;
void openInput(String file)
{
if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
else
{
try{
fstrea... | linear | 46_C. Hamsters and Tigers | CODEFORCES |
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.lang.Character.*;
import static java.lang.Double.*;
public class A {
Scanner scan = new Scanner(System.in);
void solve() {
int n = scan.nextInt();
String[]A = new String[n];
String[]B = new String[n]... | linear | 1000_A. Codehorses T-shirts | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* Created with IntelliJ IDEA.
* User: Alexey
* Date: 16.09.12
* Time: 19:29
* To change this template use File | Settings | File Templates.
*/
public clas... | linear | 224_B. Array | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System... | nlogn | 169_A. Chores | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
public class Solution {
class... | nlogn | 166_A. Rank List | CODEFORCES |
import java.io.PrintStream;
import java.util.Scanner;
public class Cfbra {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintStream out = System.out;
out.println(in.nextInt() / 2 * 3);
}
}
| constant | 84_A. Toy Army | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.