src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringclasses 256
values | from stringclasses 1
value |
|---|---|---|---|
import java.util.*;
public class Main {
static int a[][],n;
static boolean isClique[];
static int maxClique[];
static void DFS1(int p,int n,int S)
{
if(p>n)
{
isClique[S]=true;
return ;
}
DFS1(p+1,n,S);
boolean mark=true;
for(int i=1;i<p;++i)
if((S>>(i-1)&1)==1&&a[p][i]==0)
mark=false;
i... | np | 839_E. Mother of Dragons | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Map.Entry;
publ... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.io.*;
import java.util.*;
import java.util.Random;
import java.util.StringTokenizer;
public class Main {
long b = 31;
String fileName = "";
////////////////////// SOLUTION SOLUTION SOLUTION //////////////////////////////
int INF = Integer.MAX_VALUE / 10;
long MODULO = 1000*... | linear | 1004_A. Sonya and Hotels | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CodeJ
{
static class Scanner
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.Writer;
import java.io.OutputStream... | np | 1209_E2. Rotate Columns (hard version) | CODEFORCES |
//package A;
import java.util.Scanner;
public class Solution {
Scanner in = new Scanner(System.in);
void run() throws Exception {
int tests = in.nextInt();
while (tests > 0) {
--tests;
int a = in.nextInt();
int b = in.nextInt();
int res = 0;
... | constant | 267_A. Subtractions | CODEFORCES |
/*(c) gorlum0 [at] gmail.com*/
import java.io.*;
import java.util.*;
import java.math.*;
public class E
{
int bitcount(int x) {
int c = 0;
for ( ; x != 0; c++)
x &= x-1;
return c;
}
boolean bit(int x, int i)
{
if (i < 0) return false;
return (x>>i & ... | np | 112_E. Petya and Spiders | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
BufferedReader in;
StringTokenizer str = null;
private String next() throws Exception{
if (str == null || !str.hasMoreElements())
str = new StringTokenizer(in.readLine());
return str.nextToken();
}
private int nextInt() throws Exception{
retu... | logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamW... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.io.*;
import java.util.*;
public class A implements Runnable {
public static void main(String[] args) {
new A().run();
}
class FastScanner {
BufferedReader br;
StringTokenizer st;
boolean eof;
String buf;
public FastScanner(String fileName) throws FileNotFoundException {
br = new Buffer... | nlogn | 22_A. Second Order Statistics | CODEFORCES |
import java.util.*;
import java.lang.*;
public class Main {
static long m = 1000000007;
static long powmod(long x, long y, long p)
{
// Initialize result
long res = 1;
// Update x if it is more
// than or equal to p
x = x % p;
while (y > 0)
{
... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
/**
* Created by IntelliJ IDEA.
* User: aircube
* Date: 11.01.11
* Time: 4:14
* To change this template use File | Settings | File Templates.
*/
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.Exchanger;
public class Template {
BufferedReader br;
PrintWrit... | np | 16_E. Fish | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
long gcd(long a, long b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
long solve(long a,long b) {
if (a == 0 || b ==0) {
return 0;
}
long t = gcd(a,b);
a /= t;
b /= t;
if (a>b) {
return solve(a%b,b)+a/b;
} else ... | constant | 343_A. Rational Resistance | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class A {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
br.readLine();
String[] ss = br.readLine().split(" ");
int n = ss.len... | linear | 25_A. IQ test | CODEFORCES |
import java.io.*;
public class CF8C {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
int si = s.indexOf(' ', 0);
int x = Integer.parseInt(s.substring(0, si));
int y = Integer.parseInt(s.substring... | np | 8_C. Looking for Order | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException{
Scanner cin = new Scanner(System.in);
int t, n, m;
t = cin.nextInt();
while(t > 0) {
t--;
int sum = 0;
n = cin.nextInt();
m = cin.nextInt();
while(n > 0 && m > 0) {
... | constant | 267_A. Subtractions | CODEFORCES |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = Integer.parseInt(sc.next());
int[] a = new int[N];
int[] flag = new int[N];
int ans = 0;
for (int i=0;i<N;i++) {
a[i] = Integer.p... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.InputMismatchException;
public class E46A
{
public static void main(String[] args)
{
FastScanner in = new FastScanner(System.in);
String[] sizes = {"XXXS", "XXS", "XS", "S", "M", "L", "XL", "XXL", "XXXL"};
int n ... | linear | 1000_A. Codehorses T-shirts | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
new Main().run(in, out);
out.close();
}
public static long mod =... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import java.util.*;
import java.math.*;
import java.io.*;
public class Main
{
public static void main(String args[]) throws IOException
{
BufferedReader c=new BufferedReader(new InputStreamReader(System.in));
String S[]=c.readLine().split(" ");
int N=Integer.parseInt(S[0]);
int K=Integer.parseInt(S[1]);
... | nlogn | 274_A. k-Multiple Free Set | CODEFORCES |
import java.io.*;
import java.util.*;
/*
* And now I wonder if I should delete these comments cause they might throw me off.
* Lol who cares though?
*/
public class R364C {
public static void main(String[] args) throws NumberFormatException, IOException {
Scanner s = new Scanner(System.in);
BufferedReader f ... | linear | 701_C. They Are Everywhere | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main
{
HashMap<Integer,Pair> map;
int n,a[];
private void solve()throws IOException
{
n=nextInt();
a=new int[n+1];
for(int i=1;i<=n;i++)
a[i]=nextInt();
map=new HashMap<>();
for(int i=1;i<=n;i++)
{
int sum=0;
for(int j=i;j>=1;j--)
{
sum+... | quadratic | 1141_F2. Same Sum Blocks (Hard) | 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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Pradyumn
*/
public class M... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class Round113_A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt() - 1;
Obe[] a = new Obe[n];
for (int i = 0; i < n; i++)
a[i] = ne... | nlogn | 166_A. Rank List | CODEFORCES |
import java.util.Scanner;
public class Main {
private static boolean check(int n , int m , int k) {
for (int i = 0;i < n;i ++) {
for (int j = 0;j < n;j ++) {
for (int l = 0;l < (1 << n);l ++) {
dp[i][j][l] = - 1;
}
}
}
for (int i = 0;i < n;i ++) {
if (dfs(i , i , n , m , k , 0)) {
... | np | 1102_F. Elongated Matrix | CODEFORCES |
import java.util.*;
import java.io.*;
public class Sol{
static class Pair implements Comparable<Pair>{
int x;int y;int value;
public Pair(int x,int y,int value) {
this.x=x;
this.y=y;
this.value=value;
}
@Override
public int compareTo(Pair... | cubic | 1515_E. Phoenix and Computers | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
int k = s.nextInt();
int a[] = new int [n];
for (int i = ... | nlogn | 257_A. Sockets | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Bag implements Runnable {
private void solve() throws IOException {
int xs = nextInt();
int ys = nextInt();
int n = nextInt... | np | 8_C. Looking for Order | 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.BufferedReader;
import java.io.InputStreamReader;
/**
* @author Son-Huy TRAN
*
*/
public class P122A_LuckyDivision {
private static boolean isLuckyNumber(int number) {
while (number > 0) {
int digit = number % 10;
if (digit != 4 && digit != 7) {
return false;
}
number /= 10;
... | constant | 122_A. Lucky Division | CODEFORCES |
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.*;
/**
* Generated by Contest helper plug-in
* Actual solution is at the bottom
*/
public class Main {
public static void main(String[] args) {
InputReader in = new StreamInputReader(System.in);
PrintWriter out = ne... | nlogn | 257_A. Sockets | CODEFORCES |
//package round429;
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 C2 {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
in... | cubic | 840_C. On the Bench | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class Main {
private static int REM = 1000000007;
private static int dig;
private static int[][][] dp = new int[701][701][2];
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String X = in.next();
... | quadratic | 908_G. New Year and Original Order | 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
{
public static void main (String[] args) throws java.lang.Exception
{
int n,a,b;
Scanner obj=new S... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
static class Reader
{
private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
public int read() {if (nu... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.io.*;
import java.util.*;
public class Test{
public static void main(String[] args) {
Scanner in= new Scanner(System.in);
int n=in.nextInt();
if(n%7==0 || n%4==0 || n%47==0 || n%74==0 || n%447==0 || n%474==0 || n%477==0 || n%747==0 || n%774==0){
System.out.println("Y... | constant | 122_A. Lucky Division | 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.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 |
import java.util.*;
import java.io.*;
public class SameSumBlock {
static BufferedReader br;
static StringTokenizer tokenizer;
public static void main(String[] args) throws Exception {
br = new BufferedReader(new InputStreamReader(System.in));
int n = nextInt();
int[] arr = new int[n];
int[] pSum = new int[... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
/**
* BaZ :D
*/
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
static Reader scan;
static PrintWriter pw;
static int n,k,left[],right[],arr[];
static long MOD = 1000000007,count[],dp[];
public static void main(String[] args) {
new Thread(null,null... | linear | 1037_F. Maximum Reduction | CODEFORCES |
import sun.reflect.generics.tree.Tree;
import java.io.*;
import java.math.BigInteger;
import java.net.Inet4Address;
import java.util.*;
public class l {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////... | np | 1185_G1. Playlist for Polycarp (easy version) | CODEFORCES |
/*
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀⢠⠞⠉⠙⠲⡀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀⡏⠀⠀Y⠀⠀⢷
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀⢸⠀⠀A⠀⠀ ⡇
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀⣸⠀⠀S⠀ ⡇
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀⢹⠀⠀H⠀⠀ ⡇
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀⡇⠀⠀⠀⠀⡼
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀⠘⠤⣄⣠⠞⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿………⣀⣰⣏⣘⣆⣀⠀⠀
*/
import java.io.BufferedReader;
imp... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class ProblemA {
static ArrayList<Point2> houses = new ArrayList<Point2>();
public static void main(String[] args) {
ProblemA a = new ProblemA();
Scanner in = new Scanner(Sys... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class A {
public void realMain() throws Exception {
BufferedReader fin = new BufferedReader(new InputStreamReader(System.in), 1000000);
String in = fin.readLine();
String[] ar = in.split(" ");
int n = Integer.parseInt(ar[0]);
int[] a =... | quadratic | 1209_A. Paint the Numbers | 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... | nlogn | 1000_G. Two-Paths | CODEFORCES |
import java.util.Arrays;
import java.util.Scanner;
public class A {
static final Scanner sc = new Scanner(System.in);
void run() {
int n = sc.nextInt();
int[] xs = new int[n];
for(int i = 0; i < n; i++) {
xs[i] = sc.nextInt();
}
Arrays.sort(xs);
... | nlogn | 135_A. Replacement | CODEFORCES |
import static java.lang.Math.*;
public class C {
public C () {
int N = sc.nextInt(); int R = sc.nextInt();
int [] X = sc.nextInts();
double [] res = new double [N];
for (int i : rep(N)) {
res[i] = R;
for (int j : rep(i)) {
int D = abs(X[i] - X[j]);
if (D <= 2*R) {
double H = sqrt(4.0*R*R ... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import static java.lang.Math.*;
import java.io.*;
import java.math.*;
import java.util.*;
public class Solution implements Runnable {
public static void main(String... strings) throws InterruptedException {
new Thread(new Solution()).start();
}
BufferedReader in;
PrintWriter out;
StringTokenizer st;
String ... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class Main20 {
static ArrayList<Integer> primes = new ArrayList<Integer>();
static boolean[] prime = new... | cubic | 23_A. You're Given a String... | CODEFORCES |
//created by Whiplash99
import java.io.*;
import java.util.*;
public class D
{
private static ArrayDeque<Integer>[][] edge;
private static long[][] dp[],w1,w2;
private static int N,M,K;
private static void answer()
{
StringBuilder sb=new StringBuilder();
for(int i=0;i<N;i++)
... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.io.*;
import java.util.*;
public class CF8C {
FastScanner in;
PrintWriter out;
int[] x, y;
int[] av;
int[][] d = new int[25][25];
int dist(int v, int u) {
if (u == v)
return 0;
return (d[v][u] == 0 ? d[v][u] = d[u][v] = (x[v] - x[u])
* (x[v] - x[u]) + (y[v] - y[u]) * (y[v] - y[u]) : d[v]... | np | 8_C. Looking for Order | CODEFORCES |
import java.util.Scanner;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author madis
*/
public class Spreadsheet {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
in.nextL... | linear | 1_B. Spreadsheets | CODEFORCES |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import java.util.*;
/**
*
* @author N-AssassiN
*/
public class Main {
private static BufferedReader reader;
private static BufferedWriter out;
private static StringTokenizer tokenizer;... | constant | 313_A. Ilya and Bank Account | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
if (n % 2 == 0) {
System.out.println((n - 4) + " " + (n - (n - 4)));
} else {
System.out.println((n - 9) + " " +... | constant | 472_A. Design Tutorial: Learn from Math | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;
public class D {
int[][] fast(int n, int m){
int[][] ans = new int[2][n * m];
int c = 0;
for (int left = 1, ri... | quadratic | 1179_B. Tolik and His Uncle | CODEFORCES |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class b {
public static void main(String[] rgs)
{
Scanner s=new Scanner(System.in);
int n=s.nextInt();
long[] arr=new long[n];
for(int i... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
public class A{
public static void main(String args[]){
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int a = in.nextInt();
int b = in.next... | linear | 468_B. Two Sets | CODEFORCES |
import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static String taskName = "";
public class Task {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
int r = in.nextInt();
int[] x = new int[n];
for(int i = 0; i < n; i++)
x[i] = ... | quadratic | 908_C. New Year and Curling | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamRead... | linear | 224_B. Array | CODEFORCES |
import java.io.*;
import java.math.*;
import java.util.*;
public class StringRepeat
{
static Scanner in = new Scanner( new BufferedReader( new InputStreamReader( System.in ) ) );
public static void main( String[] args )
{
String s = in.next();
int n = s.length(), ans = 0;
for( int i = 0; i < n; i++ ) for( in... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Map.Entry;
import static java.lang.Math.*;
public class C extends PrintWriter {
final long mod = 1_000_000_007;
long pow(long n, long p) {
long r = 1;
while (p > 0) {
if (p % 2 == 1) {
... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
import java.util.Scanner;
/**
* Write a description of class lukno here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class lukno
{
public static void main (String args[])
{
Scanner i= new Scanner(System.in);
int n,p;
n=i.nextInt(); in... | constant | 122_A. Lucky Division | CODEFORCES |
import java.util.*;
import java.io.*;
public class submitting {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
StringTokenizer st = new StringTokenizer(sc.nextLine());
long n = Integer.parseInt(st.nextToken());
long k = Integer.parseInt(st.nextToken());
lo... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class C {
public static void main(String[] args) {
MyScanner in = new MyScanner();
PrintWriter out = new PrintWriter(Sys... | quadratic | 908_C. New Year and Curling | 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 m = in.nextInt();
boolean[][] graph = new boolean[n][n];
for(int i = 0; i < m; i++) {
... | np | 11_D. A Simple Task | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.*;
import javax.script.*;
public class Noldbach {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int k=sc.nextInt();
boolean[] sieve=new boolean[1001];
sieve[2]=false;
ArrayList<Integ... | linear | 17_A. Noldbach problem | CODEFORCES |
import java.util.*;
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();
long no=0;
for(int i=0; i<n-1; i++)
{
for(int j=i+1; j<n; j++)
... | quadratic | 911_D. Inversion Counting | CODEFORCES |
//package ;
import java.io.*;
import java.util.*;
public class D {
static int dp(int i,int start,int msk)
{
if(Integer.bitCount(msk)==n)
return s_e[i][start];
if(dp[i][start][msk]!=-1)
return dp[i][start][msk];
int max=0;
for(int k=0;k<n;k++)
{
int min=Integer.MAX_VALUE;
if((msk & (1<<k)) ... | np | 1102_F. Elongated Matrix | CODEFORCES |
import java.util.*;
import java.io.*;
public class D {
static int mod = (int) (1e9+7);
static InputReader in;
static PrintWriter out;
static void solve()
{
in = new InputReader(System.in);
out = new PrintWriter(System.out);
int t = 1;
... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.util.function.Function;
public class D {
public static void main(String[] args) throws IOException {
try (Input input = new StandardInput(); PrintWriter writer = new PrintWriter(System.out)) {
long[] s ... | logn | 1080_D. Olya and magical square | CODEFORCES |
import java.util.*;
import java.io.*;
public class _G14 {
public static void main(String[] args) {
MyScanner sc = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int t = 1;
while (t-- > 0) {
int n = sc.nextInt();
mod ... | cubic | 1515_E. Phoenix and Computers | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class A {
private void solve() throws IOException {
int n = nextInt();
int r = n;
n *= 2;
n -= (0.5*r);
System.out.println(n);
}
public static void main(String[] args) {
new A().run();
}
... | constant | 84_A. Toy Army | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class DD {
public static void main(String args[]) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
long k=Long.parseLong(br.readLine());
long ans=... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import java.util.Scanner;
public class TaxiDriversAndLyft2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
long m = scanner.nextLong();
long[] people = new long[(int) (n+m)];
int[] taxiDrivers = new int[(int) (n+m)];
for(int i = 0;i< ... | linear | 1075_B. Taxi drivers and Lyft | CODEFORCES |
import java.io.*;
import java.util.*;
/**
__ __
( _) ( _)
/ / \\ / /\_\_
/ / \\ / / | \ \
/ / \\ / / |\ \ \
/ / , \ , / / /| \ \
/ / |\_ /| / / / \ \_\
/ / |\/ _ '_| \ / / / \ \\
| / |/ 0 \0\ / ... | cubic | 1523_C. Compression and Expansion | CODEFORCES |
import java.awt.Point;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class sdffsdf {
public static void ma... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Bag implements Runnable {
private void solve() throws IOException {
int xs = nextInt();
int ys = nextInt();
int n = nextInt... | np | 8_C. Looking for Order | CODEFORCES |
import java.util.*;
public class Main {
public static int n, m;
public static int[][] arr;
public static class Item implements Comparable<Item> {
int i, x;
public Item(int i, int x) {
this.i = i;
this.x = x;
}
public int compareTo(Item other) {
... | np | 1209_E1. Rotate Columns (easy version) | CODEFORCES |
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.io.*;
public class Main {
boolean[] b;
int[] r;
ArrayList<ArrayList<Integer>> q;
public void dfs(int u, int p) {
for (int i = 0; i < q.get(u).size(); i++) {
int v = q.get(u).get(i);
... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.io.DataInputStream;
import java.io.InputStream;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;
public class B {
public static void main(String[] args) throws Exception {
Parserdoubt2333 s = new Parserdoubt2333(System.in);
int n = s.nextInt... | linear | 224_B. Array | CODEFORCES |
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.io.*;
import java.util.*;
public class Main {
static boolean LOCAL = false;//System.getSecurityManager() == null;
Scanner sc = new Scanner(System.in);
void run() {
char[] cs = sc.nextLine().toCharArray();
int... | cubic | 23_A. You're Given a String... | CODEFORCES |
/**
* BaZ :D
*/
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class ACMIND
{
static FastReader scan;
static PrintWriter pw;
static long MOD = 1_000_000_007;
static long INF = 1_000_000_000_000_000_000L;
static long inf = 2_000_000_000;
public static void main(Str... | np | 1185_G1. Playlist for Polycarp (easy version) | 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.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long n = scan.nextLong();
long k = scan.nextLong();
long D = 9 + 4 * (2 * k + 2 * n);
long y = (- 3 + (long)Math.sqrt(D)) / 2;
Sy... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.io.*;
import java.util.*;
public class LuckyDivision
{
public LuckyDivision(Scanner in)
{
int n;
n = in.nextInt();
if ( (n % 4 == 0) ||
(n % 7 == 0) ||
(n % 44 == 0) ||
(n % 47 == 0) ||
(n % 74 == 0) ||
(n % 77 == 0) ||
... | constant | 122_A. Lucky Division | CODEFORCES |
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Solution {
public static void main(String[] args) {
InputStream inputStream;
try {
inputStream = new FileInputStream("input.txt");
} catch (IOException e) {
throw new Runti... | cubic | 35_C. Fire Again | CODEFORCES |
import java.awt.*;
import java.math.*;
import java.util.regex.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Integer.parseInt;
import static java.util.AbstractMap.*;
import static java.lang.System.*;
import static java.lang.Math.*;
import java.awt.geom.*;
import java... | linear | 17_A. Noldbach problem | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
public class Main {
static PrintWri... | np | 1209_E1. Rotate Columns (easy version) | 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 |
/*
* Author- Priyam Vora
* BTech 2nd Year DAIICT
*/
import java.awt.Checkbox;
import java.awt.Point;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Map.Entry;
import j... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new PrintStream(System.out));
StringTokenizer st = new StringToken... | nlogn | 1159_C. The Party and Sweets | CODEFORCES |
import java.io.*;
import java.util.*;
public class A {
private static Scanner sc = new Scanner(new InputStreamReader(System.in));
public static void main (String[] args) throws IOException {
BitSet b = new BitSet(1001);
BitSet p = primes(1001);
for (int i = 0; i < ps.length - 1; i++) {
... | linear | 17_A. Noldbach problem | CODEFORCES |
//david alexander
import java.util.*;
public class Subtract {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a,b;
String answer = "";
while(n!=0){
a = sc.nextInt();
b = sc.nextInt();
answer += solve(a,b) + "\n";
n--;
}
System.out.printl... | constant | 267_A. Subtractions | CODEFORCES |
import java.util.*;
public class maximus {
static long GCD(long a,long b){
if(b==0)return a;
return GCD(b,a%b);
}
public static void main(String [] args){
Scanner in=new Scanner(System.in);
long n=in.nextInt();
if(n<=2){
System.out.print(n);
return;
}
if(n%2==1){
System.out.print((n*(n-1)*(n-2)));... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.util.Scanner;
public class R113A {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt(), k = in.nextInt();
int[] ind = new int[n];
int[] p = new int[n];
int[] t = new int[n];
for (int i = 0; i < n; i++){
... | nlogn | 166_A. Rank List | CODEFORCES |
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 {
public static void main(String[] args) throws IOException {
new Thread(null, new Runnable() {
public vo... | cubic | 35_C. Fire Again | 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(System... | nlogn | 22_A. Second Order Statistics | 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 Vaibhav Pulastya
*/
public... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.util.*;
public class A72 {
public static void main (String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
System.out.println(n * 3 / 2);
}
}
| constant | 84_A. Toy Army | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.