Help me in solving ASM120 problem

include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T–) {
int X, Y;
cin >> X >> Y;

    while (X != 0) {
        if (X > Y) {
            swap(X, Y);
        } else {
            X = Y - X;
            Y = X; 
        }
    }
    
    cout << Y << endl;
}
return 0;

}

can you give problem link

As the value of x and y can be upto 10^9
doing this in while loop will give tle
what we are finding is the gcd of x and y
you can directly use builtin function (gcd(x,y))
or {
while(x%y!=0){
int z=x%y;
x=y;
y=z;
}
this will solve your problem

Test cases that gives tle are like
1000000000 1 doing this in while loop will take 10^9 operation which is greater than 1 sec