akhauriyash/Code-Regression huggingface dataset:
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    const inputNum1 = input[0].split(" ").map(x => parseInt(x, 10));
    const inputNum2 = input[1].split(" ").map(x => parseInt(x, 10));

    const H = inputNum1[0];
    const W = inputNum1[1];
    const h = inputNum2[0];
    const w = inputNum2[1];
    // 全マス数はH * W
    const tileCount = H * W;
    // 残るマス数はh * W + w * H - h * w
    const whiteTile = tileCount - (h * W + w * H - h * w);
    console.log(whiteTile);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    for(int i=sqrt(n);i>=1;i--){
        if(n%i==0){
            int t=i,l=n/i;
            int s=1;
            while(l>=10){
                s++;
                l/=10;
            }
            cout<<s;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i; i < n; i++) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll MOD=998244353;
const int MAX=100010;

vector<vector<ll> >G(MAX);

ll cnt;
ll dfs(ll i,ll p){
    ll res=0;
    for(auto e:G[i]){
        if(e==p)continue;
        res+=(dfs(e,i)>0);
    }
    ll d=G[i].size();
    ll z=1;
    if(p>=0)z++;
    d-=z;
    if(d>res){
        cnt+=d-res;
        res=d;
    }
    return res;
}

signed main(){
    ll n;cin>>n;
    vector<ll>d(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
        d[a]++;
        d[b]++;
    }
    ll idx=-1;
    vector<ll>dist(n,-1);
    queue<ll>q;
    dist[0]=0;
    q.push(0);
    ll ma=0;
    while(!q.empty()){
        ll k=q.front();
        q.pop();
        for(auto e:G[k]){
            if(dist[e]>=0)continue;
            dist[e]=dist[k]+1;
            ma=max(ma,dist[k]+1);
            q.push(e);
        }
    }
    rep(i,n){
        if(dist[i]==ma)idx=i;
    }
    cnt=1;
    dfs(idx,-1);
    cout<<cnt<<endl;
}

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

using int64 = long long;

int main() {
	string str;
	while (true) {
		cin >> str;
		if (str == "0000") break;

		int cnt = 0;
		while (true) {
			if (str == "6174") {
				cout << cnt << endl;
				break;
			}
			if (str[0] == str[1] && str[1] == str[2] && str[2] == str[3]) {
				cout << "NA" << endl;
				break;
			}
			cnt++;
			string L = str;
			sort(L.rbegin(), L.rend());
			sort(str.begin(), str.end());

			int nl = stoi(L);
			int ns = stoi(str);


			int res = nl - ns;
			str = to_string(res);
			if (str.size() < 4) {
				for (int i = 1; i + str.size() <= 4; ++i) str.insert(str.begin(), '0');
			}
		}
	}
}


Measured memory_bytes: 3260
use std::collections::VecDeque;

const MOD: u64 = 1e9 as u64 + 7;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let l: u64 = sc.read();
    let r: u64 = sc.read();

    let mut dp = vec![0; 1 << 3];
    dp[0] = 1;
    for i in (0..63).rev() {
        let r = (r >> i) & 1;
        let l = (l >> i) & 1;
        let mut next = vec![0; 1 << 3];
        for mask in 0..(1 << 3) {
            let started = mask & 1 == 1;
            let lower_than_r = (mask >> 1) & 1 == 1;
            let greater_than_l = (mask >> 2) & 1 == 1;

            for next_x in 0..2 {
                for next_y in 0..2 {
                    if next_x > next_y {
                        continue;
                    }
                    if !started && next_y == 1 && next_x == 0 {
                        continue;
                    }
                    if !lower_than_r && next_y > r {
                        continue;
                    }
                    if !greater_than_l && next_x < l {
                        continue;
                    }

                    let next_started = if started || next_y == 1 { 1 } else { 0 };
                    let next_lower_than_r = if lower_than_r || r > next_y { 1 } else { 0 };
                    let next_greater_than_l = if greater_than_l || next_x > l { 1 } else { 0 };
                    let next_mask =
                        next_started + (next_lower_than_r << 1) + (next_greater_than_l << 2);
                    next[next_mask] += dp[mask];
                    next[next_mask] %= MOD;
                }
            }
        }
        dp = next;
    }

    let mut ans = 0;
    for mask in 0..(1 << 3) {
        if mask & 1 == 1 {
            ans += dp[mask];
        }
    }

    println!("{}", ans % MOD);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

const double EPS = 0.00000001;

int main(){
    int n;
    while(cin >> n, n){
        int str[n];
        for(int i = 0; i < n; i++)  cin >> str[i];

        int x, y, z;
        double score = DBL_MAX;
        for(int s = 0; s <= 15; s++){
            for(int a = 0; a <= 15; a++){
                for(int c = 0; c <= 15; c++){
                    int r[n+1];
                    r[0] = s;
                    for(int i = 1; i < n+1; i++)  r[i] = (a*r[i-1]+c)%256;

                    int ap[256] = {};
                    for(int i = 0; i < n; i++)  ap[(str[i]+r[i+1])%256]++;

                    double tmp = 0;
                    for(int i = 0; i < 256; i++){
                        if(ap[i] == 0)  continue;
                        double ratio = (double)ap[i]/n;
                        tmp += -ratio * log(ratio);
                    }

                    if(tmp+EPS < score) score = tmp, x = s, y = a, z = c;
                }
            }
        }

        cout << x << " " << y << " " << z << endl;
    }
    return 0;
}


Measured memory_bytes: 3408
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	if(N%111 == 0) {
	    System.out.println(N);
	    return;
	}
	int num = N/111+1;
	System.out.println(num*100+num*10+num);
    }
}

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

int main() {
	int D, C[26];
	cin >> D;
	for (int i = 0; i < 26; i++) cin >> C[i];
	vector<int> L(26, -1);
	vector<vector<int> > S(D, vector<int>(26));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) cin >> S[i][j];
	}
	for (int i = 0; i < D; i++) {
		int MAX = -10000000, ID = -1;
		for (int j = 0; j < 26; j++) {
			if (MAX < S[i][j]) MAX = S[i][j] - C[j] * (i - L[j]), ID = j;
		}
		L[ID] = i;
		cout << ID + 1 << endl;
	}
}

Measured memory_bytes: 3696
def main():
    n = int(input())
    a = [int(input()) for _ in range(5)]
    if not [i for i in a if i < n]:
        print(5)
        return
    b = n / min(a)
    if int(b) != b:
        b = int(b) + 1
    else:
        b = int(b)
    print(b + 4)


main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
double w[2][44];
double s[44];
int r;
int n;
int x1, x2, h;
double nkr;
double a[3];

main(){
	while (cin >> r >> n, r || n){
		nkr = -1;
		for (int i = 0; i<2; i++)for (int j = 0; j<44; j++) w[i][j] = 0;

		for (int i = 0; i<n; i++){
			cin >> x1 >> x2 >> h;

			if (w[0][x2 + 20]<h || w[0][x2 + 20] == 0) w[0][x2 + 20] = h;
			if (w[1][x1 + 20]<h || w[1][x1 + 20] == 0) w[1][x1 + 20] = h;
			for (int j = x1 + 21; j<x2 + 20; j++){
				if (w[0][j]<h || w[0][j] == 0) w[0][j] = h;
				if (w[1][j]<h || w[1][j] == 0) w[1][j] = h;
			}

		}

		nkr = w[1][20 - r] + r;
		for (int i = r*(-1) + 1; i<r; i++){
			s[i + 20] = sqrt(r*r - i*i) - r;
			if (w[0][i + 20] - s[i + 20]<nkr) nkr = w[0][i + 20] - s[i + 20];
			if (w[1][i + 20] - s[i + 20]<nkr) nkr = w[1][i + 20] - s[i + 20];
		}
		if (w[0][20 + r] + r<nkr) nkr = w[0][20 + r] + r;



		printf("%.4f\n", nkr);
	}
}

Measured memory_bytes: 3160
N = int(input())
blue = [input() for i in range(N)]
M = int(input())
red = [input() for i in range(M)]
blue_only = []

max_get = 0
for i in range(N):
    if blue[i] in red:
        get = blue.count(blue[i]) - red.count(blue[i])
    else:
        get = blue.count(blue[i])
    if get > max_get:
        max_get = get

print(max_get)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll prev = A[0];
    ll ans = 0;
    rep(i, N){
        if(!i){
            if(A[i] != 0) drop(-1);
            continue;
        }
        if(A[i] - prev == 1) ++ans;
        else if(A[i] - prev <= 0) ans += A[i];
        else drop(-1);

        prev = A[i];
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 1792
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; putInts [a*b, 2*(a+b)]
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3580
# diverta2019-2B - Picking Up
def main():
    n = int(input())
    arr = sorted(tuple(map(int, input().split())) for _ in range(n))
    cnt = {}
    for i in range(n):
        for j in range(i + 1, n):
            dif = (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])
            cnt.setdefault(dif, 0)
            cnt[dif] += 1
    print(n - max(cnt.values(), default=0))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> s(n); REP(i, n) cin >> s[i];
  vector<vector<bool> > score(n + 1, vector<bool>(100 * n + 1, false));
  score[0][0] = true;
  REP(i, n) REP(j, 100 * i + 1) {
    if (score[i][j]) score[i + 1][j] = score[i + 1][j + s[i]] = true;
  }
  for (int j = 100 * n; j > 0; --j) if (j % 10 != 0) {
    if (score[n][j]) {
      cout << j << '\n';
      return 0;
    }
  }
  cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 384
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf 1e11
#define hahaha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;
int dp[N];

signed main()
{
    hahaha
    
    fill(dp+1,dp+N,inf);
    
    int n,W;
    cin>>n>>W;
    int w,v,i,j;
    for(i=1;i<=n;++i)
    {
        cin>>w>>v;
        for(j=N-3;j>=0;--j)
        {
            if(j-v>=0)
                dp[j]=min(dp[j],dp[j-v]+w);
        }
    }
    
    for(j=N-3;j>=0;--j)
    {
        if(dp[j]<=W)
        {
            cout<<j;
            return 0;
        }
    }
    
        
    return 0;
}


Measured memory_bytes: 1024
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int x,y;
  cin >> x >> y;
  cout << x + y / 2;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

const int MAX_V = 1000000;
int prime[MAX_V+1];

int main()
{
	int i, k, v;
	int input;

	for(i = 2; i <= MAX_V; i++)
	{
		prime[i] = 1;
	}
	
	for(i = 2; i*i <= MAX_V; i++)
	{
		if(prime[i])
		{
			for(k = 2 * i; k <= MAX_V; k += i)
			{
				prime[k] = 0;
			}
		}
	}

	for (i = 0; ; ++i)
	{
		cin >> input;
		if (input == 0) break;

		for (v = input; v != 0; --v)
		{
			if (prime[v] && prime[v - 2])
			{
				cout << v - 2 << " " << v << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 6964
n1 = gets.split.map(&:to_i)
n2 = gets.split.map(&:to_i)

score1 = 0
score2 = 0
n1.each do |v|
	score1 += v
end

n2.each do |v|
	score2 += v
end

if score1>score2
	puts score1
else
	puts score2
end

Measured memory_bytes: 8600
#include <bits/stdc++.h>
#define inf 1e9

using namespace std;

typedef long long ll;
typedef long double ld;

ll V[200005], A[200005], rght, n, nr;

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

    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>A[i];
        V[A[i]] = i;
    }

    rght = inf;
    for (int i=1; i<=n; i++)
    {
        int poz = V[i];
        if (poz < rght)
        {
            nr++;
            rght = poz;
        }
    }
    cout<<nr;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n, m;
    cin>>n>>m;
    int a[n], tot = 0;
    f(i, n) {
        cin>>a[i];
        tot += a[i];
    }
    int to = (tot + 4 * m - 1)/(4 * m);
    int cnt = 0;
    f(i, n) {
        if(a[i] >= to) cnt++;
    }
    if(cnt >= m) cout<<"Yes\n";
    else cout<<"No\n";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int tests = 1; tests <= t; tests++) {
        //cout<<"Case #"<<tests<<": ";
        solve();
    }
    return 0;
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

const int MOD=1e9+7;
int n;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    cin >> n;
    ll cc=1;

    FORN(i,1,n){
    	cc=(cc*i)%MOD;
    }

    cout << cc%MOD << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

using b = bitset<6400 * 2 + 64>;


int main() {
	ll H, W;
	vector<vector<b>> f;
	vector<vector<ll>> a, b;
	cin >> H >> W;
	f.resize(H);
	a.resize(H);
	b.resize(H);
	REP(i, 0, H) {
		f[i].resize(W);
		a[i].resize(W);
		REP(j, 0, W) {
			f[i][j].reset();
			cin >> a[i][j];
		}
	}
	REP(i, 0, H) {
		b[i].resize(W);
		REP(j, 0, W) {
			cin >> b[i][j];
		}
	}
	int i0 = 6400;
	f[0][0][i0 + b[0][0] - a[0][0]] = true;
	f[0][0][i0 - b[0][0] + a[0][0]] = true;
	auto bs = [](auto& b, int d) {
		if (d >= 0) return b << d;
		else return b >> -d;
	};
	REP(j, 1, W) f[0][j] = bs(f[0][j - 1], b[0][j] - a[0][j]) | bs(f[0][j - 1], -b[0][j] + a[0][j]);
	REP(i, 1, H) f[i][0] = bs(f[i - 1][0], b[i][0] - a[i][0]) | bs(f[i - 1][0], -b[i][0] + a[i][0]);
	REP(i, 1, H)REP(j, 1, W) {
		f[i][j] = bs(f[i][j - 1], b[i][j] - a[i][j]) | bs(f[i - 1][j], b[i][j] - a[i][j]);
		f[i][j] |= bs(f[i][j - 1], -b[i][j] + a[i][j]) | bs(f[i - 1][j], -b[i][j] + a[i][j]);
	}
	for (int i = 0; i <= 6400; ++i) {
		if (f[H - 1][W - 1][i0 + i] || f[H - 1][W - 1][i0 - i]) {
			PRI(i);
			return 0;
		}
	}
	return 0;
}




Measured memory_bytes: 13808
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <cmath>      // sqrt
#include <cstdlib>    // exit
#include <algorithm>  // min,max
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 1
typedef pair<int,int> pii;

#define MAXN 100001
bool markx[MAXN];
bool marky[MAXN];
vector< set<int> > x2y;
vector< set<int> > y2x;

void dfsx(set<pii> *pst, int x, int y);

void dfsy(set<pii> *pst, int x, int y) {
  pst->insert(pii(x,y));
  for (int xx: y2x[y]) {
    if (markx[xx]) continue;
    markx[xx] = true;
    dfsx(pst, xx, y);
  }
}

void dfsx(set<pii> *pst, int x, int y) {
  pst->insert(pii(x,y));
  for (int yy: x2y[x]) {
    if (marky[yy]) continue;
    marky[yy] = true;
    dfsy(pst, x, yy);
  }
}

int main() {
  int n;
  cin >> n;
  x2y.resize(MAXN);
  y2x.resize(MAXN);
  vector<pii> xys(n);
  forr(i,0,n-1) {
    int x,y;
    cin >> x >> y;
    x -= 1;
    y -= 1;
    x2y[x].insert(y);
    y2x[y].insert(x);
    xys[i] = pii(x,y);
  }

  long long sum = 0;
  for (pii xy: xys) {
    int x = xy.first;
    int y = xy.second;
    if (markx[x] || marky[y]) continue;
    if (x2y[x].size()>1 && y2x[y].size()>1) {
      set<pii> st;
      st.insert(pii(x,y));
      markx[x] = marky[y] = true;
      for (int yy: x2y[x]) dfsy(&st, x,yy);
      for (int xx: y2x[y]) dfsx(&st, xx,y);
      set<int> setx;
      set<int> sety;
      for (pii xy: st) {
        setx.insert(xy.first);
        sety.insert(xy.second);
      }
      ////sum += setx.size() * sety.size() - st.size();
      //for (int x: setx)
      //  for (int y: sety)
      //    if (x2y[x].find(y) == x2y[x].end())
      //      sum += 1;
      int sum2 = 0;
      for (pii xy2: xys) {
        int xx = xy2.first;
        int yy = xy2.second;
        if (setx.find(xx) != setx.end() && sety.find(yy) != sety.end())
          sum2++;
      }
      sum += setx.size() * sety.size() - sum2;
    }
  }

  cout << sum << endl;

}


Measured memory_bytes: 35584
#include <iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <algorithm>
#include <cstring>
#include<queue>
#include <stack>
#include<map>
#include<vector>
using namespace std;

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    if(w>h){
        int t=w;
        w=h;
        h=t;
    }
    if(n%h==0){
        cout<<n/h<<endl;
    }else{
        cout<<n/h+1<<endl;
    }
    return 0;
}



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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define endl "\n"

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define ALL(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.k << ", " << p.v << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = n; 0 <= i; i--) {
        if (s.find(t.substr(0, i)) != string::npos) {
            cout << n + (n - i) << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
}


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

int main(){
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    double sq = (double)W * H;
    int flag = 0;
    double max;
    if((double)W / 2 == x && (double)H / 2 == y) flag = 1;
    max = sq / 2;
    cout << max << " " << flag << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
    int xco;
    int yco;
    int num;
} stPoint;

typedef struct{
    int dist;
    int num;
}stDist;

int ads(int n)
{
    return (n > 0) ? n : -n;
}

int main()
{
    int n;  scanf("%d", &n);
    int m;  scanf("%d", &m);

    stPoint human[n];
    int i;
    for(i = 0; i < n; i++){
        scanf("%d%d", &human[i].xco, &human[i].yco);
        human[i].num = i + 1;
    }

    stPoint checkp[m];
    for(i = 0; i < m; i++){
        scanf("%d%d", &checkp[i].xco, &checkp[i].yco);
        checkp[i].num = i + 1;
    }

    stDist Dist = {0};
    stDist tmp;
    int j;
    for(i = 0; i < n; i++){
        Dist.dist = ads(human[i].xco - checkp[0].xco)
                + ads(human[i].yco - checkp[0].yco);
        Dist.num = 1;

        for(j = 1; j < m; j++){
            tmp.dist = ads(human[i].xco - checkp[j].xco)
                    + ads(human[i].yco - checkp[j].yco);
            tmp.num = j + 1;
            if(tmp.dist < Dist.dist){
                Dist = tmp;
            }
        }
        printf("%d\n", Dist.num);
    }

    return 0;
}

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

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

//     vector<int> height;
//     vector<int> cost;
//     for (int i = 0;i < n; i++) {
//         cin >> height[i];
//     }

//     cost[0] = height[0];
//     cost[1] = height[1];

//     for (int i = 2; i < n; i++) {
//         cost[i] = min(cost[i-1] + abs(height[i] - height[i-1]), cost[i-2] + abs(height[i] - height[i-2]));
//     }
    
//     cout << cost[n-1] << endl;
//     return 0;
// }

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

    int h1, h2, h3;
    int c1, c2, c3;

    cin >> h1 >> h2;
    c1 = 0; c2 = abs(h2-h1); c3 = c2;

    for (int i = 2; i < n; i++) {
        cin >> h3;
        // cost[i] = min(cost[i-1] + abs(height[i] - height[i-1]), cost[i-2] + abs(height[i] - height[i-2]));
        c3 = min (c2 + abs(h3 - h2), c1 + abs(h3 - h1));
        c1 = c2; c2 = c3;
        h1 = h2; h2 = h3;
    }
    
    cout << c3 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i *= 2) ans = i;
  out(ans);
}
int main(void) { solve(); }

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass {
  public static void Main (string[] args) {
    //入力
    var N = long.Parse(Console.ReadLine());
    var ans = (long)1;
    //処理
    for(var i = 1; i <= N; i++){
      ans = i * ans % (long)(Math.Pow(10, 9) + 7);
    }

    //出力
    Console.WriteLine(ans);
  }
 
}   


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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

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

	int H,W,h,w;
	cin>>H>>W>>h>>w;
	cout << (H-h)*(W-w) << endl;

	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>


#define deb(x,y) cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   " << #x << ':' << x <<" ###### "<< y <<"\n";
#define ll long long  


using namespace std;

int main(){

	//freopen("input.txt","r",stdin);

	string a;

	cin>>a;

	if(a.at(0)==57 || a.at(1)==57){
	cout<<"Yes";
	}
	else{
	cout<<"No";
	}

}



Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val k = sc.nextLong()
  val a = sc.nextLong()
  val b = sc.nextLong()

  val kMax = 1 + k

  val tmp = Math.max(0, (k-(a-1L))/2L)
  val tmpMax = (b-a) * tmp + (k-tmp * 2) + 1


  val max = Math.max(kMax, tmpMax)
  println(max)
}

Measured memory_bytes: 36404
#include <stdio.h>

int main(void){
  
 int a, b;
  
  scanf("%d %d", &a, &b);
  if(a != 1 && b!= 1){
    printf("1\n");
  }
  else if(a != 2 && b!= 2){ 
   printf("2\n");
  }
  else{
    printf("3\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
 
    int x,y;
    cin >> x >> y;
 
    int a=((4*x)-y)/2;
    int b=(y-(2*x))/2;
 
    if ((a<0)||(b<0))
    {
        cout << "No" << endl;
        return 0;
    }
 
    if (((a+b)==x)&&(((2*a)+(4*b))==y))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3628
/* 
 Author:N_o_o_B 
 Created:November 19 2019 13:53:00
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int r;
    cin >> r;
    cout << r*r << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const ut INF=1LL<<30;
const int SIZE=5+2*1e5;
int N;
int nums[SIZE];
int pos[SIZE];
class UnionFind{
public:
	vector<int> unions,talls,sents,dists,sizes;
	int size;
	UnionFind(){}
	UnionFind(int size):size(size){
		init();
	}
	void init(){
	 	unions=vector<int>(size);
	 	talls=vector<int>(size);
	 	sents=vector<int>(size);
	 	dists=vector<int>(size);
	 	sizes=vector<int>(size);
		FOR(i,0,size){
			unions[i]=i;
			sents[i]=0;
			sizes[i]=1;
//			ns[i].PB(pr(0,1));
			talls[i]=1;
		}
	}
	int find(int x,int t=0){
		if(unions[x]==x || sents[x]>t) return x;
		return find(unions[x],t);
 
	}
	int minisize(int x){
		if(x==unions[x]) return sizes[x];
		return minisize(find(x));
	}
	bool isFriend(int a,int b,int t=0){
		return find(a,t)==find(b,t);	
	}
	void unite(int a,int b,int t=0){
		if(isFriend(a,b,t)) return;
		a=find(a,t);
		b=find(b,t);
		if(talls[a]<talls[b]) unite(b,a,t);
		else{
 			sizes[a]+=sizes[b];
			sents[b]=t;
			talls[a]=max(talls[a],talls[b]+1);
			unions[b]=a;
			dists[b]=1;
//			ns[a].PB(pr(t,ns[b].back().second+ns[a].back().second));
		}
	}
};

UnionFind uf;
int main(){
	cin >> N;

	uf=UnionFind(N);
	REP(i,N){
		cin >> nums[i];
		pos[nums[i]]=i;
	}
	LL ans=0;
	REP(i,N){
		LL next=N-i;
		int npos=pos[next];
		LL left=1,right=1;
		if(npos+1<N && nums[npos+1]==0) right+=uf.minisize(npos+1);
		if(npos && nums[npos-1]==0) left+=uf.minisize(npos-1);
		ans+=right*left*next;
		nums[npos]=0;
		if(npos+1<N && nums[npos+1]==0) uf.unite(npos+1,npos);
		if(npos && nums[npos-1]==0) uf.unite(npos-1,npos);
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

using namespace std;

int main() {
    int N, M, A[100], sum = 0;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {;
        cin >> A[i];
        sum += A[i];
    }
    sort(A, A + N);
    reverse(A, A + N);
    int count = 0;
    for (int i = 0; i < N; i++) {;
        if (A[i] >= sum / (double)(4 * M)) {
            count++;
        }
    }
    if (M <= count) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=5005;
#define ll long long
bitset < N > b;
int a[N];
int n,m;
inline bool check(int x){
	b.reset(),b[0]=1;
	for (int i=1;i<=n;i++)
		if (i!=x&&a[i]<=m) b|=(b<<a[i]);
	for (int i=max(0,m-a[x]);i<m;i++)
		if (b[i]) return false;
	return true;
}
int main (){
	scanf ("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf ("%d",&a[i]);
	sort(a+1,a+n+1);
	int l=0,r=n,ans=0;
	while (l<=r){
		int mid=(l+r)>>1;
		if (check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf ("%d",ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
c = list(input())

r = c.count("R")
g = c.count("G")
b = c.count("B")

ans = r*g*b
count  = 0
sub1 = 0

for i in range(n):
    for j in range(i+1,n):
        if 2*j-i >= n or 2*j-i <0:
            break
        elif c[2*j-i] != c[i] and c[i] != c[j] and c[2*j-i] != c[j]:
                sub1 += 1


print(ans-sub1)


Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <stack>

using namespace std;
long long a[100001];
int n, k;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	long long ans = a[k - 1] - a[0];
	for (int i = k; i < n; i++) {
		ans = min(ans, a[i] - a[i - k + 1]);
	}
	cout << ans << '\n';

}

Measured memory_bytes: 1024
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

long long n;
long long k;
long long ar[N];

bool cmp(pair < int , int > a , pair < int , int > b){
     if(a.first < b.first)
        return 1;
     if(a.first == b.first){
        return a.second < b.second;
     }
     return 0;
}

int cnt[111];

void add(long long x){
     for(long long i = 0; i <= 50; i++){
         cnt[i] += ((x & (1ll << i)) == 0);
     }
}

int main(){
    scanf("%lld%lld" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%lld" , &ar[i]);
        add(ar[i]);
    }
    long long x = 0;
    for(int i = 50; i >= 0; i--){
        if(cnt[i] > n - cnt[i] && x + (1ll << i) <= k){
            x += (1ll << i);
        }
    }
    long long finl = 0;
    for(int i = 1; i <= n; i++){
        finl += ar[i] ^ x;
    }
    printf("%lld\n" , finl);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    string s;
    cin>>s;
    int n=sl(s),i;
    fr(i,n)
    {
        if(s[i]=='?')
            s[i]='D';
    }
    cout<<s;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);

  int ans = 1e9;

  for (int i = 0; i <= N - K; i++) {
    int tmp, j = i + K - 1;
    if (vec.at(j) <= 0) tmp = abs(vec.at(i));
    else if (vec.at(i) >= 0) tmp = vec.at(j);
    else tmp = min(abs(vec.at(i)), vec.at(j)) + vec.at(j) - vec.at(i);
    ans = min(ans, tmp);
  }

  cout << ans << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}
int n,m;
vector<vector<int>> adjlist;
int dp[100005];

int dfs(int node) {
    int ans = 0;
    if (dp[node])
        return dp[node];
    for (int x: adjlist[node]) {
        ans = max(ans, dfs(x) + 1);
    }
    return dp[node] = ans;
}

int main() {
    IO;
    cin >> n >> m;
    adjlist.resize(n);
    for (int i = 0; i < m; i++) {
        int x,y;
        cin >> x >> y;
        x--,y--;
        adjlist[x].push_back(y);
    }
    int ans = 0;
    for (int i = 0;i < n; i++)
        ans = max(ans, dfs(i));
    cout << ans;
    return 0;
}


Measured memory_bytes: 8192
import sys
input = sys.stdin.readline

N=int(input())
POINT=[list(map(int,input().split())) for i in range(N)]
mod=998244353

compression_dict_x={a: ind for ind, a in enumerate(sorted(set([p[0] for p in POINT])))}
POINT=[[compression_dict_x[x]+1,y] for x,y in POINT]
P_Y=sorted(POINT,key=lambda x:x[1])

# BIT(BIT-indexed tree)

LEN=len(compression_dict_x)

BIT=[0]*(LEN+1)# 1-indexedなtree

def update(v,w):# vにwを加える
    while v<=LEN:
        BIT[v]+=w
        v+=(v&(-v))# 自分を含む大きなノードへ. たとえばv=3→v=4

def getvalue(v):# [1,v]の区間の和を求める
    ANS=0
    while v!=0:
        ANS+=BIT[v]
        v-=(v&(-v))# 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ
    return ANS

ANS= 4*N+(pow(2,N,mod)-1)*(N-4)%mod

for i in range(N):
    x,y=P_Y[i]
    left=getvalue(x)
    ANS=(ANS+pow(2,left,mod)+pow(2,i-left,mod)-2)%mod
    update(x,1)

P_Y.reverse()
BIT=[0]*(LEN+1)

for i in range(N):
    x,y=P_Y[i]
    left=getvalue(x)
    ANS=(ANS+pow(2,left,mod)+pow(2,i-left,mod)-2)%mod
    update(x,1)

print(ANS)


Measured memory_bytes: 126848
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

using namespace std;

int main()
{
    int x[100],y[100],N,W,H,a[100],S;
    int c1,c2,d1,d2,c,d;
    cin >> W >> H >> N;
    for(int i = 0;i<N;i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    d1=0,c1=0,c2 = W,d2 = H;
    for(int i = 0;i<N;i++){
        if(a[i]==1){
            c1 = max(x[i],c1);
        }
        if(a[i]==2){
            c2 = min(x[i],c2);
        }
        if(a[i]==3){
            d1 = max(y[i],d1);
        }
        if(a[i]==4){
            d2 = min(y[i],d2);
        }
    }
    if(c1>=c2 || d1>=d2){
        S=0;
    }else{
        c = c2 - c1;
        d = d2 - d1;
        S = c*d;
    }
    cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math

N,H = map(int,input().split(" "))
a = []
b = []
for i in range(N):
    temp_a,temp_b = map(int,input().split(" "))
    a.append(temp_a)
    b.append(temp_b)
a.sort(key=None,reverse=True)
b.sort(key=None,reverse=True)
ans = 0


b2 = filter(lambda x: x>a[0],b)
b2 = list(b2)
#print(b2)
for i in range(len(b2)):
    H -= b[i]
    ans += 1
    if H<=0:
        print(ans)
        sys.exit() 
#print(H)
ans += math.ceil(H/a[0])
print(ans)


Measured memory_bytes: 12024
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int R;
    cin >> R;
    cout << 2 * R * 3.141592 << endl;
}

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


using namespace std;


bool yaki_check(string s)
{
  if (s.length() < 4){
    return false;
  }
  string t("YAKI");
  for (int i=0; i<4; i++){
    if (s[i] != t[i]){
      return false;
    }
  }
  return true;
}

int main()
{
  string s;

  cin >> s;

  if (yaki_check(s)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
h, w = (int(x) for x in input().split())
a = [[0 if x == "." else 1 for x in input()] for _ in range(h)]
l = []
for i in range(h):
    if sum(a[i][:]) == 0: l.append(i)
if len(l) != 0:
    l = l[::-1]
    for l_i in l:
        a.pop(l_i)
l = []
for i in range(w):
    s = 0
    for j in range(len(a)):
        s += a[j][i]
    if s == 0: l.append(i)
if len(l) != 0:
    l = l[::-1]
    for l_i in l:
        for i in range(len(a)):
            a[i].pop(l_i)
ans = [["#" if int(x) == 1 else "." for x in a[i]] for i in range(len(a))]
for ans_i in ans:
    print("".join(ans_i))

Measured memory_bytes: 3188