codeparrot/codecomplex huggingface dataset:
// Problem: 111_C. Petya and Spiders
// Time complexity: np
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x111C
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int R = Integer.parseInt(st.nextToken());
         int C = Integer.parseInt(st.nextToken());
         if(R > C)
         {
            int t = R;
            R = C;
            C = t;
         }
         //dp[c][m1][m2] = min spoders in first c columns
         int[][][] dp = new int[C+1][1 << R][1 << R];
         for(int i=0; i <= C; i++)
            for(int mask=0; mask < (1<<R); mask++)
               Arrays.fill(dp[i][mask], 69);
         for(int mask=0; mask < (1<<R); mask++)
            dp[0][0][mask] = 0;
         for(int c=1; c <= C; c++)
            for(int mask1=0; mask1 < (1<<R); mask1++)
               for(int mask2=0; mask2 < (1<<R); mask2++)
                  for(int mask3=0; mask3 < (1<<R); mask3++)
                  {
                     boolean works = true;
                     for(int b=0; b < R; b++)
                        if((mask2&(1<<b)) == 0)
                        {
                           if(b > 0 && (mask2&(1<<(b-1))) > 0);
                           else if(b+1 < R && (mask2&(1<<(b+1))) > 0);
                           else if((mask1&(1<<b)) > 0);
                           else if((mask3&(1<<b)) > 0);
                           else  works = false;
                        }
                     if(works)
                        dp[c][mask2][mask3] = Math.min(dp[c][mask2][mask3], dp[c-1][mask1][mask2]+Integer.bitCount(mask1));
                  }
         int res = 0;
         for(int mask=0; mask < (1<<R); mask++)
            res = Math.max(res, R*C-(dp[C][mask][0]+Integer.bitCount(mask)));
         System.out.println(res);
      }
   }
// Problem: 111_C. Petya and Spiders
// Time complexity: np
import java.io.*;

import java.awt.geom.Point2D;
import java.text.*;
import java.math.*;
import java.util.*;

public class Main implements Runnable {

	final String filename = "";

	public void solve() throws Exception {
		int n = iread(), m = iread();
		int INF = -1;
		if (m > n) {
			int t = m;
			m = n;
			n = t;
		}
		int[][][] d = new int[2][1 << m][1 << m];
		for (int i = 0; i < 1 << m; i++)
			Arrays.fill(d[0][i], INF);

		int[] cnt = new int[1 << m];
		for (int i = 0; i < 1 << m; i++)
			cnt[i] = cnt[i / 2] + i % 2;

		int step = 0;
		d[0][0][0] = 0;
		for (int u = 0; u < n; u++) {
			for (int i = 0; i < 1 << m; i++)
				Arrays.fill(d[step ^ 1][i], INF);
			for (int mask1 = 0; mask1 < 1 << m; mask1++)
				for (int mask2 = 0; mask2 < 1 << m; mask2++) {
					int t = d[step][mask1][mask2];
					if (t == INF)
						continue;
					for (int mask = 0; mask < 1 << m; mask++) {
						if ((mask1 & mask) != mask1)
							continue;
						int mask01 = ((1 << m) - 1) & ~mask2;

						for (int j = 0; j < m; j++)
							if ((mask & (1 << j)) != 0) {
								if (j > 0)
									mask01 &= ~(1 << (j - 1));
								mask01 &= ~(1 << j);
								if (j + 1 < m)
									mask01 &= ~(1 << (j + 1));
							}
						int mask02 = mask;

						int t2 = t + cnt[((1 << m) - 1) & ~mask];
						if (d[step ^ 1][mask01][mask02] < t2) {
							d[step ^ 1][mask01][mask02] = t2;
						}
					}
				}
			step ^= 1;
		}
		int ans = INF;
		for (int mask = 0; mask < 1 << m; mask++) {
			ans = Math.max(ans, d[step][0][mask]);
		}
		out.write(ans + "\n");
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedWriter(new OutputStreamWriter(System.out));
			// in = new BufferedReader(new FileReader(filename+".in"));
			// out = new BufferedWriter(new FileWriter(filename+".out"));
			solve();
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int iread() throws Exception {
		return Integer.parseInt(readword());
	}

	public double dread() throws Exception {
		return Double.parseDouble(readword());
	}

	public long lread() throws Exception {
		return Long.parseLong(readword());
	}

	BufferedReader in;

	BufferedWriter out;

	public String readword() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) {
		try {
			Locale.setDefault(Locale.US);
		} catch (Exception e) {

		}
		// new Thread(new Main()).start();
		new Thread(null, new Main(), "1", 1 << 25).start();
	}
}
// Problem: 1185_G1. Playlist for Polycarp (easy version)
// Time complexity: np
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class G1 {
    static int n, T, duration[], type[];
    static long dp[][][], mod = (long) 1e9 + 7;

    public static void main(String[] args) throws Exception {
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    solveIt();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }, "Main", 1 << 28).start();
    }

    public static void solveIt() throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = in.nextInt();
        T = in.nextInt();
        dp = new long[3][T + 1][1 << n];
        duration = new int[n];
        type = new int[n];
        for (int i = 0; i < n; i++) {
            duration[i] = in.nextInt();
            type[i] = in.nextInt() - 1;
        }
        for (long a[][] : dp) for (long b[] : a) Arrays.fill(b, -1);
        pw.println(solve(0, T, 0));

        pw.close();
    }

    static long solve(int lastType, int rem, int mask) {
        if (rem == 0) return 1;
        if (rem < 0) return 0;
        if (dp[lastType][rem][mask] != -1) return dp[lastType][rem][mask];
        long res = 0;
        for (int i = 0; i < n; i++) {
            if (!check(mask, i) && (lastType != type[i] || mask == 0) && rem - duration[i] >= 0) {
                res += solve(type[i], rem - duration[i], set(mask, i));
                if (res >= mod) res -= mod;
            }
        }
        return dp[lastType][rem][mask] = res;
    }

    static boolean check(int N, int pos) {
        return (N & (1 << pos)) != 0;
    }

    static int set(int N, int pos) {
        return N = N | (1 << pos);
    }

    static int reset(int N, int pos) {
        return N = N & ~(1 << pos);
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}
// Problem: 1185_G1. Playlist for Polycarp (easy version)
// Time complexity: np
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;


public class q5 {
	static NoD[] arr;
	static int index,count,zc;
	static ArrayList<NoD> pos,neg;
	static long[][][][] dp;
	
	static long solve(int a,int b, int c,int d, long mod) {
		long[][][][] a2=dp;
		int p=-1;
		if(a==0 && b==0 && c==0) return 1;
		if(dp[a][b][c][d]!=-1) return dp[a][b][c][d];
		long tr=0;
		if(a>0 && d!=1) {
			tr=+a*solve(a-1,b,c,1,mod);
			tr%=mod;
		}
		if(b >0 && d!=2) {
			tr+=b*solve(a,b-1,c,2,mod);
			tr%=mod;
		}
		if(c>0 && d!=3) {
			tr+=c*solve(a,b,c-1,3,mod);
			tr%=mod;
		}
		tr%=mod;
		return dp[a][b][c][d]=tr;
		
	}
	
	
	public static void main(String[] args) throws IOException {
		
		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Reader.nextInt(),t=Reader.nextInt();
		long mod=(long)1e9+7,fact[]=new long[16];
		dp=new long[16][16][16][4];
		for(int i=0;i<16;i++) {
			for(int j=0;j<16;j++) {
				for(int k=0;k<16;k++)
				Arrays.fill(dp[i][j][k], -1);
			}
		}
		fact[0]=1;
		for(int i=1;i<=15;i++) {
			fact[i]=i*fact[i-1];
			fact[i]%=mod;
		}
		NoD[] arr=new NoD[n];
		for(int i=0;i<n;i++) {
			int a=Reader.nextInt(),b=Reader.nextInt();
			arr[i]=new NoD(a,b);
			
		}
		long ans=0;
		for(int i=0;i<(1<<n);i++) {
			int time=0;
			int prev=-1;
			int t1=0,t2=0,t3=0;
			long[] c= {i};
			BitSet b=BitSet.valueOf(c);
			for(int j=0;j<n;j++) {
				if(b.get(j)) {
					time+=arr[j].val;
						prev=arr[j].index;
						if(arr[j].index==1) t1++;
						else if(arr[j].index==2) t2++;
						else t3++;	
				}
			}
			if(time==t) {
				long v=1;
				long v2=1;
				v*=solve(t1,t2,t3,0,mod);
				v%=mod;
				ans+=v;
				ans%=mod;
			}
		}
		out.println(ans);
		out.flush();
		
	}
}

class NoD{
	int val, index;
	NoD(int v,int i){
		val=v;index=i;
	}
}

class Pair{
	NoD a, b;
	Pair(NoD aa,NoD bb){
		a=aa;b=bb;
	}
}


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}
// Problem: 1185_G1. Playlist for Polycarp (easy version)
// Time complexity: np
import java.util.*;
public class G {
    static int n,t;
    static int[]a;
    static int[]g;
    static long[][][]dp;
    static final long MOD=1000000007;
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        t=sc.nextInt();
        a=new int[n];
        g=new int[n];
        for(int i=0;i<n;i++) {
            a[i] = sc.nextInt();
            g[i] = sc.nextInt();
        }
        dp=new long[4][1<<(n-1)+1][t+1];
        for(int i=0;i<4;i++)
            for(int j=0;j<1<<(n-1)+1;j++)
                for(int k=0;k<=t;k++)
                    dp[i][j][k]=-1;
        System.out.println(dp(0,0,t));
    }
    private static long dp(int genre,int mask,int time){
        if(time<0)
            return 0;
        if(dp[genre][mask][time]!=-1)
            return dp[genre][mask][time];
        if(time==0)
            return 1;
        dp[genre][mask][time]=0;
        for(int i=0;i<n;i++) {
            if (g[i] != genre && ((1 << i) & mask) == 0)
                dp[genre][mask][time] = (dp[genre][mask][time]+dp(g[i], mask | (1 << i), time - a[i]))%MOD;
        }
        return dp[genre][mask][time];
    }
}
// Problem: 1185_G1. Playlist for Polycarp (easy version)
// Time complexity: np
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	static final int MOD = (int)1e9 + 7;
	static int n;
	static int[] t;
	static int[] g;	
	static int[][] memo;
	
	static int dp(int mask, int rem, int last)
	{
		if(rem == 0)
			return 1;
		if(memo[last][mask] != -1)
			return memo[last][mask];
		
		int ans = 0;
		for(int i = 0; i < n; i++)
		{
			if((mask & (1 << i)) == 0 && rem >= t[i] && g[i] != last)
				ans += dp(mask | 1 << i, rem - t[i], g[i]);
			
			if(ans >= MOD)
				ans -= MOD;
		}
		
		return memo[last][mask] = ans;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		
		n = in.nextInt();
		int T = in.nextInt();
		
		t = new int[n];
		g = new int[n];
		
		for(int i = 0; i < n; i++)
		{
			t[i] = in.nextInt();
			g[i] = in.nextInt() - 1;
		}
		
		memo = new int[4][1 << n];
		for(int []x : memo)
		{
			Arrays.fill(x, -1);
		}
		
		out.println(dp(0, T, 3));
		out.close();
	}
	
	static class InputReader
	{
		BufferedReader reader;
		StringTokenizer tokenizer;
		
		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		
		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}
			
			return tokenizer.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}
// Problem: 1185_G1. Playlist for Polycarp (easy version)
// Time complexity: np
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static long mod = 1000000007;

    public static void main(String[] args) {
    	int n = sc.nextInt();
    	int T = sc.nextInt();
    	int[] t = new int[n];
    	int[] g = new int[n];
    	for(int i=0; i<n; i++) {
    		t[i] = sc.nextInt();
    		g[i] = sc.nextInt() - 1;
    	}
    	long[][][] dp = new long[T+1][3][1 << 15];
    	for(int i=1; i<=T; i++) {
    		for(int j=0; j<n; j++) {
    			if(i - t[j] == 0) {
    				dp[i][g[j]][1 << j] = (dp[i][g[j]][1 << j] + 1) % mod;
    			} else if(i - t[j] > 0) {
    				for(int k=0; k<(1 << 15); k++) {
    					if((k >> j & 1) == 1) {
    						continue;
    					}
    					dp[i][g[j]][k + (1 << j)] = (dp[i][g[j]][k + (1 << j)] + dp[i - t[j]][(g[j] + 1) % 3][k] + dp[i - t[j]][(g[j] + 2) % 3][k]) % mod;
    				}
    			}
    		}
    	}
    	long ans = 0;
    	for(int j=0; j<3; j++) {
    		for(int k=0; k<(1 << 15); k++) {
    			ans = (ans + dp[T][j][k]) % mod;
    		}
    	}
    	System.out.println(ans);
    }

    static long power(long m , long n){
    	if(n == 0) {
    		return 1;
    	}else if(n == 1){
            return m;
        }else if(n % 2 == 0){
            long s = power(m, n/2);
            return ( (s % mod) * (s % mod) ) % mod;
        }else{
            return ( (m % mod) * (power(m, n-1) % mod) ) % mod;
        }
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
// Problem: 1185_G1. Playlist for Polycarp (easy version)
// Time complexity: np
import java.io.*;
import java.util.*;

public class B {

	static int n,t[],g[],MOD=(int)1e9+7;
	static int [][]memo;
	static int dp(int msk,int rem,int lastG) {
		if(rem==0)
			return 1;
		if(memo[lastG][msk]!=-1)
			return memo[lastG][msk];
		int ans=0;
		for(int i=0;i<n;i++) {
			if((msk & (1<<i))==0 && rem>=t[i] && g[i]!=lastG)
				ans+=dp(msk|1<<i,rem-t[i],g[i]);
				if(ans>=MOD)
					ans-=MOD;
		}
		return memo[lastG][msk]=ans;
	}
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		n=sc.nextInt();
		int T=sc.nextInt();
		t=new int [n];
		g=new int [n];
		
		for(int i=0;i<n;i++) {
			t[i]=sc.nextInt();
			g[i]=sc.nextInt()-1;
		}
		memo=new int [4][1<<n];
		for(int []x:memo)
			Arrays.fill(x, -1);
		out.println(dp(0, T, 3));
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

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

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}
// Problem: 1185_G1. Playlist for Polycarp (easy version)
// Time complexity: np
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class G1 {
    static int n, T, duration[], type[];
    static long dp[][][], mod = (long) 1e9 + 7;

    public static void main(String[] args) throws Exception {
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    solveIt();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }, "Main", 1 << 28).start();
    }

    public static void solveIt() throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = in.nextInt();
        T = in.nextInt();
        dp = new long[4][T + 1][1 << n];
        duration = new int[n];
        type = new int[n];
        for (int i = 0; i < n; i++) {
            duration[i] = in.nextInt();
            type[i] = in.nextInt() - 1;
        }
        for (long a[][] : dp) for (long b[] : a) Arrays.fill(b, -1);
        pw.println(solve(3, T, 0));

        pw.close();
    }

    static long solve(int lastType, int rem, int mask) {
        if (rem == 0) return 1;
        if (rem < 0) return 0;
        if (dp[lastType][rem][mask] != -1) return dp[lastType][rem][mask];
        long res = 0;
        for (int i = 0; i < n; i++) {
            if (!check(mask, i) && lastType != type[i] && rem - duration[i] >= 0) {
                res += solve(type[i], rem - duration[i], set(mask, i));
                if (res >= mod) res -= mod;
            }
        }
        return dp[lastType][rem][mask] = res;
    }

    static boolean check(int N, int pos) {
        return (N & (1 << pos)) != 0;
    }

    static int set(int N, int pos) {
        return N = N | (1 << pos);
    }

    static int reset(int N, int pos) {
        return N = N & ~(1 << pos);
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}
// Problem: 1185_G1. Playlist for Polycarp (easy version)
// Time complexity: np
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class x1185G1b
   {
      static long MOD = 1000000007L;
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int T = Integer.parseInt(st.nextToken());
         Song[] arr = new Song[N];
         for(int i=0; i < N; i++)
         {
            st = new StringTokenizer(infile.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken())-1;
            arr[i] = new Song(a, b);
         }
         //bitmask
         long[][] dp = new long[1 << N][3];
         Arrays.fill(dp[0], 1L);
         for(int mask=0; mask < dp.length; mask++)
         {
            for(int i=0; i < N; i++)
               if((mask & (1 << i)) == 0)
               {
                  Song c = arr[i];
                  //continue all dp if mask == 0
                  if(mask == 0 && c.t <= T)
                  {
                     dp[mask|(1 << i)][c.g]++;
                     dp[mask|(1 << i)][c.g] %= MOD;
                  }
                  //continue dp if not same genre
                  else
                  {
                     for(int gen=0; gen < 3; gen++)
                        if(gen != c.g)
                        {
                           dp[mask|(1 << i)][c.g] += dp[mask][gen];
                           dp[mask|(1 << i)][c.g] %= MOD;
                        }
                        //optimize?
                  }
               }
         }
         long res = 0L;
         for(int mask=1; mask < dp.length; mask++)
            for(int i=0; i < 3; i++)
            {
               int sum = 0;
               for(int b=0; b < N; b++)
                  if((mask & (1 << b)) > 0)
                     sum += arr[b].t;
               if(sum == T)
                  res = (res+dp[mask][i])%MOD;
            }
         System.out.println(res);
      }
   }
   class Song
   {
      public int t;
      public int g;
      
      public Song(int a, int b)
      {
         t = a;
         g = b;
      }
   }
   //cheerios are good for your heart, but are they good for your brain?