src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringclasses 256
values | from stringclasses 1
value |
|---|---|---|---|
import java.io.*;
import java.util.*;
public class CF {
class W implements Comparable<W> {
int id, sz;
W(int id, int sz) {
this.id = id;
this.sz = sz;
}
@Override
public int compareTo(W o) {
return -Integer.compare(sz, o.sz);
}
}
int[] left;
int center;
boolean[] used;
boolean go(int v)... | cubic | 387_D. George and Interesting Graph | CODEFORCES |
import java.util.Scanner;
public class TaskC {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), r = sc.nextInt();
int[] xcords = new int[n];
double[] ycords = new double[n];
double y = r, x = 0, px = 0, ty = 0;
for(int i = 0; i < n; i++) {
xcords[i] = ... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.A... | cubic | 23_A. You're Given a String... | CODEFORCES |
/*
* Created on 17.05.2019
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Wolfgang Weck
*/
public class A01Easy {
private static interface Matrix {
boolean get(int i, int j);
int size();
}
private static class MData implements Matrix {
priva... | quadratic | 958_A1. Death Stars (easy) | CODEFORCES |
import java.io.* ;
import java.util.* ;
public class Codeshefcode {
final static long r = 1000000007 ;
static FasterScanner ip = new FasterScanner() ;
static PrintWriter op = new PrintWriter(System.out) ;
public static void main(String[] args) throws IOException{
int n = ip.i() ;
TreeMap<Character,Integer... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String ns = sc.next();
sc.close();
int n1 = Integer.parseInt(ns);
int n2 = Integer.parseInt(ns.substring(0, ns.length() - 1));
int n3 = Integer.parseInt(ns.substring(0, ns.length() ... | constant | 313_A. Ilya and Bank Account | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
public class Main {
static PrintWriter out;
static InputReader ir;
static void solve() {
int n = ir.nextInt();
int t = ... | np | 1185_G1. Playlist for Polycarp (easy version) | CODEFORCES |
import java.io.*;
import java.util.*;
public class CF1009E {
static final int MD = 998244353;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(b... | linear | 1009_E. Intercity Travelling | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class OlyaAndMagicalSquare {
void solve() {
long[] dp = new long[32];
dp[0] = 0;
for (int i = 1; i < 32... | logn | 1080_D. Olya and magical square | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class SequenceTransformation {
void solve() {
int p = 1, n = in.nextInt();
while (n > 0) {
if (n ==... | linear | 1059_C. Sequence Transformation | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main{
public static void main( String[] args ){
Scanner cin = new Scanner( System.in );
String s = cin.next();
int n = s.length();
char[] ss = new char[ n ];
ss = s.toCharArray();
int ans = 0;
for (int i=0; i<n; i++)
for (int j=i+1; j<n; j++){
... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
long totalBlocks = 0;
long a[] = new long[n];
for(int i = 0; i < n; ++i) {
a[i] = sc.nextLo... | nlogn | 1061_B. Views Matter | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class CF_1029E_Tree_with_Small_Distances {
static ArrayList<Integer> adj[];
... | linear | 1029_E. Tree with Small Distances | CODEFORCES |
import java.util.*;
import java.io.*;
public class a {
static long mod = 1000000009;
static ArrayList<Integer>[] g;
public static void main(String[] args) throws IOException
{
//Scanner input = new Scanner(new File("input.txt"));
//PrintWriter out = new PrintWriter(new File("output.txt"));
input.init(... | logn | 338_A. Quiz | CODEFORCES |
import java.util.Scanner;
public class Prob023A
{
public static void main( String[] Args )
{
Scanner scan = new Scanner( System.in );
String s = scan.next();
all: for ( int x = s.length() - 1; x >= 0; x-- )
for ( int y = 0; x + y <= s.length(); y++ )
{
... | cubic | 23_A. You're Given a String... | CODEFORCES |
//package codeforces_464_div2;
import java.util.*;
import java.util.stream.Collectors;
public class F {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) arr[i] = sc.nextInt();
... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;
public class B
{
BufferedReader in;
PrintStream out;
StringTokenizer tok;
public B() throws NumberFormatException, IOException
{
in = new Buffe... | linear | 224_B. Array | CODEFORCES |
/**
* Author: Ridam Nagar
* Date: 27 February 2019
* Time: 01:17:36
**/
/*
package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{ ... | constant | 913_A. Modular Exponentiation | CODEFORCES |
//package com.example.programming;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class Test {
static class Pair {
int f,s;
public Pair(int x, int ... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.util.*;
import java.io.*;
public class C{
static PrintWriter out;
static InputReader in;
public static void main(String args[]){
out = new PrintWriter(System.out);
in = new InputReader();
new C();
out.flush(); out.close();
}
C(){
int w = solve();... | linear | 1190_B. Tokitsukaze, CSL and Stone Game | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
public class LuxuriousHouses {
public static void main(String[] args) thro... | constant | 630_A. Again Twenty Five! | 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... | quadratic | 908_G. New Year and Original Order | CODEFORCES |
import java.io.*;
public class again_25 {
public static void main(String ar[])throws IOException
{
long n;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n=Long.parseLong(br.readLine());
System.out.println("25");
}
}
| constant | 630_A. Again Twenty Five! | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
private void run() throws IOException {
int cx = in.nextInt();
int cy = in.nextInt();
int n = in.nextInt();
int[] x = new int[n];
int[] y = new int[n];
for (int i = 0; i < n; ++i) {
x[i] = in.nextInt() - cx;
y[i] = in.nextInt() - cy;
}
in... | np | 8_C. Looking for Order | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Colours {
public static void main(String args[] ) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int n = Integ... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import static java.lang.Math.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Character.*;
@SuppressWarnings("unused")
public class round176B {
static BufferedReader br = ... | logn | 287_B. Pipeline | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
static Scanner cin = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
static PrintWriter cout = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static void main(String[] agrs) throws IOException{
... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class CF274A {
public static void main(String[] args) throws Exception {
new CF274A().solve();
}
private void solve() throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
... | nlogn | 274_A. k-Multiple Free Set | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.Writer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author emotionalBlind
*/
public class Main {... | logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
import java.util.*;
import java.io.*;
public class A1 {
public static BufferedReader br;
public static StringTokenizer st;
public static String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (Ex... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.util.Scanner;
public class Main {
static class LeftOver {
int a;
long b;
long c;
LeftOver(int a, long b, long c) {
this.a = a;
this.b = b;
this.c = c;
}
}
private static long pow(long base, long coe) {
if (coe ... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
boolean eof;
String nextToken() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (Exception e) {
eof = true;
return "-1";
}
}
return st.nextToken();
}
int nextInt() {
return ... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class d {
double a, v, l, d, w;
private void solve() throws Exception {
a = nextInt(); v = nextInt(); l = nextInt(); d = nextInt(); w = nextInt();
double ans;
if (w >= v){
ans = fromSign(0, l);
}
else{
double tToW... | constant | 5_D. Follow Traffic Rules | CODEFORCES |
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;
import java.util.function.Predicate;
public class Main{
public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
static long MOD = (long) (1e9 + 7);
// static long MOD = 998244353;
... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.util.*;
import java.io.*;
public final class CF {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<String> a = new ArrayList<>();
for(int i = 0; i<n; i++)
a.add(sc.next());
int count = 0;
... | linear | 1000_A. Codehorses T-shirts | CODEFORCES |
import java.util.*;
public class Test
{
public static void main(String[] args)
{
Scanner t = new Scanner(System.in);
int n=t.nextInt();
int a[]= new int[n];
for(int i=0; i<n; i++)
a[i]=t.nextInt();
Arrays.sort(a);
int r=a[0];
for(int i=1; i<n; i++)
if(a[i]!=r)
... | nlogn | 22_A. Second Order Statistics | CODEFORCES |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class ProblemB {
public static void main(String[] args) throws IOException {
ProblemB... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class C {
static int[] nm;
stati... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long l = in.nextLong();
long r = in.nextLong();
in.close();
if (r - l < 2) {
System.out.println(-1);
return;
}
if ((r - l > 2)||(l%2 ==0 )) {
long s = l + l%2;
System.out... | constant | 483_A. Counterexample | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.Writer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @auth... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.util.Scanner;
public class DigitalSequence {
public static void print(String s) {
System.out.println(s);
}
public static void main(String[] args) {
long k = new Scanner(System.in).nextLong();
long i = 1,t=0, c = 9,digits = 0,l=0,k2=k;
while(t<k){
l ... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
long n;
long maxlcm;
void run(){
n = cin.nextInt();
if(n == 1 || n ==2)
maxlcm = n;
else if(n >= 3){
if(n % 2 != 0){
maxlcm = n * (n-1) * (n - 2);
}
else if(n%3 != 0)... | constant | 235_A. LCM Challenge | 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.StringTokenizer;
public class A {
static void solve(InputReader in, PrintWriter out) {
long n = in.nextLong();
out.pri... | constant | 630_A. Again Twenty Five! | CODEFORCES |
import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Task {
public static void solve() throws Exception {
int n = nextInt();
int[] S = new int[n];
for(int i=... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author George Marcus
*/
public class Main {
public static void main(String[] args) {
Inpu... | logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
import java.util.*;
import java.io.*;
public class _1523_C {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int t = Integer.parseInt(in.readLine());
... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.io.*;
import java.util.*;
public class CodeForce {
private void solve() throws IOException {
final int N = nextInt();
int []A = new int[N];
for(int i = 0; i < N; i++) A[i] = nextInt();
Arrays.sort(A);
if(A[N-1] == 1) A[N-1] = 2;
else A[N-... | nlogn | 135_A. Replacement | CODEFORCES |
//package contese_476;
import java.util.*;
public class q1
{
int m=(int)1e9+7;
public class Node
{
int a;
int b;
public void Node(int a,int b)
{
this.a=a;
this.b=b;
}
}
public int mul(int a ,int b)
{
a=a%m;
b=b%m;
return((a*b)%m);
}
public int pow(int a,int b)
{
int x=1;
while(b>0)
{
if(b%2!=0)
x=mul... | linear | 1013_B. And | CODEFORCES |
import java.util.Scanner;
public class A275 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long a=sc.nextLong();
long b=sc.nextLong();
if(b-a<2){
System.out.println(-1);
}else if(b-a==2 && a%2==1){
Sy... | constant | 483_A. Counterexample | CODEFORCES |
import java.util.Scanner;
/**
* Created by mmaikovych on 18.02.16.
*/
public class EER_A {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
scanner.nextLine();
System.out.println(25);
}
}
| constant | 630_A. Again Twenty Five! | CODEFORCES |
import java.util.*;
import java.io.*;
import java.text.*;
public class Main {
//SOLUTION BEGIN
//Into the Hardware Mode
void pre() throws Exception{}
void solve(int TC) throws Exception {
long K = nl();
K--;
int sz = 1;long pw = 1;
while(K >= pw){
long npw = ... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
//>>>BaZ<<<//
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
static int dx[] = {-1,1,0,0};
static int dy[] = {0,0,1,-1};
static long MOD = 1000000007;
static int INF = Integer.MAX_VALUE/10;
static PrintWriter pw;
static Reader scan;
//static MyFil... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.util.*;
public class hackerearth {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
HashMap<String,Integer> map=new HashMap<>();
HashMap<String,Integer> map2=new HashMap<>();
for(int i=0;i<n;i++)
{
... | linear | 1000_A. Codehorses T-shirts | CODEFORCES |
import java.io.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.StringTokenizer;
public class CodeForces {
public static void main(String[] args) throws FileNotFoundException {
FastIO io = new FastIO();
int width = io.nextInt();
int height = io.nextInt();
i... | cubic | 35_C. Fire Again | CODEFORCES |
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
long b=0;long p=1;
Scanner s=new Scanner(System.in);
long m=s.nextLong();
long x=1;
do{
p=(m+b)/x;
b=10*b+10;
x++;
}while(p/(long)Math.pow(10... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
solution.solve();
}
private void solve() {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t -- > 0) {
long ... | logn | 1080_D. Olya and magical square | CODEFORCES |
import java.io.*;
import java.util.*;
public class LookingForOrder
{
public Scanner in = new Scanner(System.in);
public PrintStream out = System.out;
public int[] go;
public int[][] cost;
public int [] sol;
public Pair[] how;
public int n, lim;
public Pair bag;
public Pair[] obj;
public void main()
... | np | 8_C. Looking for Order | CODEFORCES |
import java.io.BufferedWriter;
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.util.Arrays;
import java.util.InputMismatchException;
public class TestClass11 {
/**
* @param args... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test3 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int x=Integer.parseInt(br.readLine());
int ... | constant | 913_A. Modular Exponentiation | CODEFORCES |
//package round455;
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 C {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
int... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.util.Scanner;
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 13.05.11
* Time: 23:21
* To change this template use File | Settings | File Templates.
*/
public class ToyArmies {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long n = in.... | constant | 84_A. Toy Army | CODEFORCES |
import java.util.Scanner;
/**
*
* @author Ronak
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner in=new Scanner(System.in);
int n=in.nextInt();
... | linear | 25_A. IQ test | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;
public final class on_the_bench
{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static FastScanner sc=new FastScanner(br);
static PrintWriter out=new PrintWriter(System.out);
static Rando... | cubic | 840_C. On the Bench | CODEFORCES |
import javafx.collections.transformation.SortedList;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scan scan = new Scan();
int n = scan.scanInt();
... | linear | 1004_A. Sonya and Hotels | CODEFORCES |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class FireAgain {
static int n;
static int m;
public static void main(String[] args) throws IOException {
//... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Comparator;
public class Main {
private static StreamTokenizer in;
private static PrintWriter out;
static {
in = new StreamTokenizer(new BufferedRe... | np | 105_B. Dark Assembly | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static int bit[];
static int array[];
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
class Team implements Comparable<Team>{
int ac;
int penalty;
public Team(int ac, int penalty) {
this.ac = ac;
th... | nlogn | 166_A. Rank List | CODEFORCES |
//package codeforces;
import java.util.*;
public class Main {
class team implements Comparable<team>{
int pro,time;
public int compareTo(team oth) {
if(pro>oth.pro)
return -1;
if(pro==oth.pro&&time<oth.time)
return -1;
// TODO Au... | nlogn | 166_A. Rank List | CODEFORCES |
import java.awt.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;
import static java.lang.Math.max;
import static java.lang.Math.min;
public class C implements Runnable{
// SOLUTION!!!
// HACK ME PLEASE IF YOU CAN!!!
// PLEASE!!!
... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class D5 {
static int a, v, l, d;
static double w;
static double afterMark( int s, double w) {
if (2 * s * a > v * v - w * w) { // ���� ��������� v. ����� ��
return (v - w) * 1.0 / a + (s - (v * v - w * w) * 1.0 / (2 * a)) / v;
} else { // ��... | constant | 5_D. Follow Traffic Rules | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
public class Main implements Runnable {
class Home implements Comparable<Home> {
@Override
public int compareTo(Home arg0) {
return st - arg0.st;
}
int st, end;
}
... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception{
FastReader sc=new FastReader();
Outp... | logn | 1195_B. Sport Mafia | 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 PrintWriter saida = new PrintWriter(System.out, false);
public st... | np | 839_E. Mother of Dragons | 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 Div1_429C {
static final long MOD = 1_000_000_007;
static long[] fact = new long[3... | cubic | 840_C. On the Bench | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
public class B {
private static StreamTokenizer in;
private static PrintWriter out;
private static int nextInt() throws Exception{
in.nextToken();
return (int)in... | linear | 46_C. Hamsters and Tigers | CODEFORCES |
import java.util.Scanner;
public class A {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int f1 = 0;
int f2 = 1;
int f3 = 1;
while (f3 < n) {
f1 = f2;
f2 = f3;
f3 = f1 + f2;
... | constant | 199_A. Hexadecimal's theorem | CODEFORCES |
//package c;
import java.util.*;
import java.io.*;
public class Main {
int n,m;
int d[][];
Queue<int[]> q = new LinkedList<int[]>();
int cur[];
public void run() throws Exception{
Scanner in = new Scanner(new File("input.txt"));
PrintWriter out = new PrintWriter(new File("output.txt"));
n = in.nextInt();... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Practice {
public static long mod = (long) Math.pow(10, 9) + 7;
public static long[][] dp;
public static void main(String[] args) throws Exception {
BufferedR... | cubic | 1515_E. Phoenix and Computers | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Solution implements Runnable {
boolean hasBit(long n, int pos) {
return (n & (1L << pos)) != 0;
}
public void solve() throws Exception {
long l = sc.next... | logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
import java.util.Scanner;
import java.util.TreeMap;
public class B {
static Scanner in;
static void put(TreeMap<Integer, Integer> m, int key) {
if (m.containsKey(key)) {
m.put(key, m.get(key) + 1);
} else {
m.put(key, 1);
}
}
static void remove(TreeMap... | linear | 224_B. Array | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
long mod = (long)(1e+9+9);
long pow(long a,long b) {
long mul = a;
long res = 1;
while (b > 0) {
if (b %2 == 1) {
res = (res*mul)%mod;
}
mul = (mul*mul)%mod;
b/=2;
}
return res;
}
void solve() throws IOException {
long n = nextLong... | logn | 338_A. Quiz | CODEFORCES |
import java.util.Scanner;
public class LCM {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long n = scan.nextLong();
if (n <= 2)
System.out.println(n);
else if (n % 2 == 1)
System.out.println(n * (n - 1) * (n - 2));
... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.util.Map;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.TreeMap;
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... | linear | 468_B. Two Sets | CODEFORCES |
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class CottageVillage {
class cl {
int x=0;
int a=0;
cl(int x, int a){
this.x=x;
this.a=a;
}
}
class cmp implements Comparator<cl> {
publ... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.util.*;
public class A135 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = s.nextInt();
}
Arrays.sort(arr);
int[] ans = ne... | nlogn | 135_A. Replacement | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.StringTokenizer;
public class c {
public st... | nlogn | 912_C. Perun, Ult! | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
/**
*
* @author Natasha
*/
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int produzeni = in.nextInt();
int devices = in.nextInt();
int stekovi = in.nextInt();
int [] fi... | nlogn | 257_A. Sockets | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* Created by huhansan on 2017/12/19.
* http://codeforces.com/problemset/problem/11/D
* 参考 Petr http://codeforces.com/contest/11/submission/47646
* 求所有不同的环的个... | np | 11_D. A Simple Task | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Solution implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new S... | cubic | 35_C. Fire Again | CODEFORCES |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
Arrays.sort(a);
Set<Integer> di... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Scanner;
public class A {
static {
final Locale us = Locale.US;
if (!Locale.getDefault().equals(us)) {
Locale.se... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
s.nextLine();
while(s.hasNext()) {
int first = s.nextInt();
int second = s.nextInt();
System.out.println(calculate(... | constant | 267_A. Subtractions | CODEFORCES |
import java.util.*;
import java.math.*;
public class Solution{
private long [] sums;
private void solve(){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
int [] arr = new int[n];
this.sums = new long[n];
... | quadratic | 1197_D. Yet Another Subarray Problem | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main implements Runnable {
private BufferedReader in;
private PrintWriter out;
private StringTokenizer st;
private void eat(String line)
{
st = new StringTokenizer(line);
}
private String next() throws IOException
{
while(!st.hasMoreTokens()) {
Stri... | linear | 25_A. IQ test | CODEFORCES |
import java.math.BigInteger;
import java.util.Scanner;
public class TaskC {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
BigInteger x = new BigInteger(sc.next());
BigInteger k = new BigInteger(sc.next());
BigInteger mod = new BigInteger(String.valueOf((int) (Math.pow(10, 9)... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
/**
* Mx NINJA 04:06:52 ص 14/01/2014
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringBuilder line = new StringBui... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class taskB {
StringTokenizer st;
BufferedReader in;
PrintWriter out;
public static void main(String[] args) throws NumberFormatException,
... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
setup();
xuly();
}
private static long dp[][] = new long[20][170];
private static void setup() {
dp[0][0] = 1;
for (int i = 1; i < 20; i ++)
for (int j = 0; j < 170;... | logn | 817_C. Really Big Numbers | 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 ankur
*/
public class Main... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.