akhauriyash/Code-Regression huggingface dataset:
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long mod=(long long)(1e9+7);

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll a,ll p)
{
   return power(a,p-2,p);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
int main()
{
    // #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
    fio;
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        ll n;
        cin>>n;
        ll ans=0;
        forin(i,1,n)
        {
            if(i%3 && i%5)
            {
                ans+=i;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
import functools
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def gcd(nums):
    return functools.reduce(euclid, nums)



n=int(input())
a=[int(i) for i in input().split()]

print(gcd(a))


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

int main()
{    
   int n;
   string s;
   cin >> n >> s;
   int ans = 0;

   rep(i,n -2){
      if(s[i] =='A' && s[i + 1] =='B' && s[i + 2] =='C')
         ++ans;
   }

   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m)cin >> a[i];
    int acu = accumulate(all(a), 0LL);
    if(n-acu < 0)cout << -1;
    else cout << n-acu;
}  

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
	cin >> N;
	vector <int> X(N);
	vector <int> Y(N);
	for (int i=0; i<N; i++){
		cin >> X.at(i);
		Y.at(i) = X.at(i);
	}

	sort(Y.begin(), Y.end());
	
	for (int i=0; i<N; i++){
		if (X.at(i) > Y.at(N/2-1)){
			cout << Y.at(N/2-1) << endl;
		}
		else{
		cout << Y.at(N/2) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n; cin >> n;
    int a, b; cin >> a >> b;
    int l = 0, m = 0, h = 0;
    rep(i, 0, n){
        int p; cin >> p;
        if(p <= a) l++;
        if(a < p && p <= b) m++;
        if(p > b) h++;
    }
    cout << min({l, m, h}) << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    String ans = "";
    while(N != 0){
      if(N % 2 != 0){
        ans = "1" + ans;
        N--;
      }else{
        ans = "0" + ans;
      }
      N /= -2;
    }
    if(ans == "") ans = "0";
    out.println(ans);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 21332
<?php
 
fscanf(STDIN, "%d %d", $n, $m);
$a_arr = explode(' ', trim(fgets(STDIN)));
$sum = array_sum($a_arr);

rsort($a_arr);
$possible = true;
for ($i = 0; $i < $m; ++$i) {
    if ($a_arr[$i] < $sum / (4 * $m)) {
        $possible = false;
        break;
    }
}

echo $possible ? 'Yes' : 'No';


Measured memory_bytes: 5112
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int a[7] = {0};
		while(n--)
		{
			int temp;
			cin >> temp;
			if(temp < 10)
			{
				a[0]++;
			}
			else if(temp < 20)
			{
				a[1]++;
			}
			else if(temp < 30)
			{
				a[2]++;
			}
			else if(temp < 40)
			{
				a[3]++;
			}
			else if(temp < 50)
			{
				a[4]++;
			}
			else if(temp < 60)
			{
				a[5]++;
			}
			else
			{
				a[6]++;
			}
		}
		for(int i = 0; i < 7; ++i)
		{
			cout << a[i] << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 2019
#define INF2 1000000000000000000

int cnt[2020];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = 0;
    cnt[0] = 0;
    rep(i, S.length()) {
        int cnt2[2020] = {};
        int k = S[i] - '0';
        rep(j, 2019) {
            cnt2[(j * 10 + k) % mod] += cnt[j];
        }
        cnt2[k]++;
        
        rep(j, 2019) cnt[j] = cnt2[j];
        ans += cnt[0];
        //REP(j, 0, 20) cout << j << " " << cnt[j] << endl;
        //cout << i << " " << cnt[0] << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;

	map<char, ll> mp;
	rep(i, n) {
		if (s[i]=='R') mp['R']++;
		if (s[i]=='G') mp['G']++;
		if (s[i]=='B') mp['B']++;
	}

	ll res = mp['R'] * mp['G'] * mp['B'];
	for (ll i=0; i<(ll)s.size(); i++) {
		for (ll j=i+1; j<(ll)s.size(); j++) {
			ll k = 2*j - i;
			if (s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i] && k<n) res--;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3648
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int X, A, B;
	std::cin >> X >> A >> B;
	if (B - A <= 0)
		std::cout << "delicious\n";
	else if (B-A <= X)
		std::cout << "safe\n";
	else
		std::cout << "dangerous\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, D;
    int ans = 0;
    cin >> N >> D;
    D *= D;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        x *= x;
        y *= y;
        if (x + y <= D)
            ans++;
    }
    cout << ans << endl;


    solve();
    return 0;
}


Measured memory_bytes: 3636
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

bool vis[100001];

int sim[100001];

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    
    vis[1] = true;
    for (int i = 2; i <= 317; i++)
    {
        if (vis[i]) continue;
        for (int j = i*2; j <= 100000; j += i) vis[j] = true;
    }
    
    
    
    sim[1] = 0;
    
    for (int i = 3; i <= 100000; i+=2)
    {
        sim[i] = sim[i-2];
        if (!vis[i] && !vis[(i+1)/2]) sim[i]++;
    }
    
    int q;
    cin >> q;
    
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << sim[r] - sim[l]+(!vis[l]&&!vis[(l+1)/2]) << '\n';
    }
    
    return 0;
    
}



Measured memory_bytes: 1152
#include<iostream>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

using namespace std;

int main() {
  int n; cin >> n;
  int a[110];
  REP(i, n) {
    cin >> a[i];
  }
  RREP(i, n) {
    cout << a[i];
    if (i > 0) cout << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 3128
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

constexpr int MOD = int(1e9) + 7;

enum {
    A = 0,
    C = 1,
    G = 2,
    T = 3,
    _ = 4,
};

char toChar(int n) {
    switch(n) {
    case A: return 'A';
    case G: return 'G';
    case C: return 'C';
    case T: return 'T';
    default: return '_';
    }
}

int N;

int dp[128][5][5][5];

bool isNG(int x, int y, int z)
{
    return (x == A && y == G && z == C);
}

bool isNG(int a, int b, int c, int d)
{
    return
        isNG(b, c, d) ||
        isNG(c, b, d) ||
        isNG(b, d, c) ||

        isNG(a, c, d) ||
        isNG(a, b, d) ||

        isNG(a, b, c) ||
        isNG(b, a, c) ||
        isNG(a, c, b);
}

i64 slv(int idx, int a, int b, int c)
{
    if (idx >= N) {
        return 1;
    }
    int &ret = dp[idx][a][b][c];
    if (~ret) return ret;

    ret = 0;
    for (int x = 0; x <= 3; ++x) {
        if (!isNG(a, b, c, x)) ret = (ret + slv(idx + 1, b, c, x)) % MOD;
    }

    return ret;
}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N;

    memset(dp, -1, sizeof(dp));
    cout << slv(0, _, _, _) << endl;
    return 0;
}

// vim: set foldmethod=marker :


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>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#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
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

/*
n=14
1
2
3
4
567
89ABCDE

n=10
1
2
3

45
6789A
*/
int main(void){
	llint i,n,K,sq=0;cin>>n>>K;K--;
	while(sq*sq<=n){sq++;}
	sq--;
	vector<llint>kei(sq*2,1);
	llint mae=sq;
	for(i=sq;i>=1;i--){
		kei[sq+sq-i]=n/i-mae;
		mae=n/i;
	}
	vector<llint>dp=kei;
	while(K--){
		for(i=1;i<sq+sq;i++){dp[i]=(dp[i-1]+dp[i])%mod;}
		REV(dp);
		for(i=0;i<sq+sq;i++){dp[i]*=kei[i];dp[i]%=mod;}
	}
	llint ans=0;
	for(i=0;i<sq+sq;i++){ans+=dp[i];}
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
const long long int MOD = 1000000007;
const long double EPS = 0.00000001;

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

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	vector<long long int>dis(N + 1, LLONG_MAX);
	list<pair<int, int>>edge[100001];
	for (int i = 1; i < N; i++) {
		cin >> L >> R >> K;
		edge[L].push_back({ R,K });
		edge[R].push_back({ L,K });
	}
	cin >> M >> K;
	dis[K] = 0;
	priority_queue<pair<long long int, int>, vector<pair<long long int, int>>, greater<pair<long long int, int>>>PQ;
	PQ.push({ 0,K });
	while (!PQ.empty()) {
		long long int c = PQ.top().first;
		long long int cn = PQ.top().second;
		PQ.pop();
		if (c > dis[cn])continue;
		for (auto i : edge[cn]) {
			if (dis[cn] + i.second < dis[i.first]) {
				dis[i.first] = dis[cn] + i.second;
				PQ.push({ dis[i.first],i.first });
			}
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		cout << dis[L] + dis[R] << endl;
	}
	return 0;
}


Measured memory_bytes: 11636
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(d==1) cout<<1<<endl;
	else cout<<0<<endl;
    return 0;
}



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int h,w,a[80][80],b[80][80],c[80][80],K=12800;
bool dp[2][80][25600], ans[25600];

signed main() {
    cin >> h >> w;
    rep(i,h) rep(j,w) cin >> a[i][j];
    rep(i,h) rep(j,w) cin >> b[i][j];
    rep(i,h) rep(j,w) c[i][j] = abs(a[i][j]-b[i][j]);
    dp[0][0][K] = true;
    rep(i,h) {
        int I=i%2,II=(i+1)%2;
        rep(j,w) {
            bool tmp[25600]={};
            rep(k,25600) {
                if (dp[I][j][k]) {
                    if (k-c[i][j] >= 0) tmp[k-c[i][j]] = true;
                    if (k+c[i][j] < 25600) tmp[k+c[i][j]] = true;
                }
                dp[I][j][k] = false;
            }
            if (j != w-1) rep(k,25600) dp[I][j+1][k] |= tmp[k];
            if (i != h-1) rep(k,25600) dp[II][j][k] |= tmp[k];
            if (i==h-1 && j==w-1) rep(k,25600) ans[k] = tmp[k];
        }
    }
    rep(i,K) {
        if (ans[K+i] | ans[K-i]) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld n;
  cin >> n;
  n %= 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    cout << "hon\n";
  } else if (n == 3) {
    cout << "bon\n";
  } else {
    cout << "pon\n";
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
const ll MOD = 1000000007;

struct edge{
    int to;
    ll cost;
    edge(int to, ll cost): to(to), cost(cost){}
};

vector<ll> dijkstra(vector<vector<edge>>& E, int start=0){
    vector<ll> d(E.size(), 1LL << 60);
    priority_queue<P, vector<P>, greater<P>> que;
    d[start] = 0;
    que.push(P(0, start));
    while(que.size()){
        P p = que.top(); que.pop();
        if(d[p.second] < p.first) continue;
        for(edge e: E[p.second]){
            ll nc = p.first + e.cost;
            if(d[e.to] > nc){
                d[e.to] = nc;
                que.push(P(nc, e.to));
            }
        }
    }
    return d;
}

int main(){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;

    vector<vector<edge>> G_a(n), G_b(n);
    for(int i=0;i<m;i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        G_a[u].emplace_back(v, a);
        G_a[v].emplace_back(u, a);
        G_b[u].emplace_back(v, b);
        G_b[v].emplace_back(u, b);
    }

    auto dist_a = dijkstra(G_a, s);
    auto dist_b = dijkstra(G_b, t);
    vector<ll> dist_ab(n);
    for(int i=0;i<n;i++){
        dist_ab[i] = dist_a[i] + dist_b[i];
    }
    for(int i=n-2;i>=0;i--){
        dist_ab[i] = min(dist_ab[i], dist_ab[i + 1]);
    }
    for(int i=0;i<n;i++){
        cout << 1000000000000000LL - dist_ab[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 19012
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    string a, b, c;
    cin >> a >> b >> c;
    cout << char(int(a[0]) - 32) << char(int(b[0]) - 32) << char(int(c[0]) - 32) << "\n";

}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
def cChristmas(n, k, hl):


    hl.sort()
    ans = 10**10

    for i in range(n-k+1):
        ans = min(ans, hl[i+k-1]-hl[i])

    return ans

def main():
    n, k = map(int, input().split())
    hl = [int(input()) for i in range(n)]
    print(cChristmas(n, k, hl))

if __name__ == '__main__':
    main()


Measured memory_bytes: 7444
#include <bits/stdc++.h>
using namespace std;
#define N 2003

int n, m;
char s[N][N];

int up[N][N], dn[N][N], le[N][N], rt[N][N];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        scanf("%s", s[i] + 1);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (s[i][j] == '.')
                up[i][j] = up[i - 1][j] + 1,
                le[i][j] = le[i][j - 1] + 1;
    for (int i = n; i >= 1; --i)
        for (int j = m; j >= 1; --j)
            if (s[i][j] == '.')
                dn[i][j] = dn[i + 1][j] + 1,
                rt[i][j] = rt[i][j + 1] + 1;
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <=m; ++j)
            ans = max(ans, up[i][j] + dn[i][j] + rt[i][j] + le[i][j] - 3);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 66816
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,m,d;
    scanf("%d%d%d", &n, &m, &d);

    double ans = (d>0? (double)2*(n-d)/n/n*(m-1): (double)1/n*(m-1));
    printf("%.12lf\n", ans);

    return 0;
}


Measured memory_bytes: 128
import bisect, collections

def solution():
    h, w = [int(x) for x in input().strip().split(" ")]
    if w == 1 or h == 1:
        print(1)
    else:
        print(((h+1)//2)*((w+1)//2)+(h//2)*(w//2))
    



def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

Measured memory_bytes: 39888
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

string tar[] = { "the", "this", "that" };

int main()
{
	string in;
	while (getline(cin, in))
	{
		string ans;
		for (int i=0; i<26; i++)
		{
			ans = in;
			for (int k=0; k<ans.size(); k++)
			{
				if (islower(ans[k]))
				{
					int r = i - ('z' - ans[k]);
					if (r > 0)
						ans[k] = (char) ((int) 'a' + r - 1);
					else
						ans[k] = (char) ((int) ans[k] + i);
				}
			}
			if (	   ans.find(tar[0], 0) != string::npos
				|| ans.find(tar[1], 0) != string::npos
				|| ans.find(tar[2], 0) != string::npos)
				break;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
using namespace std;

int n;
char buf[1000];

int main() {
  while (1) {
    if (scanf("%s", buf) != 1) break;

    n = strlen(buf);
    int total = 0;
    int cur_num = 0;
    int prev_num = 0;
    for (int i=0; i<n; i++) {
      switch (buf[i]) {
      case 'I':
        cur_num = 1;
        break;
      case 'V':
        cur_num = 5;
        break;
      case 'X':
        cur_num = 10;
        break;
      case 'L':
        cur_num = 50;
        break;
      case 'C':
        cur_num = 100;
        break;
      case 'D':
        cur_num = 500;
        break;
      case 'M':
        cur_num = 1000;
      }

      if (prev_num >= cur_num) total += cur_num;
      else total += cur_num - prev_num*2;
      prev_num = cur_num;
    }

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

Measured memory_bytes: 2532
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M, Q;
std::vector<std::vector<ll>> vs;
ll A[20], ans;
bool used[20];

void dfs( ll v )
{
  if( v == N-1 )
  {
    ll ret = 0;

    rep( q, Q )
    {
      ll a = vs[q][0], b = vs[q][1], c = vs[q][2], d = vs[q][3];

      if( A[b]-A[a] == c )
        ret += d;
    }

    chmax( ans, ret );

    return;
  }

  repi( i, A[v], M+1 )
  {
    A[v+1] = i;
    dfs( v+1 );
  }
}

int main()
{
  std::cin >> N >> M >> Q;

  rep( q, Q )
  {
    ll a, b, c, d;
    std::cin >> a >> b >> c >> d;
    --a; --b;

    vs.push_back( { a,b,c,d} );
  }

  A[0] = 1;

  dfs( 0 );

  std::cout << ans << std::endl;

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int rec;
    int min = 200001;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> rec;
        if(min > rec){
            ans++;
            min = rec;
        }

    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int R;
	string ans;
	cin >> R;
	if (R < 1200) ans = "ABC";
	else if (R < 2800) ans = "ARC";
	else ans = "AGC";
	cout << ans << endl;

	return 0;
}


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

int main() {
  int N , K;
  cin >> N >> K;
  int A = K;
  int count = 1;
  while(1){
    if(N < K) break;
    K *= A;
    count++;
    if(N < K) break;
  }
 cout << count << endl;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int d = a/b;
  int r = a%b;
  double f = double(a)/double(b);
  cout << d << " " << r << " ";
  printf("%.5lf\n", f);
}

Measured memory_bytes: 1240
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;


int main() {
    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    for(ll i=0;i<n;i++) cin >> t[i];
    sort(t.begin(),t.end());
    ll cnt=0,dep=t[0]+k,ans=0;
    for(ll i=0;i<n;i++){
        if(cnt==c||dep<t[i]){
            dep=t[i]+k;
            ans++;
            cnt=1;
        }
        else    cnt++;

    }
    if(cnt>0)   ans++;
    cout << ans << endl;
	return 0;
}

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

int main() {

  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while(true){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
}


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

main(){
  string s,ans="Yes";
  int i;
  cin >> s;
  
  for(i=0;i<s.length();i++){
    if((i%2==0 && s[i]=='L') || (i%2==1 && s[i]=='R')){
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())

short_time = (h * (360 / 12) + m * 0.5)
long_time = m * (360 / 60)


kakudo = abs(long_time - short_time)

ans = a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo))
print(math.sqrt(ans))

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,c;cin>>n>>c;

	vector<ll> xr(n + 2,0LL);
	vector<ll> xl(n + 2,0LL);
	vector<ll> vr(n + 2,0LL);
	vector<ll> vl(n + 2,0LL);
	vector<ll> sumr(n + 2,0LL);
	vector<ll> suml(n + 2,0LL);
	for(int i = 1; i <= n; i++) {
		cin>>xr[i]>>vr[i];
		vl[n - i + 1] = vr[i];
		xl[n - i + 1] = (c - xr[i]);
		sumr[i] = sumr[i - 1] + vr[i];
	}

	for(int i = 1; i <= n; i++) {
		suml[i] = suml[i - 1] + vl[i];
	}

	

	vector<ll> cr(n + 2,0LL);
	for(int i = n; i >= 1; i--) {
		cr[i] = max(cr[i + 1] ,sumr[n] - sumr[i] - (c - xr[i + 1]));
	}

	vector<ll> cl(n + 2,0LL);
	for(int i = n; i >= 1; i--) {
		cl[i] = max(cl[i + 1],suml[n] - suml[i] - (c - xl[i + 1]));
	}

	// for(int i = 1; i <= n; i++) {
	// 	cout << xl[i] << " " << vl[i] <<" " << cl[i] << endl;
	// }



	ll ans = 0LL;
	for(int i = 1; i <= n; i++) {
		ll tmp1 = sumr[i] - xr[i];
		ans = max(ans,tmp1);
		ll tmp2 = suml[i] - xl[i];
		ans = max(ans,tmp2);
		if (i < n){
			ll tmp3 = sumr[i] - 2 * xr[i] + cr[i]; 
			ans = max(ans,tmp3);
		}
		ll tmp4 = suml[i] - 2 * xl[i] + cl[i]; 
		ans = max(ans,tmp4);
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n;
    cin>>n;
    vector<int> d(n+1,0);
    int k = -1;
    for(int i=0;i<=n+1;i++){
	if( n == (int)(i*1.08) ){
	    k = i;
	    break;
	}
    }
    if( k != -1 ){
    	cout<<k<<endl;
    }else{
	cout<<":("<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

const double eps = 0.00001;
double q;

inline double next_x(double x)
{
    return x - (x * x * x - q) / (3 * x * x);
}

int main()
{
    cout << fixed << setprecision(6);

    while (cin >> q, q != -1) {
        double xn = q / 2;

        while (abs(xn * xn * xn - q ) >= eps * q) 
            xn = next_x(xn);

        cout << xn << endl;
    }

    return 0;
}

Measured memory_bytes: 1276
import java.util.*;

public class Main {
	
	private static int board[][] = new int[8][8];
	
	public static void main(String[] args) {
		
		//input
		Scanner sc = new Scanner(System.in);
		
		char[] c;
		char ret;
		int call_cnt = 0;
		while(sc.hasNext()){
			call_cnt++;
			for(int i=0;i<8;i++){
				c = sc.next().toCharArray();
				for(int j=0;j<8;j++){
					board[i][j] = Character.digit(c[j],10);
				}
			}
			
			ret = 'N';
			loop:for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					if(board[i][j] == 1){
						ret = check(i,j);
						if(!(ret == 'N')){break loop;}
					}
				}
			}
			System.out.println(ret);
		}
	}
	
	private static char check(int i,int j){
		char ret = 'N';
		if      (check_A(i,j)){ret = 'A';}
		else if (check_B(i,j)){ret = 'B';}
		else if (check_C(i,j)){ret = 'C';}
		else if (check_D(i,j)){ret = 'D';}
		else if (check_E(i,j)){ret = 'E';}
		else if (check_F(i,j)){ret = 'F';}
		else if (check_G(i,j)){ret = 'G';}
		return ret;
	}
	
	private static boolean check_A(int i,int j){
		boolean ret = false;
		if(i+1 != 8 && j+1 != 8){
			if(board[i][j+1]   == 1 &&
			   board[i+1][j]   == 1 &&
			   board[i+1][j+1] == 1){
				ret = true;
			}
		}
		return ret;
	}
	
	private static boolean check_B(int i,int j){
		boolean ret = false;
		if(i+3 < 8){
			ret = true;
			for(int k=1;k<4;k++){
				if(board[i+k][j] != 1){
					ret = false;
				}
			}
		}
		return ret;
	}
	
	private static boolean check_C(int i,int j){
		boolean ret = false;
		if(j+3 < 8){
			ret = true;
			for(int k=1;k<4;k++){
				if(board[i][j+k] != 1){
					ret = false;
				}
			}
		}
		return ret;
	}
	
	private static boolean check_D(int i,int j){
		boolean ret = false;
		if(i+2 < 8 && j-1 != -1){
			if(board[i+1][j]   == 1 &&
			   board[i+1][j-1] == 1 &&
			   board[i+2][j-1] == 1){
				ret = true;
			}
		}
		return ret;
	}
	private static boolean check_E(int i,int j){
		boolean ret = false;
		if(i+1 != 8 && j+2 < 8){
			if(board[i][j+1]   == 1 &&
			   board[i+1][j+1] == 1 &&
			   board[i+1][j+2] == 1){
				ret = true;
			}
		}
		return ret;
	}
	private static boolean check_F(int i,int j){
		boolean ret = false;
		if(i+2 < 8 && j+1 != 8){
			if(board[i+1][j]   == 1 &&
			   board[i+1][j+1] == 1 &&
			   board[i+2][j+1] == 1){
				ret = true;
			}
		}
		return ret;
	}

	private static boolean check_G(int i,int j){
		boolean ret = false;
		if(i+1 != 8 && j+1 != 8 && j-1 != -1 ){
			if(board[i][j+1]   == 1 &&
			   board[i+1][j]   == 1 &&
			   board[i+1][j-1] == 1){
				ret = true;
			}
		}
		return ret;
	}
}

Measured memory_bytes: 20068
#include<bits/stdc++.h>
#define input(arr, s, n) for (int i = s; i < n; i++) cin >> arr[i];
using namespace std;

int main()
{
    int n;
    cin >> n;
    double a = 0.0, s;

    for (int i = 0; i < n; i++) {
        cin >> s;
        a += 1.0 / s;
    }
    a = 1.0 / a;
    cout << setprecision(16) << a << "\n";
}


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

int main()
{
    int n,k,sum=0;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	sort(arr,arr+n);
for(int i=0;i<k;i++)
{

sum=sum+arr[i];

}
cout<<sum;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

ll H, W ,M;
ll BH[310000];
ll BW[310000];

ll EH[310000] = {};
ll EW[310000] = {};
bool EXMAXH[310000];
bool EXMAXW[310000];

int main(void){

    cin >> H >> W >> M;
    for (int i = 1; i <= M;i++) cin >> BH[i] >> BW[i];

    ll ans = 0;

    for (int i = 1; i <= M;i++){
        ll BHV = BH[i];
        ll BWV = BW[i];
        EH[BHV] += 1;
        EW[BWV] += 1;
    }

    ll MAXH = 0;
    ll MAXW = 0;
    ll MAXHcount = 0;
    ll MAXWcount = 0;

    for (int i = 1; i <= H;i++){
        if (MAXH < EH[i]) MAXH = EH[i];
    }
    for (int i = 1; i <= H;i++) {
        if (EH[i] == MAXH) {
            EXMAXH[i] = true;
            MAXHcount++;
        }
        else EXMAXH[i] = false;
    }
    for (int i = 1; i <= W;i++){
        if (MAXW < EW[i]) MAXW = EW[i];
    }
    for (int i = 1; i <= W;i++) {
        if (EW[i] == MAXW){
            EXMAXW[i] = true;
            MAXWcount++;
        } 
        else EXMAXW[i] = false;
    }

    ll BOMBcount = 0;
    for (int i = 1; i <= M;i++){
        if (EXMAXH[BH[i]] && EXMAXW[BW[i]]){
            BOMBcount++;
        }
    }

    ll Tspace = MAXHcount * MAXWcount;

    ans = MAXH + MAXW;
    if (Tspace == BOMBcount) ans--;

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 13576
import heapq
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
A = inpl()
q = []
for a in A:
    heapq.heappush(q,-a)
for _ in range(M):
    a = -heapq.heappop(q)
    a //= 2
    heapq.heappush(q,-a)
print(-sum(q))

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

#define MAX_V 1000
int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];


void graph_init(){
  for(int i=0;i<MAX_V;i++)G[i].clear();
}

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}
 
bool dfs(int v){
  used[v]=true;
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i],w=match[u];
    if( w<0 ||( !used[w] && dfs(w) )){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}
 
int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
        res++;
      }
    }
  }
  return res;
}


int main(){
  int N;
  typedef pair<int,int> P;
  vector<P> A,B;
  
  cin>>N;
  V=N*2;
  A.resize(N);
  B.resize(N);
  
  for(int i=0;i<N;i++){
    cin>>A[i].first>>A[i].second;
  }
  for(int i=0;i<N;i++){
    cin>>B[i].first>>B[i].second;
    
    for(int j=0;j<N;j++)
      if( A[j].first < B[i].first )
        if( A[j].second < B[i].second )
          add_edge(j,i+N);
  }

  cout<< bipartite_matching() <<endl;

  return 0;
}


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

int main(){

    int N;
    cin >> N;
    
    for(int i = 0;;i++){
        if((N-4*i)%7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
        if(N < 4 * i){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#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;
/*-----------------------------------------*/
struct UnionFind {
  UnionFind(int sz) : data(sz, -1) {}

  int root(int ver) { return data[ver] < 0 ? ver : data[ver] = root(data[ver]); }

  void unite(int ver1, int ver2) {
    ver1 = root(ver1);
    ver2 = root(ver2);
    if (ver1 != ver2) {
      if (data[ver1] > data[ver2]) swap(ver1, ver2);
      data[ver1] += data[ver2];
      data[ver2] = ver1;
    }
  }

  bool same(int ver1, int ver2) { return root(ver1) == root(ver2); }

  int size(int ver) { return -data[root(ver)]; }

private:
  vector<int> data;
};
// UnionFind uf(sz) = 頂点数 sz の Union-Find 木を考える
// uf.root(ver) = ver の根
// uf.unite(ver1, ver2) = ver1 と ver2 を併合する
// uf.same(ver1, ver2) = ver1 と ver2 は連結されているか?
// uf.size(ver) = ver を含む連結成分の個数

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n; int m; cin >> n >> m;
  vector<int> a(m), b(m);
  REP(i, m) {
    cin >> a[i] >> b[i]; --a[i]; --b[i];
  }
  reverse(ALL(a));
  reverse(ALL(b));
  long long fuben = n * (n - 1) / 2;
  vector<long long> ans(m);
  ans[0] = fuben;
  UnionFind uf(n);
  REP(i, m - 1) {
    if (uf.same(a[i], b[i])) {
      ans[i + 1] = fuben;
      continue;
    }
    long long sz1 = uf.size(a[i]), sz2 = uf.size(b[i]);
    fuben -= sz1 * sz2;
    ans[i + 1] = fuben;
    uf.unite(a[i], b[i]);
  }
  reverse(ALL(ans));
  REP(i, m) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  ll L, R; cin >> L >> R;

  R = min(R,L+2019);
  ll ans = inf;
  for(ll i=L; i<=R-1; i++) {
    for(ll j=i+1; j<=R; j++) {
      ans = min(ans, (i*j)%2019);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

		int[] y = new int[n];
		System.arraycopy(x, 0, y, 0, n);
		Arrays.parallelSort(y);

		int y1 = y[n / 2 - 1];
		int y2 = y[n / 2];
		for (int i = 0; i < n; i++) {
			if (y1 == y2) {
				System.out.println(y1);
			} else if (x[i] <= y1) {
				System.out.println(y2);
			} else {
				System.out.println(y1);
			}
		}
	}
}


Measured memory_bytes: 100352