akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

ll a[55], b[55], c[55], d[55];
ll N, M, Q;
ll nums[11];
ll ans = 0;
void solve(ll dep, ll now) {
    if (dep < N) {
        REP(i, now, M + 1) {
            nums[dep] = i;
            solve(dep + 1, i);
        }
    } else {
        ll tmp = 0;
        REP(i, 0, Q) {
            if (nums[b[i]] - nums[a[i]] == c[i]) {
                tmp += d[i];
            }
        }
        ans = max(ans, tmp);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> Q;
    REP(i, 0, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    solve(0, 1);
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include<cstdio>
int main(void){
  int x,y,z;
  scanf("%d %d %d",&x,&y,&z);
  if(x+y==z)printf("Yes\n");
  else if(y+z==x)printf("Yes\n");
  else if(z+x==y)printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int d = sc.nextInt();
		int ans = 0;
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		long dsq = (long) d*d;
		for(int i = 0; i < n; i++) {
			int dx = Math.abs(x[i]);
			int dy = Math.abs(y[i]);
			long distance = (long)dx*dx + (long)dy*dy;
			if(distance <= dsq) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 63060
from time import time
import numpy as np

def main():
    N = int(input())
    A = list(map(int, input().split()))
    min_costs = [0 for i in range(N)]
    min_costs[1] = abs(A[1] - A[0])
    if N == 2:
        print(min_costs[1])
        return

    min_cost = 100000


    for i in range(2, N):
        # 一つ前の足場からジャンプ
        one_step_cost = abs(A[i] - A[i-1]) + min_costs[i-1]
        # 二つ前の足場からジャンプ
        two_step_cost = abs(A[i] - A[i-2]) + min_costs[i-2]
        min_cost = min(one_step_cost, two_step_cost)

        min_costs[i] = min_cost

    print(min_costs[N-1])



if __name__ == '__main__':
    start = time()
    main()
    # print(time() - start)



Measured memory_bytes: 22708
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

bool equal(vector<int> A,vector<int> B){
    int n=A.size();
    for(int i=0;i<n;i++){
        if(A[i]!=B[i]){
            return false;
        }
    }
    return true;
}

void output(vector<int> A){
    int n=A.size();
    for(int i=0;i<n;i++){
        if(i!=0) cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
}

vector<int> solve(vector<int> A,vector<int>B){
    int n=A.size();
    for(int i=0;i<n;i++){
        if(i-A[i]>=0){
            B[i-A[i]]+=1;
        }else{
            B[0]+=1;
        }
        if(i+A[i]+1<n){
            B[i+A[i]+1]-=1;
        }
    }

    for(int i=1;i<n;i++){
        B[i]+=B[i-1];
    }

    return B;
}

signed main(){ 
    int n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    vector<int> b(n,0);
    vector<int> a2(n,0);

    for(int i=0;i<k;i++){
        a2=a;
        a=solve(a,b);
        if(equal(a,a2)){
            break;
        }
    }
    
    output(a);

}  

Measured memory_bytes: 11176
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if a==b&&b==c{"Yes"}else{"No"});
}

Measured memory_bytes: 4352
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

def search(n):
    l = 0
    r = len(arr2) - 1
    while l + 1 < r:
        c = (l + r) // 2
        if arr2[c] > n:
            r = c
        elif arr2[c] < n:
            l = c
        elif arr2[c] == n:
            l = c
            r = c
    return l, r

s = STR()
l = len(s)
arr = [0 for _ in range(l)] #1: 右 0: 左
arr2 = []
arr[0] = 1
for i in range(l - 1):
    if s[i] == 'R' and s[i + 1] == 'L':
        arr[i + 1] = -1
        arr2.append(i)
    elif s[i] == 'L' and s[i + 1] == 'R':
        arr[i + 1] = 1
for i in range(1, l):
    arr[i] += arr[i - 1]
debug(arr)
debug(arr2)
ans = [0 for _ in range(l)]
for i in range(l):
    l, r = search(i)
    debug(i, arr[i], l, r)
    if arr[i] == 1:
        if arr2[l] >= i:
            r = l
        ans[arr2[r] + (arr2[r] - i) % 2] += 1
    elif arr[i] == 0:
        if arr2[r] <= i:
            l = r
        ans[arr2[l] + (arr2[l] - i) % 2] += 1
debug('ans', ans)
ans = [str(i) for i in ans]
print(' '.join(ans))


Measured memory_bytes: 76844
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)4e5+100;
    const int inf=(int)1e9+100;
#define filename ""

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,i,j;
    cin>>n;
    vector<int> p(n),p1(n),p2(n);
    fo(i,n)
    {
        p[i]=i;
        cin>>p1[i];
        p1[i]--;
    }
    fo(i,n)
    {
        cin>>p2[i];
        p2[i]--;
    }
    int q=0;
    int x,y;
    do
    {
        bool a=1,b=1;
        fo(i,n)
        {
            if (p1[i]!=p[i]) a=0;
            if (p2[i]!=p[i]) b=0;
        }
        if (a)
        {
            x=q;
        }
        if (b)
        {
            y=q;
        }
        q++;
    }while(next_permutation(all(p)));
    cout<<abs(x-y);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=5e3+10,mod=1e9+7;
void upd(int &x,int y){ x=x+y-mod; x+=x>>31&mod; }
int n,c[N];
vi g[N];
int dp[N][N],siz[N];
void dfs(int u,int f){
	siz[u]=1;
	dp[u][1]=1;
	for (auto v:g[u]) if (v!=f){
		dfs(v,u);
		static int d[N];
		for (int i=0;i<=siz[u]+siz[v];i++) d[i]=0;
		for (int i=1;i<=siz[u];i++){
			for (int j=1;j<=siz[v];j++){
				upd(d[i],mod-(ll)dp[u][i]*dp[v][j]%mod*c[j]%mod);
				upd(d[i+j],(ll)dp[u][i]*dp[v][j]%mod);
			}
		}
		for (int i=1;i<=siz[u]+siz[v];i++) dp[u][i]=d[i];
		siz[u]+=siz[v];
	}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].pb(v),g[v].pb(u);
	}
	c[0]=1;
	for (int i=2;i<=n;i+=2) c[i]=(ll)c[i-2]*(i-1)%mod;
	dfs(1,0);
	int ans=0;
	for (int i=2;i<=n;i+=2) upd(ans,(ll)dp[1][i]*c[i]%mod);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 58548
#include <bits/stdc++.h>
using namespace std;
// 一番右からやるのが最適
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    string s;
    cin >> s;
    int N = s.size();
    int64_t ans = 0;
    int64_t a = 0;
    int64_t bc = 0;
    for(int i = 0; i < N - 2; i++) {
        if(s[i] == 'A') {
            a++;
            if(s.substr(i, 3) == "ABC") {
                int j;
                for(j = i + 1; j < N - 1 && s.substr(j, 2) == "BC"; j += 2) {
                    bc++;
                }
                ans += a * bc;
                bc = 0;
                i = j - 1;
            }
        } else {
            a = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
int main()
{
  int n;
  string s;
  unordered_map<string, int> mp = {{"RE", 0}, {"TLE", 0}, {"WA", 0}, {"AC", 0}};

  cin >> n;

  for (int i = 0; i < n; i++)
  {
    cin >> s;
    mp[s]++;
  }

  for (auto item : mp)
  {
    cout << item.first << " x " << item.second << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;


int main()
{
    std::ios_base::sync_with_stdio(0);	
    cin.tie(0);
    cout.tie(0);
    
    string s,t;
    
    cin>>s>>t;
    
    ll n,m;
    cin>>n>>m;
    
    string w;
    cin>>w;
    
    if(s==w)
    {
		n--;
	}
	else{
		if(t==w)
		{
			m--;
		}
	}
	
	cout<<n<<" "<<m;
    
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main() 
{
	int r, g, b, n, count = 0;
	cin >> r >> g >> b >> n;
	for (int i = n; i >= 0; i -= r)
		for (int j = i; j >= 0; j -= g)
			if (j % b == 0) count++;
	cout << count;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int a[100100];
int main(){
//	freopen("B.in","r",stdin);
	int n;
	scanf("%d",&n);
	int x=-1,y=-1,cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(x==-1) x=a[i],cnt1=1;
		else if(a[i]==x) cnt1++;
		else if(y==-1) y=a[i],cnt2=1;
		else if(a[i]==y) cnt2++;
		else{
			printf("No\n");
			return 0;
		}
	}
	if(y==-1){
		if(n>=x*2)
			printf("Yes\n");
		else if(x==n-1)
			printf("Yes\n");
		else
			printf("No\n");
		return 0;
	}
	if(x!=y+1&&y!=x+1){
		printf("No\n");
		return 0;
	}
	if(x>y) swap(x,y),swap(cnt1,cnt2);
	if(y-cnt1<=0){
		printf("No\n");
		return 0;
	}
	y-=cnt1;
	if(y*2<=cnt2)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
//#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int n, a, b, c, d;
string s;
bool f = true;

int move(char chr)
{
    if (chr == 'A')
    {
        if (s[a + 1] == '.' && a + 1 != b)
        {
            a++;
            return 1;
        }
        else if (s[a + 2] == '.' && a + 2 != b)
        {
            a += 2;
            return 1;
        }
        else
        {
            f = false;
            return 0;
        }
    }
    else
    {
        if (s[b + 1] == '.' && b + 1 != a)
        {
            b++;
            return 1;
        }
        else if (s[b + 2] == '.' && a + 2 != a)
        {
            b += 2;
            return 1;
        }
        else
        {
            f = false;
            return 0;
        }
    }
}

int main(void)
{
    cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;
    cin >> s;

    if (c < d)
    {
        while (b < d)
        {
            if (!move('B'))
                break;
        }
        while (a < c)
        {
            if (!move('A'))
                break;
        }
    }
    else
    {
        while (1)
        {
            if (s[b - 1] == '.' && s[b + 1] == '.')
                break;
            if (b == d)
            {
                f = false;
                break;
            }
            if (!move('B'))
                break;
        }
        while (a < c)
        {
            if (!move('A'))
                break;
        }
        while (b < d)
        {
            if (!move('B'))
                break;
        }
    }
    print(f);
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int a,b,i,n;
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0 && b==0)break;
        for(i=1;i<=a;i++){
            for(n=1;n<=b;n++){
        if(1<i && i<a && n<b && 1<n)
            printf(".");
        else printf("#");
        }
        printf("\n");
        }
        printf("\n");
        }
    return 0;
    }


Measured memory_bytes: 1976
N = input()
A = list(map(int,input().split()))
count = 0
exist_odd = False

while (exist_odd == False):
  for x in A:
    if x % 2 != 0:
      exist_odd = True
      
  if exist_odd == True:
    break
  else:
    A = [x/2 for x in A]
  count += 1
print(count)
        

Measured memory_bytes: 39664
import math


a, b, h, m = map(int, input().split())

h_deg = 30 * h + 0.5 * m
m_deg = 6 * m
diff_rad = math.radians(abs(h_deg - m_deg))
print((a ** 2 + b ** 2 - 2 * a * b * math.cos(diff_rad)) ** 0.5)


Measured memory_bytes: 9548
#pragma GCC optimize("Ofast")
#include<vector>
#include<queue>
#include<iostream>
#include<fstream>
#include<string>
#include<cassert>
#include<algorithm>
#include<random>
#include<map>
#include<set>
#include <bitset>
#include<ctime>

using namespace std;

int mod = 998244353;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<char>vc;
typedef vector<string>vs;
typedef vector<vector<int>>vii;
typedef vector<vector<char>>vvc;
typedef vector<vector<ll>>vll;
typedef vector< pair<ll, ll>>vpll;
typedef vector< pair<ld, ld>>vpld;
typedef vector< pair<int, int>>vpi;
typedef pair<ld, ld>pld;
#define mp make_pair
#define pb push_back

int sum(int a, int b)
{
	int c = a + b;
	if (c >= mod)
	{
		c -= mod;
	}
	return c;
}
int dif(int a, int b)
{
	int c = a - b;
	if (c < 0)
	{
		c += mod;
	}
	return c;
}
int mlt(int a, int b)
{
	ll c = a * 1LL * b;
	return c % mod;
}
int ibit(int n, int i)
{
	return ((n >> i) & 1);
}
void outp(vii &ou)
{
	for (int i = 0; i < ou.size(); i++)
	{
		for (int j = 0; j < ou[i].size(); j++)
		{
			cout << ou[i][j] << ' ';
		}
		cout << '\n';
	}
}
int bp(int x, int y)
{
	if (y == 0)
	{
		return 1;
	}
	int a = 0;
	if (!(y % 2))
	{
		a = bp(x, y / 2);
	}
	return (y % 2) ? mlt(bp(x, y - 1), x) : mlt(a, a);
}
int obr(int x)
{
	return bp(x, mod - 2);
}
const int maxn = 200007;
int fact[1000007], ofact[1000007];
vii del(maxn), alldivs(maxn);
vi maxpr(maxn);
vi mu(maxn), sqf(maxn, 1);
void prec()
{
	fact[0] = 1;
	ofact[0] = 1;
	for (int i = 1; i < maxn; i++)
	{
		fact[i] = mlt(fact[i - 1], i);
	}
	//cerr << "sdsds" << endl;
	ofact[maxn - 1] = obr(fact[maxn - 1]);
	for (int i = maxn - 2; i > 0; i--)
	{
		ofact[i] = mlt(ofact[i + 1], i + 1);
	}
}
int c(int a, int b)
{
	return ((a <= b) && (a >= 0)) ? mlt(fact[b], mlt(ofact[a], ofact[b - a])) : 0;
}
ll gcd(ll x, ll y)
{
	//cerr << x << y << endl;
	if (x == 0)return y;
	return(x > y) ? gcd(y, x) : gcd(y%x, x);
}
int main()
{
	int h, w;
	cin >> h >> w;
	vvc desk(h, vc(w));
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> desk[i][j];
	vii dp(h, vi(w, 228));
	dp[0][0] = 0;
	if (desk[0][0] == '#')dp[0][0] = 1;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (i >= 1)
			{
				int cur = dp[i - 1][j];
				if ((desk[i][j] =='#')&& (desk[i - 1][j]=='.'))cur++;
				dp[i][j] = min(dp[i][j], cur);
			}
			if (j >= 1)
			{
				int cur = dp[i][j-1];
				if ((desk[i][j] =='#')&& (desk[i][j-1]=='.'))cur++;
				dp[i][j] = min(dp[i][j], cur);
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	int n;
	cin >> n;
}

Measured memory_bytes: 12032
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nhw = IO.RSInt;
            var n = nhw[0];
            var h = nhw[1];
            var w = nhw[2];
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                var ab = IO.RSInt;
                if (ab[0] >= h && ab[1] >= w) cnt++;
            }
            WriteLine(cnt);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 19360
n = int(input())
d = sorted(list(map(int, input().split())))

m = int(len(d) / 2)
if d[m-1] == d[m]:
    print(0)
else:
    ans = list(range(d[m-1] + 1, d[m] + 1))
    print(len(ans))


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b;
    cin >> a >> b;

    cout << max({a+b, a-b, a*b}) << endl;
    
    return 0;
}


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

int main(){
    long long n,a,b,c;
    cin >>n>>a>>b;
    if(n % (a+b) >a){
        c=a;
    }else{
        c=min(n % (a+b),a);
    }
    cout<<n/(a+b)*a+c<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

p_list = list(map(int, input().split()))

ans = 0

for i in range(n-2):
    p1 = p_list[i]
    p2 = p_list[i + 1]
    p3 = p_list[i + 2]
    if min(p1, p2, p3) != p2 and max(p1, p2, p3) != p2:
        ans += 1

print(ans)


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

using namespace std;
const int N = 1e5+1;

int n, m;
int f[3][N];
vector <int> g[N];
int main(){
    cin >> n >> m;
    for (int i = 0; i < m; ++ i){
        int u, v; cin >> u >> v;
        -- u, -- v;

        g[u].push_back(v);
    }

    int S, F;
    cin >> S >> F;
    -- S, -- F;

    for (int j = 0; j < 3; ++ j)
    for (int i = 0; i < n; ++ i)
        f[j][i] = 1e9;
    f[0][S] = 0;

    queue <pair <int, int> > q;
    q.push(make_pair(S, 0));

    while (q.size()){
        int u = q.front().first,
            o = q.front().second;
        q.pop();

        for (int v: g[u]){
            if (f[(o+1)%3][v] != 1e9)
                continue;
            f[(o+1)%3][v] = f[o][u]+1;
            q.push(make_pair(v, (o+1)%3));
        }
    }

    int res = f[0][F];
    if (res == 1e9) res = -1;
    else res /= 3;

    cout << res << endl;
}


Measured memory_bytes: 6912
#include<stdio.h>

  int a[3];

  void swap(int i,int j);

int main(void){

  int i,j;

for(i=0; i<3;i++){

  scanf("%d",&a[i]);
 }
for(i=0;i<3;i++){
  for(j=i+1;j<3;j++){
    if(a[i]>a[j]){
      swap(i,j);
    }
  }
 }
printf("%d %d %d\n",a[0],a[1],a[2]);

return 0;
}

void swap(int i,int j){
  int temp = a[i];
  a[i] = a[j];
  a[j] = temp;

  return;
}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define get(a,t) get<a>(t)
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const int INF=1e18;

void dprint(string s) { cout << endl;}
void dprint() { cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w=s.find(','); cout <<"["<< s.substr(0,w) << ": " << t << "] " ; dprint(s.substr(w+1, sz(s)-w), u...);} 


// #define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...); 
#endif
const int N=100005;
const int mod=2019;
int32_t main()
{
	IOS;
	string s; cin>>s; 
	int ans=0;
	int n=sz(s);
	int pow=1;
	int freq[mod]={};
	int rem=0; freq[rem]++;
	for(int i=n-1;i>=0;i--)
	{
		int digit=s[i]-'0';
		rem=(rem+digit*pow)%mod;
		pow=pow*10%mod;
		dbg(rem,freq[rem],digit);
		ans+=freq[rem];
		freq[rem]++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3804
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
struct edge {
	ll to, cost;
	bool operator<(const edge& right) const {
		return cost == right.cost ? to < right.to : cost < right.cost;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll ans;
string s;

int main() {
	rd(s);
	ans += stoll(s);
	if (s.length() == 1) {
		wrln(ans);
		return 0;
	}
	else {
		repi(i, 1, (1 << (s.length() - 1))) {
			ll t_i = i;
			string t_s(s);
			repi(j, 0, s.length() - 1) {
				if (t_i & 1) {
					ans += stoll(t_s.substr(s.length() - 1 - j));
					t_s = t_s.substr(0, s.length() - 1 - j);
				}
				t_i >>= 1;
			}
			ans += stoll(t_s);
		}
	}
	wrln(ans);
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> ng(n + 1);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    ng[a] = true;
  }

  const ll mod = 1e9 + 7;
  vector<ll> memo(n + 1, -1);
  memo[0] = 1;
  function<ll(int)> f = [&](int n) -> ll {
    if (n < 0)
      return 0;
    if (memo[n] != -1)
      return memo[n];
    if (ng[n])
      return 0;
    return memo[n] = (f(n - 1) + f(n - 2)) % mod;
  };
  cout << f(n) << endl;

  // vector<ll> dp(n + 1, 0);
  // dp[0] = 1;
  // for (int i = 1; i <= n; i++) {
  //   if (find(a.begin(), a.end(), i) != a.end())
  //     continue;
  //   dp[i] += dp[i - 1];
  //   dp[i] %= mod;
  //   if (i > 1) {
  //     dp[i] += dp[i - 2];
  //     dp[i] %= mod;
  //   }
  // }
  //
  // cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 10308
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static long MOD = 1_000_000_007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		for (int i=1;i<=Math.sqrt(n);i++) {
			list.add(i);
		}
		for (int i=(int)Math.floor(Math.sqrt(n));i>=1;i--) {
			if (list.get(list.size()-1)<n/i) {
				list.add(n/i);
			}
		}
		//System.out.println(list);
		
		int m = list.size();
		long[] dp = new long[m];
		long[] dp2 = new long[m];
		
		for (int i=0;i<m;i++) {
			dp[i]=1;
		}
		
		for (int j=0;j<k;j++) {
			dp2[m-1]=dp[0];
			for (int i=m-2;i>=0;i--) {
				dp2[i]=(dp2[i+1]+(list.get(m-1-i)-list.get(m-2-i))*dp[m-i-1])%MOD;
			}
			long[] tmp = dp;
			dp = dp2;
			dp2 = tmp;
		//	System.out.println(Arrays.toString(dp));
		}
		
		System.out.println(dp[0]);
	}



}




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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed 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 main() {
    let n:usize = read();
    let v:Vec<f64> = (0..n).map(|_| read()).collect();
    let mean = v.iter().sum::<f64>() / n as f64;
    let mean_round = mean.round() as i64;
    let mean_ceil = mean.ceil() as i64;
    let mut ans1 = 0;
    let mut ans2 = 0;
    for i in v {
        ans1 += (i as i64 - mean_round).pow(2);
        ans2 += (i as i64 - mean_ceil).pow(2);
    }
    println!("{}", std::cmp::min(ans1, ans2));
}


Measured memory_bytes: 2580
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = min(a, b); i >= 1; i--) {
		if (a%i == 0 && b % i == 0) {
			--k;
			if (k == 0) {
				cout << i;
				ed;
				return 0;
			}
		}
	}

	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);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());

    String result = (A + B) < C ? "No" : "Yes";
    System.out.println(result);

  }
}


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

int main() {
  long long int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  if(k<=a){
    cout << k << endl;
  }
  
  else if(a < k&& k <= a+b){
    cout << a << endl;
  }
  
  else{
    cout << 2*a + b - k << endl;
  }
  
  
}


Measured memory_bytes: 3620
program sample
    implicit none
  
    integer(8) :: i,j,m,n,k,a
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,k
    allocate(x(n))
    read(*,*)x
    a=0
    do i=1,k
        a=a+x(i)
    end do
    m=a
    do i=1,n-k
        a=a-x(i)+x(k+i)
        if(a>m)then
            m=a
        end if
    end do
    write(*,*) (m+k)/2.0
  
    stop
end program sample
  



Measured memory_bytes: 4744
#include <iostream>
using namespace std;

int main(void){
	int a, b;
	char op;

	while (true){
		cin >> a >> op >> b;
		if (op == '?') break;
		switch (op){
		case '+':
			cout << a + b << "\n";
			break;
		case '-':
			cout << a - b << "\n";
			break;
		case '*':
			cout << a * b << "\n";
			break;
		case '/':
			cout << a / b << "\n";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

S=input()
N=len(S)
S=S+'R'
L=[0]*N
i=0
while i<N:
    l=r=0
    while S[i]=='R':
        i+=1
        r+=1
    ri=i
    while S[i]=='L':
        i+=1
        l+=1
    L[ri-1]=(r+1)//2+l//2
    L[ri]=r//2+(l+1)//2
lprint(L,' ')

Measured memory_bytes: 78268
#include <iostream>

using namespace std;

int devide[83], modulo[83];

int main()
{
    int p, q;
    while(cin >> p >> q) {
        bool loop = false;
        int i, j;
        for(i = 0; i < 80 && !loop ; i++) {
            p *= 10;
            devide[i] = p / q;
            modulo[i] = p % q;
            if(modulo[i] == 0) {
                break;
            }
            for(j = 0; j < i; j++) {
                if(devide[i] == devide[j] && modulo[i] == modulo[j]) {
                    loop = true;
                    i -= 2;
                    break;
                }
            }
            p = modulo[i];
        }

        for(int k = 0; k <= i; k++) {
            cout << devide[k];
        }
        cout << endl;
        if(loop) {
            for(int l = 0; l <= i; l++) {
                if(l < j) {
                    cout << " ";
                } else {
                    cout << "^";
                }
            }
            cout << endl;
        }
    }
}

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

int f(int x) {
  int ret = 0;
  while (x % 100 == 0) {
    x /= 100;
    ret++;
  }
  return ret;
}

int main() {
  int d, n; cin >> d >> n;
  int cnt = 0;
  for (int i = 1; ; i++) {
    if (f(i) == d) {
      cnt++;
    }
    if (cnt == n) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  rep(i,n-1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }

  vector<vector<ll>> dp(n, vector<ll>(2, 0));
  auto dfs = [&](auto& f, int p, int u)->void{
    dp[u][0] = dp[u][1] = 1;
    for (auto v : g[u]) {
      if (v == p) continue;
      f(f, u, v);
      (dp[u][0] *= (dp[v][0] + dp[v][1])) %= mod;
      (dp[u][1] *= dp[v][0]) %= mod;
    }
  };

  dfs(dfs, -1, 0);
  cout << (dp[0][0] + dp[0][1]) % mod << endl;
  return 0;
}


Measured memory_bytes: 21104
#include <iostream>
#include <algorithm>
#include <set>
  
using namespace std;
  
#define MAX_V 100
#define MAX_E 10000
#define INF 1e9
typedef pair<int,int> pii;
  
struct Edge{
    int u,v,cost;
    Edge(){}
    Edge(int u,int v,int cost) : u(u),v(v),cost(cost) {}
};
  
bool cmp(const Edge &e1,const Edge &e2){
    return e1.cost < e2.cost;
}
  
int V,E,par[MAX_V],rank[MAX_V],wmin;
Edge es[MAX_E];
  
void init(){
    for(int i = 0 ; i < V ; i++){
	par[i] = i;
	rank[i] = 0;
    }
}
  
int find(int x){
    if(par[x] == x){
	return x;
    }
    return par[x] = find(par[x]);
}
  
void unite(int x,int y){
    x = find(x), y = find(y);
    if(x == y){
	return;
    }
    if(rank[x] < rank[y]){
	par[x] = y;
    }else{
	par[y] = x;
	if(rank[x] == rank[y]){
	    rank[x]++;
	}
    }
}
  
bool same(int x,int y){
    return find(x) == find(y);
}
  
int kruskal(){
    init();
    sort(es,es+E,cmp);
    set<pii> v;
    int max = 0, min = INF;
    for(int i = 0 ; i < E ; i++){
	Edge e = es[i];
	if(!same(e.u,e.v) && wmin <= e.cost){
	    unite(e.u,e.v);
	    v.insert(pii(e.u,e.v));
	    max = std::max(max,e.cost);
	    min = std::min(min,e.cost);
	} 
    }
    if((int)v.size() != V-1){
	return INF;
    }
    return max-min;
}
  
int main(){
    while(cin >> V >> E, (V | E)){
	int a,b,c;
	set<int> w;
	for(int i = 0 ; i < E ; i++){
	    cin >> a >> b >> c;
	    a--, b--;
	    es[i] = Edge(a,b,c);
	    w.insert(c);
	}
	int res = 1e9;
	set<int>::iterator it;
	for(it = w.begin() ; it != w.end() ; ++it){
	    wmin = *it;
	    res = min(res,kruskal());
	}
	cout << (res == INF ? -1 : res) << endl;
    }
    return 0;
}

Measured memory_bytes: 1444
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int L,N,M,X,SE[110],SS[110],E[110],S[110],dp[2][3][110][1010];
string s;

int main(){
	while(cin>>L>>N>>M>>X,L){
		rep(i,N)cin>>s>>SE[i]>>SS[i];
		rep(i,M)cin>>s>>E[i]>>S[i];
		rep(i,2)rep(j,3)rep(k,M+1)rep(l,L+1)dp[i][j][k][l]=-INF;
		dp[0][0][0][0]=0;
		rep2(i,1,N+M+1){
			int cur=i%2,pre=1-cur;
			if(i<=N)rep(j,3)rep(l,L+1){
				if(SE[i-1]>l||!j)dp[cur][j][0][l]=dp[pre][j][0][l];
				else dp[cur][j][0][l]=max(dp[pre][j][0][l],dp[pre][j-1][0][l-SE[i-1]]+SS[i-1]);
			}else rep2(j,1,3)rep(k,M+1)rep(l,L+1){
				if(E[i-N-1]>l||!k)dp[cur][j][k][l]=dp[pre][j][k][l];
				else dp[cur][j][k][l]=max(dp[pre][j][k][l],dp[pre][j][k-1][l-E[i-N-1]]+S[i-N-1]);
			}
		}
		int ans=0;
		rep2(j,1,3)rep2(k,X,M+1)rep(l,L+1)ans=max(ans,dp[(N+M)%2][j][k][l]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    ans = 0
    d = defaultdict(lambda: 0)
    N = int(input())
    for _ in range(N):
        s = [c for c in str(input().strip())]
        s.sort()
        s = tuple(s)
        if s in d:
            ans += d[s]
        d[s] += 1

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 23900
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int N;
    cin >> N;
    for(int index_n=0;index_n<N;index_n++){
        vector<int> V(10);
        rep(i,10) cin >> V[i];
        // left,right,next
        queue<pair<pair<int,int>,int> > Q;
        Q.push(mp(mp(V[0],0),1));
        bool ok = false;
        while(!Q.empty()){
            int left = Q.front().first.first;
            int right = Q.front().first.second;
            int next = Q.front().second;
            Q.pop();

            if(next == 10){
                ok = true;
                break;
            }
            if(V[next] > left){
                Q.push(mp(mp(V[next],right),next+1));
            }
            if(V[next] > right){
                Q.push(mp(mp(left,V[next]),next+1));
            }
        }
        if(ok) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
# https://atcoder.jp/contests/abc086/tasks/arc089_a

Pos = Struct.new(:x, :y)

N = gets.to_i
ts = Array.new(N)
# xs = Array.new(N)
ps = Array.new(N) { Pos.new(0, 0) }
N.times do |i|
  ts[i], ps[i].x, ps[i].y = gets.split.map(&:to_i)
end

ts.insert(0, 0)
ps.insert(0, Pos.new(0, 0))

cond =  ps.zip(ts).each_cons(2).all? do |(p1, t1), (p2, t2)|
  d = (p1.x - p2.x).abs + (p1.y - p2.y).abs
  t = t2 - t1
  d <= t && (t - d).even?
end

puts cond ? 'Yes' : 'No'


Measured memory_bytes: 16764
import java.io.IOException;
import java.util.*;

/**
 */
class Main {
	final static int N = 10;

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		List<Integer> data = new ArrayList<>();
		List<Integer> modes = new ArrayList<>(102);
		for(int i=0;i<=101;i++) {
			modes.add(0);
		}
		while(in.hasNext()) {
			int d = in.nextInt();
			data.add(d);
			modes.set(d, modes.get(d) + 1);
		}
		int mode_num = 0;
		for(int i=1;i<=100;i++) {
			if(mode_num < modes.get(i)) {
				mode_num = modes.get(i);
			}
		}
		for(int i=1;i<=100;i++) {
			if(mode_num == modes.get(i)) {
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 26028
N = int(input())
S = int(input())

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + (n % b)

def solve(N, S):
    if S > N:
        return -1
    elif N == S:
        return N+1
    else:
        for b in range(2, int(N**(1/2))+1):
            if f(b, N) == S:
                return b
        for p in range(int(N**(1/2)), 0, -1):
            if (N - S) % p == 0:
                b = (N - S) // p + 1
                if f(b, N) == S:
                    return b
        return -1

print(solve(N, S))

Measured memory_bytes: 41840
a, b = map(int, input().split())

x = b * 10

for i in range(x, x+10):
   ta = (i * 0.08 * 10) // 10
   tb = (i * 0.10 * 10) // 10
   if ta == a and tb == b:
      print(i)
      exit()

print(-1)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>

using namespace std;

enum Face
{
	TOP = 0,
	FRONT = 1,
	RIGHT = 2,
	LEFT = 3,
	BACK = 4,
	BOTTOM = 5,
};

void roll(vector<int> &f, string cmd)
{
	int tmp;
	for (int i = 0; i < cmd.size(); i++)
	{
		switch (cmd[i])
		{
		case 'E':
			tmp = f[TOP];
			f[TOP] = f[LEFT];
			f[LEFT] = f[BOTTOM];
			f[BOTTOM] = f[RIGHT];
			f[RIGHT] = tmp;
			break;
		case 'N':
			tmp = f[TOP];
			f[TOP] = f[FRONT];
			f[FRONT] = f[BOTTOM];
			f[BOTTOM] = f[BACK];
			f[BACK] = tmp;
			break;
		case 'S':
			tmp = f[TOP];
			f[TOP] = f[BACK];
			f[BACK] = f[BOTTOM];
			f[BOTTOM] = f[FRONT];
			f[FRONT] = tmp;
			break;
		case 'W':
			tmp = f[TOP];
			f[TOP] = f[RIGHT];
			f[RIGHT] = f[BOTTOM];
			f[BOTTOM] = f[LEFT];
			f[LEFT] = tmp;
			break;
		default:
			break;
		}
	}
}

int main()
{
	vector<int> f(6);
	int q;
	int top, front;
	for (int i = 0; i < 6; i++)
	{
		cin >> f[i];
	}
	cin >> q;
	vector<int> res(q);
	for (int i = 0; i < q; i++)
	{
		cin >> top >> front;
		if (top != f[TOP])
		{
			if (top == f[FRONT])
			{
				roll(f, "N");
			}
			else if (top == f[RIGHT])
			{
				roll(f, "W");
			}
			else if (top == f[LEFT])
			{
				roll(f, "E");
			}
			else if (top == f[BACK])
			{
				roll(f, "S");
			}
			else if (top == f[BOTTOM])
			{
				roll(f, "NN");
			}
		}
		if (front == f[FRONT])
		{
			res[i] = f[RIGHT];
		}
		else if (front == f[RIGHT])
		{
			roll(f, "WSE");
			res[i] = f[RIGHT];
		}
		else if (front == f[LEFT])
		{
			roll(f, "ESW");
			res[i] = f[RIGHT];
		}
		else if (front == f[BACK])
		{
			roll(f, "WSSE");
			res[i] = f[RIGHT];
		}
	}
	for (int i = 0; i < q; i++)
	{
		cout << res[i] << endl;
	}
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  i64 ans = 1e18;
  for(i64 i = 0;i <= X || i <= Y;i++) {
    ans = std::min(ans, C * 2 * i + A * std::max(0ll, X - i) + B * std::max(0ll, Y - i));
  }
  cout << ans << endl;
}


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

int main() {

  while( true ) {

    long long int m;
    cin >> m;
    if ( m == 0 ) break;

    vector< pair< long long int, long long int > > s;
    for ( long long int i = 0; i < m; i++ ) {
      long long int x, y;
      cin >> x >> y;
      s.push_back( make_pair( x, y ) );
    }

    long long int n;
    cin >> n;

    vector< pair< long long int, long long int > > t;
    for ( long long int i = 0; i < n; i++ ) {
      long long int x, y;
      cin >> x >> y;
      t.push_back( make_pair( x, y ) );
    }

    if ( m == 1 ) {
      cout << t[0].first - s[0].first << " " << t[0].second - s[0].second << endl;
      continue;
    }

    sort( s.begin(), s.end() );
    sort( t.begin(), t.end() );

    for ( long long int i = 0; i < n - m + 1; i++ ) {
      long long int x = t[i].first - s[0].first;
      long long int y = t[i].second - s[0].second;
      long long int k = 1;
      bool flag = false;
      for ( long long int j = i + 1; j < n; j++ ) {
	if ( s[k].first + x != t[j].first || s[k].second + y != t[j].second ) continue;
	k++;
	if ( k == m ) {
	  cout << x << " " << y << endl;
	  flag = true;
	  break;
	}
      }
      if ( flag ) break;
    }

  }

  return 0;

}

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

using namespace std;

int main(){
    int x;
    cin >> x;
    if (x < 600) {
        cout << 8;
    }
    else if (x < 800){
        cout << 7;
    }
    else if (x < 1000){
        cout << 6;
    }
    else if (x < 1200){
        cout << 5;
    }
    else if (x < 1400){
        cout << 4;
    }
    else if (x < 1600){
        cout << 3;
    }
    else if (x < 1800){
        cout << 2;
    }
    else if (x < 2000){
        cout << 1;
    }
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    int count = 0;
    forn(n) {
        cin >> v[i];
        count += (v[i] >= k);
    }
    cout << count << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 1024