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

#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define p(x) cout<<x<<"\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define btc __builtin_popcount
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef priority_queue<int> pq;
typedef pair<int, int> ii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
using ll=long long int;
const int N=100001;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll sum=0;
    for(char c:s){
        sum+=c-'0';
        sum%=9;
    }
    if(sum==0)p("Yes");
    else p("No");
    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int h[n];
  int ch[n];
  vector<int> edge[n];
  for ( int i = 0; i < n; i++ ) {
    cin >> h[i];
    ch[i] = 0;
  }
  for ( int i = 0; i < m; i++ ) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  int s = 0;
  while ( s < n ) {
    for ( int i = 0; i < edge[s].size(); i++ ) {
      if ( h[s] >= h[edge[s][i]] ) { ch[edge[s][i]] = -1; }
      if ( h[s] <= h[edge[s][i]] ) { ch[s] = -1; }
    }
    if ( ch[s] == 0 ) { ch[s] = 1; }

    for ( ; s < n; s++ ) {
      if ( ch[s] == 0 ) { break; }
    }
  }

  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( ch[i] == 1 ) { ans++; }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9516
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans = i;
        }
    }
    cout << (ans-1)+(n/ans-1);
    return 0;
}

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


int main() {
    ll n; cin>>n;
    vector<ll> a(n);
    constexpr ll max=1e18;
    ll ans=1;
    rep(i,n){
        cin>>a.at(i);
        if(a.at(i)==0){
            puts("0");
            return 0;
        }
    }
    rep(i,n){
        if(a.at(i)>max/ans){
            cout<<-1<<endl;
            return 0;
        }
        else{
            ans*=a.at(i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4048
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    c = Counter(S)
    return YES if len(c) == 2 and len(set(c.values())) == 1 else NO


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    result = solve(S)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
    faster

    int n;
    cin>>n;

    int a[n],b[n];

    int max1,max2,j;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=a[i];

        if(i==0)
        {
            max1=a[i];
            j=i;
        }
        else
        {
            if(a[i]>max1)
            {
                max1=a[i];
                j=i;
            }

        }
    }

    b[j]=-1;

    for(int i=0; i<n; i++)
    {

        if(i==0)
        {
            max2=b[i];
        }
        else
        {
            if(b[i]>max2)
            {
                max2=b[i];
            }

        }
    }

    for(int i=0; i<n; i++)
    {
        if(i==j)
            cout<<max2<<endl;
        else
            cout<<max1<<endl;


    }







    return 0;
}


Measured memory_bytes: 3200
package main

import (
	"fmt"
)

func max(v1,v2 int) int{
	if v1 > v2 {
		return v1
	} else {
		return v2
	}
}

func main() {
	var a, b int
	
	fmt.Scan(&a,&b)
	
	fmt.Printf("%d",max(max(a+b,a-b),a*b))

}

Measured memory_bytes: 512
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<i64>();
    let mut cnt = 0i64;
    for i in 1..n+1 {
        let f = fst(i);
        let l = last(i);
        if l == 0 {continue;}
        if f == l && f <= n {
            cnt += 1;
//            dbg!((i, 1));
        }
        for k in 0.. {
            let c = count(l, f, k, n);
            if c == 0 {
                break;
            } else {
//                dbg!((i, k, c));
                cnt += c;
            }
        }
    }
    println!("{}", cnt);
}

fn count(f: i64, l: i64, k: usize, n: i64) -> i64 {
    let nf = fst(n);
    let nlen = format!("{}", n).len();
    if k + 2 > nlen || (k + 2 == nlen && f > nf) {
        0
    } else if f < nf || k + 2 < nlen {
        10f64.powi(k as i32) as i64
    } else {
        let mut ret = (last(n) >= l) as i64;
        for i in 1..k+1 {
            let p = n / 10f64.powi(i as i32) as i64 % 10;
            ret += p * 10f64.powi(i as i32 - 1) as i64;
        }
        ret
    }
}

fn fst(n: i64) -> i64 {
    format!("{}", n).chars().next().unwrap() as i64 - '0' as i64
}

fn last(n: i64) -> i64 {
    format!("{}", n).chars().last().unwrap() as i64 - '0' as i64
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a[] = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
		}

		Arrays.sort(a);

		System.out.println(a[a.length - 1] - a[0]);
	}
}


Measured memory_bytes: 21460
s, t = input(), input()

ls = len(s)
lt= len(t)
is_double = False
c = len(s)
for i in range(ls-lt+1):
  _c = 0 
  for j in range(lt):
    if not s[i+j] == t[j]:
      _c +=1
  if c > _c:
    c = _c
    
print(c)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int x[50],y[50];
map<pair<int,int>,int> m;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>x[i]>>y[i];
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++){
			m[make_pair(x[i]-x[j],y[i]-y[j])]++;
			m[make_pair(x[j]-x[i],y[j]-y[i])]++;
		}
	int M=0;
	for(auto it:m)
		M=max(M,it.second);
	cout<<n-M<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int ans = 0;
    for(auto x : mp)ans++;
    cout << ans << endl;
}


Measured memory_bytes: 19260
#include <stdio.h>
int main (void)
{
	int a,b,c,x;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a>b)
	{
		x=a;
		a=b;
		b=x;
	}
	else
	{
	}
	if(b>c)
	{
		x=b;
		b=c;
		c=x;
	}
	if(a>b)
	{
		x=a;
		a=b;
		b=x;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define Q int tt,qq; cin>>tt ;for(qq=1;qq<=tt;qq++)
#define I ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    ll n,i,j,ans=0;
    cin>>n;
    ll a[n+1],b[n];
    for(i=0;i<n+1;i++)cin>>a[i];
    for(i=0;i<n;i++)cin>>b[i];
    for(i=n-1;i>=0;i--)
    {
        ans+=min(a[i+1],b[i]);
        b[i]-=a[i+1];
        if(b[i]<1)continue;
        ans+=min(a[i],b[i]);
        if(b[i]>a[i])a[i]=0;
        else a[i]-=b[i];
    }
    cout<<ans;
}


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

using namespace std;

#define REP(i,a,b) for(ll i = a; i < b; i++)
#define DB( x ) cout << #x << " = " << x << endl;
#define sz(s) ((int)((s).size()))
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<int, pii> tri;
typedef vector <vector <ll>> matrix;
typedef pair<string, string> pss;

const ll mod = (ll)1e9 + 7;
const int MAX = (int)1e6 + 100;

const ll oo = 0x3f3f3f3f3f3f3f3f;

ll dp[102][100005];

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

    int n, w; cin >> n >> w;

    vector<pii> v(n);

    for(auto &it : v) cin >> it.first >> it.second;

    memset(dp, oo, sizeof(dp));

    dp[0][0] = 0;

    for(int i = 1;i <= n;++i){
        for(int j = 0;j <= 100000;++j){
            if(j >= v[i - 1].second)
                dp[i][j] = dp[i - 1][j - v[i - 1].second] + v[i - 1].first;
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }

    for(int i = 100000;i >= 0;--i)
        if(dp[n][i] <= w){
            cout << i << endl;
            return 0;
        }
}

Measured memory_bytes: 80000
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 20000000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, a, fac[N], inv[N];

int POW(int a, int b){
	int res = 1;
	while (b){
		if (b & 1) res = res * 1ll * a % MOD;
		b >>= 1;
		a = a * 1ll * a % MOD;
	}
	return res;
}

int nCr(int a, int b){
	if (a < b || a < 0 || b < 0) return 0;
	int res = fac[a];
	res = res * 1ll * inv[b] % MOD;
	res = res * 1ll * inv[a - b] % MOD;
	return res;
}

int mul(int a, int b){
	return a * 1ll * b % MOD;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> a;
	fac[0] = 1;
	for (int i = 1; i < N; i++) fac[i] = (fac[i - 1] * 1ll * i) % MOD;
	inv[N - 1] = POW(fac[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; i--){
		inv[i] = (inv[i + 1] * 1ll * (i + 1)) % MOD;
	}
//	cout << "YES" << endl;
//	cout << nCr(6,3) << '\n';
	int b = n - a;
	int ans = 0;
	for (int i = 1; i <= a + 1; i++){
		int res = 0;
		if (i == 1 && n == a){
			ans++;
			continue;
		}
		for (int j = 0; j < i - 1; j++){
			int delta = nCr(i - 1, j);
			int x = i - 1 - j;
			int c = max(0, a - i);
			delta = mul(delta, fac[x + b + c]);
			delta = mul(delta, mul(x, mul(inv[x + b], fac[x + b - 1])));
			res += ((j % 2)?-delta:delta);
			res %= MOD;
			res += MOD;
			res %= MOD;
//			cout << i << ' ' << j << ' ' << x << ' ' << b << ' ' << c << ' ' << res << '\n';
		}
//		cout << res << '\n';
		ans = (ans + res) % MOD;
	}
	cout << ans;








	return 0;
}


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

using namespace std;

const long long INF = (1LL << 36);

vector<int> solve(int K, int N){
    vector<int> res;
    if(K % 2 == 0){
        res.push_back(K/2);
        for(int i=0;i<N-1;i++) res.push_back(K);
        return res;
    }
    vector<long long> block(N);
    block.back() = 1;
    for(int i=N-2;i>=0;i--){
        block[i] = K * block[i+1] + 1;
        if(block[i] >= INF) block[i] = INF + (block[i] % 2);
    }
    int offset = 0;
    res.push_back((K+1)/2);
    for(int i=1;i<N;i++){
        if(block[i]/2 <= offset){
            long long order = (K * block[i])/2 - offset;
            while(order){
                --order;
                res.push_back(1 + order/block[i]);
                order %= block[i];
                ++i;
            }
            break;
        } else {
            res.push_back((K+1)/2);
            if(block[i]%2 == 1) ++offset;
        }
    }
    return res;
}

int main(){
    int K, N;
    while(cin >> K >> N){
        auto res = solve(K, N);
        cout << res[0];
        for(int i=1;i<res.size();i++) cout << " " << res[i];
        cout << endl;
    }
}

Measured memory_bytes: 4724
X = int(input())
a = [False]*(10**5+100)
l = []
for i in range(2, 10**5+100):
    if not a[i]:
        l.append(i)
        for j in range(i, 10**5+100, i):
            a[j] = True
for n in l:
    if n >= X:
        print(n)
        exit()


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)      //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++)    //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    ll n, a,b; cin >> n >> a >> b;
    if((b-a)%2==0) cout << (b-a)/2 << '\n';
    else {
        ll p = n-a;
        ll q = b-1;
        ll ans;
        if(p<q) ans = n-b;
        else ans = a-1;
        if((b-a)%2==0) ans += (b-a)/2;
        else ans += 1 + (b-1-a)/2; 

        cout << ans << '\n';
    }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a[200010],l,r,n,k,m;
int check(long long x)
{
    long long i,sum=0;
    for(i=1;i<=n;i++)
    {
        if(a[i]%x==0) sum+=a[i]/x-1;
        else sum+=a[i]/x;
    }
    return (sum<=k);
}
                     
int main()
{
    int i;
    cin>>n>>k;
    for(i=1;i<=n;i++) cin>>a[i];
    l=1;
    r=1999999999;
    while(l<r-1)
    {
        m=(l+r)/2;
        if(check(m)==1) r=m;
        else l=m;
    }
    if(check(l)==1) cout<<l;
    else cout<<r;
    system("pause");
}
    


Measured memory_bytes: 5180
n=int(input())
d={}
for i in range(n):
    a=input()
    if a[0]=="M" or a[0]=="A" or a[0]=="R" or a[0]=="C" or a[0]=="H":
        d[a[0]]=d.get(a[0],0)+1
a=list(d.values())
if len(a)<3:
    print(0)
    exit()
import itertools
c=list(itertools.combinations(a,3))
ans=0
for i,j,k in c:
    ans+=i*j*k
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	int s;
	cin >> s;
	set<int> k;
	k.insert(s);
	
	int ans = 2;
	while (k.find(s % 2 == 0 ? s / 2 : 3 * s + 1) == k.end()) {
		int next = s % 2 == 0 ? s / 2 : 3 * s + 1;
		k.insert(next);
		s = next;
		++ans;
	}

	cout << ans << "\n";

	return 0; 
}


Measured memory_bytes: 256
fn main() {
	loop {
		let v = read_vec::<i32>();
		if v == [-1, -1, -1] { break; }
		
		println!("{}", solve(v[0], v[1], v[2]));
	}
}

fn solve(m: i32, f: i32, r: i32) -> char {
	let s = m + f;
	if m == -1 || f == -1 || s < 30 { 'F' }
	else if s >= 80 { 'A' }
	else if s >= 65 { 'B' }
	else if s >= 50 || r >= 50 { 'C' }
	else { 'D' }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


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

int n, w, h;
int x1[1002], y1[1002], x2[1002], y2[1002];
short t[3002][3002];
vector<int> vx, vy;

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

void show(){
  for(int i = h - 1; i >= 0; i--){
    for(int j = 0; j < w; j++){
      cout << t[i][j];
    }
    cout << endl;
  }
}

void dfs(int x, int y){
  t[y][x] = 1;

  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];

    if(0 <= nx && nx < w && 0 <= ny && ny < h && !t[ny][nx]){
      dfs(nx, ny);
    }
  }
}

void compressX(){
  int minus = 0;

  if(2 <= w - vx[vx.size() - 1]){
    w -= w - vx[vx.size() - 1] - 1;
  }

  if(2 <= vx[0]){
    for(int i = 0; i < n; i++){
      x1[i] -= vx[0] - 1;
      x2[i] -= vx[0] - 1;
    }
    minus += vx[0] - 1;
  }

  for(int i = 0; i < vx.size() - 1; i++){
    int diff = vx[i + 1] - vx[i];

    if(diff <= 1) continue;

    diff--;

    for(int j = 0; j < n; j++){
      if(vx[i + 1] <= x1[j] + minus){
        x1[j] -= diff;
      }
      if(vx[i + 1] <= x2[j] + minus){
        x2[j] -= diff;
      }
    }

    minus += diff;
  }

  w -= minus;
}

void compressY(){
  int minus = 0;

  if(2 <= h - vy[vy.size() - 1]){
    h -= h - vy[vy.size() - 1] - 1;
  }

  if(2 <= vy[0]){
    for(int i = 0; i < n; i++){
      y1[i] -= vy[0] - 1;
      y2[i] -= vy[0] - 1;
    }
    minus += vy[0] - 1;
  }

  for(int i = 0; i < vy.size() - 1; i++){
    int diff = vy[i + 1] - vy[i];

    if(diff <= 1) continue;

    diff--;

    for(int j = 0; j < n; j++){
      if(vy[i + 1] <= y1[j] + minus){
        y1[j] -= diff;
      }
      if(vy[i + 1] <= y2[j] + minus){
        y2[j] -= diff;
      }
    }

    minus += diff;
  }

  h -= minus;
}

void paste(){
  memset(t, 0, sizeof(t));

  for(int i = 0; i < n; i++){
    for(int x = x1[i]; x < x2[i]; x++){
      t[y1[i]][x]++;
      t[y2[i]][x]--;
    }
  }

  for(int x = 0; x < w; x++){
    int cnt = 0;

    for(int y = 0; y < h; y++){
      cnt += t[y][x];
      t[y][x] = (cnt > 0);
    }
  }
}

void solve(){
  //座標圧縮
  compressX();
  compressY();

  //テ-プ貼り
  paste();

  //DFSでカウント
  int cnt = 0;

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(t[i][j]) continue;
      cnt++;
      dfs(j, i);
    }
  }

  cout << cnt << endl;
}

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

    vx.clear();
    vy.clear();

    for(int i = 0; i < n; i++){
      cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      vx.push_back(x1[i]);
      vx.push_back(x2[i]);
      vy.push_back(y1[i]);
      vy.push_back(y2[i]);
    }

    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());

    solve();
  }
}

Measured memory_bytes: 20840
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    unsigned long x, y;
    
    while (cin >> x >> y)
    {
        unsigned long a = x, b = y;
        while (true)
        {
            unsigned long tmp = b;
            b = a % b;
            a = tmp;
            if (b == 0)
            {
                break;
            }
        }
        cout << a << " " << x / a * y << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3084
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

int T,n,m,i,j,k,x,y,z,Ans,sum,cnt;
int a[N],b[N];
char c[N],d[N];

struct Data{
	int x,y;
};

IL int Abs(int x){return (x<0)?-x:x;}
IL void Swap(int &a,int &b){a^=b^=a^=b;}
IL int Min(int a,int b){return (a<b)?a:b;}
IL int Max(int a,int b){return (a>b)?a:b;}
IL bool cmp(const Data a,const Data b){return a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL int read(){
	int p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int Check(int l){
	reg int i=0,s=0;
	for (i=l;i<=l+y-1;i++){
		if (c[i]!=d[i-l])	s++;
	}
	return s;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	scanf("%s",&c);
	scanf("%s",&d);
	x=strlen(c);	y=strlen(d);
	Ans=INF;
	for (i=0;i<x-y+1;i++){
		Ans=Min(Ans,Check(i));
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint t(N+1),x(N+1),y(N+1);
    for(int i=1;i<=N;i++) cin>>t[i]>>x[i]>>y[i];

    REP(i,N){
        int dt=t[i+1]-t[i];
        int dx=abs(x[i+1]-x[i]);
        int dy=abs(y[i+1]-y[i]);
        if(dt<dx+dy or dt%2!=(dx+dy)%2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
 
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int w, a, b;
  std::cin >> w >> a >> b;
  if (a > b)
    swap(a, b);
  if (a + w >= b)
    print(0);
  else
    print(b - (a + w));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <cstring>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

const int MaxV = 10000;

vector<int> graph[MaxV];
int match[MaxV];
bool used[MaxV];

void addEdge(int u, int v)
{
    graph[u].push_back(v);
    graph[v].push_back(u);
}

bool dfs(int v)
{
    used[v] = true;

    for (auto &e : graph[v])
    {
        int u = e, w = match[u];

        if (w < 0 || !used[w] && dfs(w))
        {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }

    return false;
}

int bipartiteMatcing()
{
    int res = 0;

    memset(match, -1, sizeof(match));

    REP(v, MaxV)
    {
        if (match[v] < 0)
        {
            memset(used, 0, sizeof(used));

            if (dfs(v))
            {
                res++;
            }
        }
    }

    return res;
}

int gcd(int a, int b)
{
    if(a < b)
    {
        gcd(b, a);
    }

    if(b == 0)
    {
        return a;
    }

    return gcd(b, a % b);
}

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

    int M, N;
    while(cin >> M >> N && M)
    {
        vector<int> B(M), R(N);

        REP(i, 1010)
        {
            graph[i].clear();
            match[i] = 0;
            used[i] = false;
        }

        REP(i, M)
        {
            cin >> B[i];
        }

        REP(i, N)
        {
            cin >> R[i];
        }

        REP(i, M)
        {
            REP(j, N)
            {
                if(gcd(B[i], R[j]) == 1) continue;
                
                addEdge(i, j + M);
                   
            }
        }

         Cout(bipartiteMatcing());
    }
    return 0;
}


Measured memory_bytes: 5308
/*
 * src.cpp
 *
 *  Created on: 2016/08/06
 *      Author: joi
 */

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

const int MAX_N=1e4,LETTERS='z'-'a'+1;

int N;
char word[64];

int in['z'-'a'+1],out['z'-'a'+1];
bool flg['z'-'a'+1];
vector<int> G[LETTERS];

void dfs(int v){
	flg[v]=true;
	REP(i,(int)G[v].size()){
		if (!flg[G[v][i]]){
			dfs(G[v][i]);
		}
	}
}

int main(){
	do{
		scanf("%d",&N);
		if (N){
			REP(i,LETTERS){
				G[i].clear();
				flg[i]=false;
				in[i]=out[i]=0;
			}
			REP(i,N){
				scanf("%s",word);
				int len=strlen(word);
				G[word[0]-'a'].push_back(word[len-1]-'a');
				out[word[0]-'a']++;
				in[word[len-1]-'a']++;
			}
			bool f=true;
			REP(i,LETTERS){
				if (in[i]!=out[i]){
					f=false;
				}
			}
			int con=0;
			REP(i,LETTERS){
				if (in[i]==0 && out[i]==0){
					continue;
				}
				if (!flg[i]){
					dfs(i);
					con++;
				}
			}
			if (f && con==1){
				printf("OK\n");
			}else{
				printf("NG\n");
			}
		}
	}while(N);
	return 0;
}

Measured memory_bytes: 1248
fun main(args: Array<String>) {
    val S = readInputLine().toCharArray().map { (it - '0').toLong() }

    var ans = 0L

    for (bit in 0 until (1 shl (S.size - 1))) {
        var tmp = 0L
        for (i in 0 until S.size) {
            tmp = tmp * 10 + S[i]
            if (bit and (1 shl i) != 0) {
                ans += tmp
                tmp = 0L
            }
        }
        ans += tmp
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 33652
#template
from sys import setrecursionlimit
setrecursionlimit(10**6)
from collections import Counter
def inputlist(): return [int(i) for i in input().split()]
#template
li = ['hi','hihi','hihihi','hihihihi','hihihihihi']
S = input()
if S in li:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <stack>
#include <string>
#include <cstring>
using namespace std;

int main() {
	string str;
	while(getline(cin,str)) {
		stack <double> s;
		for(int i=0;i<str.size();i++) {
			string tmp=""; char ch; ch=str[i];
			while(ch!=' ') {tmp+=str[i++]; if(i>=str.size()) break; ch=str[i];}
			if(tmp=="+" || tmp=="-" || tmp=="*" || tmp=="/"){
				double a[2];
				for(int j=0;j<2;j++) {a[j]=s.top(); s.pop();}
				if(tmp=="+") s.push(a[1]+a[0]);
				else if(tmp=="-") s.push(a[1]-a[0]);
				else if(tmp=="*") s.push(a[1]*a[0]);
				else s.push(a[1]/a[0]);
			}
			else s.push(atoi(tmp.c_str()));
		}
		cout << fixed << setprecision(6) << s.top() << '\n' ; s.pop();
	}
}

Measured memory_bytes: 1272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    string S;
    cin >> S;
    
    map<char, int> dir;
    dir['N'] = 0;
    dir['W'] = 0;
    dir['S'] = 0;
    dir['E'] = 0;
    
    for(int i = 0; i < S.length(); ++i){
        dir[S[i]]++;
    }
    
    if((dir['N'] == 0 && dir['S'] > 0) || (dir['S'] == 0 && dir['N'] > 0)){
        cout << "No\n";
        return 0;
    }
    if((dir['W'] == 0 && dir['E'] > 0) || (dir['E'] == 0 && dir['W'] > 0)){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> A(N+1);
  multiset<int> num;

  for(int i=1;i<=N;i++) {
    std::cin >> A[i];
  }
  num.insert(A[1]);
  for(int i=2;i<=N;i++){
    if(A[i]<=*num.begin()){
      num.insert(A[i]);
    }else{
      auto itr = num.lower_bound(A[i]);
      itr--;
      num.erase(itr);
      num.insert(A[i]);
    }
  }
  std::cout << num.size() << '\n';
  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

struct Combination {
	const int MAX = 5000010;
	const int MOD;
	vector<fint64> FAC;
	vector<fint64> INV;
	vector<fint64> FAC_INV;
	Combination(fint64 MOD) :
		MOD(MOD),
		FAC(vector<fint64>(MAX)),
		INV(vector<fint64>(MAX)),
		FAC_INV(vector<fint64>(MAX))
		{
			FAC[0] = INV[1] = FAC_INV[0] = 1;
			for(int i = 1; i < MAX; ++i) {
				FAC[i] = FAC[i - 1] * i % MOD;
				if(i > 1) INV[i] = MOD - INV[MOD % i] * (MOD / i) % MOD;
				FAC_INV[i] = FAC_INV[i - 1] * INV[i] % MOD;
			}
		}
	fint64 C(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[r] % MOD * FAC_INV[n - r] % MOD;
	}
	fint64 P(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[n - r] % MOD;
	}
	fint64 H(int n, int r) {
		if(r == 0) return 1;
		return C(n + r - 1, r);
	}
};

using mint = ModInt<MOD>;
int main() {
	Combination com(MOD);
	int n, k; cin >> n >> k;
	mint ans = 0;
	for(int i = 0; i <= min(n - 1, k); ++i) {
		ans += com.C(n, i) * com.C(n - 1, i);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 117376
/*
 * coder: @SumitRaut
 */
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

inline void solve() {
	int n;
	cin>>n;
	ll ans=0;
	int a=1;
	while(a<n) {
		ans+=n/a-!(n%a);
		++a;
	}
	cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        solve();
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#define maxn 2000010
using namespace std;
int n,w,st=0;
int ans[2][10]={{0,1,0,1,1,2,1,0},{0,1,0,1,1,0,1,0}};
bool flag=0; 
char s[maxn];
int main(){
	scanf("%d%s",&n,s);
	n--;
	for(register int i=0;i<=n;i++){
		if(s[i]=='2')flag=1;
		w=s[i]-'1';
		st^=(1<<w)&((n==(n|i))?7:0);
	}
	printf("%d",ans[flag][st]);
	return 0;
} 

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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 sumde(ll n) {
  return n * (n + 1) / 2;
}


string s;

int main () {
  cin >> s;
  int n = s.size();

  int up_num = 0;
  int down_num = 0;
  ll ans = 0;

  Rep(i, n) {
    char tmp_char = s[i];

    if (tmp_char == '<') {
      if (down_num == 0) {
        up_num++;
      } else {
        ans += sumde(up_num-1);
        ans += sumde(down_num-1);
        ans += max(up_num, down_num);

        //cout << ans << "\n";

        up_num = 1;
        down_num = 0;
      }
    } else {
      down_num++;
    }

    //cout << up_num << " " << down_num << "\n";
  }

  ans += sumde(up_num-1);
  ans += sumde(down_num-1);
  ans += max(up_num, down_num);

  cout << ans << "\n";
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
void swap(ll &a,ll &b){
    ll temp=a;
    a=b;
    b=temp;
}
ll gcd(ll a,ll b){
    while(b){
        a%=b;
        swap(a,b);
    }
    return a;
}

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




int main(){
    ll N;
    cin>>N;
    ll ans=0;
    if(N%2==1){
        out(0);
        return 0;
    }else{
        N/=2;
        while(N>0){
            ans+=(N/=5);
        }
        out(ans);
    }
    return 0;
}


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

int main() {
	int	N;
	cin >> N;
	vector<int> vec1;
	rep(i, N)
	{
		int a;
		cin >> a;
		vec1.push_back(a);
	}
	int	M;
	cin >> M;
	vector<int> vec2;
	rep(i, M)
	{
		int b;
		cin >> b;
		vec2.push_back(b);
	}
	if (vec2 > vec1)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}



Measured memory_bytes: 3144
import java.util.*;

public class Main {
	static class Criteria {
		int l,r;
		int x;
		public Criteria(int l, int r, int x) {
			this.l = l;
			this.r = r;
			this.x = x;
		}
	}
	static int N;
	static ArrayList<ArrayList<Criteria>> list;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final long MOD = 1000000007;
		
		N = sc.nextInt();
		int M = sc.nextInt();
		list = new ArrayList<>();
		for(int i=0; i<N+1; i++)
			list.add(new ArrayList<>());
		for(int i=0; i<M; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt();
			int x = sc.nextInt();
			list.get(r).add(new Criteria(l, r, x));
		}
		
		int[][][] dp = new int[N+1][N+1][N+1];
		dp[0][0][0] = 1;

		for(int i=0; i<N; i++) {
			for(int j=0; j<N; j++) {
				for(int k=0; k<N; k++) {
					if(dp[i][j][k]==0)
						continue;
					if(isOK(i, j, k)) {
						int max = Math.max(i, Math.max(j, k));
						dp[max+1][j][k] = (int)(((long)dp[max+1][j][k] + dp[i][j][k])%MOD);
						dp[i][max+1][k] = (int)(((long)dp[i][max+1][k] + dp[i][j][k])%MOD);
						dp[i][j][max+1] = (int)(((long)dp[i][j][max+1] + dp[i][j][k])%MOD);
					}
				}
			}
		}
		long ans = 0;
		for(int i=0; i<N; i++)
			for(int j=0; j<N; j++)
				if(isOK(N, i, j))
					ans = (ans + dp[N][i][j] + dp[j][N][i] + dp[i][j][N])%MOD;
		
		System.out.println(ans);
		sc.close();
	}
	
	static boolean isOK(int i, int j, int k) {
		int max = Math.max(i, Math.max(j, k));
		for(Criteria c : list.get(max))
			if(!isOK(c, i, j, k))
				return false;
		return true;
	}
	
	static boolean isOK(Criteria c , int i, int j, int k) {
		int ci3 = Math.min(i, Math.min(j, k));
		int ci1 = Math.max(i, Math.max(j, k));
		int ci2 = i^j^k^ci3^ci1;
		if(c.x==1) {
			return ci2 <= c.l;
		} else if(c.x==2) {
			return ci3 <= c.l && c.l < ci2;
		} else {
			return c.l < ci3;
		}
	}
}


Measured memory_bytes: 168284
#include <bits/stdc++.h>
#define eps 1e-9

using namespace std;
typedef double db;
struct P{
    db x, y;
    P(){}
    P(db x, db y) : x(x) , y(y) {}
    P operator - (P a){ return P(x-a.x, y-a.y); }
    P operator + (P a){ return P(x+a.x, y+a.y); }
    P operator * (db a){ return P(x*a, y*a); }
    db times(P a){ return x*a.y-y*a.x; }
    void pri(){ printf("%.10lf %.10lf\n", x, y); }
};
typedef P V;
struct L{ P p, q; };

int sign(db x){ return x<-eps ? -1 : x>eps; }

P crosspoint(P p1, P q1, P p2, P q2){
    P p=p2-p1, l2=q2-p2, l1=q1-p1;
    if( !sign( p.times(l2) ) ) return p1;
    P tmp = l1* abs( p.times(l2)/l2.times(l1) ) ;
    return p1+tmp;
}

int main(){
    //freopen("owo.in","r",stdin);
    L s1, s2;
    int n;
    cin >> n;
    while(n--){
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &s1.p.x, &s1.p.y, &s1.q.x, &s1.q.y, &s2.p.x, &s2.p.y, &s2.q.x, &s2.q.y);
        crosspoint(s1.p, s1.q, s2.p, s2.q).pri();
    }
    return 0;
}


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

using namespace std;
main(){

long long int W,N;
cin>>N>>W;
long long int w[N],v[N];
for(int i=0;i<N;i++){
cin>>w[i]>>v[i];
}
long long dp[W+1][2];
for(int i=0;i<=W;i++){dp[i][0]=0;dp[i][1]=0;}
for(int i=0;i<N;i++)for(int j=1;j<=W;j++){

if(j<w[i]){dp[j][i%2]=dp[j][(i+1)%2];}
else{dp[j][i%2]=max(dp[j][(i+1)%2],v[i]+dp[j-w[i]][(i+1)%2]);}
}
cout<<dp[W][(N-1)%2];

}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <stack>
#include <vector>
using namespace std;
const long long INF = 0x3f3f3f3f;
typedef long long ll;
long long dis[2505]={0};
struct node{
    long long dis;
    int pos;
    bool operator<(const node &t)const{
        return dis>t.dis;
    }
};
vector<node>edg[2505];
int sele[2505]={0};
int vis[2505]={0};
int inq[2505]={0};
bool SPFA(int n)
{
    memset(vis,0,sizeof(vis));
    memset(inq,0,sizeof(inq));
    queue<int> Q;
    for(int i = 2;i <= n;i++) dis[i] = INF;
    dis[1]=0;
    inq[1] = 1;
    Q.push(1);
    int t,j;
    while(!Q.empty())
    {
        t = Q.front();
        Q.pop();
        vis[t] = 0;
        for(int i=0;i<edg[t].size();i++)
        {
            j=edg[t][i].pos;
            if(dis[t]+edg[t][i].dis<dis[j]&&sele[j]){
                dis[j]=dis[t]+edg[t][i].dis;
                if(!vis[j]){
                    if(inq[j]>=n)
                        return false;
                    inq[j]++;
                    Q.push(j);
                    vis[j]=1;
                }
            }
        }
    }
    return true;
}
void dfs(int x){
    vis[x]=1;
    for(int i=0;i<edg[x].size();i++)
        if(!vis[edg[x][i].pos])dfs(edg[x][i].pos);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    int n,m,k;
    int a,b;
    long long num;
    cin >> n >> m >> k;
    for(int i=0;i<m;i++){
        cin >> a >> b >> num;
        edg[a].push_back({k-num,b});
    }
    for(int i=1;i<=n;i++){
        memset(vis,0,sizeof vis);
        dfs(i);
        if(vis[n])sele[i]=1;
        //cout << sele[i] << endl;
    }
//    for(int i=1;i<=n;i++)
//        sort(edg[i].begin(),edg[i].end());
    if(SPFA(n)){
        cout << max(0ll,-dis[n]) <<endl;
    }
    else
        cout << -1 <<endl;
    return 0;
}


Measured memory_bytes: 512
N = int(input())
M, A, R, C, H = 0, 0, 0, 0 ,0
for i in range(N):
  s = input()
  if s[0] == "M": M+=1
  if s[0] == "A": A+=1
  if s[0] == "R": R+=1
  if s[0] == "C": C+=1
  if s[0] == "H": H+=1
ans = 0
ans += M*A*R
ans += M*A*C
ans += M*A*H
ans += M*R*C
ans += M*R*H
ans += M*C*H

ans += A*R*C
ans += A*R*H
ans += A*C*H

ans += R*C*H

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> str[105];
	for(int i=1;i<=k;i++)
	{
		int d;
		cin>>d;
		for(int j=1;j<=d;j++)
		{
			int x;
			cin>>x;
			str[x].push_back(d);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	if(str[i].size()==0) ans++;
	cout<<ans<<endl; 
}

Measured memory_bytes: 3652
#include<stdio.h>
  
  
int main(void){
 
int i,j,N,v,S[10000],T[10000],q; 
int c =0;
  
    scanf("%d", &N);
     for ( i = 0; i < N; i++ ){ 
scanf("%d", &S[i]);
}
   
 scanf("%d", &q);
     for ( i = 0; i < q; i++ ){ 
scanf("%d", &T[i]);
}
  
 
for(i=0;i<q;i++){
    
        for ( j = 0 ; j <N; j++ ) {
            if ( T[i] == S[j] ) {
                 
      
                 
c++;
break;
            }
        }
    }
  
     
 
  
    printf("%d\n",c);
  
    return 0;
}

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

int main() {
  int a,b;
  cin>>a;
  b=a;
  int in=1,count=0;
  for(int i=0; i<10; i++){
    count+=a%10;
    a/=10;
    
  }
  if(b%count==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
                           
}



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

using namespace std;

int draw()
{
    int x,y;
    cin>>x>>y;

    if(x==0 && y==0)
        return 0;
    else
        for(int i = 0; i<x; i++)
        {
            for(int j = 0; j<y; j++)
            {
                if(i==0 || j==0 || i == x-1 || j == y-1)
                    cout<<"#";
                else
                    cout<<".";
            }
            cout<<endl;
        }
    cout<<endl;
    draw();
}

int main()
{

    draw();
    return 0;
}




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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++)
    cin >> h.at(i);
  int ans = 0;
  for(int i : h)
    if(i >= k)
      ans++;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>

int main(){
    int swap,a[3];
    std::cin >> a[1] >> a[2] >> a[3];
    if ( a[1] > a[2] ){
        swap = a[1];
        a[1] = a[2];
        a[2] = swap;
    }
    if ( a[2] > a[3] ){
        swap = a[2];
        a[2] = a[3];
        a[3] = swap;
    }
    if ( a[1] > a[2] ){
        swap = a[1];
        a[1] = a[2];
        a[2] = swap;
    }
    std::cout << a[1] << " " << a[2] << " " << a[3] << std::endl;
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const int maxn=30;
vector<int> childs[maxn];
int parents[maxn];
int de[maxn];
int bro[maxn];
int he[maxn];
int n;
void pr(){
	for(int i=0;i<n;i++){
		cout<<i<<" ";
		for(int j=0;j<childs[i].size();i++){
			cout<<childs[i][j]<<" ";
		}
		cout<<endl;
	}
} 
void set_d(int root,int k){
	de[root]=k;
	for(int i=0;i<childs[root].size();i++){
		int v=childs[root][i];
		set_d(v,k+1);
	} 
}

int set_h(int rt){
	int nh=-1;
	for(int i=0;i<childs[rt].size();i++){
		nh=max(nh,set_h(childs[rt][i]));
	}
	he[rt]=nh+1;
	return he[rt];
}

int main()
{
	cin>>n;
	memset(parents,-1,sizeof(parents));
	memset(bro,-1,sizeof(bro));
	for(int i=0;i<n;i++){
		int id,left,right;
		cin>>id>>left>>right;
		if(left!=-1) bro[left]=right;
		if(right!=-1) bro[right]=left;
		if(left!=-1) childs[id].push_back(left);
		if(right!=-1) childs[id].push_back(right);
		if(left!=-1) parents[left]=id;
		if(right!=-1) parents[right]=id;
	}
	int root;
	for(int i=0;i<n;i++){
		if(parents[i]==-1){
			root=i;
			break;
		}
	}
	//cout<<"ok"<<endl;
	set_d(root,0);
//	cout<<"ok"<<endl;
	set_h(root);
	//cout<<"ok"<<endl;
	for(int i=0;i<n;i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,parents[i],bro[i],childs[i].size(),de[i],he[i]);
		if(i==root){
			cout<<"root";
		} 
		else if(childs[i].size()==0){
			cout<<"leaf";
		}
		else{
			cout<<"internal node";
		}
		cout<<endl;
	} 
	return 0;
}


Measured memory_bytes: 3280