content stringlengths 219 31.2k | complexity stringclasses 5
values | file_name stringlengths 6 9 | complexity_ranked float64 0.1 0.9 |
|---|---|---|---|
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;
public class A1 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long size = scan.nextLong();
int numberOfSpecial = scan.nextInt();
long pageSize = scan.nextLong... | n | 633.java | 0.5 |
import java.util.*;
import java.io.*;
public class C{
static PrintWriter out;
static InputReader in;
public static void main(String args[]){
out = new PrintWriter(System.out);
in = new InputReader();
new C();
out.flush(); out.close();
}
C(){
int w = solve();... | n | 636.java | 0.5 |
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
Arrays.sort(a);
//boolean
int t=1,c=0;
for(int i=1;i<n;i++){
if(a[i]==a[i-1]... | n | 637.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template ... | n | 638.java | 0.5 |
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class B {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new Out... | n | 639.java | 0.5 |
// Java implementation of brute
// force solution.
import
java.util.LinkedHashSet;
class
GFG
{
// Function to check if the given
// number has repeated digit or not
static
int
repeated_digit(
int
n)
{
LinkedHashSet<Integer> s =
new
LinkedHashSet<>();
// Traversing through each digit
while
(n !=
0
)
... | n | 64.java | 0.5 |
import java.util.*;
import java.io.*;
public class C{
static PrintWriter out;
static InputReader in;
public static void main(String args[]){
out = new PrintWriter(System.out);
in = new InputReader();
new C();
out.flush(); out.close();
}
C(){
int a = solve();... | n | 640.java | 0.5 |
import java.io.*;
import java.util.*;
public class Solution {
static boolean canWinFromOneMove(char []s,int k) {
int prefix=0;
int n=s.length;
for(int i=0;i<n && s[i]==s[0];i++)
prefix++;
int suffix=0;
for(int i=n-1;i>=0 && s[i]==s[n-1];i--)
suffix++;
return s[0]==s[n-1] && prefix+suffix+k>=n ||... | n | 641.java | 0.5 |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.SortedSet;
import java.util.Set;
import java.util.NavigableSet;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamRe... | n | 642.java | 0.5 |
// Java code to demonstrate Difference Array
class
GFG {
// Creates a diff array D[] for A[] and returns
// it after filling initial values.
static
void
initializeDiffArray(
int
A[],
int
D[])
{
int
n = A.length;
D[
0
] = A[
0
];
D[n] =
0
;
for
(
int
i =
1
; i < n; i++)
D[i] = A[i] - A[i -
1
]... | n | 65.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class LightItUp {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new ... | n | 650.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Cf1003A {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.r... | n | 653.java | 0.5 |
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 Priya
*/
public class Main... | n | 654.java | 0.5 |
import java.util.*;
import java.io.*;
public class programA {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int d = Intege... | n | 657.java | 0.5 |
import java.util.*;
import java.io.*;
public class SonyaExhibition {
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 = {0,1};
for(int i = 0; i < n; i... | n | 658.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Cf1005A {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer... | n | 659.java | 0.5 |
class
Profit
{
// Returns maximum profit with two transactions on a given
// list of stock prices, price[0..n-1]
static
int
maxProfit(
int
price[],
int
n)
{
// Create profit array and initialize it as 0
int
profit[] =
new
int
[n];
for
(
int
i=
0
; i<n; i++)
profit[i] =
0
;
/* Get the maximum pro... | n | 66.java | 0.5 |
import java.util.*;
import java.lang.*;
public class CodeForce {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.next();
String t=sc.next();
int count=s.length()+t.length();
for(int i=0;i<Math.min(s.l... | n | 660.java | 0.5 |
import java.util.*;
//201920181
public class Polycarp{
public static void main(String args[]){
Scanner s = new Scanner(System.in);
int rem[] = new int[3];
Arrays.fill(rem,-1);
rem[0] = 0;
char ch[] = s.next().toCharArray();
int n = ch.length;
long dp[] = new long[n];
int sum =... | n | 662.java | 0.5 |
import java.util.*;
import java.io.*;
import java.util.Map.Entry;
public class Codeforces {
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.pa... | n | 665.java | 0.5 |
import java.io.OutputStream;
import java.io.IOException;
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.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
... | n | 667.java | 0.5 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n,ans=0;
String sa,sb;
char[] a,b;
n=sc.nextInt();
sa=sc.next();
sb=sc.next();
a=sa.toCharArray();
b=sb.toCharArray();
ans=0;
for(int i=0;i<n;i++)
{
if(i==n/2)
{... | n | 668.java | 0.5 |
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.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author... | n | 669.java | 0.5 |
// A Simple Java program to find
// minimum average subarray
class
Test {
static
int
arr[] =
new
int
[] {
3
,
7
,
90
,
20
,
10
,
50
,
40
};
// Prints beginning and ending indexes of subarray
// of size k with minimum average
static
void
findMinAvgSubarray(
int
n,
int
k)
{
// k must be smaller... | n | 67.java | 0.5 |
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int n=scan.nextInt();
int m=scan.nextInt();
int[] game=new int[n];
int[] bill=new int[m];
for (int i = 0; i <n ; i++) {
game[i]=scan.ne... | n | 670.java | 0.5 |
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner in=new Scanner(System.in);
String str=in.next();
int cnt=0;
for(int i=0;i<str.length();++i) {
if(str.charAt(i)=='1') {
++cnt;
}
}
int i=0;
for(;i<str.length();++i) {
if(str.charAt(i)=='0') {
S... | n | 671.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class AnnoyingPresent {
//UPSOLVED
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String... | n | 672.java | 0.5 |
import java.io.*;
import java.util.*;
public class CF1009E {
static final int MD = 998244353;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(b... | n | 675.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class SFly {
public static void main(String[] args) throws IOException {
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
int planet = Integer.parseInt(lector.readLine());
int ini... | n | 676.java | 0.5 |
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
/* spar5h */
public class cf1 implements Runnable{
public void run() {
InputReader s = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
int t = 1;
while(t-- > 0) {
int n = s.nextInt(), m ... | n | 679.java | 0.5 |
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();
String str = in.next();
boolean[] exist = new boolean[200];
int dn[][] = new int[200][m+1];
for(int i = 0; i < n; i++) {
int ... | n | 683.java | 0.5 |
import java.io.*;
public class First {
StreamTokenizer in;
PrintWriter out;
int nextInt() throws IOException {
in.nextToken();
return (int)in.nval;
}
long nextLong() throws IOException {
in.nextToken();
return (long) in.nval;
}
String nextString() throws ... | n | 685.java | 0.5 |
import java.util.*;
import java.io.*;
public class Solution
{
public static void main(String [] args) throws IOException
{
PrintWriter pw=new PrintWriter(System.out);//use pw.println() not pw.write();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenize... | n | 687.java | 0.5 |
class
MinimumDistance
{
int
minDist(
int
arr[],
int
n,
int
x,
int
y)
{
int
i =
0
;
int
min_dist = Integer.MAX_VALUE;
int
prev=
0
;
// Find the first occurence of any of the two numbers (x or y)
// and store the index of this occurence in prev
for
(i =
0
; i < n; i++)
{
if
(arr[i] == x || arr... | n | 69.java | 0.5 |
import java.util.*;
public class helloWorld
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int cnt = 0;
String ans = "Yes";
for(int i = 0; i < n; i++)
cnt += in.nextInt();
for(int i = 0; i < n; i++)
cnt -= in.nextInt();
if(cnt < 0)
... | n | 693.java | 0.5 |
import java.util.*;
import java.io.*;
public class Piles {
static int summation(int arr[]) {
int k, sum=0;
for(k=0;k<arr.length;k++) {
sum = sum + arr[k];
}
return sum;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n>=1 && n<=50) {
int ... | n | 694.java | 0.5 |
import java.util.Scanner;
public class Stones {
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
int s1=0;
int s2=0;
for (int i=0;i<n;++i)
s1+=input.nextInt();
for (int i=0;i<n;++i)
s2+=input.nextInt();
if (s1 >= s2)
System.out.println("Yes... | n | 695.java | 0.5 |
import java.util.Scanner;
public class Piles {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int[] a = new int[2]; int x = scan.nextInt();
for(int i = 0; i < 2; i++) for(int j = 0; j < x; j++) a[i] += scan.nextInt();
System.out.println(a[1] <= a[0] ? "Yes" : "No");
}
}
| n | 696.java | 0.5 |
import java.util.*;
import static java.lang.Math.*;
import java.io.*;
public class SolutionB {
public static void main(String args[])throws IOException{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
Set<Integer> se... | n | 698.java | 0.5 |
//package contese_476;
import java.util.*;
public class q1
{
int m=(int)1e9+7;
public class Node
{
int a;
int b;
public void Node(int a,int b)
{
this.a=a;
this.b=b;
}
}
public int mul(int a ,int b)
{
a=a%m;
b=b%m;
return((a*b)%m);
}
public int pow(int a,int b)
{
int x=1;
while(b>0)
{
if(b%2!=0)
x=mul... | n | 699.java | 0.5 |
/**
* Created by Baelish on 7/30/2018.
*/
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class B {
public static void main(String[] args)throws Exception {
FastReader in = new FastReader(System.in);
PrintWriter pw = new PrintWriter(System.out);
int ans = -1... | n | 704.java | 0.5 |
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.math.*;
import java.util.*;
import java.util.Map.Entry;
public class Main {
public static void main(String[] args) throws IOExce... | n | 708.java | 0.5 |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class DeathNote {
public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public stati... | n | 712.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Cf1017A {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer... | n | 713.java | 0.5 |
import java.util.*;
public class Test { public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int x= (int)Math.sqrt(n) ;
int a[] = new int[n+5];
for(int i=1,o=n,j;i<=n;i+=x)
for(j=(int)Math.min(i+x-1,n);j>=i;a[j--]=o--);
for(int i=1;i<=n;i++)System.out.print(a[i]+" ");
Syste... | n | 714.java | 0.5 |
import java.util.Scanner;
//import java.util.Scanner;
public class SingleWildcard {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input =new Scanner(System.in);
int a = input.nextInt();
int b = input.nextInt();
char[] s1 =new char[a];
s1 = input.next().toCharArr... | n | 717.java | 0.5 |
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 <... | n | 719.java | 0.5 |
import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.Function;
public class Main {
static String S;
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
S = sc.next();
Sy... | n | 721.java | 0.5 |
import java.io.*;
import java.util.*;
public class CF1027D {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
int[] cc = new in... | n | 728.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Cheast {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] l = new int[n];
... | n | 735.java | 0.5 |
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.*;
public class Main
{
static Graph graph[];
public static void add_edge(in... | n | 736.java | 0.5 |
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.Scanner;
import java.util.StringTokenizer;
public class CF_1029E_Tree_with_Small_Distances {
static ArrayList<Integer> adj[];
... | n | 738.java | 0.5 |
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
public class PlayingPiano {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
List<Integer> as = new LinkedList<>();
int[] as2 =... | n | 742.java | 0.5 |
import java.util.*;
import java.io.*;
public class _1036_B_DiagonalWalkingV2 {
public static void main(String[] args) throws IOException {
int Q = readInt();
while(Q-- > 0) {
long n = readLong(), m = readLong(), k = readLong();
if(Math.max(n, m) > k) println(-1);
else {
long ans = k;
if(n%2 != k... | n | 746.java | 0.5 |
import java.util.*;
import java.io.*;
public class vasyaarray{
public static void main(String[] args)throws IOException {
FastReader in=new FastReader(System.in);
int n=in.nextInt();
long arr1[]=new long[n];
long pre1[]=new long[n];
int i,j;
arr1[0]=in.nextLong();
pre... | n | 747.java | 0.5 |
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;
... | n | 750.java | 0.5 |
/**
* 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... | n | 752.java | 0.5 |
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[] ar = new int[200];
String str = in.next();
for(int i = 0; i < str.length(); i++)
ar[ str.charAt(i) ]++;
int ans = 1... | n | 753.java | 0.5 |
import java.util.*;
public class helloWorld
{
static ArrayList<Integer> ar;
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
StringBuilder ans = new StringBuilder();
if(n <= 2)
ans.append("No");
else if(n == 4) {
ans.append("Yes\n");
ans.appe... | n | 754.java | 0.5 |
// LM10: The next Ballon d'or
import java.util.*;
import java.io.*;
import java.math.*;
import javafx.util.Pair;
public class Main
{
static class FastReader
{
private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public FastReader() { this(System.in); }public FastRead... | n | 756.java | 0.5 |
import java.util.*;
import java.io.*;
public class FirstClass {
public static void main(String[] args)throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int n = Integer.parseInt(br.readLine());
int arr[] = new ... | n | 758.java | 0.5 |
// O(n) solution for finding smallest subarray with sum
// greater than x
class
SmallestSubArraySum
{
// Returns length of smallest subarray with sum greater than x.
// If there is no subarray with given sum, then returns n+1
static
int
smallestSubWithSum(
int
arr[],
int
n,
int
x)
{
// Initialize curre... | n | 76.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
public class B {
static ArrayList<Integer> [] adj;
static int [] num;
static int d... | n | 761.java | 0.5 |
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;
public class A
{
public static void main(String args[]) throws Exception
{
BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st ... | n | 763.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class SequenceTransformation {
void solve() {
int p = 1, n = in.nextInt();
while (n > 0) {
if (n ==... | n | 765.java | 0.5 |
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 MaxHeap
*/
public class Main ... | n | 770.java | 0.5 |
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;
... | n | 771.java | 0.5 |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.List;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
/**
... | n | 772.java | 0.5 |
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
// Scanner scan = new Scanner(System.in);
PrintWriter out = new P... | n | 773.java | 0.5 |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.stream.Stream;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchExce... | n | 774.java | 0.5 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
public class CodeForces
{
public static void main(String[] args)
{
Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int n = input.nextInt();
String s = input.ne... | n | 776.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class pr1073B {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.... | n | 777.java | 0.5 |
// Java program to find maximum average
// subarray of given length.
import
java .io.*;
class
GFG {
// Returns beginning index
// of maximum average
// subarray of length 'k'
static
int
findMaxAverage(
int
[]arr,
int
n,
int
k)
{
// Check if 'k' is valid
if
(k > n)
return
-
1
;
// Create and... | n | 78.java | 0.5 |
import java.io.*;
import java.util.*;
public class CF1082D {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
int[] aa = new in... | n | 785.java | 0.5 |
/**
* Created by Aminul on 3/14/2019.
*/
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import static java.lang.Math.max;
public class E_2 {
public static void main(String[] args) throws Exception {
F... | n | 786.java | 0.5 |
import java.util.*;
import java.io.*;
public class MinimumDiameterTree{
public static void main(String[] args) {
InputReader in = new InputReader (System.in);
PrintWriter out = new PrintWriter (System.out);
int n = in.nextInt();
int s = in.nextInt();
int deg[] = new int [n];
for (int i = 1; i < n; ++i) {
... | n | 789.java | 0.5 |
// Java program to find maximum average subarray
// of given length.
import
java.io.*;
class
GFG {
// Returns beginning index of maximum average
// subarray of length 'k'
static
int
findMaxAverage(
int
arr[],
int
n,
int
k)
{
// Check if 'k' is valid
if
(k > n)
return
-
1
;
// Compute sum of f... | n | 79.java | 0.5 |
import java.util.*;
public class ehab3 {
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();
System.out.println( ( n + 1 ) );
int c = 0;
for ( int i = n - 1; i >= 0; i-- )... | n | 793.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class EhabAndAComponentChoosingProblem {
long INF = (long) 1e18;
int n;
int[] a;
... | n | 795.java | 0.5 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
long sum1=0,sum2=0;
for(int i=0;i<num*2;i++){
sum1+=sc.nextInt();
sum2+=sc.nextInt();
}
System.out.println(sum1/num+" "+sum2/num);
}
}
... | n | 796.java | 0.5 |
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.min;
import static java.lang.System.exit;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public cla... | n | 798.java | 0.5 |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class UniformString {
public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public s... | n | 799.java | 0.5 |
// JAVA implementation of left rotation
// of an array K number of times
import
java.util.*;
import
java.lang.*;
import
java.io.*;
class
arr_rot
{
// Function to leftRotate array multiple
// times
static
void
leftRotate(
int
arr[],
int
n,
int
k)
{
/* To get the starting point of
rotated array */
... | n | 8.java | 0.5 |
// Java program to find number of operations
// to make an array palindrome
class
GFG
{
// Returns minimum number of count operations
// required to make arr[] palindrome
static
int
findMinOps(
int
[] arr,
int
n)
{
int
ans =
0
;
// Initialize result
// Start from two corners
for
(
int
i=
0
,j=n-
... | n | 80.java | 0.5 |
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;
import java.util.Stack;
public class D527A2 {
public static void main(String[] args) {
FastScanner in = new FastScanner(System.in);
int N = in.nextInt();
Stack<Integer> stack = new Stack<>();
for(int i = 0; i < N;... | n | 800.java | 0.5 |
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()... | n | 801.java | 0.5 |
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner s= new Scanner(System.in);
int n=s.nextInt();StringBuilder sb=new StringBuilder();
long[] a=new long[n/2];
for(int i=0;i<n/2;i++){
a[i]=s.nextLong();
}int j=0;long[] a2=new long[n/2];long[] a1... | n | 803.java | 0.5 |
import java.io.*;
public class GennadyAndACardGame {
public static void main(String[] args) throws IOException {
BufferedReader bufr = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bufw = new BufferedWriter(new OutputStreamWriter(System.out));
String line =null;
String[] n={};
String ... | n | 806.java | 0.5 |
// Java program to find the smallest positive value that cannot be
// represented as sum of subsets of a given sorted array
class
FindSmallestInteger
{
// Returns the smallest number that cannot be represented as sum
// of subset of elements from set represented by sorted array arr[0..n-1]
int
findSmallest(
i... | n | 81.java | 0.5 |
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
public class CodeForces {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int d = in.nextInt(), sum = in.nextInt();
List<Data> data = new ArrayList<>();
for (int i = 0; i < ... | n | 814.java | 0.5 |
// practice with rainboy
import java.io.*;
import java.util.*;
public class CF903F {
static final int INF = 0x3f3f3f3f;
static void fill(int[][][][] aa, int a) {
for (int h0 = 0; h0 <= 4; h0++)
for (int h1 = 0; h1 <= 4; h1++)
for (int h2 = 0; h2 <= 4; h2++)
for (int h3 = 0; h3 <= 4; h3++)
aa[h0][... | n | 820.java | 0.5 |
import java.util.Scanner;
public class GenerateLogin {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String a = scan.next();
String b = scan.next();
char last = b.charAt(0);
String ans = ""+a.charAt(0);
for(int i = 1;i<a.length();i++){
if(a.charAt(i)>=last)break;
a... | n | 824.java | 0.5 |
import java.util.*;
import java.io.*;
public class A{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int ans = 0;
for(int i = 1; i <= n; i++){
ans += ((i*2) <= n) ? i : n-i+1;
... | n | 825.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class D909 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char[] line = br.readLin... | n | 827.java | 0.5 |
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Main {
static Scanner in = new Scanner();
static PrintWriter out = new PrintWriter(System.out);
public static void main(Strin... | n | 828.java | 0.5 |
import java.io.*;
import java.util.*;
import java.util.Collections;
import java.util.Arrays;
public class Codechef {
public static void main(String[] args) throws IOException {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a=sc.nextInt();
int b=sc.nextInt();
int res=0;
... | n | 829.java | 0.5 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] P = new int[n];
int[] check=new int[n];
for (int i = 1; i < n; i++) {
P[i] = scanner.nextInt();
... | n | 836.java | 0.5 |
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;
import static java.lang.Math.ceil;
public class practise {
static final int N = 31;
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out,true);
static long c[] = new long[N];
... | n | 837.java | 0.5 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class C {
public static int mod = 1000000000 + 7;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String n = br.readLine();
... | n | 841.java | 0.5 |
import java.util.*;
public class Main{
public static void main(String [] args)
{
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
char c[]=new char[n];
Arrays.fill(c,'o');
int x=1,y=1,z;
while(y<=n)
{
c[y-1]='O';
z=x+y;
... | n | 846.java | 0.5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.