akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    vi a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    vb aa(n,false),bb(n,false);
    rep(i,n-1){
        if(a[i+1]==a[i])aa[i+1]=true;
    }
    rep(i,n-1){
        if(b[i+1]==b[i])bb[i]=true;
    }
    ll ans=1;
    rep(i,n){
        if(aa[i]){
            if(bb[i]){
                ans*=min(a[i],b[i]);
                ans%=mod;
            }
            else if(b[i]>a[i])dame(0);
        }
        else{
            if(bb[i]){
                if(b[i]<a[i])dame(0);
            }
            else if(b[i]!=a[i])dame(0);
        }
    }
    out(ans);
}

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

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<vector<int>> ans(H, vector<int>(W, 0));
    queue<pair<int, int>> que;
    for (int h = 0; h < H; h++) {
        if (h % 2 == 0) {
            for (int w = 0; w < W; w++) {
                que.push({h, w});
            }
        } else {
            for (int w = W - 1; w >= 0; w--) {
                que.push({h, w});
            }
        }
    }

    for (int n = 0; n < N; n++) {
        while (A[n] != 0) {
            auto now = que.front();
            que.pop();
            ans[now.first][now.second] = n + 1;
            A[n]--;
        }
    }

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cout << ans[h][w] << " ";
        }
        cout << endl;
    }
}


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

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

ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    
    rep(i,n){
        cin >> a[i];
    }

    vector<int> r(n),l(n);

    l[0]=a[0];
    for(int i=1;i<n;i++){
        l[i]=gcd(a[i],l[i-1]);
    }

    r.back()=a.back();
    for(int i=n-2;i>=0;i--){
        r[i]=gcd(a[i],r[i+1]);
    }
    ll ans=max(r[1],l[n-2]);
    rep(i,n-2){
        ans=max(ans,gcd(l[i],r[i+2]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
int i,j,p,n,q,a[9]={5,7,5,7,7,-1},d[50];char s[50];
main(){for(;scanf("%d\n",&n),n;){for(i=0;i<n;)d[i++]=strlen(gets(s));
for(i=j=0;j<6;i++)for(p=i,j=q=0;q>=0&&(q=a[j]);)for(j++;q>0;)q-=d[p++];
printf("%d\n",i);
}}

Measured memory_bytes: 1200
n, m = map(int, input().split())
new_li = []
cnt = 0

for i in range(n):
	li = list(map(int, input().split()))
	new_li += li[1:]

for i in range(m+1):
	if new_li.count(i) == n:
		cnt += 1

print(cnt) 

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int n, k, s;
	cin >> n >> k >> s;
	vector<int> ans(n);
	for (int i = 0; i < k; i++) ans[i] = s;
	for (int i = k; i < n; i++) {
		if (s == 1000000000) {
			ans[i] = s - 1;
		}
		else {
			ans[i] = s + 1;
		}
	}
	for (int i : ans) cout << i << ' ';
	cout << endl;
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X):
    C = X.count('1')
    cmr = 0
    cpr = 0
    for b in X:
        if C-1 != 0:
            cmr *= 2
            cmr += int(b)
            cmr %= C - 1
        cpr *= 2
        cpr += int(b)
        cpr %= C + 1

    for i in range(N):
        t = 1
        if X[i] == '0':
            x = (cpr + pow(2, N-i-1, C+1)) % (C+1)
        elif X[i] == '1' and C-1 != 0:
            x = (cmr - pow(2, N-i-1, C-1)) % (C-1)
        else:
            x = 0
            t = 0
        while x != 0:
            x = x % bin(x).count('1')
            t += 1
        print(t)


def main():
    N = read_int()
    X = read_str()
    slv(N, X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82496
import kotlin.math.max
import kotlin.math.min

fun main(args: Array<String>) = tokiomarine2020c()

fun tokiomarine2020c() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    var curr = aList.toLongArray()

    repeat(min(k, 50)) {
        val imos = LongArray(n)

        curr.withIndex().forEach { (index, value) ->
            val left = max(index - value, 0)
            imos[left.toInt()]++

            val right = index + value + 1
            if (right in imos.indices) imos[right.toInt()]--
        }

        for (i in 0 until n - 1) imos[i + 1] += imos[i]

        curr = imos.copyOf()
    }

    val answer = curr.joinToString(" ")

    println(answer)
}


Measured memory_bytes: 87388
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)
	{
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}




Measured memory_bytes: 2104
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
import java.util.regex.Matcher;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行目数字、2行目文字
		String s = br.readLine();

		String r = "B+";
		Pattern p = Pattern.compile(r);
		Matcher m = p.matcher(s);
		s = m.replaceAll("B");

		r = "W+";
		p = Pattern.compile(r);
		m = p.matcher(s);
		s = m.replaceAll("W");


		//StringBuilder sb = new StringBuilder();

		int i = s.length() -1;
		
		i = i > 0 ? i : 0;
		
		System.out.println(i);
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}
template<class Abel>
class WeightedUnionFind{
private:
	::std::vector<int_fast32_t> par;
	::std::vector<Abel> diff_weight;
	size_t n;

public:
	WeightedUnionFind(){}
	WeightedUnionFind(size_t n, Abel identity = 0):n(n){
		par.resize(n, -1);
		diff_weight.resize(n, identity);
	}

	uint_fast32_t find(uint_fast32_t x){
		if (par[x] < 0) {
			return x;
		} else {
			uint_fast32_t root = find(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = root;
		}
	}

	Abel weight(uint_fast32_t x){
		find(x);
		return diff_weight[x];
	}

	size_t size(uint_fast32_t x){
		return -par[find(x)];
	}

	bool unite(uint_fast32_t x, uint_fast32_t y, Abel w){
		w += weight(x); w -= weight(y);
		x = find(x); y = find(y);
		if(x == y) return false;
		if(size(x) < size(y)) std::swap(x, y), w = -w;
		par[x] += par[y];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(uint_fast32_t x, uint_fast32_t y){
		return weight(y) - weight(x);
	}

	bool same(uint_fast32_t x, uint_fast32_t y){
		return find(x) == find(y);
	}
};


int main(void){
	int64 N, M;
	cin >> N >> M;
	WeightedUnionFind<int64> wuf(N);
	REP(i, M){
		int64 l, r, d;
		cin >> l >> r >> d; l--; r--;
		if (!wuf.unite(l, r, d)) {
			if (wuf.diff(l, r) != d) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1920
s = input()
t = input()
ans = 0
ls = len(s)
lt = len(t)
for i in range(ls-lt+1):
    tmp = 0
    for j in range(lt):
        if s[i+j] == t[j]:
            tmp+=1
    ans = max(ans,tmp)
print(lt-ans)

Measured memory_bytes: 73020
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll MOD = 998244353;

vector<int> G[200000];
int color[200000];
int ans[200000];

int dfs(int v, int p, int c) {
	color[v] = c;
	int sum = 0;
	if (c == 0) sum++;
	for (int to : G[v]) {
		if (to == p) continue;
		sum += dfs(to, v, c ^ 1);
	}
	return sum;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	int cnt[3] = { N / 3,N / 3,N / 3 };
	if (N % 3 == 1) cnt[1]++;
	else if (N % 3 == 2) cnt[1]++, cnt[2]++;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ret = dfs(0, -1, 0);
	if (ret <= N / 3) {
		for (int i = 0; i < N; i++) {
			if (color[i] == 0) {
				ans[i] = 3 * cnt[0];
				cnt[0]--;
			}
			else {
				if (cnt[1] > 0) {
					ans[i] = 3 * (cnt[1] - 1) + 1;
					cnt[1]--;
				}
				else if (cnt[2] > 0) {
					ans[i] = 3 * (cnt[2] - 1) + 2;
					cnt[2]--;
				}
				else {
					ans[i] = 3 * cnt[0];
					cnt[0]--;
				}
			}
		}
	}
	else if (N - ret <= N / 3) {
		for (int i = 0; i < N; i++) {
			if (color[i] == 1) {
				ans[i] = 3 * cnt[0];
				cnt[0]--;
			}
			else {
				if (cnt[1] > 0) {
					ans[i] = 3 * (cnt[1] - 1) + 1;
					cnt[1]--;
				}
				else if (cnt[2] > 0) {
					ans[i] = 3 * (cnt[2] - 1) + 2;
					cnt[2]--;
				}
				else {
					ans[i] = 3 * cnt[0];
					cnt[0]--;
				}
			}
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			if (color[i] == 0) {
				if (cnt[1] > 0) {
					ans[i] = 3 * (cnt[1] - 1) + 1;
					cnt[1]--;
				}
				else {
					ans[i] = 3 * cnt[0];
					cnt[0]--;
				}
			}
			else {
				if (cnt[2] > 0) {
					ans[i] = 3 * (cnt[2] - 1) + 2;
					cnt[2]--;
				}
				else {
					ans[i] = 3 * cnt[0];
					cnt[0]--;
				}
			}
		}
	}
	for (int i = 0; i < N; i++) cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 21504
#include <bits/stdc++.h>
#define st first
#define nd second
using namespace std;

constexpr int nax = 1e5;

int n;
map< int, int > M;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    
    for (int i = 0; i < n; ++i)
    {
        int v; cin >> v;
        ++M[v];
    }
    
    if (M.find(0) != M.end() and M[0] == n)
        return cout << "Yes" << '\n', 0;

    if (n % 3) 
        return cout << "No" << '\n', 0;

    int su = 0;
    for (auto& p : M)
    {
        if (p.nd % (n / 3))
            return cout << "No" << '\n', 0;
        if ((p.nd / (n / 3)) & 1)
            su xor_eq p.st;
    }

    if (su) return cout << "No" << '\n', 0;

    cout << "Yes" << '\n';
}


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

int main(){
  string S, T;
cin >> S;
cin >> T;
  int o = 0;
  for(int q = 0; q < 3; q++) {
    if(S.at(q) == T.at(q)) {
      o++;
    }
  }
  cout << o << endl;
}

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

int main() {
//入力
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++) cin >> mochi.at(i);
  
//ソート、出力
  sort(mochi.begin(), mochi.end());
  int count = 1;
  for (int i = 0; i < N - 1; i++) {
    if (mochi.at(i) != mochi.at(i + 1)) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

struct P{
    int x,y;
};

int main (){
    int d;cin>>d;
    cout<<"Christmas";
    rep(i,0,25-d)cout<<" Eve";
    cout<<endl;
}


/*
5 5
2...2
.....
..1..
.....
2...2

5 10
..3.......
.....1....
..........
....3.....
..........



1010
00000
00000
00000
00000
*/


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

int main() {
	string w;
	cin >> w;

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

	int count = 0;
	bool flag = true;

	if(w.size() == 1) flag = false;
	else {
		for(int i=0;i<w.size()-1;i++) {
			if(w[i] == w[i+1]) count++;
			else {
				if(count%2 == 0) flag = false;
				count = 0;
			}
		}
	}

	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
C=[]
A=[]
for i in range(N):
  L=list(map(int,input().split()))
  C.append(L[0])
  A.append(L[1:])
res=-1
for i in range(1<<N):
  und=[0]*M
  cost=0
  for j in range(N):
    if (i>>j)&1==0:
      continue
    cost+=C[j]
    for k in range(M):
      und[k]+=A[j][k]
    if min(und)>=X:
      if res==-1:
        res=cost
      else:
        res=min(res,cost)
print(res)

Measured memory_bytes: 9160
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, F[111][6][2], P[111][22], pp = -INF;

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    for (int j = 0; j < 5; j ++)
      for (int k = 0; k < 2; k ++)
        std::cin >> F[i][j][k];

  for (int i = 0; i < N; i ++)
    for (int j = 0; j < 11; j ++)
      std::cin >> P[i][j];

  for (int t = 1; t < 1024; t ++) {
    int p = 0;
    
    for (int i = 0; i < N; i ++) {
      int c = 0;
      
      for (int j = 0; j < 5; j ++)
        for (int k = 0; k < 2; k ++)
          if (F[i][j][k] && (t & (1 << (j * 2 + k))))
            c ++;

      p += P[i][c];
    }

    pp = std::max(p, pp);
  }

  std::cout << pp << std::endl;
    
  return 0;
}


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

int main() {
  int K;
  cin >> K;
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << v.at(K-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>	
#include <utility>	
#include <list>		
#define N 10000	
#define INF (1<<31-1);
using namespace std;

typedef pair<int,int> pii;	
vector<pii> adj[N];	
bool color[N];	
int dist[N];	
int n;	
priority_queue<pii> pq; 

int dijkstra(int k){	
	for(int i=0;i<n;i++){
		color[i]=false; 
		dist[i]=INF;	
	}
	color[k]=true; 
	dist[k]=0;	
	for(int i=0;i<adj[k].size();i++){
		pq.push(adj[k][i]); 
	}
	while(!pq.empty()){	
		pii temp=pq.top();pq.pop();	
		temp.first=-temp.first;	
		if(color[temp.second])continue;	
		color[temp.second]=true; 
		dist[temp.second]=temp.first;	
		for(int i=0;i<adj[temp.second].size();i++){
			if(!color[adj[temp.second][i].second])pq.push(make_pair(-dist[temp.second]+adj[temp.second][i].first,adj[temp.second][i].second));
		}
	}

	for(int i=0;i<n;i++) cout<<i<<" "<<dist[i]<<endl;
	return 0;
}
int main(void){
	int v,c;	
	int u,k;	
	cin>>n; 
	for(int i=0;i<n;i++){ 
		cin>>u>>k;	
		for(int j=0;j<k;j++){
			cin>>v>>c;	
			adj[u].push_back(make_pair(-c,v));	
		}
	}
	dijkstra(0);	
	return 0;
}

Measured memory_bytes: 9832
number = input().split(" ")
a = int(number[0])
b = int(number[1])
result = 0
con1 = a >= 1 and a <= 100
con2 = b >= 1 and b <= 100
if con1 == True and con2 == True:
    result = a * b
    print(result)
else:
    print()


Measured memory_bytes: 9172
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc;
vector<ll> va,vb,vc;
set<int> sta;


ll qa(int jj){
    ll rs=0;
    while(jj%2==0){
        jj/=2;
        rs++;
    }
    return rs;
}

int main(){
    cin>>n;
    m=100000000;
    for(int i=0;i<n;i++){
        cin>>aa[i];
        m=min(m,qa(aa[i]));
    }
    C(m);
    
    
}

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

ll f(ll n,ll a,ll b){
  return b/n-(a-1)/n;
}

ll g(ll a,ll b){
  int n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

int main(){
  int i,j,cnt=0;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<b-a+1-f(c,a,b)-f(d,a,b)+f(c*d/g(c,d),a,b);
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N, K;
	cin >> N >> K;
	vector<uint64_t> dp(K+1), dp2(K+1);
	vector<int> a(N);
	for (auto& ai : a)
		cin >> ai;
	uint64_t mod = 1e9 + 7;
	dp[K] = 1;
	for(auto ai : a)
	{
		fill(all(dp2), 0);
		uint64_t su = 0;
		forn(j, ai)
			su += dp[j];
		su %= mod;
		forn(i, K + 1)
		{
			if (i + ai <= K)
			{
				su += dp[i + ai];
				if (su >= mod)
					su -= mod;
			}
			dp2[i] = su;
			su = su + mod - dp[i];
			if (su >= mod)
				su -= mod;
		}
		dp.swap(dp2);
	}
	cout << dp[0] << endl;
	return 0;
}


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

int main() {

	int n, m; cin >> n >> m;
	vector<pair<int, int>> pa;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		pa.push_back({ b,a });
	}
	sort(pa.begin(), pa.end());
	int ans = 0;
	for (int i = 0; i < pa.size(); ) {
		int tmpIndex = pa[i].first - 1;
		int cnt = 1;
		ans++;
		for (int j = i + 1; j < pa.size(); j++) {
			if (pa[j].second <= tmpIndex) {
				cnt++;
			}
			else {
				break;
			}
		}
		i += cnt;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> p(n+1);
  rep(i,n+1){
    p[i]=200020;
  }
  map<int,int> mp;
  rep(i,n){
    int a;
    cin>>a;
    mp[a]++;
  }
  for(auto x : mp){
    p[x.first]=x.second;
  }
  sort(p.begin(),p.end());


  if(mp.size()-k<=0){
    cout<<0<<endl;
  }else{
    int ans=0;
    rep(i,mp.size()-k){
      ans+=p[i];
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 13384
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 110

ll f(ll n,ll k){
	ll ans=0;while(n)ans+=(n/k),n/=k;
	return ans;
}
ll get(ll n,ll k){
	ll ans=f(n,2)-f(k,2)-f(n-k,2);
	if(ans)return 0;
	return 1;
}
int main(){
	IOS;
	tihs;

	ll n;cin>>n;
	string s;cin>>s;
	ll par=0,ok=0;
	rep(i,0,n){
		ll x=s[i]-'0';x--;
		(par+=get(n-1,i)*x)%=2;
		if(x==1)ok=1;
	}
	if(par&1){
		cout<<1;
		return 0;
	}
	if(ok){
		cout<<0;
		return 0;
	}
	par=0;
	rep(i,0,n){
		ll x=s[i]-'0';x--;
		(par+=get(n-1,i)*(bool)x)%=2;
	}
	cout<<(par?2:0);

	


	return 0;
}

Measured memory_bytes: 1948
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

/*
vvl comb(int n, int r) {
	vvl v(n + 1,vl(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() {
	ll a[1010],b[1010],c[1010];
	vl v;
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	rep(i,0,x)cin>>a[i];
	rep(i,0,y)cin>>b[i];
	rep(i,0,z)cin>>c[i];
	sort(a,a+x,greater<>());
	sort(b,b+y,greater<>());
	sort(c,c+z,greater<>());
	rep(i,1,x+1)rep(j,1,y+1)rep(l,1,z+1){
		if(i*j*l<=k)v.push_back(a[i-1]+b[j-1]+c[l-1]);
	}
	sort(ALL(v),greater<>());
	rep(i,0,k)print(v[i]);
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define MP make_pair
using namespace std;

int n, vis[100100];

int main() {
	scanf("%d", &n);
	deque<pair<int, int> > q;
	q.push_back(MP(1, 1));
	while(!q.empty()) {
		pair<int, int> x = q.front(); q.pop_front();
		if(vis[x.first]) continue;
		vis[x.first] = 1;
		if(x.first == 0) {
			printf("%d\n", x.second);
			return 0;
		}
		q.push_front(MP(x.first * 10 % n, x.second));
		q.push_back(MP((x.first * 10 + 1) % n, x.second + 1));
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(),a.end(),greater<ll>());
    ll mx1 = 0, mx2 = 0;
    ll i = 0;
    while(i < n-1){
        if(a[i] == a[i+1]){
            if(mx1 == 0){
                mx1 = a[i];
                i++;
            }else{
                mx2 = a[i];
                break;
            }
        }
        i++;
    }
    cout << mx1*mx2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    int a;
    int ans = n;
    REP(i, m) {
        cin >> a;
        ans -= a;
    }
    cout << (ans < 0 ? -1 : ans) << endl;
}


Measured memory_bytes: 3644
n = int(input())
d_ans = {}
for _ in range(n):
  line = input()
  char_lst = 26*[0]
  for char in line:
    char_lst[ord(char) - 97] += 1
  try:
    char_tup = tuple(char_lst)
    d_ans[char_tup] += 1
  except KeyError:
    d_ans[char_tup] = 1

ans = 0    
for val in d_ans.values():
  ans += (val*(val-1)) >> 1
print(ans)
  
  

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

using namespace std;

int main() {
    long n;
    cin >> n;
    vector<long> a(n);
    for (long i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<long> ans;
    for (long i = n-1; i >= n/2+1; --i) {
        ans.push_back(a[i]);
    }
    for (long i = n/2; i >= 0; --i) {
        long sum = 0;
        for (long j = i+1+i+1; j <= n; j += i+1) {
            sum += ans[n-j];
        }
        ans.push_back((sum+a[i])%2);
    }
    long sum = accumulate(ans.begin(), ans.end(), 0L);
    cout << sum << endl;
    if (sum != 0) {
        long last_1;
        for (long i = n-1; i >= 0; --i) {
            if (ans[i] == 1) {
                last_1 = i;
                break;
            }
        }
        for (long i = 0; i < last_1; ++i) {
            if (ans[i] == 1) {
                cout << n - i;
                cout << ' ';
            }
        }
        cout << n - last_1 << endl;

    }
    
	return 0;
}

Measured memory_bytes: 4080
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll INF = -1;

int solve(void);

int main(void)
{
	while (solve())
	{
	}

	return 0;
}

int solve(void)
{
	ll N, W;
	cin >> N >> W;

	vector<ll> w(N), v(N);

	for(int i = 0; i < N; i++)
		cin >> w[i] >> v[i];

	vector<ll> dp(W+1, 0);

	for (int i = 0; i < N; i++) 
	{
		for (int j = W; j >= 0; j--)
		{
			const ll next_weight = j + w[i];
			if(next_weight > W) { continue; }

			const ll next_val = dp[j] + v[i];
			dp[next_weight] = max(dp[next_weight], next_val);
		}
	}

	ll ans = 0;
	for(auto d: dp)
		ans = max(d, ans);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
//#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE    
    freopen("input.txt", "r", stdin);     
    freopen("output.txt", "w", stdout);
#endif

int n ;int m;
cin>>n>>m;
char arr[n][m];
rep(i,n){
	rep(j,m){
		cin>>arr[i][j];
	}
}
int dp[n+5][m+5];
memset(dp,0,sizeof(dp));
// initialisation
dp[1][1] = 1;

int mod  = 1e9+7;

for(int i = 1;i<=n;i++){
	for(int j = 1;j<=m;j++){
		if(i == 1 && j == 1)
			continue;
		if(arr[i-1][j-1] == '#')
			dp[i][j] = 0;
		else
			dp[i][j] = (dp[i][j-1]%mod+dp[i-1][j]%mod)%mod;
	}
}

// for(int i = 0;i<=n;i++){
// 	for(int j = 0;j<=m;j++){
// 		cout<<dp[i][j]<<" ";
// 	}
// 	cout<<endl;
// }
cout<<dp[n][m]%mod;








#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#endif

return 0;
}

Measured memory_bytes: 8480
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	int x,a,b;
	while(scanf("%d%d%d",&x,&a,&b)!=EOF){
		int sum=b-a;
		if(sum<=0)
			printf("delicious\n");
		else if(sum>0&&sum<=x)
			printf("safe\n");
		else
			printf("dangerous\n");	
	}
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
UV = [tuple(map(int,input().split())) for i in range(M)]
S,T = map(int,input().split())
S,T = S-1,T-1

es = [[] for _ in range(N*3)]
for u,v in UV:
    u,v = u-1,v-1
    es[u].append(v+N)
    es[u+N].append(v+N+N)
    es[u+N+N].append(v)

from collections import deque
q = deque([S])
INF = float('inf')
dist = [INF] * (N*3)
dist[S] = 0
while q:
    v = q.popleft()
    for to in es[v]:
        if dist[to] <= dist[v]+1: continue
        dist[to] = dist[v]+1
        q.append(to)
        if to==T:
            print(dist[to] // 3)
            exit()
print(-1)

Measured memory_bytes: 74656
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if ( ceil(a/(float)d) < ceil(c/(float)b) )
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 3684
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
asu=[]
s=0
for i in a:
  s+=i
  asu.append(s)
asu.append(0)
bsu=[]
s=0
for i in b:
  s+=i
  bsu.append(s)
bsu.append(0)
ac=n-1
bc=-1
maxc=0

while (bc!=m)and(ac>=-1):
  while (bc!=m) and (asu[ac]+bsu[bc]<=k):
    bc+=1
  if asu[ac]+bsu[bc-1]<=k:
    maxc=max(maxc,ac+bc+1)
  ac-=1
print(maxc)


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

class Edge{
	public:
		long long cost;
		int from, to;
		Edge(long long c, int f, int t){
			cost = c;
			from = f;
			to = t;
		}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
bool operator < (const Edge &e, const Edge &f){
	return e.cost != f.cost ? e.cost > f.cost : e.from != f.from ? e.from < f.from : e.to < f.to;
}
constexpr long long INF = 1e18+9;
void dijkstra(int s, const Graph &g, vector<long long> &dist){
	int V = g.size();
	dist = vector<long long>(V, INF);
	dist[s] = 0;
	priority_queue<Edge> q;
	q.push(Edge(0, s, s));
	while(!q.empty()){
		Edge e = q.top();
		q.pop();
		if(dist[e.to] < e.cost) continue;
		for(int i=0; i<(int)g[e.to].size(); ++i){
			Edge f = g[e.to][i];
			if(dist[f.to] > dist[e.to] + f.cost){
				dist[f.to] = dist[e.to] + f.cost;
				q.push(Edge(dist[f.to], s, f.to));
			}
		}
	}
}

void solve(int w, int h){
	Graph g(w*h);
	for(int i=0; i<2*h-1; ++i){
		if(i % 2 == 0){
			for(int j=0; j<w-1; ++j){
				int t;
				cin >> t;
				if(t == 0){
					g[w*(i/2)+j].push_back(Edge(1, w*(i/2)+j, w*(i/2)+j+1));
					g[w*(i/2)+j+1].push_back(Edge(1, w*(i/2)+j+1, w*(i/2)+j));
				}
			}
		}else{
			for(int j=0; j<w; ++j){
				int t;
				cin >> t;
				if(t == 0){
					g[w*(i/2)+j].push_back(Edge(1, w*(i/2)+j, w*(i/2+1)+j));
					g[w*(i/2+1)+j].push_back(Edge(1, w*(i/2+1)+j, w*(i/2)+j));
				}
			}
		}
	}
/*	for(int i=0; i<w*h; ++i){
		for(int j=0; j<g[i].size(); ++j){
			cout << g[i][j].to << " ";
		}
		cout << "\n";
	}
*/	vector<long long> v;
	dijkstra(0, g, v);
	if(v[w*h-1] == INF) cout << 0 << "\n";
	else cout << v[w*h-1]+1 << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int w, h;
		cin >> w >> h;
		if(w+h==0) return 0;
		solve(w, h);
	}
}


Measured memory_bytes: 3096
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int h = Integer.parseInt(scan.next());
		int w = Integer.parseInt(scan.next());
		
		int count = 0;
		for(int i = 0;i < n; ++i){
			int a = Integer.parseInt(scan.next());
			int b = Integer.parseInt(scan.next());
			if(a >= h && b >= w) ++count;

		}
		System.out.print(count);

	}
}



Measured memory_bytes: 22356
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int t[1000 * 100 + 5];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, c, k;
	cin >> n >> c >> k;
	for(int i = 0; i < n; i++)
		cin >> t[i];
	sort(t , t + n);
	int ans = 0, i = 0;
	while(i < n){
		int x = min(i + c, n), y = t[i] + k;
		for( ; i < x; i++)
			if(t[i] > y)
				break;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
LIMIT = 1000000000000000000

def main():
    N = int(input())  # 文字列または整数(一変数)
    a = list(map(int, input().split()))  # 整数のリスト
    answer = 1

    for i in range(N):
        answer *= a[i]
        if answer > LIMIT:
            if 0 in a[i:]:
                print(0)
                return
            else:
                print(-1)
            return

    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    int N; cin >> N;
    vll A(N),B;
    rep(i,N) cin >> A[i];
    ll ans = 1000000001;
    int min_val,min_idx;
    int count;
    while(1){
        sort(ALL(A));
        rep(i,N){
            if(A[i]!=0){
                min_idx = i;
                min_val = A[i];
                break;
            }
        }
        count = 0;
        rep(i,N){
            if(i == min_idx) {
                count++;
                continue;
            }
            A[i] %= min_val;
            if(A[i]!=0) count++;
        }
        if(count == 1) break;
    }
    print(min_val);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3996
n = int(input())
for i in range(n):
    str = input().split()
    arr = [int(str[j]) for j in range(len(str))]
    b,c = 0,0
    flag = True
    for i in range(len(arr)):
        if b < arr[i]:
            b = arr[i]
            continue
        if c < arr[i]:
            c = arr[i]
            continue
        print("NO")
        flag = False
        break
    if flag:
        print("YES")

Measured memory_bytes: 7648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k,x;cin>>k>>x;
  print((500*k>=x)?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int A[8]={1,2,1,2,1,4,1,4};
int P[8];
main()
{
	while(cin>>P[0]>>P[1]>>P[2]>>P[3]>>P[4]>>P[5]>>P[6]>>P[7])
	{
		int ans=1919810;
		int id=0;
		for(int i=0;i<8;i++)
		{
			int now=0;
			for(int j=0;j<8;j++)
			{
				if(A[(i+j)%8]>P[j])now+=A[(i+j)%8]-P[j];
			}
			if(ans>now)
			{
				ans=now;
				id=i;
			}
			else if(ans==now)
			{
				int L=0,R=0;
				for(int j=0;j<8;j++)
				{
					L=L*10+A[(id+j)%8];
					R=R*10+A[(i+j)%8];
				}
				if(L>R)id=i;
			}
		}
		for(int i=0;i<8;i++)cout<<A[(id+i)%8]<<(i==7?"\n":" ");
	}
}



Measured memory_bytes: 3048
#include <stdio.h>

 int main(void) {
 int a, b, c, tmp;

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

 if(b < a) {
 tmp = a;
 a = b;
 b = tmp;
 }

 if(c < b) {
 tmp = b;
 b = c;
 c = tmp;

 if(b < a) {
 tmp = a;
 a = b;
 b = tmp;
 }
 } 

 printf("%d %d %d\n", a, b, c);

 return 0;
 }



Measured memory_bytes: 2056
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		int i, j;
		
		for(i=1;i<10;i++){
			for(j=1;j<10;j++){
				System.out.println(i + "x" + j + "=" + (i*j));
			}
		}
	}
}

Measured memory_bytes: 16852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e6 + 10;
const ll mod = 1e9 + 7;
int n, m, k;
ll a[3010][3010];
ll dp[3010][3010][4];
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)a[i][j] = -inf;
	for (int i = 1; i <= k; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (a[x][y] != -inf)while (1);
		scanf("%lld", &a[x][y]);
	}
	for (int i = 0; i <= n; i++)for (int j = 0; j <= m; j++)for (int x = 0; x <= 3; x++)dp[i][j][x] = -inf;
	for (int i = 0; i <= n; i++)for (int j = 0; j <= m; j++)dp[i][j][0] = 0;
	dp[1][1][0] = 0; if (a[1][1] >= 0)dp[1][1][1] = a[1][1];
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j][0] = 0;
			if (i == 1 && j == 1)continue;
			if (a[i][j] <= 0) {
				for (int x = 0; x <= 3; x++) {
					dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][x]);
					dp[i][j][x] = max(dp[i][j][x], dp[i][j - 1][x]);
				}
				continue;
			}
			dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0]);
			for (int x = 0; x <= 3; x++)dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][x]), dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][x] + a[i][j]);
			for (int x = 1; x <= min(j, 3); x++) {
				dp[i][j][x] = max(dp[i][j][x], max(dp[i][j - 1][x], dp[i][j - 1][x - 1] + a[i][j]));
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= 3; i++)ans = max(ans, dp[n][m][i]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 356536
#include<bits/stdc++.h>
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef unsigned long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}
const int N = (int)2e5+5;
const int Q = 301;

int a,b,d=0;
vector<int> v[N];
int dist[N];
void run(int i, int p) {
    if (i!=p) {
        dist[i] = 1 + dist[p];
    }
    for (auto it:v[i]) {
        if (it!=p) {
            run(it, i);
        }
    }
}
vector<pi> cnt;
void dfs(int i,int p,int dis,int steps) {
    if (i!=p) {
        if (dis<2) {
            return;
        }
        dis--;
        steps++;
    }
    if (v[i].size()==1) {
        //d = max(d, dis);
        cnt.pb({dis, steps});
    }
    for (auto it:v[i]) {
        if (it==p) {
            continue;
        }
        if (dist[it]>dist[i]) {
            dfs(it, i, dis+1, steps);
        }
        else {
            dfs(it, i, dis-1, steps);
        }
    }
}
void solve() {
    int n, x, y;
    cin>>n>>a>>b;
    REP(i,1,n-1) {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    run(b,b);
    dfs(a,a,dist[a],0);
    int ans = 0;
    for (auto it:cnt) {
        ans = max(ans, it.first + it.second - 1);
    }
    cout<<ans;
}
int main() {
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 14848