stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long



using namespace std;



ll n,a,b,p,q;



int main()

{

	scanf("%lld%lld%lld",&n,&a,&b);

	for(int i=1;i<n;i++)

	{

		scanf("%lld%lld",&p,&q);

		a=(a/p+(a%p!=0))*p;

		if(b<=a/p*q)b=a/p*q;

		else

		{

			b=(b/q+(b%q!=0))*q;

			a=b/q*p;

		}

	}

	printf("%lld",a+b);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<math.h>

#include<algorithm>

#define N 100010

using namespace std;

int main()

{

    int a,b,n;

    long long x1,x2,sum,ans,m;

    scanf("%d",&n);

    scanf("%d %d",&a,&b);

    x1=a,x2=b;

    for(int i=0;i<n-1;i++)

    {

        scanf("%d %d",&a,&b);

        sum=x1/a;

        if(x1%a!=0)

            sum++;

        ans=x2/b;

        if(x2%b!=0)

            ans++;

        m=max(sum,ans);

        x1=a*m,x2=b*m;

    }

    printf("%lld",x1+x2);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define pb push_back

typedef long long goo;

using namespace std;

goo read(){

    char ch;

    goo input = 0, num = 1;

    do{

        ch = getchar();

        if(ch == '-') num=-1;

    }

    while(ch < '0' or ch > '9');

    while(ch >= '0' and ch <= '9'){

        input = input * 10 + ch - '0';

        ch = getchar();

    }

    return input * num;

}

goo gcd(goo x,goo y)

{

	if(x%y==0) return y;

	else return (gcd(y,x%y));

}

int main()

{

    goo n=read(),T=1,A=1;

    for(int i=1;i<=n;i++){

        goo t=read(),a=read();

        goo num=max((T+t-1)/t,(A+a-1)/a);

        T=t*num,A=a*num;

    }

    goo res=T+A;

    cout<<res;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;



int main(){

    int n;

    scanf("%d",&n);

    long long t = 1, a = 1;

    int T, A;

    for(int i=0;i<n;i++){

        scanf("%d%d",&T,&A);

        long long tmp = max(max(t%T?t/T+1:t/T,a%A?a/A+1:a/A),1ll);

        t = tmp*T;

        a = tmp*A;

    }

    printf("%lld\n",t+a);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>



using namespace std;



const long long MAXN = 1e4+10;

long long Ti[MAXN],Ai[MAXN];



int main()

{

    ios::sync_with_stdio(false);

    long long N;

    cin >> N;

    for(long long i = 0 ; i < N ; i++)

    {

        cin >> Ti[i] >> Ai[i];

    }

    long long A,B;

    A = 1,B=1;

    for(long long i = 0 ; i < N ; i++)

    {

        long long beiA = A/Ti[i];

        if(A%Ti[i] != 0){beiA++;};

        long long beiB = B/Ai[i];

        if(B%Ai[i] != 0){beiB++;};

        long long L = min(beiA,beiB);

        long long R = max(beiA,beiB);

        long long bei= L;

        while( L <= R)   //如果查找区间不为空就继续查找

        {

            long long mid = L+(R-L)/2; //取查找区间正中元素的下标

            //cout<<" L = "<<L<<" R = "<<R<<" mid = "<<mid<<endl;

            if(Ti[i]*mid>=A && Ai[i]*mid>=B) {//如果成立就再小一点

                bei = mid;

                R = mid - 1;

            }

            else{

                L = mid+1;

            }

        }

        A = bei*Ti[i];

        B = bei*Ai[i];

    }

    cout<<A+B<<endl;

    return 0;

}




// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;



int main(){

    int n;

    scanf("%d",&n);

    long long t = 1, a = 1;

    int T, A;

    for(int i=0;i<n;i++){

        scanf("%d%d",&T,&A);

        long long tmp = max(max(t%T?t/T+1:t/T,a%A?a/A+1:a/A),1ll);

        t = tmp*T;

        a = tmp*A;

    }

    printf("%lld\n",t+a);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//#include <bits/stdc++.h>

#include <iostream>

#include <algorithm>

#include <iomanip>

#include <cmath>

#include <string>

#include <string.h>

#include <cstdlib>

#include <climits>

#include <cstdio>

#include <vector>

#include <bitset>

#include <set>

#include <map>

#include <queue>

#include <stack>

#define PI 3.14159265

#define base 27

#define  fi first

#define  se second



#define TASK "Traveling"



using namespace std;

typedef long long lli;

typedef long double lb;

typedef unsigned long long ull;

typedef pair<int,int> pa;

const long long mod =1e9+7;

const long long oo=1e15+7;

const int maxn=1e6+1;

const int maxN=1e3+1;



/******************************************************************************

 *                                                                            *

 *                       Be a warrior not a worrier!! =)))                    *

 *                                                                            *

 *                                                                            *

 *****************************************************************************/

 int n;

 int t[maxn],x[maxn],y[maxn];







void in()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    freopen(TASK".inp","r",stdin);

    freopen(TASK".out","w",stdout);

}



void solve()

{

      cin>>n;

      for(int i=1;i<=n;i++)

      {

            cin>>t[i]>>x[i]>>y[i];

            if(t[i]<x[i]+y[i])

            {

                  cout<<"No";

                  exit(0);

            }

            else

            {

                  if(abs(x[i]-y[i])%2!=(t[i]%2))

                  {

                        cout<<"No";

                        exit(0);

                  }

            }

      }

      cout<<"Yes";





}



int main()

{

    //in();

    solve();



}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int t[100010],x[100010],y[100010];

int main()

{

    int n,sum=0;

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

        scanf("%d%d%d",&t[i],&x[i],&y[i]);

    for(int i=1;i<=n;i++)

    {

        sum=x[i]+y[i]-x[i-1]-y[i-1];

        if((t[i]-t[i-1])<sum)

        {

            printf("No\n");

            return 0;

        }

        if((sum-(t[i]-t[i-1]))%2)

        {

            printf("No\n");

            return 0;

        }

    }

    printf("Yes\n");

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//27/8

#include<bits/stdc++.h>

using namespace std;



int n,x,y,t,sx,sy,tp;



int main()

{

    cin>>n;



    sx=0;sy=0;tp=0;



    int chk=0;



    for(int i=1;i<=n;++i)

    {

        cin>>t>>x>>y;



        if(chk)continue;



        int bc=t-tp;



        if((abs(x-sx)>bc) || abs(y-sy)>bc || abs(x-sx+y-sy)>bc || ((abs(x-sx+y-sy))%2 != bc%2))chk=1;



        sx=x;

        sy=y;

        tp=t;

    }



    if(chk)cout<<"No";



    else cout<<"Yes";

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int t[100010],x[100010],y[100010];

int main()

{

    int n,sum=0;

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

        scanf("%d%d%d",&t[i],&x[i],&y[i]);

    for(int i=1;i<=n;i++)

    {

        sum=x[i]+y[i]-x[i-1]-y[i-1];

        if((t[i]-t[i-1])<sum)

        {

            printf("No\n");

            return 0;

        }

        if((sum-(t[i]-t[i-1]))%2)

        {

            printf("No\n");

            return 0;

        }

    }

    printf("Yes\n");

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define up(i,a,b) for(int i=a;i<=b;i++)

#define down(i,a,b) for(int i=a;i>=b;i--)

#define rep(i,a,b) for(int i=a;i<b;i++)

#define repd(i,a,b) for(int i=a-1;i>=b;i--)

#define CL(x) (x<<1)

#define CR(x) (x<<1)+1

#define pb push_back

#define bit1(x) __builtin_popcount(x)



using namespace std;



typedef long long ll;

typedef pair<int,int> pii;



template<typename T> inline void _read(T &x){

    char ch; x=0; bool neg=false;

    for(ch=getchar();ch<'0'||ch>'9';ch=getchar())

        if(ch=='-') neg=true;

    for(;ch>='0'&&ch<='9';ch=getchar()) x=10*x+ch-'0';

    if(neg) x=-x;

}

#define read(a) _read(a)

#define Read(a,b) _read(a),_read(b)



const int maxn=1e5+7;

const int maxS=(1<<6);

const ll mod=1e9;

const int inf=1e9+7;

const ll linf=1e16+9;



int n,t[maxn],kq;

struct Neko{

    int x,y;

}a[maxn];



inline void Enter(){

    cin>>n;

    up(i,1,n) cin>>t[i]>>a[i].x>>a[i].y;

}



inline int dis(Neko x,Neko y){

    return abs(x.x-y.x)+abs(x.y-y.y);

}



inline void Solve(){

    up(i,1,n){

        int Time=t[i]-t[i-1];

        if(dis(a[i],a[i-1])%2 == Time%2 && dis(a[i],a[i-1])<=Time) kq++;

    }

    if(kq!=n) cout<<"No";

    else cout<<"Yes";

}



int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL),cout.tie(NULL);

    //freopen("TEST.INP","r",stdin);

    //freopen("TEST.OUT","w",stdout);



    Enter();

    Solve();



    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int t[100010],x[100010],y[100010];

int main()

{

    int n,sum=0;

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

        scanf("%d%d%d",&t[i],&x[i],&y[i]);

    for(int i=1;i<=n;i++)

    {

        sum=x[i]+y[i]-x[i-1]-y[i-1];

        if((t[i]-t[i-1])<sum)

        {

            printf("No\n");

            return 0;

        }

        if((sum-(t[i]-t[i-1]))%2)

        {

            printf("No\n");

            return 0;

        }

    }

    printf("Yes\n");

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <set>

#include <map>

#include <cassert>

#include <queue>

#include <vector>

#define CL(a) memset(a,0,sizeof(a))

#define cl(a,b) memset(a,(b),sizeof(a))

#define For(i,a,b) for(int i=a;i<=b;i++)

#define _for(i,a,b) for(int i=a;i<b;i++)

#define LL long long 

using namespace std;

const int maxn = 1e5 + 100;

struct Point{

	int t,x,y;

	bool operator < (const Point& p)const

	{

		return t<p.t;

	}

}a[maxn]; 

int main()

{

	//freopen("in.txt","r",stdin);

    int n;

	scanf("%d",&n);

	a[0].t = a[0].x = a[0].y = 0;

	for(int i=1;i<=n;i++)

	{

		scanf("%d%d%d",&a[i].t,&a[i].x,&a[i].y);	

	}   

	sort(a,a+n+1);

	int flag = true;

	for(int i=1;i<=n&&flag;i++)

	{

		int tt = a[i].t - a[i-1].t;

		int dis = abs(a[i].x-a[i-1].x)+abs(a[i].y-a[i-1].y);

		if(dis>tt) flag = 0;

		if((tt-dis)%2) flag = 0;

	}

	if(flag) printf("Yes\n");

	else printf("No\n");









        



	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int t[100010],x[100010],y[100010];

int main()

{

    int n,sum=0;

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

        scanf("%d%d%d",&t[i],&x[i],&y[i]);

    for(int i=1;i<=n;i++)

    {

        sum=x[i]+y[i]-x[i-1]-y[i-1];

        if((t[i]-t[i-1])<sum)

        {

            printf("No\n");

            return 0;

        }

        if((sum-(t[i]-t[i-1]))%2)

        {

            printf("No\n");

            return 0;

        }

    }

    printf("Yes\n");

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define mp make_pair

#define f first

#define s second

#define int long long

#define double long double

typedef long long ll;

typedef pair<int,int> pii;

#define MAXN 1123456

#define INF LLONG_MAX

#define MOD 32416187567

#define cte 10002

#define MAX ULLONG_MAX



pair<int,pii> v[112345];





int32_t main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.precision(11);

    cout.setf(ios::fixed);



    int n;

    cin>>n;



    for(int i=0;i<n;i++){

        cin>>v[i].f>>v[i].s.f>>v[i].s.s;

    }



    sort(v,v+n);



    int dis=abs(v[0].s.s)+abs(v[0].s.f);

    //cout<<dis<<endl;

    if(dis>v[0].f || (v[0].f-dis)%2==1){

        cout<<"No"<<endl;

        return 0;

    }





    for(int i=1;i<n;i++){

        int dis=abs(v[i].s.s-v[i-1].s.s)+abs(v[i].s.f-v[i-1].s.f);

        //cout<<dis<<endl;

        if(dis>v[i].f-v[i-1].f || ((v[i].f-v[i-1].f)-dis)%2==1){

            cout<<"No"<<endl;

            return 0;

        }

    }



    cout<<"Yes"<<endl;

    return 0;



}










// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



int main()

{

    int n,x,y,t,xx = 0,yy = 0,tt = 0,flag = 1;

    scanf("%d",&n);

    while(n--)

    {

        scanf("%d%d%d",&t,&x,&y);

        if(abs(x-xx)+abs(y-yy)>(t-tt) || (abs(x-xx)+abs(y-yy))%2 != (t-tt)%2)

            flag = 0;

        xx = x;

        yy = y;

        tt = t;

    }

    if(flag)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



const int MAX = 112345;



struct point {

    int x, y, t;

    point(int X = 0, int Y = 0, int T = 0):

        x(X), y(Y), t(T) {}

    

    bool operator < (const point ot) const {

        return (t < ot.t);

    }

};



bool can(point cur, point targ) {

    int D = abs(cur.x - targ.x) + abs(cur.y - targ.y);

    int T = targ.t - cur.t;

    //printf("Time %d --- Dist %d\n", T, D);

    if (T >= D && ((T - D) % 2 == 0)) return true;

    return false;

}



int N;

int main() {

    point cur = point(0, 0, 0);

    scanf("%d", &N);

    for (int i = 0; i < N; i++) {

        point targ;

        scanf("%d%d%d", &targ.t, &targ.x, &targ.y);

        if (!can(cur, targ)) {

            puts("No");

            return 0;

        }

        cur = targ;

    }



    puts("Yes");

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



int main()

{

    int n,x,y,t,xx = 0,yy = 0,tt = 0,flag = 1;

    scanf("%d",&n);

    while(n--)

    {

        scanf("%d%d%d",&t,&x,&y);

        if(abs(x-xx)+abs(y-yy)>(t-tt) || (abs(x-xx)+abs(y-yy))%2 != (t-tt)%2)

            flag = 0;

        xx = x;

        yy = y;

        tt = t;

    }

    if(flag)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
// i will show you da wae

#include <bits/stdc++.h>

#define mp make_pair

#define pb push_back

#define fill(x,v) memset(x,v,sizeof(x))

#define FOR(i,a,b) for(int i = int(a); i < int(b); ++i)

#define trace(x) cout << #x << " = " << x << endl

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef long long ll;

typedef pair<int,int> ii;



int manh(int a, int b, int c, int d){

	return abs(a-c) + abs(b-d);

}



int main(){

	    

	int n,t,a,b;

	int x = 0, y = 0, prevt = 0;

	cin >> n;

	FOR(i,0,n){

		cin >> t >> a >> b;

		int dist = manh(x,y,a,b);

		int dif = t - dist - prevt;

		x = a, y = b, prevt = t;

		if(!(dif >= 0 and ((dif%2) == 0) )){

			puts("No");

			return 0;

		}

	}

	puts("Yes");

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



int main()

{

    int n,x,y,t,xx = 0,yy = 0,tt = 0,flag = 1;

    scanf("%d",&n);

    while(n--)

    {

        scanf("%d%d%d",&t,&x,&y);

        if(abs(x-xx)+abs(y-yy)>(t-tt) || (abs(x-xx)+abs(y-yy))%2 != (t-tt)%2)

            flag = 0;

        xx = x;

        yy = y;

        tt = t;

    }

    if(flag)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;



const int maxn = 1e5 + 10;



int n;

int x[maxn], y[maxn], t[maxn];



bool solve() {

	for(int i = 1; i <= n; ++i) {

		int dx = abs(x[i] - x[i - 1]);

		int dy = abs(y[i] - y[i - 1]);



		if(dx + dy > t[i] - t[i - 1]) return false;

		if(((t[i] - t[i - 1]) - (dx + dy)) % 2) return false;

	}



	return true;

}



int main() {

	cin.sync_with_stdio(false);

	

	cin >> n;

	

	for(int i = 1; i <= n; ++i)

		cin >> t[i] >> x[i] >> y[i];

	

	if(solve()) cout << "Yes\n";

	else cout << "No\n";



	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



int main()

{

    int n,x,y,t,xx = 0,yy = 0,tt = 0,flag = 1;

    scanf("%d",&n);

    while(n--)

    {

        scanf("%d%d%d",&t,&x,&y);

        if(abs(x-xx)+abs(y-yy)>(t-tt) || (abs(x-xx)+abs(y-yy))%2 != (t-tt)%2)

            flag = 0;

        xx = x;

        yy = y;

        tt = t;

    }

    if(flag)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

const long long maxn=1e4+100;

using namespace std;

long long n,m,k,t,a[maxn],x,y,xi,yi,ti;bool le;

int main()

{

    scanf("%lld",&n);

    x=y=0;

    t=0;

    for(int i=1;i<=n;++i)

    {

        scanf("%lld%lld%lld",&ti,&xi,&yi);

        if(abs(xi-x)+abs(yi-y)>ti-t)

        {

            le=1;

        }

        if(   (ti-t -  (abs(xi-x)+abs(yi-y) ))%2==1)

        {

            le=1;

        }

        t=ti;

        x=xi;

        y=yi;

    }

    if(le)

        printf("No\n");

    else

        printf("Yes\n");

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



int main()

{

    int n,x,y,t,xx = 0,yy = 0,tt = 0,flag = 1;

    scanf("%d",&n);

    while(n--)

    {

        scanf("%d%d%d",&t,&x,&y);

        if(abs(x-xx)+abs(y-yy)>(t-tt) || (abs(x-xx)+abs(y-yy))%2 != (t-tt)%2)

            flag = 0;

        xx = x;

        yy = y;

        tt = t;

    }

    if(flag)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <stdio.h>

#include <bits/stdc++.h>

using namespace std;

#define pb(x) push_back(x)

#define mp(x, y) make_pair(x, y)

typedef long long ll;

typedef pair <int, int> pii;

typedef pair <long long, long long> pll;



int main() {

	int n, x, y, t, px = 0, py = 0, pt = 0, ok = 1;

	scanf("%d", &n);

	for (int i = 0; i < n && ok; i++) {

		scanf("%d %d %d", &t, &x, &y);

		int dis = abs(x-px) + abs(y-py);

		int tme = t-pt;

		if (dis > tme or dis%2 != tme%2) ok = 0;

		px = x;

		py = y;

		pt = t;

	}

	printf(ok ? "Yes\n" : "No\n");

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cmath>

#include <cstdio>

using std::abs;

int main(void)

{

	int x=0,y=0,nx,ny,dx,dy;

	int t=0,nt,dt,d,N;

	bool winFlag=true;

	scanf("%d",&N);

	while(N--)

	{

		scanf("%d%d%d",&nt,&nx,&ny);

		dx=abs(nx-x);

		dy=abs(ny-y);

		y=ny;

		x=nx;



		dt=nt-t;

		t=nt;



		if(dx+dy>dt ||(dx+dy)%2 !=dt%2)

		{

			winFlag=false;

		}

	

	}

	if(winFlag)

		printf("Yes\n");

	else

		printf("No\n");





}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;



main(){

  int n,s;

  while(cin>>n>>s && n){

    int r[101]={0};

    for(int i=0;i<n;i++){

      int tmp;cin>>tmp;r[tmp]++;

    }

    int ans = 0;

    for(int i=0;i<101;i++){

      if (i+i > s && r[i])ans += (r[i]*(r[i]-1))/2;

      for(int j=i+1;j<101;j++){

	if (i+j > s && r[i] && r[j])ans += r[i]*r[j];

      }

    }

    cout << ans << endl;

  }

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;



main(){

  int n,s;

  while(true){

    scanf("%d%d",&n,&s);

    if (n==0)break;

    int r[101]={0};

    for(int i=0;i<n;i++){

      int tmp;scanf("%d",&tmp);r[tmp]++;

    }

    int ans = 0;

    for(int i=0;i<101;i++){

      if (i+i > s && r[i])ans += (r[i]*(r[i]-1))/2;

      for(int j=i+1;j<101;j++){

	if (i+j > s)ans += r[i]*r[j];

      }

    }

    printf("%d\n",ans);

  }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cmath>

#include <vector>

#include <map>

#include <stack>

#include <queue>

#include <algorithm>

#include <set>



#define FOR(i,a,b) for(int i=(a);i<(b);i++)

#define REP(i,j) FOR(i,0,j)

#define mp std::make_pair



const int INF = 1 << 24;

const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};



typedef unsigned long long ull;

typedef std::pair<int,int> P;



int main(){

    int n, S;

    int r[10000];

    while(std::cin >> n >> S, n){

        REP(i, n){

            std::cin >> r[i];

        }

        std::sort(r, r+n);

        int res = 0;

        for(int i=0;i+1<n;i++){

            auto it = std::upper_bound(r+i+1, r+n, S-r[i]);

            res += std::distance(it, r+n);

        }

        std::cout << res << std::endl;

    }

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

int main(){int n,S,r[10000];while(scanf("%d%d",&n,&S),n){for(int i=0;i<n;i++){scanf("%d",r+i);}std::sort(r,r+n);int res = 0;for(int i=0;i+1<n;i++){res += std::distance(std::upper_bound(r+i+1,r+n,S-r[i]),r+n);}printf("%d\n",res);}}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;



int main(){

  int n,s;

  int r[20100];



  while(cin>>n >> s , n||s){

    for(int i=0;i<n;i++)cin >> r[i];



    sort(r,r+n);

    int ans = 0;

    for(int i=0;i<n;i++)

      ans += n - (int)(upper_bound(r+i+1,r+n,s-r[i]) - r);

    cout << ans << endl;

  }

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>



int main(){

  int n,s,r[20200];

  while(scanf("%d%d",&n,&s),n){

    for(int i=0;i<n;i++)scanf("%d",r+i);

    std::sort(r,r+n);

    int ans = 0;

    for(int i=0;i<n;i++)ans += n - (std::upper_bound(r+i+1,r+n,s-r[i]) - r);

    printf("%d\n",ans);

  }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;



int main(){

  int n,s,r[20200];



  while(cin >> n >> s,n){

    for(int i=0;i<n;i++)cin >> r[i];

    sort(r,r+n);



    int ans = 0;

    for(int i=0;i<n;i++){

      ans += n - (upper_bound(r+i+1,r+n,s-r[i]) - r);

    }

    cout << ans << endl;

  }

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>



int main(){

  int n,s,r[20200];

  while(scanf("%d%d",&n,&s),n){

    for(int i=0;i<n;i++)scanf("%d",r+i);

    std::sort(r,r+n);

    int ans = 0;

    for(int i=0;i<n;i++)ans += n - (std::upper_bound(r+i+1,r+n,s-r[i]) - r);

    printf("%d\n",ans);

  }

}

// Fastest known solution for this problem: