codeparrot/codecomplex huggingface dataset:
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class RoundOneProblemB {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
				
		int n=1;
		
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in), 50);
		
		try {
			
			n = Integer.valueOf(input.readLine());
			
			if (! ((1 <= n) && (n <= Math.pow(10, 5)))) {
				formatError();
			}
			
			Pattern typeOne = Pattern.compile("^([A-Z]+)([0-9]+)$");
			Pattern typeTwo = Pattern.compile("^R([0-9]+)C([0-9]+)$");
			for (int i=0; i < n; i++) {
				String line = input.readLine();
				Matcher matchOne = typeOne.matcher(line);
				if (matchOne.find()) {
					System.out.println(convertOneToTwo(matchOne.group(2), matchOne.group(1)));
				} else {
					Matcher matchTwo = typeTwo.matcher(line);
					if (matchTwo.find()) {
						System.out.println(convertTwoToOne(matchTwo.group(1), matchTwo.group(2)));
					}
				}
			}
						
		} catch (Exception e) {
			formatError();		
		} 
		
	}
	
	private static String convertTwoToOne(String row, String col) {
		StringBuilder result = new StringBuilder();
		
		long c = Long.parseLong(col);
		while ( c > 0) {
			result.append((char)(((c-1) % 26)+'A'));
			c = (c-1) / 26;
		} 
		result.reverse();
		result.append(Long.parseLong(row));
		
		return result.toString();
	}
	
	private static String convertOneToTwo(String row, String col) {
		StringBuilder result = new StringBuilder();
		
		int l = col.length();
		col = col.toUpperCase();
		
		long base = 1;
		long c = 0;
		for (int i=l-1; i >= 0; i--) {
			c = c + ((col.charAt(i) - 'A' + 1) * base);
			base = base * 26;
		}
		
		result.append("R").append(Long.parseLong(row)).append("C").append(c);
		return result.toString();
	}
	
	/**
	 * Exit with an error due to unexpected standard input. 
	 */
	private static void formatError() {
		System.out.println("Unexpected input");
		System.exit(1);	
	}

}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.*;
import java.util.*;

public class Elektronnietablici {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer in;
	static PrintWriter out = new PrintWriter(System.out);
	
	public static String nextToken() throws IOException{
		while (in == null || !in.hasMoreTokens()){
			in = new StringTokenizer(br.readLine());
		}
		
		return in.nextToken();
	}
	
	public static int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	
	public static double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	
	public static void main(String[] args) throws IOException{
		int n = nextInt();
		
		String S;
		for (int i = 0; i < n; i++) {
			S = nextToken();
			
			int f = 0;
			if (S.charAt(0) == 'R' && S.charAt(1) >= '1' && S.charAt(1) <= '9'){
				for (int j = 2; j < S.length(); j++) {
					if (S.charAt(j) >= 'A' && S.charAt(j) <= 'Z'){
						f = 1;
						break;
					}
				}
			}
			
			if (f == 0){
				String T1 = "";
				String ans = "R";
				
				int j;
				
				for (j = 0; S.charAt(j) >= 'A' && S.charAt(j) <= 'Z'; j++) {
					T1 += S.charAt(j);
				}
				
				ans += S.substring(j, S.length()) + "C";
				
				int len = j;
				
				j--;
				
				int p = 1;
				int z = 0;
				for (;  j >= 0; j--) {
					z += (S.charAt(j) - 'A') * p;
					p *= 26;
				}
				
				p = 1;
				for (int k = 0; k < len; k++) {
					z += p;
					p *= 26;
				}
				
				ans += z;
				
				out.println(ans);
			}
			else{
				String T1 = "";
				String ans = "";
				
				int j;
				for (j = 1; S.charAt(j) != 'C'; j++) {
					ans += S.charAt(j);
				}
				
				T1 = S.substring(j + 1, S.length());
				int z = Integer.parseInt(T1);
				int p = 1;
				int len = 0;
				
				while (p <= z){
					z -= p;
					p *= 26;
					len++;
				}
				p /= 26;
				
				T1 = "";
				
				for (int k = len - 1; k >= 0; k--) {
					int l = z / p;
					
					T1 += (char)(z / p + 'A');
					
					z -= l * p;
					
					p /= 26;	
				}
				ans = T1 + ans;
				
				out.println(ans);
			}
		}
		
		//2
		//R23C55
		//BC23
		
		out.close();
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.Scanner;
public class MSpreadSheet {
    
    public int toNum(String x)
    {
        int result = 0;
        int pow = 0;
        for (int i = x.length()-1; i >=0; i--)
        {
            result+=(x.charAt(i)-'A'+1)*Math.pow(26, pow);
            pow++;
        }
        return result;
    }
    
    public String toString(int x)
    {
        if(x<=26) return String.valueOf((char)(x+'A'-1));
        String result = "";
        while(x!=0)
        {
            if(x%26==0) 
            {
                result = 'Z' + result;
                x = x/26 - 1;
            }
            else
            {
                result = (char)((x%26)+'A'-1) + result;
                x = x/26;
            }           
        }
        return result;
    }
    
    public  boolean check(String x)
    {
        if(x.charAt(0)!='R') return false;  //first rep
        int in = x.indexOf('C');
        if(in==-1) return false;
        if(Character.isDigit(x.charAt(in-1))&&Character.isDigit(x.charAt(in+1))) return true;
        return false;
    }
    
    public void solve(String x)
    {
        String r="";
        String c="";
        if(check(x))
        {
            int in = x.indexOf('C');
            r = x.substring(1,in);
            c = x.substring(in+1);
            System.out.println(toString(Integer.parseInt(c))+r);
        }
        else
        {
            int i =0;
            while(!Character.isDigit(x.charAt(i)))
                    c+=x.charAt(i++);
            while(i<x.length())
                r+=x.charAt(i++);
            System.out.println("R"+r+"C"+toNum(c));
        }
    }
    
    public static void main(String[] args) {
        MSpreadSheet sh = new MSpreadSheet();
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int i = 0;
        while(i<n)
        {
            sh.solve(s.next());
            i++;
        }
    }

}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.*;
import java.io.*;

public class Solution extends Thread {

	final static int MAXNUM = 1 << 20;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer("");
			int tests = nextInt();
			int num = 1;
			for (int test = 0; test < tests; test++) {
				String s = next();
				if (s.charAt(0) == 'R' && s.charAt(1) >= '0' && s.charAt(1) <= '9' && s.indexOf('C') != -1) {
					String[] sp = s.split("[RC]");
					int r = Integer.parseInt(sp[1]);
					int c = Integer.parseInt(sp[2]);
					s = "";
					while (c > 0) {
						if (c % 26 == 0) {
							s = 'Z' + s;
							c /= 26;
							c --;
						} else {
							s = (char)('A' + c % 26 - 1) + s;
							c /= 26;
						}
					}
					s = s + r;
				} else {
					int pos = 0;
					while (s.charAt(pos) < '0' || s.charAt(pos) > '9') {
						pos ++;
					}
					int r = Integer.parseInt(s.substring(pos));
					int c = 0;
					s = s.substring(0, pos);
					for (int i = 0; i < s.length(); i++) {
						if (s.charAt(i) < 'Z') {
							c = c * 26 + (s.charAt(i) - 'A' + 1);
						} else {
							c = c * 26 + 26;
						}
					}
					s = "R" + r + "C" + c;
				}
				System.out.println(s);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			System.exit(-1);
		}
	}
	
	String next() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

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

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

	BufferedReader in;
	StringTokenizer st;

	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new Thread(new Solution()).start();
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.*;

public class B {
    public static void main (String[] args) throws IOException {
        BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(b.readLine());
        while (n-- > 0) {
            String s = b.readLine();
            if (s.matches("^[A-Z]+[0-9]+$")) {
                System.out.println(toRC(decodeCR(s)));
            } else {
                System.out.println(toCR(decodeRC(s)));
            }
        }
    }
    private static String toRC(int[] a) {
        return "R" + a[0] + "C" + a[1];
    }
    private static String toCR(int[] a) {
        String r = "";
        if (a[1] == 1) {
            r = "A";
        } else {
            for (int x = a[1]; x > 0; x /= 26) {
                r = (char)('A' + (x - 1) % 26) + r;
                if (x % 26 == 0) x -= 26;
            }
        }
        return r + a[0];
    }
    private static int[] decodeCR(String s) {
        int[] a = new int[2];
        int i = 0;
        while (s.charAt(i) >= 'A') {
            a[1] = a[1] * 26 + (s.charAt(i) - 'A' + 1);
            i++;
        }
        a[0] = Integer.parseInt(s.substring(i));
        // System.out.println("decoding CR: " + s + "..." + a[0] + ", " + a[1]);
        return a;
    }
    private static int[] decodeRC(String s) {
        assert s.charAt(0) == 'R';
        int[] a = new int[2];
        a[0] = Integer.parseInt(s.substring(1, s.indexOf('C')));
        a[1] = Integer.parseInt(s.substring(s.indexOf('C') + 1));
        // System.out.println("decoding RC: " + s + "..." + a[0] + ", " + a[1]);
        return a;
    }
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class B1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int testCount = in.nextInt();
        for (int test = 0; test < testCount; test++) {
            String src = in.next();
            if (src.matches("^R\\d+C\\d+$")) {
                Pattern p = Pattern.compile("\\d+");
                Matcher m = p.matcher(src);
                m.find();
                int r = Integer.parseInt(m.group(0));
                m.find();
                int c = Integer.parseInt(m.group(0));
                System.out.println(toBase26(c) + r);
            } else {
                Pattern p = Pattern.compile("[A-Z]+");
                Matcher m = p.matcher(src);
                m.find();
                String c = m.group(0);
                p = Pattern.compile("\\d+");
                m = p.matcher(src);
                m.find();
                int r = Integer.parseInt(m.group(0));
                System.out.println("R" + r + "C" + toBase10(c));
            }
        }
    }
    private static String toBase26(int n) {
        String res = "";
        do {
            n -= 1;
            res = (char)('A' + (n % 26)) + res;
            n /= 26;            
        } while (n > 0);
        return res;
    }
    private static int toBase10(String x) {
        int n = 0;
        char[] digits = x.toCharArray();
        for (int i = 0; i < digits.length; i++) {
            n *= 26;
            n += digits[i] - 'A' + 1;
        }
        return n;
    }
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Task1b {

	static int[] fromRC (String data) {
		int pos = data.indexOf('C');
		int res[] = new int[2];
		res[0] = Integer.parseInt(data.substring(1, pos));
		res[1] = Integer.parseInt(data.substring(pos + 1));
		return res;
	}
	
	static int[] fromXC (String data) {
		int pos = 0;
		int res[] = new int[2];
		res[0] = res[1] = 0;
		while (data.charAt(pos) >= 'A' && data.charAt(pos) <= 'Z') {
			res[1] *= 26;
			res[1]++;
			res[1] += data.charAt(pos) - 'A';
			pos++;
		}
		res[0] = Integer.parseInt(data.substring(pos));
		return res;
	}
	
	static String toRC (int[] data) {
		return String.format("R%dC%d", data[0], data[1]);
	}
	
	static String toXC (int[] data) {
		StringBuilder sb = new StringBuilder();
		while (data[1] > 0) {
			data[1]--;
			sb.append((char)('A' + data[1] % 26));
			data[1] /= 26;
		}
		sb = sb.reverse();
		sb.append(data[0]);
		return sb.toString();
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			if ((s.charAt(0) == 'R') && 
				(s.charAt(1) >= '0' && s.charAt(1) <= '9') &&
				(s.indexOf('C') != -1)) {
				
				System.out.println(toXC(fromRC(s)));
			} else {
				System.out.println(toRC(fromXC(s)));
			}
		}
	}

}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
// by kotb
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class SpreadSheet {

    public void run() {
        try {
            Scanner s = new Scanner(System.in);
            int tests = s.nextInt();
            for (int i = 0; i < tests; i++) {
                String line = s.next();
                String regex = "R[\\d]+C[\\d]+";
                Pattern pattern = Pattern.compile(regex);
                Matcher matcher = pattern.matcher(line);
                
                if (matcher.matches()){
                    int r = Integer.parseInt(line.substring(1, line.indexOf("C")));
                    int c = Integer.parseInt(line.substring(line.indexOf("C") +1));
                    System.out.println(toFormula(r, c));
                }
                else {
                    int index = -1;
                    for (int j = 0; j < line.length(); j++) {
                        if (line.charAt(j) >= '0' && line.charAt(j) <= '9') {
                            index = j;
                            break;
                        }
                    }
                    String c = line.substring(0, index);
                    int r = Integer.parseInt(line.substring(index));
                    System.out.println(fromFormula(c, r));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    private String toFormula(int r, int c) {
        StringBuffer buff = new StringBuffer();
        char ch;
        while (c != 0) {
            int m = c%26;
            if(m==0)
            {
                ch = 'Z';
                c = c/26 - 1;
            }
            else
            {
                ch = (char)(m+'A'-1);
                c /= 26;
            }
            buff.append(ch);            
        }
        return buff.reverse().toString() + r;
    }
    
    private String fromFormula(String c, int r) {
        int ret = 0;
        int power = 1;
        for (int i = c.length()-1; i >= 0; i--) {
            ret += ((c.charAt(i) - 'A' + 1) * power);
            power *= 26;
        }
        return "R" + r + "C" + ret;
    }
    
    public static void main(String[] args) {
        new SpreadSheet().run();
    }
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {

	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
				System.in)));
		int nc = sc.nextInt();
		while (nc-- > 0) {
			String s = sc.next();
			StringTokenizer st = new StringTokenizer(s, "0123456789");
			if (st.countTokens() > 1) {
				int k = s.indexOf('C');
				int r = Integer.parseInt(s.substring(1, k));
				int c = Integer.parseInt(s.substring(k + 1));
				int len = 1;
				int p = 26;
				while (c > p) {
					c -= p;
					len++;
					p *= 26;
				}
				String col = Integer.toString(--c, 26).toUpperCase();
				while (col.length() < len)
					col = "0" + col;
				StringBuilder sb = new StringBuilder();
				for (int i = 0; i < col.length(); i++) {
					if (col.charAt(i) < 'A') {
						sb.append((char) (col.charAt(i) - '0' + 'A'));
					} else {
						sb.append((char) (col.charAt(i) + 10));
					}
				}
				System.out.printf("%s%d\n", sb.toString(), r);
			} else {
				int k = 0;
				while (s.charAt(k) > '9')
					k++;
				char[] col = s.substring(0, k).toCharArray();
				int r = Integer.parseInt(s.substring(k));
				int c = 1;
				int p = 26;
				int cnt = 1;
				while (cnt++ < col.length) {
					c += p;
					p *= 26;
				}
				StringBuilder sb = new StringBuilder();
				for (int i = 0; i < col.length; i++) {
					if (s.charAt(i) < 'K') {
						sb.append((char) ('0' + col[i] - 'A'));
					} else {
						sb.append((char) (col[i] - 10));
					}
				}
				c += Integer.parseInt(sb.toString(), 26);
				System.out.printf("R%dC%d\n", r, c);
			}
		}
		System.out.close();
	}

}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class SpreadSheet {

	public void run() {
		try {
			Scanner s = new Scanner(System.in);
			int tests = s.nextInt();
			for (int i = 0; i < tests; i++) {
				String line = s.next();
				String regex = "R[\\d]+C[\\d]+";
				Pattern pattern = Pattern.compile(regex);
				Matcher matcher = pattern.matcher(line);
				
				if (matcher.matches()){
					int r = Integer.parseInt(line.substring(1, line.indexOf("C")));
					int c = Integer.parseInt(line.substring(line.indexOf("C") +1));
					System.out.println(toFormula(r, c));
				}
				else {
					int index = -1;
					for (int j = 0; j < line.length(); j++) {
						if (line.charAt(j) >= '0' && line.charAt(j) <= '9') {
							index = j;
							break;
						}
					}
					String c = line.substring(0, index);
					int r = Integer.parseInt(line.substring(index));
					System.out.println(fromFormula(c, r));
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private String toFormula(int r, int c) {
		 StringBuffer buff = new StringBuffer();
               char ch;
               while (c != 0) {
                       int m = c%26;
                       if(m==0)
                       {
                               ch = 'Z';
                               c = c/26 - 1;
                       }
                       else
                        {
                               ch = (char)(m+'A'-1);
                               c /= 26;
                       }
                       buff.append(ch);                        
               }
               return buff.reverse().toString() + r;
	
	
//		String ret = "";
//		StringBuffer buff = new StringBuffer();
//		while (c != 0) {
//			int m = c%26;
//			char ch = (char)(m+'A'-1);
//			buff.append(ch);
//			c /= 26;
//		}
//		return buff.reverse().toString() + r;
	}
	
	private String fromFormula(String c, int r) {
		int ret = 0;
		int power = 1;
		for (int i = c.length()-1; i >= 0; i--) {
			ret += ((c.charAt(i) - 'A' + 1) * power);
			power *= 26;
		}
		return "R" + r + "C" + ret;
	}
	
	public static void main(String[] args) {
		new SpreadSheet().run();
	}
}
// Problem: 701_C. They Are Everywhere
// Time complexity: linear
import java.io.*;
import java.util.*;

/*
 * And now I wonder if I should delete these comments cause they might throw me off. 
 * Lol who cares though?
 */

public class R364C {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner s = new Scanner(System.in);
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		int n = Integer.parseInt(f.readLine());
		char[] a = f.readLine().toCharArray();
		int difTypes = 0;
		TreeSet<Character> types = new TreeSet<Character>();
		for(int i = 0; i < n; i++) {
			if(!types.contains(a[i])) {
				types.add(a[i]);
			}
		}
		int i = 0, j = 0;
		difTypes = types.size();
		int curTypes = 0;
		int min = Integer.MAX_VALUE;
		TreeSet<Character> has = new TreeSet<Character>();
		HashMap<Character, Integer> freq = new HashMap<Character, Integer>();
		while(i < n && j < n) {
//			System.out.println(i + " " + j);
			has.add(a[j]);
			if(!freq.containsKey(a[j])) {
				freq.put(a[j], 1);
			} else {
				freq.put(a[j], freq.get(a[j])+1);
			}
			j++;
			curTypes = has.size();
			if(curTypes == difTypes) min = Math.min(min, j-i);
//			System.out.println(freq.toString());
//			System.out.println(curTypes);
//			System.out.println();
			while(i < n && has.size() == difTypes) {
				int Freq = freq.get(a[i]);
//				System.out.println(Freq);
				if(Freq - 1 == 0) {
					has.remove(a[i]);
					freq.put(a[i], freq.get(a[i])-1);
					i++;
					break;
				}
				freq.put(a[i], freq.get(a[i])-1);
				i++;
				if(curTypes == difTypes) min = Math.min(min, j-i);
			}
			curTypes = has.size();
		}
//		if(curTypes == difTypes) min = Math.min(min, j-i);
		System.out.println(min);
	}
}
// Problem: 701_C. They Are Everywhere
// Time complexity: linear
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;


public class C364 {
	static HashMap<Character, Integer> freq;
	static int unique = 0;
	public static void main(String[] args) throws Exception {
		FastScanner in = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int n = in.nextInt();
		char[] s = in.next().toCharArray();
		freq = new HashMap<Character, Integer>();
		for(int i = 0; i < n; i++) {
			char c = s[i];
			if(!freq.containsKey(c))
				freq.put(c, 0);
		}
		
		int k = freq.size();
		int l = 0, r = 0, best = n;
		inc(s[0]);
		
		while(r < n) {
			if(unique == k) { // got all, move left
				best = Math.min(best, r+1-l);
				dec(s[l++]);
			}
			else { // advance r
				if(++r == n)
					break;
				inc(s[r]);
			}
		}
		
		pw.println(best);
		
		pw.flush();
		pw.close();
	}
	
	static void inc(char c) {
		int cur = freq.get(c);
		if(cur == 0)
			unique++;
		freq.put(c, cur+1);
	}
	
	static void dec(char c) {
		int cur = freq.get(c);
		if(cur == 1)
			unique--;
		freq.put(c, cur-1);
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer("");
		}
		
		String next() throws Exception {
			while(!st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		
		int nextInt() throws Exception {
			return Integer.parseInt(next());
		}
	}
}
// Problem: 701_C. They Are Everywhere
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

/**
 * @author Ran Bi (ran.bi@addepar.com)
 */
public class C {

  public static void main(String[] arg) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.valueOf(in.readLine());
    char[] s = in.readLine().toCharArray();
    int i = 0, j = 0;
    int[] ct = new int[256];
    Set<Character> all = new HashSet<>();
    for (char c : s) {
      all.add(c);
    }
    int total = 0, res = Integer.MAX_VALUE;
    while (j < s.length) {
      while (total < all.size() && j < s.length) {
        if (ct[s[j]] == 0) {
          total++;
        }
        ct[s[j]]++;
        j++;
      }
      res = Math.min(res, j - i);
      while (total == all.size() && i < s.length) {
        ct[s[i]]--;
        if (ct[s[i]] == 0) {
          total--;
        }
        i++;
        if (total == all.size()) {
          res = Math.min(res, j - i);
        }
      }
    }
    System.out.println(res);
  }
}