akhauriyash/Code-Regression huggingface dataset:
///
// File:  alds1_6_d.cpp
// Author: ymiyamoto
//
// Created on Thu Oct 12 23:39:32 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;
#define SIZE 10000

static vector<uint32_t> array;
static uint32_t T[SIZE + 1];

static uint32_t solve(uint32_t min_val)
{
  uint32_t count = 0;

  vector<bool> V(array.size(), false);
  vector<uint32_t> B(array);

  sort(B.begin(), B.end());

  for (uint32_t i = 0; i < array.size(); i++) {
    T[B[i]] = i;
  }

  for (uint32_t i = 0; i < array.size(); i++) {
    if (V[i]) continue;
    uint32_t cur = i;
    uint32_t S = 0;
    uint32_t m = UINT32_MAX;
    uint32_t an = 0;
    while (true) {
      V[cur] = true;
      an++;
      uint32_t v = array[cur];
      m = min(v, v);
      S += v;
      cur = T[v];
      if (V[cur]) break;
    }
    count += min(S + (an - 2) * m, m + S + (an + 1) * min_val);
  }

  return count;
}

int32_t main()
{
  uint32_t n;
  cin >> n;

  uint32_t s = UINT32_MAX;
  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    array.push_back(val);
    s = min(s, val);
  }

  uint32_t count = solve(s);

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3152
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return
#B
def B():

    return

#C
def C():
    n = I()
    s = S()
    for i in range(2*n):
        s[i] = ord(s[i])-96
    for i in range(n>>1):
        s[i],s[n-i-1] = s[n-i-1],s[i]
    k = 27
    m = 1<<n
    p = [1<<j for j in range(n)]
    d = defaultdict(lambda : 0)
    for i in range(m):
        r = 0
        b = 0
        for j in range(n):
            if i&p[j]:
                r *= k
                r += s[j]
            else:
                b *= k
                b += s[j]
        d[(r,b)] += 1
    ans = 0
    for i in range(m):
        r = 0
        b = 0
        for j in range(n):
            if i&p[j]:
                r *= k
                r += s[j+n]
            else:
                b *= k
                b += s[j+n]
        ans += d[(r,b)]
    print(ans)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 113884
from collections import defaultdict
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
cnt = [defaultdict(int) for i in range(3)]
for i in range(N):
    s = list(map(int, input().split()))
    for j in range(N):
        t = (i+j+2) % 3
        cnt[t][s[j]-1] += 1
ans = 10**9
for x in range(C):
    for y in range(C):
        for z in range(C):
            if x == y or y == z or z == x: continue
            tmp = 0
            for i, c in enumerate([x, y, z]):
                for key in cnt[i]:
                    tmp += D[key][c] * cnt[i][key]
            ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 46300
#include <iostream>

using namespace std;

int abs(int n)
{
    return (n > -n) ? n : -n;
}

int main()
{
    int w, h, n; cin >> w >> h >> n;

    int a, b; cin >> a >> b;

    int cnt = 0;

    for(int i = 1; i < n; ++i) {
        int tox, toy; cin >> tox >> toy;
        
        if ((a < tox && b < toy) || (a > tox && b > toy)) {
            cnt += max(abs(a-tox), abs(b-toy));
        } else {
            cnt += abs(a-tox) + abs(b-toy);
        }
        
        a = tox, b = toy;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;

const int nmax=40,abmax=10,inf = 1000000;

int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main(void){
    int n,ma,mb;
    cin >> n >> ma >> mb;
    for(int i=0;i<n;++i){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 0; i <= n; ++i){
        for(int ca = 0; ca <= nmax*abmax; ++ca){
            for(int cb = 0; cb <= nmax*abmax; ++cb){
                dp[i][ca][cb]=inf;
            }
        }
    }
    dp[0][0][0]=0;

    for(int i = 0; i < n; ++i){
        for(int ca = 0; ca <= nmax*abmax; ++ca){
            for(int cb = 0; cb <= nmax*abmax; ++cb){
                if(dp[i][ca][cb]==inf) continue;
                dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
            }
        }
    }

    int ans=inf;
    for(int ca = 1; ca <= nmax*abmax; ++ca){
        for(int cb = 1; cb <= nmax*abmax; ++cb){
            if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
        }
    }

    if(ans==inf) ans=-1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25984
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return c*c;
	else
		return c*c*a;
}

int main()
{
    boost
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n+1),b(m+1);
    for(ll i=1;i<=n;i++) {
        cin >> a[i];
        a[i]+=a[i-1];
    }
    for(ll i=1;i<=m;i++) {
        cin >> b[i];
        b[i]+=b[i-1];
    }
    ll ans=0;
    for(ll i=1;i<=n;i++) {
        if( a[i]<=k )   {
            ll rem=k-a[i];
            ll c=upper_bound(all(b),rem)-b.begin();
            ans=max(ans,i+c-1);
        }
    }
    for(ll i=1;i<=m;i++) {
        if( b[i]<=k )   {
            ll rem=k-b[i];
            ll c=upper_bound(all(a),rem)-a.begin();
            ans=max(ans,i+c-1);
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 6368
#include <iostream>

using namespace std;

int main() {
    int seq[1000001];
    int x, y;
    while (cin >> x >> y, x|y) {
        fill_n((int *)seq, 1000001, -1);
        int count = -1;
        while (x / y == 0) {
            x *= 10;
            count++;
            seq[x/10] = count;
        }
        while (1) {
            while (x / y != 0)
                x -= y;
            count++;
            if (~seq[x]) {
                printf("%d %d\n", seq[x], count-seq[x]);
                break;
            }
            seq[x] = count;
            if (x == 0) {
                printf("%d %d\n", seq[x], 0);
                break;
            }
            x *= 10;
        }
    }
    return 0;
}

Measured memory_bytes: 5040
//https://atcoder.jp/contests/abc143/tasks/abc143_c

#include<iostream>
#include<string>

using namespace std;

int main(){
    int n;
    string words;

    cin >> n;
    cin >> words;

    string com_words = {};

    while(true){

        string tmp_words = words.substr(0,1);

        for(int i = 0; i < words.size()- 1; i++){
            if(words.substr(i,1) != words.substr(i+1,1)){
                tmp_words += words.substr(i+1,1);
            }
        }

        com_words = tmp_words;

        if(words.size() == com_words.size()){
            break;
        }else{
            words = com_words;
        }
    }

    cout << words.size();

    return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){

    int k,n;
    cin>>k>>n;
    int F,L;
    int M=0;
    int sum=0;
    int a,y;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a);
        if(i==0)
        {
             F=a;
             y=a;
        }
        if(i==n-1)
            L=a;
        if(i>0)
        {
            sum+=a-y;
            M=max(M,a-y);
            y=a;
        }
    }
    sum+=F+k-L;
    M=max(M,F+k-L);
    printf("%d",sum-M);
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
using namespace std;

int main() {
  int n;
  vector<long long> A;
  cin >> n;
  REP(i, n) {
    int tmp;
    cin >> tmp;
    A.pb(tmp);
  }
  sort(all(A), greater<int>());
  long long pre = 0, hol = 0, ver = 0;
  for(const auto a : A) {
    if(hol && ver) { break; }
    else if(pre == a) {
      hol ? (ver = a) : (hol = pre);
      pre = 0;
    }
    else { pre = a; }
  }
  cout << hol * ver << endl;
  return 0;
}


Measured memory_bytes: 1400
win = ["First", "Second"]
S = input()
if len(S) % 2 != 0:
    if S[0] == S[-1]:
        ans = 1
    else:
        ans = 0
else:
    if S[0] == S[-1]:
        ans = 0
    else:
        ans = 1
print(win[ans])


Measured memory_bytes: 3316
@inf=10000000000
def mp(s)
  as=s.count('a')
  bs=s.count('b')
  cs=s.count('c')
  return @inf if as==0||bs==0||cs==0
  asum,bsum,csum=0,0,0
  (0..(@n-1)).each do |i|
    asum+=@l[i] if s[i]=='a'
    bsum+=@l[i] if s[i]=='b'
    csum+=@l[i] if s[i]=='c'
  end
  return (@a-asum).abs+(@b-bsum).abs+(@c-csum).abs+10*(as+bs+cs-3)
end

def dfs(s)
  return mp(s) if s.size == @n
  ret1=dfs(s+"a")
  ret2=dfs(s+"b")
  ret3=dfs(s+"c")
  ret4=dfs(s+"d")
  return [ret1, ret2, ret3, ret4].min
end

@n,@a,@b,@c=gets.split(' ').map(&:to_i)
@l=Array.new(@n){gets.to_i}
puts dfs("")

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif

    ll n;
    cin>>n;
    ll a[n];
    inp_arr(a,n);
    sort(a,a+n);

    vl v;
    v.pb(a[n-1]);
    ll ans = 0;
    ll k = 0;
    for(int i=n-2;i>=0;--i) {
        ans += v[k];
        v.pb(a[i]);
        v.pb(a[i]);
        ++k;
    }
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 8984
using System;

public class Program{
    public static void Main(){
        string[] input=Console.ReadLine().Split(' ');
        int N=int.Parse(input[0]);
        int A=int.Parse(input[1]);
        int B=int.Parse(input[2]);
        int sumA=A*N;
        int ans=0;
        if(sumA>=B){
            ans=B;
        }else{
            ans=sumA;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let h: i32 = read();
    let w: i32 = read();

    let ans = (n - h + 1) * (n - w + 1);

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4476
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 3e5 + 5;
int a[MaxN];
int main(){
	int n;
	cin>>n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		cin>>a[i];
		ans += a[i];
	}
	cout<<ans-n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    string s;
    int n;

    cin >> n >> s;

    //RGBの選択の総和を求める
    //R x G x B (R,G,Bの個数の積)
    vector<int> a(n);
    rep(i, n){
        if(s[i] == 'R') {a[i] = 0;}
        if(s[i] == 'G') {a[i] = 1;}
        if(s[i] == 'B') {a[i] = 2;}
    }

    vector<ll> num(3);
    rep(i, n){
        num[a[i]]++;
    }

    ll All = num[0] * num[1] * num[2];

    rep(j, n)rep(i,j){
        int k = j + (j - i);
        if(k < n){
            if(a[i] == a[j]) continue;
            if(a[i] == a[k]) continue;
            if(a[j] == a[k]) continue;

            All--;
        }
    }

    cout << All << endl;


    return 0;
}

Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();

    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn next_indices(S: &str) -> Vec<Vec<usize>> {
    let len = S.len();
    let mut result: Vec<Vec<usize>> = vec![vec![0; 26]; len+2];
    let s_slice = S.as_bytes();
    for i in (0..len).rev() {
        for j in 0..26 {
            result[i][j] = result[i+1][j];
        }

    }
    result
}

fn main() {
    let mut vec: Vec<usize> = Vec::new();
    for i in 0..5 {
        vec.push(read::<usize>());
    }
    let k: usize = read();
    let mut flag = true;
    let min = &vec.iter().min().unwrap().clone();
    for x in vec {
        if x - *min > k {
            flag = false;
            break;
        }
    }
    if flag {
        println!("Yay!");
    }
    else{
        println!(":(");
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//
 
int N;
string S;
 
int main() {
	cin >> N >> S;
	
	int ans = INF;
	int l = 0, r = 0;
	REP(i, S.size()) if (S[i] == 'E') r++;
	
	REP(i, S.size()) {
		if (S[i] == 'E') r--;
		chmin(ans, l + r);
		if (S[i] == 'W') l++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 900
loop do
    s = gets.chomp
    break if s == "\#"
    dp = Array.new(s.length).map{Array.new(2,Float::INFINITY)}
    dp[0][0] = dp[0][1] = 0
    s = s.split(//).map(&:to_i)
    s.each_with_index do |c,i|
        break if i == s.length - 1
        if (c - 1) % 3 > (s[i + 1] - 1) % 3
            dp[i+1][0] = [dp[i][0] + 1, dp[i][1]].min
        elsif (c - 1) % 3 < (s[i + 1] - 1) % 3
            dp[i+1][1] = [dp[i][0], dp[i][1] + 1].min
        else
            dp[i+1][0] = [dp[i][0] + 1, dp[i][1]].min
            dp[i+1][1] = [dp[i][0], dp[i][1] + 1].min
        end
    end
    p dp[s.length - 1].min
end

Measured memory_bytes: 35784
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	bool leap[3000];
	rep(i, 3000) {
		if (i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)) leap[i] = true;
		else leap[i] = false;
	}
	int nCase = 0;
	for (int a, b; cin >> a >> b, (a | b) != 0; ) {
		if (nCase) cout << endl;
		bool exist = false;
		REP(i, a, b) {
			if (leap[i]) {
				cout << i << endl;
				exist = true;
			}
		}
		if (!exist) cout << "NA" << endl;
		nCase++;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
//vll a;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> x >> y;
	x--; y--;
	if(x==0) x=13;
	if(y==0) y=13;

	if(x > y) cout<<"Alice";
	else if(y > x) cout<<"Bob";
	else cout<<"Draw"; 
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int x[32], k, ans=0;
  while(n != 0)
    {
      x[0] = 1, x[1] = 1;
      for(k=1;k<=n;k++)
        {
          if(k==2) x[k] = 2;
          if(k>=3) x[k] = x[k-1] + x[k-2] + x[k-3];
        }
      ans = x[n] / 3650;
      if(x[n] % 3650  > 0) ans++;
      printf("%d\n", ans);
      scanf("%d", &n);
    }
  return 0;
}

Measured memory_bytes: 600
#include <cstdio>

int main() {
    int N, H, W, A, B, count=0;
    scanf("%d %d %d", &N, &H, &W);
    for (int i=0; i<N; i++) {
        scanf("%d %d",&A,&B);
        if (A >= H && B >= W) count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
n = list(map(int,input().split()))
m= []
mm= []
nuke = []
for x in range(n[1]):
    m.append(int(input()))
    mm.extend(list(map(int,input().split())))

for i in range(n[0]):
    nuke.append(i+1)

mn = list(set(mm))

for l in range(len(mn)):
    if mn[l] in nuke:
        nuke.remove(mn[l])

print(len(nuke))

Measured memory_bytes: 67384
from itertools import combinations
n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0
for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
print(count)

Measured memory_bytes: 9044
value = [tuple(map(int,input().split())) for i in range(2)]
lis = []
new_v = 0

for i in range(value[0][0]):
    lis.append(value[1][i])

lis.sort()

for i in range(len(lis)-1):
    alch = (lis[i] + lis[i+1]) / 2
    lis[i+1] = alch

print(alch)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>

using namespace std;

class UnionFind {
    public:
        vector<int> rank, p;
    
    UnionFind(){}
    UnionFind(int size){
        rank.resize(size,0);
        p.resize(size, 0);
        for(int i=0; i < size; i++) makeSet(i);
    }

    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y){
        link(findSet(x), findSet(y));
    }

    void link(int x, int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        } else {
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }

    int findSet(int x){
        if( x!= p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main(){
    int n, a, b, q, t;

    cin >> n >> q;
    UnionFind UF = UnionFind(n);

    for(int i=0; i < q; i++){
        cin >> t >> a >> b;
        if(t==0) UF.unite(a, b);
        else if(t==1){
            if(UF.same(a, b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() {
 

  int64_t n,a,b;
  cin>>n>>a>>b;

  //組み合わせ50Ca,bだと巨大な数になるのでNG
  //大きい方からb個取れば平均は最大値となる
  //bの一番小さいのと同じのが有る分

  vector<int64_t> v(n);
  for(int i=0;i<n;i++){
    cin>>v.at(i);
  }

  sort(v.begin(),v.end(),greater<int64_t>());

  int64_t sum=0;
  for(int i=0;i<a;i++){
    sum+=v.at(i);
  }

  cout<< fixed << setprecision(6) <<(double)sum/(double)a<<endl;

  int64_t cnt=0;
  for(int i=a;i<n;i++){
    if(v.at(a-1)==v.at(i))
      cnt++;
  }

  int64_t cnt2=0;
  for(int i=a-1;i>=0;i--){
    if(v.at(a-1)==v.at(i))
      cnt2++;
  }

  if(1+cnt!=n){
    if(cnt2==a){
      int64_t sum_all2=0;
      for(int i=a;i<=min(b,cnt2+cnt);i++){
        vector<vector<long long>> out3(n + 1,vector<long long>(n + 1, 0));
        out3=comb(cnt2+cnt,i);
        sum_all2+=out3.at(cnt2+cnt).at(i);
      }
      cout<<sum_all2<<endl;
    }else{
      vector<vector<long long>> out2(n + 1,vector<long long>(n + 1, 0));
      out2=comb(cnt+cnt2,cnt2);
      cout<<out2.at(cnt+cnt2).at(cnt2)<<endl;
    }
  }
  else{
    int64_t sum_all=0;
    for(int i=a;i<=b;i++){
      vector<vector<long long>> out(n + 1,vector<long long>(n + 1, 0));
      out=comb(n,i);
      sum_all+=out.at(n).at(i);
    }

    cout<<sum_all<<endl;
  }
    

	return 0;
}



Measured memory_bytes: 3848
#include <cstdio>
using namespace std;

int main(){
	double weigh;
	
	while((scanf("%lf", &weigh)) != EOF){
		if(weigh <= 48) printf("light fly\n");
		else if(weigh <= 51) printf("fly\n");
		else if(weigh <= 54) printf("bantam\n");
		else if(weigh <= 57) printf("feather\n");
		else if(weigh <= 60) printf("light\n");
		else if(weigh <= 64) printf("light welter\n");
		else if(weigh <= 69) printf("welter\n");
		else if(weigh <= 75) printf("light middle\n");
		else if(weigh <= 81) printf("middle\n");
		else if(weigh <= 91) printf("light heavy\n");
		else printf("heavy\n");
	}
	
	return 0;
}

Measured memory_bytes: 1036
N = int(input())
L = []
for i in range(N):
    L.append(list(input().split()))
A = [i for i in range(1, N+1)]
tL = list(zip(*L))
B = tL[0]
C = map(int, tL[1])
Z = list(zip(A, B, C))
sortZ = sorted(Z, key=lambda x:x[2],reverse = True)
ans = sorted(sortZ, key=lambda x:x[1])
for i in range(N):
    print(ans[i][0])


Measured memory_bytes: 3064
#include <vector>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <list>
#include <map>
#include <istream>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <stack>
#include <set>
#include <cmath>
#include <random>
#include <iostream>
#include <bitset>
#include <iomanip>
#include <queue>
#include <string>

#define int long long
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rr return 0
#define xx first
#define yy second
#define pii pair<int,int>

using namespace std;

typedef long long ll;
typedef long double ld;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<string> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        sort(all(a[i]));
    }
    sort(all(a));
    int p = 0;
    int ans = 0;
    for(int i = 1;i < n;i++){
        if(a[i] != a[i - 1]){
            int g = i - p;
            ans += g * (g - 1) / 2;
            p = i;
        }
    }
    int g = n - p;
    ans += g * (g - 1) / 2;
    cout << ans;
    rr;
}


Measured memory_bytes: 5760
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

int main() {
  int x;
  cin >> x;
  if (x == 0) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> t(26);
  for (int i = 0; i < n; i++) {
    t.at(s.at(i) - 'a').insert(i);
  }
  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 1) {
      int iq;
      char cq;
      cin >> iq >> cq;
      iq--;
      t.at(s.at(iq) - 'a').erase(iq);
      s.at(iq) = cq;
      t.at(cq - 'a').insert(iq);
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      int ans = 0;
      for (char c = 'a'; c <= 'z'; c++) {
        if (t.at(c - 'a').lower_bound(l)
           != t.at(c - 'a').lower_bound(r)) ans++;
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 24196
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll n,m;
int dp[1005][15];
string s;
ll dfs1(ll pos,ll dep){
	if(dep==0) return 1;
	if(pos==s.length()) return 0;
	ll ans = 0;
	ans+=dfs1(pos+1,dep);
	ans%=mod;
	ans+=(9*dfs1(pos+1,dep-1)%mod);
	ans%=mod;
	return ans%mod;
}
ll dfs2(ll pos,ll dep){
	if(dep==0) return 1;
	if(pos==s.length()) return 0;
	ll ans = 0;
	if(s[pos]=='0') ans+=dfs2(pos+1,dep);
	if(s[pos]>'0')
		ans+=dfs1(pos+1,dep);
	ans%=mod;
	//cout<<ans<<endl;
	if(s[pos]>'0')
		ans+=dfs2(pos+1,dep-1);
	ans%=mod;
	if(s[pos]>'0')
		ans+=(dfs1(pos+1,dep-1)*(s[pos]-'0'-1)%mod);
	ans%=mod;
	return ans%mod;
}
int main() {
	cin>>s;
	cin>>n;
	ll ans = 0;
	ans+=dfs2(1,n-1);
	ans%=mod;
	ans+=(dfs1(1,n-1)*(s[0]-'0'-1)%mod);
	ans%=mod;
	ans+=dfs1(1,n);
	cout<<(ans+mod)%mod;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int a,b;
    cin>>a>>b;
    int ans=-1;

    rep(i,11000){
        int sa=i*8/100;
        int sb=i*10/100;
        if(a==sa&&b==sb&&ans==-1) ans=i;
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long s = long.Parse(input[0]);
            long c = long.Parse(input[1]);
            long answer=0;

            if(s*2>=c)//cが足りない時
                answer=c/2;
            else { //Sが足りない時
                answer=s;
                s -= answer;
                c -= answer * 2;
                answer += c / 4;

            }

            Console.WriteLine(answer);

        }
    }
}

Measured memory_bytes: 13140
s = input()
st1=[]
st2=[]
st3=[]
n=len(s)
lv = 0
for i in range(n):
	c=s[i]
	if c=='\\':
		lv-=1
		st1.append(i)
	elif c=='/':
		lv+=1
		if len(st1) > 0:
			a = i - st1.pop()
			t=0	
			while len(st2)>0 and st2[-1]<lv:
				st2.pop()
				t+=st3.pop()
			st3.append(a+t)		
			st2.append(lv)
		else:
			if len(st2) > 0:
				st2.pop()
				st2.append(lv)
				
st=''
total=0
n = len(st3)
st+=str(n)
for i in range(n):
	st+=' '+str(st3[i])
	total+=(st3[i])
print(total)
print(st)



Measured memory_bytes: 6120
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() { 
    string N;
    long long ans=0;
    cin >> N;
    rep(i, N.length()){
        // cout << int(N[i]) - 48 << endl;
        ans += int(N[i]) - 48 ;
    }

    // cout << ans << endl;
    if (ans % 9 == 0 or ans == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b=0,i,s[101];
    cin>>a;
    for(i=0;i<a;i++){
cin>>s[i];
if(s[i]%2==1 && i%2==0)b++;
        }
 cout<<b<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

vector<int> same(100005);

signed main(){
  int n;
  cin>>n;
  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
    if(p[i]==i+1){
      same[i]=1;
    }
  }
  int cnt=0;
  rep(i,n){
    if(same[i]==1&&same[i+1]==1){
      cnt++;
      i++;
    }else if(same[i]==1&&same[i+1]==0){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
int a;
  string b,c;
  cin>>a>>b>>c;
  rep(i,a*2){
    if(i%2==0)
    cout<<b.at(i/2);
      else
        cout<<c[(i-1)/2];
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i<n; i++) cin >> a[i];
    int sum = 0;
    sort(a, a+n);
    for(int i = 0; i<k; i++) sum += a[i];
    cout << sum;
}

int main() {
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 100000;
const ll MOD = 1e9+7;

int n;
char s[MAXN+10];

int pos[30];
ll ans=1;

int main()
{
    int i, j;
    scanf("%d%s", &n, s+1);

    for(i=1; i<=n; i++) pos[s[i]-'a']++;
    for(i=0; i<='z'-'a'; i++) ans=ans*(pos[i]+1)%MOD;
    ans+=MOD;
    ans--;
    ans%=MOD;

    printf("%lld", ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=3e5+10;
char s[maxn];
int sum[maxn];
int main(){
	int n=read(),ans=n;
	scanf("%s",s+1);
	REP(i,1,n) sum[i]=sum[i-1]+(s[i]=='W');
	REP(i,1,n) chkmin(ans,sum[i-1]+(n-i-sum[n]+sum[i]));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int d,n;
    cin >> d >> n;
    int answer = 1;
    REP(i,d)answer *= 100;
    if(n == 100)
        answer *= (n+1);
    else
        answer *= n;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll a,ll b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}

int main(){
  ll l;
  cin >> l;
  long double ans;
  ans = pow(l,3);
  ans /= 27.0;
  cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 256
S = input()
result = 'Yes'
for i in range(1, len(S)+1):
  #print(i)
  if (i % 2 == 0 and S[i-1] == "R") or (i % 2 == 1 and S[i-1] == "L"):
      result = 'No'
      break
      
print(result)
      


Measured memory_bytes: 2940
//waz
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int n, p;

int64 f[55][2];

int main()
{
	gii(n, p);
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		int x;
		gi(x);
		x &= 1;
		f[i][0] += f[i - 1][0];
		f[i][1] += f[i - 1][1];
		f[i][0] += f[i - 1][x];
		f[i][1] += f[i - 1][x ^ 1];
	}
	printf("%lld\n", f[n][p]);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int cnt = 0;
        for (int i = 0; i < n.length(); i++) {
            if (n.charAt(i) == '2') {
                cnt++;
            }
        }
        System.out.println(cnt);
    }

}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
  int n,m;
  int x[100][100]={{}};
  int y[100]={};
  cin >> n >> m;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> x[i][j];
    }
  }
  for(int j=0;j<m;j++){
       cin >> y[j];
  }
  for(int i=0;i<n;i++){
    int z=0;
    for(int j=0;j<m;j++) z+=x[i][j]*y[j];
    cout << z << endl;		       
  }
  
  return 0;
}


Measured memory_bytes: 3148
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;

const ll INF = 1e15;
const ld eps = 1e-15;

ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	else
		return gcd(b, a%b);
}

int main() {
	ll N;
	cin >> N;
	for (int k = 0;k < N;k++) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		bool ok = true;
		ok &= D >= B;
		if (A <= C) {
			ok &= A >= B;
		}
		else{
			A -= (A - min(A, C+1)) / B * B;
			assert(A >= C + 1);
			// A = C+1 ~
			ll now = (A - (C + 1)) % B;
			if (D % B != 0) {
				ll step = (B - (D % B)) % B;
				step = gcd(step, B);
				now -= now / step * step;
				//now += ((B - now + (D%B) - 1) / (D%B)) * (D%B);
				//now %= B;
			}
			ok &= now + C + 1 >= B;
		}
		if (ok)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

/*
int main() {
	for (ll A1 = 1;A1 <= 10;A1++) {
		for (ll B1 = 1;B1 <= 10;B1++) {
			for (ll C1 = 1;C1 <= 10;C1++) {
				for (ll D1 = 1;D1 <= 10;D1++) {
					ll A = A1; ll B = B1; ll C = C1; ll D = D1;
					bool ok = true;
		ok &= D >= B;
		if (A <= C) {
			ok &= A >= B;
		}
		else{
			A -= (A - min(A, C+1)) / B * B;
			assert(A >= C + 1);
			// A = C+1 ~
			ll now = (A - (C + 1)) % B;
			if (D % B != 0) {
				ll step = (B - (D % B)) % B;
				now -= now / step * step;
				//now += ((B - now + (D%B) - 1) / (D%B)) * (D%B);
				//now %= B;
			}
			ok &= now + C + 1 >= B;
		}
					A = A1; B = B1; C = C1; D = D1;
					bool ok2 = true;
					vector<ll> visited(1000);
					while (!visited[A]) {
						visited[A] = true;
						A -= B;
						ok2 &= (A >= 0);
						if (!ok2 || A >= 50)
							break;
						if (A <= C)
							A += D;
					}
					if (ok != ok2)
						cout << A1 << " " << B1 << " " << C1 << " " << D1 << " " << (int)ok << endl;
				}
			}
		}
	}
	return 0;
}*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    rep1(i, s.size()){
        if (s[i]!=t[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3916
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	vector<ll> d;
	vector<bool> p(300000);
	p[0] = p[1] = true;

	for(ll i = 2; i < 300000; ++i) {
		if((i % 7 == 1 || i % 7 == 6) && !p[i]) {
			d.pb(i);
			for(ll j = 1; i * j < 300000; ++j) {
				p[i * j] = true;
			}
		}
	}
	while(true) {
		ll n;
		cin>>n;
		if(n == 1) break;
		cout<<n<<":";
		REP(i, d.size()) {
			if(d[i] > n) break;
			if(n % d[i] == 0) {
				cout<<" "<<d[i];
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(a<=0 && b>=0) {
    cout << "Zero" << endl;
  } else if (a>0 && b>0) {
    cout << "Positive" << endl;
  } else if ((b-a) % 2 == 0) {
    cout << "Negative" << endl;
  } else {
    cout << "Positive" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
    int N;

    cin >> N;

    int x[N], y[N];

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }

    int array[N];

    for (int i = 0; i < N; i++)
    {
        array[i] = i;
    }

    double avesum = 0;

    do
    {
        double sum = 0;

        for (int i = 0; i < N - 1; i++)
        {
            sum += sqrt(pow(x[array[i]] - x[array[i + 1]], 2) + pow(y[array[i]] - y[array[i + 1]], 2));
        }
        avesum += sum;
    } while (next_permutation(array, array + N));

    int N_dash = 1;

    for (int i = 1; i <= N; i++)
    {
        N_dash *= i;
    }

    // for (int i = 0; i < N; i++)
    // {
    //     for (int j = i + 1; j < N; j++)
    //     {
    //         avesum += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    //     }
    // }

    double ans = (double)avesum / (double)N_dash;

    
    printf("%.16f", ans);

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>

using int64 = int64_t;

const auto MOD = 1'000'000'000 + 7;

int64 factorial(int64 n) {
    int64 result = 1;
    for(int64 i = 1; i <= n; i++) {
        result = (result * (i % MOD)) % MOD;
    }
    return result;
}

int main() {
    int N, M;
    std::cin >> N >> M;

    if(std::abs(N - M) > 1) {
        std::cout << 0 << std::endl;
        return 0;
    }

    auto answer = (factorial(N) * factorial(M)) % MOD;

    if(N == M) {
        answer = (answer * 2) % MOD;
    }

    std::cout << answer << std::endl;

    return 0;
}

Measured memory_bytes: 256
//100
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

LL H, W, h, w, A, B, C, I;
string s;

int main() {
	cin >> A >> B;
	//int X = 0;
	//for (int i = 0; i < 4; i++)(s[i] == '+' ? X++ : X--);
	//int ans = max(A, max(B, C)) * 10 + A + B + C - max(A, max(B, C));
	cout << (A<=8&&B<=8?"Yay!":":(") << endl;

	return 0;
}

Measured memory_bytes: 256
// abc149_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif
    
    int K;
    cin >> K;
    
    int ans = (K/2) * (K - K/2);
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int X;
  cin >> X;
  int count = 0;
  while(X >= 500){
    X -= 500;
    count += 1000;
  }
  while(X >= 5){
    X -= 5;
    count += 5;
  }
  cout << count << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    bool ok = true;
    vector<int>a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if(a[i] == 1) {
            ok = false;
        }
    }
    if(ok) {
        cout << -1 << endl;
        return 0;
    }
    int cnt = 1;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(cnt != a[i]) {
            ans++;
        }
        else {
            cnt++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  double A[110];
  double res = 0;
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
    res += 1/A[i];
  }
    cout << double(1/res) << '\n';
}


Measured memory_bytes: 256
n = int(input())
l = [input() for _ in range(n)]
l = [sorted([j for j in i]) for i in l]
l = ["".join(i) for i in l]
al = list(set(l))
ans_dict = {}
ans = 0
for i in l:
    if i in ans_dict:
        
        ans += ans_dict[i]
        ans_dict[i]+=1
    else:
        ans_dict[i] = 1

print(ans)


Measured memory_bytes: 31260