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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int A[401];
int B[401];
//! [iの][j乗]
ll S[401][401];
//! [iから][jの][k乗]を足したもの
int T[401][401][401];

int dp[401][401];

int main()
{
    ll N, C;
    cin >> N >> C;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N)
    {
        cin >> B[i];
    }
    memset(S, 0, sizeof(S));
    memset(T, 0, sizeof(T));
    memset(dp, 0, sizeof(dp));
    REP(i, 400)
    {
        ll m = 1;
        REP(j, C + 1)
        {
            S[i + 1][j] = m;
            m = (m * (i + 1)) % MOD;
        }
    }
    REP(i, 400)
    {
        FOR(j, 400, i)
        {
            REP(k, C + 1)
            {
                T[i + 1][j + 1][k] = (T[i + 1][j][k] + S[j + 1][k]) % MOD;
            }
        }
    }

    dp[0][0] = 1;
    REP(i, N)
    {
        REP(j, C + 1)
        {
            ll s = 0;
            REP(k, j + 1)
            {
                s += (ll)dp[i][k] * (ll)T[A[i]][B[i]][j - k] % MOD;
                s %= MOD;
            }
            dp[i + 1][j] = s;
        }
    }
    cout << dp[N][C] << endl;
    return 0;
}

Measured memory_bytes: 253952
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<sstream>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

long long dp[110][100010];
int main() {
	int N, T;
	cin >> N >> T;
	int *c = new int[N];
	int*t = new int[N];
	ll min = INF;
	for (int i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
		if (t[i] <= T && min > c[i])min = c[i];
	}
	if (min == INF) {
		cout << "TLE";
	}
	else {
		cout << min;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,i,j,a,b,c,r,k,x,y,l,d;
    cin>>n>>m;
    char ch;
    ll dp[n+1][m+1],arr[n+1][m+1];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>ch;
            if(ch=='#')
                arr[i][j]=1;
            else
                arr[i][j]=0;
        }
    }
    dp[1][1]=arr[1][1];
    for(i=2;i<=m;i++)
    {
        if(arr[1][i]==0)
            dp[1][i]=dp[1][i-1];
        else
        {
            if(arr[1][i-1]==1)dp[1][i]=dp[1][i-1];
            else
                dp[1][i]=dp[1][i-1]+1;
        }
    }
    for(i=2;i<=n;i++)
    {
        if(arr[i][1]==0)dp[i][1]=dp[i-1][1];
        else
        {
            if(arr[i-1][1]==1)dp[i][1]=dp[i-1][1];
            else
                dp[i][1]=dp[i-1][1]+1;
        }
    }
    for(i=2;i<=n;i++)
    {
        for(j=2;j<=m;j++)
        {
            if(arr[i][j]==0)
            {
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
                continue;
            }
            if(arr[i-1][j]==1)dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=dp[i-1][j]+1;
            if(arr[i][j-1]==1)dp[i][j]=min(dp[i][j],dp[i][j-1]);
            else
                dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
        }
    }
    cout<<dp[n][m]<<endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long 
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int32_t main(){
    fast;
    int x;  cin>>x;
    int ans = 2*(x/11);
    x = x%11;
    if(x>6) ans++;
    if(x>0) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int a[110];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,n; cin>>x>>n;
    rep(i,n){
        int t;cin>>t;
        a[t] = 1;
    }
    int tmp = 1000;
    int ans = -1;
    for(int i=0; i<110; i++){
        if(a[i] == 0 && abs(i-x)<tmp){
            tmp = abs(i-x);
            ans = i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

string S;
int cnt[3];

signed
main() {
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        cnt[S[i] - 'a']++;
    }
    int t = 0, b = 114514;
    for (int i = 0; i < 3; i++) {
        t = max(t, cnt[i]);
        b = min(b, cnt[i]);
    }
    if (t - b <= 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int K;

void read()
{
	cin >> K;
}

int d[MAXN];
bool in_queue[MAXN];

void solve()
{
	for(int i = 0; i < MAXN; i++)
		d[i] = (int)1e9;

	d[1] = 1;
	queue<int> Q;
	in_queue[1] = 1;
	Q.push(1);

	while(!Q.empty())
	{
		int u = Q.front();
		in_queue[u] = 0;
		Q.pop();

		if(d[10 * u % K] > d[u])
		{
			d[10 * u % K] = d[u];
			if(!in_queue[10 * u % K])
				Q.push(10 * u % K);
			in_queue[10 * u % K] = 1;
		}

		if(d[(u + 1) % K] > d[u] + 1)
		{
			d[(1 + u) % K] = d[u] + 1;
			if(!in_queue[(1 + u) % K])
				Q.push((1 + u) % K);
			in_queue[(1 + u) % K] = 1;
		}
	}
	
	cout << d[0] << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 4608
#include <iostream>

using namespace std;

int main(void)
{
    int coef;
    int offset;
    int penalty;

    cin >> coef >> penalty >> offset;

    long long current_weight = offset;
    for(int i = 0; i < 10; i++){
        current_weight = current_weight * coef - penalty;
        cout << current_weight << endl;
    }

    return 0;
}

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

using namespace std;

int N, C, D[ 31 ][ 31 ], c[ 501 ][ 501 ], wrongness[ 3 ][ 31 ]; bitset< 31 > selected; 

int min_wrongness( int i = 0, int k = 0 )
{
    if ( i == 3 )
        return k;
        
    int min_value = INT_MAX, l = i + 1; 
    
    for( int c = 1; c <= C; c++ )
        if ( !selected[ c ] )
            selected.set( c ),
            min_value = min( min_value, min_wrongness( l, k + wrongness[ i ][ c ] ) ),
            selected.reset( c );
            
    return min_value;
}

struct c_count_t: map< int, int > 
{
    int wrongness( int color ) const 
    {
        int total = 0;
        
        for( auto p: *this )
            total += p.second * D[ p.first ][ color ];
        
        return total; 
    }
    
} c_count[ 3 ];

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

    cin >> N >> C; int color; 

    for( int i = 1; i <= C; i++ )
        for( int j = 1; j <= C; j++ )
            cin >> D[ i ][ j ];
    
    for( int i = 1; i <= N; i++ )
        for( int j = 1; j <= N; j++ )
            cin >> color, c_count[ ( i + j ) % 3 ][ c[ i ][ j ] = color ]++;
            
    for( int i = 0; i < 3; i++ )
        for( color = 1; color <= C; color++ )
            wrongness[ i ][ color ] = c_count[ i ].wrongness( color );
    
    cout << min_wrongness();
}

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

int main(){
	for(int i = 0; i < 3000; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if(x || y) {
			if(y < x) swap(x, y);
			printf("%d %d\n", x, y);
		}else break;
	}
}



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

using namespace std;

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define INF 1e9

int main(){
    while(true){
        int sx,sy;
        bool flag = false;
        cin >> sx >> sy ;
        if(sx == 0 && sy == 0)
            break;
        int n;
        cin >> n ;
        vector<pair<int,int> > sprinkleres(n);
        FOR(i,0,n){
            int x,y;
            cin >> x >> y ;
            sprinkleres[i] = make_pair(x,y);
        }

        int dx[12] = {-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2};
        int dy[12] = {-2,-2,-2,-1, 0, 1, 2, 2, 2, 1, 0,-1};

        vector<pair<pair<int,int>,int> > queue;
        queue.push_back(make_pair(make_pair(sx,sy),0));

        while(queue.size() != 0){
            auto pair = queue.begin();queue.erase(queue.begin());
            auto point = pair->first;
            auto next_sprinker = pair->second;

            for(int j=0;j<12;j++){
                int nx = point.first + dx[j];
                int ny = point.second + dy[j];
                
                if(abs(sprinkleres[next_sprinker].first - nx) <= 1 && abs(sprinkleres[next_sprinker].second - ny) <= 1){
                    if(next_sprinker == n - 1){
                        flag = true;
                        break;
                    }
                    queue.push_back(make_pair(make_pair(nx,ny),next_sprinker+1));
                }
            }
            if(flag)
                break;
        }
        if(flag){
            printf("OK\n");
         }else{
             printf("NA\n");
         }
    }

    return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>


int main(void){
    int s = 100000;
    int i,j;
    
    
    scanf("%d", &i);
    
    for(j=1; j<=i; j++){
        s = s * 1.05;
    
        if(s % 1000 > 0)
            s = (s / 1000) * 1000 + 1000;
        
    }
    printf("%d\n", s);
    
    return 0;
}

Measured memory_bytes: 592
# 深さ優先探索
def dfs(V, closed): # V:探索頂点, closed:探索済み頂点リスト
 
    # 全頂点を探索したとき
    if not False in closed:
        return 1
    
    answer = 0
    for i in range(N):
        if not graph[V][i]:
            continue
        if closed[i]:
            continue
 
        # 頂点iを探索済みにする
        closed[i] = True
        answer += dfs(i,closed)
 
        # 最深まで探索したとき
        closed[i] = False
    
    return answer
 
N,M = map(int,input().split())
graph = [[False for i in range(N)] for j in range(N)]
 
for i in range(M):
    a,b = map(int,input().split())
    graph[a-1][b-1] = graph[b-1][a-1] = True
 
closed_list = [False]*N
closed_list[0] = True
 
print(dfs(0,closed_list))

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

template <typename T>
struct service {
  size_t L;
  std::vector<T> dat;
  std::vector<T> sum;
  std::vector<T> lazy;
  std::vector<bool> delayed;

  explicit service(size_t n, T x)
    : L(csqrt(n))
    , dat(L * L, x)
    , sum(L, x * L)
    , lazy(L)
    , delayed(L, false)
  { }

  void resolve(size_t g) {
    if (!delayed[g]) { return; }
    for (size_t i = g * L; i < (g + 1) * L; ++i) {
      dat[i] = lazy[g];
    }
    delayed[g] = false;
  }

  void compute_sum(size_t g) {
    assert(!delayed[g]);
    T s = 0;
    for (size_t i = g * L; i < (g + 1) * L; ++i) {
      s += dat[i];
    }
    sum[g] = s;
  }

  void update(size_t begin, size_t end, T x) {
    resolve(begin / L);
    resolve(end / L);
    size_t i;
    for (i = begin; i < end && i % L != 0; ++i) {
      dat[i] = x;
    }
    compute_sum(begin / L);
    for (; i + L <= end; i += L) {
      lazy[i / L] = x; delayed[i / L] = true;
      sum[i / L] = x * L;
    }
    for (; i < end; ++i) {
      dat[i] = x;
    }
    compute_sum(end / L);
  }

  T get_sum(size_t begin, size_t end) {
    resolve(begin / L);
    resolve(end / L);
    size_t i;
    T ans = 0;
    for (i = begin; i < end && i % L != 0; ++i) {
      ans += dat[i];
    }
    for (; i + L <= end; i += L) {
      ans += sum[i / L];
    }
    for (; i < end; ++i) {
      ans += dat[i];
    }
    return ans;
  }

  static size_t csqrt(size_t n) {
    size_t k = 1;
    while (k * k < n + 2) { ++k; }
    return k;
  }
};

int main() {
  // cout << fixed << setprecision(10);

  int N, Q; cin >> N >> Q;
  service<lli> srv(N, 0);
  REP(query, Q) {
    int T; cin >> T;
    if (T == 0) {
      lli S, T, X; cin >> S >> T >> X;
      srv.update(S, T+1, X);
    } else {
      lli S, T; cin >> S >> T;
      cout << srv.get_sum(S, T+1) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3540
# https://atcoder.jp/contests/abc077/tasks/arc084_a



N = gets.to_i
As = gets.split.map(&:to_i).sort!
Bs = gets.split.map(&:to_i)
Cs = gets.split.map(&:to_i).sort!

ans = Bs.inject(0) do |result, b|
  x = As.bsearch_index{ |a| a >= b } || N
  y = N - (Cs.bsearch_index{ |c| c > b } || N)
  result + x * y
end

puts ans


Measured memory_bytes: 23032
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))


int main(){
  Int res = INF;
  Int sum = 0;
  Int n, s;
  cin >> n >> s;
  vector<Int> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  int r = 0;
  for(int i = 0;i < n;i++){
    while(r < n && sum < s)sum += a[r++];
    if(sum >= s)res = min(res, r - i);
    sum -= a[i];
  }
  if(res == INF)res = 0;
  cout << res << endl;  
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define v(t,n) vector<t> n
void _din() {}
void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void qsortv(vector<T>& v) { qsort(v.data(), v.size(), sizeof(T), [](const void*a, const void*b)->int {if ((*(T*)a) < (*(T*)b))return -1; if ((*(T*)a) == (*(T*)b))return 0; return 1; }); }
template <typename T, typename F>inline void qsortv(vector<T>& v, F func) { qsort(v.data(), v.size(), sizeof(T), func); }
template <typename T>inline void sortv(vector<T>& v) { sort(v.begin(), v.end()); }
// ==================================================

int main()
{
	din(string, s);
	bool b = s[0]=='A';
	int c = -1;
	rep(i, 1, s.size())
	{
		if (i >= 2 && i <= s.size() - 2 && s[i] == 'C'&&c < 0) c = i;
		else if (i != c && (s[i]<'a' || s[i]>'z')) b = false;
	}
	if (c < 0) b = false;
	dout(b?"AC":"WA");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m, q; cin >> n >> m >> q;
    vvint accum(n+1,vint(n+1,0));
    rep(i,m) {
        int l, r; cin >> l >> r;
        accum[l][r]++;
    }
    REP(i,n+1)REP(j,n+1) {
        accum[i][j] += accum[i-1][j] + accum[i][j-1] - accum[i-1][j-1];
    }
    rep(i,q) {
        int p, q; cin >> p >> q;
        int ans = accum[n][q] - accum[p-1][q];
        printf("%d\n",ans);
    }
}

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

int main(){
    vector<int> a(3);
    int ans;
    cin >> a[0] >> a[1] >> a[2];
    /**/
    sort(a.begin(),a.end());
    int x = a.at(2) - a.at(0);
    int y = a.at(2) - a.at(1);

    //cout << x << " " << y << endl;

    if(x%2 == y%2){
        ans = (x + y)/2;
    }
    else{
        ans = (x + y + 1)/2;
        ans++;
    }

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


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m,l = readline() |> split |> parseMap
    g = 10^12*ones(Int,n,n)
    for i in 1:n
        g[i,i] = 0
    end
    for i in 1:m
        a,b,c = readline() |> split |> parseMap
        g[a,b] = c
        g[b,a] = c
    end
    for k in 1:n
        for i in 1:n
            for j in 1:n
                g[i,j] = min(g[i,j],g[i,k]+g[k,j])
            end
        end
    end
    h = 10^12*ones(Int,n,n)
    for i in 1:n
        for j in 1:n
            if g[i,j] <= l
                h[i,j] = 1
            end
        end
    end
    for k in 1:n
        for i in 1:n
            for j in 1:n
                h[i,j] = min(h[i,j],h[i,k]+h[k,j])
            end
        end
    end
    q = readline() |> parseInt
    for i in 1:q
        s,t = readline() |> split |> parseMap
        println(h[s,t] < 10^11 ? h[s,t] - 1 : -1)
    end
end

main()



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

using namespace std;

int main(){
    int N, low, up;
    cin >> N >> low >> up;

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int sum = 0;
        int tmp = i;
        while (tmp!=0) {
            sum += tmp % 10;
            tmp /= 10;
        }
        if (low <= sum && sum <= up) ans+=i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * 16-7-23_ABC042_C.cpp
 *
 *  Created on: 2016/07/23
 *      Author: ryoma
 */

#include <iostream>
#include <string>
#include <sstream>
#include <set>

using namespace std;

int N, K;
set<int> D;
stringstream ss;
string Ns, anss, mi;
bool up = false;
int carry = -2, ans;

int main() {
	cin >> Ns >> K;
	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		D.insert(d);
	}
	for (int j = 1; j < 10; j++)
		if (D.find(j) == D.end()) {
			ss << j;
			ss >> mi;
			break;
		}
	ss.clear();
	ss.str("");
	for (int i = 0; i < Ns.size(); i++) {
		anss += Ns[i];
		if (up == true) {
			for (int j = 0; j < 10; j++)
				if (D.find(j) == D.end()) {
					anss[i] = j + '0';
					break;
				}
			continue;
		}
		for (int j = anss[i] - '0'; j - (anss[i] - '0') < 10; j++) {
			if (j >= 10)
				carry = i - 1;
			if (D.find(j % 10) == D.end()) {
				anss[i] = '0' + (j % 10);
				break;
			}
		}
		if (anss[i] != Ns[i])
			up = true;
	}
	int now = -1;
	while (1) {
		now = carry;
		if (carry < 0)
			break;
		for (int i = anss[now] - '0' + 1; i - (anss[now] - '0') <= 10; i++) {
			if (D.find(i % 10) == D.end()) {
				if (i >= 10)
					carry--;
				anss[now] = '0' + (i % 10);
				break;
			}
		}
		if (now == carry)
			break;
	}
	if (carry == -1)
		anss = mi + anss;
	cout << anss << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll H,W;
    cin>>H>>W;
    
    VECi(string,S,H+2,"");
    REP(i,W+2){
        S[0]+=".";
        S[H+1]+=".";
    }
    REP1(i,H){
        S[i]+=".";
        string t; 
        cin>>t;S[i]+=t;
        S[i]+=".";
    }
    
    
    REP1(i,H){
        REP1(j,W){
            if(S[i][j]=='#'){
                cout<<"#";
            }else{
            int cnt=0;
            if(S[i-1][j-1]=='#')cnt++;
            if(S[i-1][j]=='#')cnt++;
            if(S[i-1][j+1]=='#')cnt++;
            if(S[i][j-1]=='#')cnt++;
            if(S[i][j+1]=='#')cnt++;
            if(S[i+1][j-1]=='#')cnt++;
            if(S[i+1][j]=='#')cnt++;
            if(S[i+1][j+1]=='#')cnt++;
            cout<<cnt;
            }
        }
        cout<<endl;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#define EPS 1e-9
using namespace std;

double eps, alterX;
int q;

//漸化式
double formula() {
    return(alterX - ((alterX*alterX*alterX - q) / (3.0 * (alterX*alterX))));
}
//ループ
void solve() {
    while(fabs(alterX*alterX*alterX - q) > eps) { //|x^3 - q| <= epsの時終了
        alterX = formula();
    }
}
//出力
void output(double ans) {
    printf("%.6lf\n", ans);
}

int main(void) {
    while(cin >> q, q != -1) {
        alterX = q / 2.0; //X1
        eps = q * 0.00001; //EPS
        
        solve();
        output(alterX);
    }
    return(0);
}

Measured memory_bytes: 1192
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
ll counter;

int main() {
	ll a = 0, b = 0, n = 0, counter = 0, maxi = 0;
	ll B[1000];
	std::string str, str2;
	cin >> n;
	rep(i, n-1) {
		cin >> B[i];
}
	rep(i, n-2) {
		counter += min(B[i],B[i+1]);
	}
	counter += B[0] + B[n-2];
	cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long m = 1000000007;
int h,w;
char as[1005][1005];
long long cs[1005][1005];

int main(){
    cin>>h>>w;
    for(int i=0; i<h; i++){
        for(int j =0; j<w; j++){
            cin>>as[i][j];
        }
    }
    cs[0][0] = 1;
    
    for(int i=1; i<h; i++){
        if(as[i][0]=='#'){
            cs[i][0] = 0;
        }
        else{
            cs[i][0] = (cs[i-1][0])%m;
        }
    }
    
    for(int i=1; i<w; i++){
        if(as[0][i]=='#'){
            cs[0][i]=0;
        }
        else{
            cs[0][i] = (cs[0][i-1])%m;
        }
    }
    
    for(int i=1; i<h; i++){
        for(int j =1; j<w; j++){
            if(as[i][j]=='#'){
                cs[i][j] = 0;
            }
            else{
                cs[i][j] = (cs[i-1][j]+cs[i][j-1])%m;
            }
        }
    }
    cout<<cs[h-1][w-1]<<"\n";
    return 0;
}

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

using namespace std;

string s;
int k;
vector<string> v;

string sub(int l, int r){
	return s.substr(l, r-l+1);
}

int main(){
	cin >> s >> k;
	
	for(int i = 0; i < s.size(); ++i){
		for(int j = 0; j < 5; ++j){
			if(i+j < s.size()){
				v.push_back(sub(i, i+j));
			}
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());

	cout << v[k-1] << endl;
}

Measured memory_bytes: 1660
// dp1_A
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>

int main() {
	int N;
	std::cin>>N;
	std::vector<int> h_vec(N);
	if (N == 1) {
		printf("0\n");
		return 0;
	}
	for (int i = 0;i < N; ++i) {
		int h;
		std::cin >> h;
		h_vec[i] = h;
	}

	std::vector<int> f(N);
	f[0] = 0;
	f[1] = abs(h_vec[1] - h_vec[0]);
	if (N == 2) {
		printf("%d\n", f[1]);
		return 0;
	}
	for (int i = 2; i < N; ++i) {
		f[i] = std::min(f[i-1] + abs(h_vec[i] - h_vec[i-1]),
					f[i-2] + abs(h_vec[i] - h_vec[i-2]));
	}
	printf("%d\n", f[N-1]);
	return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let r_count = s.iter().filter(|&&x| x == 'R').count();
    let g_count = s.iter().filter(|&&x| x == 'G').count();
    let b_count = s.iter().filter(|&&x| x == 'B').count();

    let mut ans = r_count * g_count * b_count;
    for i in 0..n {
        for j in i + 1..n {
            let k = 2 * j - i;
            if k >= n {
                break;
            }
            if s[i] != s[j] && s[i] != s[k] && s[j] != s[k] {
                ans -= 1;
            }
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2108
#include<stdio.h>
int main(){
  int x,y,o;

	
	while(1){
		scanf("%d %d",&x,&y);
	
		
		if(x == 0 && y == 0){
			break;
		}
		
		if(x > y){
			
			      o = y;
		      y = x;
	      x = o;
		
		
		}
		
		printf("%d %d\n",x,y);
	
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();

        for (int i = 0; i < n; i++) {
            System.out.print(s.charAt(i));
            System.out.print(t.charAt(i));
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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 / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    ll ans = 0;
    if(a + b > 2 * c){
        ans += (max(x, y) - abs(x - y)) * 2 * c;
        if(x > y){
            if(a > 2 * c){
                ans += 2 * c * (x - y);
            }else{
                ans += a * (x - y);
            }
        }else{
            if(b > 2 * c){
                ans += 2 * c * (y - x);
            }else{
                ans += b * (y - x);
            }
        }
    }else{
        ans += a * x + b * y;
    }
    cout<<ans<<endl;

    return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long k = sc.NextLong();

        long answer = n - k;
        if (k == 1)
        {
            answer = 0;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27508
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <iomanip>

inline intmax_t calcExcpectedValueDoubled(intmax_t num)
{
  return (num + 1); // * 0.5f;
}

int main(int argc, char* pArgv[])
{
  intmax_t n = 0, k = 0;
  std::cin >> n >> k;
  std::vector<intmax_t> a(n, 0);
  for (intmax_t index = 0; index < n; index ++) {
    std::cin >> a[index];    
  }

  std::list<intmax_t> w;


  intmax_t count = n - k;
  intmax_t maxWSum = 0;
  intmax_t wsum = 0;
  for (intmax_t j = 0; j < k; j ++) {
    auto e = calcExcpectedValueDoubled(a[j]);
    w.push_back(e);
    wsum += e;
  }
  maxWSum = wsum;

//  std::cerr << "wsum_first=" << (wsum * 0.5) << std::endl;

  for (intmax_t index = 0; index < count; index ++) {
    auto wleft = w.front();
    w.pop_front();
    
    wsum -= wleft;
//    std::cerr << "wleft=" << (wleft  * 0.5) << std::endl;
    auto e = calcExcpectedValueDoubled(a[index + k]);
    wsum += e;
//    std::cerr << "e=" << (e * 0.5) << std::endl;
    
    w.push_back(e);

//    std::cerr << "wsum=" << (wsum * 0.5) << std::endl;

    if (maxWSum < wsum) maxWSum = wsum;
  }

  std::cout << std::fixed << (maxWSum * 0.5) << std::endl;
  return 0;
}

/*
5 3
1 2 2 4 5

1 * 1/1 = 1
1 * 1/2 + 2 * 1/2  = 1.5
1 * 1/3 + 2 * 1/3 + 3 * 1/3 = 2
1 * 1/4 + 2 * 1/4 + 3 * 1/4 + 4 * 1/4 = 2.5
1 * 1/5 + 2 * 1/5 + 3 * 1/5 + 4 * 1/5 + 5 * 1/5 = 3

p について期待値は
sigma(p) / p = p(p+1)/(2*p) = (p + 1) / 2
5*6/(2*5)

*/


Measured memory_bytes: 8064
#include <iostream>
#include <cassert>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
int ansA,ansB;
int n;
int a,b;
using namespace std;
int main() {
  while(1){
    cin >> n;
    if(n==0) return 0;
    ansA = 0;
    ansB = 0;
    rep(i,n){
      cin >> a;
      cin >> b;
      if(a>b){
        ansA += a+b;
      }else if(b>a){
        ansB += a+b;
      }else{
        ansA += a;
        ansB += b;
      }
    }

    cout << ansA << " " << ansB << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a = Integer.parseInt(scanner.next());
    int b = Integer.parseInt(scanner.next());
    int c = Integer.parseInt(scanner.next());
    
    if(a + b >= c){
     System.out.println("Yes"); 
    }
    else{
     System.out.println("No");
    }
    scanner.close();
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    int N; cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++) {cin >> a[i]; a[i]--;}
    int count =0;
    map<int, int> m{};

    int idx = 0; m[0]++; 
    while(true){
        idx = a[idx];
        if(m[idx] != 0) {count = -1; break;}
        else {
            m[idx]++; count++;
            if(idx == 1) break;
        } 
    }
    cout << count << endl;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    int N, K, S;
    cin >> N >> K >> S;

    if (K <= 0) {
        if (S < 1000000000) {
            rep(i,N) {
                if (i != N - 1) cout << S + 1 << " ";
                else cout << S + 1 << endl;
            }       
        } else {
            rep(i,N) {
                if (i != N - 1) cout << 1 << " ";
                else cout << 1 << endl;
            }     
        }
        return 0;
    }
    if (S < 1000000000) {
        rep(i,N) {
            if (i < K) cout << S << " ";
            else {
                if (i != N - 1) cout << 1000000000 << " ";
                else cout << 1000000000 << endl;
            }
        }       
    } else {
        rep(i,N) {
            if (i < K) cout << S << " ";
            else {
                if (i != N - 1) cout << 1 << " ";
                else cout << 1 << endl;
            }
        }       
    }

    return 0;
}

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

int main() { 
	int n;
	cin >> n;
	int l;
	cin >> l;
	int sum = ((n * (n + 1)) / 2)  + n * l - n * 1;
	int ans = 1e9;
	int p = sum;
	for (int i = 1; i <= n; ++i) {
		int a = abs(sum - (sum - (l + i - 1))); 
		if (a < ans) {
			ans = a;
			p = sum - (l + i - 1);
		}
	}
	cout << p;
	return 0; 
} 



Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
if abs((30*H + 0.5 * M )-6*M) > 180:
    ang = 360- abs((30*H + 0.5 * M )-6*M)
else:
    ang = abs((30*H + 0.5 * M )-6*M)
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(ang))))

Measured memory_bytes: 9576
#include<bits/stdc++.h>
using namespace std;
int k, tot;
queue <long long> q;
int main() {
	cin >> k;
	if (k <= 9) {cout << k; return 0;}
	for (register int i = 1; i <= 9; ++i) q.push(i);
	tot = 9;
	while (tot < k) {
		long long p = q.front();
		q.pop();
		if (p % 10 == 0) {
			if (k - tot > 2)
			q.push(p * 10), q.push(p * 10 + 1), tot += 2;
			else {
				if (k - tot == 1) {cout << p * 10; return 0;}
				else {cout << p * 10 + 1; return 0;}
			}
		} else if (p % 10 == 9) {
			if (k - tot > 2)
			q.push(p * 10 + 8), q.push(p * 10 + 9), tot += 2;
			else {
				if (k - tot == 1) {cout << p * 10 + 8; return 0;}
				else {cout << p * 10 + 9; return 0;}
			}
		} else {
			if (k - tot > 3) q.push(p * 10 + ((p % 10) - 1)), q.push(p * 10 + p % 10), q.push(p * 10 + (p % 10) + 1), tot += 3;
			else {
				if (k - tot == 1) {cout << p * 10 + ((p % 10) - 1); return 0;}
				if (k - tot == 2) {cout << p * 10 + (p % 10); return 0;}
				if (k - tot == 3) {cout << p * 10 + ((p % 10) + 1); return 0;}
 			}
		}
	}
	return 0;
}

Measured memory_bytes: 768
def main():
    import sys
    N=int(sys.stdin.readline())
    L=list(map(int,sys.stdin.readline().split()))
    count=0
    for i in L:
        for j in L:
            if i==j:
                continue
            for k in L:
                if i==k or j==k:
                    continue
                
                lst=sorted([i,j,k])
                if lst[2]<lst[1]+lst[0]:
                    count+=1
  
    print(count//6)
main()

Measured memory_bytes: 67880
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
int a[200000], vs[200000],b[200020], co[200200];
vector<int>v[300000];
string s;
int main()
{
    int i, j, m, k, n, l;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 10664
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let [h,w]=t.n(2)
  let row=''
  for(let i=0;i<w+2;i++) row+='#'
  t.o(row)
  for(let i=0;i<h;i++) t.o('#'+t.s()+'#')
  t.o(row)
}
main()

Measured memory_bytes: 7500
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int inf=1e9;
const int maxn=200000+10;
int n,m; 
int num[maxn],can[maxn],cnt[maxn];
int main()
{
	//freopen("w1.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {scanf("%d",&num[i]);cnt[num[i]]++;}
	for(int i=1;i<=n;i++) 
	{
		for(int j=max(i-cnt[i]+1,1);j<=i;j++) can[j]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++) if(can[i]==0) ans++;
	//printf("aaaaaa%d\n",ans);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(num[x]-cnt[num[x]]+1>=1) 
		{
			can[num[x]-cnt[num[x]]+1]--;
			if(can[num[x]-cnt[num[x]]+1]==0) ans++;
		}
		cnt[num[x]]--;
		if(y-cnt[y]>=1) 
		{
			can[y-cnt[y]]++; 
			if(can[y-cnt[y]]==1) ans--;
		}
		cnt[y]++;
		num[x]=y;
		printf("%d\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 3712
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
count = 0
num = 1

for i in range(n):
    num = a[num - 1]
    count += 1
    if num == 2:
        break

if num != 2:
    count = -1

print(count)

Measured memory_bytes: 13044
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
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 ll INF=1e9+7;

int main(){
    ios;
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true){
        c-=b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
            break;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
            break;
        }
    }
    return 0;
} 

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    i64 i = f.size();
    if (x >= i) {
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 comb(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(k) * fact(n - k) % mod) % mod : 0;
}
int main() {
    i64 n, k;
    cin >> n >> k;
    if (k > n) cout << 0 << endl;
    else cout << comb(n - 1, n - k) << endl;
    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define vi vector<int>
using namespace std;
 
int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int a, b, c;
	cin>>a>>b>>c;
	if(c-a-b < 0)
	{
		cout<<"No";
		return 0;
	}
	int lhs = 4*a*b;
	int rhs = (c-a-b)*(c-a-b);
	if(lhs < rhs) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
let rec pow x n =
  if n = 0 then 1
  else x * (pow x (n-1));;

let f x =
  let rec loop h = function
      10 -> h
    | i -> loop (x land (pow 2 i)::h) (i+1)
  in loop [] 0;;

let mk_str x y =
  if y>0 then
    ((string_of_int y)^(if x = "" then x else " "^x))
  else x;;

let rec read () =
  try let n = read_int () in
      List.fold_left mk_str "" (f n) |> print_endline;
      read ()
  with End_of_file -> ();;

let () = read();;

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/e.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

int mp[1 << 11][1 << 11];
void solve(std::istream &in, std::ostream &out) {
  int n, m;
  in >> n >> m;
  bool swapped = false;
  if (n < m) swap(n, m), swapped = true;
  mp[1][1] = 1;
  for (int len = 1; len < n; ++len) {
    int L = 1 << len;
    mp[L][L] = 1;
    for (int i = 1; i < L; ++i) {
      for (int j = 1; j < L; ++j) {
        mp[i + L][j + L] = mp[i + L][j] = mp[i][j + L] = mp[i][j];
      }
    }
  }
  if (swapped) swap(n, m);
  for (int i = 1; i < 1 << n; ++i) {
    for (int j = 1; j < 1 << m; ++j) {
      out << char('0' + (!swapped ? mp[i][j] : mp[j][i]));
    }
    out << '\n';
  }
}



Measured memory_bytes: 11520
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int K;
    cin >> K;
    cout << ((K - 1) / 2 + 1) * (K / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ 0550: Dividing Snacks
// 2017.11.18 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define INF 0x33333333
int dp[2][2][5001];
int ti[10001];
char buf[20], *p;

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
    int n, n1, n2, i, j, jj, k1, k2, ans;
#if TM
	clock_t start, finish;
	start = clock();
#endif
	fgets(p=buf, 20, stdin), n = getint(), n1 = n - 1, n2 = n >> 1;
	for (i = 0; i < n1; i++) {
		fgets(p=buf, 20, stdin); 
		ti[i] = getint();
	}

	memset(dp, INF, sizeof(dp));
    dp[0][0][0] = dp[0][1][0] = 0;
    for (k1 = 0, k2 = 1, i = 0; i < n; i++, k1 = k2, k2 = !k2) {
		jj = i; if (jj > n2) jj = n2;
		memset(dp[k2], INF, sizeof(int)*(jj+1));
		for (j = 0; j <= jj; j++) {
			if (dp[k2][0][j+1] > dp[k1][0][j]) dp[k2][0][j+1] = dp[k1][0][j];
			if (dp[k2][1][j+1] > dp[k1][0][j]+ti[i]) dp[k2][1][j+1] = dp[k1][0][j]+ti[i];

			if (dp[k2][1][j] > dp[k1][1][j]) dp[k2][1][j] = dp[k1][1][j];
			if (dp[k2][0][j] > dp[k1][1][j]+ti[i]) dp[k2][0][j] = dp[k1][1][j] + ti[i];
		}
    }
    ans = dp[k1][0][n2]; if (ans > dp[k1][1][n2]) ans = dp[k1][1][n2];
	printf("%d\n", ans);
#if TM
	finish = clock();
	printf("time %lf\n", (double)(finish-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 1968