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





int main() {
	ll N, K,an=99999999999;
	cin >> N >> K;
	vector<ll> x(N);
	rep(i, N) {
		cin >> x.at(i);
	}
	rep(i, N - K + 1) {
		an = Min(an, abs(x.at(i)) + abs(x.at(i) - x.at(i + K - 1)), abs(x.at(i + K - 1)) + abs(x.at(i) - x.at(i + K - 1)));
	}
	cout << an << endl;
	
}


Measured memory_bytes: 1024
def answer(n: int, p: []) -> int:
    p.append(p.pop(p.index(max(p))) // 2)
    return sum(p)


def main():
    n = int(input())
    p = list(int(input()) for _ in range(n))
    print(answer(n, p))


if __name__ == '__main__':
    main()

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> x,y;
  vector<int> X,Y;
  vector<pair<int,int>> G[100000];
  for(int i(0);i<N;i++){
    int xi,yi;
    cin>>xi>>yi;
    X.push_back(xi);
    Y.push_back(yi);
    x.push_back({xi,i});
    y.push_back({yi,i});
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  for(int i(0);i<N-1;i++){
    G[x[i].second].push_back({x[i+1].first - x[i].first, x[i+1].second});
    G[x[i+1].second].push_back({x[i+1].first - x[i].first, x[i].second});

    G[y[i].second].push_back({y[i+1].first - y[i].first, y[i+1].second});
    G[y[i+1].second].push_back({y[i+1].first - y[i].first, y[i].second});
  }

  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
  vector<int> used(N);
  q.push({0,0});
  //used[0] = 1;
  ll ans(0);
  while(!q.empty()){
    pair<int,int> now = q.top();q.pop();
    //cout << now.second << endl;
    int v = now.second;
    if(used[v] == 1) continue;
    used[v] = 1;
    ans += now.first;
    for(auto next:G[v]){
      int nv = next.second;
      if(used[nv] == 0){
        //cout << v << " " << nv << " " << min(abs(X[nv]-X[v]),abs(Y[nv]-Y[v])) << endl;
        q.push({min(abs(X[nv]-X[v]),abs(Y[nv]-Y[v])),nv});
        //ans += min(abs(X[nv]-X[v]),abs(Y[nv]-Y[v]));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15012
def dist(r, c):
    return min(r, H - r - 1, c, W - c - 1)

H, W, K = map(int, input().split())
A = [list(input()) for _ in range(H)]

for r in range(H):
    for c in range(W):
        if A[r][c] == 'S':
            sr = r
            sc = c

dxy = [(1, 0), (0, -1), (-1, 0), (0, 1)]
pos = [(sr, sc)]
dic = {(sr, sc): K}
cnt = 0
ans = H * W
i = 0
while i < len(pos):
    r0, c0 = pos[i]
    d0 = dist(r0, c0)
    ans = min(ans, (d0 + K - 1) // K + 1)
    m0 = dic[(r0, c0)]
    if 0 < m0:
        m = m0 - 1
        for (dx, dy) in dxy:
            r = r0 + dy
            c = c0 + dx
            d = dist(r, c)
            if 0 <= r < H and 0 <= c < W and A[r][c] != '#' and (r, c) not in dic:
                pos.append((r, c))
                dic[(r, c)] = m
    i += 1

print(ans)


Measured memory_bytes: 145172
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, h, w; 
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> h >> w;
 	int cnt = 0;
 	for(int i=1; i<=n; i++)
 		for(int j=1; j<=n; j++)
 			if(i+h-1<=n && j+w-1<=n) cnt++;
 	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#define max(a, b) (a) > (b) ? (a) : (b)
using namespace std;

int main() {
	int x[100], y[100];
    double p_1 = 0, p_2 = 0, p_3 = 0, p_00 = -1;
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> x[i];
	for (int i = 0; i < n; i++) cin >> y[i];
	for (int i = 0; i < n; i++) {
        int d = abs(x[i] - y[i]);
		p_1 += d;
		p_2 += d * d;
		p_3 += d * d * d;
		p_00 = max(p_00, d);
 	}
    cout << fixed << setprecision(6);
    cout << p_1 << endl;
    cout << sqrt(p_2) << endl;
    cout << cbrt(p_3) << endl;
    cout << p_00 << endl;
    return 0;
}


Measured memory_bytes: 3388
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int R = Integer.parseInt(sc.next());
		sc.close();

		if(N >= 10) {
			System.out.println(R);
		}else {
			System.out.println(R + 100 * (10 - N));
		}
	}
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	for(int i=k;i<n;++i){
		cout<<(a.at(i-k)<a.at(i)?"Yes"s:"No"s)<<"\n"s;
	}
}


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

int fib(int F[], int n) {
  if (n == 0) return 1;
  if (n == 1) return 1;
  if (F[n]) return F[n];
  F[n-1] = fib(F, n-1);
  F[n-2] = fib(F, n-2);
  return F[n-1] + F[n-2];
}

int main() {
  int n;
  cin >> n;
  int F[n+1];
  for (int i = 0; i <= n; i++) {
    F[i] = 0;
  }
  cout << fib(F, n) << endl;
  return 0;
}



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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 100005;

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    string s;
    cin >> s;

    int n = sz(s);

    int ans = 0;
    fo1(i, n/2) {
        if (s[i] != s[n-i-1])
            ans++;
    }

    cout << ans << endl;

    return 0;
%>

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	string S;
	cin >> S;
	int wins = 15 - SZ(S);
	for(char c: S)
		wins += c == 'o';
	cout << (wins >= 8 ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    A, B, C = map(int, input().split())
    K = int(input())

    M = 0
    while True:
        if A < B:
            break
        else:
            B *= 2
            M += 1
    while True:
        if B < C:
            break
        else:
            C *= 2
            M += 1

    if M <= K:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    int n;
	cin >> n;
    vector<int> A(n+1);
    A[0] = 0;
    A[1] = 0;
    FOR(i, 2, n+1) cin >> A[i];
    vector<int> v(n+1, 0);

    FOR(i, 2, n+1){
        v[A[i]]++;
    }
    FOR(i, 1, n+1) cout << v[i] << endl;
}


Measured memory_bytes: 4844
def factorization(n):
    factors = []
    i = 2
    cnt = 0
    while i ** 2 <= n:
        while n % i == 0:
            n //= i
            cnt += 1
        if cnt > 0:
            factors.append((i, cnt))
        i += 1
        cnt = 0
    if n > 1:
        factors.append((n, 1))
    return factors


n = int(input())
print(sum([int((-1 + (1 + 8 * v[1]) ** 0.5) / 2) for v in factorization(n)]))

Measured memory_bytes: 9380
<?php
$N = fgets(STDIN);
$n = $N % 10;

$array1 = [2, 4, 5, 7, 9];
$array2 = [0, 1, 6, 8];
if($n == 3) {
  	echo "bon";
} elseif(in_array($n, $array2)) {
	echo "pon";
} elseif(in_array($n, $array1)) {
  	echo "hon";
}

  
?>

Measured memory_bytes: 16164
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; ++i) {
    if(i % 3 && i % 5) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	colors := []int{a, b, c}
	var ans []int

	for _, color := range colors {
		if !include(ans, color) {
			ans = append(ans, color)
		}
	}

	fmt.Println(len(ans))
}

func include(arr []int, c int) bool {
	for _, a := range arr {
		if a == c {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1562>
問題文============================================================
 12以下の自然数 N が与えられるので、約数の個数がちょうど N 個であるような最小の自然数を求めよ。
=================================================================

解説=============================================================
貪欲
================================================================
*/

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    for(int i = 1; i < 10000;i++){
        ll cnt = 0;
        for(int j = 1; j <= i;j++){
            if(i%j == 0) cnt++;
        }
        if(cnt == N){
            cout << i << endl;
            break;
        }
    }
	return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
input = gets.chomp

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

flag = true
for i in 0..input.length - 1
    if i % 2 == 0
        if not odd.include?(input[i])
            flag = false
            break
        end
    else
        if not even.include?(input[i])
            flag = false
            break
        end
    end
end


if flag
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
import java.io.IOException;
import java.lang.Integer;
import java.lang.System;
        import java.util.Scanner;

public class Main{
    // インキ滴 小
    final static int size1[][] = {
            {0, 0, 0, 0, 0},
            {0, 0, 1, 0, 0},
            {0, 1, 1, 1, 0},
            {0, 0, 1, 0, 0},
            {0, 0, 0, 0, 0}
    };
    // インキ滴 中
    final static int size2[][] = {
            {0, 0, 0, 0, 0},
            {0, 1, 1, 1, 0},
            {0, 1, 1, 1, 0},
            {0, 1, 1, 1, 0},
            {0, 0, 0, 0, 0}
    };
    // インキ滴 大
    final static int size3[][] = {
            {0, 0, 1, 0, 0},
            {0, 1, 1, 1, 0},
            {1, 1, 1, 1, 1},
            {0, 1, 1, 1, 0},
            {0, 0, 1, 0, 0}
    };

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);

        int field[][] = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                field[i][j] = 0;
            }
        }

        while(s.hasNext()) {
            String str = s.nextLine();
            String[] strNum = str.split(",");
            int x = Integer.parseInt(strNum[0]);
            int y = Integer.parseInt(strNum[1]);
            int size = Integer.parseInt(strNum[2]);

            if(size == 1) {
                field = putInk(field, x, y, size1);
            } else if(size == 2) {
                field = putInk(field, x, y, size2);
            } else if(size == 3) {
                field = putInk(field, x, y, size3);
            }
        }

        // 色のついてないマス目の数
        int count = 0;
        int maxInkPoint = -1;
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                if (field[i][j] == 0) count++;
                if (maxInkPoint <= field[i][j]) {
                    maxInkPoint = field[i][j];
                }
            }
        }
        System.out.println(count);
        System.out.println(maxInkPoint);
    }

    // インクをフィールドに落とす
    private static int[][] putInk(int[][] field, int x, int y, int size[][]) {
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if ((x + i) >= 0 && (x + i) <= 9 && (y + j) >= 0 && (y + j) <= 9) {
                    field[x + i][y + j] += size[i + 2][j + 2];
                }
            }
        }
        return field;
    }
}

Measured memory_bytes: 17188
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int N;
int p[100], t[100];
int memo[100][3];
int maxdepth;
int dfs(int depth, int bal){
  maxdepth = max(maxdepth, depth);
  if(depth == N + 1) return 0;
  if(memo[depth][bal] != -1) return memo[depth][bal];
  int res = INF;
  if(bal <= 2 && t[depth] + abs(p[depth+1]-p[depth]) * (bal + 1) <= t[depth+1]){
    res = min(res, dfs(depth + 1, bal + 1) + abs(p[depth+1]-p[depth]));
  }
  if(t[depth] + abs(0-p[depth]) * (bal + 1) + p[depth+1] <= t[depth+1]){
    res = min(res, dfs(depth + 1, 1) + p[depth+1] + p[depth]);
  }
  return memo[depth][bal] = res;
}
int main(){
  while(cin>>N && N){
    REP(i, N) cin>>p[i+1]>>t[i+1];
    p[0] = 0; t[0] = 0;
    p[N+1] = 0; t[N+1] = INF;
    maxdepth = 0;
    memset(memo, -1, sizeof(memo));
    int ans = dfs(0, 0);
    if(maxdepth == N + 1) printf("OK %d\n", ans);
    else printf("NG %d\n", maxdepth + 1);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

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

  /* DP でやってみる */
  vector<vector<int>> dp(N.size(), vector<int>(2));
  // dp[i][0] ... 繰り上がりなし。
  // dp[i][1] ... 繰り上がりあり。
  dp[N.size()-1][0] = N[N.size()-1] - '0';
  dp[N.size()-1][1] = 10 - (N[N.size()-1] - '0');

  for(ll i=N.size()-2; i>=0; i--) {
    int num = N[i] - '0';

    if(num==0) {
      dp[i][0] = min(dp[i+1][0], dp[i+1][1] + 1);
      dp[i][1] = min(dp[i+1][0]+1000000, dp[i+1][1] + 9);
    } else if(num==9) {
      dp[i][0] = min(dp[i+1][0] + num, dp[i+1][1] + 1000000);
      dp[i][1] = min(dp[i+1][0] + 10-num, dp[i+1][1] + 0);
    } else {
      dp[i][0] = min(dp[i+1][0] + num, dp[i+1][1] + (num+1));
      dp[i][1] = min(dp[i+1][0] + 10-num, dp[i+1][1] + (10-num-1));
    }

  }


  int ans = min(dp[0][0], dp[0][1]+1);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 55940
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt();
		int[] x=new int[n];
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
		}
		long sum=0;
		for(int i=0;i<n-1;i++){
			long t=x[i+1]-x[i];
			if(t*a<=b)
				sum+=t*a;
			else
				sum+=b;
		}
		System.out.print(sum);
	}
}


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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
inline ll ri() {
	ll r; cin >> r; return r;
}


int main()
{
	ll x;
	cin >> x;
	vector<ll> fc(201);
	for(ll i = 0; i <= 200; i++) {
		fc[i] = i * i * i * i * i;
	}
	for(ll i = 0; i <= 200; i++) {
		for(ll j = 0; j <= 200; j++) {

			if(fc[i] + fc[j] == x) {
				cout << i << " " << -j << endl;
				return 0;
			}
		}
	}

	for(int i = 0; i <=200; i++) {
		for(int j = i + 1; j <= 200; j++) {
			if(fc[j] - fc[i] == x) {
				cout << j << " " << i << endl;
				return 0;
			}
		}
	}
	exit(1);
}

Measured memory_bytes: 3636
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo

int odd_divisor_count(int n) {
	static const vector<int> p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
	int c = 1;

	for (int i = 0; n != 1 && p[i] * p[i] <= n; i++) {
		int k = 1;
		while (!(n % p[i])) {
			k++;
			n /= p[i];
		}
		if (p[i] != 2)
			c *= k;
	}
	if (n > 2)
		c *= 2;

	return c - 1;
}

int main() {
	for (int n; (n = in());)
		out(odd_divisor_count(n), '\n');
}


Measured memory_bytes: 2404
<?php
	$data = explode(" ", trim(fgets(STDIN)));
	$ans = 0;
	$ans += $data[1];
	$ans += (floor($data[0]/2) + floor($data[3]/2) + floor($data[4]/2)) * 2;
	$a = $data[0] % 2;
	$b = $data[3] % 2;
	$c = $data[4] % 2;
	$k = $a + $b + $c;
	if($k == 3) $ans += 3;
	else{
	    if($a + $b == 2 && $data[4] > 1) $ans++;
	    if($b + $c == 2 && $data[0] > 1) $ans++;
	    if($c + $a == 2 && $data[3] > 1) $ans++;
	}
	echo $ans;
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	while(1){
	int H, W;
	cin>>H>>W;
	if(H == 0 && W == 0) break;

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

	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N;
string S;


signed main(){
    cin >> N;
    cin >> S;

    int ans = 0;
    repe(i, 0, N-3) if(S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C') ans++;

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
	string tmp;
	vector<char> ret;
	cin>>tmp;
	for(int i=0;i<tmp.size();i++){
		if(tmp[i]=='0'){
			ret.push_back('0');
		}else if(tmp[i]=='1'){
			ret.push_back('1');
		}else if(tmp[i]=='B' && ret.size()>0){
			ret.pop_back();
		}
	}
	for(int i=0;i<ret.size();i++){
		cout<<ret[i];
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#abc075 c
n,m=map(int,input().split())
graph=[[0]*n for _ in range(n)]
visited=[0]*n
hen=[]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    hen.append([a,b])
    graph[a][b]=graph[b][a]=1

def dfs(x):
    if visited[x]==1:
        return 0
    visited[x]=1
    for i in range(n):
        if graph[x][i]:#xとiがつながっているとき
            dfs(i)#graph[x][i]は0か1で頂点ではない


ans=0
for i in range(m):
    a,b=hen[i]
    graph[a][b]=graph[b][a]=0#ab間の辺を消す
    visited=[0]*n#visitedを初期化
    dfs(0)
    bridge=False
    for j in range(n):
        if visited[j]==0:#訪れてない場所があるとき渡れない場所（複数頂点含む）
            bridge=True#端ができている
    if bridge:
        ans+=1
    graph[a][b]=graph[b][a]=1#ab間の辺を戻す

print(ans)

Measured memory_bytes: 3064
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]


def dfs(i, sum, count, nokori):
    global ans
    if i == D:
        if sum < G:
            use = max(nokori)
            n = min(pc[use-1][0], -(-(G-sum)//(use*100)))
            count += n
            sum += n * use * 100
        if sum >= G:
            ans = min(ans, count)

    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], nokori-{i+1})


ans = float('inf')

dfs(0, 0, 0, set(range(1, D+1)))
print(ans)

Measured memory_bytes: 3064
#include <iostream>

int main() {
  uint64_t A, B;
  std::cin >> A >> B;
  
  if (A > B) std::swap(A, B);
  
  uint64_t n = B;
  for (uint64_t i = 0; i < A; ++i) {
    if (n % A == 0) break;
    n += B;
  }

  std::cout << n;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

__attribute__((target("avx"))) int main() {
    int n;
    int a[200000], b[200000];

    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);
    }

    int ans = 0;

    int m = n / 6 * 6;

    for (int i = 0; i < m; i += 6) {
        const int a0 = a[i];
        const int a1 = a[i + 1];
        const int a2 = a[i + 2];
        const int a3 = a[i + 3];
        const int a4 = a[i + 4];
        const int a5 = a[i + 5];

        for (int j = 0; j < n; j++) {
            ans ^= a0 + b[j];
            ans ^= a1 + b[j];
            ans ^= a2 + b[j];
            ans ^= a3 + b[j];
            ans ^= a4 + b[j];
            ans ^= a5 + b[j];
        }
    }

    for (int i = m; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans ^= a[i] + b[j];
        }
    }

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


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll a, b, c, k; cin >> a >> b >> c >> k;

    ll ans = 0;
    rep(i, k){
        if(a>0){
            ans += 1;
            a--;
        }
        else if(b>0){
            ans += 0;
            b--;
        }
        else if(c>0){
            ans += -1;
            c--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())

    pay = (N + 1000 - 1) // 1000 * 1000
    ans = pay - N
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
#include<stdio.h>

int A[1000000], n;


int binarySearch(int key){
	int left=0;
	int right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(key==A[mid]) return 1;
		if(key>A[mid]) left=mid+1;
		else if(key<A[mid]) right=mid;
	}
	return 0;
}

int main(){
	int i, q, k, sum=0;
	
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for(i=0; i<q; i++){
		scanf("%d",&k);
		if(binarySearch(k)) sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 980
n = int(input())
a = list(map(int, input().split()))

ascore = bscore = 0
for i in range(1, n+1):
    if i % 2 == 1:
        ascore += max(a)
    else:
        bscore += max(a)
    a.remove(max(a))
print(ascore - bscore)


Measured memory_bytes: 2940
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


ll s1(ll h, ll w) {
    if (h % 3 == 0) return 0;
    return w;
}

ll s2(ll h, ll w) {
    ll t = linf;
    for (ll x = 1; x < w; ++x) {
        ll t1 = x * (h / 2);
        ll t2 = x * (h - h / 2);
        ll t3 = (w - x) * h;
        t = min(t, max(t1, max(t2, t3)) - min(t1, min(t2, t3)));
    }
    return t;
}


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    array<ll, 4> A = {
        s1(H, W), s1(W, H), s2(H, W), s2(W, H)
    };
    sort(all(A));
    cout << A[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
int H,W,count=0;
char **map;
bool **isCount;

bool valid(int x,int y)
{
    return x<=(W-1)&&x>=0&&y<=(H-1)&&y>=0;
}

void bfs(int x,int y)
{
    if(valid(x,y)&&map[y][x]!='#' && !isCount[y][x])
    {
        count++;
        isCount[y][x]=true;
        for(int i=0;i<4;i++)
            bfs(x+dx[i],y+dy[i]);
    }
  /*int D[100];
  for(int i=0;i<100;i++)
    D[i]=-1;
  queue<int>Q;
  Q.push(src);
  D[src]=0;
  while(!Q.empty())
    {
      int cur=Q.front();
      Q.pop();
       for(int dst=0;dst<n;dst++)
	{
	  if(M[cur][dst]==1&&D[dst]==-1)
	    {
	      D[dst]=D[cur]+1;
	      Q.push(dst);
	    }
    }
    }
    for(int i=0;i<n;i++)
        cout<<i+1<<' '<<D[i]<<endl;
        */
}



int main()
{
    int x,y;
    cin>>W>>H;
    while(W!=0&&H!=0)
    {
        isCount=new bool*[H];
        map=new char*[H];
        for(int i=0;i<H;i++)
        {
            isCount[i]=new bool[W];
            map[i]=new char[W];
        }
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<W;j++)
                isCount[i][j]=false;
        }
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<W;j++)
            {
                cin>>map[i][j];
                if(map[i][j]=='@')
                {
                    x=j;
                    y=i;
                }
            }
        }
        bfs(x,y);
        cout << count << endl;
        delete map;
        delete isCount;
        cin>>W>>H;
        count=0;
    }
    return 0;
}

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

using namespace std;
int main() {
	string a,b,c;
	cin >> a >>b>>c;
	if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int coins[4] ={10, 50, 100, 500};

int main() {
	bool isfirst = true;
	while(1){
		int m; cin >> m;
		if(!m) break;

		if(isfirst) isfirst = false;
		else cout << endl;

		int c[4], r[4];
		int sum = 0;
		for(int i=0; i<4; i++) {
			cin >> c[i];
			sum += coins[i] * c[i];
			r[i] = 0;
		}

		sum -= m;
		for(int i=3; i>=0; i--) {
			while(sum >= coins[i]) { 
				sum -= coins[i]; r[i]++; 
			}
		}

		for(int i=0; i<4; i++) {
			int x = c[i] - r[i];
			if(x > 0) cout << coins[i] << " " << x << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
object Main extends App {
  val n = io.StdIn.readLine()
  val line = io.StdIn.readLine().split(" ").map(_.toInt)

  var flag = true
  for(o <- line){
    if(o % 2 == 0 && o%3 != 0 && o %5 != 0) flag = false
  }

  if(flag) println(s"APPROVED")
  else println(s"DENIED")
}


Measured memory_bytes: 25488
/* Author: Akkapaka Saikiran (@saikidon911) */
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using vi = vector<int>; using vll = vector<long long>; 
using vvi = vector<vector<int> >; using vb = vector<bool>;
#define pb push_back
#define all(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
//////////////////////////////////////////
#define test(t) int t; cin>>t; while(t--)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
////////////////////////////////////////////
#define tki take_input 
#define tkii take_input<int>
template <typename T> void take_input(vector<T> &a,int sz){
	T t;rep(i,sz){cin>>t;a.pb(t);}}
#define prv print_vector
#define prvi print_vector<int> 
template <typename T> void print_vector(vector<T> v){
	rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;}
/////////////////////////////////////////

int main(){
	fastio;

	int x; cin>>x;

	cout<<10-x/200<<endl;
	
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	swap(a,b),swap(a,c);
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)

    if 0 in A:
        print(0)
        exit()

    ans = A[0]
    for i in range(1, N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            exit()


    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21568
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int P = sc.nextInt();

        int sumP = 3 * A + P;
        int api = sumP / 2;
        System.out.println(api);
    }
}

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

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector<pair<int,pair<double,double>>> p;
    vector<double> rad;
    int xs, ys, xf, yf, n;
    cin >> xs >> ys >> xf >> yf >> n;
    p.push_back({0, {xs, ys}});
    p.push_back({n+1, {xf, yf}});
    rad.push_back(0);
    rad.push_back(0);
    for (int q = 1; q <= n; q++) {
        int x, y, r;
        cin >> x >> y >> r;
        p.push_back({q, {x, y}});
        rad.push_back(r);
        int number_of_chunks = 10;
        double degrees = 0;
        double radius = r;

        for (int i = 0; i < number_of_chunks; i++)
        {
            degrees = i * (360 / number_of_chunks);
            float radian = (degrees * (M_PI / 180));
            double xi = radius * cos(radian);
            double yi = radius * sin(radian);

            p.push_back({q, {xi, yi}});
            rad.push_back(0);
        }
    }
    int maxn = rad.size();
    double dist[maxn];
    for (int i = 0; i < maxn; i++) {
        dist[i] = 1e18;
    }
    dist[0] = 0;
    priority_queue<pair<double, int>> pq;
    pq.emplace(make_pair(0, 0));
    while (!pq.empty()) {
        pair<double, int> node = pq.top();
        pq.pop();
        double d = -node.first;
        int i = node.second;
        //cout << "node: " << i << " dist= " << d << '\n';
        if (d > dist[i]) continue;
        for (int j = 0; j <= rad.size(); j++) {
            double c = sqrt((p[i].second.first-p[j].second.first)*(p[i].second.first-p[j].second.first)
                            + (p[i].second.second-p[j].second.second)*(p[i].second.second-p[j].second.second));
            c -= rad[i] + rad[j];
            c = max(c, (double)0);
            //cout << " attempt edge " << j << " with cost " << c << '\n';
            if (d+c > dist[j]) continue;

            if (d+c < dist[j]) {
                dist[j] = d+c;
                pq.emplace(make_pair(-dist[j], j));
            }
        }
    }
    cout << fixed << setprecision(9) << dist[1] << '\n';
}

Measured memory_bytes: 135192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, long P)
        {
            var factors = new Dictionary<long, int>();
            for (long i = 2; i * i <= P; ++i)
            {
                int n = 0;
                while (P % i == 0)
                {
                    P /= i;
                    ++n;
                }
                if (n > 0) { factors[i] = n; }
            }
            if (P > 1) { factors[P] = 1; }
            long ans = 1;
            foreach (var pair in factors)
            {
                int n = pair.Value / N;
                for (int i = 0; i < n; ++i) { ans *= pair.Key; }
            }
            return ans;
        }

        static void Main(string[] args)
        {
            var V = ReadLongs();
            Console.WriteLine(Solve((int)V[0], V[1]));
        }
    }
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
int arr[100005],mx[100005];
main()
{
	int t,p;
    scanf("%d%d",&t,&p);
    for(int i = 1;i <= t;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(int i = t;i >= 1;i--)
    {
        mx[i]=arr[i];
        if(i!=t)
        mx[i]=max(mx[i+1],mx[i]);
    }
    int ck1=-1e9,ck2=0;
    for(int i = 1;i < t;i++)
    {
        if(mx[i+1]-arr[i]>ck1)
        {
            ck1=arr[i]-mx[i+1];
            ck1=-ck1;
            ck2=1;
            //printf("%d %d %d\n",i,arr[i],mx[i]);
        }
        else if(mx[i+1]-arr[i]==ck1)
        {
            ck2++;
        }
    }
    printf("%d",ck2);
}


Measured memory_bytes: 1024
from collections import Counter

N = int(input())
S = sorted(Counter([input() for _ in range(N)]).items(), key=lambda x: x[0])
S = sorted(S, key=lambda x: x[1], reverse=1)
cnt_max = S[0][1]
# print(cnt_max)
for i, v in S:
    if v == cnt_max:
        print(i)


Measured memory_bytes: 45004
m=input()
A=[map(int,raw_input().split()) for _ in [0]*input()]
X=[]
while A:
  a1,a2=map(set,zip(*A))
  for e in A:
    if e[1] in a2-a1:
      if e[1] not in X: X.append(e[1])
      A.remove(e)

for e in list(set(range(1,m+1))-set(X))+X[::-1]: print e

Measured memory_bytes: 4224
def dfs(x,cnt):
    global ans
    if cnt != n:
        for i in range(x[-1],m+1):
            dfs(x+[i],cnt+1)
    else:
        cnt = 0
        for a,b,c,d in lis:
            if x[a-1] + c == x[b-1]:
                cnt += d
        ans = max(ans,cnt)
n,m,q = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(q)]
ans = 0
dfs([1],0)
print(ans)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,blue,red,tot;
	cin>>n>>blue>>red;
	tot=blue+red;
	ll div = n/tot;
	ll rem = n%tot;
	rem = min(rem, blue);
	cout<<div*blue+rem<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <cstdlib>
#include <cstdio>

using namespace std;

struct edge{
	int start, target, weight;
};

const int INF = 2147473000;


int main(){
	int init_buf;
	cin >> init_buf;
	const int num_of_node = init_buf;
	cin >> init_buf;
	const int num_of_edge = init_buf;
	cin >> init_buf;
	const int start_point = init_buf;

	edge *edges = new edge[num_of_edge];
	int *res = new int[num_of_node];

	for(int i = 0; i < num_of_node; i ++)
		res[i] = INF;
	for(int i = 0; i < num_of_edge; i ++)
		cin >> edges[i].start >> edges[i].target >> edges[i].weight;

	res[start_point] = 0;
	while(true){
		bool update = false;

		for(int i = 0; i < num_of_edge; i ++){
			edge e = edges[i];
			if(res[e.start] == INF) continue;	
			int test = res[e.start] + e.weight; 
			if(test < res[e.target]){
				res[e.target] = test;
				update = true;
			}
		}
		if(!update)break;
	}

	for(int i = 0; i < num_of_node; i ++){
		if(res[i] != INF) cout << res[i];
		else cout << "INF";
		cout << endl;
	}

	delete [] edges;
	delete [] res;
}

Measured memory_bytes: 7204
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A_lst = list(map(int,input().split()))
S = Counter(A_lst)
sums = 0
#for i in S.keys():
#    if S[i] > 1:
#        sums += combinations_count(S[i], 2)

for c, i in S.items():
    sums += i*(i-1)//2

for j in range(1, N + 1):
    if S[A_lst[j-1]] == 2:
        print(sums - 1)
    elif S[A_lst[j-1]] > 2:
        print(int(sums - S[A_lst[j-1]] * (S[A_lst[j-1]]-1) * 0.5 + (S[A_lst[j-1]] - 1) * (S[A_lst[j-1]] - 2) * 0.5))
    else:
        print(sums)

Measured memory_bytes: 110200
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define endl "\n"
#define ing long long
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

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

    while(true){
        vector<pair<int,pair<int,int>>> c;
        vector<int> ans;
        int n, w, d, h;
        int p, s, num = 0;

        cin>>n>>w>>d;

        if(!n && !w && !d) break;

        c.push_back(make_pair(-1,make_pair(w,d)));

        for(int i = 0; i < n; i++){
            sort(c.begin(), c.end());
            pair<int,int> p1, p2;
            cin>>p>>s;
            
            p--;
            w = c[p].second.first;
            h = c[p].second.second;


            //   if(h == 0 || w == 0) cout<<"9804375043 "<<endl;
            //else
                s %= (h*2+w*2);

            num = s;
            
            if(s <= w){
                p1 = make_pair(num, h);
                p2 = make_pair(w-num,h);
            } else if(w <= s && s <= w+h){
                num -= w;
                // p1 = make_pair(num, h);
                //p2 = make_pair(w-num,h);
                
                p1 = make_pair(w, num);
                p2 = make_pair(w,h-num);
            } else if( w+h <= s && s <= w*2+h){
                num -= w+h;
                // p1 = make_pair(w, num);
                // p2 = make_pair(w,h-num);
                p1 = make_pair(num, h);
                p2 = make_pair(w-num,h);
                
            } else {
                num -= w*2+h;
                p1 = make_pair(w, num);
                p2 = make_pair(w,h-num);
                }
             if(p1.first*p1.second > p2.first*p2.second) swap(p1,p2);

             c.erase(c.begin()+p);
            c.push_back(make_pair(i,p1));
            c.push_back(make_pair(i,make_pair(p2.first,p2.second)));
        }

        for(int i = 0; i < c.size(); i++){
            ans.push_back(c[i].second.first*c[i].second.second);
            //cout<<c[i].first<<" "<<c[i].second<<endl;
        }
        
        sort(ans.begin(), ans.end());
        for(int i = 0; i < ans.size(); i++){
            if(i) cout<<" ";
            cout<<ans[i];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 80005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int num[10];
void Solve() {
	for(int i = 1 ; i <= 4 ; ++i) read(num[i]);
	sort(num + 1,num + 5);
	if(num[1] == 1 && num[2] == 4 && num[3] == 7 && num[4] == 9) {puts("YES");}
	else puts("NO");
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


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

int main()
{
	long long int n;
	cin >> n;
	cout << n * (n + 1) / 2
		- (n / 3) * (6 + 3 * (n / 3 - 1)) / 2
		- (n / 5) * (10 + 5 * (n / 5 - 1)) / 2
		+ (n / 15) * (30 + 15 * (n / 15 - 1)) / 2 << endl;
	return 0;
}

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

int main()
{
	int n, m, c, temp;
	cin >> n >> m >> c;
	int b[m + 1];
	for (int i = 1; i <= m; i++)
		cin >> b[i];
		
	int count = 0;
	for (int j = 1; j <= n; j++)
	{
		int sum = 0;		
		for (int i = 1; i <= m; i++)
		{
			cin >> temp;
			sum += b[i]*temp;
		}
		if (sum + c > 0) count++;
	}
	cout << count;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int c[26];
string S;

int main(){
    cin>>S;
    rep(i,4)c[S[i]-'A']++;
    rep(i,26){
        if(c[i]==2||c[i]==0)continue;
        else{
            out("No");
            return 0;
        }
    }
    out("Yes");
    
    
}


Measured memory_bytes: 256
n = int(input())
cnt = 0
flag = False
for _ in range(n):
    s, t = map(int, input().split())
    if s == t:
        cnt = cnt + 1
    else:
        cnt = 0

    if cnt >= 3:
        flag = True

if flag:
    print('Yes')
else:
    print('No')

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template<typename T>
class BITree2 {
    private:
        // 隣接する値との差分を管理する BIT
        class BITree {
            public:
                BITree() {}
                void Init(int n) {
                    m_N = n + 1;
                    m_Tree.assign(m_N, 0);
                }
                T Sum(int i) {
                    assert(i >= 1 && i < m_N);
                    T s = 0;
                    while(i > 0) { s += m_Tree[i]; i -= i & -i; }
                    return s;
                }
                void Add(int i, T x){ while(i < m_N) { m_Tree[i] += x; i += i & -i; } }
            private:
                int m_N;
                vector<T> m_Tree;
        };
    public:
        BITree2() {}
        BITree2(int n) { Init(n); }
        void Init(int n) { fenwick.Init(n); }
        // 区間 [l, r] の各要素に x を加える O(log m_N)
        void Add(int l, int r, T x) {
            assert(l <= r);
            fenwick.Add(l, x);
            fenwick.Add(r+1, -x);
        }
        // i 番目の要素の値を返す O(log m_N)
        T Get(int i) { return fenwick.Sum(i); }
    private:
        BITree fenwick;
};

int N, M;

signed main()
{
    cin >> N >> M;
    BITree2<int> tree(N);
    REP(i, M) {
        int l, r;
        cin >> l >> r;
        tree.Add(l, r, 1);
    }
    int ans = 0;
    REP(i, N) {
        if(tree.Get(i+1) == M) { ans++; }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024