codeparrot/codecomplex huggingface dataset:
// Problem: 1197_A. DIY Wooden Ladder
// Time complexity: linear
 import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
import java.math.BigInteger.*;
import java.util.Arrays; 

public class   CF111111
{
  BufferedReader in;
  StringTokenizer as;
  int nums[],nums2[];
  int[] nums1[];
  boolean con = true;
 
  ArrayList < Integer >  ar = new ArrayList < Integer >();
  ArrayList < Integer >  fi = new ArrayList < Integer >();
  Map<Integer,Integer > map = new HashMap<Integer, Integer>();
  public static void main (String[] args)
  {
    new CF111111  ();
  }
  
  public int GCD(int a, int b) {
    if (b==0) return a;
    return GCD(b,a%b);
  }
  
  public int LIS(int arr[])
  {
    int n = arr.length;
    int sun[] = new int [n];
    int cur = 0;
    for(int x = 0;x<n;x++)
    {
      int temp = Arrays.binarySearch(sun,0,cur,arr[x]);
      if(temp < 0)
        temp = -temp -1;
      sun[temp] = arr[x];
      if(temp == cur)
        cur++;
    }
    return cur;
    
  }
  
  
  
  
  public CF111111  ()
  {
    try
    {
      
      in = new BufferedReader (new InputStreamReader (System.in));
      int a = nextInt();
      for(int xx1 = 0;xx1<a;xx1++)
      {
        int b = nextInt();
        nums = new int [b];
        for(int x = 0;x<b;x++)
        {
          nums[x] = nextInt();
        }
         int max = 0;
         int max2 = -1;
         for(int x = 0;x<b;x++)
         {
           if(nums[x] >= max)
           {
             max2 = max;
             max = nums[x];
           }
           else if(nums[x] >= max2)
             max2 = nums[x];
         }
        System.out.println(Math.min(max2, b-1)-1);
      }
    }
    catch(IOException e)
    {

    }
  }
  
  
  
  
  
  
  
  String next () throws IOException
  {
    while (as == null || !as.hasMoreTokens ())
    {
      as = new StringTokenizer (in.readLine ().trim ());
    }
    
    
    return as.nextToken ();
  }
  
  
  
  long nextLong () throws IOException
  {
    return Long.parseLong (next ());
  }
  
  
  int nextInt () throws IOException
  {
    return Integer.parseInt (next ());
  }
  
  
  double nextDouble () throws IOException
  {
    return Double.parseDouble (next ());
  }
  
  
  String nextLine () throws IOException
  {
    return in.readLine ().trim ();
  }
}
// Problem: 978_B. File Name
// Time complexity: linear

import java.io.*;
import java.util.Scanner;
public class abc{
    public static int check(StringBuilder s)
    {
    	int countRemove=0;
    	if(!s.toString().contains("xxx")) return countRemove;
    	else{
    		
    		for(int i=1;i<s.length()-1;i++)
    		{
    			if(s.charAt(i-1)=='x' && s.charAt(i)=='x' && s.charAt(i+1)=='x')
    			{
    			
    				countRemove++;
    			}
    		}
    		return countRemove;
    	}
    }
   
	public static void main (String[] args) {
	
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	//sc= new Scanner(System.in);
	String s = sc.next();
	StringBuilder sb = new StringBuilder("");
	sb.append(s);
	
    System.out.println(check(sb));
	
	
	
	}
}
// Problem: 964_B. Messages
// Time complexity: linear
import java.io.*;
import java.util.*;
public class GFG {
	public static void main (String[] args) {
	    Scanner sc = new Scanner (System.in);
	    int n = sc.nextInt();
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    int c = sc.nextInt();
	    int ans = 0;
	    int t= sc.nextInt();
	    int arr[] = new int[n];
	    for(int i=0;i<n;i++){
	        int nn = sc.nextInt();
	        ans+=a;
	        if(b<c){
	            ans += (t-nn) * (c - b);
	        }
	    }
	    System.out.println(ans);
	}
}
// Problem: 1191_D. Tokitsukaze, CSL and Stone Game
// Time complexity: linear

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 file, choose Tools | Templates
744444444747477777774
44444447474747777777
 */

/**
 *
 * @author Andy Phan
 */
public class b {
    public static void main(String[] args) {
        FS in = new FS(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        int n = in.nextInt();
        Integer[] arr = new Integer[n];
        int numZ = 0;
        for(int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
            if(arr[i] == 0) numZ++;
        }
        
        Arrays.sort(arr);
        
        
        if(numZ > 1) {
            System.out.println("cslnb");
            return;
        }
        int numDup = 0;
        int[] arr2 = new int[n];
        for(int i = 0; i < n; i++) {
            arr2[i] = arr[i];
            if(i != 0) {
                if(arr2[i] == arr2[i-1]) {
                    arr2[i-1]--;
                    numDup++;
                }
            }
        }
        
        if(numDup > 1) {
            System.out.println("cslnb");
            return;
        }
        
        
        for(int i = 0; i < n; i++) {
            if(i != 0) {
                if(arr2[i] == arr2[i-1]) {
                    System.out.println("cslnb");
                    return;
                }
            }
        }
        long num = 0;
        if(numDup == 1) num++;
        for(int i = 0; i < n; i++) {
            num += arr2[i]-i;
        }
        
        if(num%2 == 0) {
            System.out.println("cslnb");
        } else {
            System.out.println("sjfnb");
        }
        

        out.close();
    }
    
    static class FS {

        BufferedReader in;
        StringTokenizer token;
        
        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }
        
        public String next() {
            if (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
// Problem: 1159_C. The Party and Sweets
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		String[] s = br.readLine().trim().split(" ");
		int n = Integer.parseInt(s[0]);
		int m = Integer.parseInt(s[1]);
		long b[] = new long[n];
		s = br.readLine().trim().split(" ");
		for(int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(s[i]);
		}
		long g[] = new long[m];
		s = br.readLine().trim().split(" ");
		for(int i = 0; i < m; i++) {
			g[i] = Integer.parseInt(s[i]);
		}
		Arrays.sort(b);
		Arrays.sort(g);
		if(g[0] < b[n-1]) {
			System.out.println("-1");
		}
		else if(g[0] == b[n-1]){
			long ans = 0;
			for(int i = 0; i < m; i++) {
				ans += g[i];
			}
			for(int i = 0; i < n-1; i++) {
				ans += (m)*b[i];
			}
			System.out.println(ans);

		}
		else {
			long ans = 0;
			for(int i = 0; i < m; i++) {
				ans += g[i];
			}
			for(int i = 0; i < n-1; i++) {
				ans += (m)*b[i];
			}
			ans += b[n-1]-b[n-2];
			System.out.println(ans);

		}
	}
}
// Problem: 1100_E. Andrew and Taxi
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args){
        try {
            new Main().solve();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    ArrayList<Edge>[]edge;
    int n,m,cnt=0;
    int ord;
    int[]order;int[]vis;
    Edge[] e;
    private void solve() throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        n=in.nextInt();m=in.nextInt();
        edge=new ArrayList[n+1];
        e=new Edge[m];
        vis=new int[n+1];
        order=new int[n+1];
        for(int i=1;i<=n;i++){
            edge[i]=new ArrayList<>();
        }
        for(int i=1;i<=m;i++){
            int s=in.nextInt(),t=in.nextInt(),c=in.nextInt();
            edge[s].add(new Edge(s,t,c,i));
        }
        int l=0,r=1000000000;
        while (l<r){
            int mid=(l+r)>>>1;
            if(judge(mid,false))r=mid;
            else l=mid+1;
        }
        out.print(l+" ");
        judge(l,true);
        Arrays.sort(e,0,cnt,Comparator.comparingInt(x->x.id));
        int ans=0;
        int[]a=new int[m];
        for(int i=0;i<cnt;i++){
            if(order[e[i].s]<order[e[i].t])a[ans++]=e[i].id;
        }
        out.println(ans);
        for(int i=0;i<ans;i++){
            out.print(a[i]+" ");
        }
        out.println();
        out.flush();
    }
    boolean judge(int min,boolean mod){
        Arrays.fill(vis,0);
        cycle=false;
        for(int i=1;i<=n;i++){
            if(vis[i]==0){
                dfs(i,min,mod);
                if(cycle)return false;
            }
        }
        return true;
    }
    boolean cycle=false;
    void dfs(int cur,int min,boolean mod){
        if(cycle)return;
        vis[cur]=1;
        for(Edge e:edge[cur]){
            if(e.c<=min){
                if(mod)this.e[cnt++]=e;
                continue;
            }
            if(vis[e.t]==1){
                cycle=true;return;
            }
            else if(vis[e.t]==0)dfs(e.t,min,mod);
        }
        vis[cur]=2;
        if(mod)order[cur]=ord++;
    }
}
class Edge{
    int s,t,c,id;
    Edge(int a,int b,int c,int d){
        s=a;t=b;this.c=c;id=d;
    }
}
class InputReader{
    StreamTokenizer tokenizer;
    public InputReader(InputStream stream){
        tokenizer=new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
        tokenizer.ordinaryChars(33,126);
        tokenizer.wordChars(33,126);
    }
    public String next() throws IOException {
        tokenizer.nextToken();
        return tokenizer.sval;
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public boolean hasNext() throws IOException {
        int res=tokenizer.nextToken();
        tokenizer.pushBack();
        return res!=tokenizer.TT_EOF;
    }
}
// Problem: 1080_A. Petya and Origami
// Time complexity: constant

import java.util.Scanner;

public class origami {
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		double n = input.nextInt();
		double k = input.nextInt();
		double red = 0;
		double green = 0;
		double blue = 0;
		double ans = 0;
		red = (2 * n) / k;
		green = (5 * n) / k;
		blue = (8 * n) / k;

		double red1 = Math.ceil(red) ;
		double green1 = Math.ceil(green);
		double blue1 = Math.ceil(blue);

		ans+=red1;
		ans+=green1;
		ans+=blue1;
		Double answer = new Double(ans);
		int finished = answer.intValue();
		System.out.println(finished);
	}
}
// Problem: 46_C. Hamsters and Tigers
// Time complexity: linear
import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by IntelliJ IDEA.
 * User: piyushd
 * Date: Dec 5, 2010
 * Time: 4:09:41 PM
 * To change this template use File | Settings | File Templates.
 */
public class HamstersTigers {
    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer st;

	int solve(String a, int k){
		int n = a.length(), ret = 0;
		int temp[] = new int[n];
		for(int i = 0; i < n; i++) temp[(n + i - k) % n] = (a.charAt(i) == 'T') ? 1: 0;
		int left = 0, right = n - 1;
		while(left < right){
			while(temp[left] == 0) left++;
			while(temp[right] == 1) right--;
			if(left < right){
				int t = temp[left];
				temp[left] = temp[right];
				temp[right] = t;
				ret++;
			}
		}
		return ret;
	}

    void solve() throws IOException {
		int n = nextInt();
		String a = next();
		int ans = Integer.MAX_VALUE;
		for(int fix = 0; fix < n; fix++){
			ans = Math.min(ans, solve(a, fix));
		}
		out.println(ans);
    }

    HamstersTigers() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        //in  = new BufferedReader(new InputStreamReader(new FileInputStream(new File("C://Users/piyushd/Desktop/codeforces/sample.txt"))));
        out = new PrintWriter(System.out);

        eat("");

        solve();

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

    private void eat(String str) {
        st = new StringTokenizer(str);
    }

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            eat(line);
        }
        return st.nextToken();
    }

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

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

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

    public static void main(String[] args) throws IOException {
        new HamstersTigers();
    }
}
// Problem: 46_C. Hamsters and Tigers
// Time complexity: linear
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	Scanner in;
	PrintWriter out;
	StreamTokenizer ST;
	BufferedReader br;

	int nextInt() throws IOException {
		ST.nextToken();
		return (int) ST.nval;
	}

	double nextDouble() throws IOException {
		ST.nextToken();
		return ST.nval;
	}

	String next() throws IOException {
		ST.nextToken();
		return ST.sval;
	}

	String nextLine() throws IOException {
		return br.readLine();
	}

	void solve() throws IOException {
		br.readLine();
		char[]s = br.readLine().toCharArray();
		int n = s.length;
		int h=0;
		for(int i=0;i<n;++i)if (s[i]=='H')++h;
		int res=1000000;
		for(int i=0;i<n;++i)
		{
			int t=0;
			for(int j=0;j<h;++j)
			{
				if (s[(i+j)%n]=='T')++t;
			}
			res=Math.min(res,t);
		}
		out.println(res);
	}

	public void run() throws IOException {
		// br = new BufferedReader(new FileReader(new File("input.txt")));
		br = new BufferedReader(new InputStreamReader(System.in));
		ST = new StreamTokenizer(br);
		in = new Scanner(br);
		out = new PrintWriter(System.out);
		// out = new PrintWriter(new FileWriter(new File("output.txt")));
		solve();
		in.close();
		out.close();
		br.close();
	}

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

}
// Problem: 46_C. Hamsters and Tigers
// Time complexity: linear
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
    static final double eps=1e-10;
    public static void main(String[] args) throws FileNotFoundException
    {
        new Main().solve();
    }
    public void solve() throws FileNotFoundException
    {
        Scanner cin=new Scanner(System.in);
        int n;
        n=cin.nextInt();
        String s;
        s=cin.next();
        int ans=Integer.MAX_VALUE;
        int h=0,t=0;
        for(int i=0;i<s.length();i++)
        {
            if(s.charAt(i)=='H')
                h++;
            else if(s.charAt(i)=='T')
                t++;
        }
        ans=Math.min(ans,fun(s,'H',h));
        ans=Math.min(ans,fun(s,'T',t));
        System.out.println(ans);
    }
    public int fun(String s,char c,int num)
    {
        int ans=Integer.MAX_VALUE;
        int ret=num;
        for(int i=0;i<num;i++)
        {
            if(s.charAt(i)==c)
            {
                ret--;
            }
        }
        ans=ret;
        for(int i=0;i+num<s.length();i++)
        {
            if(s.charAt(i)!=c)
                ret--;
            if(s.charAt(i+num)!=c)
            {
                ret++;
            }
            ans=Math.min(ans, ret);
        }
        return ans;
    }
}
// Problem: 46_C. Hamsters and Tigers
// Time complexity: linear

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
	
	InputStreamReader  inp = new InputStreamReader(System.in);
	BufferedReader in = new BufferedReader(inp);
	boolean test = false;

	String[] inData = { "9",
"HTHTHTHHT",
		};

	static int id = -1;
	public String readLine() throws IOException {
		id++;
		if(test)
			return inData[id];
		else
			return in.readLine();
	}
	
	
	public Main() throws Throwable {
		
		int animalNr = Integer.valueOf(readLine());
		String animals = readLine();
		
		boolean[] state = new boolean[animalNr];
		int tigerCount = 0;
		for (int i = 0; i < animals.length(); i++) {
			if('T' == animals.charAt(i)){
				state[i] = true;
				tigerCount++;
			}
		}
		int best = Integer.MAX_VALUE;
		for (int i = 0; i < state.length; i++) {
			int swaps = 0;
			for (int j = i; j < i+tigerCount; j++) {
				if(state[j %animalNr] == false){
					swaps ++;
				}
			}
			if(swaps < best){
				best = swaps;
			}
		}
		
		System.out.println(best);
		
	}
	
	
	public static void main(String[] args) throws Throwable {
		new Main();
	}
}
// Problem: 46_C. Hamsters and Tigers
// Time complexity: linear
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.util.* ;
import java.io.* ;
import java.math.* ;
/************************
 *                      *
 *    Lord Klotski      *
 *                      *
 ***********************/
public class C
{
    static int[] arr ; static int L ;
    public static void rotate()
    {
        int tmp = arr[0] ;
        for (int i = 1 ; i < L ; i ++)
            arr[i-1] = arr[i] ;
        arr[L-1] = tmp ;
    }

    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in) ;

        L = input.nextInt() ; String s = input.next() ;
        arr = new int[L]; for (int i = 0 ; i < L ; i ++) {arr[i] = s.charAt(i) == 'H' ? 1 : 0 ;}

        // want to find longest sequence of 1s
        // then rotate to head
        int count = 99999 ;
        for (int A = 0; A < L ; A ++)
        {
            int[] tmp = new int[L] ; System.arraycopy(arr, 0, tmp, 0, arr.length);
            int ans = 0 ;
            for (int i = 0 ; i < L ; i ++)
            {
                if (tmp[i] == 1) continue ;
                for (int j = L-1 ; j > i ; j --)
                {
                    if (tmp[j] == 0) continue ;
                    ans ++ ;
                    tmp[i] = 1 ; tmp[j] = 0 ;
                    //System.out.println("SWAP " + i + " " + j);
                    //for (int k = 0 ; k < L ; k ++)
                    //    System.out.print(arr[k]);
                    //System.out.println("");
                    break;
                }
            }
            count = Math.min(count,ans) ;
            rotate() ;
        }
        // rotate until j is at the front
        System.out.println(count);

    }
}
// Problem: 46_C. Hamsters and Tigers
// Time complexity: linear
import java.util.*;

public class C {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        char[] s = new char[n];
        String line = in.next();
        int ct=0,ht=0;
        for(int i=0;i<n;i++) //count animals
            if(line.charAt(i)=='T')
                ct++;
            else
                ht++;
        
        int cnt = 1000000000;
        int[] c = new int[2];
        char[] cc = new char[2];
        if(ct<ht)
        {
            c[0] = ct;
            c[1] = ht;
            cc[0] = 'T';
            cc[1] = 'H';
        }else{
            c[0] = ht;
            c[1] = ct;
            cc[0] = 'H';
            cc[1] = 'T';
        }
        
        for(int i=0;i<n;i++)
        {
            int ptr = i;
            for(int j=0;j<c[0];j++) //fill First
            {
                s[ptr] = cc[0];
                ptr = (ptr+1)%n;
            }
            for(int j=0;j<c[1];j++) //fill Second
            {
                s[ptr] = cc[1];
                ptr = (ptr+1)%n;
            }
            //check
            int ch = 0;
            for(int j=0;j<n;j++) //difference
                if(s[j]!=line.charAt(j)&&s[j]==cc[0])
                    ch++;
            cnt = Math.min(cnt,ch);
        }
        
        System.out.print(cnt);
    }
}
// Problem: 46_C. Hamsters and Tigers
// Time complexity: linear
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class B {
    private static StreamTokenizer in;
    private static PrintWriter out;
    
    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }
    
    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }
    
    static{
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
    }
    
    public static void main(String[] args)throws Exception{
        int n = nextInt();
        char[] c = nextString().toCharArray();
        
        int tc = 0, hc = 0;
        for(int i = 0;i<c.length; i++){
            if(c[i] == 'T')tc++; else hc++;
        }
//      char g = 'T';
//      if(tc > hc){
//          tc = hc;
//          g = 'H';
//      }
        
        int max = -1;
        int pos = 0;
        for(int i = 0; i<c.length; i++){
            int a = 0;
            for(int j = 0; j<tc;j++){
                int k = i+j;
                if(k>=n)k-=n;
                if(c[k] == 'T'){
                    a++;
                }
            }
            if(a>max){
                max = a;
                pos = i;
            }
        }
        int min1 = tc - max;
        
        max = -1;
        pos = 0;
        for(int i = 0; i<c.length; i++){
            int a = 0;
            for(int j = 0; j<hc;j++){
                int k = i+j;
                if(k>=n)k-=n;
                if(c[k] == 'H'){
                    a++;
                }
            }
            if(a>max){
                max = a;
                pos = i;
            }
        }
        int min2 = hc - max;
        
        out.println(Math.min(min1, min2));
        out.flush();
    }
}
// Problem: 46_C. Hamsters and Tigers
// Time complexity: linear
import java.util.Scanner;

public class Tsk1 {
    static void metod() throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        String ss = s + s;
        int t = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'T') {
                t++;
            }
        }
        if (t == 1 || t == n - 1) {
            System.out.println(0);
        } else {
            int sum = 0;
            for (int i = 0; i < t; i++) {
                if (s.charAt(i) == 'T') {
                    sum++;
                }
            }
            
            int max = sum;
            for (int i = 0; i < s.length(); i++) {
                if (ss.charAt(i) == 'T') {
                    if (ss.charAt(i + t) == 'H') {
                        sum--;
                    }
                } else {
                    if (ss.charAt(i + t) == 'T') {
                        sum++;
                        max = Math.max(max, sum);
                    }
                }
            }
            System.out.println(t - max);
        }
    }

    public static void main(String[] args) throws Exception {
        Tsk1.metod();
    }
}