codeparrot/codecomplex huggingface dataset:
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Scanner;

public class A {

    static {
	final Locale us = Locale.US;
	if (!Locale.getDefault().equals(us)) {
	    Locale.setDefault(us);
	}
    }

    static boolean file = false;

    static Scanner in;
    static {
	try {
	    in = new Scanner(file ? new FileInputStream("f:\\var\\tmp\\in.txt")
		    : System.in);
	} catch (final FileNotFoundException e) {
	    e.printStackTrace();
	}
    }

    static PrintWriter out;
    static {
	try {
	    out = file ? new PrintWriter(
		    new FileWriter("f:\\var\\tmp\\out.txt")) : new PrintWriter(
		    System.out);
	} catch (final IOException e) {
	    e.printStackTrace();
	}
    }

    /**
     * @param args
     */
    public static void main(final String[] args) {
	try {

	    solve();
	    if (file) {
		System.out.flush();
	    }
	    if (!file) {
		out.flush();
	    }

	} finally {
	    in.close();
	    out.close();
	}
    }

    private static void solve() {
	final String s = in.next();

	int ans = 0;
	for (int l = 0; l < s.length(); ++l) {
	    for (int r = l; r < s.length(); ++r) {
		for (int p = l + 1; p - l + r < s.length(); ++p) {
		    boolean ok = true;

		    for (int q = l, qq = p; q <= r; ++q, ++qq) {
			if (s.charAt(q) != s.charAt(qq)) {
			    ok = false;
			}
		    }

		    if (ok) {
			ans = Math.max(ans, r - l + 1);
		    }
		}
	    }
	}

	out.println(ans);
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Gaurav
 */import java.io.*;
public class a23 {
    public static void main(String arg[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));




          String s=br.readLine();int max=0;
          for(int i=0;i<s.length();i++)
          {
              for(int j=i+1;j<=s.length();j++)
              {
                  String g=s.substring(i,j);
                  //System.out.println(g);
                  if(max<g.length())
                  for(int k=i+1;k<=s.length()-g.length();k++)
                  {
                      //System.out.println(s.substring(k,k+g.length()));
                      if(g.compareTo(s.substring(k,k+g.length()))==0)
                      {
                          max=g.length();
                          break;
                      }
                      }
              }
          }
          System.out.println(max);
}
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
//contest 23. You're Given A String
import java.util.*;
public class ProblemA
{
	public static void main(String[] args)
	{
		Scanner keyboard = new Scanner(System.in);
		String input = keyboard.nextLine();
		boolean con = false;
		for( int i = input.length()-1; i > 0 ; i--)
		{	
			for ( int j = 0; j+i< input.length(); j++ )
				for( int k = j+1; k+i <= input.length(); k++ )
					if( input.substring(j,j+i).equals( input.substring(k,k+i) ) ) 
					{
						System.out.print(i+"\n");
						k = input.length()+1;
						j = input.length();
						i = -1;
						con = true;
					}
		}
		if( con == false )
			System.out.print(0+"\n");
	}	
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class A{
    Scanner sc=new Scanner(System.in);

    void run(){
        String s=sc.nextLine();
        int n=s.length();
        int ans=0;
        for(int len=1; len<n; len++){
            for(int i=0; i+len<=n; i++){
                String t=s.substring(i, i+len);
//              println(t);
                if(s.indexOf(t,i+1)!=-1){
                    ans=len;
                    break;
                }
            }
        }
        println(ans+"");
    }

    void println(String s){
        System.out.println(s);
    }

    void print(String s){
        System.out.print(s);
    }

    public static void main(String[] args){
        new A().run();
    }

}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic

import java.util.Scanner;

public class P23A {
    public P23A() {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        sc.close();
        
        String maxStr = "";
        for (int i = 0; i < str.length() - 1; i++){
            for (int j = i + 1; j < str.length(); j++){
                String pattern = str.substring(i, j);
                if (str.substring(i+1).contains(pattern) && pattern.length() > maxStr.length()){
                    maxStr = pattern;
                }
            }
        }
        System.out.println(maxStr.length());
    }
    
    public static void main (String []args){
        new P23A();
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Test {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            for (int j = i + 1; j <= s.length(); j++) {
                String t = s.substring(i, j);
                if (s.indexOf(t, i + 1)>=0) {
                    ans = Math.max(ans, j - i);
                }
            }
        }
        System.out.println(ans);
    }   

}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class R023A {
	String str;
	int n; 
	public R023A() {
		Scanner scanner = new Scanner(System.in);
		str = scanner.next();
		n = str.length();
	}

	private void process() {
		int length = -1;
		for(int i=1; i<n; i++) {
			Set<String> set = new HashSet<String>();
			length = n - i;
			for(int j=0; j<=i; j++) {
				String sub = str.substring(j, j+length);
				set.add(sub);
			}
			if(set.size() < i+1) {
				System.out.println(length);
				return;
			}
		}
		System.out.println(0);
	}

	public static void main(String[] args) {
		new R023A().process();
	}
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class _P023A{
    Scanner sc=new Scanner(System.in);

    int INF=1<<28;
    double EPS=1e-9;

    String s;

    void run(){
        s=sc.nextLine();
        solve();
    }

    void solve(){
        int n=s.length();
        int max=0;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                for(int k=0; j+k<n; k++){
                    if(s.charAt(i+k)!=s.charAt(j+k)){
                        break;
                    }else{
                        max=max(max, k+1);
                    }
                }
            }
        }
        println(max+"");
    }

    void println(String s){
        System.out.println(s);
    }

    void print(String s){
        System.out.print(s);
    }

    void debug(Object... os){
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args){
        Locale.setDefault(Locale.US);
        new _P023A().run();
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic

/**
 * Mx NINJA 04:06:52 ص 14/01/2014
 */
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder line = new StringBuilder(reader.readLine());
        int length = 0;
        for (int head = 0; head < line.length(); head++) {
            for (int tail = line.length() - 1; tail > head; tail--) {
                String subString = line.substring(head, tail);
                if(line.indexOf(subString,head+1)>-1){
                    length = Math.max(subString.length(), length);
                }
            }
        }
        System.out.println(length);
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
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 BufferedReader(new FileReader(fileName));
			nextToken();
		}

		public FastScanner(InputStream stream) {
			br = new BufferedReader(new InputStreamReader(stream));
			nextToken();
		}

		String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		void close() {
			try {
				br.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	FastScanner sc;
	PrintWriter out;

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() {
		return sc.nextInt();
	}

	String nextToken() {
		return sc.nextToken();
	}

	long nextLong() {
		return sc.nextLong();
	}

	double nextDouble() {
		return sc.nextDouble();
	}

	void solve() {
		String s = nextToken();
		for (int len = s.length(); len >= 1; len--) {
			for (int i = 0; i + len <= s.length(); i++) {
				int cnt = 0;
				for (int j = 0; j + len <= s.length(); j++) {
					boolean ok = true;
					for (int k = 0; k < len; k++) {
						if (s.charAt(i + k) != s.charAt(j + k)) {
							ok = false;
							break;
						}
					}
					if (ok) {
						cnt++;
					}
				}
				if (cnt > 1) {
					out.println(len);
					return;
				}
			}
		}
		out.println(0);
	}
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.util.Scanner;


public class GiveString23A {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        String stroke = in.next();
        char[] s = new char [stroke.length()];
        for (int i=0;i<stroke.length();i++)
            s[i]=stroke.charAt(i);
        int dlina = 0;
        for (int i=0;i<s.length-1;i++)
            for (int j=i+1;j<s.length;j++)
                for (int k=0;k<(s.length-j);k++)
                    if (s[i]==s[j])
                    {
                        int ik=i+k;
                        int jk = j+k;
                        if (s[ik]==s[jk])
                        {
                            if (dlina<k+1)
                                dlina=k+1;      
                        }
                        else 
                        break;
                    }       
        System.out.println(dlina);
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class P023A {

    public static void main(String[] args) {
        Scanner inScanner = new Scanner(System.in);
        String string = inScanner.next();
        int n = string.length();
        for (int l = n - 1; l > 0; l--) {
            Set<String> seen = new HashSet<String>();
            for (int i = 0; i < n - l + 1; i++) {
                String subString = string.substring(i, i + l);
                if (seen.contains(subString)) {
                    System.out.println(l);
                    return;
                }
                seen.add(subString);
            }
        }
        System.out.println("0");
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.text.DecimalFormat;
import java.util.Scanner;

public class A {
    public static void main(String[] args){
        try{
            Scanner scanner = new Scanner(System.in);
            String in = scanner.next();
            int max = 0;
            for(int j=0;j<in.length()-1;j++){
                for(int i=j;i<in.length();i++){
                    if(in.indexOf(in.substring(j, i)) != in.lastIndexOf(in.substring(j, i)) && (i-j)>max){
                        max = i-j;
                    }
                }
            }
            System.out.println(max);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.io.*;
import java.util.StringTokenizer;

/**
 *
 * @author Prateep
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
    }
}

class TaskB{
    public void solve(int testNumber, InputReader in, PrintWriter out){
        String base = in.next();
    for (int len=base.length()-1;len>=1;len--)
            for (int i=0;i<base.length()-len+1;i++)
                for (int j=i+1;j<base.length()-len+1;j++)
                    if (base.substring(i,i+len).equals(base.substring(j,j+len))){
                        out.println(len);
            return;
                    }
    out.println(0);
    
    }
    
}
class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong(){
        return Long.parseLong(next());
    }
    public double nextDouble(){
        return Double.parseDouble(next());
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.io.*;
import java.util.*;

public class A implements Runnable {

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public static void main(String[] args) {
		new Thread(new A()).start();
	}

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void solve() throws IOException {
		String s = nextToken();
		int max = 0;
		for(int i = 0 ; i < s.length(); i++)
			for(int j = i+1 ; j < s.length(); j ++){
				String sub = s.substring(i, j);
				int kv = 0;
				for(int k = 0 ; k<= s.length() - sub.length(); k ++){
					boolean ok = true;
					for(int g = 0 ; g < sub.length(); g ++)
					if (sub.charAt(g) != s.charAt(g+k)){
						ok = false;
						break;
					}
					if (ok) kv ++;
				}
				if (kv > 1)
				max = Math.max(max, sub.length());
			}
				
		out.println(max);
	}

	public void run() {
		try {
				br = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
		
		//		br = new BufferedReader(new FileReader("input.txt"));
		//		out = new PrintWriter("output.txt");
		
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}

	}

}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic

import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.io.*;

public class Mulitple
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		
		String s = r.readLine();

		System.out.println(num(s));
	}

	public static int num(String s)
	{
		int answer = 0;
		Set<String> set = new HashSet<String>();
		for(int j = s.length()-1; j>=1; j--)
		{
			for(int i = 0; i<s.length()-j+1; i++)
			{
				if(set.contains(s.substring(i,i+j)))
				{
					return s.substring(i,i+j).length();
				}
				else
				{
					set.add(s.substring(i,i+j));
				}
			}
		}

		return 0; 

	}
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.lang.Math.*;

public class Main {
    //StreamTokenizer in;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() throws IOException {
        //in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));

        String s = in.readLine();
        int n = s.length();
        for(int len = n; len > 0; len--) {
            for(int i = 0; i + len <= n; i++) {
                for(int j = 0; j + len <= n; j++)
                    if(i != j) {
                        boolean f = true;
                        for(int k = 0; k < len; k++)
                            if(s.charAt(i + k) != s.charAt(j + k)) {
                                f = false;
                                break;
                            }
                        if(f) {
                            out.println(len);
                            out.flush();
                            return;
                        }
                    }
            }
        }
        out.println(0);
        out.flush();
    }

    void solve() throws IOException {
        
    }
    
    //int ni() throws IOException { in.nextToken(); return (int) in.nval; }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import static java.lang.Math.max;

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 GivenString implements Runnable
{
  public static void main(String[] args) throws Exception
  {
    new GivenString().run();
  }

  private void solve() throws Exception
  {
    String s = nextToken();
    int len = s.length();
    KMP kmp = new KMP();
    int r = 0;
    for (int i = 0; i < len; i++)
    {
      for (int j = i + 1; j <= len; j++)
      {
        String cur = s.substring(i, j);
        int count = kmp.search(s, cur);
        if (count >= 2)
          r = max(r, cur.length());
      }
    }
    out.println(r);
  }

  class KMP
  {
    public int search(String text, String pattern)
    {
      int count = 0;
      int n = text.length(), m = pattern.length(), matchPoint = -1;
      char pat[] = pattern.toCharArray(), t[] = text.toCharArray();
      int p[] = prefixTable(pattern);
      int j = 0;
      for (int i = 0; i < n; i++)
      {
        while (j > 0 && pat[j] != t[i])
          j = p[j - 1];
        if (pat[j] == t[i])
          j++;
        if (j == m)
        {
          matchPoint = i - m + 1;
          j = p[j - 1];
          count++;
        }
      }
      return count;
    }

    private int[] prefixTable(String pat)
    {
      int m = pat.length(), p[] = new int[m];
      char s[] = pat.toCharArray();
      int j = 0;
      for (int i = 1; i < m; i++)
      {
        while (j > 0 && s[j] != s[i])
          j = p[j - 1];
        if (s[j] == s[i])
          j++;
        p[i] = j;
      }
      return p;
    }

  }

  // -------------- Input/Output routines below ---------------//
  private BufferedReader in;
  PrintWriter out;
  StringTokenizer tokenizer;

  public void run()
  {
    // String problem = this.getClass().getName();
    try
    {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(new BufferedOutputStream(System.out));
      solve();
      out.flush();
      in.close();
      out.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      // System.exit(1);
    }
  }

  String nextToken() throws IOException
  {
    while (tokenizer == null || !tokenizer.hasMoreTokens())
    {
      tokenizer = new StringTokenizer(in.readLine());
    }
    return tokenizer.nextToken();
  }

  int nextInt() throws IOException
  {
    return Integer.parseInt(nextToken());
  }

  long nextLong() throws IOException
  {
    return Long.parseLong(nextToken());
  }

  double nextDouble() throws IOException
  {
    return Double.parseDouble(nextToken());
  }

}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic
import java.util.Scanner;


public class p23a {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] x = in.next().toCharArray();
        
        int min = 0;
        int max = x.length;
        while(true) {
            if(max-min == 1)
                break;
            int mid = (max+min)/2;
            boolean eq = false;
            for (int i = 0; i <= x.length-mid; i++) {
                for (int j = 0; j <= x.length-mid; j++) {
                    if(j == i)
                        continue;
                    eq = true;
                    for (int k = 0; k < mid; k++) {
                        if(x[i+k] != x[j+k]) { 
                            eq = false;
                            break;
                        }
                    }
                    if(eq)
                        break;
                }
                if(eq) break;
            }
            if(eq) {
                min = mid;
            } else {
                max = mid;
            }
        }
        System.out.println(min);
        
    }
}
// Problem: 23_A. You're Given a String...
// Time complexity: cubic


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class A23 implements Runnable {

	private void Solution() throws IOException {
		String s = in.readLine();
		int n = s.length(), ans = 0;
		for (int i = 0; i < n; i ++) {
			for (int j = i; j < n; j ++) {
				for (int k = i+1; k <= n; k ++) {
					for (int g = k; g <= n; g ++) {
						if (s.substring(i,j).equals(s.substring(k,g))) {
							int l = s.substring(i,j).length();
							ans = Math.max(ans, l);
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String args[]) {
		new A23().run();
	}
	
	BufferedReader in;
	StringTokenizer tokenizer;
	
	public void run() {
		try {
            in = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            Solution();
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
	}

	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}
	
	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(in.readLine());
		return tokenizer.nextToken();
	}
}