codeparrot/codecomplex huggingface dataset:
// Problem: 608_B. Hamming Distance Sum
// Time complexity: linear
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	 int[][] x = new int [200010][10];
     String a = sc.nextLine(); 
     String b = sc.nextLine(); 
 	  int n = a.length();
	  int m = b.length();
       for (int i = 1; i <= m; i++) {
         for (int j = 0; j < 2; j++) {
           x[i][j] = x[i - 1][j];
         }
         ++x[i][b.charAt(i - 1) - '0'];
       }
       long res = 0;
        for (int i = 0, c; i < n; i++) {
          c = a.charAt(i) - '0';
           for (int j = 0; j < 2; j++) {
             res += Math.abs(c - j) * (x[m - n + i + 1][j] - x[i][j]);
           }
        }
         System.out.println(res);
  }
}
// Problem: 1075_C. The Tower is Going Home
// Time complexity: nlogn
import java.awt.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;


public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), m = scanner.nextInt();
        int[] vertical = new int[n];

        for (int i = 0; i < n; i++) {
            vertical[i] = scanner.nextInt();
        }

        Arrays.sort(vertical);


        ArrayList<Integer> horisontal = new ArrayList<>();
        int amount = 0;
        for (int i = 0; i < m; i++) {
            int x1 = scanner.nextInt(), x2 = scanner.nextInt(), y = scanner.nextInt();
            if (x1 == 1) {
                amount++;
                horisontal.add(x2);
            }
        }

        Collections.sort(horisontal);


        if (amount == 0) {
            System.out.println(0);
            return;
        }


        int minVal = amount, horSize = horisontal.size(), verLen = vertical.length;
        int h = 0, v = 0;

        for (; v < verLen && h < horSize; ) {

           while (h < horSize && horisontal.get(h) < vertical[v]){
               h++;
               amount--;
           }
           minVal = Math.min(minVal, amount + v);

            while (h < horSize && v < verLen && horisontal.get(h) >= vertical[v]){
                minVal = Math.min(minVal, amount + v);
                v++;
            }

        }

        if(horisontal.get(horSize - 1) < 1E9){
            minVal = Math.min(minVal, v);
        }



        System.out.println(minVal);

    }
}
// Problem: 1068_A. Birthday
// Time complexity: constant
import java.io.*;
import java.util.*;
public class Codechef{
	

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

    long n=in.nextLong();
		long m=in.nextLong();
		long k=in.nextLong();
		long l=in.nextLong();
 
		long j=((k+l)/m);
		if((k+l)%m!=0)j++;
		if((k+l>n) || j*m>n) {
			System.out.println(-1);
		}else {
			
			System.out.println(j);
		}


    }

}
// Problem: 913_A. Modular Exponentiation
// Time complexity: constant
import java.math.BigInteger;
import java.util.Scanner;

public class RENAMETHISBITCH {
		
	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			BigInteger m = sc.nextBigInteger();
			
			System.out.println(m.mod(BigInteger.valueOf(2).pow(n)));
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
// Problem: 1005_C. Summarize to the Power of Two
// Time complexity: nlogn
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] arr = new int[n];
        HashMap<Integer, Integer> map = new HashMap<>();
        StringTokenizer st = new StringTokenizer(br.readLine());
        for (int i = 0; i < n; i++) {
            int x = Integer.parseInt(st.nextToken());
            arr[i] = x;
            if (!map.containsKey(x)) {
                map.put(x, 1);
            } else {
                map.replace(x, map.get(x) + 1);
            }
        }
        int[] power = new int[31];
        for (int i = 0; i < 31; i++) {
            power[i] = 1 << i; // 0 100=4 1000=8 10000=16
        }
        int c = 0;
        for (int i = 0; i < n; i++) {
        boolean f = false;
        for (int j = 0; j <= 30; j++) {
        int check = power[j] - arr[i];
                if ((map.containsKey(check) && check != arr[i])) {
                f = true; break;}
                if((map.containsKey(check) && check == arr[i] && map.get(check) >=2)) {
                    f = true; break;
                }
            }
            if (!f) {
                c++;
            }
        }
        System.out.println(c);
    }
}
// Problem: 994_C. Two Squares
// Time complexity: constant
import java.util.*;
import java.io.*;


public class C994{
	static double area(double x1,double y1,double x2,double y2,double x3,double y3){
		return Math.abs((x1 * (y2 - y3) +  
        x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0); 
	}
	public static void main(String args[])throws IOException{
		Scanner sc=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter pw=new PrintWriter(System.out);
		int x11=sc.nextInt();
		int y11=sc.nextInt();
		int x12=sc.nextInt();
		int y12=sc.nextInt();
		int x13=sc.nextInt();
		int y13=sc.nextInt();
		int x14=sc.nextInt();
		int y14=sc.nextInt();
		double x1c=(x11+x12+x13+x14)/4.0;
		double y1c=(y11+y12+y13+y14)/4.0;
		int x21=sc.nextInt();
		int y21=sc.nextInt();
		int x22=sc.nextInt();
		int y22=sc.nextInt();
		int x23=sc.nextInt();
		int y23=sc.nextInt();
		int x24=sc.nextInt();
		int y24=sc.nextInt();
		double x2c=(x21+x22+x23+x24)/4.0;
		double y2c=(y21+y22+y23+y24)/4.0;
		double a1=area(x11,y11,x12,y12,x13,y13)+area(x11,y11,x13,y13,x14,y14);
		double a2=area(x21,y21,x22,y22,x23,y23)+area(x21,y21,x23,y23,x24,y24);
		if(a1==area(x11,y11,x12,y12,x21,y21)+area(x11,y11,x21,y21,x14,y14)+area(x21,y21,x12,y12,x13,y13)+area(x21,y21,x14,y14,x13,y13)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a1==area(x11,y11,x12,y12,x22,y22)+area(x11,y11,x22,y22,x14,y14)+area(x22,y22,x12,y12,x13,y13)+area(x22,y22,x14,y14,x13,y13)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a1==area(x11,y11,x12,y12,x23,y23)+area(x11,y11,x23,y23,x14,y14)+area(x23,y23,x12,y12,x13,y13)+area(x23,y23,x14,y14,x13,y13)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a1==area(x11,y11,x12,y12,x24,y24)+area(x11,y11,x24,y24,x14,y14)+area(x24,y24,x12,y12,x13,y13)+area(x24,y24,x14,y14,x13,y13)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a1==area(x11,y11,x12,y12,x2c,y2c)+area(x11,y11,x2c,y2c,x14,y14)+area(x2c,y2c,x12,y12,x13,y13)+area(x2c,y2c,x14,y14,x13,y13)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a2==area(x21,y21,x22,y22,x11,y11)+area(x21,y21,x11,y11,x24,y24)+area(x11,y11,x22,y22,x23,y23)+area(x11,y11,x24,y24,x23,y23)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a2==area(x21,y21,x22,y22,x12,y12)+area(x21,y21,x12,y12,x24,y24)+area(x12,y12,x22,y22,x23,y23)+area(x12,y12,x24,y24,x23,y23)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a2==area(x21,y21,x22,y22,x13,y13)+area(x21,y21,x13,y13,x24,y24)+area(x13,y13,x22,y22,x23,y23)+area(x13,y13,x24,y24,x23,y23)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a2==area(x21,y21,x22,y22,x14,y14)+area(x21,y21,x14,y14,x24,y24)+area(x14,y14,x22,y22,x23,y23)+area(x14,y14,x24,y24,x23,y23)){
			pw.println("YES");
			pw.close();
			return;
		}
		if(a2==area(x21,y21,x22,y22,x1c,y1c)+area(x21,y21,x14,y14,x2c,y2c)+area(x1c,y1c,x22,y22,x23,y23)+area(x1c,y1c,x24,y24,x23,y23)){
			pw.println("YES");
			pw.close();
			return;
		}
		
		pw.println("NO");
		pw.close();
	}
}
// Problem: 988_B. Substrings Sort
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;


public class pr988B {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int n = Integer.parseInt(br.readLine());

        ArrayList<String> a = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            a.add(br.readLine());
        }

        if(solve(n, a)){
            out.println("YES");
            for (String s : a) {
                out.println(s);
            }
        }
        else
            out.println("NO");

        out.flush();
        out.close();
    }

    private static boolean solve(int n, ArrayList<String> a) {
        a.sort(Comparator.comparingInt(String::length));
        for (int i = 0; i < n - 1; i++) {
            if(!a.get(i+1).contains(a.get(i))) return false;
        }
        return true;
    }
}
// Problem: 994_C. Two Squares
// Time complexity: constant
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class TwoSquares {
    
    int INF = 1000;
    
    void solve() {
        int[][] s1 = new int[4][2];
        for (int i = 0; i < 4; i++) {
            s1[i][0] = in.nextInt();
            s1[i][1] = in.nextInt();
        }
        
        int[][] s2 = new int[4][2];
        for (int i = 0; i < 4; i++) {
            s2[i][0] = in.nextInt();
            s2[i][1] = in.nextInt();
        }
        
        if (ok(s1, s2)) {
            out.println("Yes");
            return;
        }
        
        rotate(s1);
        rotate(s2);
        
        if (ok(s2, s1)) {
            out.println("Yes");
            return;
        }
        
        out.println("No");
    }
    
    void rotate(int[][] s) {
        for (int i = 0; i < 4; i++) {
            int x = s[i][0], y = s[i][1];
            s[i][0] = x - y;
            s[i][1] = x + y;
        }
    }
    
    boolean ok(int[][] s1, int[][] s2) {
        int xmin = INF, xmax = -INF, ymin = INF, ymax = -INF;
        for (int i = 0; i < 4; i++) {
            xmin = Math.min(xmin, s1[i][0]);
            xmax = Math.max(xmax, s1[i][0]);
            ymin = Math.min(ymin, s1[i][1]);
            ymax = Math.max(ymax, s1[i][1]);
        }
        
        for (int i = 0; i < 4; i++) {
            if (s2[i][0] >= xmin && s2[i][0] <= xmax && s2[i][1] >= ymin && s2[i][1] <= ymax) return true;
        }
        
        int[] mid2 = new int[]{s2[0][0] + s2[2][0], s2[0][1] + s2[2][1]};
        return mid2[0] >= xmin * 2 && mid2[0] <= xmax * 2 && mid2[1] >= ymin * 2 && mid2[1] <= ymax * 2;
    }
    
    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new TwoSquares().solve();
        out.close();
    }
    
    static FastScanner in;
    static PrintWriter out;
    
    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;
        
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
        
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
        
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}
// Problem: 1005_D. Polycarp and Div 3
// Time complexity: linear
import java.util.*;

//201920181

public class Polycarp{

	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
        int rem[] = new int[3];
		
		Arrays.fill(rem,-1);
		rem[0] = 0;
        char ch[] = s.next().toCharArray();
		int n = ch.length;
 		long dp[] = new long[n];

        int sum = 0;
		
        for(int i=0;i<ch.length;i++){
		   sum = sum + (ch[i]-48);
		   if(rem[sum%3] != -1)
			    if(i>0){
					dp[i] = Math.max(dp[i-1],dp[rem[sum%3]]+1);}
				else
					dp[i] = 1;
	       else
			   if(i>0)
				   dp[i] = dp[i-1];
			   
		   
		   rem[sum%3] = i;
		   sum = sum%3;
		   
		}		
		 

            System.out.println(dp[n-1]);			
		
		
	}
}
// Problem: 1075_A. The King's Race
// Time complexity: constant
import java.awt.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long x = scanner.nextLong(), y = scanner.nextLong();
        long whiteSteps, blackSteps;

        if(x == 1 || y == 1){
            whiteSteps = (x - 1) + (y - 1);
        } else {
            whiteSteps = Math.min((x - 1) + Math.abs(y - x), (y - 1) + Math.abs(y - x));
        }

        if(x == n || y == n){
            blackSteps = (n - x) + (n - y);
        } else {
            blackSteps = Math.min((n - x) + Math.abs(y - x), (n - y) + Math.abs(y - x));
        }

        if (whiteSteps <= blackSteps){
            System.out.println("White");
        } else {
            System.out.println("Black");
        }

    }
}
// Problem: 1159_D. The minimal unique substring
// Time complexity: linear
//package com.krakn.CF.D1159;

import java.util.Scanner;

public class Main {

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

        int n, k;
        n = sc.nextInt();
        k = sc.nextInt();

        int a = (n - k) / 2;

        StringBuilder s = new StringBuilder();

        int i;
        while (s.length() < n) {
            i = 0;
            while (i < a && s.length() < n) {
                s.append("0");
                i++;
            }
            if (s.length() < n) s.append("1");
        }

        System.out.println(s);
    }
}
// Problem: 992_C. Nastya and a Wardrobe
// Time complexity: logn


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicReferenceArray;

public class NastyaWardrobe {
    static long modulo = 1000000007;
    static long ans = 0;
    public static void main(String[] args) throws IOException {

        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = inp.readLine().split(" ");
        long clothes = Long.parseLong(s1[0]);
        long months = Long.parseLong(s1[1]);

        //formula 2^k(2x-1)+1;
        calc(clothes,months);
        System.out.print(ans);
    }
    static void calc(long clothes,long months){
        if(clothes!=0) {
            long a;
            long count = 0;
            ArrayList<Long> list = new ArrayList<>();
            if (months >= 2) {
                a = 2;
                long c = months;

                while (c > 1) {
                    if (c % 2 == 1) {
                        count++;
                        list.add(a);
                    }
                    c = c / 2;

                    a = (a * a) % modulo;
                }
                while (count > 0) {
                    long b = list.get(0);
                    list.remove(0);
                    a = (a * b) % modulo;
                    count--;
                }

            } else {
                a = (long) Math.pow(2, months);
            }


            long b = clothes;

            //System.out.println(b);
            b = (2 * b - 1) % modulo;
            ans = (a * b) % modulo;
            ans = (ans + 1) % modulo;
        }else{
            ans = 0;
        }

    }
}
// Problem: 1017_C. The Phone Number
// Time complexity: linear
import java.util.*;
public class Test { public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int x= (int)Math.sqrt(n) ;
int a[] = new int[n+5];
for(int i=1,o=n,j;i<=n;i+=x)
for(j=(int)Math.min(i+x-1,n);j>=i;a[j--]=o--);
for(int i=1;i<=n;i++)System.out.print(a[i]+" ");
System.out.println();


} 
}
// Problem: 1054_C. Candies Distribution
// Time complexity: quadratic
import java.util.*;
import java.lang.*;
import java.io.*;

public class java2 {
    public static void main(String[] args) {
        Scanner r = new Scanner(System.in);
        int n=r.nextInt();
        int []l=new int[1005];
        int []ri=new int[1005];
        int []candy=new int[1005];
        for(int i=1;i<=n;++i)
        {
            l[i]=r.nextInt();
        }
        for(int i=1;i<=n;++i)
        {
            ri[i]=r.nextInt();
        }
        for(int i=1;i<=n;++i)
        {
            if(l[i]>i-1||ri[i]>n-i)
            {
                System.out.println("NO");
                System.exit(0);
            }
            candy[i]=n-l[i]-ri[i];
        }
        for(int i=1;i<=n;++i)
        {
            int left=0,right=0;
            for(int j=1;j<=i-1;++j)
            {
                if(candy[j]>candy[i])
                {
                    ++left;
                }
            }
            for(int j=i+1;j<=n;++j)
            {
                if(candy[j]>candy[i])
                {
                    ++right;
                }
            }
            if(left!=l[i]||right!=ri[i])
            {
                System.out.println("NO");
                System.exit(0);
            }
        }
        System.out.println("YES");
        for(int i=1;i<=n;++i)
        {
            System.out.print(candy[i]+" ");
        }
    }
}
// Problem: 1190_B. Tokitsukaze, CSL and Stone Game
// Time complexity: linear
import java.util.*;
import java.io.*;
public class C{
    static PrintWriter out;
    static InputReader in;
    public static void main(String args[]){
        out = new PrintWriter(System.out);
        in = new InputReader();
        new C();
        out.flush(); out.close();
    }   
    C(){
       int w = solve();
       out.print(w == 0 ? "sjfnb" : "cslnb");
    }
    int n;
    long a[];
    int solve(){
        n = in.nextInt(); a = new long[n];
        long sum = 0;
        for(int i = 0; i < n; i++)sum += a[i] = in.nextLong();
        if(sum == 0){
            return 1;
        }
        Arrays.sort(a);
        int c = 0, c0 = 0; long p = -1, max = 0;
        int f = 0;
        long t = -1; int pp = -1;
        for(int i = 0; i < n; i++){
            if(a[i] == p){
                c++;
            }else{
                if(p == 0)c0 = c;
                if(c >= 2){f++; t = p; pp = i - 2;}
                max = Math.max(max, c);
                p = a[i];
                c = 1;
            }
        }
        max = Math.max(max, c);
        sum = 0;
        if(c >= 2){f++; t = p; pp = n - 2;}
        if(max > 2 || c0 > 1 || f > 1)return 1;
        if(f == 1){
            long v = Arrays.binarySearch(a, t - 1);
            if(v >= 0)return 1;
            a[pp]--; sum = 1;
        }

        p = -1;
        for(int i = 0; i < n; i++){
            sum += a[i] - (p + 1);
            a[i] = p + 1;
            p = a[i];
        }

        return 1 - (int)(sum % 2);
    }
    public static class InputReader{
        BufferedReader br;
        StringTokenizer st;
        InputReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
        public String next(){
            while(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){}
            }
            return st.nextToken();
        }
    }
}
// Problem: 1011_A. Stages
// Time complexity: linear
import java.io.*;


public class First {
    StreamTokenizer in;
    PrintWriter out;

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

    long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }



    void run() throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    void solve() throws IOException {
        int n = nextInt(), k = nextInt(), sum = 0, count = 0;
        String str = nextString();
        char[] arr = str.toCharArray();
        boolean[] bool = new boolean[26];
        for(char ch: arr){
            bool[((int)ch)-97] = true;
        }
        for(int i = 0; i < 26; i++){
            if(bool[i]){
                sum += i+1;
                count++;
                i += 1;
            }
            if(count == k) break;
        }
        if(count == k) out.println(sum);
        else out.println(-1);
    }

    public static void main(String[] args) throws IOException {
        new First().run();
    }
}
// Problem: 967_A. Mind the Gap
// Time complexity: linear
import java.util.*;
 
public class Main{
    private static final int MAX_SIZE = 100005;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(((m + 1) / 60 < a) || ((m + 1) / 60 == a && (m + 1) % 60 <= b)) {
            out(0, 0);
            System.exit(0);
        }
        for(int i = 2; i <= n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            int bb = b + 2 * m + 2;
            int aa = a + bb / 60;
            bb %= 60;

            if((aa < x) || (aa == x && bb <= y)) {
                b = b + m + 1;
                a = a + b / 60;
                b %= 60;
                out(a, b);
                System.exit(0);
            }
            a = x;
            b = y;
        }
        b = b + m + 1;
        a = a + b / 60;
        b = b % 60;        
        out(a, b);
    }

    private static void out(int a, int b) {
        cout(a);
        cout(" ");
        cout(b);
    }

    private static void cout(Object a) {
        System.out.print(a);
    }
}
// Problem: 1023_C. Bracket Subsequence
// Time complexity: linear
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();

		StringBuilder ans = new StringBuilder();
		int count = 0;
		int open = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '(') {
				ans.append("(");
				count++;
				open++;
			} else {
				ans.append(")");
				open--;
			}
			if (count == k / 2) {
				break;
			}
		}

		while (open > 0) {
			ans.append(")");
			open--;
		}
		System.out.println(ans.toString());
	}
}