akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef unsigned long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

ll mod, modInv;
ll pw(ll n, ll m){
	ll res = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * n;
		n = n * n;
	}
	return res;
}
ll h_[510000], *h = h_ + 255000;

void init(int n, ll mod_){
	mod = mod_;
	modInv = pw(mod, -1);
	h[0] = 1;
	ll x = 1, y = 1;
	for(int i = 1; i <= n; i++){
		x *= mod;
		y *= modInv;
		h[i] = x;
		h[-i] = y;
	}
}

ll solve(int n, const string &s, ll mod){
	init(n, mod);
	int p = 0;
	ll hash = 0;
	for(char c : s){
		if(c == '<') p--;
		if(c == '>') p++;
		if(c == '+') hash += h[p];
		if(c == '-') hash -= h[p];
	}
	
	int p2 = p;
	ll h2 = 0;
	map<ll, vi> pos;
	for(int i = n; i >= 0; i--){
		if(i < n){
			char c = s[i];
			if(c == '<') p2++;
			if(c == '>') p2--;
			if(c == '+') h2 -= h[p2];
			if(c == '-') h2 += h[p2];
		}
		pos[h2].pb(i);
	}
	for(auto &i: pos) reverse(all(i.second));
	
	int p3 = p;
	ll h3 = hash, ans = 0;
	rep(i, n){
		ll diff = (hash - h3) * h[p - p3];
		if(pos.count(diff)) ans += pos[diff].end() - upper_bound(all(pos[diff]), i);
		
		char c = s[i];
		if(c == '<') p3++, h3 *= mod;
		if(c == '>') p3--, h3 *= modInv;
		if(c == '+') h3--;
		if(c == '-') h3++;
	}
	return ans;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; string s; cin >> n >> s;
	map<ll,int> ans;
	vector<ll> mods;
	for(ll p = 1e9 + 1; mods.size() < 5; p += 2){
		for(ll i = 3; i * i <= p; i += 2) if(p % i == 0) goto NG;
		mods.pb(p); NG:;
	}
	for(ll mod : mods) ++ans[solve(n, s, mod)];
	
	int mxc = 0; ll res = 0;
	for(auto i : ans) if(i.second > mxc) mxc = i.second, res = i.first;
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 31764
#include <cstdio>

const int MAXN = 40, MAXL = 17, MOD = 1e9 + 7;
int n, x, y, z, f[2][1 << MAXL];

inline void add_eq ( int& a, const int b ) { if ( ( a += b ) >= MOD ) a -= MOD; }

int main () {
	scanf ( "%d %d %d %d", &n, &x, &y, &z );
	int all = ( 1 << x + y + z ) - 1, ans = 1;
	int haiku = ( 1 << x + y + z >> 1 ) | ( 1 << y + z >> 1 ) | ( 1 << z >> 1 );
	f[0][0] = 1;
	for ( int i = 0, t = 0; i < n; ++ i, t ^= 1, ans = ans * 10ll % MOD ) {
		for ( int s = 0; s <= all; ++ s ) {
			int& cur = f[t][s];
			if ( ! cur ) continue;
			for ( int j = 1, trs; j <= 10; ++ j ) {
				trs = ( s << j | ( 1 << j >> 1 ) ) & all;
				if ( ( trs & haiku ) ^ haiku ) add_eq ( f[t ^ 1][trs], cur );
			}
			cur = 0;
		}
	}
	int sub = 0;
	for ( int i = 0; i <= all; ++ i ) add_eq ( sub, f[n & 1][i] );
	printf ( "%d\n", ( ans - sub + MOD ) % MOD );
	return 0;
}

Measured memory_bytes: 4100
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e6 + 200;
const long long MNN = 4e2 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n;
llong a[MXN], pr[MXN], dp[MNN][MNN];

int main () {
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            dp[i][j] = INF;
        }
    }
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        pr[i] = pr[i - 1] + a[i];
        dp[i][i] = 0;
    }
    for(int sz = 1; sz <= n - 1; sz++){
        for(int l = 1; l + sz <= n; l++){
            int r = l + sz;
            for(int i = l; i < r; i++){
                dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + pr[r] - pr[l - 1]);
                //cout << i << ' ' << l << ' ' << r << ' ' << dp[l][i] + dp[i + 1][r] + pr[r] - pr[l - 1] << nl;
            }
            //cout << l << ' ' << r << ' ' << dp[l][r] << nl;
        }
    }
    cout << dp[1][n];
}


Measured memory_bytes: 6272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        WriteLine((n[0] + n[1]) % 24);
    }
}


Measured memory_bytes: 18976
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
int main() {
  int N; cin >> N;
  vector<int> v1, v2;
  int six = 1, nine = 1;
  while (six <= N) {
    v1.push_back(six);
    six *= 6;
  }
  while (nine <= N) {
    v2.push_back(nine);
    nine *= 9;
  }

  int vmin = 1e9;
  for (int i = 0; i <= N; ++i) {
    int coin = 0;
    int n1 = i;
    for (auto it = v1.rbegin(); it != v1.rend(); ++it) {
      int x = *it;
      coin += n1 / x;
      n1 %= x;
    }
    int n2 = N - i;
    for (auto it = v2.rbegin(); it != v2.rend(); ++it) {
      int x = *it;
      coin += n2 / x;
      n2 %= x;
    }
    vmin = min(vmin, coin);
  }
  cout << vmin << endl;
}


Measured memory_bytes: 256
#include <cstdio>

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

int main() {
  int n;
  scanf("%d", &n);
  int cnt[26] = {};
  static char s[100000 + 1];
  scanf("%s", s);
  for (int i = 0; i < n; ++ i)
    cnt[s[i] - 'a'] ++;
  int result = 1;
  for (int i = 0; i < 26; ++ i) {
    result = result * 1LL * (cnt[i] + 1) % MOD;
  }
  printf("%d\n", (result + MOD - 1) % MOD);
}


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


ll N, A, B;


void input() {
    cin >> N >> A >> B;
}


int main() {
    input();
    ll s = A + B;
    ll ans = (N / s) * A;
    ans += min(A, N % s);
    cout << ans << endl;
}


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

int N, Q;

// 区間を左端でソートして順にセグメント木を更新

template <typename T>
class SegTree
{
    int N;
    int head;
    vector<T> x;
    T defaultT;
    using func = function<T(const T&, const T&)>;
    func tree_update;

    T _query_search(int begin, int end, int pos, int l, int r)
    {
        if (r <= begin || l >= end) return defaultT;
        if (l >= begin && r <= end) return x[pos];
        T v_l = _query_search(begin, end, 2*pos+1, l, (l+r)/2);
        T v_r = _query_search(begin, end, 2*pos+2, (l+r)/2, r);
        return tree_update(v_l, v_r);
    }

public:
    SegTree(int N, T val_default, func f) : N(N), defaultT(val_default), tree_update(f)
    {
        int N_tmp = 1;
        while (N_tmp < N) N_tmp <<= 1;
        x = vector<T>(N_tmp*2, defaultT);
        head = N_tmp - 1;
    }

    void update(int pos, T val)
    {
        pos += head;
        x[pos] = val;
        while (pos)
        {
            pos = (pos - 1) / 2;
            x[pos] = tree_update(x[pos*2+1], x[pos*2+2]);
        }
    }
    T query(int begin, int end)
    {
        return _query_search(begin, end, 0, 0, (int)x.size() / 2);
    }
};

int main()
{
    cin >> N;
    vector<int> b(N);
    for (auto &v : b) cin >> v;
    SegTree<int> RMQ(N+1, 200000, [](int a, int b) { return min(a, b); });
    RMQ.update(0, 0);

    vector<vector<int>> c(N+1);
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int tmp1, tmp2; cin >> tmp1 >> tmp2;
        c[tmp1].push_back(tmp2);
    }

    for (int l = 1; l <= N; l++)
    {
        for (auto r : c[l]) RMQ.update(r, RMQ.query(l - 1, r + 1));
        RMQ.update(l, min(RMQ.query(l-1, l) + (b[l-1] ? 1 : -1), RMQ.query(l, l+1)));
    }
    cout << RMQ.query(N, N + 1) + N - accumulate(b.begin(), b.end(), 0) << endl;
}


Measured memory_bytes: 11776
var i, n, k, S, v:Longint;
begin
  S := 0;
  read(k, n);
  for i := 1 to n do
  begin
    read(v);
    S := S + v;
    if S >= k then
      begin
        writeln('Yes');
        exit;
      end;
  end;
  writeln('No');
end.


Measured memory_bytes: 128
N = int(input())
D,X = map(int,input().split())
A = [int(input()) for _ in range(N)]

d = 1
ans = 0
while d <= D:
    for a in A:
        if a == 1:
            ans += 1
        elif d%a == 1:
            ans += 1
    d += 1

print(ans+X)

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

/* constant */

const double MIN_X = -100;
const double MIN_Y = -100;
const double MAX_X =  100;
const double MAX_Y =  100;

const int MAX_N = 100;

const double EPS = 1e-10;

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  Pt operator+(const Pt pt) const { return Pt(x + pt.x, y + pt.y); }
  Pt operator-() const { return Pt(-x, -y); }
  Pt operator-(const Pt pt) const { return Pt(x - pt.x, y - pt.y); }
  Pt operator*(T t) const { return Pt(x * t, y * t); }
  Pt operator/(T t) const { return Pt(x / t, y / t); }
  T dot(Pt v) { return x * v.x + y * v.y; }
  T cross(Pt v) { return x * v.y - y * v.x; }
  Pt mid(const Pt pt) { return Pt((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt(c * x - s * y, s * x + c * y);
  }

  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }
  
  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
};

typedef Pt<double> pt;
typedef pair<pt,pt> ppt;
typedef vector<pt> vpt;

/* global variables */

int n;
ppt segs[MAX_N];

/* subroutines */

bool cross_lines(const pt& a0, const pt& a1, const pt& b0, const pt& b1,
                 pt& ret) {
  pt da = a1 - a0;
  pt db = b1 - b0;

  double op01 = da.cross(db);
  if (op01 == 0.0) return false; /* need to handle parallel?? */

  pt v = b0 - a0;
  double op0 = v.cross(da);
  double op1 = v.cross(db);

  double t0 = op1 / op01;
  double t1 = op0 / op01;

  if (t0 < 0.0 || t0 > 1.0 || t1 < 0.0 || t1 > 1.0) return false;
  
  ret = db * t1 + b0;
  return true;
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      double x0, y0, x1, y1;
      cin >> x0 >> y0 >> x1 >> y1;
      segs[i].first.x = x0;
      segs[i].first.y = y0;
      segs[i].second.x = x1;
      segs[i].second.y = y1;
    }

    int count = 1;
    
    for (int i = 0; i < n; i++) {
      ppt& segi = segs[i];
      
      vpt cpts;
      cpts.push_back(segs[i].first);
      cpts.push_back(segs[i].second);

      for (int j = 0; j < i; j++) {
	ppt& segj = segs[j];
	pt cpt;
	if (cross_lines(segi.first, segi.second, segj.first, segj.second, cpt))
	  cpts.push_back(cpt);
      }
      sort(cpts.begin(), cpts.end());

      int ncpts = 1;
      for (int j = 1; j < cpts.size(); j++)
	if ((cpts[j] - cpts[j - 1]).d() >= EPS) ncpts++;

      count += ncpts - 1;
    }

    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll modpow(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, 61) {
        ll sum1 = 0;
        rep(j, 0, n) {
            if (a[j] & (1LL << i)) sum1++;
        }
        ans += modpow(2, i, MOD) * ((sum1 * (n - sum1)) % MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<stdio.h>
int main(){
	int v1,v2;
	std::vector<int> vec(10);
	while(scanf("%d,",&vec[0])!=EOF) {
		float sum=0;
		for(int i=1;i<10;i++){
			scanf("%d,",&vec[i]);
			//std::cin>>vec[i];
			sum+=vec[i];
		}
		scanf("%d,%d",&v1,&v2);
		//std::cin>>v1>>v2;
		if(std::cin.eof())break;
		float time=sum/(v1+v2);
		float a=v1*time;
		int b=0;
		while(a>0){
			a-=vec[b];
			b++;
		}
		std::cout<<b<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    long long n;
    cin>>n;
    long long ans=0;
    
    if(n%2==1) cout<<0<<endl;
    else{
        for(long long hoge=10;hoge<=n;hoge*=5) ans+=n/hoge;
        
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

const int INF=1e18;

signed main()
{
    int N,W; cin>>N>>W;
    vector<int> w(N),v(N);
    for(int i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    
    vector<vector<int> > dp(N+1,vector<int>(W+1,-INF));
    dp[0][0]=0;

    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            chmax(dp[i+1][j],dp[i][j]);
            if(j+w[i]<=W){
                chmax(dp[i+1][j+w[i]],dp[i][j]+v[i]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<=W;i++){
        chmax(ans,dp[N][i]);
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

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


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

  ll N; std::cin >> N;

  auto f = [](ll x, ll y) -> int {
    std::string A = std::to_string(x);
    std::string B = std::to_string(y);
    return std::max( sz(A), sz(B) );
  };

  int ans = 1e5;
  for(ll i=1; i<=std::sqrt(N); i++) {
    if ( N % i == 0 ) ans = std::min(ans, f(i, N/i));
  }
  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;

struct edge {
	edge(int u, int v, int w)
		: src(u)
		, dst(v)
		, weight(w)
	{}
	int src;
	int dst;
	int weight;
};

void dfs(const vector<vector<edge>> &g, vector<int> &v, int x, int c)
{
	if (v[x] != -1) {
		return;
	}
	v[x] = c;
	for (auto &e : g[x]) {
		if (e.weight % 2 == 0) {
			dfs(g, v, e.dst, c);
		}
		else {
			dfs(g, v, e.dst, 1 - c);
		}
	}
}

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

	vector<vector<edge>> g(N);

	for (int i = 0; i < N - 1; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		--u;
		--v;
		g[u].emplace_back(u, v, w);
		g[v].emplace_back(v, u, w);
	}

	vector<int> color(N, -1);
	dfs(g, color, 0, 0);
	for (auto x : color) {
		cout << x << endl;
	}
}


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

using namespace std;

int N,num[11][11][10010],len[11][11];
long long int ans;

int main()
{
	scanf("%d",&N);
	for(int i=0;i<=10;i++)
	    for(int j=0;j<=10;j++)
	        len[i][j]=0;
	for(int i=1;i<=N;i++)
	{
		int a=i;
		int a1=a%10;
		while(a>=10)
		    a=a/10;
		int a2=a;
		len[a2][a1]++;
		num[a2][a1][len[a2][a1]]=i;
	}
	for(int i=1;i<=N;i++)
	{
		int a=i;
		int a1=a%10;
		while(a>=10)
		    a=a/10;
		int a2=a;
		ans=ans+(long long)len[a1][a2];
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 2944
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n; (n = in());) {
		bool r = true, l = true, p = true;
		int s = 0;
		while (n--) {
			char c = gcu(); gcu(), gcu();
			if (c == 'r')
				r = !r;
			else
				l = !l;
			if (r == l && r != p) {
				s++;
				p = r;
			}
		}
		outl(s);
	}
}


Measured memory_bytes: 2620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e18;
class SCC{//cmp(0 - kk-1) is scc's return. Same number is group. The number is no relatoin.
	public:
	int n;
	vvi G,rG;
	vector<bool>used;
	vi vs,cmp;
	SCC(int size){
		n=size;
		G=rG=vvi(n);
		used=vector<bool>(n);
		cmp=vi(n);
		vs=vi(0);
	}
	void add_edge(int s,int t){
		G[s].pb(t);
		rG[t].pb(s);
	}
	void rdfs(int v,int k){
		used[v]=true;
		cmp[v]=k;
		rep(i,rG[v].size())if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
	void dfs(int v){
		used[v]=true;
		rep(i,G[v].size())if(!used[G[v][i]])dfs(G[v][i]);
		vs.pb(v);
	}
	int scc(){
		rep(i,n)used[i]=false;
		rep(v,n)if(!used[v])dfs(v);
		rep(i,n)used[i]=false;
		int kk=0;
		for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]])rdfs(vs[i],kk++);
		return kk;  
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	SCC scc(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		scc.add_edge(a,b);
	}
	scc.scc();
	vi co(n);
	rep(i,n)co[scc.cmp[i]]++;
	bool h=false;
	rep(i,n)if(co[i]>1)h=true;
	cout<<h<<endl;
}
 
 

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  vector<bool> first(n,false);
  vector<bool> last(n, false);
  rep(i,m){
    cin >> a[i];
    cin >> b[i];
    if(a[i] == 1){
      first[b[i]-1] = true;
    }else if(b[i] == 1){
      first[a[i]-1] = true;
    }else if(a[i] == n){
      last[b[i]-1] = true;
    }else if(b[i] == n){
      last[a[i]-1] = true;
    }
  }
  for(int i = 1; i < n - 1; i++){
    if(first[i] && last[i]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

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

    cout << (n + (2 * d)) / (2 * d + 1);

    return 0;
}

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

int main(){
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool correct = true;
    for(int i=0; i<a+b+1; i++){
        if((i!=a && s[i]=='-') || (i==a && s[i]!='-')){
            correct = false;
            break;
        }
    }
    if(correct){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }   
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            //半径rの円の面積と円周の長さを求める

            double r = double.Parse(Console.ReadLine());

            //円の面積を求める
            double area = (double)r * r * Math.PI;
            //円周を求める
            double circumference = (double)r * 2 * Math.PI;

            Console.WriteLine("{0} {1}",area.ToString("f5"), circumference.ToString("f5"));

            Console.ReadKey();
        }
    }
}




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

int main(){
    int n, a;
    while(cin >> n, n){
        int sum = 0;
        set<int> s;
        s.insert(0);

        for(int i = 0; i < n; i++){
            cin >> a;
            sum += a;
            set<int> next;
            for(int x : s){
                next.insert(x+a);
                next.insert(x);
            }
            s = next;
        }

        int ans = sum;
        for(int x : s)  ans = min(ans, abs(2*x-sum));
        cout << ans << endl;
    }
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf = LLONG_MAX;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cout << #x << " " << x << endl

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

    ll s,w;
    cin >> s >> w;

    cout << (( s > w ) ? "safe" : "unsafe") ; 
    return 0;
} 

Measured memory_bytes: 3648
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int count = 0;
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      while (a % 2 == 0) {
        a /= 2;
        count++;
      }
    }
  System.out.println(count);
  }
}


Measured memory_bytes: 35520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;cin >> k;
    vector<ll> a(k),l(k+1),r(k+1);
    REP(i,k){
        cin >> a[i];
    }
    reverse(ALL(a));
    l[0]=2;
    r[0]=2;
    REP(i,k){
        l[i+1]=(l[i]+a[i]-1)/a[i]*a[i];
        r[i+1]=(r[i])/a[i]*a[i]+a[i]-1;
        if(l[i+1]>r[i+1]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l[k] << " " << r[k] << endl;
}

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

const int MAX_N = 100000;
const int MAX_V = 1000000000;

int main()  {
    int n;
    ll x,l,ans=0,cur=-MAX_V;
    cin>>n;
    set<pair<int,int>> s;
    for(int i=0;i<n;i++)
    {
        cin>>x>>l;
        s.insert(make_pair(x+l,x-l));
    }
    //sort(s.begin(),s.end());
    for(auto i:s)
    {
        if(cur<=i.second)
        {
            ans++;
            cur=i.first;
        }
    }
    cout<<ans;
    return 0;
}


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n, m; cin >> n >> m;
    vector<int> a(m), b(m);
    vector<int> c(m, 0);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        for (int j = 0; j < b[i]; j++) {
            int ci; cin >> ci; ci--;
            c[i] |= (1 << ci);
        }
    }

    vector<int> dp(1 << n, inf);
    dp[0] = 0;
    for (int S = 0; S < (1 << n); S++) {
        if (dp[S] >= inf) continue;
        for (int i = 0; i < m; i++) {
            dp[S | c[i]] = min(dp[S | c[i]], dp[S] + a[i]);
        }
    }

    cout << ((dp[(1 << n) - 1] >= inf) ? -1 : dp[(1 << n) - 1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
struct Precision{
  Precision(){
    cout<<fixed<<setprecision(20);
  }
}precision_beet;

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,k;
  while(cin>>n>>k,n){
    using T = tuple<Int, Int, Int>;
    vector<T> v;
    map<Int, Int> cnt;
    for(Int i=0;i<n;i++){
      Int x,y,z;
      cin>>x>>y>>z;
      v.emplace_back(z,x,y);
      cnt[z]++;
    }
    Int flg=0;
    for(auto p:cnt){
      if(p.second>k){
	cout<<-1<<endl;
	flg=1;
	break;
      }
    }
    if(flg) continue;
    sort(v.rbegin(),v.rend());
    v.erase(unique(v.begin(),v.end()),v.end());
    assert((Int)v.size()==n);
    
    const double inf = 1e18;
    auto dist=make_v<double>(n,n);
    fill_v(dist,0);
    auto calc=[&](T a,T b){
      if(get<0>(a)==get<0>(b)) return inf;
      double sum=0;
      sum+=(get<0>(a)-get<0>(b))*(get<0>(a)-get<0>(b));
      sum+=(get<1>(a)-get<1>(b))*(get<1>(a)-get<1>(b));
      sum+=(get<2>(a)-get<2>(b))*(get<2>(a)-get<2>(b));
      return sqrt(sum);
    };
    
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
	dist[i][j]=calc(v[i],v[j]);

    auto di=[&](Int i,Int j){
      if(min(i,j)<0) return (double)0.;
      return dist[i][j];
    };

    auto dp=make_v<double>(n+1,n+1,n+1);
    fill_v(dp,inf);
    dp[0][0][0]=0;
    
    auto nx=make_v<double>(n+1,n+1,n+1);    
    for(Int i=0;i<n;i++){
      fill_v(nx,inf);
      for(Int a=-1;a<i;a++){
	for(Int b=-1;b<0||b<a;b++){
	  for(Int c=-1;c<0||c<b;c++){
	    if(dp[a+1][b+1][c+1]>=inf) continue;
	    //cout<<i-1<<" "<<a<<" "<<b<<" "<<c<<":"<<dp[a+1][b+1][c+1]<<endl;
	    chmin(nx[a+1][b+1][c+1],dp[a+1][b+1][c+1]+di(i-1,i));
	    chmin(nx[i+0][b+1][c+1],dp[a+1][b+1][c+1]+di(a,i));
	    chmin(nx[i+0][a+1][c+1],dp[a+1][b+1][c+1]+di(b,i));
	    chmin(nx[i+0][a+1][b+1],dp[a+1][b+1][c+1]+di(c,i));
	  }
	}
      }
      swap(dp,nx);
    }
    double ans=inf;
    
    for(Int a=-1;a<n;a++){
      for(Int b=-1;b<0||b<a;b++){
	for(Int c=-1;c<0||c<b;c++){
	  Int s=(a==-1)+(b==-1)+(c==-1);
	  if(k+s>=4) chmin(ans,dp[a+1][b+1][c+1]);
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 19968
// ITP1_8_D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

    string s,p;
    cin>>s>>p;
    bool flag=false;
    int ll=s.size();
    int l=p.size();
    for(int i=0;i<ll;i++){ //先頭の全探索
        bool flag2=true;
        for(int j=0;j<l;j++){
            //cout<<i<<" "<<j<<endl;
            //cout<<s[(i+j)%ll]<<endl;
            if(s[(i+j)%ll]!=p[j]){
                flag2=false;
                break;
            }
        }
        if(flag2){
            flag=true;
            break;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3220
#include<iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
#define INF 1<<30

using namespace std;

int N;
int a, b;

int main(){
	cin >> N;
	if(N == 1){
		cout << "Hello World" << endl;
	}else if(N == 2){
		cin >> a >> b;
		cout << a + b << endl;
	}


	return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll a, b, c; cin >> a >> b >> c;
  string result = c-(a+b)>=0 && (c-(a+b))*(c-(a+b))>4*a*b ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int a, b;
ll k;
ll func[300010];
ll inv[300010];

ll poW(ll x, ll r) {
	ll temp;
	if (r == 0LL)return 1LL;
	else if (r == 1LL)return x % mod;
	temp = poW(x, r / 2);
	return (temp*temp%mod)*poW(x, r % 2) % mod;
}

void init() {
	func[0] = 1;
	for (int i = 1; i <= n; i++) {
		func[i] = func[i - 1] * i%mod;
	}
	inv[n] = poW(func[n], mod - 2);
	for (int i = n - 1; i >= 0; i--) {
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
}

int main() {
	cin >> n >> a >> b >> k;
	init();
	ll ans = 0LL;
	for (int i = 0; i <= n;i++) {
		int j;
		ll temp;
		temp = (k - a * i) / b;
		if (temp > (ll)n||temp<0LL)continue;
		if (k - a * i - b * temp != 0LL)continue;
		j = (int)temp;
		temp = (func[n] * inv[i] % mod*inv[n - i] % mod)*(func[n] * inv[j] % mod*inv[n - j] % mod) % mod;
		ans = (ans + temp) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def cum_2d(field:list):
    row = len(field)
    col = len(field[0])
    
    # 横方向に累積和
    for r in range(row):
        for c in range(col-1):
            field[r][c+1] += field[r][c]
    
    # 縦方向に累積和
    for c in range(col):
        for r in range(row-1):
            field[r+1][c] += field[r][c]
            
    return field

n,k = li()

wishes = []
# mod K をとり、すべての希望を黒に変換
for _ in range(n):
    x,y,c = ls()
    x = int(x) % (2*k)
    y = int(y) % (2*k)
    
    if c == "B":
        if x >= k and y >= k:
            x -= k
            y -= k
        
        elif y >= k:
            x += k
            y -= k
    
    if c == "W":
        if x >= k and y >= k:
            y -= k
        
        elif x >= k:
            x -= k
            
        elif y >= k:
            y -= k
            
        else:
            x += k
        
    wishes.append((x,y))

imos = [[0 for _ in range(2*k+1)] for _ in range(2*k+1)]

for x, y in wishes:
    
    # xが K 未満のとき
    if x < k:
        # 左上
        imos[0][y+k+1] += 1
        imos[0][2*k] -= 1
        imos[x+1][y+k+1] -= 1
        imos[x+1][2*k] += 1
            
        # 左下
        imos[0][0] += 1
        imos[x+1][0] -= 1
        imos[0][y+1] -= 1
        imos[x+1][y+1] += 1
            
        # 中央
        imos[x+1][y+1] += 1
        imos[x+1][y+k+1] -= 1
        imos[x+k+1][y+1] -= 1
        imos[x+k+1][y+k+1] += 1
        
        # 右下
        imos[x+k+1][0] += 1
        imos[x+k+1][y+1] -= 1
        imos[2*k][0] -= 1
        imos[2*k][y+1] += 1
            
        # 右上
        imos[x+k+1][y+k+1] += 1
        imos[x+k+1][2*k] -= 1
        imos[2*k][y+k+1] -= 1
        imos[2*k][2*k] += 1

    # xが K 以上のとき
    else:
        #左
        imos[0][y+1] += 1
        imos[x-k+1][y+1] -= 1
        imos[0][y+k+1] -= 1
        imos[x-k+1][y+k+1] += 1
        
        # 下
        imos[x-k+1][0] += 1
        imos[x-k+1][y+1] -= 1
        imos[x+1][0] -= 1
        imos[x+1][y+1] += 1
        
        # 右
        imos[x+1][y+1] += 1
        imos[2*k][y+1] -= 1
        imos[x+1][y+k+1] -= 1
        imos[2*k][y+k+1] += 1
        
        # 上
        imos[x-k+1][y+k+1] += 1
        imos[x-k+1][2*k] -= 1
        imos[x+1][y+k+1] -= 1
        imos[x+1][2*k] += 1
    

# 累積和
imos = cum_2d(imos)

ans = 0
for i in range(2*k):
    for j in range(2*k):
        if imos[i][j] > ans:
            ans = imos[i][j]
        

print(ans)

Measured memory_bytes: 88668
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n,i,r = 0,b = 0;
    string s;
    cin >> n >> s;
    for(i = 0;i < n;++i){
        if(s.at(i) == 'R'){
            ++r;
        }else{
            ++b;
        }
    }
    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    double a, b, h, m; cin >> a >> b >> h >> m;

    h = h * 5;

    double d = (h * 6) - (m * 6) + (30 * m / 60);

    d = d * acos(-1) / 180.0;

    double x = cos(d);

    double ans = sqrt((a * a) + (b * b) - 2.0 * a * b * x);

    cout << fixed << setprecision(20) << ans;
}

Measured memory_bytes: 4244
from scipy.misc import comb
N,A,B,*V=map(int,open(0).read().split());d={}
for v in V:d[v]=d.get(v,0)+1
l=sorted(d.items(),key=lambda x:x[0])[::-1]
if l[0][1]>A:
 print(l[0][0])
 print(int(sum(comb(l[0][1],i,exact=1)for i in range(A,B+1))))
else:
 s=0;c=A
 for k,v in l:
  if v<c:s+=k*v;c-=v
  else:print((s+k*c)/A);print(int(comb(v,c,exact=1)));break

Measured memory_bytes: 14000
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 1e5 + 7;
bool can[N];
int cnt[N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cnt[i] = 1;
    }   
    can[1] = 1;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        can[v] |= can[u];
        --cnt[u];
        ++cnt[v];
        if (cnt[u] == 0)
            can[u] = 0;
    }   
    /*
    for (int i = 1; i <= n; ++i) {
        cout << cnt[i] << ' ' << can[i] << endl;
    }   
    */
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += can[i];
    }   
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <tuple>

using namespace std;


typedef pair<int, int> Location;
typedef queue<Location> LocationQueue;

#define N 1000
char field[N][N];
int levels[N][N] = {0};
bool visited[N][N] = {false};

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

int solve(int h, int w, LocationQueue &que) {
  /*
  cout << h << " " <<  w << " " << endl;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << field[i][j];
    }
    cout << endl;
  }
  */
  Location loc;
  int i0, j0, i, j, level;
  int max_level = 0;

  while(que.size()){
    loc = que.front(); que.pop();
    i0 = loc.first; j0 = loc.second;
    level = levels[i0][j0];

    for(int n = 0; n < 4; n++){
        i = i0 + dx[n];
        j = j0 + dy[n];

        if (i >= 0 && i <= h - 1 && j >= 0 && j <= w -1 &&
            !visited[i][j]
            && (field[i][j] == '.'))
        {
          field[i][j] = '#';
          visited[i][j] = true;
          que.push(make_pair(i,j));
          levels[i][j] = level + 1;
          max_level = max(max_level, level+1);
        }
    }
  }

  return max_level;
}

int main(int argc, char const *argv[]) {
  int h, w;
  char c;
  LocationQueue que;

  cin >> h;
  cin >> w;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> c;
      field[i][j] = c;
      if (c == '#') {
        que.push(make_pair(i, j));
        visited[i][j] = true;
      }
    }
  }

  cout << solve(h, w, que);

  return 0;
}


Measured memory_bytes: 11008
/* 

	 - If you fail to prepare, you are prepared to fail.	

	(C) Mark Spitz

*/

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;

using ll = long long;

const bool dbg_flg = 1;
#define NAME(x) #x
#define debug if (dbg_flg) cerr

const int inf = 1e9 + 7;
const int MAXN = 1e6 + 5;

int n;
vector<int> v;

void solve() {	
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		v.pb(x);
	}
	
	vector<int> res;
		
	while (!v.empty()) {
		int pos = -1;
		
		for (int i = 0; i < sz(v); i++) {
			if (v[i] == i + 1) pos = i;
		}
		
		if (pos == -1) {
			cout << -1;
			return;
		}
		
		res.pb(v[pos]);
		
		v.erase(v.begin() + pos);
	}
	
	reverse(all(res));
	
	for (int i : res) {
		cout << i << '\n';
	}
}

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	                                                         
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	int tt = 1;
	//~ cin >> tt;
	while (tt--) {
		solve();
	}

	return 0;
}


Measured memory_bytes: 3588
n = int(input())
ans = []
i=2
j=0
k = 0
while True:
    if k==n:
        break
    if (n-k)%i==0:
        ans.append(0)
    else:
        k += i>>1 if j%2==0 else -i>>1
        ans.append(1)
    i = i<<1
    j+=1

if n==0:
    print(0)
else:
    for i in ans[::-1]:
        print(i,end='')
    print()

Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto xs = readints();
    int a = xs[0], b = xs[1], c = xs[2], d = xs[3];

    int ans = 0;
    for (int i = 0; i <= 100; i++) {
        if (a <= i && i <= b && c <= i && i <= d) {
            ans++;
        }
    }
    writeln(max(0, ans - 1));
}


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

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int s = sc.nextInt();
		int MOD = 1000000007;
		
		// 計算
		long result = 1;
		long[] list = new long[2001];
		list[3] = 1;
		list[4] = 1;
		list[5] = 1;
		long[] sum = new long[2001];
		sum[3] = 1;
		sum[4] = 2;
		sum[5] = 3;
		for(int i = 6; i <= s; i++){
		   list[i] = sum[i-3] + 1;
		   list[i] %= MOD;
		   sum[i] = sum[i-1] + list[i];
		   sum[i] %= MOD;
		}
		
		result = list[s];
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}

}


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

using namespace std;
#define int long long
int MOD = 1000000007;


signed main(){
    string S;
    cin >> S;
    
    if(regex_match(S,regex("A?KIHA?BA?RA?"))) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,K,i,ans=0;cin>>N>>K;ll p[N];
  REP(i,N)cin>>p[i];
  sort(p,p+N);
  REP(i,K)ans+=p[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
double dp[3001][3001];

int main()
{
    int n;
    double k;
    cin>>n>>k;
    double x[n+5],y[n+5];
    vector<double>v;
    for(int i=0; i<n; i++){
        cin>>x[i]>>y[i];
        v.push_back(sqrt((x[i]*x[i])+(y[i]*y[i])));
    }
    int cnt=0;
    for(int i=0; i<n; i++)
        if(v[i]<=k)
           cnt++;
    cout<<cnt<<endl;

}


Measured memory_bytes: 8272
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<iostream>
using namespace std;
int N,D,M;
int d[100001];
int k[10001];
int main(){
  while(1){
    scanf("%d",&D);
    if(!D) break;
    scanf("%d %d",&N,&M); 
    for(int i=0;i<N-1;i++)
      scanf("%d",&d[i]);
    for(int i=0;i<M;i++)
      scanf("%d",&k[i]);
    sort(d,d+N-1);
    sort(k,k+M);
    int res=0;
    for(int i=0;i<M;i++){
      int st=0,ed=N-2,h,ky=D;
      //printf("%d %d\n",k[i],i);
      while(st<=ed){
	h = (st+ed)/2;
	if(d[h]>k[i]){ ky = min(ky,abs(d[h]-k[i])); ed = h-1;}
	else if( d[h]<k[i] ){ ky = min(ky,abs(d[h]-k[i])); st = h+1; }
	else{ ky=0; break;}
      }
      res += min(ky,min(D-k[i],k[i]));
      // printf("%d %d\n",ky,res);
    }
    printf("%d\n",res);
  }
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {
    int n;
    int a[200001] = {};
    int b[200001] = {};
    ll ans = 0;

    Scd(n);

    set<int> s;
    Rep(i,n){
        Scd(a[i]);
        b[a[i]] = i+1;
        s.insert( i+1 );
    }
    s.insert(0);
    s.insert(n+1);

    for (int i = n; i > 0; i-- ){
        s.erase(b[i]);
        auto itr = s.upper_bound( b[i] );
        ans += i * 1ll * ( *itr - b[i] ) * ( b[i] - *(--itr) );
    }

    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 11136
char buf[10000000],out[11];
sz;
cnt[60];
main()
{
	read(0,buf,10000000);
	long N=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(int c=N;c--;)
	{
		long A=0;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			A=A*10+k-'0';
		}
		for(int i=0;A;i++)
		{
			cnt[i]+=A&1;
			A>>=1;
		}
	}
	int ans=0;
	for(int i=59;i>=0;i--)
	{
		ans=(ans*2+(N-cnt[i])*cnt[i])%1000000007;
	}
	int outsz=10;
	do{
		out[--outsz]=ans%10+'0';
	}while(ans/=10);
	write(1,out+outsz,10-outsz);
}


Measured memory_bytes: 6272