akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
struct A {
	string name;
	int num;
};
queue<A>que;
signed main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		string s;
		int k;
		cin >> s >> k;
		que.push(A{ s,k });
	}
	int sum = 0;
	while (!que.empty()) {
		A t = que.front(); que.pop();
		if (t.num > q) {
			t.num -= q;
			sum += q;
			que.push(t);
		}
		else {
			sum += t.num;
			cout << t.name << " " << sum << endl;
		}
	}
}


Measured memory_bytes: 6252
H,W=map(int,input().split())
s=[[0 for x in range(W+2)] for y in range(H+2)]
for y in range(1,H+1):
	t=input()
	for i in range(W):
		if t[i]=='#':
			s[y][i+1]=1

for y in range(1,H+1):
	for x in range(1,W+1):
		if s[y][x]==1:
			for d in [[-1,0],[1,0],[0,-1],[0,1]]:
				f=False
				if s[y+d[0]][x+d[1]]==1:
					f=True
					break
			if f==False:
				print('No')
				exit()

print('Yes')



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

B = B[::-1]

j, bef = 0, -1
for i in range(N):
    if A[i] != bef:
        j = 0
    if A[i] == B[i]:
        while j < N:
            if A[j] != B[i] and B[j] != A[i]:
                B[i], B[j] = B[j], B[i]
                break
            j += 1
        if A[i] == B[i]:
            print("No")
            exit()

    bef = A[i]

print("Yes")
for b in B:
    print(b,end=" ")
print("")





Measured memory_bytes: 105216
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 210;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

ll a, b, c, d;

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

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

ll get(ll n) {
    if (n == 0) return 0;
    ll res = n / c + n / d - n / lcm(c, d);
    return n - res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> a >> b >> c >> d;
    cout << get(b) - get(a-1);
    return 0;
}

Measured memory_bytes: 256
// BFSを用いた閉路検出(トポロジカルソートを流用)
// 計算量 O(V + E) 
// reference Programming Contest Challenge Book Second Edition
// verify https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_4_A

#include <bits/stdc++.h>

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;//2^60
constexpr double kEPS = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

// --!!!!ここからコピペする!!!!--

template<typename T> struct Edge {
  int to;
  Edge(int to_) : to(to_) {}
};

template<typename T,template <typename ELEM> class EDGE> struct AdListGraph {
  vector<vector<EDGE<T>>> G;

  vector<bool> used;
  vector<int> deg;
  int V;//0,...,|V|-1

  AdListGraph (int V_) {
    Init(V_);
  }

  void Init(int V_) {
    V = V_;

    G.clear();
    G.resize(V);
  }

  // https://faithandbrave.hateblo.jp/entry/20080310/1205149207
  template <typename FROM, class... Args>
  void AddEdge(FROM from, Args&&... arg) {
    G[from].emplace_back(arg...);
  }

  template<typename ID_TYPE>
  bool TopologicalSort (vector<ID_TYPE>& sorted) { // 成功ならtrue 失敗(DAG出ない)ならfalseを返す
    used.clear();
    used.resize(V, false);
    deg.clear();
    deg.resize(V, 0);
    sorted.clear();

    for (const auto& v : G) 
      for (const auto& e : v)
        deg[e.to]++;

    queue<int> que;

    rep (i, V) if (deg[i] == 0) {used[i] = true; que.push(i);}


    while(!que.empty()) {
      int i = que.front();
      que.pop();
      sorted.emplace_back(i);

      for (auto& e: G[i]) {
        deg[e.to]--;
        if (!used[e.to] && deg[e.to] == 0) {
          used[e.to] = true;
          que.push(e.to);
        }
      }
    }

    // https://ikatakos.com/pot/programming_algorithm/graph_theory/topological_sort
    // トポロジカルソート出来なかったらDAGではない
    return (int)sorted.size() == V;
  }

};

using ll = long long;

signed main() {
  ll V,E;
  cin >> V >> E;
  AdListGraph<ll, Edge> G(V);
  rep(i,E) {
    ll s,t;
    cin >> s >> t;
    G.AddEdge(s,t);
  }

  vector<int> ans;

  cout << !G.TopologicalSort(ans) << endl;

  return 0;
}



Measured memory_bytes: 3172
#!python3

# import numpy as np


# input
K = int(input())


def main():
    l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    ans = l[K-1]
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for (ll i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j <= W - w[i]; j++) {
            dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
        }
        for (ll j = 0; j <= W; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << *max_element(dp[N].begin(), dp[N].end()) << endl;
}

Measured memory_bytes: 80256
X, Y, Z, K  = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

l = []
for a in A:
    for b in B:
        l.append(a+b)
l = sorted(l, reverse = True)[:K]

ans = []
for c in C:
    for k in l:
        ans.append(c + k)
        
ans = sorted(ans, reverse = True)
print(*ans[:K], sep="\n")

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

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


    int N;
    cin >> N;

    ll a[N];
    rep(i, N)
    {
        cin >> a[i];
    }

    ll base = 0;
    rep(i, N)
    {
        base ^= a[i];
    }

    rep(i, N)
    {
        ll  ans = base^a[i];
        cout << ans << " ";
    }




    return 0;
}



Measured memory_bytes: 5152
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int n,k;
int r,s,p;
int Xiaobo()
{	
	cin>>n;
	cin>>k;
	cin>>r>>s>>p;
	string str;
	cin>>str;
	ll ans=0;
	for(int i=0;i<n;i++) {
		if(i<k) {
			if(str[i]=='r') ans+=p;
			else if(str[i]=='s') ans+=r;
			else ans+=s;
		}
		else {
			if(str[i]!=str[i-k]) {
				if(str[i]=='r') ans+=p;
				else if(str[i]=='s') ans+=r;
				else ans+=s;	
			}
			else str[i]='1';
		}
	}
	cout<<ans<<'\n';
	return 0;	
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int t = in.nextInt();
		if (t == 0) return false;

		int[] h = new int[5];
		boolean[] f = new boolean[4];
		h[0] = t;
		f[t] = true;
		for (int i=1; i<5; i++) {
			h[i] = in.nextInt();
			f[h[i]] = true;
		}

		int cnt = 0;
		for (int i=1; i<=3; i++) {
			if (f[i]) cnt++;
		}

		if (cnt == 3 || cnt == 1) {
			for (int i=0; i<5; i++) {
				out.println("3");
			}
		} else {
			if (f[1] && f[2]) {
				for (int i=0; i<5; i++) {
					out.println(h[i] == 1 ? "1" : "2");
				}
			} else if (f[2] && f[3]) {
				for (int i=0; i<5; i++) {
					out.println(h[i] == 2 ? "1" : "2");
				}
			} else if (f[3] && f[1]){
				for (int i=0; i<5; i++) {
					out.println(h[i] == 3 ? "1" : "2");
				}
			}
		}

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 27756
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << int(ceil(n/(float)x))*t << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases
// multiset erase is does not do what it is supposed to


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int ,int> pi;
typedef pair<ll ,ll> pl;
typedef map<ll ,ll> ml;
#define modulo 1000000007
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N=1e5+1;


void solve()
{
    int n,ans;
    cin >> n;
    if(n%1000==0)ans=0;
    else ans=1000-n%1000;
    cout << ans << endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fast;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    n <<= 1;
    VI a(n); cin >> a;
    rSORT(a, greater<int>());
    int ans = 0;
    for (int i = 1; i < n; i += 2)ans += a[i];
    cout << ans << "\n";
}

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

using namespace std;

int n;
string s;
int a[30];

int main () {
    cin >> s;
    for (auto c : s) {
        a[c - 'a']++;
    }
    for (int i=0; i<26; i++) {
        if (a[i] & 1) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readStrings2() = readLn().split("").filter { it.isNotEmpty() }
private fun readInts2() = readStrings2().map(String::toInt)
private fun initArray(n:Int, v:String) = Array(n) { v }
private fun initIntArray(n:Int, v:Int) = IntArray(n) { v }

fun main(args: Array<String>) {
    val S = readStrings2()
    val T = readStrings2()

    var cnt = 0

    for (i in S.indices) {
        if(S[i] != T[i]) {
            cnt += 1
        }
    }

    println(cnt)
}

Measured memory_bytes: 82252
import numpy as np

n, w = map(int, input().split())
wv_list = [[int(i) for i in input().split()] for i in range(n)]

dp = np.zeros(w+1)

for wv in wv_list:
    w = wv[0]
    v = wv[1]
    dp[w:] = np.maximum(dp[:-w]+v, dp[w:])

print(int(np.max(dp)))

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

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    vector<vector<int>> memo(s.size()+1, vector<int>(t.size()+1,0));
    
    vector<vector<pair<int, int>>> par(s.size()+1, vector<pair<int, int>>(t.size()+1));
    for(int i = 0; i < s.size(); ++i) {
        for(int j = 0; j < t.size(); ++j) {
            if(memo[i+1][j+1] < memo[i+1][j]) {
                memo[i+1][j+1] = memo[i+1][j];
                par[i+1][j+1] = {i+1, j};
            }
            if(memo[i+1][j+1] < memo[i][j+1]) {
                memo[i+1][j+1] = memo[i][j+1];
                par[i+1][j+1] = {i, j+1};
            }
            
            if(s[i] == t[j]) {
                if(memo[i+1][j+1] < 1 + memo[i][j]) {
                    memo[i+1][j+1] = 1 + memo[i][j];
                    par[i+1][j+1] = {i, j};
                }
            }
        }
    }
    int currI = s.size();
    int currJ = t.size();
    string res = string(memo[currI][currJ], '$');
    int pos = (int)res.size()-1;
    while(pos >= 0) {
        const int toI = par[currI][currJ].first;
        const int toJ = par[currI][currJ].second;
        if(toI < currI && toJ < currJ) {
            res[pos--] = s[toI];
        }
        currI = toI;
        currJ = toJ;
    }
    cout << res << '\n';
    return 0;
}


























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


int main(void){
  int N,M;
  int A[10000];
  cin >> N >> M;
  
  int sum=0;
  for (int i=0; i<M; i++){
    cin >> A[i];
    sum+=A[i];
  }
  
  if (N>=sum){
    cout << N-sum << endl;
  }
  else{
    cout << "-1" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3144
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=400010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int n=read();
    int mx=0, mi=1e9;
    for(ri int i=1;i<=n;i++)
    {
        int x=read();
        mi=min(mi,x), mx=max(mx,x);
    }
    printf("%lld\n",mx-mi);
    return 0;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,h;
	cin >> n >> h;
	vector<int> b(n);
	int a = 0;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		a = max(a,x);
		b[i] = y;
	}

	sort(b.begin(),b.end(),greater<int>());

	int cnt = 0;
	for(int i = 0;i < n;i++){
		if(a < b[i]){
			h -= b[i];
			cnt++;
		} 
		else{
			cnt += (h + a - 1) / a;
			cout << cnt << endl;
			return 0;
		}
		if(h <= 0){
			cout << cnt << endl;
			return 0;
		}
	}

	if(h > 0){
		cout << cnt + (h + a-1) / a << endl;
	}
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import sys

def main():
    n = int(input())

    HP = [int(e) for e in input().split(" ")]

    while True:
        # 一番 HP の少ないモンスターが他に攻撃すれば良い
        min_idx = HP.index(min([e for e in HP if e > 0]))

        died = 0
        for i in range(n):
            if i == min_idx:
                continue
            if HP[i] <= 0:
                died += 1
                continue
            HP[i] %= HP[min_idx]
        if died == len(HP)-1:
            break

    for m in HP:
        if m > 0:
            print(m)

main()


Measured memory_bytes: 14224
import numpy as np
A,B = map(int,input().split())

mat = np.zeros((100,100),dtype=bool)

if A<=B:
    black = "."
    white = "#"
else:
    black = "#"
    white = "."

A,B = min(A,B),max(A,B)

a = A-1
b = B-1

for i in range(100):
    mat[0][i] = 1
for i in range(100):
    mat[1][i] = i%2

for line in range(2,100):
    if a>=50 and b>=50:
        for j in range(100):
            mat[line][j] = not(line%2 ^ j%2)
        a-=50
        b-=50
    elif a>0:
        for j in range(a*2):
            mat[line][j] = not(line%2 ^ j%2)
        b-=a
        a = 0
    else:
        break
for line in range(99,2,-2):
    if b>=50:
        for j in range(100):
            mat[line][j] = (j%2)
        b -= 50
    elif b>0:
        for j in range(b*2):
            mat[line][j] = (j%2)
        b = 0
    else:
        break

print("100 100")
for i in range(100):
    for j in range(100):
        if not mat[i][j]:
            print(black,end="")
        else:
            print(white,end="")
    print("")



Measured memory_bytes: 22668
#include <algorithm>
#include <queue>
#include <cstdio>
typedef long long LL ;
using namespace std ;
int main()
{
    int X,Y,Z;
    while(scanf("%d %d %d",&X,&Y,&Z)!=EOF)
    {
        int sum;
        sum=X-Z;
        printf("%d\n",sum/(Y+Z));
    }
    return 0;
}


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

int dp[3010][3010];
int main() {
  string S,T;
  cin >> S;
  cin >> T;
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < T.size(); j++) {
      if (S[i] == T[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
    }
  }
  string str = "";
  int i = S.size();
  int j = T.size();
  while (0 < i && 0 < j) {
    int x = dp[i][j];
    if (dp[i - 1][j] == x) {
      i--;
    } else if (dp[i][j -1] == x) {
      j--;
    } else {
      str = S[i - 1] + str;
      i--;
      j--;
    }
  }
  cout << str << endl;
  return 0;
}


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

using std::cin;
using std::cout;
using std::cerr;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using std::sort;
using std::reverse;

using ll = long long;

#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())
#define endl '\n'

struct __init {
    __init() {
        cin.tie(nullptr);
        std::iostream::sync_with_stdio(false);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
        std::mt19937 rand(300);
    }

    ~__init() {
        #ifdef SEREZHKA
            cerr << "Time elapsed: " << static_cast<double>(clock()) / CLOCKS_PER_SEC << endl;
        #endif
    }
} init;

const ll inf = (ll) 1e9 + 7ll;
const int maxn = (int) 1e5 + 17;

int n, root;
vector<int> g[maxn];
int dp[maxn];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n - 1) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    return true;
}

void dfs(int v, int pr) {
    int sum = 0;

    for (auto to : g[v])
        if (to != pr) {
            dfs(to, v);
            sum += max(dp[to], 1);
        }

    dp[v] = sum;

    for (auto to : g[v])
        if (to != pr && dp[to] == 0)
            dp[v] = sum - 1;
}

void solve() {
    root = -1;

    forn (i, n)
        if (sz(g[i]) > 2)
            root = i;

    if (root == -1) {
        cout << 1 << endl;
        return ;
    }

    dfs(root, -1);
    cout << dp[root] << endl;
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


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

int A,B,C,X;
int main(){
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;
	long long count = 0;
	for(int i=0;i<=A;i++){
		for(int j=0;j<=B;j++){
			for(int k=0;k<=C;k++){
				if(500*i+100*j+50*k==X) count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200000];
int main(){

    int n, c=0;
    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int j=1;
    for(int i=0 ; i<n ; i++){
              if(a[i]==j){
              j++;
              c++;
         }
    }
    j==1 ? printf("-1\n") : printf("%d\n", n-c);
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        int b = 0;
        int[] c = new int[n - 1];
        int d = 0;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
        }
        for(int i = 0; i < n; i++){
            b = b + scan.nextInt();
        }
        for(int i = 0; i < n - 1; i++){
            c[i] = scan.nextInt();
        }
        for(int i = 0; i < n - 1; i++){
            if(a[i] + 1 == a[i + 1]){
                d = d + c[a[i] - 1];
            }
        }
        System.out.println(b + d);
    }
}

Measured memory_bytes: 23636
#include<cstdio>
int main()
{
	int a,b,n;
	n=0;
	scanf("%d %d",&a,&b);
	if(a>=b){
		n+=a;
		a-=1;
	}
	else{
		n+=b;
		b-=1;
	}
	if(a>=b) n+=a;
	else n+=b;
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 1708
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	int a, b,c;
	scanf("%d%d", &a, &b);
	c = a - 2*b;
	if(c<0)printf("0\n");
	else printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 128
x,y,z,k=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
b=sorted(list(map(int,input().split())))[::-1]
c=sorted(list(map(int,input().split())))[::-1]
d=[]
for i in a:
  for j in b:
    d+=[i+j]
ans=[]
d=sorted(d)[::-1][:k]
for i in c:
  for j in d:
    ans+=[i+j]
print(*sorted(ans)[::-1][:k],sep='\n')

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else if (a == b) {
        cout << "a == b" << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

//#include <windows.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int ans = 0;

	int a, b, c;
	cin >> a >> b >> c;
	ans = c - (a - b);

	if (ans < 0) ans = 0;
	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif


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

int main() {
	stack<int> S1;
	stack< pair<int, int> > S2;
	char ch;
	int sum = 0;
	for (int i=0; cin >> ch; i++) {
		if(ch == '\\') S1.push(i);
		else if(ch == '/' && S1.size()>0) {
			int j = S1.top();
			S1.pop();
			int a = i - j;
			sum += a;
			while (S2.size() > 0 && S2.top().first > j) {
				a += S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	
	vector<int> ans;
	while (S2.size() > 0) {
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout << sum << endl;
	cout << ans.size();
	for( int i = 0; i < ans.size(); i++) {
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
	
	return 0;
	
}

Measured memory_bytes: 3144
S = input()

a = S[:2]
b = S[2:]

if 1 <= int(a) <= 12 and 1 <= int(b) <= 12:
    print('AMBIGUOUS')
elif 0 <= int(a) <= 99 and 1 <= int(b) <= 12:
    print('YYMM')
elif 1 <= int(a) <= 12 and 0 <= int(b) <= 99:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 38384
using System.Numerics;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var t = int.Parse(line[1]);
        var s = Console.ReadLine().Trim();
        var sL = s.Length;
        BigInteger a = 0;
        for (int i = 0; i <= 9; i++)
        {
            var w = sL - s.Replace(i.ToString(), "").Length;
            if (w > 0) a += BigInteger.Pow(n, i) * w;
        }
        a *= t;
        if (a > 1000000000) Console.WriteLine("TLE");
        else Console.WriteLine(a);
    }
}



Measured memory_bytes: 18108
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int x, y;
	cin >> x >> y;
	cout << x + y/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 2e5+5;
long long INF = 0x3f3f3f3f3f3f3f3f;
int n;
long long a[maxn];
long long summ[maxn];
long long cal(long long x)
{
    int pos = lower_bound(a+1,a+1+n,x)-a;
    long long sum1 = 1LL* x *(pos-1) -summ[pos-1];
    long long sum2 =  summ[n]-summ[pos-1] - 1LL*(n-pos+1)*x ;
    return sum1+sum2;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]-=i;
    }
    sort(a+1,a+1+n);
    long long sum = 0;
    for(int i=1;i<=n;i++)
    {
        summ[i]=summ[i-1]+a[i];
        sum+=a[i];
    }
    long long ans = INF;
    long long tmp = sum/n;
    for(long long i = tmp-5000000;i<= tmp+ 5000000;i++)
    {
        ans = min (ans,cal(i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }


int main(){
    ll N=ii();
    ll zmax=LLONG_MIN, zmin=LLONG_MAX, wmax=LLONG_MIN, wmin=LLONG_MAX; 
    REP(i,0,N){
        ll x=ii();
        ll y=ii();
        ll z=x+y;
        ll w=x-y;
        maxin(zmax, z);
        minin(zmin, z);
        maxin(wmax, w);
        minin(wmin, w);
    }
    oie(max(zmax-zmin, wmax-wmin));
    

    return 0;
}


Measured memory_bytes: 3628
#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 a, b, k;
    cin >> a >> b >> k;
    int num = 0;
    for (int i = min(a,b); 1 <= i; i--) {
        if (a%i==0 && b%i==0) num++;
        if (num == k) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
  int N;cin >> N;
  int mi=300000,a=0;
  for(int i=0; i<N; i++){
    int P;cin >> P;
    if(P<=mi){
      a++;mi=P;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int h,m,s,S,a;
	scanf("%d",&S);
	h = S / 3600;
	a = S - h * 3600;
	m = a / 60;
	s = a % 60;
	printf("%d:%d:%d\n",h,m,s);
	
	
	return 0;
}

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

int main(){
int n;
ll sum =0;
cin >> n;
for(int i=1;i<=n;i++){
    if(i%3 == 0 || i%5==0){
        continue;
    }
    sum += i;
}
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector> 

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }

    sort(V.begin(), V.end());

    double tmp = V[0];
    for (int i = 1; i < N; i++) {
        tmp = (double)(tmp + V[i])/2;
    }

    cout << setprecision(10) << tmp << endl;
    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n,K;
	scanf("%d%d",&n,&K);

	vector<pair<double,double>> ps;
	const double PI=3.14159265359;
	rep(i,0,n){
		double x,y,r;
		scanf("%lf%lf%lf",&x,&y,&r);
		if(y+r<=0) continue;
		if(y-r<=0){
			double f,s;
			if(x<0){
				f=atan2(y,x)-asin(r/sqrt(x*x+y*y));
				s=PI;
			}else{
				f=0;
				s=atan2(y,x)+asin(r/sqrt(x*x+y*y));
			}
			while(f<0) f+=PI;
			while(s<0) s+=PI;
			ps.push_back(mp(f,s));
		}else ps.push_back(mp(atan2(y,x)-asin(r/sqrt(x*x+y*y)),atan2(y,x)+asin(r/sqrt(x*x+y*y))));
	}
	
	sort(ps.begin(),ps.end());
	ps.erase(unique(ps.begin(),ps.end()),ps.end());
	
	vector<pair<double,double>> tmp;
	rep(i,0,ps.size()){
		bool ok=true;
		rep(j,0,ps.size()){
			if(i==j) continue;
			if(ps[j].first<=ps[i].first&&ps[i].second<=ps[j].second){
				ok=false;
				break;
			}
		}
		if(ok) tmp.push_back(ps[i]);
	}
	ps=tmp;

	if(ps.size()==0){
		cout << 0 << endl;
		return;
	}

	vector<int> a(ps.size());
	rep(i,1,ps.size()){
		rep(j,0,i+1){
			if(ps[j].second>=ps[i].first){
				a[i]=j;
				break;
			}
		}
		if(a[i]==i) a[i]=i-1;
	}

	static double dp[1500][1501][2];
	dp[0][0][0]=0;
	dp[0][1][1]=ps[0].second-ps[0].first;
	double ans=dp[0][1][1];
	rep(i,1,ps.size()){
		rep(j,0,K+1){
			dp[i][j][0]=max(dp[i-1][j][0],dp[i-1][j][1]);
			if(j==0) continue;
			if(j==1) dp[i][j][1]=ps[i].second-ps[i].first;
			dp[i][j][1]=max(dp[a[i]][j-1][1]+ps[i].second-max(ps[i].first,ps[a[i]].second),dp[a[i]][j-1][0]+ps[i].second-ps[i].first);
			ans=max({ans,dp[i][j][1],dp[i][j][0]});
		}
	}

	printf("%.10lf\n",ans/PI);
}

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

Measured memory_bytes: 36584
#include "bits/stdc++.h"
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1e9+7
#define inf 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec));
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define cend cout<<endl;
#define P pair<int,int>
#define prique priority_queue<P,vector<P>,greater<P>>
using namespace std;

signed main() {
	int m;
	cin>>m;
	cout<<48-m<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b) gcd(b, a);
	long long  r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
namespace NTT {
	const int MOD = 998244353;  // to be set appropriately
	const long long PR = 3;     // to be set appropriately

	void trans(vector<long long> &v, bool inv = false) {
		int n = (int)v.size();
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k >(i ^= k); k >>= 1);
			if (i > j) swap(v[i], v[j]);
		}
		for (int t = 2; t <= n; t <<= 1) {
			long long bw = modpow(PR, (MOD - 1) / t, MOD);
			if (inv) bw = modinv(bw, MOD);
			for (int i = 0; i < n; i += t) {
				long long w = 1;
				for (int j = 0; j < t / 2; ++j) {
					int j1 = i + j, j2 = i + j + t / 2;
					long long c1 = v[j1], c2 = v[j2] * w % MOD;
					v[j1] = c1 + c2;
					v[j2] = c1 - c2 + MOD;
					while (v[j1] >= MOD) v[j1] -= MOD;
					while (v[j2] >= MOD) v[j2] -= MOD;
					w = w * bw % MOD;
				}
			}
		}
		if (inv) {
			long long inv_n = modinv(n, MOD);
			for (int i = 0; i < n; ++i) v[i] = v[i] * inv_n % MOD;
		}
	}

	// C is A*B
	vector<long long> mult(vector<long long> A, vector<long long> B) {
		int size_a = 1; while (size_a < A.size()) size_a <<= 1;
		int size_b = 1; while (size_b < B.size()) size_b <<= 1;
		int size_fft = max(size_a, size_b) << 1;

		vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0);
		for (int i = 0; i < A.size(); ++i) cA[i] = A[i];
		for (int i = 0; i < B.size(); ++i) cB[i] = B[i];

		trans(cA); trans(cB);
		for (int i = 0; i < size_fft; ++i) cC[i] = cA[i] * cB[i] % MOD;
		trans(cC, true);

		vector<long long> res((int)A.size() + (int)B.size() - 1);
		for (int i = 0; i < res.size(); ++i) res[i] = cC[i];
		return res;
	}
};
typedef pair<int, int> p;
typedef pair<int, p> pai;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int cnt[4] = { 0 };
	int a, b;
	for (int i = 1; i <= 3; i++) {
		cin >> a >> b;
		cnt[a-1] += 1;
		cnt[b-1] += 1;
	}
	sort(cnt, cnt + 4);
	if (cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 2 && cnt[3] == 2)cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

template <class Edge>
decltype(auto) FloydWarshall(const vector<Edge> & edges,
                 typename vector<Edge>::size_type node_num) {
  using size_type = typename vector<Edge>::size_type;
  using w_type = typename Edge::w_type;
  const w_type kInf = numeric_limits<int>::max();

  vector<vector<w_type>> adjacency_matrix(node_num, vector<w_type>(node_num, kInf));
  for (const auto & e: edges) {
    adjacency_matrix[e.u][e.v] = e.w;
  }
  for (unsigned i = 0; i < node_num; ++i) {
    adjacency_matrix[i][i] = 0;
  }

  auto dist_prev = adjacency_matrix;
  for (unsigned k = 0; k < node_num; ++k) {
    vector<vector<w_type>> dist_now = dist_prev;
    for (unsigned i = 0; i < node_num; ++i) {
      for (unsigned j = 0; j < node_num; ++j) {
        if (dist_prev[i][k] == kInf || dist_prev[k][j] == kInf) { continue; }
        dist_now[i][j] = min(dist_prev[i][j], dist_prev[i][k] + dist_prev[k][j]);
      }
    }
    dist_prev = dist_now;
  }

  for (unsigned i = 0; i < node_num; ++i) {
    if (dist_prev[i][i] < 0) {
      return make_pair(false, dist_prev);
    }
  }

  return make_pair(true, dist_prev);
}

int main(int argc, char const *argv[]) {
  using w_type = int;
  const w_type kInf = numeric_limits<w_type>::max();
  vector<Edge<w_type>> edges;
  unsigned V, E;
  cin >> V >> E;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    w_type w;
    cin >> u >> v >> w;
    edges.emplace_back(u, v, w);
  }

  auto ans = FloydWarshall(edges, V);
  auto have_neg_cycle = ans.first;
  auto dist = ans.second;
  if (!have_neg_cycle) {
    cout << "NEGATIVE CYCLE\n";
  } else {
    for (unsigned i = 0; i < V; ++i) {
      for (unsigned j = 0; j < V; ++j) {
        if (dist[i][j] == kInf) {
          cout << "INF";
        } else {
          cout << dist[i][j];
        }
        if (j == V - 1) {
          cout << "\n";
        } else {
          cout << " ";
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3280
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N, M; cin >> N >> M;
    vii jobs(M, vi());
    rep(i, 0, N){
        int a, b; cin >> a >> b;
        if(a > M) continue;
        jobs[M-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for(int i=M-1; i>=0; i--){
        for(int b: jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}




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

signed main(){
	int N, A, i, l, h, r;
	scanf("%lld", &N);
	vector<int> Anum(N + 1, 0), num(N + 1, 0);
	for(i = 0; i < N; i++){
		scanf("%lld", &A);
		Anum[A]++;
		num[Anum[A]]++;
	}
	for(i = 1; i <= N; i++) num[i] += num[i - 1];
	for(i = 1; i <= N; i++){
		for(l = 0, h = 0, r = N + 1; r - l > 1; h = (l + r) / 2){
			if(num[h] < h * i) r = h;
			else l = h;
		}
		printf("%lld\n", l);
	}
	return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void solve() {
	ll h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	REP(i, h) cin >> s[i];

	Matrix sum(h + 1, Array(w + 1, 0));
	REP(i, h) {
		REP(j, w) {
			sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j];
			if (s[i][j] == '1')sum[i + 1][j + 1]++;
		}
	}

	auto check = [&](ll y1, ll y2, ll x1, ll x2) {
		return sum[y1][x1] - sum[y1][x2] - sum[y2][x1] + sum[y2][x2];
	};

	ll ans = (h - 1) * (w - 1);
	REP(bit, (1LL << (h - 1))) {
		Array th(1, 0);
		ll con = 0;
		REP(i, h - 1) {
			if (bit & (1LL << i)) {
				th.push_back(i + 1);
				con++;
			}
		}
		th.push_back(h);

		bool flag = true;
		ll pre = 0;

		REP(j, w) {
			bool flag2 = true;
			REP(i, th.size() - 1) {
				if (check(th[i + 1], th[i], j + 1, pre) > k) {
					flag2 = false;
					break;
				}
			}
			if (flag2) continue;
			pre = j;
			con++;
			flag2 = true;
			REP(i, th.size() - 1) {
				if (check(th[i + 1], th[i], j + 1, pre) > k) {
					flag2 = false;
					break;
				}
			}
			if (flag2) continue;
			flag = false;
			break;
		}

		if (flag) chmin(ans, con);

	}
	cout << ans << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#define PI acos(-1.0)
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	double t = 1;//当前比例 
	int now;//当前分数 
	double ans = 0;	
	for(int i = 1;i <= n;i++){
		t = 1.0/n;
		now = i;
		while(now < k){
			now *= 2;
			t /= 2;
		}
		ans += t;
	}
	printf("%.12lf",ans);
	return 0;
}

Measured memory_bytes: 256