akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cassert>
using namespace std;

int main(){
  int N;
  cin >> N;
  if(N == 2){
    cout << -1 << endl;
    return 0;
  }

  vector<string> A(N,string(N,'.'));
  
  vector<string> P3 = {"abb","a.d","ccd"};
  vector<string> P5 = {"abbcc",
                       "ad..f",
                       "bd..f",
                       "b.aae",
                       "ccdde"};
  vector<string> P4 = {"aabc",
                       "ddbc",
                       "efgg",
                       "efhh"};

  if(N%3 == 0 or N == 7){

    for(int i = 0; i < N/3; ++i){
      for(int j = 0; j < 3; ++j){
        for(int k = 0; k < 3; ++k){
          A[3*i+j][3*i+k] = P3[j][k];
        }
      }
    }
  }else if(N == 11){
    for(int i = 0; i < 2; ++i){
      for(int j = 0; j < 3; ++j){
        for(int k = 0; k < 3; ++k){
          A[3*i+j][3*i+k] = P3[j][k];
        }
      }
    }

    for(int j = 0; j < 4; ++j){
      for(int k = 0; k < 4; ++k){
        A[7+j][7+k] = P4[j][k];
      }
    }
  }else{
    int y = N%4;
    for(int t = 0; t < y; ++t){
      for(int i = 0; i < 5; ++i){
        for(int j = 0; j < 5; ++j){
          A[N-5+i][N-5+j] = P5[i][j];
        }
      }
      N -= 5;
    }
    for(int i = 0; i < N/4; ++i){
      for(int j = 0; j < 4; ++j){
        for(int k = 0; k < 4; ++k){
          A[4*i+j][4*i+k] = P4[j][k];
        }
      }
    }
  }
  if(N == 7 or N == 11){
    string tmp = "xxyyzz.";
    for(int i = 0; i < 7; ++i){
      A[i][6] = tmp[i];
      A[6][i] = tmp[i];
    }
  }
  for(auto a : A){
    cout << a << endl;
  }
}


Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long ll;
int n,m,a[100010],b[100010];
int main()
{
  cin>>n>>m;
  for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
  ll ans=0;
  for(int w=31;w>=0;w--) if(w==0 || m>>(w-1)&1)
  {
  	ll tmp=0;
    for(int i=1;i<=n;i++)
	  if(((a[i]>>w)|(m>>w))==(m>>w) && (w==0 || (a[i]>>(w-1)&1)==0)) tmp+=b[i];
	ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


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

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

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

using namespace std;

const long long mod = 1000000007;
const long long MOD = 998244353;

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

	string s;
	cin >> s;

	ll ans = 0;
	ll counter = 0;
	llrep(i, s.length()) {
		if (s[i] == 'W') {
			ans += i - counter;
			++counter;
		}
	}

	cout << ans << "\n";

	return 0; 
}


Measured memory_bytes: 848
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	for (int i = 0; i < N; i++) {
		string s, t;
		cin >> s >> t;
		reverse(s.begin(), s.end());
		reverse(t.begin(), t.end());
		int a, b;
		a = 0;
		b = 0;
		int box = 0;
		for (auto j : s) {
			if (j == 'i') {
				if (box) {
					a += box;
				}
				box = 1;
			}
			else if (j == 'x') {
				if (box) {
					a += box;
				}
				box = 10;
			}
			else if (j == 'c') {
				if (box) {
					a += box;
				}
				box = 100;
			}
			else if (j == 'm') {
				if (box) {
					a += box;
				}
				box = 1000;
			}
			else {
				box *= j - '0';
				a += box;
				box = 0;
			}
		}
		a += box;
		box = 0;
		for (auto j : t) {
			if (j == 'i') {
				if (box) {
					b += box;
				}
				box = 1;
			}
			else if (j == 'x') {
				if (box) {
					b += box;
				}
				box = 10;
			}
			else if (j == 'c') {
				if (box) {
					b += box;
				}
				box = 100;
			}
			else if (j == 'm') {
				if (box) {
					b += box;
				}
				box = 1000;
			}
			else {
				box *= j - '0';
				b += box;
				box = 0;
			}
		}
		b += box;
		int c = a + b;
		while (c) {
			if (c >= 2000) {
				cout << c / 1000;
				c -= c / 1000 * 1000 - 1000;
			}
			if (c >= 1000) {
				cout << "m";
				c -= 1000;
			}
			if (c >= 200) {
				cout << c / 100;
				c -= c / 100 * 100 - 100;
			}
			if (c >= 100) {
				cout << "c";
				c -= 100;
			}
			if (c >= 20) {
				cout << c / 10;
				c -= c / 10 * 10 - 10;
			}
			if (c >= 10) {
				cout << "x";
				c -= 10;
			}
			if (c >= 2) {
				cout << c / 1 ;
				c -= c / 1 * 1 - 1;
			}
			if (c >= 1) {
				cout << "i";
				c -= 1;
			}
		}
		cout << endl;
	}
	return 0;
}

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


main()
{
	set<int> s;
	//stack<int> s;
	queue<int> q;
	int n,m,i,j;
	int input;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&input);
		if(s.count(input)!=0)
		{
			s.erase(input);
		}
		else
		{
			s.insert(input);
		}
	}
	printf("%d",s.size());
	
}

Measured memory_bytes: 4864
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  string S, T;
  cin >> S >> T;

  ll DP_S[S.length() + 1][2];
  DP_S[0][0] = 0; DP_S[0][1] = 0;
  for (int i = 0; i < S.length(); i++){
    for (int j = 0; j < 2; j++){
      DP_S[i + 1][j] = DP_S[i][j];
    }
    
    if (S[i] == 'A') DP_S[i + 1][0]++;
    else DP_S[i + 1][1]++;
  }

  int DP_T[T.length() + 1][2];
  DP_T[0][0] = 0; DP_T[0][1] = 0;
  for (int i = 0; i < T.length(); i++){
    for (int j = 0; j < 2; j++){
      DP_T[i + 1][j] = DP_T[i][j];
    }
    
    if (T[i] == 'A') DP_T[i + 1][0]++;
    else DP_T[i + 1][1]++;
  }  

  int Q; cin >> Q;
  vector <bool> ans(Q);
  for (int i = 0; i < Q; i++){
    int A, B, C, D; cin >> A >> B >> C >> D;
    A--; C--;

    int S_A = DP_S[B][0] - DP_S[A][0];
    int S_B = DP_S[B][1] - DP_S[A][1];

    int T_A = DP_T[D][0] - DP_T[C][0];
    int T_B = DP_T[D][1] - DP_T[C][1];

    int now = (S_A - S_B) - (T_A - T_B);
    if (now % 3 == 0) ans[i] = true;
  }
  
  for (int i = 0; i < Q; i++){
    if (ans[i] == true) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3200
n, *is = $<.read.split(/\s+/).map(&:to_i)
min = n
(1..n).each{|w|
    a = is.map{|i| [(i-1) % w, (i-1) / w]}
    sum = (0..3).map{|i| (a[i&2][i%2] - a[1+(i&2)][i%2]).abs}.inject(&:+)
    min = [min, sum].min
}
puts min

Measured memory_bytes: 6108
def gcd(a, b): # a < b
    while True:
        c = b%a
        if c == 0:
            break
        b = a
        a = c

    return a


A, B, C, D = map(int, input().split())

start = A // C
end = B // C
if A % C != 0:
    start = start + 1
C_num = end - start + 1

start = A // D
end = B // D
if A % D != 0:
    start = start + 1
D_num = end - start + 1

CD = C * D // gcd(C, D)
start = A // CD
end = B // CD
if A % CD != 0:
    start = start + 1
CD_num = end - start + 1

ans = (B - A + 1) - (C_num + D_num - CD_num)

print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ABC11X_A();
		ABC11X_B();
		// ABC11X_C();
		// ABC11X_D();
	}

	private static void ABC11X_A() {
		Scanner scanner = null;
		int nenrei = 0;

		try {
			scanner = new Scanner(System.in);
			nenrei = scanner.nextInt();
			switch (nenrei) {
			case 3:
			case 5:
			case 7:
				System.out.println("YES");
				break;
			default:
				System.out.println("NO");
				break;
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_B() {
		Scanner scanner = null;
		String lineAB;

		try {
			final int length = 3;
			scanner = new Scanner(System.in);
			lineAB = scanner.nextLine();

			int minInt = Integer.MAX_VALUE;
			int wkInt = 0;
			for (int i = 0; i < lineAB.length() - length + 1; i++) {
				String wk = lineAB.substring(i, i + length);
				wkInt = Integer.parseInt(wk);
				if (Math.abs(wkInt - 753) < minInt) {
					minInt = Math.abs(wkInt - 753);
				}
			}

			System.out.println(minInt);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_C() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_D() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

int main()
{

        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int t=1;
       /// cin>>t;
        
        while(t--)
        {
            string a,b,u;
         	int x,y;
          cin>>a>>b>>x>>y>>u;
          
          if(u==a)
            cout<<--x<<" "<<y;
          else
            cout<<x<<" "<<--y;
        }
        
        
         return 0;

    }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int[] ws = new int[n];

		for (int i = 0; i < n; i++) {
			ws[i] = scn.nextInt();

		}

		scn.close();

		int min = 10001;
		for (int i = 0; i < n; i++) {
			int sum1 = 0;
			int sum2 = 0;
			for (int j = 0; j < i; j++) {
				sum1 += ws[j];
			}
			for (int j = i; j < n; j++) {
				sum2 += ws[j];
			}

			int dif = Math.abs(sum1 - sum2);

			if (dif < min) {
				min = dif;
			}

		}

		System.out.println(min);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  string s,aaaa;
  for(int i=-2;b>i;i++)
    s += "#";
  cout << s << endl;
  for(int i=0;a>i;i++){
    cin >> aaaa;
    cout << "#" + aaaa + "#" << endl;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(float, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

a, b = inm()
a = int(a)
b = int(b * 100 + 0.1)
print(a*b // 100)

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

int main() {
  string a, b;
  cin >> a >> b;
  
  if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
sdin = sys.stdin.readline

INF = float("inf")

n = int(sdin())
ta = []
for _ in range(n):
    ta.append(tuple(map(int, sdin().split())))
    
    
t_real = [ta[0][0]]
a_real = [ta[0][1]]
for i in range(1,n):
    t_k = t_real[i-1]//ta[i][0] + bool(t_real[i-1]%ta[i][0])
    a_k = a_real[i-1]//ta[i][1] + bool(a_real[i-1]%ta[i][1])
    
    # t_realとa_realの次の候補
    if t_k * ta[i][1] < a_real[i-1]:
        t_real_t = INF
        a_real_t = INF
    else:
        t_real_t = t_k * ta[i][0]
        a_real_t = t_k * ta[i][1]
        
    if a_k * ta[i][0] < t_real[i-1]:
        t_real_a = INF
        a_real_a = INF
    else:
        t_real_a = a_k * ta[i][0]
        a_real_a = a_k * ta[i][1]
        
    # 選択
    if (t_real_t + a_real_t) <= (t_real_a + a_real_a):
        t_real.append(t_real_t)
        a_real.append(a_real_t)
    else:
        t_real.append(t_real_a)
        a_real.append(a_real_a)
        
print(t_real[-1] + a_real[-1])

Measured memory_bytes: 3188
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var n = o.a();
  var k = o.a();
  console.log(n - k + 1);
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,n;
    cin >> n;
 a=0;b=0;
    vector<int> m(n);
    for (int i = 0; i < n; i++){
        cin >> m.at(i);
    }
    sort(m.begin(), m.end());
    for (int i = 0; i < n; i++){
      for(int j =i+1;j<n;j++){
      if(m.at(i)==m.at(j)){m.at(j)=0;}
        }
    }
  for(int i=0;i<n;i++){if(m.at(i)>0){a++;}}
    cout<<a<<endl;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;

    long long x[100], y[100], h[100], ch[4];
    int t;
    
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] != 0) {
            t = i;
        }
    }

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            ch[0] = h[t] + i - x[t] + j - y[t];
            ch[1] = h[t] + i - x[t] - j + y[t];
            ch[2] = h[t] - i + x[t] + j - y[t];
            ch[3] = h[t] - i + x[t] - j + y[t];
            for (int l = 0; l < 4; l++) {
                int flag = 1;
                if (ch[l] > 0) {
                    for (int k = 0; k < n; k++) {
                        if (h[k] != max(ch[l] - abs(x[k] - i) - abs(y[k] - j), 0ll)) {
                            flag = 0;
                            break;
                        }
                    }

                    if (flag == 1) {
                        cout << i << " " << j << " " << ch[l] << endl;
                        return 0;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 256
class EdmondsKarp
  def initialize(n)
    @n = n
    @flow = Array.new(n) { Array.new(n, 0) }
    @cap = Array.new(n) { Array.new(n, 0) }
  end

  def add_edge(s, t, w)
    @cap[s][t] = w
  end

  def max_flow(start, goal)
    inf = 2 ** 30
    sum = 0
    while true
      que = [start]
      prev = Array.new(@n, -1)
      prev[start] = start
      while !que.empty? && prev[goal] == -1
        u = que.shift
        @n.times do |i|
          if prev[i] == -1 && @cap[u][i] - @flow[u][i] > 0
            prev[i] = u
            que.push(i)
          end
        end
      end
      return sum if (prev[goal] == -1)
      inc = inf
      c = goal
      while c != start
        inc = [inc, @cap[prev[c]][c] - @flow[prev[c]][c]].min
        c = prev[c]
      end
      c = goal
      while c != start
        @flow[prev[c]][c] += inc
        @flow[c][prev[c]] -= inc
        c = prev[c]
      end
      sum += inc
    end
  end
end



vn, en = gets.split.map(&:to_i)
g = EdmondsKarp.new(vn)

en.times do |i|
  s, t, w = gets.split.map(&:to_i)
  g.add_edge(s, t, w)
end

puts g.max_flow(0, vn - 1)


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

int main() {
    int N,c=1,a,b,ans;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> dec(N);

    for(int i=0;i<N;i++)
        cin >> P.at(i);
    for(int i=0;i<N;i++)
        cin >> Q.at(i);
    dec = P;
    sort(dec.begin(),dec.end());

    do{
        if(dec==P)
            a=c;
        if(dec==Q)
            b=c;
        c++;
    }while(next_permutation(dec.begin(), dec.end()));
    ans = abs(a-b);
    cout << ans <<endl;
    
}

Measured memory_bytes: 3640
<?php
fscanf(STDIN, '%d', $n);
$tmp = [];
for($i = 1; $i <= $n; $i++) {
    fscanf(STDIN, '%s %d', $s, $p);
    $tmp[$s][$p] = $i;
}
ksort($tmp);
$ans = [];
foreach($tmp as $city => $point) {
    krsort($point);
    foreach($point as $no) {
        echo $no, PHP_EOL;
    }
}

Measured memory_bytes: 4728
/*input
2 7 10
*/

#include <bits/stdc++.h>
 
using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con))) 
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)
 
using ll = long long;
using ss = stringstream;
using ul = unsigned long long;
 
template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) { 
  FH(it,s) 
    *it = tolower(*it); 
} 
 
inline void upper(string &s) { 
  FH(it,s) 
    *it = toupper(*it); 
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
} 

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n) 
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    ll n, a, b;
    cin >> n >> a >> b;
    if(n == 1) {
        if(a == b) {
            cout << "1";
        }
        else {
            cout << "0";
        }
        return 0;
    }
    if(a > b) {
        return cout << "0", nl, 0;
    }
    ll c = b - a;
    ll n1 = n - 2;
    ll cnt = n1 * c + 1;
    cout << cnt;
    nl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int i, j, it, now, k, n, dp[5005], a[5005], rs;
long long sum;
 
int main() {
  ios_base::sync_with_stdio(0);
 
  cin >> n >> k;
  for(i = 1; i <= n; ++i) cin >> a[i], sum += a[i];
 
  if(sum < k) return cout << n << '\n', 0;
 
  sort(a + 1, a + n + 1);
 
  int st = 1, dr = n;

  while(st <= dr) {
    it = (st + dr) / 2;
    memset(dp, 0, sizeof(dp));
 
    for(dp[0] = i = 1; i <= n; ++i) {
      if(i == it) continue;
 
      for(j = k; j >= 0; --j)
        if(dp[j] && j + a[i] <= k) dp[j + a[i]] = 1;
    }
 
    for(i = 0; i < k; ++i)
      if(dp[i] && i + a[it] >= k) i = 1e9;
 
    if(i == k) rs = it, st = it + 1;
    else dr = it - 1;
  }
 
  cout << rs << '\n';
 
  return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    h,w = LI()
    a,b = LI()

    return (h-a) * (w-b)


print(main())




Measured memory_bytes: 7364
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }


const int N = 1001, K = 17, inf = 1e9 + 1;
vector<int> g[N];
int x[2][N];
bool f[2][5001];
bool ok = 1;

void dfs(int i, int p) {
  int s = 0;
  fore(e, g[i])if (e != p) {
    dfs(e,i);
    if (!ok)return;
    s += x[0][e] + x[1][e];
  }
  Fill(f[0], 0);
  int c = 0;
  f[0][0] = 1;
  fore(e, g[i])if (e != p) {
    c ^= 1;
    Fill(f[c], 0);
    rep(it, 2) {
      int t = x[it][e];
      FOR(j, 0, x[0][i] - t)f[c][j + t] |= f[!c][j];
    }
  }
  int cur = x[0][i];
  while (cur >= 0 && !f[c][cur])cur--;
  if (cur < 0) {
    ok = 0;
    return;
  }
  x[1][i] = s - cur;

}


void solve() {
  int n, v;
  cin >> n;
  FOR(i, 2, n) {
    cin >> v;
    g[v].push_back(i);
  }
  FOR(i, 1, n)cin >> x[0][i];
  dfs(1, 0);
  if (ok)cout << "POSSIBLE" << ln;
  else cout << "IMPOSSIBLE" << ln;
}


void init() {
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }
  
  
  return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#define N 100000
#define Q 50000
 
int main(){
  int S[N], T[Q], C = 0;
  int left, right, mid, key;
  int n, q, i;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }
 
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
  }
 
  for(i = 0; i < q; i++){
    key = T[i];
    left = 0;
    right = n;
 
    while(left < right){
      mid = (left + right) / 2;
      if(S[mid] == key){
        C++;
        break;
      }
      else if (key < S[mid]){
        right = mid;
      }
      else left = mid + 1;
    }
  }
 
  printf("%d\n", C);
 
  return 0;
}

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

int main() {
    long long N, M;
    cin >> N >> M;
    long long teisyutu_kaisuu = 1LL<<M;
    long long each_time = 1900LL * M + 100LL * (N - M);
    cout <<  each_time * teisyutu_kaisuu << endl;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max({ abs(a - b),abs(b - c),abs(c - a) }) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define mem(x,val) memset(x,val,sizeof(x))
//#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<int,pii>
 
const int mod=1e9+7;
const int N=1e5+10;
const int MAXN=2e6+10;
const int INF=1e18;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int a[N];

string getbase(int x,int b){
    string ans;
    int d;
    while(x){
        d=x%b;
        ans=char('0'+d)+ans;
        x/=b;
    }
    return ans;
}

string L,R;
int d,dp[10010][2][2][101];

int rec(int ind,int tlo,int thi,int rem){
    if(ind>=L.length()){
        if(rem==0){
            return 1;
        }
        return 0;
    }
    if(dp[ind][tlo][thi][rem]==-1){
        int blo=0;
        int bhi=9;
        if(tlo){
            blo=L[ind]-'0';
        }
        if(thi){
            bhi=R[ind]-'0';
        }
        int ans=0;
        for(int i=blo;i<=bhi;i++){
            int ntlo=tlo;
            int nthi=thi;
            if(i>L[ind]-'0'){
                ntlo=0;
            }
            if(i<R[ind]-'0'){
                nthi=0;
            }
            ans+=rec(ind+1,ntlo,nthi,(rem+i)%d);
            ans%=mod;
        }
        dp[ind][tlo][thi][rem]=ans;
    }
    return dp[ind][tlo][thi][rem];
}

void solve(){
    string l,r;
    l="1";
    cin>>r>>d;
    L=l;
    R=r;
    reverse(all(L));
    reverse(all(R));
    while(L.length()<R.length()){
        L+='0';
    }
    while(L.length()>R.length()){
        R+='0';
    }
    reverse(all(L));
    reverse(all(R));
    mem(dp,-1);
    cout<<rec(0,1,1,0)<<endl;
}


int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     //freopen("outputf.in", "w", stdout);
    // #endif
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        solve();
        t1++;
        if(t1>T)
            break;
    }
}



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

int n;

int main()
{
	scanf("%d",&n);
	if ((n&-n)==n) return puts("No"),0;
	printf("Yes\n1 3\n3 2\n2 %d\n%d %d\n%d %d\n",n+1,n+1,n+3,n+3,n+2);
	for (int i=4; i<n; i+=2) printf("%d %d\n%d %d\n%d %d\n%d %d\n",n+1,i,i,i+1,n+1,n+i+1,n+i+1,n+i);
	if (!(n&1)) 
	{
		int m;
		for (int i=16; i>=0; i--) if (n>>i&1) {m=(1<<i); break;}
		printf("%d %d\n%d %d\n",n,m,n+n,(n^m^1)+n);
	}
	return 0;
}

Measured memory_bytes: 2816
//Minimum Spanning Tree

#include<stdio.h>
#define N 100
#define FIR 0
#define SEC 1
#define FIN 2
#define INF 10000

int i,j,n,min,flag,b,sum;
int arr[N][N],state[N],posi[N],point[N];

int work(void)
{
  //initialize numbers
  for(i = 1; i <= n; i++)
    {
      point[i] = INF;
      posi[i] = -1;
      state[i] = FIR;
    }
   point[1] = 0;

   while(1)
     {
       //initialize min
       min = INF;
       flag = -1;

       for(i = 1; i <= n; i++)
	 {
	   if(min > point[i] && state[i] != FIN)
	     {
	       flag = i;
	       min = point[i];
	     }
	 }

       if(flag == -1) break;
       state[flag] = FIN;
       
       for(b = 1; b <= n; b++)
	 {
	   if(state[b] != FIN && arr[flag][b] != INF && point[b] > arr[flag][b])
	     {
	       point[b] = arr[flag][b];
	       posi[b] = flag;
	       state[b] = SEC;
	     }
	 }
       
       sum = 0;
       for(i = 1; i <= n; i++)
	 {
	   if(posi[i] != -1)
	     {
	       sum += arr[i][posi[i]];
	     }
	 }
     }

   return sum;
  
}

int main()
{
  //input data
  scanf("%d",&n);
  for(i = 1; i <= n; i++)
    {
      for(j = 1; j <= n; j++)
	{
	  int weight;
	  scanf("%d",&weight);

	  //initialize weights
	  if(weight == -1) arr[i][j] = INF;
	  else arr[i][j] = weight;
	  
	}
    }

  printf("%d\n",work());

  return 0;
}



Measured memory_bytes: 1956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  ll ans1=a.at(n-1),ans2,q=1e9+7;
  ll p=(ans1+1)/2;
  rep(i,n-1){
    if(q>abs(p-a.at(i))){
      ans2=a.at(i);
      q=abs(p-a.at(i));
    }
  }
  cout << ans1 << " " << ans2;
}

Measured memory_bytes: 4044
let N=Int(readLine()!)!,A=readLine()!.characters.split(" ").map{Int(String($0))!}
var ope=0,ans=1
for i in 1..<N{
  let tmp=A[i]-A[i-1]
  if ope*tmp<0{
    ans++
    ope=0
  }else if tmp != 0{
    ope=tmp
  }
}
print(ans) 

Measured memory_bytes: 6956
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b,x = LI()
    t = x / (a**2)
    if t*2 >= b:
        return abs(math.degrees(math.atan2(b-t,a/2)))

    c = x / a / b * 2
    return abs(math.degrees(math.atan2(b,c)))


print(main())





Measured memory_bytes: 5460
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

ans = 10**9+7

for i in range(N):
    tem = abs(A - (T - H[i]*0.006))
    if tem < ans:
        num = i+1
        ans = tem
        
print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int l , r;
  int x = 0;
  cin >> N;
  // ここにプログラムを追記
  
    for (int i = 0; i < N; i++) {
      cin >> l >> r;
      x = x + ( r - l + 1 );
}
  cout << x << endl;
}

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

#define rep(i, k) for(int i = 0; i < (k); i++)

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);
    for(auto &x : a){
        cin >> x;
    }
    double ans = 0;
    rep(i, a.size()){
        ans += 1.0 / a[i];
    }
    ans = 1.0 / ans;
    printf("%.6f\n", ans);
    return 0;
}

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

long long euk(long long a,long long b){//a,bの最大公約数
  long long c;
  if(b>a){//小さい方をb
    c=a;
    a=b;
    b=c;
  }
  c=a%b;
  if(c==0) return b;
  else return euk(b,c);
}

int main(){
  long long a,b,maxi,r=1;
  cin>>a>>b;
  maxi=euk(a,b);

  vector<long long> divs;
  vector<bool> bl;
  //約数
  for(a=2;a<maxi;a++){
    if(a*a>maxi) break;
    if(maxi%a==0){
      divs.push_back(a);
      bl.push_back(1);
      if(a*a!=maxi){
        divs.push_back(maxi/a);
        bl.push_back(1);
      }
    }
  }

  if(divs.size()==0&&maxi!=1){
    divs.push_back(maxi);
    bl.push_back(1);
  }
  sort(divs.begin(),divs.end());
  for(int i=0;i<divs.size();i++){
    if(bl[i]){
      r++;
      for(int j=i+1;j<divs.size();j++){
        if(divs[j]%divs[i]==0) bl[j]=0;
      }
    }
  }


  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long k = sc.nextLong();
    long ans =0;
    if(k%2==0){
      ans=a-b;
    }else{
      ans=b-a;
    }
    System.out.println(ans);





  }
  

  
}


Measured memory_bytes: 23892
import math
a,b,h,m=map(float,input().split())
h=h*math.pi/6.0
h=h+m/60*math.pi/6.0
m=m*math.pi/30.0
t=min(2*math.pi-abs(h-m),abs(h-m))
c=(a*a+b*b-2*a*b*math.cos(t))**0.5
print(c)

Measured memory_bytes: 9500
while 2 > 1:
    line_num = int(raw_input())
    if line_num < 1:
        break
    mydict = {}
    mydict_distinct = {}
    myIDlist = []
    for n in range(line_num):
        dat = map(int, raw_input().split(" "))
        if dat[0] in mydict_distinct:
            mydict[dat[0]] += dat[1] * dat[2]
        else:
            mydict[dat[0]] = dat[1] * dat[2]
            mydict_distinct[dat[0]] = 1
            myIDlist.append(dat[0])
    flg = 0
    for n in myIDlist:
        if mydict[n] > 999999:
            print n
            flg = 1
    if flg == 0:
        print 'NA'

Measured memory_bytes: 4336
N = gets.to_i
P = gets.split.map(&:to_i)
Q = gets.split.map(&:to_i)

p_num = P.join.to_i
q_num = Q.join.to_i

nums = [*1..N].permutation(N).map { |list| list.join.to_i }.sort

r = nums.bsearch_index { |x| x >= p_num }
l = nums.bsearch_index { |x| x >= q_num }

puts (r - l).abs


Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[101][4][4][4];
signed main(){
  int N;
  cin >> N;
  //長さ0の文字列は一
  //０，１，２に関する制約しかないので
  //Sは、333Sと考えても問題ない
  dp[0][3][3][3]=1;//グローバルにおいてあげると全部0に初期化せれる。
  int mod=1000000000+7;
  //文字列の文字数
  for(int len=0;len<N;len++){

    //最後から1文字目の文字
    for(int c1=0;c1<4;c1++){
      //最後から2文字目の文字
      for(int c2=0;c2<4;c2++){
        //最後から3文字目の文字
        for(int c3=0;c3<4;c3++){
          //条件に当てはまるものがない場合はcontinue;
          if(dp[len][c1][c2][c3]==0) continue;
          //新しく追加する文字
          for(int a=0;a<4;a++){
            if(a==2 && c1==1 && c2==0) continue;
            if(a==2 && c1==0 && c2==1) continue;
            if(a==1 && c1==2 && c2==0) continue;
            if(a==2 && c1==1 && c3==0) continue;
            if(a==2 && c2==1 && c3==0) continue;

            //ダメな条件を抜けたら、aを足した文字列が作れる
            //S=...... c3 c2 c1
            //nextS = ...... c2 c1 a
            dp[len+1][a][c1][c2]+=dp[len][c1][c2][c3];
            dp[len+1][a][c1][c2]%=mod;
          }
        }
      }
    }
  }
  int ans=0;
  //長さNの全体をまとめる
  //最後から1文字目の文字
  for(int c1=0;c1<4;c1++){
    //最後から2文字目の文字
    for(int c2=0;c2<4;c2++){
      //最後から3文字目の文字
      for(int c3=0;c3<4;c3++){
        ans+=dp[N][c1][c2][c3];
        ans%=mod;
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;

    string target_str;
    cin >> target_str;

    int ans = 0;
    int i_c, j_c, k_c;
    for (int i = 0; i < 10; ++i) {
        for (i_c = 0; i_c < n; ++i_c) {
            if (target_str.substr(i_c, 1) == to_string(i)) {
                break;
            }
        }
        for (int j = 0; j < 10; ++j) {
            for (j_c = i_c + 1; j_c < n; ++j_c) {
                if (target_str.substr(j_c, 1) == to_string(j)) {
                    break;
                }
            }
            for (int k = 0; k < 10; ++k) {
                for (k_c = j_c + 1; k_c < n; ++k_c) {
                    if (target_str.substr(k_c, 1) == to_string(k)) {
                        ++ans;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

int n,m;
vector<int> v[100001];
bool vis[100001];
int dis[100001];

void solve()
{
	cin>>n>>m;
	while(m--)
	{
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	for(int i=1;i<=n;i++)
	{
		vis[i]=false;
		dis[i]=0;
	}
	queue<int> q;
	q.push(1);
	vis[1]=true;
	dis[1]=0;
	while(!q.empty())
	{
		int node = q.front();
		q.pop();
		for(auto ch:v[node])
		{
			if(!vis[ch])
			{
				q.push(ch);
				vis[ch]=true;
				dis[ch]=node;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			cout<<"No";return;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++)
		cout<<dis[i]<<endl;
}
 
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 10504
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

def f(k):
    return chr(97+k)

c = 0
i = 1
while True:
    d = c+pow(26,i)
    if c < n <= d:
        break
    c = d
    i+=1

m = n-c-1

ans = ''
while m >= 26:
    ans = f(m%26) + ans
    m = m//26
ans = f(m%26) + ans

ans = 'a'*(i-len(ans)) + ans

print(ans)

Measured memory_bytes: 9204
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n;
  string s;
  readf (" %d\n%s", &n, &s);
  int r, b;
  foreach (i; 0 .. n) {
    if (s[i] == 'R') ++r;
    if (s[i] == 'B') ++b;
  }
  writeln (r > b ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main() {
	int N;
	cin>>N;
	vector<pair<int,int>> res;
	int dame=N;
	if(N%2==1) dame--;

	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			if(j<=i || j==dame) continue;
			res.push_back({i,j});
		}
		dame--;
	}
	cout<<res.size()<<endl;
	for(auto p : res){
		cout<<p.first<<" "<<p.second<<endl;
	}
}

Measured memory_bytes: 384
n = int(input())
abc = [list(map(int, input().split())) for i in range(n)]
a,b,c=abc[0][0],abc[0][1],abc[0][2]
for i in range(1,n):
    a,b,c = abc[i][0]+max(b,c),abc[i][1]+max(a,c),abc[i][2]+max(a,b)
print(max(a,b,c))

Measured memory_bytes: 62552
#include <iostream>
#include <algorithm>
using namespace std;
int P[100];
int main(void){
    int X,N;
    cin >> X >> N;
    for(int i=0;i<N;i++){
        cin >> P[i];
    }
    if(N == 0){
        cout << X << endl;
        return 0;
    }
    
    sort(P,P+N);
    int m = 0;
    int ans = 0;
    for(int i=1;i<=101;i++){
        bool sonzai = false;
        while(P[m] <= i && m < N){
            if(P[m++] == i){
                sonzai = true;
            }
        }
        if(sonzai == false && abs(X-ans) > abs(X-i)){
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
using System;
using System.Text;

namespace ALDS1_8_A {
    class Node {
        public int Key { get; set; }
        public Node Parent { get; set; }
        public Node Left { get; set; }
        public Node Right { get; set; }

        public Node(int key = default(int), Node parent = null) {
            Key = key;
            Parent = parent;
        }
    }

    class Problem {
        private Node _root;
        private StringBuilder _sb;

        public void Run() {
            _sb = new StringBuilder();
            int n = int.Parse(Console.ReadLine());
            SetRoot();
            for (int i = 1; i < n; i++) {
                string[] input = Console.ReadLine().Split(' ');

                switch (input[0]) {
                    case "insert":
                        Insert(int.Parse(input[1]));
                        break;
                    case "print":
                        Inorder(_root);
                        _sb.AppendLine();
                        Preorder(_root);
                        _sb.AppendLine();
                        break;
                }
            }
            Console.Write(_sb);
        }

        private void SetRoot() {
            string[] input = Console.ReadLine().Split(' ');
            _root = new Node(int.Parse(input[1]));
        }

        private void Insert(int key) {
            Node x = _root;
            Node y = null;
            while (x != null) {
                y = x;
                x = key < x.Key ? x.Left : x.Right;
            }
            
            if (key < y.Key)
                y.Left = new Node(key, parent: y);
            else
                y.Right = new Node(key, parent: y);
        }

        private void Inorder(Node node) {
            if (node == null)
                return;
            Inorder(node.Left);
            _sb.Append(" " + node.Key);
            Inorder(node.Right);
        }

        private void Preorder(Node node) {
            if (node == null)
                return;
            _sb.Append(" " + node.Key);
            Preorder(node.Left);
            Preorder(node.Right);
        }
    }

    class Program {
        static void Main(string[] args) {
            Problem p = new Problem();
            p.Run();
        }
    }
}

Measured memory_bytes: 84552
#include<bits/stdc++.h>
// five elements

#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rev(i, s, n) for (int i = s; i > n; i = i - 1)
using namespace std;
#define fr first
#define se second
#define pb push_back
#define mp make_pair
#define mv vector<ll>
#define vii vector<pair<ll, ll>>
// akane_psycho
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define c1(a) cout << a << endl;
#define c2(a, b) cout << a << " " << b << endl;
#define inf 1e18
#define mod 1000000007
#define ii pair<ll,ll>
#define sw(v)      cout << endl;                                                                \
  for(auto u:v) {cout << u << " ";}                                     \
  cout << endl;
  
  /*
  ll ml(ll a, ll b){
  	return ( (a%mod)*(b%mod) )%mod;
  }
ll fp(ll num,ll g)
{
    if(g==0)return 1;
    if(g%2==1)return ml(num,fp(ml(num,num) ,g/2) );
    return fp( ml(num,num),g/2);
}
ll d(ll a, ll b) {//a/b
	return a*fp(b, mod - 2) % mod;
}
ll pm(ll f[] , ll n, ll r){
	return d(  f[n] , f[n-r] );
}
ll cm(ll f[] , ll n , ll r ){
		return d( f[n] , ml( f[r],f[n-r] ) );
	}
*/
ll val( ll a, ll b , ll x){
	
	return (a*x)/b - a*(x/b);
}

int main(){
	ll n,k;cin>>n>>k;
	set<ll> w;
	rep(i,0,n){
	ll d;cin>>d;
		rep(j,0,d){
			ll p;cin>>p;w.insert(p);
		}
	}
	c1( n- (ll)w.size() )
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    map<ll, ll> mp;
    ll ans=0;
    for(int i=0; i<n; i++){
        ll a; cin>>a;
        mp[a]++;
        ans+=a;
    }
    int q; cin>>q;
    for(int i=0; i<q; i++){
        ll b, c;
        cin>>b>>c;
        auto itr=mp.find(b);
        if(itr!=mp.end()){
            ll x=itr->second;
            mp.erase(itr);
            ans-=b*x;
            ans+=c*x;
            mp[c]+=x;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  long long S = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    S += a;
    A.at(i) = a;
  }
  vector<long long> X(N);
  long long tmp = 0;
  for (int i = 1; i < N; i += 2) {
    tmp += A.at(i);
  }
  X.at(0) = S - 2*tmp;
  for (int i = 1; i < N; i++) {
    X.at(i) = 2*A.at(i-1) - X.at(i-1);
  }
  for (int i = 0; i < N-1; i++) cout << X.at(i) << " ";
  cout << X.at(N-1) << endl;
}


Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<algorithm>
#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0
using namespace std;

struct Item {
  int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

void compute(int &maxValue, vector<int> &selection) {
  for (int w = 0; w <= W; w ++) {
    C[0][w] = 0;
    G[0][w] = DIAGONAL;
  }
  for (int i = 1; i <= N; i ++) C[i][0] = 0;

  for (int i = 1; i <= N; i ++) {
    for (int w = 1; w <= W; w ++) {
      C[i][w] = C[i - 1][w];
      G[i][w] = TOP;
      if (items[i].weight > w) continue;

      if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
        C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
        G[i][w] = DIAGONAL;
      }
    }
  }

  maxValue = C[N][W];
  selection.clear();
  for (int i = N, w = W; i >= 1; i --) {
    if (G[i][w] == DIAGONAL) {
      selection.push_back(i);
      w -= items[i].weight;
    }
  }

  reverse(selection.begin(), selection.end());
}

void input() {
  cin >> N >> W;
  for (int i = 1; i <= N; i ++) {
    cin >> items[i].value >> items[i].weight;
  }
}

int main() {
  int maxValue;
  vector<int> selection;
  input();
  compute(maxValue, selection);

  cout << maxValue << endl;
}


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

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

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

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

int main() {
  int s, w;
  cin >> s >> w;
  if (s <= w)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    string S,T;
    int A,B;
    cin>>S>>T;
    cin>>A>>B;
    string U;
    cin>>U;
    if(S==U){
        A--;
    }
    else B--;

    cout<<A<<" "<<B;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

int n,k,count=0,a;
cin >> n >> k;


while(n-->0)
{
	cin >> a;
	if(a>=k)
	{
		  count++;
	}
}

cout << count << endl;
	return 0;
}











Measured memory_bytes: 3180