akhauriyash/Code-Regression huggingface dataset:
import sys

a = [[0] * 3 for _ in range(3)]
a[0] = list(map(int, sys.stdin.readline().strip().split()))
a[1] = list(map(int, sys.stdin.readline().strip().split()))
a[2] = list(map(int, sys.stdin.readline().strip().split()))
n = int(sys.stdin.readline().strip())
b = [0] * n
for i in range(n):
    b = int(sys.stdin.readline().strip())

    for row in range(3):
        for col in range(3):
            if a[row][col] == b:
                a[row][col] = 0


def is_bingo():
    # horizontal
    for r in range(3):
        if a[r][0] + a[r][1] + a[r][2] == 0:
            return True
    # vertical
    for c in range(3):
        if a[0][c] + a[1][c] + a[2][c] == 0:
            return True

    if a[0][0] + a[1][1] + a[2][2] == 0:
        return True
    if a[2][0] + a[1][1] + a[0][2] == 0:
        return True

    return False


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




Measured memory_bytes: 39972
%:pragma GCC optimize(3)
#include<bits/stdc++.h>
#define sc(x)  scanf("%d",&x)
#define pf(x)  printf("%d",x)
#define pfn(x) printf("%d\n",x)
#define pfs(x) printf("%d ",x)
#define rep(n) for(int i = 0;i < n;i++)
#define per(n) for(int i = n-1;i >= 0;i--)
#define mem(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char x;
	cin>>x;
	if(x>='A'&&x<='Z')cout<<'A';
	else cout<<'a';
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll XOR(ll x){
  ll ans;
  ll n=((x+1)/2)%2;
  if(x%2==0) ans=x^n;
  else ans=n;
  return ans; 
}

int main(){
  ll A,B;
  cin>>A>>B;

  ll ans=XOR(A-1)^XOR(B);

  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;
#define debug2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define debugg(g,h,w) rep(i,0,h) { rep(j,0,w) cout << g[i][j] << " "; cout << endl;}
#define debugv(v) for(auto&& x : v){cout << x << " ";} cout << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll; 

int w, h;
char g[51][51];
int dy[4] = {-1,0,1,0}; //nesw
int dx[4] = {0,1,0,-1};

void dfs(int y, int x, char c) 
{
	rep(i,0,4) {
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
		if (c == 'W' && g[ny][nx] == '.') {
			g[ny][nx] = 'a';
			dfs(ny,nx,c);
		}
		else if (c == 'W' && g[ny][nx] == 'b') {
			g[ny][nx] = 'c';
			dfs(ny,nx,c);
		}
		else if (c == 'B' && g[ny][nx] == '.') {
			g[ny][nx] = 'b';
			dfs(ny,nx,c);
		}
		else if (c == 'B' && g[ny][nx] == 'a') {
			g[ny][nx] = 'c';
			dfs(ny,nx,c);
		}
	}
}

int main()
{
	while (cin >> w >> h && w && h) {
		memset(g,0,sizeof(g));
		rep(i,0,h) rep(j,0,w) cin >> g[i][j];
		rep(i,0,h) rep(j,0,w) {
			if (g[i][j] == 'W') dfs(i,j,'W');
			if (g[i][j] == 'B') dfs(i,j,'B');
		}
		//debugg(g,h,w);
		int bcnt = 0, wcnt = 0;
		rep(i,0,h) rep(j,0,w) {
			if (g[i][j] == 'a') wcnt++;
			if (g[i][j] == 'b') bcnt++;
		}
		cout << bcnt << " " << wcnt << endl;
	}
	return 0;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n; scan(n);
      LI xs(n); for(long &x : xs) scan(x);
      LI ys;
      LI zs;
      for(long i = 0; i < n; i+=2) {
         ys.push_back(xs[i]);
      }
      for(long i = 1; i < n; i+=2) {
         zs.push_back(xs[i]);
      }
      LI res;
      if( n % 2 == 0 ) {
         std::reverse(zs.begin(), zs.end());
         for(long z : zs) res.push_back(z);
         for(long y : ys) res.push_back(y);
      }
      else {
         std::reverse(ys.begin(), ys.end());
         for(long y : ys) res.push_back(y);
         for(long z : zs) res.push_back(z);
      }
      printf("%ld", res[0]);
      for(long i = 1; i < (long)res.size(); ++i) {
         printf(" %ld", res[i]);
      }
      putchar('\n');
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

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

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

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;

using State = string::const_iterator;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    double D; int N, B; cin >> D >> N >> B;
    vector<double> p(N), h(N);
    REP(i, N) cin >> p[i] >> h[i];

    double ans = numeric_limits<double>::max();
    for (int b = 1; b <= B+1; ++b) {
        double l = D / (2 * b);

        double ma = l;
        REP(i, N) {
            double x = p[i] - (ll)(p[i] / (2*l)) * (2*l);
            double t = h[i] / (-x*x / (2*l*l) + x / l);
            chmax(ma, t);
        }
        chmin(ans, sqrt(l*l / ma + ma));
    }
    cout << ans << endl;

    return 0;
}



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

int N;
vector<int> A;
vector<int> A2;

int main() {
    cin >> N;
    rep(i, N) {
        int tmp; cin >> tmp;
        A.push_back(tmp);
        A2.push_back(tmp);
    }

    int max_value = 0;
    int max_count = 0;
    int second_value = 0;

    sort(A.rbegin(), A.rend());
    max_value = A[0];

    // vector<int> A2(A.size()); // ちゃんと確保しておくこと
    // copy(A.begin(), A.end(), A2.begin());

    // rep(i, N) {
    //     cout << A2[i] << endl;
    // }
    // cout << endl;

    rep(i, N) {
        if (A[0] == A[i]) {
            max_count++;
        } else if (A[0] != A[i]) {
            second_value = A[i]; 
            break;
        }
    }

    // printf("%d %d %d\n", max_value, max_count, second_value);
    rep(i, N) {
        if (max_count > 1) {
            cout << max_value << endl;
        } else {
            // max_count 1 かつ A[i] が max_value
            if (max_value == A2[i]) {
                cout << second_value << endl;
            } else {
                cout << max_value << endl;
            }
        }
    }
}

Measured memory_bytes: 3436
import java.util.*;
import java.lang.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		long answer = Long.MAX_VALUE;
		for (int i = 0; i < (1 << n); i++) {
			if (Integer.bitCount(i) != k) continue;
			int ma = 0;
			long cost = 0;

			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) != 1) {
					ma = Math.max(ma, a[j]);
					continue;
				}

				if (ma < a[j]) {
					ma = a[j];
					continue;
				}

				cost += (ma - a[j]) + 1;
				ma++;
			}

			answer = Math.min(answer, cost);
		}

		System.out.println(answer);

	}
}


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

void Main() {
  int K, N;
  cin >> K >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  int max_distance = 0;
  for (int i = 1; i < N; i++) {
    max_distance = max(max_distance, A[i] - A[i - 1]);
  }
  max_distance = max(max_distance, A[0] + K - A[N - 1]);
  cout << K - max_distance << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b; cin >> a >> b;
	if (a + b == 15)cout << "+" << endl;
	else if (a*b == 15)cout << "*" << endl;
	else cout << "x" << endl;
}

Measured memory_bytes: 256
// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int ans = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                push_back
#define mp              make_pair
#define sz(a)           a.size()
#define mods(a, m)          ((a % m + m) % m)
#define md(a)               mods(a, MOD)
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)     for (ll i = b; i < e; i++)
#define forr(i, b, e)     for (ll  i = b; i < e; i++)
#define endl '\n'


using namespace std;
//using namespace __gnu_pbds;
typedef long double       ld;

typedef pair<ll, ll>  ii;
typedef pair<ll,ii> iii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e9 + 7);
const ll MOD = 1e9+7;
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 1000003
ll dp[2][5][tam];
string t;
ll f(ll equal,ll k,ll pos)
{
    if (k<0)
        return 0;
    if (pos==t.size())
    {
        return (k==0);
    }
    if (dp[equal][k][pos]!=-1)
        return dp[equal][k][pos];
    ll res=0;
    if (!equal)
    {
        forr(i,0,10)
        res+=f(equal,k-(i!=0),pos+1);

    }
    else
    {
        forr(i,0,t[pos]-'0')
        {
            res+=f(0,k-(i!=0),pos+1);
        }
        ll chr=t[pos]-'0';
        res+=f(1,k-(chr!=0),pos+1);
    }
    return dp[equal][k][pos]=res;

}
int main()
{    
    std::ios::sync_with_stdio(false); cin.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>t;
    ll k;
    cin>>k;
    cout<<f(1,k,0)<<endl;

}   
// PLUS ULTRA!


Measured memory_bytes: 78336
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((q (read)))
    (declare (uint32 q))
    (dotimes (_ q)
      (let ((a (read-fixnum))
            (b (read-fixnum)))
        (declare (uint31 a b))
        (when (> a b) (rotatef a b))
        (let ((res (* 2 (- a 1))))
          (unless (= a b)
            (sb-int:named-let bisect ((ok 0) (ng (- b a)))
              (declare (uint31 ok ng))
              (if (<= (- ng ok) 1)
                  (incf res ok)
                  (let* ((mid (ash (+ ok ng) -1))
                         (x/2 (max 1 (floor mid 2))))
                    (declare (uint31 mid x/2))
                    (if (< (* (+ a x/2) (+ a mid (- x/2))) (* a b))
                        (bisect mid ng)
                        (bisect ok mid))))))
          (println res))))))

#-swank (main)


Measured memory_bytes: 21732
import math
a, b, h, m = map(int, input().split())
angle = (h * 30 + m * 0.5) - (m * 6)
Radians = math.radians(angle)
cos = math.cos(Radians)
answer = (a**2) + (b**2) - 2*(a*b)*cos
print(answer**0.5)

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

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n==0)break;
    vector<string> s(n);
    for(int i=0;i<n;i++){
      cin >> s[i];
    }

    vector<string> codes(n);
    for(int i=0;i<n;i++){
      string str = s[i];
      string code = str.substr(0,1);
      for(int j=0; j<str.size()-1; j++){
        if(str[j] == 'a'||str[j] == 'i'||str[j] == 'u'||str[j] == 'e'||str[j] == 'o'){
          code += str[j+1];
        }
      }
      codes[i] = code;
    }

    bool ok = false;
    for(int k=1; k<=50; k++){
      set<string> c;
      for(int i=0;i<n;i++){
        if(codes[i].size() >= k){
          c.insert(codes[i].substr(0,k));
        }else{
          c.insert(codes[i]);
        }
      }
      if(c.size() == n){
        ok = true;
        cout << k << endl;
        break;
      }
    }

    if(!ok){
      cout << "-1" << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,N) for(long long int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;

string s;
char c = 'A';

int main(){
	while (cin >> s){
		REP(i, s.size()){
			if (s[i] == c){
				if (i == 0){
					c = s[2];
				}
				else{
					c = s[0];
				}
				break;
			}
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 1172
#include <stdio.h>

int main() {
	int Cards[4][13], cnt, t_num;

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			Cards[i][j] = 1;
		}
	}

	char cha;
	scanf("%d", &cnt);
	
	for (int i = 0; i < cnt; i++) {
		scanf("%c", &cha);
		scanf("%c %d", &cha, &t_num);
		if (cha == 'S') {
			Cards[0][t_num - 1] = 0;
		}
		else if (cha == 'H') {
			Cards[1][t_num - 1] = 0;
		}
		else if (cha == 'C') {
			Cards[2][t_num - 1] = 0;
		}
		else if (cha == 'D') {
			Cards[3][t_num - 1] = 0;
		}
		else{printf("Error root\n");}
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (Cards[i][j] == 1) {
				if (i == 0) {
					printf("S %d\n", j + 1);
				}
				else if (i == 1) {
					printf("H %d\n", j + 1);
				}
				else if (i == 2) {
					printf("C %d\n", j + 1);
				}
				else if (i == 3) {
					printf("D %d\n", j + 1);
				}
				else {}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2104
n = int(input())
ls_v = list(map(int, input().split()))
ls_c = list(map(int, input().split()))

x = 0
y = 0

for i in range(n):
    if ls_v[i] - ls_c[i] >= 0:
        x += ls_v[i]
        y += ls_c[i]

print(x - y)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	ll n,k,q; cin>>n>>k>>q;
	ll arr[n]; ll x;
	for(int i = 0; i < n; i++){
		arr[i] = k;
	}
	for(int i = 0; i < q; i++){
		cin>>x;
		arr[x-1] += 1;
	}
	for(int i = 0; i < n; i++){
		if(arr[i]-q <= 0) cout<<"No"<<"\n";
		else cout<<"Yes"<<"\n";
	}
	
	
	
	
	
	
}

Measured memory_bytes: 1408
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int a, p;
	scanf("%d %d", &a, &p);
	printf("%d\n", (3*a+p)/2);
	return 0;
}


Measured memory_bytes: 256
var N,C,i,sum:int64;
    V:array[1..30] of integer;
begin
read(N);sum:=0;
for i := 1 to N do read(V[i]);

for i := 1 to N do 
begin
 read(C);
 if V[i]-C>=0 then sum:=sum+V[i]-C;
end;
 write(sum)
end.

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

mi = 10 ** 5
c = []

for i in range(N):
    temp = A[i]
    ctemp = 0
    while temp % 2 == 0:
        ctemp += 1
        temp = temp // 2
    c.append(ctemp)

print(min(c))


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    int t[n], sum = 0;
    rep(i, n)
    {
        cin >> t[i];
        sum += t[i];
    }

    int m, maxv = 0, ind;
    cin >> m;
    rep(i, m)
    {
        int p, x;
        cin >> p >> x;
        OP(sum - t[p - 1] + x);
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
int n,m,len;
int a[N];
bool f[N];
char s[N];
int main()
{
	int T=1;
	//scanf("%d",&T);
	while(T--)
	{
		for(int i=1;i<=9;i++)
			for(int j=1;j<=9;j++)
				f[i*j]=1;
		scanf("%d",&n);
		printf("%s",f[n]?"Yes":"No");
	}
}

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

int main()
{
    int x;
    cin>>x;
    if(x>=400&&x<600) cout<<8;
    if(x>=600&&x<800) cout<<7;
    if(x>=800&&x<1000) cout<<6;
    if(x>=1000&&x<1200) cout<<5;
    if(x>=1200&&x<1400) cout<<4;
    if(x>=1400&&x<1600) cout<<3;
    if(x>=1600&&x<1800) cout<<2;
    if(x>=1800&&x<2000) cout<<1;

}


Measured memory_bytes: 3616
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int A = Integer.parseInt(sl[0]);
            int B = Integer.parseInt(sl[1]);
            int C = Integer.parseInt(sl[2]);
            int D = Integer.parseInt(sl[3]);

            int ans = 0;
            if (A <= C && C <= B) ans = Math.min(B, D) - C;
            else if (A <= D && D <= B) ans = D - Math.max(A, C);
            else if (C < A && B < D) ans = B - A;

            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <ctime>
#include <iomanip>
#include <numeric>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin >> c;
	c++;
	cout << c;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
typedef long long int lli;

int main(){
    int n, m;
    int cumulative[MAXSIZE] = {};
    int ans = 0;

    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int l, r;
        cin >> l >> r;
        cumulative[l]++;
        cumulative[r + 1]--;
    }

    //cout << "cumulative:[";
    for(int i = 1; i <= n; ++i){
        cumulative[i] += cumulative[i - 1];
        //cout << " " << cumulative[i];
        ans += (cumulative[i] == m);
    }
    //cout << " ]" << endl;
    cout << ans << endl;
    return 0;
}

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

int par[MAX_N];
int ranks[MAX_N];
int g;

void init(int n){
  for(int i = 0; i < n; i++) par[i] = i, ranks[i] = 0;
}

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

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

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


int main(){
  int n, m;
  cin >> n >> m;
  g = n;
  init(n);
  rep(i, m){
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    if(!same(a,b)) unite(a, b);
  }
  cout << g << endl;
  return 0;
}


Measured memory_bytes: 1024
def dfs(now,depth):
    if use[now]:
        return 0

    if depth==n:
        return 1

    use[now]=1
    ans=0

    for i in range(n):
        if gragh[now][i]:
            ans+=dfs(i,depth+1)

    use[now]=0
    return ans

n,m=map(int,input().split())
gragh=[[0]*n for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    gragh[a-1][b-1]=gragh[b-1][a-1]=1

use=[0]*n

print(dfs(0,1))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  int MIN = INF;
  REP(i, N){
    if(MIN > A[i]){
      ans++;
      MIN = A[i];
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)

vs dfs(vs &words,vs &c_words,map<char,char> &m,int cur,vs &orig_c_words){
  vs ret;
  if(cur==orig_c_words.size()){
    REP(i,orig_c_words.size()){
      string s;
      REP(j,orig_c_words[i].size()){
        s.push_back(m[orig_c_words[i][j]]);
      }
      ret.push_back(s);
    }
    return ret;
  }

  REP(i,words.size()){
    if(words[i].size()==c_words[cur].size()){
      map<char,char> nm(m);
      bool ok=true;
      REP(j,words[i].size()){
        map<char,char>::iterator it_i=nm.find(words[i][j]);
        map<char,char>::iterator it_c=nm.find(c_words[cur][j]);
        bool ei=it_i!=nm.end();
        bool ec=it_c!=nm.end();
        if(ei&&ec){
          if(it_i->second!=c_words[cur][j]||it_c->second!=words[i][j]){
            ok=false;
            break;
          }
        }else if(ei||ec){
          ok=false;
          break;
        }else{
          nm[words[i][j]]=c_words[cur][j];
          nm[c_words[cur][j]]=words[i][j];
        }
      }
      if(ok){
        //cerr<<"cur:"<<cur<<endl;
        vs res=dfs(words,c_words,nm,cur+1,orig_c_words);
        //cerr<<"res:"<<res.size()<<endl;
        if(res.size()>0){
          if(res.size()==100){
            return vs(100);
          }
          if(ret.size()){
            return vs(100);
          }else{
            ret=res;
          }
        }
      }
    }
  }
  return ret;

}
bool pred(const string &l,const string &r){
  if(l.size()==r.size()){
    return l>r;
  }else{
    return l.size()>r.size();
  }
}
int main(){
  int n;
  while(cin>>n,n){
    vs words(n);
    REP(i,n){
      cin>>words[i];
    }
    string sequence;
    getline(cin,sequence);
    getline(cin,sequence);
    vs c_words;
    int prev=0;
    REP(i,sequence.size()){
      switch(sequence[i]){
        case ' ':
        case '.':
          c_words.push_back(sequence.substr(prev,i-prev));
          prev=i+1;
          break;
      }
    }
    vs orig_c_words(c_words);
    sort(ALL(c_words),pred);
    map<char,char> m;
    vs res=dfs(words,c_words,m,0,orig_c_words);
    if(res.size()&&res.size()<100){
      REP(i,res.size()){
        cout<<res[i]<<(i<res.size()-1?" ":"");
      }
      cout<<"."<<endl;
    }else{
      cout<<"-."<<endl;
    }
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;

int dict[1048576] = {};

void makeDict(long A[], long n){
	for (long i = 0; i < pow(2, n); i++){
		dict[i] += (i % 2) * A[0];
		for (long j = 1; j < n; j++){
			dict[i] += (fmod(i, pow(2, j + 1)) - fmod(i, pow(2, j))) / pow(2, j) * A[j];
		}
	}
}

int main(){
	long n, q, A[20], m[200];
	cin >> n;
	for (long i = 0; i < n; i++) cin >> A[i];
	makeDict(A, n);
	int p = pow(2, n);
	sort(dict, dict + p);
	cin >> q;
	for (long i = 0; i < q; i++){
		cin >> m[i];
		if (binary_search(dict, dict + p, m[i])) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 5308
// Pratiyush Mishra(pratiush7)
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define repab(i,a,b) for(ll i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define popf pop_front
#define p() cout<<'\n'
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n'
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define pr1(x) cout<<fixed<<setprecision(15)<<x<<'\n'
#define mod 1000000007
#define mod1 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getvec(v,n) vector<ll> v(n);for(ll i=0;i<n;i++) cin>>v[i];
#define getstr(s) string s;cin>>s
#define all(x) x.begin(),x.end()
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(n);get(t);
  ll penal=0;
  map<ll,ll> m;
  vector<bool> v(n,false);
  rep(i,t){
    get(q);getstr(s);
    q--;
    if(s=="AC")
      v[q]=true;
    else{
      if(!v[q])
        m[q]++;
    }
  }
  ll succ=0;
  rep(i,n){
    if(v[i]){
      succ++;
      penal+=m[i];
    }
  }
  p2(succ,penal);
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <utility>
using namespace std;
const int INF = 1 << 29;
struct edge {int from, to, cost;};

edge es[2010];
int d[1010];
int V, E, r;

bool bellman_ford(int s) {
    fill(d, d + V, INF);
    d[s] = 0;
    for (int cnt = 0;; cnt++) {
        bool update = false;
        for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
                if (cnt == V - 1) return true;
            }
        }
        if (!update) break;
    }
    return false;
}


int main(void) {
    cin >> V >> E >> r;
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        es[i] = edge{s, t, d};
    }
    bool negative = bellman_ford(r);
    if (negative) cout << "NEGATIVE CYCLE" << endl;
    else {
        for (int i = 0; i < V; i++) {
            if (d[i] < INF) cout << d[i] << endl;
            else cout << "INF" << endl;
        }
    }

    return 0;
}

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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  for(int i=0;i<N;i=i+1){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  for(string x:S){
    cout << x;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
struct node{
    int to,next;
}e[100100];
int cnt=0,head[10100],vis[10100],stack[10100],top=0;
void addedge(int u,int v){
    cnt++,e[cnt].to=v,e[cnt].next=head[u],head[u]=cnt;
}
void dfs(int x){
    int b,v;
    vis[x]=1;
    for(b=head[x];b;b=e[b].next){
        v=e[b].to;
        if(vis[v]==0)
            dfs(v);
    }
    stack[++top]=x;//1 此?写成 stack[++top]=v; ?了会，真是大失水准 
}
int main(){
    int n,m,i,j,u,v;
    memset(head,0,sizeof(head));
    memset(vis,0,sizeof(vis));
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        addedge(u,v);
    }
    for(i=0;i<n;i++)
        if(vis[i]==0)
            dfs(i);
    while(top){
        printf("%d\n",stack[top--]);
    }
    return 0;
}

Measured memory_bytes: 2132
#![allow(dead_code)]
#![allow(unused_imports)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

fn main() {
    input!(s:String, t:String);

    let s:Vec<char> = s.chars().collect();
    let t:Vec<char> = t.chars().collect();

    let mut ans = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  IN(ll,A);
  IN(ll,B);
  ll sum = 1;
  ll count = 0;
  while(sum < B){
    count++;
    sum += A-1;
  }
  OUT(count);
}



Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
if a[0]:
    print(-1)
else:
    s = 0
    for i in range(1, n):
        if a[i] == a[i - 1] + 1:
            s += 1
        elif a[i] > a[i - 1] + 1:
            s = -1
            break
        else:
            s += a[i]
    print(s)


Measured memory_bytes: 11048
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main (void) {
  int N; std::cin >> N;

  int ans = 0;
  for(int i=1; i<=N; i++) {
    if ( GetDigit(i) % 2 == 1 ) {
      ans++;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  set<string> said;
  vector<string> vs(N);
  FOR(i,0,N) {
    cin >> vs[i];
  }
  string a, b;
  a = vs[0];
  said.insert(a);
  FOR(i,1,N) {
    b = vs[i];
    if(a[a.length()-1]!=b[0]) {
      cout << "No" << endl;
      return 0;
    }
    if(said.count(b)) {
      cout << "No" << endl;
      return 0;
    }
    said.insert(b);
    a = b;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 998244353
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define adb2(a) for(auto i:a) cout << i.first << " " << i.second << endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define N 500010
using namespace std;

int main()
{
    fastIO;
    long long s, w;
    cin >> s >> w;

    if(s>w) cout << "safe" << endl;
    else cout << "unsafe" << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
typedef long long int64;

int n, r, X1[10000], Y1[10000], X2[10000], Y2[10000];
int max_h, max_w;

Pi get__(){
  int imos[10002], ret = 0, res = 0, imomo[10002];
  for(int i = 0; i < max( max_h, max_w) + 1; i++){
    fill_n( imos, 10002, 0), fill_n( imomo, 10002, 0);
    for(int j = 0; j < n; j++){
      if(Y1[j] <= i && i < Y2[j]){
        imos[X1[j]]++;
        imos[X2[j]]--;
      }
      if(X1[j] <= i && i < X2[j]){
        imomo[Y1[j]]++;
        imomo[Y2[j]]--;
      }
    }
    for(int j = 1; j <= max(max_w, max_h) + 1; j++){
      imos[j] += imos[j - 1];
      imomo[j] += imomo[j - 1];
      if( imos[j] > 0) ret++;
      if(imomo[j] > 0 && imomo[j - 1] == 0) res++;
      if(imomo[j - 1] > 0 && imomo[j] == 0) res++;
      if( imos[j] > 0 && imos[j - 1] == 0) res++;
      if( imos[j - 1] > 0 && imos[j] == 0) res++;
    }

    if(imos[0] > 0){
      ret++;
      res++;
    }
    if(imomo[0] > 0){
      res++;
    }
  }
  return make_pair( ret, res);
}

int main(){
  while(cin >> n >> r, n){
    max_h = max_w = 0;
   for(int i = 0; i < n; i++){
     cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
     max_h = max( max_h, Y2[i]);
     max_w = max( max_w, X2[i]);
   }
   Pi __ = get__();
   cout << __.first << endl;
   if(r == 2) cout << __.second << endl;
  }
}

Measured memory_bytes: 1392
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+10;
struct point{
    int u,to,next;
}pt[maxn],pp[maxn];
int vis[maxn],head[maxn],s,a[2100][2100],q;
void init()
{
    q=0;
    memset(head,-1,sizeof(head));
    memset(a,0,sizeof(a));
}
void add(int u,int v)
{
    pt[q].next=head[u];
    pt[q].u=u;
    pt[q].to=v;
    head[u]=q++;
}
void dfs(int pre,int st,int dis)
{
    for (int i=head[st];i!=-1;i=pt[i].next)
    {
        int to=pt[i].to;
        if (to!=pre)
        {
            a[s][to]=a[to][s]=dis;
            dfs(st,to,dis+1);
        }
    }
}
int main()
{
    int n,ans=0,k,u,v,w=0;
    init();
    cin>>n>>k;
    for (int i=1;i<n;i++)
    {
        cin>>u>>v;
        add(u,v);
        add(v,u);
        pp[w].u=u;
        pp[w++].to=v;
    }
    for (int i=1;i<=n;i++)
    {
        s=i;
        dfs(0,i,1);
    }
    if (k%2==0)
    {
        int minn=0x3f3f3f3f;
        for (int i=1;i<=n;i++)
        {
            ans=0;
            for (int j=1;j<=n;j++)
            {
                if (j!=i)
                {
                    if (2*a[j][i]>k)
                        ans++;
                }
            }
            minn=min(ans,minn);
        }
        cout<<minn<<endl;
    }
    else
    {
        int minn=0x3f3f3f3f;
        k=k/2;
        for (int i=0;i<w;i++)
        {
            ans=0;
            for (int j=1;j<=n;j++)
            {
                if (a[j][pp[i].u]>k&&a[j][pp[i].to]>k)
                    ans++;
            }
            minn=min(ans,minn);
        }
        cout<<minn<<endl;
    }
    return 0;
}

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


int n, c;
int x[110], y[110], h[110];

int max(int x, int y) {
    if (x > y)return x;
    else return y;
}

int kkk(int a, int b) {
    int h0 = abs(a-x[c])+abs(b-y[c])+ h[c];

    for (int i = 1; i <= n; ++i)
        if (max(0, h0-(abs(a - x[i]) + abs(b - y[i]))) != h[i])
            return 0;
    return 1;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i] >> y[i] >> h[i];

    for (int i = 1; i <= n; i++)
        if (h[i] != 0) c = i;

    for (int i = 0; i < 101; ++i)
        for (int j = 0; j < 101; ++j) {
            if (kkk(i, j)) {
                cout << i << " " << j << " " << abs(i - x[c]) + abs(j - y[c]) + h[c] << endl;
                return 0;
            }
        }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int len = s.length();
        long sum = 0;
        for(int i=0; i<len; i++) {
            sum += Long.parseLong(s.substring(i, i+1));
        }
        System.out.println(sum%9==0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 50536
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

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

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::vector<mint> count(60,0);
	mint sum = 0;
	rep(i,n) sum+=a[i];
	sum*=n-1;
	rep(i,n) {
		rep(j,60) {
			if((a[i]>>j)&1) count[j]+=1;
		}
	}
	mint base = 1;
	rep(i,60) {
		sum-=base*count[i]*(count[i]-1);
		base*=2;
	}
	print(sum);
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int max = 0;
  for (int i=0 ; i<n ; i++)
    cin >> p.at(i);
  
  sort(p.begin(), p.end());
  
  int ans = 0;
  for (int i=0 ; i<n-1 ; i++)
    ans += p.at(i);
  ans += p.at(n-1)/2;
  
  cout << ans << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256