src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringclasses 256
values | from stringclasses 1
value |
|---|---|---|---|
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int n=scan.nextInt();
int m=scan.nextInt();
int[] game=new int[n];
int[] bill=new int[m];
for (int i = 0; i <n ; i++) {
game[i]=scan.ne... | linear | 1009_A. Game Shopping | CODEFORCES |
import java.io.*;
import java.util.*;
public class Solution {
static class Data{
int x,i;
Data(int x,int i){
this.x = x;
this.i = i;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStream... | nlogn | 1006_B. Polycarp's Practice | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = in.nextInt();
}
int min;
int count = 0;
... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.util.HashMap;
import java.util.Scanner;
import javax.swing.text.html.HTMLDocument.Iterator;
public class Main
{
public static double p[];
static double s[];
static double m[];
static int n;
public static double a[][];
public static int index=0;
public static boolean vis[];
... | np | 16_E. Fish | CODEFORCES |
import java.io.*;
import java.util.*;
public class MainG {
static StdIn in = new StdIn();
static PrintWriter out = new PrintWriter(System.out);
static long M=(long)1e9+7;
public static void main(String[] args) {
char[] cs = in.next().toCharArray();
int n=cs.length;
int[] x = new int[n];
for(int i=0; i<n;... | quadratic | 908_G. New Year and Original Order | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static double eps = 1e-8;
public static void main(String[] args) {
Scanner r = new Scanner(System.in);
int n = r.nextInt();
int t = r.nextInt();
House[] a = new House[n];
for(int i ... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper ... | logn | 338_A. Quiz | CODEFORCES |
import java.io.IOException;
import java.util.Locale;
import java.util.Scanner;
public class A {
public void processInput() throws IOException {
Scanner in = new Scanner(System.in);
long n = in.nextLong();
long res = go(n);
System.out.printf(Locale.ENGLISH, "%d\n", res);
... | constant | 313_A. Ilya and Bank Account | CODEFORCES |
import java.io.*;
import java.util.*;
public class MainG {
static StdIn in = new StdIn();
static PrintWriter out = new PrintWriter(System.out);
static long M=(long)1e9+7;
static int n, dig;
static int[] x;
static long[] p10, s;
static long[][][] dp;
public static void main(String[] args) {
char[] cs = in.n... | quadratic | 908_G. New Year and Original Order | CODEFORCES |
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Reader;
impor... | linear | 468_B. Two Sets | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class YouAreGivenAString {
void run() {
try {
BufferedReader bfd = new BufferedReader(new InputStreamReader(
System.in));
int i, j, k, mxLen = 0;
String s= bfd.readLine();
... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(reader.readLine());
StringToke... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Main {
FastScanner in;
PrintWriter out;
static final String FILE = "";
public void solve() {
int n = in.nextInt();
TreeMap<Character, Integer> map = new TreeMap<>();
ArrayList<Integer> list = ne... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class c1523 implements Runnable{
public static void main(String[] args) {
try{
new Thread(null, new c1523(), "process", 1<<26).start();
}
catch(Exception e){
... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.util.Scanner;
public class D2 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int array[] =new int[n];
for(int i=0; i<=n-1; i++) {
array[i] = sc.nextInt();
}
int m = sc.nextInt();
int result = count(array);
for(int i=1; i<=m; i++) {
... | quadratic | 911_D. Inversion Counting | CODEFORCES |
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
static int check(int temp)
{
int count1 = 0;
while (temp>0)
{
if(temp % 2 != 0)
cou... | linear | 608_B. Hamming Distance Sum | CODEFORCES |
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main{
private static Parser in;
private static PrintWriter out;
public static void main(String[] args){
in = new Parser(Sys... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.*;
import java.util.StringTokenizer;
public class C2 {
String filename = null;
InputReader sc;
void solve() {
int n = sc.nextInt();
int[] a = sc.nextArray(n);
int[] ps = new int[n];
int[] q = new int[n];
int[] qs = new int[n];
int nq = 0;
... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.util.*;
public class A23 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
char[] input = sc.nextLine().toCharArray();
int[][] dyn = new int[input.length][input.length];
int max = 0;
for(int a = 0; a < input.length; a++) {
for(int b = a + 1; b < input.length; b++)... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import static java.lang.Math.*;
public class Main2 {
private FastScanner scanner = new FastScanner();
public static void main(String[] args) {
new Main2().solve();
}
private void... | nlogn | 976_C. Nested Segments | CODEFORCES |
import java.io.*;
import java.util.*;
public class TaskE {
static int[][] transpose(int[][] a, int n, int m) {
int[][] t = new int[m][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
t[j][i] = a[i][j];
}
}
return t;
}
... | np | 1209_E2. Rotate Columns (hard version) | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
imp... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.util.*;
public class House {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t = sc.nextInt();
ArrayList<HS> list = new ArrayList<HS>();
for (int i = 0; i < n; i++) {
list.add(new HS(sc.nextInt(),sc.nextInt()));
}
Collections.sor... | nlogn | 15_A. Cottage Village | 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... | np | 1242_C. Sum Balance | 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 {
BufferedRe... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
public class Handbag
{
// http://codeforces.com/problemset/problem/8/C
// Source of most code : http://codeforces.com/contest/8/submission/3492661
// Keep track of eac... | np | 8_C. Looking for Order | CODEFORCES |
/* Codeforces Template */
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;
public class Main {
static long initTime;
static final Random rnd = new Random(7777L);
static boo... | logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
//package prac;
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 Round568G {
InputStream is;
PrintWriter out;
String INPUT = "";
//
void solve()
{
int n = ... | cubic | 1185_G2. Playlist for Polycarp (hard version) | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class E implements Runnable {
public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();}
int n, m;
char[] str;
int[][] occs, cost;
int[] dp;
public void run() {
FastScanner fs = new FastScanner();
P... | np | 1238_E. Keyboard Purchase | CODEFORCES |
//~ 22:04:48
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String out = "";
String[] p = br.... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.util.*;
import java.io.*;
public class A
{
public static void main(String ar[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s1[]=br.readLine().split(" ");
int n=Integer.parseInt(s1[0]);
int S=In... | constant | 1061_A. Coins | CODEFORCES |
import java.io.*;
import java.util.*;
public class Codeforces
{
public static void main(String args[])throws Exception
{
BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb=new StringBuilder();
String s[]=bu.readLine().split(" ");
int n=Integ... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.io.IOException;
import java.util.Locale;
import java.util.Scanner;
public class A {
private void processInput() throws IOException {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
long res = go(n);
System.out.printf(Locale.ENGLISH, "%d\n", res);
in.close();
}
pri... | constant | 84_A. Toy Army | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer tok;
static boolean h... | linear | 1000_A. Codehorses T-shirts | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template ... | linear | 1191_D. Tokitsukaze, CSL and Stone Game | CODEFORCES |
import java.util.*;
import java.io.*;
public class luckydivision {
public static int i(String s){
return Integer.parseInt(s);
}
public static boolean solve(String k, int n){
int temp = i(k);
if(temp > n){
return false;
}
if(n % temp == 0)
return true;
if(solve(k + "7", n))
return true;
retur... | constant | 122_A. Lucky Division | CODEFORCES |
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution ... | np | 16_E. Fish | CODEFORCES |
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
long num = input.nextLong();
if(num==0){
System.out.println(num);
}else if(num==1||num==2){
System.out.println(num);}
else i... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class A {
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int k = scan.nextInt()-1;
PrimeGen p = new PrimeGen(n);
List<Integer> prims = new ArrayList<I... | linear | 17_A. Noldbach problem | CODEFORCES |
import java.io.*;
import java.util.*;
public final class Solution {
static PrintWriter out = new PrintWriter(System.out);
static FastReader in = new FastReader();
static long mod = (long) 1e9 + 7;
static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, 1)};
... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.util.*;
public class Test { public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int x= (int)Math.sqrt(n) ;
int a[] = new int[n+5];
for(int i=1,o=n,j;i<=n;i+=x)
for(j=(int)Math.min(i+x-1,n);j>=i;a[j--]=o--);
for(int i=1;i<=n;i++)System.out.print(a[i]+" ");
Syste... | linear | 1017_C. The Phone Number | CODEFORCES |
import java.io.*;
public class Main {
public static void main (String [] args) throws IOException {
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
do {
int n = Integer.parseInt (br.readLine ());
//args;
int [] ns = new int [(args = br.readLine ().split (" ")).length];
int e... | linear | 25_A. IQ test | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class EhabAndAComponentChoosingProblem {
long INF = (long) 1e18;
int n;
int[] a;
... | linear | 1088_E. Ehab and a component choosing problem | CODEFORCES |
import java.io.*;
import java.util.*;
public class B {
void solve() throws IOException {
in = new InputReader("__std");
out = new OutputWriter("__std");
int n = in.readInt();
int a = in.readInt();
int b = in.readInt();
int ma = 0;
int mb = 1;
if (a ... | linear | 468_B. Two Sets | CODEFORCES |
import java.util.*;
import java.io.*;
public class code{
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int ok,ok2;
int va,vb;
va = 0;
vb = 0;
out.println("? "+va+"... | logn | 1088_D. Ehab and another another xor problem | CODEFORCES |
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class DTask {
static Scanner in;
static int[] first = new int[4];
static int[] second = new int[4];
static PrintWriter out;
static int n;
public static void main(String[] args) throws... | logn | 713_B. Searching Rectangles | CODEFORCES |
//package codeforces.br23;
import java.io.*;
/**
* User: Kandy
* Date: 12.07.2010
* Time: 21:51:52
*/
public class ProblemA {
public void solve() {
boolean oj = true;
try {
Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("A.in");
Writer writer = ... | cubic | 23_A. You're Given a String... | CODEFORCES |
//https://github.com/EgorKulikov/yaal/tree/master/lib/main/net/egork
import java.util.*;
import java.io.*;
public class B{
static PrintWriter out;
static InputReader in;
public static void main(String args[]){
out = new PrintWriter(System.out);
in = new InputReader();
new B(... | cubic | 1515_E. Phoenix and Computers | 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.util.Scanner;
public class IQ {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; i++)
a[i] = scan.nextInt();
for(int i = 0; i < n; i++) {
boolean x = a[i] % 2 == 0;
int... | linear | 25_A. IQ test | CODEFORCES |
import java.util.Scanner;
public class ChainReaction {
public static void main(String [] args) {
Scanner kb = new Scanner(System.in);
int num = kb.nextInt();
int[] beacons = new int[1000002];
for (int i=0; i<num; i++) {
beacons[kb.nextInt()] = kb.nextInt();
}
int [] dp = new int[1000002];
int... | linear | 608_C. Chain Reaction | CODEFORCES |
import java.util.*;
import java.io.*;
public class C {
private static int[] dx = {1, -1, 0, 0};
private static int[] dy = {0, 0, -1, 1};
public static void main(String[] args) throws Exception{
Thread t = new Thread(null, null, "~", Runtime.getRuntime().maxMemory()){
@Override
public void run(){
try {... | cubic | 35_C. Fire Again | CODEFORCES |
/**
* Write a description of class VK2A here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.*;
public class VK2A
{
public static void main(String args[])
{
Scanner S = new Scanner(System.in);
int n = S.nextInt();
int a = S.nextInt();
... | nlogn | 169_A. Chores | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Vector;
/**
* Created with IntelliJ IDEA.
* User: horikawa
* Date: 3/23/13
* Time: 1:29 AM
* To change this template use File | Settings | File Templates.
*/
public class B {
public static void main (S... | logn | 287_B. Pipeline | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main implements Runnable {
private void solution() throws IOException {
int n = in.nextInt();
int m = in.nextInt();
boolean[][] adj = new boolean[n][n];
long res = 0;
for (int i = 0; i < m; ++i) {
int x = in.nextInt();
int y = in.nextInt();
adj[x -... | np | 11_D. A Simple Task | CODEFORCES |
// @author Sanzhar
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Template {
BufferedReader in;
PrintWriter out;
StringTokenizer st;
String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(in.readLine()... | constant | 267_A. Subtractions | 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.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is... | quadratic | 909_C. Python Indentation | CODEFORCES |
import static java.lang.Math.*;
import java.util.*;
import java.io.*;
public class A {
public void solve() throws Exception {
int n = nextInt();
int[] p = nextArr(n);
Arrays.sort(p);
int sum = 0;
for (int i=0; i<n; ++i) sum+=p[i];
int curr = 0;
for ... | nlogn | 160_A. Twins | CODEFORCES |
import java.util.*;
import java.text.*;
import java.io.*;
import java.math.*;
public class code5 {
InputStream is;
PrintWriter out;
static long mod=pow(10,9)+7;
static int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
String arr[];
long dp[][];
void solve() throws IOException
{
int n=ni();
int a[]=na(n);
int q=ni();
... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
private static IO io;
public static void main(String[] args) throws IOException {
new Main().run();
}
private void run() throws IOException {
io = new IO(System.getProperty("O... | nlogn | 169_A. Chores | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
public class P111C{
Scanner sc=new Scanner(System.in);
int INF=1<<28;
double EPS=1e-9;
int h, w;
void run(){
h=sc.nextInt();
... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.io.*;
import java.util.*;
public class p343a
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println();
long a = sc.nextLong();
long b = sc.nextLong();
if(a==b) System.out.println("1");
else if(b==1) System.o... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.util.*;
import java.io.*;
public class A{
static long mod = 1000000000+7;
static int arr[];
static HashMap<Long,Long> map = new HashMap<>();
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long x = scan.nextLong();
long k = scan.nextLong();
if(x == 0)
{
Syste... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
//package codeforces.br25;
import java.io.*;
import java.math.*;
import java.util.*;
public class ProblemA {
public void solve() {
boolean oj = true;
try {
Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("A.in");
Writer writer = oj ? new OutputStream... | linear | 25_A. IQ test | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import ... | nlogn | 903_D. Almost Difference | CODEFORCES |
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class D {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new Out... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] arr = new int[n];
HashMap<Integer, Integer> m... | nlogn | 1005_C. Summarize to the Power of Two | CODEFORCES |
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class A
{
private static final long MOD = 1000000009L;
public static void main(String [] args) throws IOException
{
Scanner in = new Scanner(System.in);
long n = in.nextInt(... | logn | 338_A. Quiz | CODEFORCES |
import java.util.Scanner;
public class A {
public static void main(String[] args) {
new A().solve();
}
public void solve() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t = sc.nextInt();
float[] left = new float[n];
float[] right = new... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author pttrung
*/
public class B {
static Senator[] data;
public static void main(S... | np | 105_B. Dark Assembly | CODEFORCES |
import java.io.BufferedReader;
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 MainC {
private FastScanner in;
private PrintWriter out;
private int N;
private ... | np | 8_C. Looking for Order | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class C
{
public static void main(String[] args)
{
new C();
}
final int oo = (int)1e9;
int Hx,Hy;
int N;
int[][] P;
int[] memo;
int[][] soln;
int[] dist1;
int[][] dist2;
C()... | np | 8_C. Looking for Order | CODEFORCES |
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner in=new ... | 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.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author KharYusuf
*/
public class ... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static final int MOD = (int)1e9 + 7;
static int n;
static int[] t;
static int[] g;
static int[][] memo;
static int dp(int mask, int rem, int last)
{
if(rem == 0)
return 1;
if(memo[last][mask] != -1)
return memo[last][mask... | np | 1185_G1. Playlist for Polycarp (easy version) | CODEFORCES |
// upsolve with rainboy
import java.io.*;
import java.util.*;
public class CF1187G extends PrintWriter {
CF1187G() { super(System.out); }
static class Scanner {
Scanner(InputStream in) { this.in = in; } InputStream in;
int k, l; byte[] bb = new byte[1 << 15];
byte getc() {
if (k >= l) {
k = 0;
try {... | cubic | 1187_G. Gang Up | CODEFORCES |
import javafx.util.Pair;
import java.util.*;
import static java.lang.Math.floor;
import static java.lang.Math.min;
public class Main {
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int n = scanInt();
List<Integer> a = scanList(n);
... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.util.*;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int first = Integer.MAX_VALUE, second = Integer.MAX_VALUE;
for (int i = 0, x; i < N; ++i) {
x = sc.nextInt();
if (x < fi... | nlogn | 22_A. Second Order Statistics | CODEFORCES |
import java.util.*;
public class task1 {
static void print(Object... a) {
for (Object aa : a) {
System.out.println(aa.toString());
}
}
static Map<Character, Integer> stringToCharsMap(String str) {
Map<Character, Integer> charcount = new HashMap<Character, Integer>();
... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
boolean eof;
public String nextToken() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (Exception e) {
eof = true;
return "-1";
}
}
return st.nextToken();
}
public int nextInt... | linear | 224_B. Array | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
private static void solve(InputReader in, OutputWriter out) {
int n = in.nextInt();
if (n < 6) {
out.println(-1);
} else {
int m = (n - 2);
for (int i = 2; i <= m; i++) {
out.prin... | linear | 959_C. Mahmoud and Ehab and the wrong algorithm | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
public class Solution{
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
StringTokenizer st;
for(int z=... | linear | 1197_A. DIY Wooden Ladder | CODEFORCES |
import static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import java.util.*;
import java.math.*;
import java.io.*;
public class Main implements Runnable {
boolean TEST = System.getProperty("ONLINE_JUDGE") == null;
void solve() throws IOException {
int ... | nlogn | 903_D. Almost Difference | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
static Scanner in;
static PrintWriter out;
// static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
public static void main(String[] args) throws Exception {
in = new Scanner(System.in);
out = new PrintWri... | np | 16_E. Fish | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
impo... | cubic | 840_C. On the Bench | 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
*/
public class Main {
public static vo... | quadratic | 908_C. New Year and Curling | CODEFORCES |
//package round136;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
public class A2 {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
int[] a = new int[n];
int[] b = new int[n... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
static BufferedReader br;
static PrintWriter out;
static StringTokenizer st;
static int[][] moves = new int[][]{{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
static boolean correct(int x, int y, int n, int m) {
return (x >= 0 && x < ... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class mainE {
public static PrintWriter out = new PrintWriter(System.out);
public static FastScanner enter = new FastScanner(System.in);
public static void main(String[] args) throws IOException {
int t=enter.nextIn... | np | 1209_E1. Rotate Columns (easy version) | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/*
public class _908C {
}
*/
public class _908C {
public void solve() throws FileNotFoundException {
InputStream in... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.io.*;
import java.util.*;
public class A{
InputStream is;
PrintWriter out;
String INPUT = "";
public void solve(){
int n=ni();
char[] arr=new char[n];
for(int i=0;i<n;i++){
arr[i]=ns().charAt(0);
}
long mod=1000000007;
long[][] memo=new long[n][n];
memo[0][0]=1L;
int k=0;
for(in... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main implements Runnable {
public void _main() throws IOException {
int n = nextInt();
int[] a = new int[n];
String s = next();
for (int i = 0; i < n; i++)
a[i] = s.charAt(i) == 'H' ? 1 : 0;
int res = 10 * n;
for (int i = 0; i < n; i++) {
int[] b =... | linear | 46_C. Hamsters and Tigers | 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.... | np | 1242_C. Sum Balance | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
long x = input.nextLong();
if(x==1||x==2){System.out.println(x);
}
else if(x%2==0&&x>2&&x%3!=0){
System.out.println((x)*(x-1)*(x-3));
}else if(x%2==0&&x%3==0){
System.... | constant | 235_A. LCM Challenge | 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... | constant | 267_A. Subtractions | 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.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at ... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class One {
InputStreamReader inp = new InputStreamReader(System.in);
BufferedReader in = new BufferedRead... | nlogn | 22_A. Second Order Statistics | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class template {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt();
Integer[] arr = new Integer[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.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(new B... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;
im... | np | 105_B. Dark Assembly | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.