codeparrot/codecomplex huggingface dataset:
// Problem: 267_A. Subtractions
// Time complexity: constant
//package Demo;

//import java.io.Console;
import java.util.Scanner;

//import javax.swing.plaf.basic.BasicInternalFrameTitlePane.MaximizeAction;

public class Main {

    /**
     * @param args
     */ 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        while(T-->0){
            int m , n , count=0;
            m = scanner.nextInt();
            n = scanner.nextInt();
            while(m!=0&&n!=0){
                int tmp;
                if(m<n) {
                    tmp = n;
                    n = m;
                    m = tmp;
                }
                count+=m/n;
                m = m%n;
            } 
            if(T!=0)System.out.println(count);
            else System.out.print(count);
        }
    }

}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.*;
import java.io.*;
public class Subtractions
{
	
	
	/************************ SOLUTION STARTS HERE ***********************/
	
	static long modifiedEuclidGCD(int a , int b) {
		return b == 0 ? 0 : (a / b) + modifiedEuclidGCD(b, a % b);
	}
	
	private static void solve(FastScanner s1, PrintWriter out){
		
		int T = s1.nextInt();
		while(T-->0)
			out.println(modifiedEuclidGCD(s1.nextInt(), s1.nextInt()));
		
	}
	
	
	
	/************************ SOLUTION ENDS HERE ************************/
	
	
	
	
	
	/************************ TEMPLATE STARTS HERE *********************/
	
	public static void main(String []args) throws IOException {
		FastScanner in  = new FastScanner(System.in);
		PrintWriter out = 
				new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false); 
		solve(in, out);
		in.close();
		out.close();
	}    
	
	static class FastScanner{
		BufferedReader reader;
		StringTokenizer st;
		FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}	
		String next()
		{while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}		    
		st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
		String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}	    	  	
		int    nextInt()   {return Integer.parseInt(next());}
		long   nextLong()  {return Long.parseLong(next());}		
		double nextDouble(){return Double.parseDouble(next());}
		char   nextChar()  {return next().charAt(0);}
		int[]  nextIntArray(int n)         {int[] a= new int[n];   int i=0;while(i<n){a[i++]=nextInt();}  return a;}
		long[] nextLongArray(int n)        {long[]a= new long[n];  int i=0;while(i<n){a[i++]=nextLong();} return a;}	
		int[]  nextIntArrayOneBased(int n) {int[] a= new int[n+1]; int i=1;while(i<=n){a[i++]=nextInt();} return a;}	    	
		long[] nextLongArrayOneBased(int n){long[]a= new long[n+1];int i=1;while(i<=n){a[i++]=nextLong();}return a;}	    	
		void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}				
	}
	
	/************************ TEMPLATE ENDS HERE ************************/
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	public static int gcd(int a , int b) {
		if (b == 0) return 0;
		else {
			return a / b + gcd (b , a % b);
		}
	}

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

		while (testCase-- > 0) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n < m) {
				int temp = n;
				n = m;
				m = temp;
			}	

			int ans = gcd (n , m);
			System.out.println(ans);
		}
	}
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.io.*;
import java.util.*;

public class A {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	long f(int x, int y) {
		if (x == 0 || y == 0)
			return 0;
		if (x >= y) {
			return x / y + f(y, x % y);
		} else {
			return y / x + f(x, y % x);
		}
	}

	A() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int t = nextInt();
		while (t-- > 0) {
			int a = nextInt();
			int b = nextInt();
			out.println(f(a, b));
		}
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new A();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;

public class Task267A {

	public static void main(String... args) throws NumberFormatException,
			IOException {
		Solution.main(System.in, System.out);
	}

	static class Scanner {

		private final BufferedReader br;
		private String[] cache;
		private int cacheIndex;

		Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			cache = new String[0];
			cacheIndex = 0;
		}

		int nextInt() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return Integer.parseInt(cache[cacheIndex++]);
		}

		String next() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return cache[cacheIndex++];
		}

		void close() throws IOException {
			br.close();
		}

	}

	static class Solution {

		public static void main(InputStream is, OutputStream os)
				throws NumberFormatException, IOException {
			PrintWriter pw = new PrintWriter(os);
			Scanner sc = new Scanner(is);

			int n = sc.nextInt();

			while (n-- > 0) {
				int ai = sc.nextInt();
				int bi = sc.nextInt();
				int retVal = 0;

				while (ai > 0 && bi > 0) {
					if (ai > bi) {
						retVal += ai / bi;
						ai = ai % bi;
					} else {
						retVal += bi / ai;
						bi = bi % ai;
					}
				}
				pw.println(retVal);
			}

			pw.flush();
			sc.close();
		}
	}

}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a, b, min, max, result = 0, temp;
		while(n-->0){
			a = sc.nextInt();
			b = sc.nextInt();
			max = Math.max(a, b);
			min = Math.min(a, b);
			result = 0;
			while(true){
				result += max/min;
				if(max%min == 0){
					System.out.println(result);
					break;
				}
				/* take the min and the remainder as the previous min. */
				temp = max;
				max = min;
				min = temp%min;
			}
		}
		sc.close();
	}
	
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Subtractions {
    public static void main(String[] args) {
        InputReader r = new InputReader(System.in);
        int n = r.nextInt();
        while (n-- > 0) {
            int a = r.nextInt();
            int b = r.nextInt();
            int res = 0;
            while (a > 0 && b > 0) {
                if (a > b) {
                    int div = a / b;
                    a -= div * b;
                    res += div;
                } else {
                    int div = b / a;
                    b -= div * a;
                    res += div;
                }
            }
            System.out.println(res);
        }
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return 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());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.*;
import java.io.*;

public class Solution {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        s.nextLine();
        while(s.hasNext()) {
            int first = s.nextInt();
            int second = s.nextInt();
            System.out.println(calculate(first,second));
        }
    }
    
    public static int calculate(int first, int second) {
        int operations = 0;
        while(first != 0 && second != 0) {
            int temp;
            if(first < second) {
                temp = second/first;
                operations += temp;
                second -= (first*temp);
            }
            else {
                temp = first/second;
                operations += temp;
                first -= (second*temp);
            }
        }
        return operations;
    }
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.Arrays;
import java.util.Scanner;
public class ATestingRound5 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		while(T --> 0) {
			int a = in.nextInt();
			int b = in.nextInt();
			int count = 0;
			
			int[] arr = {a, b};
			Arrays.sort(arr);
			while(arr[0] != 0) {
				count += arr[1] / arr[0];
				arr[1] = arr[1] % arr[0];
				
				Arrays.sort(arr);
			}
			System.out.println(count);
		}
		in.close();
	}

}
/*
2
4 17
7 987654321
outputCopy
8
141093479
*/
// Problem: 267_A. Subtractions
// Time complexity: constant

import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		while (n-- > 0) {
			int a = in.nextInt();
			int b = in.nextInt();
			int k = 0;
			while (a != 0 && b != 0) {
				if (a > b) {
					int t = a / b;
					k += t;
					a = a - b * t;
				} else {
					int t = b / a;
					k += t;
					b = b - a * t;
				}
			}
			System.out.println(k);
		}

	}

}
// Problem: 267_A. Subtractions
// Time complexity: constant
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class S {
	public static void main (String[] args) {
		Scanner in=new Scanner(System.in);
		int t=in.nextInt();
		while(t--!=0)
		{
		    int a=in.nextInt();
		    int b=in.nextInt();
		    int min=Math.min(a,b);
		    int max=Math.max(a,b);
		    int res=0;
		    while(min!=0)
		    {
		        res=res+max/min;
		        int temp=min;
		        min=max%min;
		        max=temp;
		    }
		    System.out.println(res);
		}
	}
	
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.*;
public class substraction {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while (t>0) {
			long a=sc.nextLong();
			long b=sc.nextLong();
			int op=0;
			if (a>b) {
				while (a%b!=0) {
					op+=a/b;
					a=a%b;
					long c=b;
					b=a;
					a=c;					
				}
				op+=a/b;
			}
			else{
				while (b%a!=0) {
					op+=b/a;
					b=b%a;
					long c=a;
					a=b;
					b=c;					
				}
				op+=b/a;
			}
			
			
			System.out.println(op);
			t--;
		}

	}

}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.*;

public class Subtractions {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int tests = scan.nextInt();

		while (tests > 0) {

			tests--;

			int first = scan.nextInt();
			int second = scan.nextInt();

			int count = 0;
			while (first > 0 && second > 0) {
				
				if (first < second) {

					count += second / first;
					second = second % first;
				} else {
					
					count += first / second;
					first = first % second;
				}
			}
			
			System.out.println(count);
		}
	}
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.*;
public class subtractionn {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int t;
		t=in.nextInt();
		while(t!=0)
		{
			int a=in.nextInt();
			int b=in.nextInt();
			int total=0,neww=0;
			if(a%b==0)
			{
				System.out.println(a/b);
			}
			else if(b%a==0)
			{
				System.out.println(b/a);
			}
			else
			{
			while(a!=0 && b!=0)
			{
				if(a>b)
				{
					total=total+(a/b);
					a=a%b;
					if(a==0)
					{
						break;
					}
				}
				else if(b>a)
				{
					total=total+(b/a);
					b=b%a;
					if(b==0)
					{
						break;
					}
				}
				else
				{
					System.exit(0);
				}
			}
			System.out.println(total);
			}
		t--;
		}
	}
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.io.*;
import java.util.*;
import java.lang.*;
public class file{

     public static void main(String []args) {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      while(n-->0)
      {
          int a=sc.nextInt();
          int b=sc.nextInt();
          int ans=f(a,b);
          System.out.println(ans);
      }
     }
     public static int f(int a,int b)
     {
         if(a==0||b==0)
           return 0;
         if(a>b)
         {
             return a/b + f(b,a%b);
         }
         else
             return b/a + f(a,b%a);
     }
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException	{
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int qq = readInt();
		while(qq-- > 0)	{
			pw.println(solve(readInt(), readInt()));
		}
		pw.close();
	}

	public static int solve(int a, int b)	{
		if(a < b)	{
			return solve(b,a);
		}
		if(a%b == 0)	{
			return a / b;
		}
		return a/b + solve(b,a%b);
	}
	
	/* NOTEBOOK CODE */

	private static long readLong() throws IOException	{
		return Long.parseLong(nextToken());
	}

	private static double readDouble() throws IOException	{
		return Double.parseDouble(nextToken());
	}

	private static int readInt() throws IOException	{
		return Integer.parseInt(nextToken());
	}

	private static String nextToken() throws IOException	{
		while(st == null || !st.hasMoreTokens())	{
			if(!br.ready())	{
				pw.close();
				System.exit(0);
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.Scanner;

public class subtractions {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        
        while(n-->0){
            int a=sc.nextInt();
            int b=sc.nextInt();
            
            int c=0;
            while(a!=0 && b!=0){
                if(a>b){
                    int t=a;
                    a=b;
                    b=t;
                }
                c+=b/a;
                b=b%a;
            }
            System.out.println(c);
        }
    }
}
// Problem: 267_A. Subtractions
// Time complexity: constant

// @author Sanzhar
import java.io.*;
import java.util.*;
import java.awt.Point;

public class Template {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(in.readLine());
            } catch (Exception e) {
            }
        }
        return st.nextToken();
    }

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

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

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

    public void run() throws Exception {
        //in = new BufferedReader(new FileReader("input.txt"));
        //out = new PrintWriter(new FileWriter("output.txt"));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
        out.close();
        in.close();
    }

    public int sub(int a, int b) {
        int res = 0;
        while (b > 0) {
            res += a / b;
            int m = a % b;
            a = b;
            b = m;
        }
        return res;
    }

    public void solve() throws Exception {
        int n = nextInt();
        while (n-- > 0) {
            out.println(sub(nextInt(), nextInt()));
        }
    }

    public static void main(String[] args) throws Exception {
        new Template().run();
    }
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.io.*;
import java.util.*;

public final class Subtractions
{
    public static void main(String[] args)
    {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
		Solver solver = new Solver(in, out);

		solver.solve();
        in.close();
        out.flush();
        out.close();
    }

    static class Solver
    {
        int n;
        InputReader in;
        PrintWriter out;

		void solve()
		{
			n = in.nextInt();

			while (n-- > 0)
			{
				int a, b;

				a = in.nextInt();
				b = in.nextInt();

				int cnt = 0;

				while (a > 0 && b > 0)
				{
					if (a < b)
						a = swap(b, b = a);

					cnt += a / b;
					a -= b * (a / b);
				}

				out.println(cnt);
			}
		}

		int swap(int a, int b)
		{
			return a;
		}

        public Solver(InputReader in, PrintWriter out)
        {
        	this.in = in;
        	this.out = out;
        }

	}

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                } catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public void close()
        {
            try
            {
                stream.close();
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }

    }

}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.io.*;
import java.util.*;
public final class subtractions
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	
	static long solve(long a,long b)
	{
		if(a<=0 || b<=0)
		{
			return 0;
		}
		else
		{
			long max=Math.max(a,b),min=Math.min(a,b);
			long low=1,high=(long)(1e9);
			while(low<high)
			{
				long mid=(low+high)>>1,val=(min*mid),curr=max-val;
				if(curr<min)
				{
					high=mid;
				}
				else
				{
					low=mid+1;
				}
			}
			return low+solve(min,max-(low*min));
		}
	}
	
	public static void main(String args[]) throws Exception
	{
		int t=sc.nextInt();
		while(t>0)
		{
			long a=sc.nextLong(),b=sc.nextLong();
			out.println(solve(a,b));
			t--;
		}
		out.close();
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    while(n-->0){
	        long a=sc.nextLong(),b=sc.nextLong();
	        long ans=0,cur=0;
	        while(a>0 && b>0){
	            if(b>a)a=a+b-(b=a);
	            cur=(a/b);
	            ans+=cur;
	            a-=(cur*b);
	        }
	        System.out.println(ans);
	    }
	}
}
// Problem: 267_A. Subtractions
// Time complexity: constant
import java.util.Scanner;

public class Subtractions {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numberOfTests = scanner.nextInt();
        while (numberOfTests-- > 0) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int[] res = new int[1];
            compute(a, b, res);
            System.out.println(res[0]);
        }
    }

    private static void compute(int x, int y, int[] res) {
        if (x == 0 || y == 0) {
            return;
        }
        int tmp;
        if (x < y) {
            tmp = x;
            x = y;
            y = tmp;
        }
        res[0] += x / y;
        tmp = x % y;
        if (tmp == 0) {
            return;
        }
        x = y;
        y = tmp;
        compute(x, y, res);
    }
}