src stringlengths 95 64.6k | complexity stringclasses 7
values | problem stringclasses 256
values | from stringclasses 1
value |
|---|---|---|---|
import java.util.*;
import java.io.*;
public class P220A
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
List<Integer> b = new ArrayList<Integer>(n);
for (int i = 0; i < n; i++)
{
... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.TreeSet;
public class B {
public static void main(String[] args) {
MScanner sc = new MScanner();
PrintWriter out = new PrintWriter(System.out);
long N = sc.nextLong();
... | logn | 256_B. Mr. Bender and Square | 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";
void init() throws IOException
{
//input = new BufferedReader(new FileRe... | cubic | 23_A. You're Given a String... | 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.ArrayList;
import java.util.Scanner;
/**
*
* @author Ahmed
*/
public class Watermelon {
static class Pas... | linear | 608_A. Saitama Destroys Hotel | 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.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Scanner;
public class CF_2020_GlobalRound_E {
static boolean verb=true;
static void log(Object X){if (verb) System.err.println(X);}
static void log(Obj... | cubic | 1515_E. Phoenix and Computers | CODEFORCES |
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
public class Solution {
static final int INF = (int) 1e9;
static final int mod = (int) (1e9 + 7);
static final short UNCALC = -1;
public static void main(String[] ar... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.*;
import static java.lang.Math.*;
import java.util.*;
import java.util.function.*;
import java.lang.*;
public class Main {
final static boolean debug = false;
final static String fileName = "";
final static boolean useFiles = false;
public static void main(String[] args) throws FileNot... | np | 16_E. Fish | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class a {
private void solve() throws Exception {
int n = nextInt(), t = nextInt();
int[] x = new int[n], a = new int[n];
for (int i = 0; i < n; ++i){
x[i] = nextInt();
a[i] = nextInt();
}
for (int i = 0; i < n; ++i)... | nlogn | 15_A. Cottage Village | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = in.readLine();
int n = line.l... | cubic | 23_A. You're Given a String... | 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 | 343_A. Rational Resistance | CODEFORCES |
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.regex.Pattern;
//Stephen Fulwider
//Parser class for efficient input in Java
// Use just as you would Scanner.
// Make sure any method that uses this class th... | linear | 1_B. Spreadsheets | CODEFORCES |
import java.io.*;
import java.util.*;
import java.util.Queue;
import java.util.LinkedList;
import java.util.Stack;
public class Main
{
@SuppressWarnings("unchecked")
public static void main(String args[])throws IOException
{
Reader ob=new Reader();
Writer out=new Writer(System.out);
... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import java.io.*;
import java.util.*;
public class Solution {
private BufferedReader in;
private PrintWriter out;
private StringTokenizer st;
void solve() throws IOException {
double a = nextDouble();
double v = nextDouble();
double l = nextDouble();
double d = nextDouble();
double w = nextDouble();
... | constant | 5_D. Follow Traffic Rules | CODEFORCES |
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class E {
static InputStream is;
//String INPUT = "";
public static void main(String[] args) throws IOException {
is = System.in;
int n = ni();
int k = ni();
int[][] aj = new int[n][n];
for (int i = 0; i < aj.lengt... | np | 839_E. Mother of Dragons | CODEFORCES |
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundExc... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
static long[][] memo;
static boolean[][] adjMat;
static in... | np | 11_D. A Simple Task | CODEFORCES |
import java.io.*;
import java.util.*;
public class TemnayaAssambleya implements Runnable {
public static void main(String[] args) {
new Thread(new TemnayaAssambleya()).run();
}
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer in;
PrintWriter out = new PrintWriter(System... | np | 105_B. Dark Assembly | CODEFORCES |
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class Main{
static ArrayList a[]=new ArrayList[200001];
static int Count(int a[][],int n) {
dsu d=new dsu(n);
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
if(a[i][j]==0) {
d.union(i, j);
}... | quadratic | 990_D. Graph And Its Complement | CODEFORCES |
import java.math.BigInteger;
import java.util.Scanner;
public class RENAMETHISBITCH {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
int n = sc.nextInt();
BigInteger m = sc.nextBigInteger();
System.out.println(m.mod(BigInteger.valueOf(2).pow(n)));
}
c... | constant | 913_A. Modular Exponentiation | CODEFORCES |
import java.util.*;
public class A
{
public static int palin(String str)
{
int flag=0;
int l=str.length();
for(int i=0;i<l/2;i++)
{
if(str.charAt(i)!=str.charAt(l-i-1))
{
flag=1;
break;
}
}
if(fla... | linear | 981_A. Antipalindrome | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
public void solve() {
int n = ni();
int a = ni();
int b = ni();
long ans = 0;
HashMap<Long, Long> m = new HashMap<>();
HashMap<String, Long> s = new HashMap<>();
for (int i = 0; i < n; i++) {
... | linear | 975_D. Ghosts | CODEFORCES |
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
System.out.println(3 * (n / 2));
}
}
| constant | 84_A. Toy Army | CODEFORCES |
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
PrintWriter out = new PrintWriter(System.out);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tok = new StringTokenizer("");
String next() throws IOException {
if (!tok.hasMoreToke... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* Created by Egor on 24/10/14.
*/
public class TaskA {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader... | constant | 483_A. Counterexample | CODEFORCES |
//package round97;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
public class A {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
int[] a = new int[n];
for(int i = 0;i < n;i... | nlogn | 135_A. Replacement | CODEFORCES |
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* CodeForces 8C - Looking for Order
* Created by Darren on 14-10-1.
*/
public class Main {
Reader in = new Reader(System.in);
PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IO... | np | 8_C. Looking for Order | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
static boo... | 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.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution i... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.util.*;
public class A
{
public static void main(String[] args)
{
new A(new Scanner(System.in));
}
public A(Scanner in)
{
TreeSet<String> ts = new TreeSet<String>();
ArrayList<String> sr = new ArrayList<String>();
String s = in.next();
for (int i=0; i<s.leng... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L;
static final int INf = 1_000_000_000;
static FastReader reader;
static PrintWriter writer;
public static void main(String[] args) {
... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import com.sun.org.apache.xalan.internal.xsltc.dom.BitArray;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
imp... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C {
static StringTokenizer st;
static BufferedReader br;
static PrintWriter pw;
... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
Ou... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BankAccount {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Str... | constant | 313_A. Ilya and Bank Account | CODEFORCES |
import java.io.BufferedInputStream;
import java.util.Scanner;
/**
* Created by jizhe on 2016/1/29.
*/
public class LCMChallenge {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedInputStream(System.in));
long N = in.nextLong();
if( N == 1 || N == 2 )
... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Homyak implements Runnable {
private void solve() throws IOException {
int n = nextInt();
String seq = nextToken();
int nh ... | linear | 46_C. Hamsters and Tigers | CODEFORCES |
import java.io.*;
import java.util.*;
import java.lang.reflect.Array;
import java.math.*;
public class Solution {
private BufferedReader in;
private PrintWriter out;
private StringTokenizer st;
private Random rnd;
int[] levels;
int[] loyal;
int n, k;
double A;
int[] choices;
int[] new_loyal;
double[] ko... | np | 105_B. Dark Assembly | CODEFORCES |
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
static int n;
static int a;
static int b;
static int g;
static int ref;
static int refg;
static HashSet<Integer> cgroup;
static HashMap<Integer,Integer> indexmap;
static HashSet<Integer> nums;
static HashSet<... | linear | 468_B. Two Sets | CODEFORCES |
import java.util.*;
public class vas2 {
public static void main( String[] args ) {
Scanner in = new Scanner( System.in );
int n = in.nextInt();
String st = in.next();
int[] a = new int[n];
for ( int i = 0; i < n; i++ )
a[i] = st.charAt( i ) - 48;
boolean c = false;
for ( int i = 1; !c && i < n; i++ ) {... | quadratic | 1030_C. Vasya and Golden Ticket | CODEFORCES |
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while(t-- >0){
String str = scn.next();
Pattern p = Pattern.compile("R[0-9]+C[0-9]+");
... | linear | 1_B. Spreadsheets | CODEFORCES |
import java.io.*;
import java.util.*;
public class Main {
static Scanner in = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) {
int n = in.nextInt();
int m = in.nextInt();
long boyMax = 0;
int NBoyMax = 0;
long sweets = ... | linear | 1159_C. The Party and Sweets | 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.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Arr... | cubic | 1185_G2. Playlist for Polycarp (hard version) | CODEFORCES |
import java.util.*;
import java.io.*;
public class main{
static int max = 5000+1;
static FastReader in = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
static int N = 18;
static int[][] mn1 = new int[N][N];
static int[][] mn2 = new int[N][N];
static int[][] dp = new int[1<<N][N];
sta... | np | 1102_F. Elongated Matrix | 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 solu... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Scanner;
public class f {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
Hashtable<Long, Boolean> d = new Hashtable<Long... | nlogn | 274_A. k-Multiple Free Set | CODEFORCES |
import java.io.*;
import java.util.*;
public class B {
static int n,t[],g[],MOD=(int)1e9+7;
static int [][]memo;
static int dp(int msk,int rem,int lastG) {
if(rem==0)
return 1;
if(memo[lastG][msk]!=-1)
return memo[lastG][msk];
int ans=0;
for(int i=0;i<n;i++) {
if((msk & (1<<i))==0 && rem>=t[i] && ... | np | 1185_G1. Playlist for Polycarp (easy version) | CODEFORCES |
import java.util.*;
public class helloWorld
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
int l = 1000, r = 0, u = 1000, b = 0;
for(int i = 0; i < n; i++ ) {
String str = in.next();
for(int j = 0; j < m; j++)
if(... | quadratic | 1028_A. Find Square | CODEFORCES |
import java.util.Scanner;
public class prob1177b {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
long k,c,n,d;
c=1;
d=9;
n=1;
k= sc.nextLong();
while(k>(c*d)) {
k-=(c*d);
n*=10;
d*=10;
... | logn | 1177_B. Digits Sequence (Hard Edition) | CODEFORCES |
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
new Main().run();
}
StreamTokenizer in;
PrintWriter out;
//deb/////////////... | logn | 338_A. Quiz | CODEFORCES |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
/**
* Created by timur on ... | logn | 1080_D. Olya and magical square | CODEFORCES |
import java.io.*;
import java.util.StringTokenizer;
public class Main {
static int[] a;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = sc.nextInt();
a = sc.nextIntArray(n);... | nlogn | 986_B. Petr and Permutations | CODEFORCES |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
public class A {
private static StreamTokenizer in;
private static PrintWriter out;
private static int nextInt() throws Exception {
in.nextToken();
return (in... | linear | 25_A. IQ test | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static int inf = (int) 1e9;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(System.out);
int n = nextInt();
... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Stack;
import java.util.StringTokenizer;
public class TwoSets {
static... | linear | 468_B. Two Sets | CODEFORCES |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class BetaRound8_C implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok;
@Override
public void run() {
try {
long startTime = System.currentTimeMillis();
if (Syste... | np | 8_C. Looking for Order | CODEFORCES |
import java.util.Scanner;
public class CodeforcesC {
public static void main(String[] args) {
Scanner ob = new Scanner(System.in);
long n = ob.nextLong();
long s = ob.nextLong();
long l = 1;
long r = n;
while(l<=r){
long mid = (l + r)/2;
if(reallybignumber(mid,s)){
r = mid-1;
}else{
l = ... | logn | 817_C. Really Big Numbers | 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.util.*;
import java.io.*;
import java.math.*;
public class d {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
long[] arr = new long[n... | nlogn | 903_D. Almost Difference | CODEFORCES |
import java.util.*;
import java.io.*;
import java.text.*;
public class B1195 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
long x =sc.nextInt();
long y =sc.nextInt();
long m = (-3+Math.round(Math.sqrt(9+8*(x+y... | logn | 1195_B. Sport Mafia | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Solution {
BufferedReader in;
PrintWriter out;
StringTokenizer st;
String nextToken() throws Exception {
while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
return st.nextToken();
}
int nextInt... | logn | 256_B. Mr. Bender and Square | CODEFORCES |
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public cl... | cubic | 35_C. Fire Again | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Tt {
p... | quadratic | 1209_A. Paint the Numbers | CODEFORCES |
// discussed with rainboy
import java.io.*;
import java.util.*;
public class CF911D {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int n = Integer.parseInt(br.readLine());
Str... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;
public class P1141F {
static BufferedReader br;
static BufferedWriter bw;
static StringTokenizer st;
public static void main(String[] ... | quadratic | 1141_F2. Same Sum Blocks (Hard) | CODEFORCES |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
public class B {
public static void main(String[] args) {
FastScanner fs=new FastScanner();
int T=fs.nextInt();
for (int tt=0;... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.util.Scanner;
public class MargariteBestPresent_1080B {
private static int f(int x) {
return (x%2==0)?x/2:(x-1)/2-x;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n,r,l;
n = sc.nextInt();
while(n-->0) {
l = sc.nextInt();
r = sc.nextInt();
Syst... | constant | 1080_B. Margarite and the best present | CODEFORCES |
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;
import java.io.IOException;import java.io.InputStream;import java.io.PrintWriter;
import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Array;import java.lang.reflect.Field;impo... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;
/*
* 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.
*/
/**
*
* @a... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
static MyScanner scan;
static PrintWriter pw;
public static void main(String[] args) {
new Thread(null,null,"_",1<<25)
{
public void run()
{
try
{... | linear | 1004_A. Sonya and Hotels | CODEFORCES |
/*
* UMANG PANCHAL
* DAIICT
*/
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main
{
static LinkedList<Integer> adj[];
static ArrayList<Integer> adj1[];
static int[] color,visited1;
static boolean b[],visited[],possible;
static int level[];
static Map<Integer,HashSet<Integer... | quadratic | 911_D. Inversion Counting | CODEFORCES |
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main
{
static final long mod=(int)1e9+7;
public static void main(String[] args) throws Exception
{
FastReader in=new FastReader();
PrintWriter pw=new PrintWriter(System.out);
int n=in.nextInt();
long ans=0;
... | linear | 1062_D. Fun with Integers | CODEFORCES |
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.*;
import java.security.SecureRandom;
public class WCS {
public static class Vector implements Comparable <Vector> {
long x, y;
int position;
Vector first, second;
boolean toReverse;
publ... | nlogn | 995_C. Leaving the Bar | CODEFORCES |
import java.io.*;
import java.lang.reflect.*;
public class D {
final int MOD = (int)1e9 + 7;
final double eps = 1e-12;
final int INF = (int)1e9;
public D () {
long L = sc.nextLong();
long R = sc.nextLong();
int Z = 64 - Long.numberOfLeadingZeros(L ^ R);
long res = (1L << Z) - 1;
exit(res);
}
///... | logn | 276_D. Little Girl and Maximum XOR | CODEFORCES |
import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;
import static java.lang.Math.*;
// Solution is at the bottom of code
public class _AAAA implements Runnable{
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
OutputWriter out;... | nlogn | 274_A. k-Multiple Free Set | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class A {
static BufferedReader in;
static PrintWriter out;
static StringTokenizer st;
static Random rnd;
void solve() throws IOException {
int n = nextInt();
int[] arr = new int[n];
Integer[] arrCopy = new Integer[n];
for (int i = 0; i ... | nlogn | 220_A. Little Elephant and Problem | CODEFORCES |
import java.util.Scanner;
public class AlexAndARhombus {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
System.out.println(n*n+(n-1)*(n-1));
sc.close();
}
}
| constant | 1180_A. Alex and a Rhombus | CODEFORCES |
import java.util.Scanner;
public class ToyArmy {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
System.out.println(n / 2 + n);
}
}
| constant | 84_A. Toy Army | CODEFORCES |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | quadratic | 1027_E. Inverse Coloring | CODEFORCES |
/**
* @author derrick20
*/
import java.io.*;
import java.util.*;
public class PetyaSpiders implements Runnable {
public static void main(String[] args) throws Exception {
new Thread(null, new PetyaSpiders(), ": )", 1 << 28).start();
}
public void run() {
FastScanner sc = new FastScanner(... | np | 111_C. Petya and Spiders | CODEFORCES |
import java.math.BigInteger;
import java.util.Scanner;
/*
* 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.
*/
/**
*
* @author Andy Phan
*/
public class p1096f {
static long MOD = 9... | nlogn | 1096_F. Inversion Expectation | CODEFORCES |
import java.io.*;
import java.util.*;
import java.math.*;
public class D {
static byte[] buf = new byte[1<<26];
static int bp = -1;
public static void main(String[] args) throws IOException {
/**/
DataInputStream in = new DataInputStream(System.in);
/*/
DataInputStream in = new DataInputStream(new Fi... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.io.*;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
public class Main {
public static void main(String[] args) {
File file = new File("in.txt");
File fileOut = new File("out.txt");
InputStream inputStream = null;
OutputStream outputStream =... | quadratic | 909_C. Python Indentation | CODEFORCES |
import java.io.*;
import java.util.*;
public class ProblemA {
InputReader in; PrintWriter out;
void solve() {
int n = in.nextInt();
int m = in.nextInt();
int k = in.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = in.nextInt();
Arra... | nlogn | 257_A. Sockets | CODEFORCES |
import java.io.PrintWriter;
import java.util.Scanner;
public class C186D2A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
if (n >= 0) {
out.println(Math.abs(n));
} else {
out.println(Math.max(n/10, (n... | constant | 313_A. Ilya and Bank Account | CODEFORCES |
/*Author: Satyajeet Singh, Delhi Technological University*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class Main{
/*********************************************Constants******************************************/
static PrintWrite... | np | 1238_E. Keyboard Purchase | CODEFORCES |
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Comp c1 = getComp(scanner);
Comp c2 = getComp(scanner);
c1.sortByPrice();
c2.sortByPrice();
int i = 0;
int j = 0;
while(i < c1.num || j < c2.num) {
Elem xi = (i < c1.num) ... | nlogn | 981_B. Businessmen Problems | CODEFORCES |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
//inputs
long n = in.nextLong();
if(n == 1)
System.out.println(1);
else if(n == 2)
System.out.println(2);
... | constant | 235_A. LCM Challenge | CODEFORCES |
import java.util.*;
import java.io.*;
public class _1517_D {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
StringTokenizer line = new StringTokenizer(in.rea... | cubic | 1517_D. Explorer Space | CODEFORCES |
import java.util.*;
import java.io.*;
@SuppressWarnings("Duplicates")
public class C817 {
private FastScanner in;
private PrintWriter out;
private long calcSum(long x) {
int ans = 0;
while (x > 0) {
ans += x % 10;
x /= 10;
}
return ans;
}
pr... | logn | 817_C. Really Big Numbers | CODEFORCES |
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.util.*;
public class CFContest {
public static void main(String[] args) throws Exception ... | np | 1209_E1. Rotate Columns (easy version) | CODEFORCES |
import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class Solution23A {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok =... | cubic | 23_A. You're Given a String... | CODEFORCES |
import java.util.Scanner;
public class R495A {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int n=scan.nextInt(), k=scan.nextInt();
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=scan.nextInt();
int res=2;
for(int i=0;i<n-1;i++) {
if(a[i+1]-a[i]>2*k) res+=2;
else if(a... | linear | 1004_A. Sonya and Hotels | 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 | 817_C. Really Big Numbers | CODEFORCES |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Template implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void init() throws FileNotFoundException {
try {
in = new BufferedReader(new FileReader... | np | 11_D. A Simple Task | CODEFORCES |
import java.io.*;
import java.util.*;
public class CF387D {
static class A {
ArrayList<Integer> list = new ArrayList<>();
int u, v, d;
}
static int INF = Integer.MAX_VALUE;
static boolean bfs(A[] aa, int n) {
LinkedList<Integer> queue = new LinkedList<>();
for (int u = 1; u <= n; u++)
if (aa[u].v > 0)
... | cubic | 387_D. George and Interesting Graph | CODEFORCES |
// practice with rainboy
import java.io.*;
import java.util.*;
public class CF111C extends PrintWriter {
CF111C() { super(System.out, true); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF111C o = new CF111C(); o.main(); o.flush();
}
int encode(int[] aa, int m) {
int a = 0;
... | np | 111_C. Petya and Spiders | CODEFORCES |
//بسم الله الرحمن الرحيم
import java.util.*;
import java.lang.*;
import java.nio.*;
import java.io.*;
public class as {
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
... | linear | 1515_B. Phoenix and Puzzle | CODEFORCES |
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;
public class C {
static long x, k;
static long mod = 1000000007;
public static void main(String[] args) {
JS in = new JS();
x = in.nextLong();
k = in.nextLong();
... | logn | 992_C. Nastya and a Wardrobe | CODEFORCES |
import java.util.*;
import java.io.*;
public class givenstring {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
String in = reader.next();
int max = 0;
for(int i = 0; i < in.length(); i++){
for(int j = i+1; j < in.length(); j++){
//take this substring
String ... | cubic | 23_A. You're Given a String... | CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.