akhauriyash/Code-Regression huggingface dataset:
/*
	2205: Lottery Checker
*/
#include	<iostream>
#include	<string>
#include	<vector>
#include	<utility>

using namespace std;

typedef pair<string, int> Lty;

int main(void) {
	int n, m, lM;
	long long int sum;
	string lN, B, buf;
	bool fl;

	while (1) {
		vector<Lty>		LotteryList;
		cin >> n >> m;
		if (n == 0 && m == 0) { break; }
		for (int i = 0; i < n; i++) {
			lN.clear();
			cin >> lN >> lM;
			LotteryList.push_back( Lty(lN, lM) );
		}
		vector<Lty>::iterator it;
		sum = 0;
		for (int i = 0; i < m; i++) {
			cin >> B;
			for (it = LotteryList.begin(); it != LotteryList.end(); it++) {
				fl = true;
				buf = it->first;
				string::iterator s1_it = buf.begin(), s2_it = B.begin();
				while (s1_it != buf.end()) {
					if ((*s1_it) != (*s2_it) && (*s1_it) != '*') {
						fl = false;
						break;
					}
					s1_it++;	s2_it++;
				}
				if (fl) {
					sum += it->second;
					break;
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
N = int(input())
A = [int(x) for x in input().split()]
count = [0 for _ in range(10**6+10)]
for a in A:
    if count[a] > 1:
        continue
    for x in range(0, 10**6+10, a):
        count[x] += 1
ans = 0
for a in A:
    if count[a] == 1:
        ans += count[a]
print(ans)


Measured memory_bytes: 32208
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int n,k;
	string s;
	cin>>n>>k>>s;
	s[k-1]=tolower(s[k-1]);
	cout<<s;
	re 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

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

	cin >> a >> b >> c;
	int cnt=0;
	for (int i = a; i <= b; ++i) {
		if(c%i==0) cnt++;
	}
	println(cnt);

	return 0;
}



Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

double minc(double x[1000],double y[1000],int n,int t){
	double a=0.0;
	int i;
	for (i = 0; i < n; i++){
		a = a + pow(fabs(x[i] - y[i]), (double)t);
	}
	a=pow(a, (double)(1.0/t));
	return a;
}
double ceb(double x[1000],double y[1000], int n){
	double a=fabs(x[0]-y[0]);
	int i = 0;
	for (; i < n; i++){
		if (a < fabs(x[i] - y[i]))
			a = fabs(x[i] - y[i]);
	}
	return a;
}

int main(void){
	int n;
	double x[1000],y[1000];

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

	printf("%.6f\n", minc(x,y,n,1));
	printf("%.6f\n", minc(x,y,n, 2));
	printf("%.6f\n", minc(x,y,n,3));
	printf("%.6f\n", ceb(x,y,n));


	return 0;
}


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

int main(){
    int n;cin >> n;
    long long nums[n] ={0};
    for(int i = 0;i < n;i++) cin >> nums[i];
    long long ans = 0;
    bool flag = 0;
    while(1){
        for (int i = 0;i < n;i++){
            if (nums[i] % 2 != 0) {
                flag = true;
                break;
            }
            nums[i] /= 2;
        }
        if (flag){
            break;
        }
        ans ++;
    }
    cout << ans << endl;;
}

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

ll mod=1e9+7;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<vector<ll>> comb(2005,vector<ll>(2005));
    for(ll i=0;i<2005;i++){
        for(ll j=0;j<=i;j++){
            if(j==0||j==i){
                comb[i][j]=1;
            }else{
                comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
                comb[i][j]=(comb[i][j]+mod)%mod;
            }
        }
    }
    for(ll i=1;i<=k;i++){
        if(i>n-k+1){
            cout<<0<<endl;
        }else{
            ll ans=comb[n-k+1][i]*comb[k-1][i-1];
            cout<<(ans+mod)%mod<<endl;
        }
    }
}


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

class union_find {
	vector<int> par;
	int find(int a) {
		return par[a] < 0 ? a : par[a] = find(par[a]);
	}
public:
	union_find(int n) : par(n, -1) {}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (par[a] < par[b]) {
			par[a] += par[b];
			par[b] = a;
		}
		else {
			par[b] += par[a];
			par[a] = b;
		}
	}
	int size(int a) {
		return -par[find(a)];
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	union_find uf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			uf.unite(x, y);
		}
		else {
			printf("%d\n", uf.same(x, y));
		}
	}
	return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repeq(i,a,b) for(int i=a;i<=(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, a, b;
    cin >> n;
    cin >> a >> b;
    if((a-b)%2==0) cout << "Alice"<<endl;
    else cout << "Borys"<<endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
// constexpr int MOD = 1e9+7;
 
int main(void){
    Cin(int, n);
    Cins2(ll, n, a, b);
    Sort(a);
    Sort(b);
    if(n % 2 == 0){
        For(i, n) a[i] *= 2, b[i] *= 2;
        Cout((b[n/2] + b[n/2-1])/2 - (a[n/2] + a[n/2-1])/2 + 1);
    }

    else{
        Cout(b[n/2] - a[n/2] + 1);
    }
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N];
        for(int n=0;n<N;n++) a[n] = sc.nextLong() - (n + 1);;
        Arrays.sort(a);
        
        long b=a[N/2];
        long ans=0;;
        for(int n=0;n<N;n++)ans += Math.abs(b-a[n]);
        System.out.println(ans);
    }
}

Measured memory_bytes: 91980
//A - Rounding
//20190915

using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] xa = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(xa[0] < xa[1] ? 0 : 10);
        }
    }
}


Measured memory_bytes: 13268
/**
 * author:    Ziel
 * created:   11.04.2020 21:59:46
**/

// ~zaletaet~

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin, x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T>
inline void cmin(T &a, T b) { a = min(a, b); }
template <class T>
inline void cmax(T &a, T b) { a = max(a, b); }

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ACCELERATE;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n;
	cin >> n;
	
	vector<int> a(n + 1);
	vector<int> cnt(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ll x = cnt[i];
		ans += (x * (x - 1) / 2);
	}
	
	for (int i = 1; i <= n; i++) {
		ll x = cnt[a[i]];
		ll y = x * (x - 1) / 2;
		ans -= y;
		cnt[a[i]]--;
		
		ll x1 = cnt[a[i]];
		ll y1 = x1 * (x1 - 1) / 2;
		ans += y1;
		cnt[a[i]]++;
		
		cout << ans << '\n';
		ans -= y1;
		ans += y;
	}
	
	return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 4224
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int>,
		null_type,
		less<pair<int, int>>,
		rb_tree_tag,
		tree_order_statistics_node_update>
		st;

//find_by_order(k);
//order_of_key(x);


const int MAXN = 220000;
int a[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	st ss;
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		ss.insert(make_pair(a[i], i));
	}
	for (int i = 0; i < n; ++i) {
		ss.erase({a[i], i});
		cout << ss.find_by_order((n - 1) / 2)->first << " ";
		ss.insert({a[i], i});
	}
	return 0;
}




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

double a[100 + 5];

int main() { // claudio van
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lf", &a[i]);
    a[i] = 1 / a[i];
  }
  double sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += a[i];
  }
  printf("%.10lf\n", 1 / sum);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n, a[10020], b[10020];
long long x, y;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i < n; i++) {
		if (b[i] > a[i] && (b[i] - a[i]) % 2 == 1) {
			a[i] += 2;
			b[i] += 1;
		}
		if (a[i] > b[i]) {
			x += a[i] - b[i];
		} else {
			y += b[i] - a[i];
		}
	}
//	cout << x << ' ' << y << endl;
	if ((y - x) >= x) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
#define db double
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }	
const int maxn=18;
char s[maxn];
int main()
{
	int n,m,k;
	while(scanf("%d%d%d",&n,&m,&k)==3)
	{
		if(n>m)	swap(n,m);
		bool flag=false;
		REPE(i,m){
			if(i*n==k)	flag=true;
			int sk=k-i*n;
			if(m-i*2==0)	continue;
			if(sk%(m-i*2)==0&&sk/(m-i*2)<=n&&sk/(m-i*2)>0)	flag=true;
		}
		if(flag)	printf("Yes\n");
		else	printf("No\n");
	}
	return 0;
}

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

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N, A, B; cin >> N >> A >> B;
	vector<int> X(N); rep(i, 0, N) { cin >> X[i]; }
	int ans = 0;
	rep(i, 1, N) {
		int d = X[i] - X[i - 1];
		if (d*A > B) {
			ans += B;
		}
		else ans += d*A;
	}
	cout << ans << endl;
	return 0;
}

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

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


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;
using ui = unsigned int;

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

struct SegmentTree{
    SegmentTree(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        for(int i=1;i<2*size;++i){
            data[i] = D;
        }
    }
    void propagate(int k){
        if(delayed[k]){
            data[k] = data2[k];
            if(k < size){
                data2[k*2] = data2[k*2+1] = data2[k];
                delayed[k*2] = delayed[k*2+1] = true;
            }
            delayed[k] = false;
        }
    }
    void update(ui x, int l, int r){
        _update(1, 0, size, x, l, r);
    }
    inline void _update(int k, int a, int b, ui x, int l, int r){
        propagate(k);

        if(b <= l || r <= a){return;}
        if(l <= a && b <= r){
            data2[k] = x;
            delayed[k] = true;
            propagate(k);
        }else{
            int mid = (a + b) / 2;
            _update(k * 2, a, mid, x, l, r);
            _update(k * 2 + 1, mid, b, x, l, r);
            data[k] = min(data[k*2], data[k*2+1]);
        }
    }
    ui minimum(int l, int r){
        return _minimum(1, 0, size, l, r);
    }
    inline ui _minimum(int k, int a, int b, int l, int r){
        propagate(k);

        if(b <= l || r <= a){return D;}
        if(l <= a && b <= r){return data[k];}
        int mid = (a + b) / 2;
        ui vl = _minimum(k * 2, a, mid, l, r),
            vr = _minimum(k * 2 + 1, mid, b, l, r);
        return min(vl, vr);
    }
    
    int size;
    bool delayed[400100]; // 伝搬されていないときtrue
    ui data[400100], data2[400100];
    const ui D = (1u << 31) - 1;
};

int N, Q;
SegmentTree segtree(100000);

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

    std::cin >> N >> Q;

    for(int i=0;i<Q;++i){
        int type, s, t;

        std::cin >> type >> s >> t;

        if(type == 0){
            ui x;
            std::cin >> x;

            segtree.update(x, s, t + 1);
        }else{
            std::cout << segtree.minimum(s, t + 1) << std::endl;
        }
    }
}



Measured memory_bytes: 5196
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string N;
  cin >> N;
  const char* n = N.c_str();
  REP(i, 0, 3) {
    if (n[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

int rectangle_menseki(int a, int b);
int rectangle_syu(int a, int b);

int main(){
    int tate, yoko;
    
    cin >> tate;
    cin >> yoko;
    
    cout << rectangle_menseki(tate, yoko) << " " <<  rectangle_syu(tate, yoko) << endl;
    return 0;
}

int rectangle_menseki(int a, int b){
    int menseki;
    menseki = a * b;
    return menseki;
}

int rectangle_syu(int a, int b){
    int syu;
    syu = 2 * a + 2 * b;
    return syu;
}


Measured memory_bytes: 3000
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            while(true) {
                var N = cin.ReadInt;
                if(N == 0) break;
                var S = cin.ReadIntArray(N);
                var aver = S.Average();
                var varia = S.Average(s => Pow(s - aver, 2));
                Console.WriteLine(Sqrt(varia));
            }
        }
        
    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 20680
#include<bits/stdc++.h>
using namespace std;
long long int knapsack(long int w,long int Wt[],long int val[],long int n)
{
    long long int k[n+1][w+1];
    for(long int i=0;i<n+1;i++)
    {
        for(long int j=0;j<=w;j++)
        {
            if((i==0)||(j==0))
            k[i][j]=0;
            else if(Wt[i-1]<=j)
            {
                k[i][j]=max(val[i-1]+k[i-1][j-Wt[i-1]],k[i-1][j]);
            }
            else
            k[i][j]=k[i-1][j];
        }
    }
    return k[n][w];
}
int main() 
{ 
    long int n,w;
    cin>>n>>w;
    long int wt[n],val[n];
    for(long int i=0;i<n;i++)
    {
         cin>>wt[i];
         cin>>val[i];
    }
    cout<<knapsack(w,wt,val,n);
    return 0;
} 

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rev(i, n) for (int i = (int)n-1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> l(n+1), r(n+1);
    l[0] = 0, r[n] = 0;
    rep(i, n) l[i+1] = gcd(l[i], a[i]);
    rev(i, n) r[i] = gcd(r[i+1],a[i]);

    int ans = 0;
    rep(i, n) ans = max(ans, gcd(l[i], r[i+1]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int main() {
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a<=b)cout<<"unsafe\n";
  else cout<<"safe";
 	return 0;
}

Measured memory_bytes: 3660
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
int n,m;
int pre[N];
struct node
{
	int l,r;
	int id;
} e[N];
int tr[N];
int lowbit(int x)
{
	return x & -x;
}
void add(int x,int k)
{
	for (int i = x; i <= n; i += lowbit(i))
		tr[i] += k;
}
int query(int x)
{
	int res = 0;
	for (int i = x; i; i -= lowbit(i))
		res += tr[i];
	return res;
}
bool cmp(node a,node b)
{
	if(a.r!=b.r)
		return a.r<b.r;
	else
		return a.l<b.l;
}
int ans[N];
void solve()
{
	cin>>n>>m;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	for(int i=1; i<=m; i++)
	{
		cin>>e[i].l>>e[i].r;
		e[i].id=i;
	}
	sort(e+1,e+1+m,cmp);
	int next=1;
	for(int i=1; i<=m; i++)
	{
		for(int j=next; j<=e[i].r; j++)
		{
			if(pre[a[j]])
				add(pre[a[j]],-1);
			add(j,1);
			pre[a[j]]=j;
		}
		next=e[i].r+1;
		ans[e[i].id]=query(e[i].r)-query(e[i].l-1);
	}
	for(int i=1; i<=m; i++)
		cout<<ans[i]<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



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

using namespace std;

bool check(long long a, long long b, long long c, long long n)
{
    return (n * (a * b + a * c + b * c)) == (4 * (a * b * c));
}
main()
{
    long long n;
    scanf("%lld", &n);
    if (n % 2 == 0)
        printf("%lld %lld %lld\n", n, n, n / 2);
    else if (n % 3 == 0)
        printf("%lld %lld %lld\n", n / 3, n * 2, n * 2);
    else{
        int limit = 0;
        if (n / 4 == 4)
            limit = n / 4 + 1;
        else
            limit = n / 4;
        long long a, b, c;
        bool finish = false;
        a = limit;
        long long antC = -1;
        while (!finish){
            b = limit;
            a++;
            if (n / a > 4)
                continue;
            while (!finish){
                b++;
                if ((double)n / b > 4.0)
                    continue;
                double count = (double)n / a + (double)n / b;
                if (count >= 4)
                    break;
                c = (n * a * b) / (4 * a * b - n * a - n * b);
                if (c == antC){
                    b = (n * a * c) / (4 * a * c - n * a - n * c);
                    if (check(a, b, c, n)){
                        printf("%lld %lld %lld\n", a, b, c);
                        finish = true;
                    }
                    else
                        break;
                }
                antC = c;
                double val = (double)n / a + (double)n / b + (double)n / c;
                if (val < 4)
                    break;
                if (check(a, b, c, n)){
                    printf("%lld %lld %lld\n", a, b, c);
                    finish = true;
                }
            }
        }
    }
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(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; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while(first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if(last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}

int N, A, B, C;
V l;

int dfs(int cur, int a, int b, int c) {
    if(cur == N) {
        if(min({a, b, c}) > 0)
            return abs(A - a) + abs(B - b) + abs(C - c) - 30;
        else
            return INF;
    }
    int a1 = dfs(cur + 1, a, b, c);
    int a2 = dfs(cur + 1, a + l[cur], b, c) + 10;
    int a3 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int a4 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    return min({a1, a2, a3, a4});
}

int main() {
    cin >> N >> A >> B >> C;
    l.resize(N);
    VECCIN(l);
    cout << dfs(0, 0, 0, 0) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int mas[9], u, w, t, q1, q2, fix[222], n;
int a[9], b[9];
void rec(int k){
	if (k == n) {
		t++;
		for(int i=1; i<=n; i++){
			if(a[i]!=mas[i])
			q1=1;
			if(b[i]!=mas[i])
			q2=1;
		}
		if(q1==0)
		u=t;
		if(q2==0)
		w=t;
		q1=0;
		q2=0;
		return;
	}
	for (int i = 1; i <= n; i++) 
		if (fix[i] == 0) {
			fix[i] = 1;
			mas[k+1] = i;
			rec(k+1);
			fix[i] = 0;
		}
}
int main ()
{
	int i=0;
	cin>>n;
	
	for(i=1; i<=n; i++){
		cin>>a[i];
	}
	for(i=1; i<=n; i++){
		cin>>b[i];
	}
	rec(0);
	cout<<abs(u-w);
}

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

typedef long long ll;

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

int main(){
	ll n,m;
	cin>>n>>m;

	ll a[n];

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

	//find lcm of the n numbers
	ll lcm = 1;

	for(int i =0;i<n;i++){
		lcm = lcm * a[i]/ gcd(lcm , a[i]);
		if(lcm > 2*m)
		{cout<<0;return 0;}
	}

	ll res = lcm /2;
	for(int i =0;i < n;i++)
		if(res % a[i] != a[i] / 2)
			{cout<<0;return 0;}

	ll cnt = m / lcm;
	if((m % lcm) >= lcm / 2) cnt++;
	cout<<cnt;
	return 0;
}
	

Measured memory_bytes: 1152
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

ll digSumSum(ll A, ll B) {
    ll sumA = 0, sumB = 0;
    while(A > 0) {
        sumA += A % 10;
        A /= 10;
    }
    while(B > 0) {
        sumB += B % 10;
        B /= 10;
    }
    return sumA + sumB;
}

int main() {
    ll N;
    cin >> N;
    ll res = INF;
    for(int i = 1; i < N; i++) {
        res = min(res, digSumSum(i, N - i));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << b + min(a + b + 1, c) << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int a, b;
    int s, d;
    while (cin >> a >> b)
    {
        if ((1 <= a && a <= 100) && (1 <= b && b <= 100))
        {
            s = a * b;
            d = (a + b) * 2;
            cout << s << " " << d << endl;
        }
    }
    return (0);
}

Measured memory_bytes: 3080
def getD(graph):
    # search edge
    origin=1
    d = 0
    queue = Queue()
    for it in graph[origin]:
        queue.enqueue((it, origin, d+1)) # next, coming from, depth

    while queue.size() > 0:
        leaf, origin, d = queue.dequeue()
        for it in graph[leaf]:
            if it != origin:
                queue.enqueue((it, leaf, d+1)) # next, coming from, depth
    # print(d, leaf)

    # search D
    origin=leaf
    d = 0
    queue = Queue()
    for it in graph[origin]:
        queue.enqueue((it, origin, d+1)) # next, coming from, depth

    while queue.size() > 0:
        leaf, origin, d = queue.dequeue()
        for it in graph[leaf]:
            if it != origin:
                queue.enqueue((it, leaf, d+1)) # next, coming from, depth
    # print(d, leaf)
    return d

class Node:
    def __init__(self, data):
        self.data = data
        self.next = None


class Queue:
    def __init__(self):
        self.head = None
        self.last = None
        self._size = 0

    def enqueue(self, data):
        if self.last is None:
            self.head = Node(data)
            self.last = self.head
        else:
            self.last.next = Node(data)
            self.last = self.last.next
            
        self._size += 1

    def dequeue(self):
        if self.head is None:
            return None
        else:
            to_return = self.head.data
            self.head = self.head.next
            self._size -= 1
            
            if self._size == 0:
                self.head = None
                self.last = None
            return to_return
        
    def size(self):
        return self._size
    
def inside(y,x,H,W):
    if 0<=y<H and 0<=x<W:
        return True
    else:
        return False
    
def addQueueIfPossible(new_y, new_x, new_val, data, queue):
    if inside(new_y, new_x, H, W) and data[new_y][new_x]==-1:
        data[new_y][new_x] = new_val
        queue.enqueue((new_y, new_x, new_val))
        return True
    else:
        return False


n = int(input())
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

if n==1:
    print('First')
else:
    d = getD(graph)

    if (d+2)%3==0:
        print('Second')
    else:
        print('First')

Measured memory_bytes: 140748
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] a = new int[M];
    int[] b = new int[M];
    boolean[] adj1 = new boolean[N + 1];
    boolean[] adj2 = new boolean[N + 1];
    boolean flag = false;
    for (int i = 0; i < M; i++){
      a[i] = scanner.nextInt();
      b[i] = scanner.nextInt();
    }
    for (int i = 0; i < M; i++){
      if (a[i] == 1){
        adj1[b[i]] = true;
      } else if (b[i] == N){
        adj2[a[i]] = true;
      }
    }
    for (int k = 0; k < N; k++){
      if (adj1[k] == true & adj2[k] == true){
        flag = true;
        if (flag = true){
          System.out.println("POSSIBLE");
          break;
        }
      } else if (k == N - 1 & flag == false){
        System.out.println("IMPOSSIBLE");
      }
    }
  }
}


Measured memory_bytes: 98764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N, K;
	cin >> N >> K;
	vector<lint>V(N);
	lint d, a;
	rep(i, K) {
		cin >> d;
		rep(j, d) {
			cin >> a;
			V[a - 1]++;
		}
	}
	lint cnt = 0;
	
	rep(i, N) {
		if (V[i] == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
 }

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(){
    int a,b,a1,b1,count1 = 0,count2 = 0;
    int array[1250] = {};
    int array2[1000] = {};
    cin >> a >> b;

    for(int i = 0;i <= 1250;i++){
        if((int)((double)i*0.08) == a){
            array[count1] = i;
            count1++;
        }
    }

    for(int i = 0;i <= 1000;i++){
        if((int)((double)i * 0.1) == b){
            array2[count2] = i;
            count2++;
        }
    }

    for(int i = 0;i < count1;i++){
        for(int j = 0;j < count2;j++){
            if(array[i] == array2[j]){
                cout << array[i] << endl;
                return 0;
            }
        }
    }
 
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = [_ for _ in input()]
t = [_ for _ in input()]
cnt=0
for i in range(len(s)):
  if s[i]!=t[i]:
    cnt+=1
print(cnt)

Measured memory_bytes: 12796
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  a,b=map(int,input().split())
  uf.union(a-1,b-1)
ans=0
for i in range(n):
  ans=max(ans,uf.size(i))
print(ans)

Measured memory_bytes: 14584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  
  bool ans =true;
  
  rep(i,n) {
  cin >> p[i];
    if(p[i]%2==0){
      if(p[i]%3!=0 && p[i]%5!=0) ans = false;
    }
  }
  
  cout << (ans==true?"APPROVED":"DENIED") <<endl;
  
}

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

#define ll long long

using namespace std;

int main(){

 int a,b,c,d;
 cin>>a>>b>>c>>d;
 if(a+b+c+d==21&&a*b*c*d==252) cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
 
 return 0;
}


Measured memory_bytes: 256
# AOJ 1503: Numbers
# Python3 2018.7.13 bal4u

import sys
n = int(input())
if n == 1: print(4, 2, sep='\n'); sys.exit(0)
ans = 1
for i in range(2, n+2): ans *= i
print(ans+2)
for i in range(2, n+2): print(i)


Measured memory_bytes: 5732
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> MAT;
#define h first
#define r second
#define rep(i,n) for(int i=0;i<n;i++)
int dp[1000][1000];
MAT info[200];
int n,m;

int dfs(int a,int b){
	if(~dp[a][b])return dp[a][b];
	
	int hoge = 0;
	rep(i,n){
		if(info[i].first < a && info[i].second < b){
			hoge = max(hoge, dfs(info[i].first,info[i].second)+1);
		}
	}
	return dp[a][b] = hoge;
}
int main(){
	while(cin >> n , n ){
		rep(i,1000)rep(j,1000)dp[i][j] = -1;
		
		int ret = 0;
		rep(i,n)cin >> info[i].h >> info[i].r;
		cin >> m;
		rep(i,m)cin >> info[n+i].h >> info[n+i].r;
		
		n = n + m;
		
		rep(i,n){
			ret = max(ret, dfs(info[i].first , info[i].second)+1);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [n, a, b] <- getIntList
  if even (b - a)
    then print $ (b - a) `div` 2
    else do
      let xl = (n - maximum [a, b])
      let xw = (minimum [a, b] - 1)
      if xl < xw
        then print $ xl + 1 + (abs (b - a) - 1) `div` 2
        else print $ xw + 1 + (abs (b - a) - 1) `div` 2


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

#pragma GCC optimization_level 3
#define _GLIBCXX_DEBUG

using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;



int main(){
	ll n;
	cin>>n;
	vector<string> s(n);
	map<string,ll> mp;

	for (size_t i = 0; i < n; i++)
	{
		cin>>s.at(i);
	}

	for (size_t i = 0; i < n; i++)
	{
		mp[s.at(i)]++;
		
	}
	
	ll mx = 0;

	for (auto p : mp)
	{
		mx = max(mx,p.second);
	}

	for (auto p : mp)
	{
		if (p.second != mx)
		{
			continue;
		}
		cout<<p.first<<endl;
		
	}
	
	
	
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
// vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
// int modInverse(int n){ 
// return p(n, MOD-2); 
// }  
// int nCrModPFermat(int n, int r){   
//     if(r == 0)  return 1; 
//     return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
// } 
signed main(){
    fast();
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 3648
N = int(input())
Blue = [input() for _ in range(N)]
M = int(input())
Red = [input() for _ in range(M)]
Word = Blue + Red
Word = list(set(Word))
ans = 0
for i in range(len(Word)):
    cnt = 0
    cnt += Blue.count(Word[i])
    cnt -= Red.count(Word[i])
    ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
int main() {
	// ios_base::sync_with_stdio(false);
 //  	cin.tie(NULL);
 	long double l;
 	while(scanf("%Lf", &l) != EOF) {
 		long double a, b, c;
 		a = b = c = l / 3;
 		printf("%.6Lf\n", a*b*c);
 	}
	return 0;
}

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

int main(){
	long long A, B;
	long long answer = 0;
	
	cin >> A >> B;
	
	long long x = (long long)(A * B);
	if(A < B){
		long long tmp = A;
		A = B;
		B = tmp;
	}
	long long r = A % B;
	while(r != 0){
		A = B;
		B = r;
		r = A % B;
	}
	answer = x / B;
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;


namespace Test1 {

    


    class ClassMain {

       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int jcnt=0, icnt=0;
                for (int i = 0; i < line.Length - 2; i++) {
                    if (line[i] == 'J') {
                        if (line[i + 1] == 'O' && line[i + 2] == 'I') {
                            jcnt++;
                        }
                    }
                    if (line[i] == 'I') {
                        if (line[i + 1] == 'O' && line[i + 2] == 'I') {
                            icnt++;
                        }
                    }
                }
                Console.WriteLine(jcnt);
                Console.WriteLine(icnt);
                //break;
            }
        }

        
    }



    
}

Measured memory_bytes: 5636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;
ll MAX=100100;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N),num(MAX);
    ll ans=0,ct=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        num[A[i]]++;
    }
    for(int i=0;i<MAX;i++){
        if(num[i]>=2 && num[i]%2==0)ct++;
        if(num[i]>=3){
            ans+=2*(ceil((float)num[i]/2)-1);
        }
    }
    //cout << ans << endl;
    //cout << ct << endl;
    ans+=2*(ceil((float)ct/2));
    cout << N-ans << endl;


    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

void dfs();
void visit(int);

int time,n,color[100],d[100],f[100],A[100][100];

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) A[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      A[u-1][v-1]=1;
    }
  }
  dfs();

  for(i=0;i<n;i++) printf("%d %d %d\n",i+1,d[i],f[i]);

  return 0;
}

void dfs(){
  int i;

  for(i=0;i<n;i++) color[i]=0;
  time=0;
  for(i=0;i<n;i++){
    if(color[i]==0) visit(i);
  }
}

void visit(int u){
  int i,j;
  
  color[u]=1;
  d[u]=++time;

  for(j=0;j<n;j++){
    if(A[u][j]==1&&color[j]==0) visit(j);
  }

  color[u]=2;
  f[u]=++time;
}

Measured memory_bytes: 636