// Arup Guha
// 9/14/2026
// Some one dimensional array examples

import java.util.*;

public class Array1DExamples {

	public static void main(String[] args) {
		example4();
	}
	
	public static void example1() {
	
		// Get # of numbers to enter.
		Scanner stdin = new Scanner(System.in);
		System.out.println("How many numbers to enter?");
		int n = stdin.nextInt();
		
		// Allocate my array.
		int[] nums = new int[n];
	
		// Read array.
		System.out.println("Please enter the values.");
		for (int i=0; i<n; i++)
			nums[i] = stdin.nextInt();
			
		// Print in reverse order.
		printRev(nums);
		
		// Print regular.
		print(nums);
		
		// Actually change the array and print again.
		reverseArray(nums);
		print(nums);
	}
	
	// Prints the array arr in order from index 0 to index arr.length-1.
	public static void print(int[] arr) {
	
		for (int i=0; i<arr.length; i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
	// Prints the array arr in order from index 0 to index arr.length-1.
	public static void printRev(int[] arr) {
	
		for (int i=arr.length-1; i>=0; i--)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
	public static void reverseArray(int[] arr) {
		
		// To make easier to read.
		int n = arr.length;
		
		for (int i=0; i<n/2; i++) {
			int tmp = arr[i];
			arr[i] = arr[n-1-i];
			arr[n-1-i] = tmp;
		}
	}
	
	public static void example2() {
		
		// Read in the whole line.
		Scanner stdin = new Scanner(System.in);
		System.out.println("Enter all prizes on one line, separated by commas.");
		String line = stdin.nextLine();
		
		// Create a StringTokenizer object.
		StringTokenizer tok = new StringTokenizer(line, ",");
		
		// Make String array.
		int n = tok.countTokens();
		String[] choices = new String[n];
		for (int i=0; i<n; i++)
			choices[i] = tok.nextToken();
		
		// To convert a token from string to integer do Integer.parseInt(tok.nextToken());
		// For doubles do Double.parseDouble(tok.nextToken())
		
		// Pick a random index into the choices array.
		Random r = new Random();
		int prize = r.nextInt(n);
		
		System.out.println("You won "+choices[prize]+"!");
		
		// Now run a simulation with 100 prizes.
		int[] win = new int[n];
		for (int i=0; i<1000000; i++)
			win[r.nextInt(n)]++;
		
		// Print out the results.
		for (int i=0; i<n; i++)
			System.out.println(choices[i]+"\t"+win[i]);

	}
	
	public static void example3() {
		
		// Get the data.
		int[] data = getData();
		
		double avg = getAverage(data);
		double stdev = getStdDev(data);
		System.out.println("Avg = "+avg+" Standard Deviation = "+stdev);
		
		double[] myZvals = returnZValues(data);
		for (int i=0; i<data.length; i++)
			System.out.println(data[i]+"\t"+myZvals[i]);
	}
	
	public static int[] getData() {
		
		Scanner stdin = new Scanner(System.in);
		System.out.println("How many data values?");
		int n = stdin.nextInt();
		
		// Allocate space, read in values.
		int[] data = new int[n];
		System.out.println("Enter each value, separated by spaces.");
		for (int i=0; i<n; i++)
			data[i] = stdin.nextInt();
		
		// Return data.
		return data;
	}
	
	// Returns the average of the values in arr.
	public static double getAverage(int[] arr) {
		double sum = 0;
		for (int x: arr)
			sum += x;
		return sum/arr.length;
	}
	
	public static double getStdDev(int[] arr) {
		
		// We need this first.
		double avg = getAverage(arr);
		
		// Numerator of variance formula.
		double sum = 0;
		for (int x: arr)
			sum += Math.pow(x-avg, 2);
		
		// This is variance.
		return Math.sqrt(sum/arr.length);
	}
	
	// Returns the corresponding Z-values for data, assumi
	public static double[] returnZValues(int[] data) {
		
		// We need these.
		double avg = getAverage(data);
		double stddev = getStdDev(data);
		
		// Store answers here.
		double[] zvals = new double[data.length];
		for (int i=0; i<data.length; i++)
			zvals[i] = (data[i]-avg)/stddev;
		
		return zvals;
	}
	
	public static void example4() {
		
		// This is more efficient than String because it's mutable.
		StringBuffer sb = new StringBuffer();
		
		Scanner stdin = new Scanner(System.in);
		
		// Reads in all the tokens.
		while (stdin.hasNext()) {
			String tmp = stdin.next();
			sb.append(tmp);
		}
		
		// Get the letter frequencies.
		String finalStr = new String(sb);
		int[] freq = getFreq(finalStr);
		
		// Prints frequency chart.
		for (int i=0; i<26; i++)
			System.out.println( ((char)('a'+i))+"\t"+freq[i]);
		
	}
	
	// Returns frequency array of all letters in the String object
	// passed to this function.
	public static int[] getFreq(String text) {
		
		// Create array initialized to 0s for all letter counts.
		int[] freq = new int[26];
		
		// Make this all lowercase, to make my life easier.
		text = text.toLowerCase();
		
		for (int i=0; i<text.length(); i++) {
			
			// Skip non letters.
			if (text.charAt(i)<'a' || text.charAt(i)>'z')
				continue;
			
			// Add 1 to the count for this letter.
			freq[text.charAt(i)-'a']++;
		}
		
		// return the frequency array.
		return freq;
	}
}