src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringclasses 256
values | from stringclasses 1
value |
|---|---|---|---|
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) {
try (final Scanner sc... | 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.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int r = sc.nextInt();
int d = 2 * r;
int[] xCoordinates = new int[n];
double[] yCoordinates = new double[n];
for (int i ... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.io.*;
import java.util.*;
public class Codeforces911D {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] sp = br.readLine().split(" ");
int n = Integer.parseInt(sp[0]);
int[] a = new int[n];
sp = br.rea... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
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();
List<Integer> list = new ArrayList<Int... | linear | 25_A. IQ test | CODEFORCES |
import java.awt.*;
import java.io.*;
import java.math.*;
import java.util.*;
public class TaskC {
public static void main(String[] args) {
new TaskC().run();
}
void solve(){
int n = in.nextInt();
String s[] = new String[n];
for(int i = 0; i < n; i++) s[i] = in.next();
if(s[n-1].compareTo("f") == 0)... | quadratic | 909_C. Python Indentation | CODEFORCES |
//package Round14Global;
import java.util.*;
import java.io.*;
public class phoenixandpuzzle {
public static void main(String[] args) throws IOException {
BufferedReader fin = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(fin.readLine());
StringBuilder fout = new StringBuilder(... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int a[]={4,7,44,47,74,77,444,447,474,477,744,747,774,777};
int n=in.nextInt();
int i=0;
boolean yes=false;
while((i<14)&&(a[i]<=n)){
if(n%a[i]==0){
System.out.print("YES");
yes=tru... | constant | 122_A. Lucky Division | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReade... | nlogn | 22_A. Second Order Statistics | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
team[] t = new team[n];
for (int i = 0; i < n; i++)
t[i] = new team(in.ne... | nlogn | 166_A. Rank List | CODEFORCES |
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next(),c;
int n = s.length(),a,b;
for(int sz = n ; sz >= 1 ; sz--) {
for(int i = 0 ; i+... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.PrintWriter;
import java.util.Scanner;
public class n122A {
Scanner in;
PrintWriter out;
void solve() {
int n = in.nextInt();
boolean good = false;
if (n % 4 == 0) {
good = true;
}
if (n % 7 == 0) {
good = true;
}
... | constant | 122_A. Lucky Division | CODEFORCES |
import java.util.*;
import java.io.*;
public class B {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int T = sc.nextInt();
while(T-->0) {
int n = sc.nextInt();
if(n % 2 == 0 && issq(n/2)) {
System.out.println("YES");
}
else if(n % 4 == 0 && issq(n/4)) {
System.... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class Code implements Runnable {
public static void main(String[] args) throws IOException {
new Thread(new Code()).start();
}
private void solve() throws IOException {
taskB();
... | linear | 224_B. Array | CODEFORCES |
import java.io.*;
import java.util.*;
public class CF {
long mod = (long) 1e9 + 9;
class Pair {
long a, b;
public Pair(long a, long b) {
super();
this.a = a % mod;
this.b = b % mod;
}
}
int k;
long pow(long n, long k) {
if (k == 0)
return 1;
long m1 = pow(n, k / 2);
m1 = (m1 * m1) % ... | logn | 338_A. Quiz | 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... | cubic | 23_A. You're Given a String... | CODEFORCES |
/*
ID: andrew42
LANG: JAVA
TASK:
PROG:
*/
import java.io.*;
import java.util.*;
import java.lang.*;
public class curling {
public static void main(String[] args) throws IOException {
Scanner input = new Scanner(System.in);
int numD = input.nextInt();
double rad = input.nextInt();
int[] xC = new int[numD];
... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
public class Main
{
Scanner cin;
int []prime;
int top;
void work()
{
cin=new Scanner(System.in);
int n=cin.nextInt();
int k=cin.nextInt();
top=0;
prime=new int[2000];
... | linear | 17_A. Noldbach problem | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Round364C {
public static void main(String[] args) throws NumberFormatException, IOException {
... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.util.*;
import java.io.*;
public class Quiz
{
public static final int MOD = 1000000009;
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
long n = in.nextInt();
long m = in.nextInt();
long k = in.nextInt();
long low = Math.min(n - (k * (n - m)), m);
if(l... | logn | 338_A. Quiz | 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... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
//package round85;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class C3 {
Scanner in;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
int m = ni();
if(n < m){
int d = n;n = m;m = d;
}
// n>=m
if(m == 1){
out.println(n-(n+2)/3);
retu... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Solution implements Runnable {
void solve() throws Exception {
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
int a [] = new int [n];
for (int i = 0; i < n; i+... | nlogn | 257_A. Sockets | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
public class Solution1 implements Runnable
{
static final lo... | linear | 527_B. Error Correct System | 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 _P023A{
Scanner sc=new Scanner(System.in);
int INF=1<<28;
double EPS=1e-9;
String s;
void run(){
... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.*;
import java.text.DecimalFormat;
public class ProblemD {
private double survive(int round, int set) {
if (sur[round][set] >= 0)
return sur[round][set];
double res = 0.0;
int count = 0;
for(int i=0;i<n;i++) {
if ((set & (1 << i)) > 0) {
... | np | 16_E. Fish | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class CF1141F {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Int... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringToken... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.*;
import java.util.*;
public class Solution {
public static void main (String[] args) throws IOException {
boolean online = "true".equals(System.getProperty("ONLINE_JUDGE"));
if (online) {
in = new InputReader(new InputStreamReader(System.in));
out = new Prin... | logn | 287_B. Pipeline | CODEFORCES |
import java.util.Scanner;
public class A338 {
public static void main (String args[]){
Scanner in= new Scanner(System.in);
long n = in.nextInt();
long m=in.nextInt();
long k=in.nextInt();
long x = n-m;
long y=n/k;
if(x>=y)
System.out.println(m);
else
{
long t= y-x;
long ans=0;
a... | logn | 338_A. Quiz | CODEFORCES |
import java.io.*;
import java.util.StringTokenizer;
/**
*
* @author Prateep
*/
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
InputStream inputStream = System.in;
Outp... | cubic | 23_A. You're Given a String... | 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.StringTokenizer;
public class C {
... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
public class ProblemB {
public static void main(String[] args) throws IOException {
BufferedReader... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;
public class Solution implements Runnab... | linear | 17_A. Noldbach problem | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Scanner;
import java.util.TreeSet;
public class Main3 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(Sy... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.io.*;
import java.util.*;
public class E implements Runnable {
FastReader scn;
PrintWriter out;
String INPUT = "";
void solve() {
int t = scn.nextInt();
while(t-- > 0) {
int n = scn.nextInt(), m = scn.nextInt();
int[][] arr = scn.next2DInt(n, m);
int[][] col = new int[m][2];
for(in... | np | 1209_E1. Rotate Columns (easy version) | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public ... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
import java .util.*;
import java .io.*;
public class Main{
public static void main(String[]YAHIA_MOSTAFA){
Scanner sc =new Scanner(System.in);
long n=sc.nextLong(),x=sc.nextLong(),y=sc.nextLong();
long xb,xw,yb,yw;
xw=x-1;yw=y-1;xb=n-x;yb=n-y;
if (x==n&&y==n){
System.out.println("Black");return;
}
lon... | constant | 1075_A. The King's Race | CODEFORCES |
import java.util.Scanner;
public class d {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size = in.nextInt();
int[] vals = new int[size];
long[] cum = new long[size];
for(int i=0; i<size; i++){
vals[i] = in.nextInt();
int c = 0;
for(int j=0; j<i; j++)
... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
//SOLUTION BEGIN
//Code not meant for understanding, proceed with caution
void pre() throws Exception{}
void solve(int TC) throws Exception{
int n = ni();
int[] a = new int[n... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.io.*;
public class java2 {
public static void main(String[] args) {
Scanner r = new Scanner(System.in);
int n=r.nextInt();
int []l=new int[1005];
int []ri=new int[1005];
int []candy=new int[1005];
for(int i=1;i<=n;+... | quadratic | 1054_C. Candies Distribution | CODEFORCES |
import java.io.*;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws IOException {
new A().solve();
}
BufferedReader br;
StringTokenizer st = new StringTokenizer("");
private void solve() throws IOException {
br = new BufferedReader(n... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
String s = sc.next();
StringBuilder ans = new StringBuilder();
int count = 0;
int open = 0;
for (int i = 0; i <... | linear | 1023_C. Bracket Subsequence | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
/**
* Created by pallavi on 22/7/16.
*/
public class C701 {
public static int f(char c) {
if (c >= 'a' && c <=... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
void solve() throws IOException {
int tot = nextInt();
int ok = nextInt();
int k = nextInt();
int maxBad = tot / k;
if (tot - maxBad >= ok) {
out.println(ok);
return;... | logn | 338_A. Quiz | CODEFORCES |
import java.util.Scanner;
public class CF_8C {
public static void main(String[] args) {
// Hooray bitmasks! I'm good at these :)
Scanner in = new Scanner(System.in);
// Handbag coordinates..
int hb_x = in.nextInt(), hb_y = in.nextInt();
int n = in.nextInt();
int[] ox = new int[n];
int[] oy = ... | np | 8_C. Looking for Order | CODEFORCES |
import java.util.*;
import java.io.*;
public class X
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String s1 = br.readLine();
String s2 = br.readLine();
int i=0;
char c1,c2;
... | linear | 1037_C. Equalize | CODEFORCES |
import java.util.*;
public class B {
static long sum(long from, long to){
final long d = to - from;
return (d*(d + 1))/2 + (d + 1)*from;
}
static long howMany(long n, long k){
if (n == 1){
return 0;
}
if (n > (k*(k - 1))/2 + 1){
return -1;
}
long hi = k - 1;
long lo = 1;
while (lo < hi){
... | logn | 287_B. Pipeline | CODEFORCES |
import java.io.*;
import java.util.*;
import javax.lang.model.util.ElementScanner6;
public class codef
{
public static void main(String ar[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer nk=new StringTokenizer(br.readLine());
... | nlogn | 1197_C. Array Splitting | CODEFORCES |
import java.util.Scanner;
/**
* 2013.07.27 No.1 235A LCM Challenge
* 数论 n%2 == 0? n%3 == 0?
* @author Administrator *
*/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if (n < 3)
System.out.print... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.io.*;
import java.util.*;
public class B {
static FastScanner fs;
public static void main(String[] args) {
fs=new FastScanner();
int t = fs.nextInt();
while (t-->0)
solve();
}
public static void solve() {
int n = fs.nextInt()*2;
int sq = (i... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc =new Scanner (System.in);
long a=sc.nextLong(); long b=sc.nextLong();
if(b-a <=1)
System.out.println("-1");
else if(b-a==2 && a%2==1)
System.out.println("-1");
... | constant | 483_A. Counterexample | CODEFORCES |
import java.io.*;
import java.util.*;
public class tr {
static int[][] ad;
static boolean []vis;
static int []goods;
static int[][]sol;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n=sc.nextInt()... | linear | 1092_D1. Great Vova Wall (Version 1) | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
public static void main(String[] args) {
long n,k;
Scanner s= new Scanner(System.in);
n=s.nextInt();
k=s.nextInt();
System.out.println((int)(n-((-3+Math.sqrt(9+8*(n+k)))/2)));
}
}
| logn | 1195_B. Sport Mafia | CODEFORCES |
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
public class E {
FastScanner in;
PrintWriter out;
boolean systemIO = true;
public class DSU {
int[] sz;
int[] p;
public DSU(int n) {
sz = new int[n];
p = new int[n];
for (int i = 0; i < p.length; i++) {
p[i] = i;
sz[i] = 1;
... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class A113 {
public static void main(String[] args) {
new A113().run();
}
public void run() {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
Team[] teams = new Team[n];... | nlogn | 166_A. Rank List | 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;
public class Main implements Runnable {
// ////////////////////////////////////////////////////
// Solution
private int n;
... | np | 8_C. Looking for Order | CODEFORCES |
import java.util.*;
import java.io.*;
public class codeforces {
public static void main(String[] args) throws Exception {
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int[]a=sc.nextIntArray(n);
LinkedList<Integer>ll=new LinkedList<Integer>();
for(int i=0;i<n;i++) {
if(a[i]==1) {
ll... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
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 Main16E {
private FastScanner in;
private PrintWriter out;
public void solve() throws IOException {
i... | np | 16_E. Fish | CODEFORCES |
/*
* Hopefully this is AC :D
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.Arrays;
public class TwoSets {
static ArrayList<Integer> g[];
static boolean vis... | linear | 468_B. Two Sets | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class ProblemA {
public static void main(String[] args) throws IOException {
BufferedReader s = new BufferedReader(new InputStreamRea... | nlogn | 169_A. Chores | CODEFORCES |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;
import sta... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
/*
* PDPM IIITDM Jabalpur
* Asutosh Rana
*/
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
long MOD = 1000000007;
InputReader in;BufferedReader br;PrintWriter out;
public static void main (String[] args) throws java.lang.Exception
{
Main solver = new Main();
... | nlogn | 903_D. Almost Difference | CODEFORCES |
import java.util.*;
import java.io.*;
public class D {
static class Scan {
private byte[] buf=new byte[1024];
private int index;
private InputStream in;
private int total;
public Scan()
{
in=System.in;
}
public int scan()throws IOException
... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/**
* Created by Brandt Henslee on 2/24/2015.
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(S... | np | 8_C. Looking for Order | 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 P287B{
Scanner sc=new Scanner(System.in);
int INF=1<<28;
double EPS=1e-9;
long n, k;
void run(){
n=sc.nextLong();... | logn | 287_B. Pipeline | CODEFORCES |
import java.io.*;
import java.util.*;
public class trafficerules {
public static void main(String[] args) throws Exception {
if ("Satayev".equals(System.getProperty("user.name"))) {
long start = System.nanoTime();
new trafficerules().solve(new FileInputStream("input"));
System.err.printf("Time elapsed... | constant | 5_D. Follow Traffic Rules | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CodeD
{
static class Scanner
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public String next... | np | 8_C. Looking for Order | 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... | constant | 313_A. Ilya and Bank Account | CODEFORCES |
import java.util.Scanner;
public class composite {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int a=s.nextInt();
if(a%2==0)
{
a=a-4;
System.out.println(4+" "+a);
}
else
... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args){
FastScanner sc = new FastScanner();
long a = sc.nextLong();
long b = sc.nextLong();
long result = 0L;
while(a != 0 && b != 0) {
if(a > b) {
result += a/b;
a = a % b;
} else ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.*;
import java.util.*;
public class Solution {
static MyScanner sc;
private static PrintWriter out;
static long M2 = 1_000_000_000L + 7;
public static void main(String[] s) throws Exception {
StringBuilder stringBuilder = new StringBuilder();
if (stringBuilder.length() =... | quadratic | 908_C. New Year and Curling | CODEFORCES |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//package pipeline;
import java.util.Scanner;
/**
*
* @author admin
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO... | logn | 287_B. Pipeline | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class AG1 {
public static void main(String[] Args){
FastReader scan=new FastReader();
int n=scan.nextInt();
int[] arr=new int[n];
for (int i = 0; i <n ; i++) {
... | quadratic | 1209_A. Paint the Numbers | 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 TA {
public void solve(long n) {
long a = 0, b = 0;
if (n % 2 == 0) {
if (n % 4 == 0) {
a = n / 2;
... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class Teams {
BufferedReader in;
PrintWriter out;
StringTokenizer st;
Random rnd;
class Pair implements Comparable<Pair> {
int a, b;
public Pair(int a, int b) {
this.a = a;
this.b = b;
... | nlogn | 166_A. Rank List | CODEFORCES |
import java.io.PrintWriter;
import java.util.Scanner;
public class D {
public void run(Scanner in, PrintWriter out) {
int n = in.nextInt();
int[][] graph = new int[n][n];
int m = in.nextInt();
for (int i = 0; i < m; i++) {
int x = in.nextInt() - 1;
int y = i... | np | 11_D. A Simple Task | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println(n + n / 2);
}
}
| constant | 84_A. Toy Army | CODEFORCES |
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for (int i = 0, t = sc.nextInt(); i < t; i++) {
int n = sc.nextInt();
LinkedList<Set<Integer>> stack = new LinkedList<>();
for (int j = 0; j ... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintW... | np | 105_B. Dark Assembly | CODEFORCES |
import java.io.*;
import java.awt.geom.Point2D;
import java.text.*;
import java.math.*;
import java.util.*;
public class Main implements Runnable {
final String filename = "";
public void solve() throws Exception {
int n = iread(), k = iread(), A = iread();
int[] b = new int[n], l = new int[n];
for (int i =... | np | 105_B. Dark Assembly | CODEFORCES |
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Locale;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.AbstractList;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.u... | np | 16_E. Fish | CODEFORCES |
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.Arrays;
public class CF1238E {
public static void main(String[] args) throws Exception {
boolean local = System.getSecurityManager() == nu... | np | 1238_E. Keyboard Purchase | CODEFORCES |
import java.io.*;
import java.util.*;
public class Problem1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n < 0) {
int first = n / 10;
int second = (n / 100)*10 + (n % 10);
if... | constant | 313_A. Ilya and Bank Account | CODEFORCES |
import java.util.Scanner;
public class codef8 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int beacon[] = new int[1000001];
int pos[] = new int[num];
for (int i = 0; i < num; i++) {
int position = sc.nextInt... | linear | 608_C. Chain Reaction | CODEFORCES |
import java.util.Scanner;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.File;
public class FireAgain {
public static void main(String[] args){
File in = new File("input.txt");
File out = new File("output.txt");
Scanner sc;
PrintWriter pw;
try{
sc = new Scanner(in);
pw = new ... | cubic | 35_C. Fire Again | CODEFORCES |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//package substring;
import java.util.*;
/**
*
* @author lav
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner scr = n... | cubic | 23_A. You're Given a String... | CODEFORCES |
/**
* Date: 14 Sep, 2019
* Link:
*
* @author Prasad-Chaudhari
* @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
* @git: https://github.com/Prasad-Chaudhari
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import ja... | np | 1209_E1. Rotate Columns (easy version) | CODEFORCES |
/**
* @author derrick20
*/
import java.io.*;
import java.util.*;
public class SameSumBlocks {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int N = sc.nextInt();
int[] pre = new int[N +... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.util.*;
import java.io.*;
public class R574B
{
public static void main(String[] args)
{
JS scan = new JS();
long n = scan.nextInt();
long put = 1;
long k = scan.nextInt();
long have = 0;
long moves = 0;
while(have < k) {
have += put;
put++;
moves++;
}
long ans = 0;
moves ... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(x%4==0||x%7==0||x%47==0||x%74==0||x%744==0||x%474==0||x%447==0||x%477==0||x%474==0)
System.out.println("YES");
else
System.out.println("NO");
}
} | constant | 122_A. Lucky Division | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class ProblemB {
public static int _gnum;
public static int _cnum;
public static int _needs;
public static int _level;
public static double _maxans = 0;
public ... | np | 105_B. Dark Assembly | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class problemA {
public static long GCD(long number1, long number2) {
//base case
if(number2 == 0){
return number1;
... | constant | 483_A. Counterexample | CODEFORCES |
import java.util.*;
public class AgainTwentyfive {
public static void main(String[] args)
{
System.out.println("25");
}
}
| constant | 630_A. Again Twenty Five! | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
BufferedReader in;
StringTokenizer st;
PrintWriter out;
String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(in.readLine());
return st.nextToken();
}
int nextInt() throws Exception {
return Integer... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
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));
int n=Integer.parseInt(br.readLine());
String s=br.readLine();
String ss[]=s.split(" ");
int arr[]=new in... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
//package round196;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class A {
InputStream is;
PrintWriter out;
String INPUT = "";
public static long pow(long a, long n... | logn | 338_A. Quiz | CODEFORCES |
import java.io.*;
import java.util.*;
import java.util.function.Function;
public class Main {
static int N;
static int[] U, V;
static int[] A;
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
N = sc.nextInt();
U = new int[N-1];
V = ... | nlogn | 1037_D. Valid BFS? | CODEFORCES |
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), sum = 0;
Integer[] A = new Integer[n];
for (int i = 0 ; i < n ; i++) {
A[i] = sc.nextInt();
... | nlogn | 160_A. Twins | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.