akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
vi d, f;
vvi G;
int t = 0;

void dfs(int n)
{
    t++;
    d[n] = t;
    for(int i : G[n]) if(d[i] == 0) dfs(i);
    t++;
    f[n] = t;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> n;
    G.resize(n+1);
    d.resize(n+1, 0);
    f.resize(n+1, 0);
    REP(i, n)
    {
        int u, k; cin >> u >> k;
        REP(j, k)
        {
            int v; cin >> v;
            G[u].pb(v);
        }
    }

    REPS(i, n)
    {
        if(d[i] == 0) dfs(i);
    }

    REPS(i, n) cout << i << " " << d[i] << " " << f[i] << endl;
}


Measured memory_bytes: 3188
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s >= d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;

    }
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


Measured memory_bytes: 3652
n, a = [int(i) for i in input().split()]

x = [int(i) for i in input().split()] 
y = [int(i)-a for i in x] 


max = max(x)

dp = [[0 for _ in range(2*n*max+1)] for _ in range(n+1)]

dp[0][n*max] = 1 

for i in range(1, n+1):
	for j in range(2*n*max+1):
		if j - y[i-1] < 0 or j - y[i-1] > 2*n*max:
			dp[i][j] = dp[i-1][j]
		else: 
			dp[i][j] = dp[i-1][j] + dp[i-1][j-y[i-1]]

result = dp[n][n*max]-1

print(result)







Measured memory_bytes: 5744
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
ll a,b;
int main()
{
	scanf("%lld %lld",&a,&b);
	if(a>0)
		printf("Positive\n");
	else if(a<=0&&b>=0)
		printf("Zero\n");
	else if(a<0&&b<0)
	{
		if((b-a+1)%2==0)
			printf("Positive\n");
		else
			printf("Negative\n");
	}
	return 0;
}


Measured memory_bytes: 256
# AGC002B - Box and Ball
def main():
    N, M = tuple(map(int, input().split()))
    X = tuple(tuple(map(int, input().split())) for _ in range(M))
    R = [0] * (N + 1)  # red ball may be in box i
    R[1] = 1
    C = [1] * (N + 1)  # number of balls in box i (count)
    for x, y in X:
        if R[x]:
            R[y] = 1
        C[x] -= 1
        C[y] += 1
        if C[x] == 0:
            R[x] = 0
    ans = sum(R[1:])
    print(ans)


if __name__ == "__main__":
    main()

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

int main(){
  int n, m, q;
  int l, r;
  int grid[510][510] = {};
  int train[510][510] = {};
  cin >> n >> m >> q;
  for(int i = 0; i < m; i++){
    cin >> l >> r;
    grid[l][r]++;
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      train[i][j] = train[i][j-1] + grid[i][j];
    }
  }
  for(int i = 0; i < q; i++){
    cin >> l >> r;
    int sum = 0;
    for(int j = l; j <= r; j++){
      sum += train[j][r] - train[j][l-1];
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int n, a[100];

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = (n - 1); i >= 0; i--) {
		if (i != 0)
			printf("%d ", a[i]);
		else
			printf("%d\n", a[i]);
	}

	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int group(int n){
    if(n==2) return 3;
    else if(n==4 || n==6 || n==9 || n==11) return 2;
    else return 1;
}

int main(){
    int x, y;
    cin >> x >> y;
    
    if(group(x)==group(y)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;

    int ret = 0;
    int size = static_cast<int>(S.size());
    rep(i, size) {
        if (S[i] != T[i]) {
            ++ret;
        }
    }

    cout << ret << endl;
}


Measured memory_bytes: 3920
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature qw/say/;

my $S = <STDIN>;
my $buf = '';
for my $c (split(//, $S)) {
    if ($c eq 'B') {
        $buf =~ s/.$//;
    } else {
        $buf .= $c;
    }
}
say $buf;

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

int main() {
    
      long long n,i,k,j,sum=0,count=0,ans=0,m,w,mx=0,l,r,x,y;
      cin>>n;
      
      ans=n-1;
      for(i=2;i<=sqrt(ans);i++)
      {
          if(ans%i==0)
          {
              if(i!=(ans/i))
              count+=2;
              else
              count++;
          }
      }
      
      if(ans!=1)
      count++;
      for(i=2;i<=sqrt(n);i++)
      {
          if(n%i==0)
          {
             k=n;
            while(k%i==0)
            {
              k=k/i;
            }
            if(k==1)
            count++;
            else
            {
                if(k%i==1)
                count++;
            }
            
            if(i!=(n/i))
            {
                 k=n;
               while(k%(n/i)==0)
               {
                 k=k/(n/i);
               }
               if(k==1)
               count++;
               else
              {
                if(k%(n/i)==1)
                count++;
               }
            }

          }
      }
      cout<<count+1;
}


Measured memory_bytes: 256
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();

	let s = get().as_bytes();
    let t = get().as_bytes();
    
    if s.len() != t.len() {
    	println!("No");
        return;
    }
    
    use std::collections::HashMap;
    
    let mut hs = HashMap::new();
    let mut ht = HashMap::new();
    
    for i in 0..s.len() {
    	let cs = s[i];
        let x = hs.len();
        let p = *hs.entry(cs).or_insert(x);
        let ct = t[i];
        let y = ht.len();
        let q = *ht.entry(ct).or_insert(y);
        if p != q {
        	println!("No");
            return;
        }
    }
    
    // この部分ないのダメじゃね？
//    for key in hs.keys() {
//    	if !ht.contains_key(&key) {
//    		println!("No");
//            return;
//        }
//    }
	// 誤読、任意の文字と交換できるのか
    
    println!("Yes");
    
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	int a, z;
	for(int i=0; i<s.size(); i++){
		if(s[i] == 'A'){
			a = i;
			break;
		}
	}
	for(int i=s.size()-1; i>=0; i--){
		if(s[i] == 'Z'){
			z = i;
			break;
		}
	}
	int ans = z - a + 1;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3868
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val n = Scanner.nextInt()
  val k = Scanner.nextInt()
  val _ = Array.fill(n)(Scanner.nextInt())
  val result = if ((n-1)%(k-1)==0){
    (n-1)/(k-1)
  } else {
    (n-1)/(k-1) + 1
  }
  println(result)
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	int64_t m = 1000000007;
	int64_t result = 1;

	for( int i = 1; i <= N; ++i ) {
		result = result * i % m;
	}

	cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int ans=0;
	for (int i=0;;i++)
	{
		n/=k;
		ans++;
		if (n==0)  break;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>){
    val n = readLine()?.toInt()?: return
    var divisor:Int = 0

    for(i in 9 downTo 1){
        if(n % i == 0) {
            divisor = n / i
            break
        }
    }

    if(divisor == 0 || divisor > 9){
        println("No")
    } else{
        println("Yes")
    }
}

Measured memory_bytes: 32020
n, m, k = map(int, input().split())

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True

def same(x, y):
    return find(x) == find(y)

def size(x):
    return -par[find(x)]

par = [-1] * n
friend = [0] * n

for _ in range(m):
    a, b = map(int, input().split())
    unite(a-1, b-1)
    friend[a-1] += 1
    friend[b-1] += 1

block = [[] for _ in range(n)]

for _ in range(k):
    c, d = map(int, input().split())
    block[c-1].append(d-1)
    block[d-1].append(c-1)

for i in range(n):
    ans = size(i) - friend[i] - 1
    for j in block[i]:
        if same(i, j):
            ans -= 1
    print(ans, end=' ')

Measured memory_bytes: 112472
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

void err(){
  std::cout << "No" << '\n';
  exit(0);
}
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  ll cnt = 0;
  vector<string> s(n);
  re(i, n) std::cin >> s[i];
  for(int i=0;i<n;i++){
    for(auto c:s[i]){
      if(c=='(') cnt++;
      if(c==')') cnt--;
    }
  }
  if(cnt!=0) err();
  vvl dat = VV(n, 2, 100000000, ll); // min , max
  for(int i=0;i<n;i++){
    cnt = 0;
    for(auto c:s[i]){
      if(c=='(') cnt++;
      else cnt--;
      dat[i][0] = min({(ll)0, dat[i][0], cnt});
    }
    dat[i][1] = cnt;
  }
  vvl pl;
  vvl mi;
  re(i, n) {
    if(dat[i][1]>=0) pl.push_back(dat[i]);
    else mi.push_back(dat[i]);
  }
  sort(all(pl));
  reverse(all(pl));
  ll now = 0;
  for(auto t:pl){
    if(now+t[0]<0) err();
    now += t[1];
  }

  sort(all(mi), [](vll a, vll b){
    return a[1]-a[0] > b[1]-b[0];
  });
  for(auto t:mi){
    if(now+t[0]<0) err();
    now += t[1];
  }
  if(now!=0) err();
  std::cout << "Yes" << '\n';
  return 0;
}


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

int main(void) {

	int num, pass[4], check = 0;

	cin >> num;

	pass[0] = num / 1000;
	pass[1] = num % 1000 / 100;
	pass[2] = num % 100 / 10;
	pass[3] = num % 10;

	for (int i = 1;i < 4;i++) {
		if (pass[i] == pass[i - 1]) {
			check = 1;
		}
	}

	if (check == 0) {
		cout << "Good" << endl;
	}
	else {
		cout << "Bad" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15

int const N = 1e5+1;
long long a[N];


int main(){

 long long n;
 cin>>n;

 a[0] = 2,a[1] = 1;

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

    a[i] = a[i-2] + a[i-1];

 }

  cout<<a[n]<<endl;

 return 0;
}


Measured memory_bytes: 4416
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n; cin >> n;
	string ss[] = { "AC","WA","TLE","RE" };
	int ans[4] = {};
	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		for (int j = 0; j < 4; ++j)
			if (s == ss[j]) ++ans[j];
	}
	for (int i = 0; i < 4; ++i)
		cout << ss[i] << " x " << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-10;
int INF=1e9;
int MOD=1000000007;
int _and[3][3]={0,0,0,0,1,1,0,1,2};
int _or[3][3]={0,1,2,1,1,2,2,2,2};
int _not[3]={2,1,0};
char pyon(string s,int p,int q,int r){
	if(s.size()==1)return s[0]=='P'?p+'0':s[0]=='Q'?q+'0':s[0]=='R'?r+'0':s[0];
	int cnt=0,f,now=-1;
	vector<int> V;
	REP(i,s.size()){
		if(s[i]=='*')f=0;
		else if(s[i]=='+')f=1;
		else if(s[i]=='-')cnt++;
		else{
			int mt=s[i]=='P'?p:s[i]=='Q'?q:s[i]=='R'?r:s[i]-'0';
			if(cnt%2==1){
				mt=_not[mt];
				cnt=0;
			}
			if(now==-1)now=mt;
			else{
				if(f==0)now=_and[now][mt];
				else now=_or[now][mt];
			}
		}
	}
	return now+'0';
}
char rec(string s,int p,int q,int r){
	stack<int> pr;
	REP(i,s.size()){
		if(s[i]=='(')pr.push(i);
		if(s[i]==')'){
			int top=pr.top();pr.pop();
			string t;
			t.assign(s,top+1,i-top-1);
			char tt=pyon(t,p,q,r);
			s.erase(top,i-top+1);
			s.insert(s.begin()+top,tt);
			i=top-1;
		}
	}
	char tt=pyon(s,p,q,r);
	return tt;
}
int main(){
	string s;
	while(cin>>s&&s!="."){
		int cnt=0;
		REP(i,3)REP(j,3)REP(k,3){
			char t=rec(s,i,j,k);
			if(t=='2')cnt++;
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define tc int t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff(i,a,b) for(i=a;i<b;i++)
#define fb(i,b,a) for(i=b;i>a;i--)
#define ffi(i,a,b,c) for(i=a;i<b;i+=c)
#define fbi(i,b,a,c) for(i=b;i>a;i-=c)
#define clin(s) getline(cin,s)
#define MOD 1e9+7
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ub upper_bound
#define lb lower_bound
int main() {
	fio;
	long n,k,i,j;
	cin>>n>>k;
	long arr[n];
	long dp[n];
	if(k>n)k=n;
	ff(i,0,n){
		cin>>arr[i];
	}
	dp[0]=0;
	ff(i,1,k){
		dp[i]=abs(arr[0]-arr[i]);
	}
	ff(i,k,n){
		//dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
		//cout<<dp[i]<<" ";
		dp[i]=LONG_MAX;
		ff(j,1,k+1){
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	//cout<<"\n";
	cout<<dp[n-1]<<"\n";
	return 0;
}


Measured memory_bytes: 1792
//
// Write a program which reads an integer x and print it as is.
// Note that multiple datasets are given for this problem.
//

import java.io.BufferedReader;
import java.io.InputStreamReader;

interface Aggregate {
	public abstract Iterator createIterator();
}

interface Iterator {
	public abstract boolean hasNext();
	public abstract Object next();
}

 class TestCases implements Aggregate {
	private int[] data;
	private int last = 0;
	
	public TestCases(int max) {
		data = new int[max];
	}
	
	public int getDataAt(int index) {
		return data[index];
	}
	
	public void appendData(int data) {
		this.data[last] = data;
		last++;
	}
	
	public int getLength() {
		return last;
	}
	
	public Iterator createIterator() {
		return new TestCasesIterator(this);
	}
}
 
 class TestCasesIterator implements Iterator {
	 private TestCases testCases;
	 private int index = 0;
	 
	 public TestCasesIterator(TestCases testCases) {
		 this.testCases = testCases;
		 this.index = 0;
	 }
	 
	 public boolean hasNext() {
		 if (index < testCases.getLength()) {
			 return true;
		 } else {
			 return false;
		 }
	 }
	 
	 public Object next() {
		 Integer data = testCases.getDataAt(index);
		 index++;
		 return data;
	 }
}

class PrintTestCases {
	private static PrintTestCases printTestCase = new PrintTestCases();
	private TestCases testCase;
	
	private PrintTestCases() {
		testCase = new TestCases(10000);
	}
	
	public static PrintTestCases getInstance() {
		return printTestCase;
	}
	
	public void read() {
		try {
			BufferedReader br =
					new BufferedReader(new InputStreamReader(System.in));
			String line = "";
			while (null != (line = br.readLine())) {
				int data = Integer.parseInt(line);
				if (0 == data)
					break;
				testCase.appendData(data);
			}
		} catch (Exception e) {
			System.exit(1);
		}
	}
	
	public void write() {
		Iterator it = testCase.createIterator();
		int cnt = 1;
		
		while (it.hasNext()) {
			System.out.println("Case " + (cnt++) + ": " + it.next());
		}
	}
}

public class Main {
	public static void main(String[] args) {
		PrintTestCases test = PrintTestCases.getInstance();
		test.read();
		test.write();
	}

}

Measured memory_bytes: 32812
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void solve(int V, int E, int[][] cap, int[][] flow, int s, int t) {
		int tot = 0;
		while (true) {
			int[] pre = new int[V];
			Arrays.fill(pre, -1);
			ArrayDeque<Integer> que = new ArrayDeque<>();
			que.add(s);
			out: while (!que.isEmpty()) {
				int cur = que.poll();
				for (int dst = 0; dst < V; ++dst) {
					if (cap[cur][dst] - flow[cur][dst] <= 0)
						continue;
					if (pre[dst] != -1 && dst != s)
						continue;
					pre[dst] = cur;
					if (dst == t)
						break out;
					que.add(dst);
				}
			}
			if (pre[t] == -1)
				break;
			int inc = Integer.MAX_VALUE / 16;
			for (int i = t; i != s; i = pre[i]) {
				inc = Math.min(inc, cap[pre[i]][i] - flow[pre[i]][i]);
			}
			for (int i = t; i != s; i = pre[i]) {
				flow[pre[i]][i] += inc;
				flow[i][pre[i]] -= inc;
			}
			tot += inc;
		}
		System.out.println(tot);

	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int[][] cap = new int[V][V];
		int[][] flow = new int[V][V];
		for (int i = 0; i < E; ++i) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int c = sc.nextInt();
			cap[u][v] = c;
		}
		int s = 0;
		int t = V - 1;

		solve(V, E, cap, flow, s, t);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 34524
#include<stdio.h>
int main(void){
  int n,i,j;
  int h[100];
  int sum=1;
  int max;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  max=h[0];
  for(i=1;i<n;i++){
    for(j=0;j<i;j++){
    if(max<h[j])
      max=h[j];
    }
    if(h[i]>=max)
      sum=sum+1;
  }
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define inf 1000000000
#define N 2000005
using namespace std;
int n,K,kk,cnt,a[N],p[N],d[N],head[N],val[N],ru[N];
struct Edge{int nxt,to;}e[N];
inline void link(int x,int y){ru[y]++;e[++kk].nxt=head[x];e[kk].to=y;head[x]=kk;}
void insert(int k,int l,int r,int x,int y){
	if (l==r){d[k]=y;return;}
	int mid=(l+r)>>1;
	if (x<=mid) insert(k*2,l,mid,x,y);
	else insert(k*2+1,mid+1,r,x,y);
	d[k]=max(d[k*2],d[k*2+1]);
}
int query1(int k,int l,int r,int x,int y){
	if (x>y) return 0;
	if (x<=l&&y>=r) return d[k];
	int mid=(l+r)>>1;
	if (y<=mid) return query1(k*2,l,mid,x,y);
	else if (x>mid) return query1(k*2+1,mid+1,r,x,y);
	else return max(query1(k*2,l,mid,x,mid),query1(k*2+1,mid+1,r,mid+1,y));
}
priority_queue<int> Q;
inline void topsort(){
	for (int i=1;i<=n;i++) if (!ru[i]) Q.push(-i);
	while (!Q.empty()){
		int u=-Q.top();Q.pop();
		cnt++;val[u]=cnt;
		for (int i=head[u];i;i=e[i].nxt){
			int v=e[i].to;ru[v]--;
			if (!ru[v]) Q.push(-v);
		}
	}
}
int main(){
	scanf("%d%d",&n,&K);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) p[a[i]]=i;
	for (int i=1;i<=n;i++){
		int pos1=query1(1,1,n,min(n,p[i]+1),min(n,p[i]+K-1));
		if (pos1) link(p[pos1],p[i]);
		pos1=query1(1,1,n,max(1,p[i]-K+1),max(1,p[i]-1));
		if (pos1) link(p[pos1],p[i]);
		insert(1,1,n,p[i],i);
	}
	topsort();
	for (int i=1;i<=n;i++) printf("%d\n",val[i]);
	return 0;
}

Measured memory_bytes: 38652
M=10**6+3
Q=int(input())
xdn=list(list(map(int,input().split())) for _ in range(Q))
factorial_list=[1]
for i in range(1,M):
    factorial_list.append(factorial_list[i-1]*i%M)
for x,d,n in xdn:
    t=x*pow(d,M-2,M)%M
    if d==0:
        print(pow(x,n,M))
    elif t+n<=M:
        print(factorial_list[t+n-1]
              *pow(factorial_list[t-1],M-2,M)
              *pow(d,n,M)%M)
    else:
        print(0)

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

#define NT 26
#define ND 365

typedef long long ll;


int main () {
	int D;
	int c[NT];
	int s[ND][NT];
	int last[NT];
	cin >> D;
	for (int typ=0; typ<NT; typ++)
		cin >> c[typ];
	for (int d=0; d<D; d++) {
		for (int typ=0; typ<NT; typ++) {
			cin >> s[d][typ];
			last[typ] = 0;
		}
	}
	int t[ND];
	for (int d=0; d<D; d++) {
		cin >> t[d];
		t[d]--;
	}
	
	ll satisfication = 0;
	for (int d=0; d<D; d++) {
		satisfication += s[d][t[d]];
		last[t[d]] = d+1;
		for (int typ=0; typ<NT; typ++) {
			satisfication -= c[typ] * (d+1 - last[typ]);
		}
		cout << satisfication << endl;
	}
	return 0;
}

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

int main() {
	string str;
	cin >> str;
	int size = str.size();
	vector<int> v(size+1);
	for(int i = 0; i < size; i++) {
		if(str[i] == '<') {
			v[i+1] = max(v[i+1], v[i] + 1);
		}
	}
	for(int i = size - 1; i >= 0; i--) {
		if(str[i] == '>') {
			v[i] = max(v[i], v[i+1] + 1);
		}
	}
	long long ans = 0;
	for(int i = 0; i <= size; i++) ans += v[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2820
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream> 
#include <cstdlib>
#include <climits>
#include <utility>
#include <string>

#define MOD 1000000009
#define SIZE 2002
typedef long long ll;
using namespace std;
 

 int main(){
    ll N;
    vector<pair<ll,ll>> A;
    cin >> N;
    for(ll i = 0 ; i < N ; i++){
        ll tmp; 
        cin >> tmp;
        A.push_back({tmp,i});
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    ll DP[SIZE][SIZE];
    for(int i = 0 ; i < SIZE ; i++){
        for(int j = 0 ; j < SIZE ; j++){
            DP[i][j] = 0;
        }    
    }
    for(int i = 0 ; i < N ; i++){
        ll act = A[i].first;
        ll no = A[i].second;
        for(int x = 0 ; x <= i ; x++){
            int y = i - x;
            if(DP[x+1][y] < DP[x][y] + abs(no-x) *act){
                DP[x+1][y] = DP[x][y] + abs(no-x) *act;
            }
            if(DP[x][y+1] < DP[x][y] + abs(no-(N-1-y)) *act){
                DP[x][y+1] = DP[x][y] + abs(no-(N-1-y)) *act;
            }
        }
    }
    ll ans = 0 ;
    for(ll i = 0 ; i <= N ; i++){
        if(ans < DP[i][N-i]){
            ans = DP[i][N-i];
        }
    }
    cout << ans;
    return 0 ;
 }


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

int main() {
  int N;
  cin >> N;

  int ans = 0;
  string s = "No";

  for (int i = 0; i < 25; i++) {
    for (int j = 0; j < 14; j++) {
      ans = 4*i + 7*j;
      if (ans == N) {
        s = "Yes"; 
      }
    } 
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        if (n == 2) {
            cout << 1 << endl;
            cout << 2 << endl;
            cout << 3 << endl;
        } else {
            vi a(2 * n - 1);
            set<int> st;
            rep(i, 2 * n - 1) {
                st.insert(i + 1);
            }
            a[n - 1] = x;       st.erase(x);
            if (x < n) {
                a[n - 2] = x + 1;   st.erase(x + 1);
                a[n] = x - 1;       st.erase(x - 1);
                a[n + 1] = x + 2;   st.erase(x + 2);
            } else {
                a[n - 2] = x - 1;   st.erase(x - 1);
                a[n] = x + 1;       st.erase(x + 1);
                a[n + 1] = x - 2;   st.erase(x - 2);
            }
            vi b(all(st));
            rep(i, 2 * n - 1) {
                if (a[i] > 0) {
                    cout << a[i] << endl;
                } else {
                    cout << b.back() << endl;
                    b.pop_back();
                }
            }
        }
    }
}


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

#define MOD 1000000007

int A[21];
long long dp[21][(1<<21)+5];

long long solve(int N, int mask, int M)
{
    if(N < 0)
        return (mask == 0);
    
    if(dp[N][mask] != -1)
        return dp[N][mask];
    
    long long ans = 0;
    
    for(int k=0; k<M; k++)
        if((A[N] & (1 << k)) && (mask & (1 << k)))
        {
            ans += solve(N-1, (mask ^ (1 << k)), M);
        }
    
    return dp[N][mask] = ans % MOD;
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N;
    cin >> N;
    
    for(int i=0; i<N; i++)
    {
        int mask = 0;
        
        for(int j=0; j<N; j++)
        {
            int x;
            cin >> x;
            
            mask |= (1 << j) * x;
        }
        
        A[i] = mask;
    }
    
    memset(dp, -1, sizeof(dp));
    cout << solve(N-1, (1 << N) - 1, N) << "\n";
    return 0;
}

Measured memory_bytes: 344320
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a; cin >> b; cin >> c; cin >> d;
	string result = "No"; 
	bool flag;
       	flag = (abs(a-c) <= d) || (abs(a-b) <= d && abs(b-c) <= d);
	if (flag) {
		result = "Yes";
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n, l;
    cin >> n >> l;

    int sum = 0;
    int ans = 101010;

    rep(i, n)
    {
        sum += l + (int)i;
    }
    rep(i, n)
    {
        if (abs(ans) > abs(l + (int(i))))
        {
            ans = l + i;
        }
    }
    cout << sum - ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    rep(i, 1, b + 1)
    {
        if ((a * i) % b == c)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


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

void format(vector<string>& s, int l, int r, int depth, string prefix) {
    if (l >= r) return;
    //cout << l << ' ' << r << endl;
    vector<int> idx;
    for (int i = l; i < r; i++) {
        int cnt = 0;
        for (int j = 0; j < s[i].size(); j++) {
            if (s[i][j] != '.') break;
            cnt++;
        }
        if (cnt == depth) idx.push_back(i);
    }
    int N = idx.size();
    for (int i = 0; i < N - 1; i++) {
        cout << prefix + '+';
        for (int j = 0; j < s[idx[i]].size(); j++) {
            if (s[idx[i]][j] == '.') continue;
            cout << s[idx[i]].substr(j, s[idx[i]].size() - j) << endl;
            break;
        }
        format(s, idx[i] + 1, idx[i + 1], depth + 1, prefix + "|");
    }
    cout << prefix + '+';
    for (int i = 0; i < s[idx[N - 1]].size(); i++) {
        if (s[idx[N - 1]][i] == '.') continue;
        cout << s[idx[N - 1]].substr(i, s[idx[N - 1]].size() - i) << endl;
        break;
    }
    format(s, idx[N - 1] + 1, r, depth + 1, prefix + " ");
}

void solve(int n) {
    string S;
    cin >> S;
    vector<string> s(n - 1);
    for (int i = 0; i < n - 1; i++) cin >> s[i];
    cout << S << endl;
    format(s, 0, n - 1, 1, "");
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;
        solve(N);
    }
    return 0;
}


Measured memory_bytes: 4536
while True:
    H, W = map(int, input().split())
    if not(H or W):
        break
    for i in range(H):
        print('#', end='')
        for j in range(W-2):
            if i > 0 and i < H - 1:
                print('.', end='')
            else:
                print('#', end='')
        print('#')
    print()

Measured memory_bytes: 8964
# レベルLのN番目
def solve(L,N):
    if L == 0:
        return 1
    if N == 1:
        return 0
    elif N <= 2**(L+1)-2:
        return solve(L-1,N-1)
    elif N == int(2**(L+1)-1):
        return 2**L
    return solve(L-1,N-2**(L+1)+1)+2**L
    

N,X = map(int,input().split())
print(solve(N,X))

Measured memory_bytes: 9196
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,an=1;
	cin >> N;
	vector<ll> a = { 0,0,0 };
	rep(i, N) {
		ll A,m=-1,cn=0;
		cin >> A;
		rep(j, 3) {
			if (A == a.at(j)) {
				cn++;
				m = j;
			}
			
		}
		if (m == -1) {
			an = 0;
			break;
		}
		an *= cn;
		an%= 1000000007;
		a.at(m)++;
	}
	
	 cout<<an << endl;
}


Measured memory_bytes: 384
using System;
using System.Numerics;
using System.Linq;

class D2
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		BigInteger c = a[0] - a[1] + 1;
		for (var i = 1; i <= a[1]; Console.WriteLine(c % 1000000007), c = c * (a[0] - a[1] + 2 - ++i) / i * (a[1] - i + 1) / (i - 1)) ;
	}
}


Measured memory_bytes: 13652
#include<bits/stdc++.h>
using namespace std;
long long n,a,sum=0;
int main(){
    cin>>n; 
    for(int i=1;i<=n;i++){
    	cin>>a;
    	sum+=a;
	}
	if(sum%2==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,w,m;
	cin >>h>>w>>m;
	int a[h+1] = {0};
	int b[w+1] = {0};
	set<pair<int,int>> v;
	for(int i = 0; i<m;i++)
	{
		int p,q;
		cin >>p>>q;
		v.insert({p,q});
		a[p]++;
		b[q]++;
	}
	int maxi = 0;
	int maxi2 = 0;
	set<int> hm;
	set<int> wm;
	for(int i = 0; i<h+1;i++)
	{
		maxi = max(maxi,a[i]);
	}
	for(int i = 0; i<w+1;i++)
	{
		maxi2 = max(maxi2,b[i]);
	}
	for(int i = 0; i<h+1;i++)
	{
		if(a[i] == maxi)
		{
			hm.insert(i);
		}
	}
	for(int i = 0; i<w+1;i++)
	{
		if(b[i] == maxi2)
		{
			wm.insert(i);
		}
	}
	int flag = 1;
	ll temp = hm.size();
	ll temp2 = wm.size();
	if(temp*temp2 > m)
	{
		flag = 0;
	}
	else
	{
		for(auto i : hm)
			for(auto j:wm)
				if(v.find({i,j}) == v.end())
					flag = 0;	
	}
	cout <<maxi+maxi2 - flag<<endl;
}


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

typedef long long lint;
typedef long double louble;

#define lf ('\n')

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline lint ty()
	{
		lint a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

inline lint gcd(lint a,lint b){while(b)a%=b,swap(a,b);return a;}

inline lint fuck(lint bas,lint mod,lint lim)
{
	return lim+(bas-lim%mod+mod)%mod;
}

void finder()
{
	lint a=ty(),b=ty(),c=ty(),d=ty();
	if(b>a || b>d){cout<<"No"<<lf;return;}
	lint g=gcd(b,d);
	cout<<((fuck(a%g,g,c-b+1)>=0)?"Yes":"No")<<lf;
}


int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	int t=ty();
	while(t--)finder();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int main() {
    int n,h;
    cin>>n>>h;
    int ma=0;
    vector<int> a(n),b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
        ma=max(ma,a[i]);
    }
    sort(all(b));
    reverse(all(b));
    int ans=0;
    rep(i,n){
        if(b[i]>=ma){
            ans++;
            h-=b[i];
            if(h<=0){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    if(h%ma==0){
        ans+=h/ma;
        cout<<ans<<endl;
    }
    else{
        ans+=h/ma+1;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc065_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { 
    cin >> c[i];
    c[i]--;
  }

  int cnt = 0;
  int next = 0;
  while (cnt < N && next != 1) {
    cnt++;
    next = c[next];
  }

  cout << (next == 1 ? cnt : -1) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;

int main(){
	int n,t;
	cin >> n >> t;
	vector<int> v;
	REP(i,n){
		int c,a;
		cin >> c >> a;
		if(a <= t)v.push_back(c);
	}
	if(v.empty()){
		dump("TLE");
	}
	else{
		sort(ALL(v));
		dump(v[0]);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

  int N; cin >> N;
  vi x(N), y(N), h(N); REP(i,N) cin >> x[i] >> y[i] >> h[i];

  int H, Cx, Cy;
  int is;
  REP(i,N) {
    if (h[i] != 0) {
      is = i;
      break;
    }
  }

  REP(Cx,101) {
    REP(Cy,101) {
      H = h[is]+abs(x[is]-Cx)+abs(y[is]-Cy);
      bool flag = true;
      REP(i,N) {
        if (h[i]!= max(H-abs(x[i]-Cx)-abs(y[i]-Cy),0)) {
          flag = false;
          break;
        }
      }
      if (flag == true) {
        printf("%d %d %d\n",Cx,Cy,H);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int x, int y) {
    if (x == 0) return y;
    if (y == 0) return x;
    return gcd(y, x%y);
}

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  
  int d = gcd(a,b);
  
  if(c % d == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}

  

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

void solve()
{
	int a,b,c;
	int c5 = 0,c7 = 0;
	cin >> a >> b >> c;

	if (a+b+c == 17){
		cout<<"YES\n";
	}else{
		cout<<"NO\n";
	}

}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	solve();
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename Iter, typename T> int gt(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L; }
template <typename Iter, typename T> int ge(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L; }
template <typename Iter, typename T> int lt(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L - 1; }
template <typename Iter, typename T> int le(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L - 1; }
template <typename Bst, typename T> typename Bst::const_iterator gt(const Bst& bst, T v) { return bst.upper_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator ge(const Bst& bst, T v) { return bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator lt(const Bst& bst, T v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator le(const Bst& bst, T v) { return bst.upper_bound(v) == bst.begin() ? bst.end() : --bst.upper_bound(v); }
const int N = 500;
int g[N][N], vis[N][N];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
vector<int> solve_grid() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> g[i][j];
            vis[i][j] = false;
        }
    }
    vector<int> cost(h * w + 1);
    priority_queue<tuple<int, int, int>> pq({}, {make_tuple(-1, y - 1, x - 1)});
    vis[y - 1][x - 1] = true;
    for(int component_size = 1; not pq.empty(); component_size++) {
        int val, y, x;
        tie(val, y, x) = pq.top();
        pq.pop();
        cost[component_size] = max(cost[component_size - 1], -val);
        for(int d = 0; d < 4; d++) {
            int ny = y + dy[d], nx = x + dx[d];
            if(0 <= ny and ny < h and 0 <= nx and nx < w and not vis[ny][nx]) {
                pq.push(make_tuple(-g[ny][nx], ny, nx));
                vis[ny][nx] = true;
            }
        }
    }
    return cost;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int r;
    while(cin >> r and r) {
        auto cost1 = solve_grid();
        auto cost2 = solve_grid();
        int ans = lim<int>::max();
        for(int r1 = 0; r1 <= r; r1++) {
            if(r1 < cost1.size() and r - r1 < cost2.size()) {
                ans = min(ans, cost1[r1] + cost2[r - r1]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 7344