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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
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;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N,M;
    cin >> N >> M;
    if (M == 1){
        cout << "1 2" << endl;
        return 0;
    }

    if (N % 2 == 0) N--;
    vector<PII> ans;

    int N2 = N / 2;
    int N1 = N - N2;

    for (int i = 1; i <= N1 / 2; i++){
        int j = N1 + 1 - i;
        ans.push_back(MP(i,j));
    }

    for (int i = 1; i <= N2 / 2; i++){
        int j = N2 + 1 - i;
        ans.push_back(MP(N1+i,N1+j));
    }

    REP(i,M){
        cout << ans[i].first << " " << ans[i].second << "\n";
    }

}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
#define debug3(x) rep(i, sizeof(x)) cout << x[i] << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, Q;
    cin >> n >> m >> Q;
    vector<ll> express[n];

    rep(i, m) {
        ll l, r;
        cin >> l >> r;
        l--, r--;
        express[l].push_back(r);
    }

    rep(i, n) sort(express[i].begin(), express[i].end());

    rep(Qi, Q) {
        ll p, q;
        cin >> p >> q;
        p--, q--;
        ll ans = 0;
        for (int i = p; i <= q; ++i) {
            auto itr = upper_bound(express[i].begin(), express[i].end(), q);
            ans += distance(express[i].begin(), itr);
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define MAX 200005

using namespace std;

int main() {
    string s, t; cin >> s >> t;
    
    int flag = 1;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) flag = 0;
    }
    
    if (flag && t.size() - s.size() == 1) cout << "Yes\n";
    else cout << "No\n";
  
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    ll A,B,C;
    cin >> A >> B >> C;
    if(A==B && B==C){
        cout << ((A&1) ? 0 : -1) << endl;
        return 0;
    }
    ll ct=0;
    while(1){
        if(ct!=0){
            A/=2,B/=2,C/=2;
        }
        if(!(A%2==0 && B%2==0 && C%2==0)) break;
        ct++;
        ll tmpa = A,tmpb = B;
        A = B+C;
        B = C+tmpa;
        C = tmpa+tmpb;
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
     public static void main(String... args) {
     	Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        Set<String> items = new HashSet<>();
       for (int i = 0; i < n; i++) {
         items.add(input.next());
       }
       
       System.out.println(items.size());
    }
}

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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    string st; cin>>st;
    int n = (int)st.length();
    lli ans = 0, cnt = 0;
    rep(i,0,n) {
        if(st[i] == 'A') {
            cnt++;
        }
        else {
            if(i<n-1 && st[i] == 'B' && st[i+1] == 'C') {
                ans += cnt;
                i++;
            }
            else cnt = 0;
        }
    }
    cout<<ans<<endl;
}



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

int rec(const int& maxnum, int cnt, int mul, int foo) {
  if(cnt == 0) return mul == 0;
  if(foo > maxnum || mul < 0) return 0;
  return rec( maxnum, cnt - 1, mul - foo, foo + 1) + rec( maxnum, cnt, mul, foo + 1);
}

int main() {
  int a, b, c;
  while( cin >> a >> b >> c, a){
    cout << rec( a, b, c, 1) << endl;
  }
}

Measured memory_bytes: 1160
s = input()
L = len(s)
flag = 1
flag1 = 1
flag2 = 1
for i in range(L):
    if s[i]!=s[L-i-1]:
        flag = 0
for i in range((L-1)//2):
    if s[i]!=s[(L-1)//2-1-i]:
        flag1 = 0
for i in range((L+3)//2,L):
    if s[i]!=s[(L-1)//2+L-i]:
        flag2 = 0
if flag == 1 and flag1 == 1 and flag2 == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static long[] city;
	public static int M;

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String str = bf.readLine();
		String[] str1 = str.split(" ");
		M = Integer.parseInt(str1[1]);
		city = new long[M];
		String strCity[] = new String[M];
		long oldzhouyear[] = new long[M];
		long zhou = 0;
		long year = 0;
		for (int i = 0; i < M; i++) {
			str = bf.readLine();
			str1 = str.split(" ");
			zhou = Long.parseLong(str1[0]);
			year = Long.parseLong(str1[1]);
			oldzhouyear[i] = zhou * 10000000000l + year;
			city[i] = zhou * 10000000000l + year;
		}
		Arrays.sort(city);
		int a = (int) (city[0] / 10000000000l);
		int c = 0;
		int ind = 1;
		strCity[0] = intToStr(a) + intToStr(ind);
		for (int i = 1; i < M; i++) {
			c = (int) (city[i] / 10000000000l);
			if (c == a) {
				++ind;
				strCity[i] = intToStr(c) + intToStr(ind);
				a = c;
			} else {
				ind = 1;
				strCity[i] = intToStr(c) + intToStr(ind);
				a = c;
			}

		}
		for (int i = 0; i < M; i++) {
			ind = getIndex(oldzhouyear[i]);
			System.out.println(strCity[ind]);
		}

	}

	public static String intToStr(int a) {
		String res = "000000" + String.valueOf(a);
		return res.substring(res.length() - 6, res.length());
	}

	public static int getIndex(long num) {
		int left = 0, right = M - 1;
		if (city[left] == num) {
			return left;
		} else if (city[right] == num) {
			return right;
		}
		int mid = (left + right) / 2;
		while (num != city[mid]) {
			if (num <= city[mid]) {
				right = mid;
			} else {
				left = mid;
			}
			mid = (left + right) / 2;
		}
		return mid;
	}

}

Measured memory_bytes: 75908
// ABC177D.cpp
// UnionFind
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1) {// 最初は全て -1:「根」とする
    }
    // グループ番号を返す
    int find(int x) {
        if (d[x] < 0) {
            return x;  // 根なら値を返す
        }
        return d[x] = find(d[x]);
    }
    // 連結する
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)  return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    // 同じグループか？
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    // サイズ
    int size(int x) {
        return -d[find(x)];
    }
};
// UnionFind uf(n);n個の頂点で初期化
// uf.unite(a,b) a頂点とb頂点を結ぶ
// uf.size(e) eグループのサイズ
// uf.same(c,d) a頂点とc頂点が同じグループか、調べる

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}


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

int solve(map<string,int>& m, string str) {
    int res = 0;
    for (int i = 0, len = str.size(); i < len; i++) {
        if ('A' <= str[i] && str[i] <= 'Z') {
            int now;
            if (i + 1 < len && 'a' <= str[i+1] && str[i+1] <='z') {
                auto tmp = string(str.begin() + i, str.begin() + i + 2);
                if (m.find(tmp) != m.end())
                    now = m[tmp];
                else
                    return -1;
                i++;
            } else {
                auto tmp = string(str.begin() + i, str.begin() + i + 1);
                if (m.find(tmp) != m.end())
                    now = m[tmp];
                else
                    return -1;
            }
            if (i + 1 < len && '0' <= str[i+1] && str[i+1] <= '9') {
                int j = i + 1;
                while (j < len && '0' <= str[j] && str[j] <= '9') j++;
                auto num = string(str.begin() + i + 1, str.begin() + j);
                stringstream ss;
                ss << num;
                int n;
                ss >> n;
                res += n * now;
                i = j - 1;
            } else {
                res += now;
            }
        }
        else {
            int count = 1;
            int j = i + 1;
            while (count) {
                if (str[j] == '(') count++;
                if (str[j] == ')') count--;
                j++;
            }
            auto tmp = string(str.begin() + i + 1, str.begin() + j - 1);
            int k = j;
            while (j < len && '0' <= str[j] && str[j] <= '9') j++;
            stringstream ss;
            ss << string(str.begin() + k, str.begin() + j);
            int num;
            ss >> num;
            int n = solve(m, tmp);
            if (n < 0) return -1;
            res += num * n;
            i = j - 1;
        }
    }

    return res;
}

int main() {
    map<string,int> m;
    for (string str; ; ) {
        cin >> str;
        if (str == "END_OF_FIRST_PART") break;
        int num;
        cin >> num;
        m[str] = num;
    }

    for (string str; cin >> str, str != "0"; ) {
        int ans = solve(m, str);
        if (ans < 0) cout << "UNKNOWN" << endl;
        else cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

bool check(vector<int> v){
  int d = v[1] - v[0];
  for(int i=1;i<v.size();i++){
    if(v[i]-v[i-1] != d) return false;
  }
  return true;
}

int main(){
  vector<int> v;
  int n, x;
  while(cin>>n && n){
    v.resize(n+1);
    for(int i=0;i<v.size();i++){
      cin>>v[i];
    }
    for(int i=0;i<v.size();i++){
      vector<int> tmp = v;
      tmp.erase(tmp.begin()+i);
      if(check(tmp)){
        cout<<v[i]<<endl;
        break;
      }
    }
  }
}


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

const long long MOD = 5;
const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long C) {
  for (int i = 0; i < 101; i++) {
      ll cA = A*i;
      if (cA % B == C) {
	  cout << YES << endl;
	  return;
      }
  }
  cout << NO << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
while True:
    a, l = map(int, raw_input().split())
    if a == l == 0:
        break
    check = {}
    i = 0
    while a not in check:
        temp = list(str(a).zfill(l))
        temp.sort()
        check[a] = i
        a = int(''.join(temp[::-1])) - int(''.join(temp))
        i += 1
    print check[a], a, i - check[a]

Measured memory_bytes: 4236
#include <stdio.h>

int main(void){
  int N,H,a=0;
  scanf("%d %d",&H,&N);
  
  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(int i=0;i<N;i++){
    a=a+A[i];
  }
  
  if(a>=H){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

ll calc(ll x){
    ll ret=0;
    ll st=x/4*4;
    for(ll i=st;i<=x;i++)ret^=i;
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    ll ans = calc(a-1)^calc(b);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line);
    let N = line.trim().parse::<usize>().unwrap();
    
    let mut line = String::new();
    io::stdin().read_line(&mut line);
    let mut line = line.split_whitespace();
    let mut a = Vec::<usize>::with_capacity(N);
    for i in 0..N {
        let n = line.next().unwrap().parse::<usize>().unwrap();
        a.push(n);
    }

    let mut max = std::usize::MIN;
    let mut min = std::usize::MAX;
    for i in 0..N {
        max = cmp::max(max, a[i]);
        min = cmp::min(min, a[i]);
    }

    let ans = max - min;
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n;
	cin>>n;
	map<ll,bool> m;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			ll a=min(i,n/i);
			ll b=max(i,n/i);
			if(a<=b-2){
				m[b-1]=true;
			}
		}
	}
	ll s=0;
	for(auto x : m) s+=x.first;
	cout<<s;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define int long long
using namespace std;
signed main() {
	set<int>s;
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int k, x; cin >> k >> x;
		if (k == 0) {
			s.insert(x);
			cout << s.size() << endl;
		}
		else if (k == 1) {
			if (s.lower_bound(x) != s.end()) {
				if (*s.lower_bound(x) == x)cout << "1\n";
				else cout << "0\n";
			}
			else cout << "0\n";
		}
		else if (k == 2) {
			if (s.lower_bound(x) != s.end()) {
				if (*s.lower_bound(x) == x)s.erase(s.lower_bound(x));
			}
		}
	}
}


Measured memory_bytes: 12424
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a[i] = tmp;
  }
  int lb = 0;
  int ub = 0;
  long long crr = 0;
  long long ans = 0;
  while (ub < n) {
    if (crr & (long long)a[ub]) {
      crr &= (long long)~a[lb];
      lb++;
    } else {
      crr |= (long long)a[ub];
      ub++;
      ans += (long long)ub - lb;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int A,B,C,cnt=0;
  cin>>A>>B>>C;
  for(int i=1;i<B;i++) if(A*i%B==C) cnt++;
  if(cnt==0) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#define int long long
using namespace std;
const int INF=2e5+5;
const int Mod=998244353;
int n,k,s[55],r,xxx[15],yyy[15];
bool vis[INF];
__int128 f[INF],tree[INF<<3];
void write(__int128 xx) {
        if (xx<0) {putchar('-'); xx=-xx;}
        if (xx>9) write(xx/10);
        putchar(xx%10+'0');
}
void build(int l,int r,int id) {
        if (l==r) {tree[id]=f[l]; return;}
        int Mid=(l+r)>>1;
        build(l,Mid,id<<1);
        build(Mid+1,r,id<<1|1);
        tree[id]=(tree[id<<1]+tree[id<<1|1])%Mod;
        // cout<<l<<" "<<r<<" "<<id<<" "<<endl;
        // write(tree[id]); putchar('\n');
        return;
}
void add_updata(int l,int r,int id,int x,int k) {
        if (l==r) { tree[id]+=k; return;}
        int Mid=(l+r)>>1;
        if (x<=Mid) add_updata(l,Mid,id<<1,x,k);
        else add_updata(Mid+1,r,id<<1|1,x,k);
        tree[id]=(tree[id<<1]+tree[id<<1|1])%Mod;
        return;
}
__int128 query_ask(int Q_l,int Q_r,int l,int r,int id) {
        if (Q_l<=l && r<=Q_r) return tree[id];
        __int128 Mid=(l+r)>>1,res=0;
        if (Q_l<=Mid) res+=query_ask(Q_l,Q_r,l,Mid,id<<1); res%=Mod;
        if (Mid<Q_r) res+=query_ask(Q_l,Q_r,Mid+1,r,id<<1|1); res%=Mod;
        return res;
}
signed main()
{
        cin>>n>>k;
        for (int i=1; i<=k; i++) {
                cin>>xxx[i]>>yyy[i];
        }
        f[1]=1; build(1,n,1);
        for (int i=2; i<=n; i++) {
                // for (int j=1; j<=r; j++) {
                //         if (i>=s[j]) f[i]=(f[i-s[j]]%Mod+f[i]%Mod)%Mod;
                // }
                __int128 res=0;
                for (int j=1; j<=k; j++)
                {if (i<=xxx[j]) continue;
                 res+=query_ask(max(i-yyy[j],(int)(1)),i-xxx[j],1,n,1),res%=Mod;}
                f[i]=res%Mod; add_updata(1,n,1,i,res);
        }
        write(f[n]); putchar('\n');
        return 0;
}


Measured memory_bytes: 14892
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {

	body, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		log.Println(err)
	}
	scanner := bufio.NewScanner(strings.NewReader(string(body)))
	scanner.Split(bufio.ScanWords)
	if err := scanner.Err(); err != nil {
		fmt.Fprintln(os.Stderr, "reading input:", err)
	}
	inputs := make([]float64, 0)
	for scanner.Scan() {
		word := scanner.Text()
		word = strings.TrimSpace(word)
		val, _ := strconv.ParseFloat(word, 64)
		inputs = append(inputs, val)
	}

	N := int(inputs[0])
	values := inputs[1:]
	sort.Float64s(values)
	var currentVal float64
	for i := 0; i < N; i++ {
		if i == 0 {
			currentVal = values[i]
			continue
		}
		currentVal = (currentVal + values[i]) / 2
	}
	fmt.Println(currentVal)
}


Measured memory_bytes: 640
#include <cstdio>

int main(int argc, char const *argv[]) {
    int n, q, target;
    int findCount = 0; // ???????????£?????°????????°
    int inputSequence[10000];

    scanf("%d", &n);
    for(int i=0 ; i<n ; i++){
        scanf("%d", &inputSequence[i]);
    }

    scanf("%d", &q);
    for(int i=0 ; i<q ; i++){
        scanf("%d", &target);
        for(int j=0 ; j<n ; j++){
            if(inputSequence[j] == target){
                findCount++;
                break;
            }
        }
    }

    printf("%d\n", findCount);
    return 0;
}

Measured memory_bytes: 2760
/**
 * File              : E.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 26.01.2020
 * Last Modified Date: 26.01.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

#include <bits/stdc++.h>
using namespace std;
int const INF = 3e8;
vector<int> a;
vector<int> b;




int main() {
    int h, n;
    cin >> h >> n;
    a = vector<int>(n);
    b = vector<int>(n);
    for (int i = 0; i < n; i++) 
        cin >> a[i] >> b[i];
    // brute force
    vector<int> dp(h+1, INF);
    for (int i = 1; i <= h; i++) {
        for (int j = 0; j < n; j++) {
            if (i - a[j] > 0) {
                dp[i] = min(dp[i], dp[i - a[j]] + b[j]);
            } else {
                dp[i] = min(dp[i], b[j]);
            }
        }
    }
    cout << dp[h];
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N; vl H(N); rep(i, N) cin >> H[i];
    ll idx = 0, ans = 0;
    while(idx < N){
        ll c = 0;
        while(idx+1 < N && H[idx] >= H[idx+1]){
            idx++; c++;
        }
        chmax(ans, c);
        idx++;
    }
    cout << ans << endstr;
    return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int a[125252];
int b[125252];

int main(){
    scanf("%d",&n);
    REP(i,n+1)scanf("%d",a+i);
    REP(i,n)scanf("%d",b+i);
    ll ans = 0;
    REP(i,n){
        int sb = min(a[i], b[i]);
        a[i] -= sb;
        b[i] -= sb;
        ans += sb;
        sb = min(a[i+1], b[i]);
        a[i+1] -= sb;
        b[i] -= sb;
        ans += sb;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
while True:
    n = int(input())#文字列の量
    if n == 0:
        break
    w = list()#文字用
    for i in range(0, n):#入力
        w.append(input())

    for j in range(1, n+1):#始めの文字の場所
        ck = 0
        co = 0
        p = 0
        t = ""
        for k in range(j-1,50):#５７５７７チェック用
            #print(k)
            if co == 0 or co == 2:#５の場所
                if ck < 5:#五以下
                    #print("<")
                    ck = ck + len(w[k+p])#文字増やす
                elif ck == 5:#ピッタリになったら
                    #print("==")
                    co = co + 1#次に移る
                    ck = 0
                    p = p-1
                else:#オーバーしたら
                    #print(">")
                    break
            else:
                if ck < 7:
                    #print("<7")
                    ck = ck+len(w[k+p])
                    #print("      " ,ck)
                elif ck == 7:
                    #print("==7")
                    co = co+1
                    ck = 0
                    p = p-1
                    if co == 5:
                        t = "fin"
                        break
                else:
                    #print(">7")
                    break

        if t == "fin":
            print(j)
            break
    #print("over")



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

class Combination {
public:
    vector<ll> fc, fci;
    int n;
    Combination(int n): n(n) {
        fc.resize(n+1, 1);
        for (int i=2; i<n+1; ++i) {
            fc[i] = (fc[i-1] * i) % mod;
        }
        fci.resize(n+1, 1);
        for (int i=2; i<n+1; ++i) {
            fci[i] = (fci[i-1] * modpow(i, mod-2)) % mod;
        }
    }
    ll operator()(ll n, ll k) {
        if (k == 0 || n == k) return 1;
        return (fc[n] * fci[k] % mod) * fci[n-k] % mod;
    }
    ll modpow(ll a, ll b) {
        if ( ! b) return 1;
        if (b % 2) return (a * modpow(a, b-1)) % mod;
        ll t = modpow(a, b/2);
        return (t * t) % mod;
    }
};

int main() {
    Combination C(200010);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (int i=0; i<=min(k, n-1); ++i) {
        ans += (C(n, i) * C(n-1, n-i-1)) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define um map <ll,ll>
#define rep(i,z,n)  for(int i=z;i<n;i++)
#define repi(i,z,n) for(int i=z;i<=n;i++)
#define repn(i,z,n) for(int i=n-1;i>=z;i--)
#define vec vector<ll>
#define vecp vector<pair<ll,ll>>
#define pi (double)3.14159265358979323846
#define ld long double
#define all(z) z.begin(),z.end()

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; if (a == 0) return 0; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }
ll modInverse(ll a, ll m) {return power(a, m - 2, m);}
ll binpow(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll binlog2(ll n) {ll logValue = -1; while (n) {logValue++; n >>= 1;} return logValue;}
ll ceil(ll t1, ll t2) {ll ans = (t1 + t2 - 1) / t2; return ans;}
void print(vec a) {rep(i, 0, a.size())cout << a[i] << " "; cout << endl;}
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;
const ll inf = 2e18;


void solve() {
    ll n;
    cin >> n;
    vecp vp(n);
    rep(i, 0, n) {
        cin >> vp[i].F >> vp[i].S;
    }

    ll c1 = 0;
    rep(i, 0, n) {
        if (vp[i].F == vp[i].S)
            c1++;
        else
            c1 = 0;
        if (c1 >= 3) {
            cout << "Yes" << endl;
            return;
        }
    }

    cout << "No" << endl;
}


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    speed;
    int test = 1;
    // cin >> test;
    while (test--) {
        // cout << "Case #" << t1 << ": ";
        solve();
    }
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  
  // 100要素の配列で初期化
  vector<string> x(N);
  int ans=0;
  for(int i=0;i<N;i++)
    cin>>x.at(i);
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(x.at(i)==x.at(j)){
        ans=1;
        break;
      }
    if(ans==1)
        break;
    }
  }
  string tmp=x[0];
  for(int i=1;i<N;i++){
      if(x[i].at(0)!=tmp.at(tmp.size()-1)){
        ans=1;
        break;
      }
      tmp=x.at(i);
  }
  if(ans==1)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}
    
        
      
  



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

int main()
{
    int N, C;
    cin >> N >> C;
    int D[C][C], pall[N][N];
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < C; ++j) {
            cin >> D[i][j];
        }
    }

    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            cin >> pall[i][j]; --pall[i][j];
        }
    }

    int mass[3][C]; //(i+j)%3 = 0,1,2のマスで, どの色がどれだけ塗られているか。
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < C; ++j) mass[i][j] = 0;
    }

    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) ++mass[(i+j)%3][pall[i][j]];
    }

    ll ans = 1e10;
    for(int i = 0; i < C; ++i) { //%3 == 0
        for(int j = 0; j < C; ++j) { //%3 == 1
            for(int k = 0; k < C; ++k) { //%3 == 2
                if(i != j && j != k && k != i) {
                    ll tmp = 0;
                    for(int l = 0; l < 3; ++l) {
                        for(int m = 0; m < C; ++m) {
                            if(l == 0) tmp += mass[l][m]*D[m][i];
                            else if(l == 1) tmp += mass[l][m]*D[m][j];
                            else tmp += mass[l][m]*D[m][k];
                        }
                    }
                    if(tmp < ans) ans = tmp;
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
inf = 1000000007
for i in range(N):
    f, b = 0, 0
    for j in range(N):
        if A[i] > A[j]:
            if i < j:
                b += 1
            else:
                f += 1
    ans += f * (K - 1) * K // 2 + b * (K + 1) * K // 2
    ans %= inf
print(ans)


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

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

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
typedef pair<ll, ll> P;
typedef pair<ll, P> Edge;

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

/* union find */
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }

    int find(int x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }

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

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;
        if (-par[x] < -par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};

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

    vector<Edge> edges; /* コスト、どことどこ */
    vector<P> x_element;
    vector<P> y_element;
    vector<ll> x(n), y(n);

    REP(i, n) {
        cin >> x[i] >> y[i];
        x_element.push_back(make_pair(x[i], i));
        y_element.push_back(make_pair(y[i], i));
    }

    /* x座標で隣接してるもの */
    sort(x_element.begin(), x_element.end());
    REP(i, n-1) {
        ll cost = x_element[i+1].first - x_element[i].first;
        //cout << cost << endl;
        edges.push_back(Edge(cost, make_pair(x_element[i].second, x_element[i+1].second)));
    }

    /* y座標で隣接してるもの */
    sort(y_element.begin(), y_element.end());
    REP(i, n-1) {
        ll cost = y_element[i+1].first - y_element[i].first;
        //cout << cost << endl;
        edges.push_back(Edge(cost, make_pair(y_element[i].second, y_element[i+1].second)));
    }

    /* クラスカル法 */
    sort(edges.begin(), edges.end()); /* コストが小さい順にソート */
    UnionFind uf(n);
    ll ans = 0;
    for(auto e: edges){
        int u = e.second.second;
        int v = e.second.first;
        if(!uf.same(u, v)) {
            uf.unite(u, v);
            ans += e.first;
        }
    }

    cout << ans << endl;
    
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){

  string s;
  cin>>s;
  s=">"+s+"<";
  ll n=s.size();

  ll cnt=1;
  vector<ll> a;
  vector<char> b;
  rep(i,n-1){
    if(s[i]!=s[i+1]){
      a.emplace_back(cnt);
      b.emplace_back(s[i]);
      cnt=1;
    }else{
      cnt++;
    }
  }
  a.emplace_back(cnt);
  b.emplace_back(s.back());
  //for(auto x:a)cout<<x<<" ";cout<<endl;
  //for(auto x:b)cout<<x<<" ";cout<<endl;
  
  ll m=a.size();
  vector<ll> res(n+1,-1);
  rep(i,n-1){
    if(s[i]=='>'&&s[i+1]=='<'){
      res[i+1]=0;
    }
  }
  rep(i,n){
    if(res[i]==0){
      ll j=i;
      while(j<n&&s[j]=='<'){
        res[j+1]=max(res[j]+1,res[j+1]);
        j++;
      }
      i=j-1;
    }
  }
  for(ll i=n-1;i>0;--i){
    if(res[i]==0){
      ll j=i;
      while(j>0&&s[j-1]=='>'){
        res[j-1]=max(res[j]+1,res[j-1]);
        j--;
      }
      i=j+1;
    }
  }
  ll ans=0;
  for(auto x:res)ans+=max(x,0ll);
  ans-=res[0];
  ans-=res.back();
  cout<<(ans)<<endl;

}

Measured memory_bytes: 7056
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            if (N == 1)
            {
                WriteLine("a");
                Out.Flush();
                return;
            }
            var q = new Queue<Tuple<string, long>>();
            q.Enqueue(Tuple.Create("a", 1L));
            while (true) 
            {
                var d = q.Dequeue();
                var lst = d.Item2 + 1;
                var c = d.Item1[0];
                for (var j = 0; j < d.Item2 + 1; ++j)
                {
                    var nextq = Tuple.Create(d.Item1 + ((char)(c + j)).ToString(), Max(d.Item2, j + 1));
                    q.Enqueue(nextq);
                }
                if (lst == N)
                    break;
            }
            foreach (var d in q)
                WriteLine(d.Item1);
            Out.Flush();
        }
    }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int A[N], sumA = 0;
    rep(i, N) {
        cin >> A[i];
        sumA += A[i];
    }

    int choice_num = 0;
    rep(i, N) {
        if (A[i] * 4 * M >= sumA) choice_num++;
    }

    if (choice_num >= M) cout << "Yes" << endl;
    else cout << "No" <<endl;

    return 0;
}



Measured memory_bytes: 256
# include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2; 
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

string a, b;
int main (){
	cin >> a >> b;
	int ans = (a[0] == b[0]) + (a[1] == b[1]) + (a[2] == b[2]);
	return !printf ("%d\n", ans);
}

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

#define rep(i,l,r) for(int i=l;i<=r;++i)
void out()
{
	puts("No");
	exit(0);
}
const int N=1e5+5;
int n,a0[3][N],a[N];
bool c[N];
bool add(int x)
{
	x=n-x+1;
	bool ans=0;
	for(int i=x;i;i-=i&-i)ans^=c[i];
	for(int i=x;i<=n;i+=i&-i)c[i]^=1;
	return ans;
}

int main()
{
	//freopen("1.in","r",stdin);
	cin>>n;
	rep(i,0,2)
	rep(j,1,n)scanf("%d",a0[i]+j);
	bool fu[2]={};
	rep(i,1,n)
	{
		rep(j,0,1)
		if(abs(a0[j][i]-a0[j+1][i])!=1)out();
		a[i]=(a0[1][i]+1)/3;
		if(a[i]%2!=i%2)out();
		if(a0[0][i]>a0[2][i])fu[i%2]^=1;
	}
	for(int i=1;i<=n;i+=2)fu[0]^=add(a[i]);
	rep(i,1,n)c[i]=0;
	for(int i=2;i<=n;i+=2)fu[1]^=add(a[i]);
	if(fu[0]||fu[1])out();
	puts("Yes");
}

Measured memory_bytes: 1920
n,m=map(int,input().split())
c=list(map(int,input().split()))
dp=[[i for i in range(n+1)] for _ in range(m+1)]
for i in range(1,m+1):
    for w in range(1,n+1):
        if c[i-1]>w:
            dp[i][w]=dp[i-1][w]
        else:
            dp[i][w]=min(dp[i][w-c[i-1]]+1,dp[i-1][w])
print(dp[m][n])


Measured memory_bytes: 46980
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){
	char c=getchar();
	while(c<'0'||'9'<c) c=getchar();
	uint_fast32_t x=0;
	while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); }
	return x;
}

#define V 202

inline int min(const int a, const int b){ return a>b?b:a; }

typedef struct{
	int to, cap, rev;
} edge;

char used[V];
edge G[V][V];
int len[V];

void add_edge(int from, int to, int cap){
	edge F, T;
	F.to = to;
	F.cap = cap;
	F.rev = len[to];
	G[from][len[from]]=F;
	len[from]++;

	T.to = from;
	T.cap = 0;
	T.rev = len[from]-1;
	G[to][len[to]]=T;
	len[to]++;
}

int dfs(int v, int t, int f){
	if(v==t) return f;
	used[v]=1;
	int i, l=len[v];
	for(i=0; i<l; i++){
		edge *e=&G[v][i];
		if(used[e->to]==0 && e->cap>0){
			int d = dfs(e->to, t, min(f, e->cap));
			if(d>0){
				e->cap -= d;
				G[e->to][e->rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	while(1){
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INT_MAX);
		if(f==0) return flow;
		flow += f;
	}
}

int main(void){
	int n, i, j;
	int a[100][2], b[100][2];
	scanf("%d", &n);
	for(i=0; i<n; i++){ scanf("%d%d", &a[i][0], &a[i][1]); add_edge(n*2, i, 1);}
	for(i=0; i<n; i++){ scanf("%d%d", &b[i][0], &b[i][1]); add_edge(i+n, n*2+1, 1);}
	for(i=0; i<n; i++){
		for(j=0; j<n; j++){
			if(a[i][0]<b[j][0] && a[i][1]<b[j][1]) add_edge(i, j+n, 1);
		}
	}
	int ans=max_flow(n*2, n*2+1);
	/*
	int ans=0;
	while(1){
		int k=dfs(n*2, n*2+1, 1);
		if(k==0) break;
		ans+=k;
	}
	*/
	printf("%d\n", ans);
}


Measured memory_bytes: 640
use std::io;

fn main() {
    let mut w = String::new();

    io::stdin()
        .read_line(&mut w)
        .expect("Failed to read line");

    let w_str :&str = &w;

    match w_str {
        "Sunny\n" => println!("Cloudy"),
        "Cloudy\n" => println!("Rainy"),
        "Rainy\n"=> println!("Sunny"),
            _ => println!("retry enter!")
    }
}


Measured memory_bytes: 2020
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let l: usize = sc.read();

    let mut trie = Trie::new(0);
    for _ in 0..n {
        trie.add(sc.chars(), 0);
    }

    let mut result = vec![];
    trie.count(&mut result);

    let mut ans = 0;
    for grundy in result
        .into_iter()
        .map(|depth| (l - depth).trailing_zeros() + 1)
    {
        ans ^= grundy;
    }

    println!("{}", if ans == 0 { "Bob" } else { "Alice" });
}

#[derive(Debug)]
struct Trie {
    one: Option<Box<Trie>>,
    zero: Option<Box<Trie>>,
    depth: usize,
}

impl Trie {
    fn new(depth: usize) -> Self {
        Trie {
            zero: None,
            one: None,
            depth: depth,
        }
    }

    fn add(&mut self, s: Vec<char>, i: usize) {
        if s.len() <= i {
            return;
        }
        match s[i] {
            '0' => {
                if self.zero.is_none() {
                    self.zero = Some(Box::new(Trie::new(self.depth + 1)));
                }
                self.zero.as_mut().unwrap().add(s, i + 1);
            }
            '1' => {
                if self.one.is_none() {
                    self.one = Some(Box::new(Trie::new(self.depth + 1)));
                }
                self.one.as_mut().unwrap().add(s, i + 1);
            }
            _ => unreachable!(),
        }
    }

    fn count(&self, result: &mut Vec<usize>) {
        let mut c = 0;
        match self.one {
            Some(ref one) => one.count(result),
            None => c += 1,
        }
        match self.zero {
            Some(ref zero) => zero.count(result),
            None => c += 1,
        }
        if c == 1 {
            result.push(self.depth);
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 20860
import qualified Data.Set as S

main :: IO ()
main = do
    [n, _] <- map read . words <$> getLine :: IO [Int]
    ds <- map read . words <$> getLine :: IO [Int]
    print $ head [i|i<-[n..], all (`S.notMember` S.fromList (digits i)) ds]

digits :: Int -> [Int]
digits 0 = []
digits n = mod n 10 : digits (div n 10)

Measured memory_bytes: 1020
import sys
import math
import collections
 
def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin
 
 
def int_input():
    return list(map(int, input().split()))
 
 
if __name__ == '__main__':
    # set_debug(True)
 
    t = input()
    
    if 'A' <= t <= 'Z':
        print('A')
    else:
        print('a')

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;
 
const ll mod = 1e9 + 7;
const ll mmod = 998244353;
 
vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};
 
vector<string> g;
vector<vector<bool>> used;
vector<ll> d;
 
int main() {
    
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll k;
    cin >> k;

    ll cur = 7;
    for (int i = 1; i <= k; ++i)
    {
        if (!(cur % k))
        {
            cout << i << endl;
            return 0;
        }
        cur = (cur * 10 + 7ll) % k;
    }

    
    cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 3604
use std::collections::HashSet;
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let (n, m) = parse!(iter, 2);
    let mut g = vec![vec![]; n];
    for _ in (0..m) {
        let (x, y, z): (usize, usize, usize) = parse!(iter, 3);
        g[x - 1].push(y - 1);
        g[y - 1].push(x - 1);
    }
    let mut seen = HashSet::<usize>::new();
    let mut res = 0;
    for i in (0..n) {
        if seen.contains(&i) {
            continue;
        }
        res += 1;
        let mut stack = vec![i];
        while stack.len() > 0 {
            let k = stack.pop().unwrap();
            seen.insert(k);
            for j in &g[k] {
                if !seen.contains(&j) {
                    stack.push(*j);
                }
            }
        }
    }
    println!("{:?}", res); // DEBUG
}


Measured memory_bytes: 18684
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[5];
 	for(int i=0;i<5;i++)cin>>a[i];
  	int mod=10;
  for(int i=0;i<5;i++)if(a[i]%10!=0)mod=min(mod,a[i]%10);
  int ans=0;
  for(int i=0;i<5;i++){
	ans+=(a[i]+9)/10*10;
    
  }
  if(mod!=10){
  	ans-=10;
    ans+=mod;
  }
cout<<ans<<endl;
}

Measured memory_bytes: 256