akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	ll ze[300000] = {}, on[300000] = {};
	int n;
	cin >> n;
	vector <ll> a(n);
	REP(i, n) cin >> a[i];
	REP(i, n){
		REP(j, 60){
			if((ll)1 << j & a[i]) on[j]++;
			else ze[j]++;
		}
	}
	REP(j, 60){
		ll mo = ((ll)1 << j) % MODA;
		ll co = (ze[j] * on[j]) % MODA;
		ans += co * mo;
		ans %= MODA;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7424
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 2000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
	ll x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

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


/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {
		x = 1; y = 0; return a;
	}
	ans = exgcd(b, a%b, x, y);
	ll t = x; x = y; y = t - a / b * y;
	return ans;
}
*/

int n;
ll a[maxn];
ll maxleft[maxn], minrgt[maxn];
priority_queue<int, vector<int>, greater<int> >q1;
priority_queue<int>q2;


int main() {
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < 3 * n; i++)rdllt(a[i]);
	for (int i = 0; i < n; i++) {
		maxleft[0] += a[i];
		q1.push(a[i]);
		minrgt[n + 1] += a[3 * n - i - 1]; q2.push(a[3 * n - i - 1]);
	}
	for (int i = 1; i <= n; i++) {
		q1.push(a[n + i - 1]);
		maxleft[i] = maxleft[i - 1] + a[n + i - 1] - q1.top();
		q1.pop();
		q2.push(a[2 * n - i]);
		minrgt[n - i + 1] = minrgt[n - i + 1 + 1] + a[2 * n - i] - q2.top();
		q2.pop();
	}
	ll maxx = -inf * 1ll;
	for (int i = 0; i <= n; i++) {
		if (i == 0)maxx = maxleft[i] - minrgt[i + 1];
		else maxx = max(maxx, maxleft[i] - minrgt[i + 1]);
	}
	cout << maxx << endl;
	return 0;
}

Measured memory_bytes: 10228
def main():
    S = input()
    N = len(S)
    K = int(input())
    dp = [[[0]*5 for j in range(2)] for i in range(N+1)]
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(2):
            for k in range(4):
                lim = (9 if j else int(S[i]))
                for d in range(lim + 1):
                    # print(i, j, lim, d, j or d < lim)
                    dp[i+1][j or d < lim][k + int(d != 0)] += dp[i][j][k]
    print((dp[N][0][K]+dp[N][1][K]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 40048
#include<stdio.h>
int main(void){
  int A1,A2,A3,A4;
  scanf("%d %d %d",&A1,&A2,&A3);
  A4 = A1+A2+A3;
  if(A4>21) printf("bust\n");
  else printf("win\n");
  return 0;
}

Measured memory_bytes: 128
s=input()
i=0
k=0
ans=0
while i<len(s):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        while i<len(s):
            if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
                k+=1
            else:
                break
            i+=1
    i+=1
    ans=max(k,ans)
    k=0
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    int N; cin >> N;
    
    int M; cin >> M;
    
    ll P; cin >> P;
    vector<vpl > graph(N);
    vector<vi > graph2(N);
    F0R(i, M) {
		int A, B, C; cin >> A >> B >> C; A--; B--; C-=P;
		graph[A].pb(mp(B, C)); 
		graph2[B].pb(A);
	}
	
	bool foundEnd[N]; F0R(i, N) foundEnd[i] = false;
	queue<int> q;
	q.push(N-1);
	foundEnd[N-1] = true;
	while (!q.empty()) {
		int cur = q.front(); q.pop();
		F0R(i, sz(graph2[cur])) {
			int nxt = graph2[cur][i];
			if (!foundEnd[nxt]) {
				foundEnd[nxt] = true;
				q.push(nxt);
			}
		}
	}
	
	ll dist[N];
	F0R(i, N) {
		dist[i] = -1000000000000;
	}
	dist[0] = 0;
	
	bool found[N]; F0R(i, N) found[i] = false;
	
	found[0] = true;
	
	F0R(i, N) {
		F0R(j, N) {
			if (dist[j] == -1000000000000) continue;
			F0R(k, sz(graph[j])) {
				int nxt = graph[j][k].f;
				found[nxt] = true;
				if (dist[nxt] < dist[j] + graph[j][k].s) {
					dist[nxt] = dist[j]+graph[j][k].s;
				}
			
			}
		}
	}
	
	/*F0R(i, N) {
		cout << dist[i] << " ";
	} cout << endl;*/
	
	F0R(i, N) {
		F0R(j, sz(graph[i])) {
		
			int k = graph[i][j].f;
			if (dist[k] == -1000000000000 || dist[i] == -1000000000000) continue;
			if (dist[k] < dist[i] + graph[i][j].s && foundEnd[k]) {
				cout << -1 << endl; return 0;
			}
		}
	}
	
	cout << max(0LL, dist[N-1]) << endl;
	
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// Abstract Segment Tree (抽象・汎化セグメント木)
// Verified: AOJ DSL_2_A: Range Minimum Query (int型のみ)

const int SIZE = 1 << 17; // 2^17 = 131072
template<typename T>
struct segtree {
    // ノード、単位元
    T node[2*SIZE], I;

    // オペレーション (update, query の 2 つが必要？)
    T (*upd_f)(T, T), (*qry_f)(T, T);

    // 演算子と単位元をセットし、全ての node を単位元で初期化
    segtree(T (*op1)(T, T), T (*op2)(T, T), T X) {
        upd_f = op1;
        qry_f = op2;
        I = X;
        fill(node, node+2*SIZE, I);
    }

    // 配列 vec の値で初期化
    void init(vector<T> vec) {
        int N = (int)vec.size();
        for(int i=0; i<N; i++) {
            node[SIZE-1+i] = vec[i];
        }
        for(int i=SIZE-2; i>=0; i--) {
            node[i] = qry_f(node[2*i+1], node[2*i+2]);
        }
    }

    // 場所 idx に値 val を反映 (upd_f を用いて update)
    void update(int idx, T val) {
        idx += SIZE - 1;
        node[idx] = upd_f(node[idx], val);
        while(idx > 0) {
            // 登るときは qry_f を使うことに注意！！！
            idx = (idx - 1) / 2;
            node[idx] = qry_f(node[2*idx+1], node[2*idx+2]);
        }
    }

    // 半開区間 [a, b) に対してクエリを投げる
    // (qry_f を用いて処理)
    T query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return I;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        T vl = query(a, b, l, mid, 2*k+1);
        T vr = query(a, b, mid, r, 2*k+2);
        return qry_f(vl, vr);
    }
};

// [[つかいかた]]
// update 用と query 用の関数と単位元 (関数を噛ませても結果が変わらないもの) を用意して宣言する
// 下の例だと、update 用の関数が upd で、query 用の関数が fnd で、単位元が INT_MAX

using Pair = pair<int, int>;
Pair upd(Pair a, Pair b) {return max(a, b);}
Pair fnd(Pair a, Pair b) {return max(a, b);}
segtree<Pair> seg(upd, fnd, make_pair(0, 0));

const int S = 100010;
signed main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }


    for(int i=0; i<N; i++) {
        int val = A[i];
        Pair ma = seg.query(0, val);
        int X, Y; tie(X, Y) = ma;

        X += 1;
        Y += val;
        seg.update(val, make_pair(X, Y));
    }

    cout << seg.query(0, S).second << endl;
    return 0;
}



Measured memory_bytes: 7516
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) {
      cin >> x[i];
      y[i] = x[i];
    }
    sort(y.begin(), y.end());
    rep(i, n) {
      if (x[i] <= y[n / 2 - 1]) {
        cout << y[n / 2] << '\n';
      } else {
        cout << y[n / 2 - 1] << '\n';
      }
    }

    return 0;
}


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


def main():
    N = input()[:-1]
    
    cnt = 0
    for i in range(0, len(N), 2):
        if i==len(N)-1:
            cnt += int(N) - 10**i + 1
        else:
            cnt += 10**(i+1) - 10**i

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int main(){
	int n;
	while(cin>>n,n){
		int a=0,b=0;
		FOR(i,n){
			int x,y; cin>>x>>y;
			if(x>y) a+=x+y;
			else if(x<y) b+=x+y;
			else a+=x,b+=y;
		}
		printf("%d %d\n",a,b);
	}
    return 0;
}

Measured memory_bytes: 1144
#include <cstdio>
#include <iostream>
#include <complex>
#include <vector>
using namespace std;

typedef complex<double> point;
double cross(const point& a, const point& b) {
	return imag(conj(a)*b);
}

typedef vector<point> polygon;
double area2(const polygon& P) {
	double A = 0;
	for (int i = 0; i < P.size(); ++i) 
		A += cross(P[i], P[(i + 1) % P.size()]);
	return A;
}

int main() {
	int n;
	while (cin >> n) {
		polygon pol(n);
		for (auto& p : pol) {
			int x, y;
			cin >> x >> y;
			p = point(x, y);
		}
//		pol = polygon(pol.rbegin(), pol.rend());
		double a = area2(pol);
		printf("%.1lf\n", a / 2.);
	}
	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        double a2 = a;
        double b2 = b;
        
        double result = (a2 + b2)/2;
        
        int ans = (int) Math.ceil(result);
        System.out.println(ans);
    
    }
}

Measured memory_bytes: 20564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		int ans = Math.min(A, B) + Math.min(C, D);
		System.out.println(ans);
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
ll n,w,h,k;
bool bomb[55][55];

inline int query(int a,int b,int c,int d){
	cout << "? " <<  a << " " << b << " " << c-1 << " " << d-1 << endl << flush;
	int ret;
	cin >> ret;
	return ret;
}

inline int rec(int a,int b,int c,int d,int rest){
	if(c<=a or d<=b) return 0;
	if(rest==0) return 0;
	//cout << a << " " << b << " " << c << " " << d << endl;
	
	const int area=(c-a)*(d-b);
	int res=query(a,b,c,d);
	if(res==0) return 0;
	if(res==area){
		rep(y,a,c)rep(x,b,d) bomb[y][x]=true;
		return area;
	}
	if(1.0*res/area>0.8){
		rep(y,a,c)rep(x,b,d) rec(y,x,y+1,x+1,1);
		return res;	
	}
	chmin(rest,res);

	const int ym=(a+c)/2,xm=(b+d)/2;
	rest-=rec(a,b,ym,xm,rest);
	rest-=rec(ym,b,c,xm,rest);
	rest-=rec(a,xm,ym,d,rest);
	rest-=rec(ym,xm,c,d,rest);
	return rest;
}

int main(void){
	cin >> h >> w >> n >> k;
	rec(0,0,h,w,n);
	
	ll ans=0LL,cur=1LL;
	rep(i,h)rep(j,w){
		if(bomb[i][j]) ans=(ans+cur)%k;
		cur=(2LL*cur)%k;
	}

	cout << "! " << ans << endl  << flush;
	return 0;
}

Measured memory_bytes: 720
#include <functional>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <type_traits>
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x) noexcept {
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer() noexcept
		: m_value(0)
	{ }
	modulus_integer(int x) noexcept
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const noexcept { return m_value; }
	self_type& operator=(const self_type& x) noexcept {
		m_value = x.m_value;
		return *this;
	}
	self_type operator+(const self_type& x) const noexcept {
		const int y = m_value + x.m_value;
		return unsafe_construct(y >= MOD ? y - MOD : y);
	}
	self_type& operator+=(const self_type& x) noexcept {
		return (*this = *this + x);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
}
using namespace std;
using mint = loquat::modulus_integer<998244353>;
static mint dp[4001][4001];
int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const int n = s.size();
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ a[i] = s[i] - '0'; }
	vector<int> r, b;
	for(int i = 0; i < n; ++i){
		switch(a[i]){
		case 0:
			r.push_back(i);
			r.push_back(i);
			break;
		case 1:
			r.push_back(i);
			b.push_back(i);
			break;
		case 2:
			b.push_back(i);
			b.push_back(i);
			break;
		}
	}
	const int m = 2 * n;
	for(int i = 0; i <= m; ++i){
		for(int j = 0; j <= m; ++j){ dp[i][j] = 0; }
	}
	dp[0][0] = 1;
	for(int i = 0; i < m; ++i){
		for(int j = 0; j <= i; ++j){
			const int x = j, y = i - j;
			if(x < r.size() && r[x] <= i){
				dp[i + 1][j + 1] += dp[i][j];
			}
			if(y < b.size() && b[y] <= i){
				dp[i + 1][j] += dp[i][j];
			}
		}
	}
	cout << dp[m][r.size()] << endl;
	return 0;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int w, h, n;
    cin >> w >> h >> n;
    int x[n], y[n], a[n];
    rep(i, n) { cin >> x[i] >> y[i] >> a[i]; }
    // rep(i, n) { cout << x[i] << y[i] << a[i]; }

    // 処理
    int v = 0;
    int u = w;
    int l = 0;
    int z = h;
    rep(i, n) {
        if (a[i] == 1) {
            v = max(v, x[i]);
        } else if (a[i] == 2) {
            u = min(u, x[i]);
        } else if (a[i] == 3) {
            l = max(l, y[i]);
        } else {
            z = min(z, y[i]);
        }
    }
    // cout << v << " " << u << " " << l << " " << z << endl;
    // int ans = (u - v) * (z - l);

    // 出力
    cout << max(u - v, 0) * max(z - l, 0) << endl;
    return 0;
}


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

int main () {
	
	int n = 0;
	const int max_n = 2;
	std::vector<int> v;
	int i,j;
	int tmp;
	
	while(n++ <= max_n) {
		std::cin >> tmp; 
		v.push_back(tmp);
	}
	n = 0;

	for (i = max_n; i; i--) {
		for (j = 0; j < i; j++) {
			if (v[j] > v[j+1]) {
				tmp = v[j];
				v[j] = v[j+1];
				v[j+1] = tmp;
			}
		}
	}
	
	while(n <= max_n) {
		if (n - max_n)
			std::cout << v[n] << " ";
		else
			std::cout << v[n] << std::endl;
		n++;
	} 

	return 0;
}



Measured memory_bytes: 3148
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define inf int(1e9)
#define half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;

ll a, b, c, k;

int main() {
    cin >> a >> b >> c >> k;
    ll ans = k % 2 == 0 ? a - b : b - a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int MAXN=100000;
ll a[MAXN+5],b[MAXN+5];
ll res,x,n;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i],&b[i]);
	for(int i=n;i>=1;i--)
	{
		a[i]=(b[i]-(a[i]+res)%b[i])%b[i];
		res+=a[i];
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 1792
class Dice
  def initialize(faces)
    @top = faces.shift
    @front = faces.shift
    @right = faces.shift
    @left = faces.shift
    @back = faces.shift
    @bottom = faces.shift
  end

  def turn_to_n
    old_top = @top
    @top = @front
    @front = @bottom
    @bottom = @back
    @back = old_top
  end

  def turn_to_e
    old_top = @top
    @top = @left
    @left = @bottom
    @bottom = @right
    @right = old_top
  end

  def turn_to_w
    old_top = @top
    @top = @right
    @right = @bottom
    @bottom = @left
    @left = old_top
  end

  def turn_to_s
    old_top = @top
    @top = @back
    @back = @bottom
    @bottom = @front
    @front = old_top
  end

  def right_when_top_and_front_are(top, front)
    set_top_to(top)
    keep_top_and_set_front_to(front)
    @right
  end

  attr_reader :top, :right

  private

  def set_top_to(top)
    return if @top == top
    case top
      when @front then turn_to_n
      when @left then turn_to_e
      when @right then turn_to_w
      when @back then turn_to_s
      else turn_to_s; turn_to_s
    end
  end

  def keep_top_and_set_front_to(front)
    return if @front == front
    case front
      when @left then turn_to_e; turn_to_s; turn_to_w
      when @right then turn_to_w; turn_to_s; turn_to_e
      when @back then turn_to_e; turn_to_s; turn_to_s; turn_to_w
    end
  end
end

faces = gets.split(" ").map(&:to_i)
n = gets.to_i
questions = (1..n).map {gets.split(" ").map(&:to_i)}

dice = Dice.new(faces)
questions.each {|q|
  top, front = q
  puts dice.right_when_top_and_front_are(top, front)
}

Measured memory_bytes: 8688
while True:
    h,w=map(int,input().split())
    if h == 0 and w == 0:
        break
    for a in range(h):
        if a % 2 == 0:
            if w % 2 == 0:
                print('#.'*(w//2))
            else:
                print('#.'*((w-1)//2)+'#')
        else:
            if w % 2 == 0:
                print('.#'*(w//2))
            else:
                print('.#'*((w-1)//2)+'.')            
    print()


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;

const int maxn= 500000 + 10;

char s[maxn];
int f[maxn], zer[maxn], N;

int main(){
	scanf("%d", &N);scanf("%s", s+1);
	for (int i= 1, lst=0; i<=N; i++){
		zer[i] = lst;
		if ( s[i]=='0') lst= i;
	}
	f[0] = 0;
	for (int i=1; i<=N; i++){
		f[i] = f[i-1];
		if ( s[i]=='0') continue;	else
		if ( !zer[i] || s[ zer[i]-1] !='1' ) continue;	else{
			f[i] = max( f[i]  , f[zer[i]-2]+ i-zer[i]);
			if ( zer[i]==i-1){
				int zzr = zer[ zer[i]];
				f[i] =max(f[i], f[zzr] + i-zzr-2);
				if ( zzr+1<zer[i]) f[i] = max(f[i], f[zzr+1]+i-zzr-3);
			}
		}
	}
	printf("%d\n", f[N]);
	return 0;
}



Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e5 + 2;
int mem[N];
int arr[N];
int k;
void init() {
    mem[0] = 0;
    for (int i = 1; i < N; i++) {
        mem[i] = 1e9;
    }
}
int findshortest() {
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= i + k; j++) {
            if (j < n) {
                mem[j] = min(mem[j] , mem[i] + abs(arr[i] - arr[j]));
            }
            
        }
    }
    return mem[n - 1];
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    init();
    cout << findshortest() << endl;

    

}

Measured memory_bytes: 4372
#include <cstdio>
#include <cstring>
#include <cstdlib>
int main()
{
	char s[1005];
	char a[1005];
	char b[1005];
	while(~scanf("%s",s))
	{
		int c1=0,c2=0,c3=0,c4=0;
		for(int i=0;s[i];i++)
		{
			if(s[i]=='N')
				c1++;
			if(s[i]=='S')
				c2++;
			if(s[i]=='W')
				c3++;
			if(s[i]=='E')
				c4++;
		}
		if(((c1==0&&c2>0)||(c2==0&&c1>0))||((c3==0&&c4>0)||(c4==0&&c3>0)))
			printf("No\n");
		else 
			printf("Yes\n");
	}
} 

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


int main()
{
	    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    vector<ll>v,v1(n,0);
          ll t;
          for(int i=0;i<n;i++)
          {
          	cin>>t;
          	v.push_back(t);
          }
         v1[1]=abs(v[0]-v[1]);
         for(int i=2;i<n;i++)
         {
         	v1[i]=min(v1[i-2]+abs(v[i-2]-v[i]),v1[i-1]+abs(v[i-1]-v[i]));
         }
         cout<<v1[n-1]<<endl;

	return 0;
}

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

int main()
{
	int n, m; cin >> n >> m;
	int l_max = 0;
	int r_min = 2147483647;
	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		l_max = max(l_max, l);
		r_min = min(r_min, r);
	}
	
	cout << max(0, r_min - l_max + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
c=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == 500*i + 100*j +50*k:
                c+=1
print(c)

Measured memory_bytes: 9116
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    
    StringBuilder sb = new StringBuilder();
    
    for (int i=0; i<n; i++) {
      sb.append(s.charAt(i));
      sb.append(t.charAt(i));
    }
    
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 23636
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if (a == b) {
      System.out.println("Draw");
    } else if (a == 1) {
      System.out.println("Alice");
    } else if (b == 1) {
      System.out.println("Bob");
    } else if (a > b) {
      System.out.println("Alice");
    } else if (b > a) {
      System.out.println("Bob");
    }
  }
}

Measured memory_bytes: 23124
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};
struct edge2{ll from, to, cost;};

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

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

int kumi(int a){
    int res=1;
    while(res<=a){
        res*=2;
    }
    return res-a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vl A(N);
    map<int,int> mp;
    rep(i,N){
        cin >> A[i];
        mp[A[i]]++;
    }
    sort(A.begin(),A.end(),greater<int>());
    ll ans=0;
    rep(i,N){
        if(A[i]!=kumi(A[i])&&mp[A[i]]&&mp[kumi(A[i])]||A[i]==kumi(A[i])&&mp[A[i]]>=2){
            ans++;
            mp[A[i]]--;;
            mp[kumi(A[i])]--;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 23488
from collections import defaultdict
class Unionfind:
    def __init__(self,n):
        self.n=n
        self.roots=[i for i in range(self.n)]


    def root(self,x):
        if self.roots[x]==x:
            return x
        else:
            self.roots[x]=self.root(self.roots[x])
            return self.roots[x]
    def unite(self,x,y):
        if self.root(x)==self.root(y):
            return
        else:
            if self.root(x)>self.root(y):
                self.roots[self.root(x)]=self.root(y)
            else:
                self.roots[self.root(y)]=self.root(x)
    
    def same(self,x,y):
        return self.root(x)==self.root(y)

N,K,L=list(input().split(" "))
N=int(N)
K=int(K)
L=int(L)
road=Unionfind(N)
train=Unionfind(N)
for i in range(K):
    p,q=map(int,list(input().split(" ")))
    road.unite(p-1,q-1)
for i in range(L):
    r,s=map(int,list(input().split(" ")))
    train.unite(r-1,s-1)



count=defaultdict(lambda:0)
point=[]
for i in range(N):
    a=road.root(i)
    b=train.root(i)
    l=[a,b]
    point.append(l)
    count[str(l)]+=1
for i in point:
    print(count[str(i)],end=" ")

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

const int MAX = 1 << 17;
int n;
int h[MAX];
int dp[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	int k;
	cin >> n >> k;
	FOR(i, 0, n)
		cin >> h[i];
	
	FOR(i, 0, n)
		dp[i] = INF;
	
	dp[0] = 0;
	FOR(i, 0, n - 1)
	{
		FOR(j, i + 1, i + k + 1)
		{
			if (j == n)
				break;
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	
	cout << dp[n - 1] << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	ins, ins2, ou := "", "", 0
	fmt.Scanf("%s", &ins)
	fmt.Scanf("%s", &ins2)
	in2 := []byte(ins2)
	in := []byte(ins)
	for j, i := range in {
      //fmt.Println(j)
      if i != byte(in2[j]) {
        //fmt.Println(j)
			ou++
		}
	}
	fmt.Println(ou)
}

Measured memory_bytes: 5000
N, M = gets.split.map(&:to_i)
pyis = M.times.map.with_index { |i| gets.split.map(&:to_i) + [i] }

group = pyis.group_by(&:first)
sorted = group.flat_map do |p, v|
  v.sort_by { |(_, y, _)| y }.map.with_index do |(_, _, i), j|
    [i, "#{p.to_s.rjust(6, '0')}#{(j + 1).to_s.rjust(6, '0')}"]
  end
end.sort_by(&:first)
sorted.each do |(_, id)|
  puts id
end


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

int main() {
  int a,b;
  cin >> a >>b;
 int x,y,z,ans; 
  x=a+b; y=a-b; z=a*b;
  //vector
    vector<int> vec = {x,y,z};
    sort(vec.begin(), vec.end());
  
  cout << vec.at(2) << endl;
}


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

int main()
{
	int x, y, x1, y1, d;

	cin >> x >> y;

	x1 = x;
	y1 = y;
	d = x % y;

	while (d > 0) {
		x1 = y1;
		y1 = d;
		d = x1 % y1;
	}

	cout << x + y - y1 + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <typename T>
struct SegTreeMin {
    vector<T> data;
    int N;
    SegTreeMin(int n) {
        N = 1;
        while (N < n) N *= 2;
        data.resize(N*2, INT_MAX);
    }
    void update(int i, T x) {
        i += N;
        data[i] = x;
        for (i /= 2; i > 0; i /= 2) {
            data[i] = min(data[2*i+0], data[2*i+1]);
        }
    }
    T query(int L, int R) { // [L, R)
        T ans = numeric_limits<T>::max();
        for (L += N, R += N; L < R; L /= 2, R /= 2) {
            if (R & 1) ans = min(ans, data[--R]);
            if (L & 1) ans = min(ans, data[L++]);
        }
        return ans;
    }
};
int main()
{
    int N, Q, A, B; cin >> N >> Q >> A >> B;
    A--, B--;
    vector<Int> X(N, 1e18);
    SegTreeMin<Int> Y(N); // Y := X + [0 .. N-1]
    SegTreeMin<Int> Z(N); // Z := X + [N-1 .. 0]
    auto update = [&](int i, Int val) {
        X[i] = val;
        Y.update(i, val + i);
        Z.update(i, val + N-1-i);
    };
    auto query = [&](int pos) { // min { X[i] + abs(pos - i) }
        return min(Z.query(0, pos) - (N-1-pos), Y.query(pos, N) - pos);
    };
    update(B, 0);
    Int dist = 0;
    for (int i = 0; i < Q; i++) {
        int x; cin >> x; x--;
        update(A, min(X[A], query(x) - abs(A - x)));
        dist += abs(A - x);
        A = x;
    }
    cout << *min_element(begin(X), end(X)) + dist << '\n';
    return 0;
}

Measured memory_bytes: 9984
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
max_x = 0
max_y = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            if max_x > j or max_y > i:
                print('Impossible')
                exit()
            else:
                max_x = j
                max_y = i
print('Possible')

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int m,n;
    cin >> m >> n;
    vi p(m);
    rep(i,m)cin >> p[i];
    sort(all(p));
    reverse(all(p));
    rep(i,m-1)p[i+1] += p[i];
    vi c(n),e(n);
    rep(i,n)cin >> c[i] >> e[i];
    vector<vi> dp(n+1,vi(m+1,INF));
    dp[0][0] = 0;
    rep(i,n)rep(j,m+1)if(dp[i][j] < INF){
        dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        dp[i+1][min(j+c[i],m)] = min(dp[i+1][min(j+c[i],m)],dp[i][j]+e[i]);
    }
    //rep(i,m+1)cout << " " << dp[n][i];cout << endl;
    for(int i = m-1; i > 0; i--)dp[n][i] = min(dp[n][i],dp[n][i+1]);
    //rep(i,m+1)cout << " " << dp[n][i];cout << endl;
    int ans = 0;
    rep(i,m){
        //cout << i+1 << " " << p[i] << " " << dp[n][i+1] << endl;
        int t = p[i] - dp[n][i+1];
        ans = max(ans, t);
    }
    cout << ans << endl;
}



Measured memory_bytes: 42176
x = list(map(int, input().split()))
m = max(x)
d = [v - m for v in x]
count = 0
while sum(d) != 0:
    ix = [i for i in range(len(x)) if x[i] != m]
    if len(ix) == 2:
        x[ix[0]] += 1
        x[ix[1]] += 1
    if len(ix) == 1:
        x[ix[0]] += 2
    m = max(x)
    d = [v - m for v in x]
    count += 1
print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll check[110000];

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  vll v;
  ll cnt = 0LL;
  ll a = x;
  rep(i,m*2) {
    v.push_back(a);
    cnt += a;
    check[a] = true;
    a *= a;
    a %= m;
    if(check[a]) break;
    if(a==0) {
      cout << cnt << endl;
      return 0;
    }
  }
  if(a==x) {
    ll s = v.size();
    ll ans = 0LL;
    ll c = n - n%s;
    ll b = c/s;
    ans += cnt*b;
    rep(i,n%s) ans += v[i];
    cout << ans << endl;
  }
  else {
    ll ans = 0LL;
    bool swi = true;
    vll vv;
    ll vs = v.size();
    rep(i,vs) {
      if(v[i]==a) swi = false;
      if(swi) {
        ans += v[i];
        n--;
      }
      else vv.push_back(v[i]);
    }
    ll s = vv.size();
    ll sum = 0LL;
    rep(i,s) sum += vv[i];
    ll b = n/s;
    ans += sum*b;
    rep(i,n%s) ans += vv[i];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 
int main(){
    int k, n ;
    cin >> k >> n ;
    vector<int> a (n) ;
    rep(i, n) cin >> a[i] ;
    vector<int> len (n) ;
    rep(i, n){
        if(i == n -1){
            len[i] = a[0] + (k - a[i]) ;
        }
        else {
            len[i] = a[i + 1] - a[i] ;
        }
    }
    sort(len.rbegin(), len.rend()) ;
    cout << k - len[0] << endl ;
} 

Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll  mod = 1e9+7;
map<ll ,ll>dp;
ll Dp(long long x)
{
    if(dp[x])return dp[x];
    else
    {
        return dp[x] = ((Dp(x/2)+Dp((x-1)/2)+Dp((x-2)/2)) )%mod;
    }
}
int main()
{
    dp[0] = 1;
    dp[1] = 2;
    long long n;
    cin>>n;
    cout<<Dp(n);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)
int main(){
    int n; cin>>n;
    int k; cin>>k;

    double ans = 0;
    for(int i=0;i<n;i++){
        double a = ceil(log2((double)k/(double)(i+1)));
        if(a<0){
            a=0;
        }
        ans+=pow(0.5,a);
    }
    printf("%.12lf\n",ans/double(n));
    return 0;
}

Measured memory_bytes: 512
import sys
input=sys.stdin.readline
from heapq import heappush,heappop
q=int(input())
L,R=[],[]
s,c=0,0
for _ in range(q):
    query=tuple(map(int,input().split()))
    if query[0]==1:
        _,a,b=query
        c+=b
        if len(L)==0 or a<=-L[0]:
            heappush(L,-a)
            s+=-L[0]-a
        else:
            heappush(R,a)
            s+=a+L[0]
        if len(R)>len(L):
            s+=-R[0]-L[0]
            heappush(L,-heappop(R))
        if len(L)-len(R)==2:
            heappush(R,-heappop(L))
    else:
        print(-L[0],s+c)

Measured memory_bytes: 77528
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>

using ll = long long;

using namespace std;

using P = pair<double, double>;

int main() {
    int n;
    cin >> n;
    P en[n];
    for (auto &ei:en) cin >> ei.first >> ei.second;
    double best = 0;
    for (int i=0; i<10000000; i++) {
        double theta = 2 * M_PI * i / 10000000;
        double x = cos(theta), y = sin(theta),
               sum = 0;
        for (auto &ei:en)
            sum += max(0., x * ei.first + y * ei.second);
        best = max(best, sum);
    }
    cout << setprecision(15) << best << '\n';
    return 0;
}

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

int main ()
{
    int n; cin >> n; int k; cin >> k;
    int c = 0;

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

        if (h >= k) c++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string str;
	cin >> str;

	for(int i=0 ; i<str.size() ; i+=2)
	{
		cout << str[i];
	}
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
int a[214514];
signed main(){
	cout<<"square1001"<<endl;
}	


Measured memory_bytes: 3112
<?php
  function resultVal($setVal = null){
    static $val=-1;
  	if($setVal===null){
      return $val;
    }else if($val===-1 || $setVal < $val){
      $val = $setVal;
    }
  }

  function calc($sumArray, $nextStart){
    global $data, $n, $m, $x;
    
    for($i=$nextStart; $i<$n; $i++){
      $tmpArray = [];
      $allFlag = true;
      for($j=0; $j<$m+1; $j++){
        $tmpArray[$j] = $sumArray[$j] + $data[$i][$j];
        
        //習熟チェック
        if($allFlag && $j>0 && $tmpArray[$j]<$x){
          $allFlag = false;
        }
      }
      //echo implode("-", $tmpArray)."\n";
      
      if($allFlag){
        //目標に達したら終了（価格順なのでこれ以降は最安にはならない）
        resultVal($tmpArray[0]);
        break;
      }else{
        //目標に達しなければ再帰
        calc($tmpArray, $i+1);
      }
    }
  }
  
  $tmp = explode(" ",trim(fgets(STDIN)));

  $n = $tmp[0];
  $m = $tmp[1];
  $x = $tmp[2];

  $data = [];
  $price = [];
  $sum = [];
  for($i=0; $i<$m; $i++){
    $sum[$i] = 0;
  }

  for($i=0; $i<$n; $i++){
    $tmp = explode(" ", trim(fgets(STDIN)));
    $data[] = $tmp;
    $price[] = $tmp[0];
    
    for($j=0; $j<$m; $j++){
      $sum[$j] += $tmp[1+$j];
    }
  }

  //可能かのチェック
  $check = true;
  foreach($sum as $tmpSum){
    if($tmpSum<$x){
      $check = false;
      break;
    }
  }
/*
  if(!$check){
    echo "-1\n";
  }else{
  */
    //安い順に並べる
    array_multisort($price, SORT_ASC, $data);
    
    $sumArray = [];
    for($i=0; $i<$m+1; $i++){
      $sumArray[] = 0;
    }
    calc($sumArray, 0);
  //}

  echo resultVal()."\n";

  

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

const int MAXN = 3.1e5;
const int MAXM = 1.1e5;
int N, M;

int bit[MAXM];

void update(int i) {
	for (i++; i <= M+1; i += (i & -i)) {
		bit[i]++;
	}
}

int query(int i) {
	int s = 0;
	for (; i; i -= (i & -i)) {
		s += bit[i];
	}
	return s;
}

int query(int l, int r) {
	return query(r) - query(l);
}

vector<int> facs[MAXM];
vector<int> rights[MAXM];
int ans[MAXM];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		int l, r; cin >> l >> r;
		rights[l].push_back(r);
	}
	for (int d = 1; d <= M; d++) {
		for (int v = d; v <= M; v += d) {
			facs[v].push_back(d);
		}
	}
	for (int v = 1; v <= M; v++) {
		for (int r : rights[v]) {
			update(r);
		}
		for (int d : facs[v]) {
			ans[d] += query(v, min(M+1, v+d));
		}
	}
	for (int d = 1; d <= M; d++) {
		cout << ans[d] << '\n';
	}

	return 0;
}


Measured memory_bytes: 17536
A=int(input())
B=int(input())
if A==1:
    if B==2:
        print("3")
    else:
        print("2")
elif A==2:
    if B==1:
        print("3")
    else:
        print("1")
else:
    if B==1:
        print("2")
    elif B==2:
        print("1")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		Set<String> hashSet = new HashSet<String>();
		int n = Integer.parseInt(reader.readLine());
		for (int i = 0; i < n; i++) {
			String[] cmd = reader.readLine().split(" ");
			if ('i' == cmd[0].charAt(0)) {
				hashSet.add(cmd[1]);
			} else {
				if (hashSet.contains(cmd[1])) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}
		}
	}
}


Measured memory_bytes: 192716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;
// std::vector<std::vector<int> > dp(N + 1, std::vector<int>(N + 1, -1));
std::vector<int> dp(N + 1, -1);
int dpf(const std::vector<int>& h, int r, int n) {
  if (dp[r] != -1) {
    return dp[r];
  }
  if (r == n) {
    return 0;
  }
  if (r == n - 1) {
    dp[r] = std::abs(h[r] - h[n]);
    return dp[r];
  }
  dp[r] = std::min(std::abs(h[r] - h[r + 1]) + dpf(h, r + 1, n),
                      std::abs(h[r] - h[r + 2]) + dpf(h, r + 2, n));
  return dp[r];
}

void once() {
  int n;
  std::cin >> n;
  std::vector<int> h(n + 1);
  for (int i = 1; i <= n; ++i) {
    std::cin >> h[i];
  }
  std::cout << dpf(h, 1, n) << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<queue>
#include<memory.h>
#include<cstdio>
#include<utility>
#include<algorithm>
#define mp make_pear
#define pd push_bake
#include<bitset>
#include<cassert>
#include<climits>
#include<complex>
#include<stack>
#include<numeric>
#include<memory>
#include<functional>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<stack>
using namespace std;
int a,b,c,d,a1,b1,c1,d1; 
string s,h="0-0-0-0=7";
int main(){
	cin>>s;
    a1=a=s[0]-'0';
    b1=b=s[1]-'0';
    c1=c=s[2]-'0';
    d1=d=s[3]-'0';
    for(int i=0;i<=1;i++){
    	b=-b;
    	for(int j=0;j<=1;j++){
    		c=-c;
    		for(int f=0;f<=1;f++){
    			d=-d;
    	        if(a+b+c+d==7){
    	        	cout<<a;
    	        	if(i)cout<<"+"<<b1;
    	        	else cout<<"-"<<b1;
    	        	if(j)cout<<"+"<<c1;
    	        	else cout<<"-"<<c1;
    	        	if(f)cout<<"+"<<d1<<"=7\n";
    	        	else cout<<"-"<<d1<<"=7\n";
    	        //	cout<<s;
    	        	return 0;
				}
			}
		}
	}
	cout<<"-1\n";
	return 0;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        mp[a]++;
    }

    if(n%3){
        if(mp.count(0) && mp[0] == n)cout << "Yes";
        else cout << "No";
    }else{
        if(mp.size() > 3)cout << "No";
        else if(mp.count(0) && mp[0] == n)cout << "Yes";
        else{
            vector<int> non_zeros;
            for(auto e: mp){
                if(e.first == 0)continue;
                non_zeros.push_back(e.first);
            }
            if(non_zeros.size() == 1){
                if(mp[non_zeros[0]] == n/3*2)cout << "Yes";
                else cout << "No";
            }else if(non_zeros.size() == 2){
                cout << "No";
            }else{
                if((non_zeros[0]^non_zeros[1]^non_zeros[2]) == 0 && mp[non_zeros[0]] == n/3 && mp[non_zeros[1]] == n/3)
                    cout << "Yes";
                else cout << "No";
            }
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3840