codeparrot/codecomplex huggingface dataset:
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.util.Scanner;

public class digits
{
	public static void main(String[] args) 
	{
		long k = (new Scanner(System.in)).nextLong();

		//k = 56
		//League 1: 0 - 9
		//League 2: 10 - 99
		//League 3: 100 - 999..
		//System.out.println("k = "+k);
		long league = 1;
		long irrelevancy = 0;
		while(true)
		{	
			irrelevancy += league * (Math.pow(10, league) - Math.pow(10, league-1));
			if(k > irrelevancy)
				league ++;
			//league = 1 : k = 56 > 9
			//league = 2 : k = 56 < 99
			//therefore league = 2
			else
				break;
		}
		//System.out.println("League = "+league);
		irrelevancy = 0;
		for(long i=1; i<league; i++)
			irrelevancy += i * (Math.pow(10, i) - Math.pow(10, i-1));

		//irrelevancy = 1 * (10^1 - 10^0) = 9

		long modified_k = k - irrelevancy;

		//modified_k = 56 - 9 = 47
		//System.out.println("modified k = "+ modified_k);
		long number = (long)(Math.pow(10, league-1)) - 1 + modified_k / league;
		//System.out.println("number = "+number);

		if(modified_k % league == 0)
			System.out.println(number % 10);
		else
		{
			number ++;
			long position_of_digit = (long)(modified_k % league);
			//System.out.println(position_of_digit);
			//number = 24
			//position_of_digit = 47 % 2 = 1
			System.out.println((Long.toString(number)).charAt((int)position_of_digit-1));
		}
	}


}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.util.*;
import java.io.*;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            long k=Long.parseLong(br.readLine());
            long l=1,h=1000000000000l;
            long p[]=new long[13];
            for(int i=1;i<=12;i++)
            {
                  long ll=9*i;
                  p[i]=ll*(long)Math.pow(10,i-1);
                  p[i]+=p[i-1];
            }
            while(h-l>1)
            {
                  long mid=(l+h)/2;
                  long num=(long)(Math.log(mid)/Math.log(10));
                  long l1=p[(int)num]+(num+1)*(mid-(long)Math.pow(10,num));
                  long l2=p[(int)num]+(num+1)*(mid-(long)Math.pow(10,num)+1);
                  if(k<=l1)
                   h=mid;
                  else if(k>l2)
                   l=mid;
                  else
                  { l=mid; h=mid; }
            }
            
            if(h-l==1)
            { 
                long num=(long)(Math.log(h)/Math.log(10));
                long l1=p[(int)num]+(num+1)*(h-(long)Math.pow(10,num));
                long l2=p[(int)num]+(num+1)*(h-(long)Math.pow(10,num)+1);
                if(k>l1 && k<=l2)
                { l=h; }
            }
            
            long n=(long)(Math.log(l)/Math.log(10));
            long u=p[(int)n]+(n+1)*(l-(long)Math.pow(10,n));
            k-=u;
            String ss=String.valueOf(l);
            //System.out.println(l+" "+k);
            System.out.println(ss.charAt((int)(k-1)));
      }
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Queue;
import java.util.Scanner;

public class Tests {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long inputNum = 0;
		String finalResult = "";

		inputNum = scanner.nextLong();
		long upperLimitResult = 0;
		long lowerLimitResult = 0;
		int multiplier = 0;
		do {
			multiplier++;
			lowerLimitResult = upperLimitResult;
			upperLimitResult += 9 * Math.pow(10, multiplier - 1) * (multiplier);
		} while (inputNum > upperLimitResult);
		long remainderFromLowerRange = inputNum - lowerLimitResult;
		long repititions = 0;
		if (multiplier > 1)
			repititions = (remainderFromLowerRange - 1 > 0 ? remainderFromLowerRange - 1 : 0) / multiplier;
		long currentNumber = (long) (Math.pow(10, multiplier - 1) + repititions);
		remainderFromLowerRange = remainderFromLowerRange - repititions * multiplier;
		long digitIndex = remainderFromLowerRange < multiplier ? multiplier - remainderFromLowerRange
				: remainderFromLowerRange % multiplier;

		if (multiplier == 1) {
			finalResult = (remainderFromLowerRange % 10) + "";
		} else {
			int charToGet = (int) ((multiplier - 1) - digitIndex);
			finalResult = (currentNumber + "").charAt(charToGet) + "";
		}
		System.out.print(finalResult);
		scanner.close();
	}

}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            long k=input.nextLong();
            long v=9;
            long s=0;
            int x=1;
            while(true)
            {
                if(s+v*x>k)
                {
                    break;
                }
                s+=v*x;
                v*=10;
                x++;
            }
            if(s==k)
            {
                out.println(9);
            }
            else
            {
                long d=k-s;
                long u=d/x;
                long rem=d%x;
                long nu=(long)Math.pow(10,x-1);
                nu+=u;
                if(rem==0)
                {
                    nu--;
                    out.println(nu%10);
                }
                else
                {
                    String str=String.valueOf(nu);
                    out.println(str.charAt((int)(rem-1)));
                }
            }
        }
        out.close();
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        long nextLong()
        {
            return Long.parseLong(next());
        }
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.util.Scanner;

public class P_1177B {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long k = scan.nextLong();
		long k2 = k - 10;
		int cont = 1, pos;
		String out; //System.out.println(getString((int)k));
		
		if(k <= 9)
			System.out.println(k);
		else {
			cont++;
			while(k2 >= cont*(long)(Math.pow(10, cont)-Math.pow(10, cont-1))) {
				k2 -= cont*(long)(Math.pow(10, cont)-Math.pow(10, cont-1));
				cont++;
			}
			pos = (int)(k2%cont);
			k2 /= cont;
			k2 += (long)Math.pow(10, cont-1);
			out = String.valueOf(k2);
			System.out.println(out.charAt(pos));
		}	
	}
	
	/*public static String getString(int number) {
		int contador = 1;
		String salida = "";
		while(salida.length() <= number) {
			salida += contador;
			contador++;
		}
		return salida.substring(0, number);
	}*/
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            long st = 1, en = n, ans = 0, len = 0;
            while (st <= en) {
                long mid = (st + en) / 2;
                long have = 0;
                int curLen = Long.toString(mid).length();
                long bef = 0;
                for (int i = 1; i < curLen; i++) {
                    long cur = 0;
                    for (int j = 1; j <= i; j++) {
                        cur *= 10;
                        cur += 9;
                    }
                    have += i * (cur - bef);
                    bef = cur;
                }
                have += curLen * (mid - bef);
                if (have < n) {
                    ans = mid;
                    len = have;
                    st = mid + 1;
                } else
                    en = mid - 1;
            }
            String s = Long.toString(ans + 1);
            for (int i = 0; i < s.length(); i++) {
                if (len + i + 1 == n) {
                    out.print(s.charAt(i));
                    return;
                }
            }
        }

    }
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn

import java.util.Scanner;

public class Training {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long index = in.nextLong();
        if (index < 10) {
            //one digit
            System.out.println(index);
        } else if (index < 190) {
            //two digits
            solve(2, index, 10, 10);

        } else if (index < 2890) {
            //three digits 
            solve(3, index, 190, 100);

        } else if (index < 38890) {
            //four digits 
            solve(4, index, 2890, 1000);

            //start changing ------------------------------------------------------------
        } else if (index < 488890) {
            //five digits 
            solve(5, index, 38890, 10000);

        } else if (index < 5888890) {
            //six digits 
            solve(6, index, 488890, 100000);

        } else if (index < 68888890) {
            //seven digits 
            solve(7, index, 5888890, 1000000);

        } else if (index < 788888890) {
            //eight digits 
            solve(8, index, 68888890, 10000000);

        } else if (index < 8888888890l) {
            //nign digits 
            solve(9, index, 788888890, 100000000);

        } else if (index < 98888888890l) {
            //ten digits 
            solve(10, index, 8888888890l, 1000000000);

        } else {
            solve(11, index, 98888888890l, 10000000000l);

        }

    }

    static void solve(int length, long index, long lastPoint, long num) {
        String s = "";
        num += (index - lastPoint) / length;
        s += num;
        int mod = (int) ((index - lastPoint) % length);
        System.out.println(s.charAt(mod));
    }

}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn

import java.util.*;
import java.io.*;


public class DigitSequenceA {
    public static void main(String[] args) throws IOException{
        FastReader in = new FastReader();
        double digit = in.nextDouble();
        double temp = digit;
        long[] seq = new long[13];
        for(int i = 1; i<13; i++){
            seq[i] = (9* (long)Math.pow(10,i-1)) * (i) +seq[i-1];
        }
        int power = 0;
        for(int i = 0; i< 13; i++){
            if(temp-seq[i] >0){
                continue;
            }
            else{
                power = i;
                break;
            }
        }
        long place = (long) Math.ceil(digit - seq[power-1]);
        place = (long)Math.ceil(place/power);
        if((digit - seq[power-1])%power>0){
            place++;
        }

        long num = (long) (place + Math.pow(10,power-1)-1);
        String num2 = Long.toString(num);
        long end =  seq[power-1] + place*power;
        long answer = (long)(power-(end - digit));
        //System.out.println("Digit is at the " + power + " power");
        //System.out.println("Digit is at the " + place + " number of the sequence");
        //System.out.println("Number is " + num);
        //System.out.println("Digit is at the " + answer+  " in that number");
        //System.out.println("Answer is " + num2.charAt((int)answer-1));
        System.out.println(num2.charAt((int)answer-1));

    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn

import java.io.*;
import java.util.Scanner;
public class Test {
	public static int digit(long number){
		int i = 1;
		long exp = 1;
		while(number > i * 9 * exp){
			number -= i * 9 * exp;
			i++;
			exp *= 10;
		}
		return i;
	}
	public static int result(long number){
		int digit = digit(number);
		long exp = 1;
		for(int i = 0; i < (digit - 1); i++){
			number -= (i+1) * 9 * exp;
			exp *= 10;
		}
		long b = number / digit;
		int c = (int)(number % digit);
		if(c > 0){
			String d = Long.toString(exp + b);
			return d.charAt(c - 1) - '0';
		}
		else{
			String d = Long.toString(exp + b - 1);
			return d.charAt(d.length() - 1) - '0';
		}

	}
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		long k = input.nextLong();
		System.out.println(result(k));
	}
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.util.Scanner;

public class cf_contest_1177_problem_B {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        long k = s.nextLong();
        if (k<=9)
            System.out.println(k);
        else
        {

            int c = 1;
            while(k>c*((Math.pow(10,c)) - Math.pow(10,c-1)))
            {
                k-=c*((Math.pow(10,c)) - Math.pow(10,c-1));
//                System.out.println(k + " hello " + c);
                c++;
            }
//            System.out.println("k is " + k);
            long mo = k%c;

//            System.out.println("mo is " + mo);
            k = k/c;

            if (mo == 0) {
                mo = c;
                k--;
            }
            mo--;
//            k = Math.max(k-1,0);
//            System.out.println("k/c is " + k);
            long j = (long) (Math.pow(10,c-1) + k);

            String j1 = "" + j;
//            System.out.println("j1 is " + j1);
//            System.out.println("final ans= " + j1.charAt((int)mo));
//            System.out.println();
            System.out.println(j1.charAt((int)mo));
        }

    }
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.util.Scanner;

public class DigitalSequence {

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

    public static void main(String[] args) {
        long k = new Scanner(System.in).nextLong();
        long i = 1,t=0, c = 9,digits = 0,l=0,k2=k;
        while(t<k){
            l = t;
            t += i*c;
            i++;
            c*=10;
            digits++;
        }
        k = k-l;
        long lastNumber = (long)Math.pow(10,digits-1)-1;
        long p = k/digits,q=k%digits;
        long finalNumber =lastNumber+p;
        if(q!=0){
            finalNumber++;
        }
            k = k-digits*p;
            if(k<=0)
                k+=digits;
        String ans = ""+finalNumber;
        int index = (int)(k-1);
        print(""+ans.charAt(index));
    }   
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class DigitSeq {

	static class FastReader { 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException  e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

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

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

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

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}

	public static void main(String[] args) {

		FastReader sc = new FastReader();
		OutputStream outputstream = System.out;
		PrintWriter out = new PrintWriter(outputstream);

		long n = sc.nextLong();
		long[] arr = new long[14];
		for(int i = 1; i <= 13; i++){
			arr[i] = (long)Math.pow(10, i)-(long)Math.pow(10, i-1);
		}
		long total = 0;
		/*for(int i = 1; i <= 13; i++) out.print(arr[i] + " ");
		out.println();*/
		for(int i = 1; i <= 13; i++){
			if(total+(long)i*arr[i]>=n){
				long ans = n-total;
				long rest = ans;
				//System.out.println(rest);
				if(ans%i!=0){
					ans /= i;
					ans++;
				} else {
					ans /= i;
				}
				ans += (long)Math.pow(10, i-1)-1;
				String str = Long.toString(ans);
				int ind = (rest%i==0) ? i-1 : (int)(rest%i)-1;
				//System.out.println(ind);
				out.println(str.charAt(ind));
				break;
			}
			total = total+(long)i*arr[i];
			//System.out.println(total);
		}
		out.close();
	}

}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class A {
    void solve(){
        long k = readLong();

       long x = 9;
       long y = 1;
       while(k > x * y){
           k -= x * y;
           x *= 10;
           y++;
       }


       long w = k / y + (k % y == 0 ? 0 : 1);
       long e = (k % y - 1 % y + y) % y;

       long num = x/9 + w - 1;
       String s = Long.toString(num);
       out.print(s.charAt((int) e) - '0');
    }

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

    void run(){
        init();
        solve();
        out.close();
    }

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok = new StringTokenizer("");

    void init(){
        in = new BufferedReader(new InputStreamReader(System.in));
        out  = new PrintWriter(System.out);
    }

    String readLine(){
        try{
            return in.readLine();
        }catch(Exception ex){
            throw new RuntimeException(ex);
        }
    }
    String readString(){
        while(!tok.hasMoreTokens()){
            String nextLine = readLine();
            if(nextLine == null) return null;
            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

    int readInt(){
        return Integer.parseInt(readString());
    }

    long readLong(){
        return Long.parseLong(readString());
    }

    double readDouble(){
        return Double.parseDouble(readString());
    }
}
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
//package test_1177a;

import java.util.Scanner;


import java.util.Scanner;

    public class test1177b{
        public  static  void main(String[] args){
            Scanner sc = new Scanner(System.in);
            long k =  sc.nextLong();
            long k1 =0,k2 = 0;
            long p = 1;
            String str="";
            for (int i=1; i<=12;i++){
                if (k>= k1 && k <= k1 + p * 9 *i){
                    // Нашли порядок
                    long kk = ((k - k1) % i);

                    k2 = p  + (k - k1) / i -1;
                    if (kk != 0) k2 ++;
                    str =""+ k2;
                    if(str.length() > i) {
                        k2--;
                        str =""+ k2;
                        kk =0;
                    }
                    if(kk > 0){
                        System.out.println(str.charAt((int)kk-1));
                    }else{
                        System.out.println(str.charAt(i-1));
                    }
                    break;
                }else {
                    k1 += p * 9 *i;
                    p = p * 10;
                }
            }

        }
    }
// Problem: 1177_B. Digits Sequence (Hard Edition)
// Time complexity: logn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class CodeForces1177B {
	
	public static char custBinSearch(long lower, long upper, long lowIndex, int ten, long position) {
		long half = Math.round((lower + upper) / 2.0);
		
		long lowBound = lowIndex + (half - lower)*(ten + 1);
		long upBound = lowBound + ten;
		
		if(position < lowBound) { //Less than the lowest index of half
			return custBinSearch(lower, half - 1, lowIndex, ten, position);
			
		} else if (position > upBound) { //Remember to update lowIndex here.
			lowIndex += (half + 1 - lower)*(ten + 1);
			return custBinSearch(half + 1, upper, lowIndex, ten, position);
			
		} else {
			return Long.toString(half).charAt((int) (position - lowBound)); //The final number will at max be 11 characters long, thus it is safe to convert and cast.
			
		}
		
	}
	
	public static void main(String[] args) throws IOException  {
		BufferedReader inputs = new BufferedReader(new InputStreamReader(System.in));
		
		long indexPosition = Long.parseLong(inputs.readLine());
		
		inputs.close();
		
		//Isolate possible combinations so that all further numbers will have the same length.
		int tenFactor = 0;
		long lowerBound = 1;
		long upperBound = (long) (Math.pow(10, 12));
		long lowerIndexBound = 1;
		long redIndex = 0;
		redIndex += indexPosition;
		
		while(redIndex > 0) {
			redIndex -= (long) (9*Math.pow(10, tenFactor)*(tenFactor + 1));
			if(redIndex <= 0) { //Stage 1: Completed Successfully.
				lowerBound = (long) (Math.pow(10, tenFactor));
				upperBound = (long) (Math.pow(10, tenFactor + 1) - 1);
				break;
			}
			
			lowerIndexBound += (long) (9*Math.pow(10, tenFactor)*(tenFactor + 1));
			tenFactor++;
			
		}
		
		System.out.println(custBinSearch(lowerBound, upperBound, lowerIndexBound, tenFactor, indexPosition));
		
	}
}