akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

string s;
int k;

ll memo[110][5][2];
ll f(int i, int cnt, bool less)
{
  if (memo[i][cnt][less] != -1)
    return memo[i][cnt][less];
  if (cnt >= 4)
    return 0;
  if (i == s.length())
    return (cnt == k);

  ll res = 0;
  if (less)
  {
    res += f(i + 1, cnt, true);
    res += 9 * f(i + 1, cnt + 1, true);
  }
  else
  {
    if (s[i] == '0')
    {
      res += f(i + 1, cnt, false);
    }
    else
    {
      res += f(i + 1, cnt, true);
      for (int j = 1; j < s[i] - '0'; j++)
        res += f(i + 1, cnt + 1, true);
      res += f(i + 1, cnt + 1, false);
    }
  }
  return memo[i][cnt][less] = res;
}

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

  cin >> s >> k;
  rep(i, 110) rep(ii, 5) rep(iii, 2) memo[i][ii][iii] = -1;
  cout << f(0, 0, false) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;

int main(){

    ll M, D;
    cin >> M >> D;

    ll ans = 0;
    for(ll i = 1; i <= M; i++){
        for(ll j = 1; j <= D; j++){
            //cout << j << endl;
            if(j % 10 < 2){
                continue;
            }
            if(j / 10 < 2){
                continue;
            }
            //cout << j << " " << j % 10  << " " << j / 10 << endl;
            if(i == (j / 10) * (j % 10) ){
                ans++;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Pyramid
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_X = 100;
const int MAX_Y = 100;
const int INF = 1 << 30;

/* typedef */

struct Trpl {
  int x, y, h;
  Trpl() {}
  Trpl(int _x, int _y, int _h): x(_x), y(_y), h(_h) {}
  bool operator<(const Trpl &t) const { return h < t.h; }
  bool operator>(const Trpl &t) const { return h > t.h; }
};

/* global variables */

Trpl ts[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++)
    scanf("%d%d%d", &ts[i].x, &ts[i].y, &ts[i].h);
  sort(ts, ts + n, greater<Trpl>());

  for (int cy = 0; cy <= MAX_Y; cy++)
    for (int cx = 0; cx <= MAX_X; cx++) {
      int h = ts[0].h + abs(ts[0].x - cx) + abs(ts[0].y - cy);
      bool ok = true;
      for (int i = 1; ok && i < n; i++)
	ok = (ts[i].h == max(h - abs(ts[i].x - cx) - abs(ts[i].y - cy), 0));

      if (ok) {
	printf("%d %d %d\n", cx, cy, h);
	return 0;
      }
    }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> c(n-1), s(n-1), f(n-1);
  rep(i, n-1) cin >> c[i] >> s[i] >> f[i];

  vector<int> res(n, 0);

  rep(si, n) {
    for (int i = si; i < n-1; ++i) {
      if (res[si] < s[i]) res[si] = s[i];
      if (res[si] % f[i]) res[si] += f[i] - res[si] % f[i];
      res[si] += c[i];
    }
  }

  rep(si, n) cout << res[si] << endl;
  return 0;
}

Measured memory_bytes: 3636
import math

n = int(input())
s = [int(input()) for i in range(5)]

neck = min(s)
time = 0
time += s.index(neck)#ボトルネックに到達するまでの時間
time += math.ceil(n/neck)#全員がボトルネックを通り抜けるまでの時間
time += 4-s.index(neck)#最後の人がゴールするまでの時間

print(time)




Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;
typedef pair<ll, ll> P;
typedef vector<P> VP;

int main() {
  ll n, m;
  VP ab;

  cin >> n >> m;
  for(ll i=0; i<n; i++) {
    ll at, bt;
    cin >> at >> bt;
    ab.push_back(make_pair(at, bt));
  }

  sort(ab.begin(), ab.end(),
       [](P e0, P e1) -> bool {
         return e0.first < e1.first;
       }
       );
  ll res = 0;
  for(ll i=0; i<n; i++) {
    ll diff = min(m, ab[i].second);
    if(diff == m) {
      res += m * ab[i].first;
      break;
    } else {
      res += ab[i].second * ab[i].first;
      m -= ab[i].second;
    }
  }
  
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2420
package main

import "fmt"

func main() {
	var x int64
	fmt.Scan(&x)

	// 120**5-119**5 = 1019663401 > 10**9
	for a := int64(1); a <= 120; a++ {
		for b := int64(-120); b < a; b++ {
			if a*a*a*a*a-b*b*b*b*b == x {
				fmt.Println(a, b)
				return
			}
		}
	}
}


Measured memory_bytes: 1752
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int A,B,C,sum=0;
    cin >> A >> B >> C;
    sum+=A+B+C;
    sum-=max({A,B,C});
    cout << sum << endl;

}



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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n];
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
		}
		int money = 1000,minn = inf;
		for(int i=0;i<n;++i)
		{
			if(arr[i]>minn)
			{
				int x = money/minn;
				int y = money%minn;
				money = y + x*arr[i]; 
				minn = inf;
			}
			
			{
				minn = min(minn,arr[i]);
			}
		}
		cout<<money<<"\n";		
    }
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main()
{
	int i, j, k, q[6+1], flag = 1;

	for (i = 0; i < 6; i++) {
		scanf("%d", &q[i]);
	}
	k = q[5];

	for (i = 0; i < 6; i++) {
		for (j = 4; j > i; j--) {
			if (q[j] - q[i] > k) {
				flag = 0;
				break;
			}
		}
	}

	if (flag) {
		printf("Yay!");
	}
	else {
		printf(":(");
	}

	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n; cin >> n;
    if (n < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	ll x;
	cin >> N >> x;
	ll rsl = INF;
	ll a[N], b[N];
	rep(i, 0, N) cin >> a[i];
	rep(i, 0, N) b[i] = a[i];
	rep(k, 0, N) {
		ll can = k * x;
		rep(i, 0, N) b[i] = min(b[i], a[(i - k + N) % N]);
		rep(i, 0, N) can += b[i];

		rsl = min(rsl, can);
	}
	cout << rsl << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)

ll f(ll A, ll B, int b) {
  if(A != 0) return f(0, A-1, b) ^ f(0, B, b);
  if(B == 3) return 0;
  if(B == 2) return 3;
  if(B == 1) return 1;
  if(B == 0) return 0;

  while(!(B >> b & 1)) b--;
  ll x = 1LL << b;
  return f(0, B ^ x, b-1) + (~B & 1) * x;
}

int main () {
  ll A, B;

  cin >> A >> B;

  cout << f(A, B, 40) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;

int main() {
	ll N;
	cin >> N;
	if (N < 1000){
	    cout<<"ABC"<<endl;
	}else{
	    cout<<"ABD"<<endl;
	}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    auto &&sum = [&](int a) {
        int res = 0;
        while (a > 0) {
            res += a % 10;
            a /= 10;
        }
        return res;
    };
    int mn = 1000000000;
    for (int i = 1; i < n; i++) {
        mn = min(mn, sum(i) + sum(n - i));
    }
    cout << mn;
    return 0;
}

Measured memory_bytes: 256
h = int(input())
ans = 0

#攻撃の順番は気にしなくていい

#2の40乗までのリスト
s = [0]
for i in range(41):
    s[i] = 2**i
    s.append(s[i])

#2の何乗の間にあるかがわかればよい
for i in range(41):
    if h >= s[i]:
        ans += s[i]
    else:
        break

print(ans)

Measured memory_bytes: 3060
import Data.List
import Data.Char
import Control.Monad

affine :: Int -> Int -> Char -> Char
affine a b c
    | isAlpha c = chr (impl (ord c - ord 'a') + ord 'a')
    | otherwise = c
        where
            impl :: Int -> Int
            impl c' = (a * c' + b) `mod` 26

nyan :: (Int , Int) -> String -> Maybe String
nyan (a , b) s = if isInfixOf "this" s2 || isInfixOf "that" s2 then Just s2 else Nothing
    where
        s2 = map (affine a b) s

solve :: String -> IO ()
solve s = putStrLn $ maybe undefined id $ foldr (\ x y -> case x of Nothing -> y ; z -> z) Nothing $ map (\ ab -> nyan ab s) [(a,b) | a <- [1..25] , b <- [1..26] , gcd a 26 == 1]

main :: IO ()
main = readLn
    >>= (\ n -> replicateM n getLine)
    >>= mapM_ solve

Measured memory_bytes: 4148
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

template <typename T>
using gtree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main() {
    gtree<string> g;
    string S;
    cin >> S;
    int K;
    cin >> K;
    vector<pair<char, int>> v;
    rep(i, S.size()) {
        v.push_back(make_pair(S[i], i));
    }
    sort(v.begin(), v.end());
    rep(ii, S.size()) {
        int i = v[ii].second;
        string tmp = ""; tmp += S[i];
        g.insert(tmp);
        int cnt = 0;
        for (int j=i+1; j<S.size(); ++j) {
            if (cnt > K) break;
            tmp += S[j];
            g.insert(tmp);
            cnt++;
        }
        if (g.size() > K and ii < S.size() and v[ii].first != v[ii+1].first) {
            break;
        }
    }
    cout << *g.find_by_order(K-1) << endl;
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
void solve()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = 0, count = 0;
  lli D, T, S;
  vector<pair<lli, lli>> pr;
  map<lli, lli> ma;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> D >> T >> S;
  ans = T * S;
  if (ans >= D)
  {
    out("Yes");
  }
  else
  {
    out("No");
  }
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  solve();
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#define loop(i, n) for(i=0; i<n; i++)
#define pb push_back
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> p;
	int i, mint = 200007;
	for(i=0; i<n; i++){
		int x;
		cin >> x;
		p.pb(x);
	}
	int count = 0;
	for(i=0; i<n; i++){
		if(p[i]<=mint){
			count++;
			mint = p[i];
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 4276
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;

namespace ndifix{
}

int main(){
  int a,p;cin>>a>>p;
  cout<<(3*a+p)/2<<endl;

  
  return 0;
}


Measured memory_bytes: 764
def main():
    n,m = map(int,input().split())
    cards = [-1 for i in range(n)]
    mg = {}
    for i in range(n):
        mg[i+1] = []
    for i in range(m):
        x,y,z = map(int,input().split())
        mg[x].append(y)
        mg[y].append(x)
    ans = 0
    for i in range(n):
        if cards[i]==-1:
            ans += 1
            cards[i] = 0
            que = [i]
            while len(que)>0:
                s = que.pop(0)
                for v in mg[s+1]:
                    if cards[v-1] == 0:
                        continue
                    cards[v-1] = 0
                    que.append(v-1)
    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

#define ll  long long
#define ld  double

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

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

ll  f[105][N];

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

    int n;  cin >> n;
    int W;  cin >> W;

    for(int i = 1 ; i <= n ; ++i)   {
        int w;  cin >> w;
        int v;  cin >> v;

        for(int j = 0 ; j <= W ; ++j)   f[i][j] = f[i - 1][j];
        for(int j = w ; j <= W ; ++j)   f[i][j] = max(f[i][j],f[i - 1][j - w] + v);
    }

    cout << f[n][W];
}

Measured memory_bytes: 156416
import java.util.*;
import java.io.*;

public class Main{
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
	
	public static void main (String[] args) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i] = Integer.parseInt(st.nextToken());
        }
        st = new StringTokenizer(br.readLine());
        int b[] = new int[m];
        for(int i=0;i<m;i++){
            b[i] = Integer.parseInt(st.nextToken());
        }
        long psa[] = new long[n];
        psa[0] = a[0];
        int la = -1;
        if(psa[0]<=(long)k){
            la = 0;
            for(int i=1;i<n;i++){
                psa[i] = psa[i-1] + a[i];
                if(psa[i]>(long)k){
                    la = i-1;
                    break;
                }else{
                    la = i;
                }
            }
        }
        long psb[] = new long[m];
        psb[0] = b[0];
        int lb = -1;
        if(psb[0]<=(long)k){
            lb = 0;
            for(int i=1;i<m;i++){
                psb[i] = psb[i-1] + b[i];
                if(psb[i]>(long)k){
                    lb = i-1;
                    break;
                }else{
                    lb = i;
                }
            }
        }
        if(la==lb && la==-1){
            bw.write("0");
        }else{
            int ans = 0;
            int j = lb;
            for(int i=0;i<=la;i++){
                while(j>=0 && (psb[j]+psa[i])>(long)k){
                    j--;
                }
                ans = (int)Math.max(ans, i+1+j+1);
            }
            ans = (int)Math.max(ans, lb+1);
            bw.write(ans + "");
        }
		bw.flush();
	}
}


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

int H,W,N,a,b;
long long res[10];
map<pair<int,int>,int>mp;

int main(){
	cin>>H>>W>>N;
	for(int i=0;i!=N;++i){
		cin>>a>>b;
		for(int j=max(1,a-2);j<=a&&j<=H-2;++j)
			for(int k=max(1,b-2);k<=b&&k<=W-2;++k)
				++mp[make_pair(j,k)];
	}
	for(auto it=mp.begin();it!=mp.end();++it){
		++res[it->second];
	}
	res[0]=(long long)(H-2)*(W-2);
	for(int i=1;i!=10;++i)
		res[0]-=res[i];
	for(int i=0;i!=10;++i)
		cout<<res[i]<<endl;
	return 0;
}


Measured memory_bytes: 56448
'use strict'

const main = (input) => {
    input = input.split('\n').map(i => Number(i))
    const k = input[input.length - 2]
    const array = input.slice(0, 5)
    const max = Math.max(...array)
    const min = Math.min(...array)

    if (max - min <= k) {
      console.log('Yay!')
    } else {
      console.log(':(')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
 ll n,k;
 cin>>n>>k;
 long double ans=0;
 for(int i =1; i<= n;i++){
  long double temp=1.0/n;
    int now = i;
    while(now < k){
        now*=2;
        temp/=2;
    }
    ans+=temp;
 }
cout<<setprecision(12)<<ans<<endl;



}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

int N;
string S, T;

string solve() {
    string ret = "";
    REP (i, 2*N) {
        if (i&1) ret += T[i>>1];
        else ret += S[i>>1];
    }
    return ret;
}

int main() {
    cin >> N >> S >> T;
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n)cin >> d[i];
    sort(all(d));
    int ans = d.at(n/2)-d.at(n/2-1);
    //if(d[n/2] == d[n/2+1])ans--;
    //if(d[n/2-1] == d[n/2-2])ans--;
    if(ans < 0)ans = 0;
    if(d[n/2] == d[n/2-1])ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int a[4], sum = 0;
    rep(i, 4){
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int ans = MAX;
    rep(S, 1<<4)if(__builtin_popcount(S) == 2){
        int tmp = 0;
        rep(i, 4)if(S>>i & 1) tmp += a[i];
        chmin(ans, abs(tmp - (sum-tmp)));
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 3212
n,m=map(int,input().split(' '))
box=[1]*n
red=[0]*n
red[0]=1
for i in range(m):
  x,y=map(lambda x:x-1,map(int,input().split(' ')))
  if box[x] == 1:
    red[y]=max(red[y],red[x])
    red[x]=0
  else:
    red[y]=max(red[y],red[x])
  box[x]-=1
  box[y]+=1
print(red.count(1))


Measured memory_bytes: 4596
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		PriorityQueue<Integer> queue = new PriorityQueue<>();
		for (int i = 1; i < n; i++) {
		    queue.add(arr[i] - arr[i - 1]);
		}
		int count = 0;
		for (int i = 0; i < n - m; i++) {
		    count += queue.poll();
		}
		System.out.println(count);
   }
}


Measured memory_bytes: 50908
# -*- coding: utf-8 -*-
n = gets.to_i
a = gets.chomp.split(" ")
a = a.sort

ans = 1
for i in 0..n-1
  x = a[i].to_i 
  ans *= x
  if ans > 1000000000000000000
    puts "-1"
    exit
  end
end

puts ans

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

int main(void){
    long long prod[100001] = {1};
    long long i;
    for(i = 1; i <= 100000; i++){
        prod[i] = (i * prod[i - 1]) % (1000000000 + 7);
    }
    
    int n, m;
    cin >> n >> m;
    
    if(abs(n - m) >= 2){
        cout << 0 << endl;
        return 0;
    }
    
    long long ans = prod[n] * prod[m] % (1000000000 + 7);
    if(n == m){
        ans = (ans * 2) % (1000000000 + 7);
    }
    
    cout << (int)ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>v;
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
  	long long n;

    while(cin>>n){
      long long cnt5 = 0;
      if(n%2!=0)
        cout<<0<<endl;
      else{
        n /= 2;

        for(;n;n/=5){
          cnt5 += n/5;
        }
        cout<<cnt5<<endl;
      }
    }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int,int);

int a[20],n;

int main(){
  int i,q,m[200];

  scanf("%d",&n);
  for(i = 0; i < n ; i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i = 0;i < q ; i++){
    scanf("%d",&m[i]);
  }

  for(i = 0;i < q; i++){
    if(solve(0,m[i]) == 1)printf("yes\n");
    else printf("no\n");	       
  }
    return 0;
  }
  
  int solve(int i,int m){
    int res;
    if(m == 0)return 1;
    if(i >= n)return 0;
    res = solve(i + 1, m) || solve(i + 1, m - a[i]);
    return res;
  }
	      



Measured memory_bytes: 2108
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
int a[MAXN];
int b[MAXN];
vector <pii> v;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i] >> b[i];		
		v.pb({b[i],a[i]});
	}	
	sort(all(v));

	int cur = 0;
	for (int i = 0; i < n; ++i)
	{
		if(cur + v[i].second <= v[i].first)
		{
			cur = cur + v[i].second;
		}
		else
		{
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";

}

Measured memory_bytes: 3568
import java.io.PrintWriter;
import java.util.Scanner;


public class Main {
	static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		// 入力
		final int[] a = new int[3];
		try(Scanner scan = new Scanner(System.in)) {
			a[0] = scan.nextInt();
			a[1] = scan.nextInt();
			a[2] = scan.nextInt();
		}
		int count5 = 0;
		int count7 = 0;
		
		for (int i = 0; i < 3; i++) {
			if (a[i] == 5) {
				count5++;
			} else if (a[i] == 7) {
				count7++;
			}
		}
		final boolean result = count5 == 2 && count7 == 1;
		
		// 出力
		out.println(result ? "YES" : "NO");
		out.flush();
	}
}


Measured memory_bytes: 9936
#include <stdio.h>

int main(void){
	long long int x;
	long long int n;
	long long int a, a_max, a_min;
	long long int b, b_max, b_min, tmp;
	long long int sum = 0;
	int vector = 0; 
	scanf("%lld %lld", &n, &x);
	
	a = x;
	b = x;
	
	
	if(x > n - x){
		x = n - x;
	}
	n = n - x;
	sum += x + n;
	while(!(x==0&&n==0)){
		if(n % x == 0){
			sum += 2 * x * (n / x) - x;
			x = 0; n = 0;
		} else {
			sum += 2 * x * (n / x);
			tmp = x;
			x = n % x;
			n = tmp;

		}
	}

	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_PRIME = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

char rot13(char c, int n)
{
  return 'a' + (c + n) % 26;
}

string rot13(string &s, int n)
{
  n %= 26;
  string res;
  tr (s, p) {
    if (islower(*p))
      res.pb(rot13(*p, n));
    else
      res.pb(*p);
  }
  return res;
}

int main(int argc, char **argv)
{
  string enc;

  while (!getline(cin, enc).eof()) {
    for (int i = 0; i < 26; i++) {
      string s = rot13(enc, i);
      if ((int)s.find("the ") >= 0 || (int)s.find("this ") >= 0 || (int)s.find("that ") >= 0) {
        cout << s << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 998244353;
#define PI 3.1415926535
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
const int siz = 2*(1e6 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int fact[siz];
int ifact[siz];
int bit[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}


signed main()
{
	// #ifndef ONLINE_JUDGE2 
	// freopen("in.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	speedrap
	int n,m;
	cin>>n>>m;
	int sum = n*(n-1) + m*(m-1);
	sum /= 2;
	cout<<sum<<"\n";
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lld;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"IMPOSSIBLE"<<endl;return 0
const int mod=1000000007;
const int big=7000000;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
//19:04~
int main(void){
	llint ans=0;
	int n,i,j,k;cin>>n;
	vector<vector<int>>ko(n);
	vector<int>can(n);//もう片方の最小値
	vector<int>x(n);
	for(i=1;i<n;i++){
		int q;cin>>q;q--;
		ko[q].pub(i);
	}
	for(i=0;i<n;i++){cin>>x[i];}
	for(i=n-1;i>=0;i--){//逆順に見る
		vector<int>dp(5001);
		for(k=0;k<ko[i].size();k++){
			int kos=ko[i][k];
			int a=x[kos];
			int b=can[kos];
			vector<int>ddp(5001,big);
			for(j=0;j+a<=5000;j++){ddp[j+a]=dp[j]+b;}
			for(j=0;j+b<=5000;j++){mineq(ddp[j+b],dp[j]+a);}
			swap(dp,ddp);
		}
		can[i]=big;
		for(j=0;j<=x[i];j++){mineq(can[i],dp[j]);}
		if(can[i]==big){dme;}
	}
	cout<<"POSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define R(i,a,n) for(int i=a;i<n;i++)
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int ddx[]={0,1,1,1,0,-1,-1,-1};
int ddy[]={-1,-1,0,1,1,1,0,-1};
#define pb push_back

int ans=1e9;
int n;


signed main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int s1=0,s2=0;
		int a=i;
		int b=(n-i);
		while(a)s1+=a%10,a/=10;
		while(b)s2+=b%10,b/=10;
		ans=min(ans,s1+s2);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int n;
    cin >> n;
    dump(n * (n - 1) / 2);
    return 0;
}

Measured memory_bytes: 256
N = int(input().strip())
x = [[] for x in range(N)]
for i in range(N-1):
     u, v, w = list(map(int, input().split()))
     x[u-1].append([v-1, w%2])
     x[v-1].append([u-1,w%2])



ret = {}
done = [0 for x in range(N)]

queue = [0]

for i in range(N):
    curr = queue.pop()
    if curr == 0:
        ret[0] = 0

    for neigh in x[curr]:
        if done[neigh[0]] == 1:
            continue
        if neigh[1] % 2 == 0:
            ret[neigh[0]] = ret[curr]
        else:
            ret[neigh[0]] = 0 if ret[curr] == 1 else 1

        queue.append(neigh[0])
    done[curr] = 1


for i in range(N):
    print(ret[i])


Measured memory_bytes: 50548
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N_MAX = 200005;
int n, m;
bool s[N_MAX], g[N_MAX]; 
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        if (a == 1) s[b] = true;
        else if (b == n) g[a] = true;
    }
    rep(i, 0, N_MAX) {
        if (s[i] && g[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

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

    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 0; i < N; i++){
        int P; cin >> P;
        if (P <= A){
            c1 ++;
        }else if(P <= B){
            c2 ++;
        }else{
            c3 ++;
        }
    }

    cout << min(c1, min(c2, c3)) << endl;
    

    return 0;
}

Measured memory_bytes: 256
a=["1","3","5","7","8","10","12"]
b=["4","6","9","11"]
main=do
 [x,y]<-words<$>getLine
 putStrLn(if([1|s<-a,t<-a,s==x,t==y]++[1|s<-b,t<-b,s==x,t==y])==[]then"No"else"Yes")

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

int main(){
  string s;
  int q;
  cin >> s >> q;
  bool flag=false;//正
  for(int i=0;i<q;i++){
    int a;
    cin >> a;
    if(a==1){
      flag=!flag;
    }else{
      int f;
      string c;
      cin >> f >> c;
      if((f==1&&!flag)||(f==2&&flag)){
        s.insert(0,c);
      }else{
        s.append(c);
      }
    }
  }
  
  if(flag){
    reverse(s.begin(), s.end());
  }
    
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 900
#coding:utf-8

#A, B = map(int,raw_input().split())
N = int(raw_input())

Time = [0 for i in range(N)]
C, S, F = map(int,raw_input().split())
Time[0] += S
for i in range(1,N-1):
    Cnew, S, F = map(int,raw_input().split())
    Time[i] += S
    #print Time[i]

    for j in range(i):
        #print j
        Time[j] = Time[j] + C
        if Time[j] > S:
            #Time[j] = Time[j] + C
            #print Time[j]
            if (Time[j] - S) % F == 0:
                pass
            else:
                Amari = F - ((Time[j] - S) % F)
                Time[j] = Time[j] + Amari
        else:
            #print "hello"
            Time[j] = S
    C = Cnew

for i in range(N-1):
    Time[i] += C
    print Time[i]
print Time[N-1]


Measured memory_bytes: 2696
# include <iostream>
# include <string.h>
using namespace std;
int main()
{
	char x[101],y[101],a,j;
	while(cin>>x>>y)
	{
		if(strcmp(x,y)==0)
			cout<<"Yes"<<endl;
		else
		{
		int length=strlen(x);
		for(j=1;j<length;j++)
		{
		  a=x[length-1];
		  for(int i=length-1;i>=1;i--)
		  {
			x[i]=x[i-1];
		  }
		  x[0]=a;
		  if(strcmp(x,y)==0)
			  break;
		}
		if(j!=length)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
		}
	}
	return 0;
}


			
			
			
		

Measured memory_bytes: 256
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
li = na()
c = Counter(li)
ans = 1
for k in c.keys():
    ct = c[k] + c[k - 1] + c[k + 1]
    ans = max(ans, ct)
print(ans)






Measured memory_bytes: 14556
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (h, _) = get!(usize, usize);
    let mut cs = Vec::new();
    for _ in 0..10 {
        cs.push(get!(String).split_whitespace().map(|c| c.parse::<i64>().unwrap()).collect::<Vec<_>>());
    }

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                if cs[i][j] > cs[i][k] + cs[k][j] {
                    cs[i][j] = cs[i][k] + cs[k][j];
                }
            }
        }
    }

    let mut r = 0;
    for _ in 0..h {
        for a in get!(String).split_whitespace() {
            if let Ok(i) = a.parse::<usize>() {
                r += cs[i][1];
            }
        }
    }
    println!("{}", r);
}

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

int main() {
	string s,t,u;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	cin>>u;
	
	if(u==s)cout<<a-1<<" "<<b<<endl;
	else cout<<a<<" "<<b-1<<endl;
	
}


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

bool chk(vector<ll> &a, vector<ll> &x, int i){
	int n = a.size();
	x.at(0) = i*2;
	for(int j=1; j<n; j++){
		x.at(j) = a.at(j-1)*2-x.at(j-1);
	}
	return x.at(0)+x.at(n-1)>=a.at(n-1)*2;
}

int main(){
	
	int n; cin>>n;
	vector<ll> a(n),x(n);
	for(auto &i:a) cin>>i;
	int ok = a.at(0)+1;
	int ng = -1;
	while(ok-ng>1){
		auto mid = (ok+ng)/2;
		(chk(a,x,mid)?ok:ng)=mid;
	}
	chk(a,x,ok);
	for(auto it = x.begin(); it!= x.end(); it++){
		cout << *it <<(it!=x.end()-1?' ':'\n');
	}
	cout << flush;
	
}


Measured memory_bytes: 2944
def pm_to_chr(s):
    s=s.group()
    if s[-1]=='?':
        return 'A'
    ans=chr((((ord(s[-1])+s.count('+')-s.count('-'))-ord('A'))%26)+ord('A'))
    return ans

def reverse(s):
    s=s.group()
    s=s[1:-1]
    ans=''.join(reversed(s))
    return ans

import re

s=input()
while s!='.':
    s=re.sub("[\+\-]*[\w?]",pm_to_chr,s)
    while('[' in s):
        s=re.sub("\[\w+\]",reverse,s)
    print(s)
    s=input()
            


Measured memory_bytes: 6524
#include<bits/stdc++.h>
#include <boost/math/common_factor_rt.hpp>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    LCIN(N);
    LL ans = 0;
    REP(a,N){
        CIN(b);
        ans += b-1;
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final long n = in.nextInt();
            final long k = in.nextInt();
            long ans = 0;
            if (k == 0) {
                out.println(n * n);
                return;
            }

            for (long b = k + 1; b <= n; b++) {
                ans += (b - k) * (n / b);
            }

            for (long b = k + 1; b <= n; b++) {
                long d = (b * (n / b)) + k - 1;
                if (d < n) {
                    ans += n - d;
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 22992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<P> p(M);
    rep(i, M) cin >> p[i].first >> p[i].second;
    vector<vector<int>> city(N, vector<int>(N, 0));
    rep(i, M)
    {
        int y = p[i].first;
        int x = p[i].second;
        city[y - 1][x - 1]++;
        city[x - 1][y - 1]++;
    }
    rep(i, N)
    {
        int ans = 0;
        rep(j, N)
        {
            ans += city[i][j];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

int main()
{
    ll x, a, b;
    cin >> x >> a >> b;

    if (abs(x - a) < abs(x - b))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "B" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		sc.close();
		int lx = tx - sx;
		int ly = ty - sy;
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < lx; i++) {
			sb.append("R");
		}
		for(int i = 0; i < ly; i++) {
			sb.append("U");
		}
		for(int i = 0; i < lx; i++) {
			sb.append("L");
		}
		for(int i = 0; i < ly; i++) {
			sb.append("D");
		}
		sb.append("D");
		for(int i = 0; i < lx + 1; i++) {
			sb.append("R");
		}
		for(int i = 0; i < ly + 1; i++) {
			sb.append("U");
		}
		sb.append("L");
		sb.append("U");
		for(int i = 0; i < lx + 1; i++) {
			sb.append("L");
		}
		for(int i = 0; i < ly + 1; i++) {
			sb.append("D");
		}
		sb.append("R");
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main() {
	int n = 3;
	int ans = 0;
	int s;
	cin >> s;
	for (int i = 0; i < (1 << n); i++) {
		ans = s / 1000;
		for (int j = 0; j < 3; j++) {
			if (i&(1 << j)) {
				ans += (s / int(pow(10, j))) % 10;
			}
			else {
				ans -= (s / int(pow(10, j))) % 10;
			}
		}
		if (ans == 7) {
			cout << s / 1000;
			for (int j = 2; j >-1; j--) {
				
				if (i&(1 << j)) {
					cout << '+';
				}
				else {
					cout << '-';
				}
				cout << (s / int(pow(10, j))) % 10;
				
			}
			cout << "=7";
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
	int s1,s2,t;
int main()
{
    for(int i=1;i<=3;i++)
	{
        cin>>t;
        if(t==5)
        {
        	s1++;
		}
        else if(t==7)
        {
        	s2++;
    	}
	}
            
    if(s1==2&&s2==1)
    {
    	 cout<<"YES";
	}
    else
    {
    	cout<<"NO";
	}
    return 0;
}

Measured memory_bytes: 256
while True :
    H, W = [int(temp) for temp in input().split()]
    
    if H == W == 0 :
        break
    
    for making in range(H):
        if making % 2 == 0 :
            if   W % 2 == 0 : print('#.' * (W // 2))
            else            : print('#.' * (W // 2) + '#')
        else :
            if   W % 2 == 0 : print('.#' * (W // 2))
            else            : print('.#' * (W // 2) + '.')

    print()

Measured memory_bytes: 7676
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s=="SUN")
    cout << 7 << endl;
        else if(s=="MON")
    cout << 6 << endl;   
     else if(s=="TUE")
    cout << 5 << endl;   
     else if(s=="WED")
    cout << 4 << endl;    
    else if(s=="THU")
    cout << 3 << endl;   
     else if(s=="FRI")
    cout << 2 << endl;    
    else if(s=="SAT")
    cout << 1 << endl;   
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    int y = 0;
    cin >> a >> b >> c;
    for (int x = a; x <= b; x++){
        if(c % x == 0){
            y++;    
        }
    }
    cout << y << endl;      
}



Measured memory_bytes: 3100