akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>

using namespace std ;


int main( void )
{
	int N ,F ;
	scanf( "%d %d" ,&N ,&F ) ;	--F ;

	int M ;
	set< string > pair ;
	multiset< string > pair_data ;

	int i ,j ,k ;
	for( i = 0 ; i < N ; ++i )
	{
		vector< string > food ;

		scanf( "%d" ,&M ) ;
		for( j = 0 ; j < M ; ++j )
		{	string in ;	cin >> in ;	food.push_back( in ) ;	}
		
		sort( food.begin() ,food.end() ) ;

		for( j = 0 ; j < M ; ++j )
		{
			for( k = j + 1 ; k < M ; ++k )
			{
				string str1 ,str2 ;
				str1 = min( food[ j ] ,food[ k ] ) ;
				str2 = max( food[ j ] ,food[ k ] ) ;

				string union_str = str1 + ' ' + str2 ;

				pair.insert( union_str ) ;
				pair_data.insert( union_str ) ;
			}
		}
	}

	vector< string > output ;
	set< string >::iterator itr ;
	for( itr = pair.begin() ; itr != pair.end() ; ++itr )
	{
		if( pair_data.count( *itr ) > F )
		{	output.push_back( *itr ) ;	}
	}

	cout << output.size() << "\n" ;
	for( i = 0 ; i < output.size() ; ++i )
	{	cout << output[ i ] << "\n" ;	}

	return 0 ;
}


Measured memory_bytes: 4172
// https://atcoder.jp/contests/abc145/tasks/abc145_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        s: chars
    };
    let mut ok = n % 2 == 0;
    if n % 2 == 0 {
        let m = n / 2;
        for i in 0..m {
            if s[i] != s[m+i] {
                ok = false;
            }
        }
    }
    println!("{}", ifv!(ok, "Yes", "No"));
}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>
 
#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}
 
const int N=200005;
 
int w,h;
int val[N];
set<int> :: iterator it;
set<int> pos;
set<pii> st;
vector<int> to_er;
 
int main()
{
//    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
    
    scanf("%d %d",&h,&w);
    
    for(int i=1;i<=w;i++)
    {
        val[i]=1;
        pos.insert(i);
        st.insert(mp(val[i],i));
    }
    
    for(int j=0;j<h;j++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        
        int mn=1000000000;
        it=pos.lower_bound(a);
        
        to_er.clear();
        while(it!=pos.end() && *it<=b)
        {
            to_er.pb(*it);
            it++;
        }
        
        for(int i=0;i<to_er.size();i++)
        {
            int vv=val[to_er[i]];
            val[to_er[i]]=-1;
            if(b!=w)
                mn=min(vv+(b+1)-to_er[i],mn);
            st.erase(mp(vv,to_er[i]));
            pos.erase(to_er[i]);
        }
        
        if(mn!=1000000000)
        {
            if(val[b+1]==-1)
            {
                val[b+1]=mn;
                st.insert(mp(val[b+1],b+1));
                pos.insert(b+1);
            }
            else if(val[b+1]>mn)
            {
                st.erase(mp(val[b+1],b+1));
                val[b+1]=mn;
                st.insert(mp(val[b+1],b+1));
                pos.insert(b+1);
            }
        }
        
        if(st.size())
        {
            int res=(*st.begin()).f;
            printf("%d\n",res+j);
        }
        else
            printf("-1\n");
        
    }
    
    
}


Measured memory_bytes: 22716
#include <stdio.h>

typedef long long ll;

ll A[100005];
ll B[100005];

int main() {

	int N;

	scanf("%d",&N);

	int i;

	for (i = 0; i < N; i++) {
		scanf("%lld %lld",&A[i],&B[i]);
	}

	ll ans = 0ll;

	ll k;

	for (i = N - 1; i >= 0; i--) {
		if (A[i] % B[i] == 0ll) {
			k = A[i] / B[i];
		}
		else {
			k = (A[i] / B[i]) + 1ll;
		}
		ans += (k*B[i]) - A[i];
		if (i > 0) {
			A[i - 1] += ans;
		}
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
import io

d1 = {
    ' ': '101', "'": '000000', ',': '000011', '-': '10010001',
    '.': '010001', '?': '000001', 'A': '100101', 'B': '10011010',
    'C': '0101', 'D': '0001', 'E': '110', 'F': '01001', 'G': '10011011',
    'H': '010000', 'I': '0111', 'J': '10011000', 'K': '0110', 'L': '00100',
    'M': '10011001', 'N': '10011110', 'O': '00101', 'P': '111',
    'Q': '10011111', 'R': '1000', 'S': '00110', 'T': '00111',
    'U': '10011100', 'V': '10011101', 'W': '000010', 'X': '10010010',
    'Y': '10010011', 'Z': '10010000'
    }
d2 = {n: chr(n+ord('A')) for n in range(26)}
d2.update(zip(range(26, 32), " .,-'?"))

for line in stdin:
    stream = io.StringIO()
    stream.write(''.join(d1[c] for c in line.rstrip('\r\n')))
    stream.seek(0)
    c = stream.read(5)
    while c:
        print(d2[int(c.ljust(5, '0'), 2)], end='')
        c = stream.read(5)
    print()

Measured memory_bytes: 4588
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	int ans = INF;
	rep(i,max(x,y)*2+1){
		//abピザをi枚買う
		int t = c*i;
		int numa = x - i/2;
		int numb = y - i/2;
		if(numa > 0)t += a * numa;
		if(numb > 0)t += b * numb;
		ans = min(ans, t);
	}
	cout << ans << endl;

}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<int> a(n);
  for (long long i = 0; i < n; i++)
    cin >> a[i];
  vector<bool> seen(n + 1);
  int loc = 1;
  while (!seen[loc]) {
    if (k == 0) {
      cout << loc << '\n';
      return 0;
    }
    seen[loc] = true;
    loc = a[loc - 1];
    --k;
  }
  if (k == 0) {
    cout << loc << '\n';
    return 0;
  }
  fill(begin(seen), end(seen), false);
  vector<int> seq;
  while (!seen[loc]) {
    seq.push_back(loc);
    seen[loc] = true;
    loc = a[loc - 1];
  }
  int m = (int) seq.size();
  int ind = k % m;
  while (ind <= 0)
    ind += m;
  cout << seq[ind % m] << '\n';
  return 0;
}

Measured memory_bytes: 4696
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
int main() {
	int n,k;
	string s;
	while((cin>>s)&&s!="-") {
		cin>>n;
		while(n--) {
			cin>>k;s=s.erase(0,k)+s.substr(0,k);
			//s=s.substr(0,k)+s.substr(k,s.length()-1);
		}
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 3172
/*
問題文
英大文字のみからなる文字列 S があります。
また、整数 N が与えられます。

S の各文字を、アルファベット順で N 個後の文字に置き換えた文字列を出力してください。

ただしアルファベット順で Z の 1 個後の文字は A とみなします。

制約
0≤N≤26
1≤|S|≤10^4
S は英大文字のみからなる

*/

function Main(input) {

    var S = input.split('\n')
    var n = Number(S[0]);
    // 配列
    var item = [
        "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L","M", "N",
        "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
    ];

    // 変換前文字列を1文字ずつ格納する配列と、変換後文字列格納用変数の宣言
    var temp = S[1].split("");
    var ans = "";

    // 配列のインデックスを利用して、文字列を変換
    for (var i = 0; i < temp.length; i++) {
        var place = item.indexOf(temp[i]);

        if (place + n <= 25) {
            ans += item[place + n];
        } else {
            ans += item[place + n - 26];
        }
    }
    console.log(ans);
}
 
//*編集不可。標準入出力から一度に読み込み、Mainを呼び出す
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8220
W,H,x,y = map(int,input().split())

if ((W/2 == x) and (H/2 == y)) or ((W/2 == y) and (H/2 == x)):
    print(W*H/2,end="")
    print(" ",end="")
    print(1)
else:
    print(W*H/2,end="")
    print(" ",end="")
    print(0)

Measured memory_bytes: 3064
H, W = map(int, input().split())
A = [list(input().split()) for _ in range(H)]

s = []
for i in range(W + 2):
    s.append('#')

for i in range(H + 2):
    if (i == 0):
        print(''.join(s))
    elif (i > 0 and i < H + 1):
        print('#' + ''.join(A[i - 1]) + '#')
    elif (i == H + 1):
        print(''.join(s))


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int H,W,K;
char s[500][500];
int ans[500][500];

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

    cin >> H >> W >> K;

    int cnt = 0;

    for (int i = 0;i < H;i++){
        for (int j = 0;j < W;j++){
            cin >> s[i][j];
            ans[i][j] = -1;
            if(s[i][j] == '#'){
                cnt++;
                ans[i][j] = cnt;
            }
        }
    }

    for (int i = 0;i < H;i++){
        int now = -1;
        for (int j = 0;j < W;j++){
            if(ans[i][j] != -1) now = ans[i][j];
            ans[i][j] = now;
        }
        now = -1;
        for (int j = W-1;j >= 0;j--){
            if(ans[i][j] != -1) now = ans[i][j];
            ans[i][j] = now;
        }
    }

    for (int j = 0;j < W;j++){
        int now = -1;
        for (int i = 0;i < H;i++){
            if(ans[i][j] != -1) now = ans[i][j];
            ans[i][j] = now;
        }
        now = -1;
        for (int i = H-1;i >= 0;i--){
            if(ans[i][j] != -1) now = ans[i][j];
            ans[i][j] = now;
        }
    }

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

    return 0;

}

Measured memory_bytes: 1536
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(b/a>=c){
        cout<<c<<endl;
    }
    
    else if(b/a<c){
        cout<<b/a<<endl;
    }
    
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main() { 

    ll N, Q;
    string S;
    cin >> N >> S >> Q;
    S = S;
    //cout << S << endl;
    //26文字分Setを用意してアルファベットの現れる位置を管理する
    //初期化->番兵追加
    vector<set<ll > > D(26, set<ll >({-1, INF}));
    //setに追加
    for(ll i = 0; i < N; i++){
        D[S[i]-'a'].insert(i);
    }

    vector<ll > ans;
    for(ll i = 0; i < Q; i++){
        ll t; cin >> t;
        if(t == 1){
            ll idx;
            char to_ch;
            cin >> idx >> to_ch;
            idx--;
            //検索
            D[S[idx] - 'a'].erase(idx);
            D[to_ch - 'a'].insert(idx);
            S[idx] = to_ch;
            //cout << S << endl;
        }else{
            //cout << S << endl;
            ll s, e; cin >> s >> e;
            // if(s == e){
            //     ans.push_back(1);
            //     continue;
            // }
            ll cn = 0;
            --s;
            for(ll j = 0; j < 26; j++){
                if(D[j].empty()) continue;
                ll st = *D[j].lower_bound(s);
                ll et = *D[j].lower_bound(e);
                // ll st = *lower_bound(D[j].begin(), D[j].end(), s);
                // ll et = *lower_bound(D[j].begin(), D[j].end(), e);
                // ll et = *upper_bound(D[j].begin(), D[j].end(), e);
                if(et > st){
                    cn++;
                }
                //cout << st << " " << et << endl;
            }
            ans.push_back(cn);
            //cout << cn << endl;
        }
    }

    for(ll i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 24708
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define pii pair< int,int>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define mxn 2000010
#define sqr 320
ll arr[1000002],n,x;
int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
     ll i,n,a,b;
     cin>>n;
    for(i=0;i<n;i++) cin>>arr[i];
    ll l=2 , r=2 ; 
    for(i=n-1;i>=0;i--)
      {
        if(l/arr[i]==r/arr[i] && l%arr[i]!=0)
            {
              cout<<-1;
              return 0;
            }
            if(l%arr[i]!=0)
            l=l+(arr[i]-l%arr[i]);
            r=(r/arr[i]+1)*arr[i]-1;

      }
      cout<<l<<" "<<r;
     return 0;
    }

Measured memory_bytes: 1024
D, G = map(int, input().split())
G //= 100
A = [[] for i in range(D)]
S = 0
MP = 0
for i in range(D):
  p, c = map(int, input().split())
  L = [(i + 1) * j for j in range(p + 1)]
  L[p] += c//100
  A[i] = L[:]
  S += L[p]
  MP += p
L1 = [[0 for i in range(MP + 1)] for j in range(D)]
for i in range(D):
  for j in range(len(A[i])):
    for k in range(MP+1):
      if j + k <= MP:
        L1[i][j+k] = max(L1[i][j+k], L1[i-1][k] + A[i][j])
L2 = [max(L1[i][j] for i in range(D)) for j in range(MP+1)]
idx = 0
while L2[idx] < G:
  idx += 1
print(idx)

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

using namespace std;

int main() {
	cin.sync_with_stdio(false);

	int N;
	int T[100];
	int M;
	int P[100];
	int X[100];
	cin >> N;
	int t=0;
	for(int i = 0;i < N;i++) {
		cin >> T[i];
		t = t + T[i];
	}
	cin >> M;
	for (int i = 0;i < M;i++) {
		cin >> P[i] >> X[i];
	}
	for (int i = 0;i < M;i++) {
		cout << t-T[P[i]-1]+X[i] << endl;
	}
	return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> v(n);
  int i,j,k;
  for(i=0;i<n;i++) cin >> v[i];
  if(n<=2){
    cout << 0 << "\n";
    return 0;
  }
  int cnt = 0;
  sort(v.begin(),v.end());
  for(i=0;i<n-2;i++){
    for(j=i+1;j<n-1;j++){
      for(k=j+1;k<n;k++){
        if((v[i]!=v[j])&&(v[j]!=v[k])&&(v[i]+v[j]>v[k])){
          cnt++;
        }
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}                                                                                      

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int m1, d1, m2, d2;
    scan(m1, d1, m2, d2);

    if(m1!=m2){
        print(1);
    }else{
        print(0);
    }

    return 0;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
#print(N_lis)
no_sweet=N_lis==0
#print(no_sweet)
print(no_sweet.sum())

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >>a>>b;
  for(int i=1;i<=3;i++)
    if(i!=a && i!=b)
      cout << i << endl;

  return 0;
}


Measured memory_bytes: 888
/*
假设当前还剩x个Yes和y个No，把这个状态看做二维平面上的点(x, y)。目标是从(N, M)走到(0, 0)
考虑在该点处选择的策略： 
1、x > y时猜当前答案是Yes
2、x < y时猜当前答案是No
3、x = y时任意猜一个，正确的概率是1 / 2
如果真实答案是Yes走到(x - 1, y)，如果真实答案是No走到(x, y - 1)
假设初始时的点(N, M)满足N >= M
考虑一条路径。把路径走到y = x的直线上时作为断点、将路径分成若干个不在y = x的直线上的部分
假设走到的第一个y = x上的点是(i, i)，那么这一部分一定恰好猜对N - i次
对于剩下的，都是形如从(a, a)走到(b, b)的部分，每一部分都是恰好猜对b - a次
那么无论路径是什么，从(N, M)走到(0, 0)，不在y = x的直线上的点产生的贡献之和一定是N
所以只要考虑y = x的直线上的点产生的贡献，走到一个(i, i)会产生1 / 2的贡献，所以枚举每个(i, i)计算走到(i, i)的概率即可 
*/

#include <cstdio>
#include <algorithm>

using namespace std;
const int MOD(998244353);
const int Max_NM(1000050);
typedef long long int LL;

constexpr int Mult(int a, int b)
{
	return (a * 1LL) * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

void exgcd(const int &a, const int &b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(const int &a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

int N, M, Fac[Max_NM], Inv[Max_NM], Ans;

inline int C(const int &n, const int &m)
{
	return Mult(Fac[n], Mult(Inv[m], Inv[n - m]));
}

int main()
{
	scanf("%d%d", &N, &M);
	if (N < M)
		swap(N, M);
	Fac[0] = 1;
	for (int i = 1;i <= N + M;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[N + M] = inverse(Fac[N + M]);
	for (int i = N + M - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	for (int i = M;i >= 1;--i)
		Ans = Add(Ans, Mult(C((N - i) + (M - i), N - i), C(i + i, i)));
	printf("%d", Add(Mult(Ans, Mult(inverse(2), inverse(C(N + M, N)))), N));
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  
  int s,t,l,Ans;
  string S,T;
  cin >> S >> T;
  s = S.size();
  t = T.size();
  Ans = t;
  
  for(int i = 0; i <= s-t; i++){
    
    l = 0;
    for(int j = 0; j < t; j++){
      
      if(S[i+j] != T[j]) l++;
    }
    if(l < Ans) Ans = l;
  }
  cout << Ans << endl;
  
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s;
  int q;
  cin>>s>>q;
  bool x=false;
  string a="", b="";
  while(q--){
    int t;
    cin>>t;
    if(t==1){
      x=!x;
    }
    else{
      int f;
      char c;
      cin>>f>>c;
      if(f==1){
        if(!x){
          a+=c;
        }
        else{
          b+=c;
        }
      }
      else{
        if(!x){
          b+=c;
        }
        else{
          a+=c;
        }
      }
    }
  }
  reverse(ALL(a));
  string ans=a+s+b;
  if(x){
    reverse(ALL(ans));
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 1300
// ConsoleApplication1.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>

//064 B

using namespace std;
int main()
{
	int N;
	cin >> N;
	int a[1100];
	for (int i = 0; i < N; i++) cin >> a[i];

	sort(a, a + N, greater<int>());
	cout << a[0] - a[N-1] << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int *score;
	int s,i;
	while(scanf("%d", &s) != EOF && s != 0){
		int max=0, min=1000, sum=0, average;
		score = (int *)(malloc(sizeof(int) * s));
		for(i = 0; i < s; i++){
			scanf("%d", (score + i));
			sum = sum + score[i];
			if(score[i] < min){
				min = score[i];
			}
			if(score[i] > max){
				max = score[i];
			}
		}
		sum = sum - (min + max);
		average = sum / (s - 2);
		printf("%d\n", average);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
using namespace std;

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string t,s;
    cin>>s>>t;
    ll l=s.size();
    ll cnt=0;
    for(ll i=0;i<l;i++)
        if(s[i]!=t[i])
            cnt++;
        cout<<cnt<<endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll q;
  cin >> q;
  vector<ll> l(q),r(q);
  rep(i,q){
    cin >> l.at(i) >> r.at(i);
  }
  vector<bool> is(100001,false);
  vector<ll> ans(100001,0);
  for(int i=3;i<=100000;i+=2){
    ll cp=i,cp1=(i+1)/2;
    bool no=true;
    for(int k=2;k*k<=i;k++){
      if(cp%k==0){
        no=false;
      }
    }
    for(int k=2;k*k<=cp1;k++){
      if(cp1%k==0){
        no=false;
      }
    }
    if(no){
      ans.at(i)=ans.at(i-2)+1;
      is.at(i)=true;
    }else{
      ans.at(i)=ans.at(i-2);
    }
  }
  rep(i,q){
    int as=ans.at(r.at(i))-ans.at(l.at(i));
    if(is.at(l.at(i))){
      as++;
    }
    cout << as << endl;
  }
}

Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
int h,w,n;
int main()
{
	cin>>h>>w>>n;
	set<pair<int,int>> s;
	while(n--)
	{
		int x,y;
		cin>>x>>y;
		s.insert({x,y});
	}
	int st=0;
	for(auto it=s.begin();it!=s.end();)
		if(it->first-it->second<st)s.erase(it++);
		else if(it->first-it->second==st)st++,s.erase(it++);
		else it++;
	int ans=h;
	for(auto it=s.begin();it!=s.end();it++)ans=min(ans,max(it->first,it->second)-1);
	cout<<ans<<'\n';
}


Measured memory_bytes: 9728
#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(){
    ll n,a;
    cin>>n;
    ll ans=100;
    string s;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%2==1&&i%2==0)continue;
        if(n%i==0){
        s=to_string(max(i,n/i));
        a=s.size();
        ans=min(ans,a);
        }

    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 998244353;
const ll mod1 = 2e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
const int inf = 0x3f3f3f3f;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;
int t;

int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	map<string, int> mp;
	while (n--)
	{
		string s;
		cin >> s;
		mp[s]++;
	}
	printf("AC x %d\n", mp["AC"]);
	printf("WA x %d\n", mp["WA"]);
	printf("TLE x %d\n", mp["TLE"]);
	printf("RE x %d\n", mp["RE"]);
	return 0;
}

Measured memory_bytes: 3732
#include <cstdio>
using namespace std;
int k;
namespace jzp1 {
	inline void sol() {
		printf("%d\n", k);
		for (int i = 1; i <= k; ++i) {
			for (int j = 1, st = i; j <= k; ++j, st = st % k + 1)
				printf("%d ", st);
			puts("");
		}
	}
}
namespace jzp2 {
	int mp[1111];
	inline void sol() {
		int n = (k + 3) / 4 * 2;
		printf("%d\n", n);
		for (int i = 1; i <= k; ++i)	mp[i] = i;
		for (int i = k + 1; i <= n + n; ++i)	mp[i] = (i - n) % n + 1;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1, st = i, lst = i - 1; j <= n; ++j, lst = st, st = st % n + 1) {
				if (i & 1)	printf("%d ", mp[st]);
				else	printf("%d ", mp[lst + n]);
			}
			puts("");
		}
	}
}
int main() {
	scanf("%d", &k);
	if (k <= 500) jzp1::sol();
	else
		jzp2::sol();
	return 0;
}


Measured memory_bytes: 3196
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String w = br.readLine();
        int[] c = new int[26];

        for (int i=0; i<w.length(); i++) {
            c[w.charAt(i)-'a']++;
        }
        String ans = "Yes";
        for (int i=0; i<26; i++) {
            if(c[i]%2!=0){
                ans = "No";
                break;
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 21076
#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++)
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> primes;
    rep2(i, 2, 55555) {
        bool flag = true;
        rep(j, primes.size()) {
            if (i%primes[j] == 0) {
                flag = false;
                break;
            }
        }
        if (flag) primes.push_back(i);
    }
    vector<int> ans;
    rep(i, primes.size()) {
        if (primes[i]%5 == 1) ans.push_back(primes[i]);
    }
    rep(i, N) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

int main(){
	ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<ii> vs(n);
	for(auto &x:vs) 
		cin >> x.ff >> x.ss;
	sort(all(vs));
	ll d = 1;
	int i=0;
	multiset<ll> st;
	ll ans = 0;
	while(d<=m){
		while(i<n and vs[i].ff<=d)
			st.insert(vs[i].ss), ++i;
		++d;
		if(st.empty()) continue;
		auto it = prev(st.end());
		ans += *it;
		st.erase(it);
	}
	cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int>> a;
    for(int i = 1; i <= n; i++){
        string S;
        int P;
        cin >> S >> P;
        P = -P;
        a.push_back(tie(S, P, i));
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        cout << get<2>(a[i]) << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;



int main(){
	int a,b,c=0,sa=0,sb=0;
	while(scanf("%d,%d",&a,&b) != EOF){
		c++;
		sa += a*b;
		sb += b;
	}
	printf("%d\n%d\n",sa,(int)round( (double)(sb)/(double)(c)));
	
	return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  cout<<h*w-(h/a*a)*(w/b*b)<<endl;
  return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
const int maxn=5000+10;
string a[maxn*10];
char s[maxn];
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
int main(){
	scanf("%s",s+1);
	int k=read();
	int n=strlen(s+1);
	int tmp=0;
	REP(i,1,n){
		string str="";
		REP(j,0,min(k-1,n-i)){
			str+=s[i+j];
			a[++tmp]=str;
		}
	}
	sort(a+1,a+tmp+1);
	tmp=unique(a+1,a+tmp+1)-a-1;
	cout<<a[k]<<endl;
	return 0;
}


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

int main()
{
  ll n, m, d;
  cin >> n >> m >> d;
  double ans;
  cout << fixed << setprecision(10) << (d == 0 ? 1.0 * (m - 1) / n : 2.0 * (n - d) * (m - 1) / (n * n)) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		// 計算
		String result = "bust";
		if(a + b + c < 22) result = "win";
		
		// 出力
		System.out.println(result);
	}
}


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

int main()
{  
    long long int n,r,b;
    cin>>n>>b>>r;
    long long int block=n/(b+r);
    long long int rem=n%(b+r);
    cout<<(block*b)+min(rem,b);

    
    
    
    
    
    
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
module Input
	def numread()
		s = gets().split()
		p = Array.new()
		for i in 0...s.size()
			p[i] = s[i].to_i()
		end
		return p
	end
	
	module_function:numread
end

include Input

loop{
	if(STDIN.eof())
		break
	end
	w = numread()
	n = w[0] + w[1];
	print(n.to_s().size(),"\n")
}

Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fi first
#define se second
#define pb push_back
#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);

using namespace std;

template<typename T> void macro_scan(T& t){cin>>t;};
template<typename F, typename ...R>void macro_scan(F& f , R& ...r){
  cin>>f;macro_scan(r...);
}
void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<" ";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    read(long long , n , k);
    if(n < k){
        cout<<min(n , abs(n - k))<<"\n";
        return 0;
    }
    cout<<min(n%k , abs(n%k - k))<<"\n";
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int ans=0;
    int mx=0;
    for(int n=0; n<N; n++) {
        int p;
        cin >> p;
        ans += p;
        if(mx<p) {
            mx = p;
        }
    }
    
    cout << ans-mx/2 << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;

int main(){
 int a,b,c;
 cin >>a>>b>>c;
 int d=c/a;
 cout << b*d<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(int argc, char const *argv[]) {
  int a,b,c;
  cin >> a >> b >> c;
  for (size_t i = a; i <= b; i++) {
    if (i < a+c) {
      std::cout << i << '\n';
    }
    else if (i > b-c) {
      std::cout << i << '\n';
    }
  }
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

set<int> createTable(string a, string b) {
  set<int> S;
  for (int offset = -(int)b.size(); offset <= (int)a.size(); offset++) {
    bool valid = true;
    REP(i, a.size()) {
      int j = i - offset;
      if (0 <= i && i < (int)a.size() && 0 <= j && j < (int)b.size() &&
          a[i] != '?' && b[j] != '?' && a[i] != b[j]) {
            valid = false;
          }
    }
    if (valid) S.insert(offset);
  }
  return S;
}

ll solve(string a, string b, string c) {
  set<int> ab = createTable(a, b);
  set<int> ac = createTable(a, c);
  set<int> bc = createTable(b, c);

  int ans = a.size() + b.size() + c.size();
  for (int i : ab) {
    for (int j : ac) {

      int a0 = 0, a1 = 0 + a.size();
      int b0 = i, b1 = i + b.size();
      int c0 = j, c1 = j + c.size();
      int len = max({ a1, b1, c1 }) - min({ a0, b0, c0 });

      if (b1 <= c0 || c1 <= b0) {
        chmin(ans, len);
      } else if (bc.count(j-i) > 0) {
        chmin(ans, len);
      }
    }
  }

  return ans;
}
int main2() {
  string a, b, c;
  cin >> a >> b >> c;

  ll ans = 10000;
  chmin(ans, solve(a, b, c));
  chmin(ans, solve(a, c, b));
  chmin(ans, solve(b, a, c));
  chmin(ans, solve(b, c, a));
  chmin(ans, solve(c, a, b));
  chmin(ans, solve(c, b, a));

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

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<utility>
#include<cstring>
using namespace std;
typedef pair<int, int> PII;

int w, h, n;
int mas_x_s[1010], mas_y_s[1010];
int mas_x_e[1010], mas_y_e[1010];
vector<int> vmas_x, vmas_y;
bool plate[2010][2010];
int ans = 0;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

void bfs(PII start)
{
  queue<PII> qbfs;
  qbfs.push(start);
  
  while(!qbfs.empty()){
    PII now = qbfs.front();
    qbfs.pop();
    
    for(int i = 0; i < 4; i++){
      PII next = make_pair(now.first + dx[i], now.second + dy[i]);
      if(0 <= next.first && next.first < vmas_x.size() - 1 && 0 <= next.second && next.second < vmas_y.size() - 1 && !plate[next.first][next.second]){
	plate[next.first][next.second] = true;
	qbfs.push(next);
      }
    }
  }
  return;
}

int main()
{
  while(true){
    scanf("%d%d", &w, &h);
    if(!w && !h)
      break;

    ans = 0;
    memset(plate, false, sizeof plate);
    vmas_x.clear();
    vmas_y.clear();

    scanf("%d", &n);
    
    for(int i = 0; i < n; i++){
      scanf("%d%d%d%d", &mas_x_s[i], &mas_y_s[i], &mas_x_e[i], &mas_y_e[i]);
      vmas_x.push_back(mas_x_s[i]);
      vmas_x.push_back(mas_x_e[i]);
      vmas_y.push_back(mas_y_s[i]);
      vmas_y.push_back(mas_y_e[i]);
    }
    
    vmas_x.push_back(mas_x_s[n] = 0);
    vmas_x.push_back(mas_x_e[n] = w);
    vmas_y.push_back(mas_y_s[n] = 0);
    vmas_y.push_back(mas_y_e[n] = h);

    sort(vmas_x.begin(), vmas_x.end());
    sort(vmas_y.begin(), vmas_y.end());
    
    vmas_x.erase(unique(vmas_x.begin(), vmas_x.end()), vmas_x.end());
    vmas_y.erase(unique(vmas_y.begin(), vmas_y.end()), vmas_y.end());

    for(int i = 0; i <= n; i++){
      mas_x_s[i] = lower_bound(vmas_x.begin(), vmas_x.end(), mas_x_s[i]) - vmas_x.begin();
      mas_x_e[i] = lower_bound(vmas_x.begin(), vmas_x.end(), mas_x_e[i]) - vmas_x.begin();
      mas_y_s[i] = lower_bound(vmas_y.begin(), vmas_y.end(), mas_y_s[i]) - vmas_y.begin();
      mas_y_e[i] = lower_bound(vmas_y.begin(), vmas_y.end(), mas_y_e[i]) - vmas_y.begin();
    }
    
    for(int i = 0; i < n; i++)
      for(int j = mas_x_s[i]; j < mas_x_e[i]; j++)
	for(int k = mas_y_s[i]; k < mas_y_e[i]; k++){
	  plate[j][k] = true;
	}

    for(int i = 0; i < vmas_x.size() - 1; i++)
      for(int j = 0; j < vmas_y.size() - 1; j++)
	if(!plate[i][j]){
	  bfs(make_pair(i, j));
	  ans++;
	}

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

Measured memory_bytes: 5188
import math
n = int(input())
t,a = map(int,input().split())
mi = [t,a]
for i in range(1,n):
    t,a = map(int,input().split())
    ts = max((mi[0]-1)//t,(mi[1]-1)//a)+1
    mi = [t*ts,a*ts]

print(mi[0]+mi[1])


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int MAXV = 1e5+1;

ll best[MAXV];

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	ll N, W;
	read2(N, W);

	FOR(i, 1, MAXV)
		best[i] = W+1;

	FOR(i,0, N)
	{
		ll w, v;
		read2(w, v);

		for (int i(MAXV-1); i >= v; --i)
			best[i] = min(best[i], w + best[i-v]);
	}
	int ans = MAXV-1;
	while (best[ans] > W) ans--;
	pnl(ans);
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	string s;
	cin>>s;
	if(s[0]==s[1]==s[2]==s[3])cout<<"Yes"<<endl;
	else if(s[0]==s[1]&&s[1]==s[2])cout<<"Yes"<<endl;
	else if(s[1]==s[2]&&s[2]==s[3])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    ll X, Y;
    cin >> X >> Y;

    // ll ans = (Y - X) / X;
    ll ans = 0;
    // while (true)
    // {
    //     if (X * pow(2, ans) > Y)
    //     {
    //         break;
    //     }
    //     ans++;
    // }
    while (X <= Y)
    {
        ans++;
        X *= 2;
    }

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

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main()
{
    int prime[80000];
    int ptr=2;
    prime[0] = 2;
    prime[1] = 3;
    for(int num=5; num<1000000; num+=2){
        bool f = false;
        for(int i = 0; i<ptr; i++){
            if (prime[i]*prime[i] > num) break;
            if (num%prime[i]==0) {
                f = true;
                break;
            }
        }
        if(!f) prime[ptr++] = num;
    }
    prime[ptr]=1000001;
    int n;
    while(cin >> n){
        int k=0;
        for(;prime[k]<=n;k++);
        cout << k << endl;
    }
     
    return 0;
}


Measured memory_bytes: 3356
#include<stdio.h>
#include<math.h>
#define faulse 0
#define true 1
int isPrime(int x){
  int i;
  if(x == 2) return true;

  if(x < 2 || x % 2 == 0) return faulse;
  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0) return faulse;

    i += 2;
  }
  return true;
}
int main(){
  int i,n,N,a[10000];
  int count = 0;
  scanf("%d",&N);
  for(i = 0; i<N; i++) scanf("%d",&a[i]);
  for( i = 0;i < N; i++){
    if(isPrime(a[i]) == true) count++;
  }
  printf("%d\n",count);
}



Measured memory_bytes: 2096
import math
N = int( input())
temp = list(map(int,input().split(" ")))
ans = 10**20
odd =[v for i,v in enumerate(temp) if i % 2 == 1]
even =[v for i,v in enumerate(temp) if i % 2 == 0]
dicodd = {}
diceven = {}
for i in temp:
    if i not in dicodd:
        dicodd[i] = 0
    if i not in diceven:
        diceven[i] = 0
for o in odd:
    dicodd[o] += 1
for e in even:
    diceven[e] += 1


maxOdd = max(dicodd.items(),key= lambda x:x[1])
dicodd.pop(maxOdd[0])

max2Odd = (0,0)
if len(dicodd) != 0:
    max2Odd = max(dicodd.items(),key= lambda x:x[1])

maxEven = max(diceven.items(),key= lambda x:x[1])
diceven.pop(maxEven[0])

max2Even = (0,0)
if len(diceven) != 0:
    max2Even = max(diceven.items(),key= lambda x:x[1])

if maxOdd[0] != maxEven[0]:
    print(N - maxOdd[1] - maxEven[1])
else:
    ans1 = N - maxOdd[1] - max2Even[1]
    ans2 = N - max2Odd[1] - maxEven[1]
    print(min(ans1,ans2))





Measured memory_bytes: 25080
#include <iostream>
#include <vector>
using namespace std;
int const MAX = 100003;
bool not_prime[MAX + 1];

int main(){
  int x;
  cin >> x;
  
  vector<int> unko;
  for (int i = 2; i <= MAX; ++i) {
    if (!not_prime[i]) {
      unko.push_back(i);
      for (int j = 1; j <= MAX / i; ++j) not_prime[i * j] = true;
    }
  }
  cout << *lower_bound(unko.begin(), unko.end(), x);
  return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int x, y, ans;
	cin >> x >> y;
	ans = 0;
	if (x <= 3) ans += (4 - x) * 100000;
	if (y <= 3) ans += (4 - y) * 100000;
	if ((x == 1) && (y == 1)) ans += 400000;
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
N = int(input())  # 1行目のNを取得する
s = [input() for i in range(N)]



print('AC x ' + str(s.count("AC")))
print('WA x ' + str(s.count("WA")))
print('TLE x ' + str(s.count("TLE")))
print('RE x ' + str(s.count("RE")))


Measured memory_bytes: 16208
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

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

const long long INF = 1LL << 60;

int main()
{
	long long N;
	cin >> N;
	vector<long long> a(N);
	for (long long i = 0;i < N;i++) {
		cin >> a[i];
	}
	bool up = false;bool down = false;
	int cnt = 1;
	for (long long i = 1;i < N;i++) {
		if (a[i] > a[i - 1]) {
			up = true;
			if (down) {
				cnt++;
				up = false;
				down = false;
			}
		}
		else if (a[i] < a[i - 1]) {
			down = true;
			if (up) {
				cnt++;
				up = false;
				down = false;
			}
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 1024