src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringclasses 256
values | from stringclasses 1
value |
|---|---|---|---|
import java.util.*;
import java.io.*;
import java.math.*;
public class loser
{
static class InputReader {
public BufferedReader br;
public StringTokenizer token;
public InputReader(InputStream stream)
{
br=new BufferedReader(new InputStreamReader(stream),32768);
... | nlogn | 608_A. Saitama Destroys Hotel | CODEFORCES |
import java.util.*;
import java.io.*;
public class ASimpleTask
{
/************************ SOLUTION STARTS HERE ***********************/
static long memo[][];
static int graph[];
static long hamiltonianPath(int mask , int u) {
if(memo[mask][u] != -1)
return memo[mask][u];
else if(u == Integer.numberOfTra... | np | 11_D. A Simple Task | CODEFORCES |
/*==========================================================================*/
/*
* AUTHOR: RonWonWon
* CREATED: 02.05.2021 19:58:57
* EMAIL: rachitpts.2454@gmail.com
*/
/*==========================================================================*/
import java.io.*;
imp... | linear | 1515_B. Phoenix and Puzzle | 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.util.TreeSet;
import java.util.StringTokenizer;
import java.util.AbstractCollection;
import java.io.InputStream;
/**
* Built usi... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
public class C817{
void solve()
{
long n = nl(), s = nl();
long l = 0, r = n;
while(l < r)
{
long mid = (l + r)/2;
if(mid - digSum(mid) < s)
l = mid + 1;
else
r = mid... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
String fileName = "<name>";
public TreeSet<Integer> set = new TreeSet<>();
public int getLowerDist(int x) {
Integer higher = set.higher(x);
Integer lower = set.lower(x);
if (higher == null)
return lower;
if... | linear | 1004_A. Sonya and Hotels | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] P = new int[n];
int[] check=new int[n];
for (int i = 1; i < n; i++) {
P[i] = scanner.nextInt();
... | linear | 913_B. Christmas Spruce | CODEFORCES |
import javax.swing.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) {
FastScanner scanner = new FastScanner();
long x = scanner.next... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class FireAgain {
static int dx[] = { 0, 0, 1, -1 };
static int dy[] = { 1, -1, 0, 0 };
public static void main(S... | cubic | 35_C. Fire Again | 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 C implements Runnable
{
String file = "input";
boolean TEST = false;
void solve() throws IOException
{
rows = ... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.*;
public class Main {
static int N;
static int [][] dp;
static int M = (int)(1e9 + 7);
static ArrayList<Integer> l;
static int f(int idx, int b) {
if(i... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class RationalResistance {
public static void main(String args[]) throws IOException{
BufferedReader f= new BufferedReader(new InputStreamReader(System.... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.math.BigInteger;
import java.util.*;
public class A {
private static Scanner in;
final int M = 1000000009;
public void run() {
int n = in.nextInt();
int m = in.nextInt();
int k = in.nextInt();
int z = n - m;
if (z >= n / k) {
System.out.println(m);
return;
}
int f = n - k * z;
i... | logn | 338_A. Quiz | CODEFORCES |
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long itrIdx = 0;
long itr = 0;
long num = 0;
while(itrIdx < n){
itrIdx += (itr+1)*(Math.pow(10,itr+1) - Math.pow(10... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class AAA {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTok... | constant | 1028_B. Unnatural Conditions | CODEFORCES |
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class Contest {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
public static void... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C {
public static void main(String[] args) throws InterruptedException{
FastScanner scan = new FastScanner();
PrintWriter out = new PrintWriter(S... | logn | 817_C. Really Big Numbers | 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.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class ProblemA_23 {
final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok=new StringTokenizer("");
void init() throws FileNotFoundException... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;
public class A implements Runnable{
public void run() {
int n = nextInt();
int[] arr = new int[n];
boolean allOne = true;
for (int i = 0; i < n; ++i) {
arr[i] = nextInt();
... | nlogn | 135_A. Replacement | CODEFORCES |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Scanner;
/**
*
* @author RezaM
*/
public class A {
public static void main(String[] args) {
Scanner... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.Function;
public class Main {
static String S;
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
S = sc.next();
Sy... | linear | 1025_C. Plasticine zebra | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class C {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = null;
private void soluti... | nlogn | 135_A. Replacement | CODEFORCES |
/**
* Created with IntelliJ IDEA.
* User: brzezinsky
* Date: 12/16/12
* Time: 7:44 PM
* To change this template use File | Settings | File Templates.
*/
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
public class E extends Thread {
public E(String inputFileName, String outputFileNa... | logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
long n = sc.nextLong(), k = sc.nextLong();
long ans = 0, sum = 0;
while(ans < n) {
if(sum - (n-ans) == k) break;
ans++;
sum += ans;
}
sc.close();
System.out.println(n-ans);
... | logn | 1195_B. Sport Mafia | CODEFORCES |
//q4
import java.io.*;
import java.util.*;
import java.math.*;
public class q4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
int query = in.nextInt();
while (qu... | quadratic | 1196_D2. RGB Substring (hard version) | CODEFORCES |
import java.util.*;
public class Solution {
public void doMain() throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
boolean[][] adj = new boolean[n][n];
for (int i=0; i<m; i++) {
int a = sc.nextInt()-1, b = sc.nextInt()-1;
... | np | 11_D. A Simple Task | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
i... | np | 1209_E1. Rotate Columns (easy version) | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws Exception {
int n = n... | nlogn | 135_A. Replacement | CODEFORCES |
import java.util.Scanner;
public class dwl {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] lr = sc.nextLine().split(" ");
long l = Long.valueOf(lr[0]);
long r = Long.valueOf(lr[1]);
if (r - l <= 1 || (l == 1 && (r - l) == 2)
|| (l % 2 != 0 && (r - l) < 3))
... | constant | 483_A. Counterexample | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class ProblemA {
public static void main(String[] args) throws Exception{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer = new PrintWriter(System.out);
int n = ... | linear | 25_A. IQ test | CODEFORCES |
import java.util.*;
import java.io.*;
public class C994{
static double area(double x1,double y1,double x2,double y2,double x3,double y3){
return Math.abs((x1 * (y2 - y3) +
x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
}
public static void main(String args[])throws IOException{
Scanner sc=new Scanner(new ... | constant | 994_C. Two Squares | CODEFORCES |
import javax.sound.sampled.Line;
import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;
public class A{
void solve()throws Exception
{
int n=nextInt();
int[]a=new int... | nlogn | 135_A. Replacement | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.*;
public class ed817Q3 {
public static void main(String[] args){
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = 1;
... | logn | 817_C. Really Big Numbers | CODEFORCES |
/**
* Created by Aminul on 3/14/2019.
*/
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import static java.lang.Math.max;
public class E_2 {
public static void main(String[] args) throws Exception {
F... | linear | 1082_E. Increasing Frequency | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
public class CodeForces {
class Pair<K, V> {
K first;
V second;
public Pair(K k, V v) {
first = k;
second = v;
}
}
pr... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import javax.print.attribute.standard.PrinterMessageFromOperator;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
new Main().run();}
// int[] h,ne,to,wt;
// int ct = 0;
// ... | quadratic | 1141_F2. Same Sum Blocks (Hard) | 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 pandusonu
*/
public class ... | quadratic | 909_C. Python Indentation | CODEFORCES |
public class pregunta1 {
public static void main(String[] args) {
System.out.println("25");
}
}
| constant | 630_A. Again Twenty Five! | 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.*;
import java.util.*;
public class taskA {
void solve() throws IOException {
long a = nextLong();
long b = nextLong();
long ans = 0;
while (a != 0 && b != 0) {
if (a > b) {
ans += a / b;
a %= b;
} else {
long c = b % a;
ans += b / a;
b = a;
a = c;
}
}
ou... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
public class a {
publi... | constant | 483_A. Counterexample | 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 = ... | linear | 17_A. Noldbach problem | CODEFORCES |
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
public class Test {
static PrintWriter writer =
new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int[][] a = new int[12][2000];
int[][] ... | np | 1209_E2. Rotate Columns (hard version) | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import java.util.PriorityQueue;
import static java.lang.Math.*;
public class solution implements Runnable {
static class InputReader {
private In... | 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
*/
public class Main {
public static... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
public class round569d2b {
public static void main(String args[]) {
FastScanner in = new FastScanner(System.in);
int n = in.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = in.nextInt();
}
if (n % 2 == 0) {
for (i... | linear | 1180_B. Nick and Array | 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 java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner s= new Scanner(System.in);
int n=s.nextInt();StringBuilder sb=new StringBuilder();
long[] a=new long[n/2];
for(int i=0;i<n/2;i++){
a[i]=s.nextLong();
}int j=0;long[] a2=new long[n/2];long[] a1... | linear | 1093_C. Mishka and the Last Exam | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
public void solve() throws IOException {
int n = nextInt();
output.println(n / 2 * 3);
}
public void run() throws IOException {
input = new BufferedReader(new InputStreamReader(System.in));
output = new PrintWriter(... | constant | 84_A. Toy Army | CODEFORCES |
import java.util.*;
public class B138 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a[] = new int[100004];
int b[] = new int[100004];
int n, m, ans = 0, dau, cuoi=-1;
n = sc.nextInt();
m = sc.nextInt();
for(int i=0;i<1000... | linear | 224_B. Array | CODEFORCES |
import java.io.*;
import java.util.*;
public class TaskA
{
public static void main(String[] args)
{
new TaskA(System.in, System.out);
}
static class Solver implements Runnable
{
int n, d;
long[] arr;
// BufferedReader in;
InputReader in;
PrintWriter out;
void solve() throws IOException
{
n = i... | linear | 1004_A. Sonya and Hotels | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
void solve(Scanner in, PrintWriter out) {
long a = in.nextLong();
out.println(25);
}
void run() {
Locale.setDefault(Locale.US);
try (
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
) {
solve(in, out... | constant | 630_A. Again Twenty Five! | CODEFORCES |
import java.util.Scanner;
public class B{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
long n = input.nextLong();
long k = input.nextLong();
System.out.println(solve(n, k));
input.close();
}
public static long solve(long n, lon... | logn | 287_B. Pipeline | CODEFORCES |
import java.util.*;
import java.io.*;
public class A{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int ans = 0;
for(int i = 1; i <= n; i++){
ans += ((i*2) <= n) ? i : n-i+1;
... | linear | 909_B. Segments | CODEFORCES |
import java.util.Scanner;
public class Main {
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();
}
int parity = 0;
for(int i = 0; i < n; i++) {
int count = 0;
for(int j = ... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class A {
@SuppressWarnings("unchecked")
private static void solve() throws IOException {
ArrayList<Num> c = new ArrayList<Num>();
n = nextInt();
a = nextInt();
b = nextInt();
for(int i = 0; i < n; i++) {
int next = nextInt();
boolean f... | nlogn | 169_A. Chores | CODEFORCES |
// Problem : G1. Playlist for Polycarp (easy version)
// Contest : Codeforces - Codeforces Round #568 (Div. 2)
// URL : https://codeforces.com/contest/1185/problem/G1
// Memory Limit : 256 MB
// Time Limit : 5000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
import java.io.*;
import java.util.*;
i... | np | 1185_G1. Playlist for Polycarp (easy version) | CODEFORCES |
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class A {
public static void main(String[] args) throws Exception{
String str = new Scanner(System.in).next();
Set<String> set = new HashSet<String>();
String max = "";
for(int l = 1; l < str.length(); ++l){
for(int i = 0; i <... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
static int inf = (int) 1e9 + 7;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(System.out);
int n = nextInt();
int a[] = new i... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args)
{
InputReader in = new InputReader(System.in);
OutputWriter out = new OutputWriter(System.out);
int n = in.nextInt();
int d = in.nextInt();
int[]a = new int[n];
... | linear | 1004_A. Sonya and Hotels | CODEFORCES |
import java.io.*;
import java.util.*;
import java.lang.Math.*;
public class A111
{
public static void main(String args[])throws Exception
{
Scanner in=new Scanner(System.in);
// br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw=new PrintWriter(System.out);
... | nlogn | 160_A. Twins | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;
import static java.lang.Math.*;
public class Main implements Runnable {
public static void main(String[] args) {
new Thread(null, new Main(), "Check2", 1 << 28).start();// to increse stack size in java
}
static l... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.util.Scanner;
public class Main {
public static long power(long a, long b, long c){
if(b == 0){
return 1;
}
a %= c;
if(b % 2 == 0){
return power((a % c * a % c) % c, b / 2, c);
}else{
return (a % c * power((a % c * a % c) % c, b / 2, c) % c) % c;
}
}
public static void main(Stri... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Tibor
*... | linear | 224_B. Array | CODEFORCES |
import java.io.*;
import java.util.StringTokenizer;
public class TaskB {
void run() {
FastReader in = new FastReader(System.in);
// FastReader in = new FastReader(new FileInputStream("input.txt"));
PrintWriter out = new PrintWriter(System.out);
// PrintWriter out = new PrintWriter(ne... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class B {
/**
* @param args
* @throws IOException
* @throws NumberFormatException
*/
public static void main(String[] args) throws NumberFormatException,
IOException {
Scanner s... | logn | 287_B. Pipeline | CODEFORCES |
import java.util.*;
public class paintTheNumbers {
public static void main (String [] args){
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int [] arr = new int[n];
for(int i = 0; i < n; i++){
arr[i] = scanner.nextInt();
}
System.out.... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class F11141 {
static class Solver {
ArrayList<int[]> ranges[];
HashMap<Long, Integer> hm = new HashMap<>();
int id(long s) {
if (!hm.cont... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class D911{
void solve()
{
int n = ni();
int[] a = ia(n);
int Q = ni();
String[] ans = {"even", "odd"};
int cur = merge(a, 0, n - 1) % 2;
while(Q--... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.util.*;
import java.io.*;
public class GG {
public static void main(String[] args) {
FastScanner scanner = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int N = scanner.nextInt();
int M = scanner.nextInt();
int K = scanner.nextInt();
i... | cubic | 1187_G. Gang Up | 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;
import java.util.*;
import java.io.*;
import java.ma... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
/**
* Created at 22:05 on 2019-09-14
*/
import java.io.*;
import java.util.*;
public class Main {
static FastScanner sc = new FastScanner();
static Output out = new Output(System.out);
static final int[] dx = {0, 1, 0, -1};
static final int[] dy = {-1, 0, 1, 0};
static final long MOD = (long) (1e9 + 7)... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class G1 {
static int n, T, duration[], type[];
static long dp[][][], mod = (long) 1e9 + 7;
public static void main(String[] args) throws Exception {
new Thread(null, new Runnable() {
public void run() {
... | np | 1185_G1. Playlist for Polycarp (easy version) | CODEFORCES |
import java.util.ArrayList;
import java.util.List;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.util.Iterator;
import java.io.*;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collection;
/**
* Generated by Contest helper plug-in
* Actual solution is at th... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Solution {
BufferedReader in;
PrintWriter out;
StringTokenizer st;
void solve() throws IOException {
int n = ni();
int[] v = new int[n];
for (int i = 0; i < n; ++i)
v[i] = ni();
... | nlogn | 22_A. Second Order Statistics | CODEFORCES |
// Don't place your source in a package
import javax.swing.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;
// Please name your class Main
public class Main {
static FastScanner fs=new F... | np | 1185_G1. Playlist for Polycarp (easy version) | 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 A implements Runnable
{
String file = "input";
boolean TEST = System.getProperty("ONLINE_JUDGE") == null;
void solve() thr... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.util.*;
import java.math.*;
import java.io.*;
public class CF1068A {
public CF1068A() {
FS scan = new FS();
long n = scan.nextLong(), m = scan.nextLong(), k = scan.nextLong(), l = scan.nextLong();
long ceil = (k + l + m - 1) / m;
if(k + l <= n && ceil * m <= n) System.out.println(ceil);
else Sys... | constant | 1068_A. Birthday | CODEFORCES |
import java.io.InputStreamReader;
import java.util.Scanner;
public class Hexadecimal {
public static void main(String [] args){
Scanner s = new Scanner(new InputStreamReader(System.in));
int x = s.nextInt();
System.out.println(x + " " + 0 + " " + 0);
}
}
| constant | 199_A. Hexadecimal's theorem | CODEFORCES |
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;
public class P1195B {
public static void main(String[] args) {
SimpleScanner scanner = new SimpleScanner(System.in);
PrintWriter writer = new PrintWriter(System.out);
int n = scanner.nextInt();
... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.io.*;
import java.util.*;
public class Problem911D {
public static void main(String args[]) throws IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), i, j;
int ar[] = new int[n];
int inv = 0;
... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class D {
private void solve() {
br = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
int n = nextInt(), m = nextI... | quadratic | 1179_B. Tolik and His Uncle | CODEFORCES |
import java.util.*;
import java.io.*;
public class C
{
static FastIO f;
public static void main(String args[]) throws IOException
{
f = new FastIO();
int t, n, a, i;
Node r, p, c;
t = f.ni();
while(t-->0)
{
n = f.ni();
r = p = new Node(-1, null);
// f.out("1\n");
for(i = 0; i < n; ... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.util.Scanner;
//import java.util.Scanner;
public class SingleWildcard {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input =new Scanner(System.in);
int a = input.nextInt();
int b = input.nextInt();
char[] s1 =new char[a];
s1 = input.next().toCharArr... | linear | 1023_A. Single Wildcard Pattern Matching | CODEFORCES |
import java.util.*;
public class Main {
public static class Pair implements Comparable<Pair> {
int k, x;
public Pair(int k) {
this.k = k;
}
public void update(int x) {
this.x = Math.max(this.x, x);
}
public int compareTo(Pair other) {
... | np | 1209_E1. Rotate Columns (easy version) | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
public A () throws IOException {
int N = sc.nextInt();
int [] A = new int [N];
for (int n = 0; n < N; ++n)
A[n] = sc.nextInt();
solve(N, A);
}
public void solve (int N, int [] A) {
//start();
Arrays.sort(A);
int S1 = 0;
for (int n = 0; n <... | nlogn | 160_A. Twins | CODEFORCES |
import java.util.*;
public class c8 {
static int n;
static int[] ds;
static int[][] g;
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int x = input.nextInt(), y = input.nextInt();
n = input.nextInt();
int[] xs = new int[n], ys = new int[n];
for(int i = 0... | np | 8_C. Looking for Order | CODEFORCES |
import java.util.Scanner;
public class Solution {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; ++i) {
arr[i] = scanner.nextInt();
}
boolean isOdd = false;
if ((arr[0]... | linear | 25_A. IQ test | CODEFORCES |
import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;
import jdk.management.cmm.SystemResourcePressureMXBean;
import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.util.List;
import java.math.*;
public class Newbie {
... | quadratic | 995_B. Suit and Tie | CODEFORCES |
import java.util.*;
import java.math.*;
import java.io.*;
public class Main
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//System.out.println(f(1,100,30));
String S[]=br.readLine().split(" ");
int N=Integer.parseInt(S[... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.util.Random;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.Pr... | nlogn | 15_A. Cottage Village | CODEFORCES |
//package round81;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class B {
Scanner in;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
int k = ni();
int a = ni();
int[] lv = new int[n];
int[] lo = new int[n];
for(int i = 0;i < n;i++){
lv[i]... | np | 105_B. Dark Assembly | CODEFORCES |
/**
* Created by IntelliJ IDEA.
* User: Taras_Brzezinsky
* Date: 8/13/11
* Time: 6:10 PM
* To change this template use File | Settings | File Templates.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
public class Da... | np | 105_B. Dark Assembly | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) {new Main().run();}
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
void run(){
out.println(work());
out.flush();
}
long mod=1000000007;
long gcd(long a,long b) {
return b==... | np | 1238_E. Keyboard Purchase | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;
public class Solution{
void solve()throws Exception
{
int n=nextInt();
int[]a=new int[n];
for(int i=0;i<n;i++)
a[i]=nextInt();
int[]b=a.clone();
Arr... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.io.*;
import java.util.*;
public class Lcm
{
public static void main(String args[])throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
long n=Long.parseLong(br.readLine());
if(n<=2)
System.out.println(n);
else
{
if(n%6==0)
{
System.out.println(((n-1)*(n-2)*(n-3)))... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B {
public static void main(String[] args){
FastScanner sc = new FastScanner();
long n = sc.nextLong();
i... | logn | 287_B. Pipeline | CODEFORCES |
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static class pair implements Comparable<pair>
{
int a;
int b;
public pair(int pa, int pb)
{
a = pa; b= pb;
}
@Override
public int compareTo(pair o) {
if(this.a < o.a)
return -1;
if(this.a > o.a)
ret... | constant | 483_A. Counterexample | CODEFORCES |
import java.util.*;
public class Solution{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int pairs = in.nextInt();
while (pairs > 0){
in.nextLine();
int a = in.nextInt();
int b = in.nextInt();
int count = 0;
... | constant | 267_A. Subtractions | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.