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

using namespace std;

const int N = 1e5+100;

long long int dp[N];

bool ok[N];

int main () {
    memset(dp,0,sizeof(dp));
    ok[0]=1;
    long long int n, w;
    cin >> n >> w;
    for(int i = 0 ; i < n ; i++ ) {
        long long int x, y;
        cin >> x >> y;
        for(int j = w ; j >= 0 ; j--) {
            if(j-x<0)break;
            if(ok[j-x]) {
                dp[j]=max(dp[j],dp[j-x]+y);
                ok[j]=1;
            }
        }
    }
    cout << *max_element(dp,dp+w+10);
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;
int main(){
    int n;
    cin>>n;
    cout<<(n+1)* n /2<<endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M, C;
	int B[30];
	int ans = 0;
	int A;

	cin >> N >> M >> C;
	rep(i, 0, M)
	{
		cin >> B[i];
	}
	rep(i, 0, N)
	{
		int res = 0;
		rep(j, 0, M)
		{
			cin >> A;
			res += A * B[j];
		}
		if (res + C > 0)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define tp tuple<int,int,int>
#define mtp make_tuple

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<tp>up,down;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        int res=0,tmp=0;
        for(char ch:s)
        {
            if(ch=='(')res++;
            if(ch==')')res--;
        }
        if(res>=0)
        {
            res=0;
            for(int i=0;i<s.size();i++)
            {
                if(s[i]=='(')res++;
                if(s[i]==')')res--;
                tmp=min(tmp,res);
            }
            up.push_back(mtp(tmp,res,i));
        }
        if(res<0)
        {
            res=0;
            for(int i=s.size()-1;i>=0;i--)
            {
                if(s[i]=='(')res--;
                if(s[i]==')')res++;
                tmp=min(tmp,res);
            }
            down.push_back(mtp(tmp,res,i));
        }
    }
    sort(up.begin(),up.end(),greater<tp>());
    sort(down.begin(),down.end(),greater<tp>());
    int val_up=0,val_down=0;
    vector<int>res;
    for(auto&x:up)
    {
        int u,v,id;
        tie(u,v,id)=x;
        if(val_up+u<0) return cout<<"No",0;
        val_up+=v;
        res.push_back(id);
    }
    for(auto&x:down)
    {
        int u,v,id;
        tie(u,v,id)=x;
        if(val_down+u<0) return cout<<"No",0;
        val_down+=v;
        res.push_back(id);
    }
    if(val_up==val_down)
    {
        cout<<"Yes"<<'\n';
        //for(auto&x:res) cout<<x+1<<' ';
    }
    else cout<<"No";
}


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

using i64 = int64_t;

int board[13][7]={0};

void init(int h){
    for(int i=1;i<=h;++i){
        for(int j=1;j<=5;++j){
            board[i][j] = 0;
        }
    }
    for(int i=0;i<7;++i){
        board[0][i] = -1;
        board[h+1][i] = -1;
    }
    for(int i=0;i<=h+1;++i){
        board[i][0] = -1;
        board[i][6] = -1;
    }
}

int erase(int h){
    int score = 0;
    for(int i=1;i<=h;++i){
        int cnt = 0, num = -1;
        for(int j=1;j<=6;++j){
            if(board[i][j] == num)cnt++;
            else{
                if(cnt >= 3){
                    int idx = j-1;
                    while(board[i][idx] == num){
                        score += num;
                        board[i][idx] = 0;
                        idx--;
                    }
                }
                cnt = 1;
                num = board[i][j];
            }
        }
    }
    return score;
}

bool drop(int h){
    bool dropped = false;
    for(int i=h;i>0;--i){
        for(int j=1;j<=5;++j){
            if(board[i][j] == 0){
                int idx = i-1;
                while(board[idx][j] == 0)idx--;
                if(board[idx][j] == -1)continue;
                board[i][j] = board[idx][j];
                board[idx][j] = 0;
                dropped = true;
            }
        }
    }
    return dropped;
}

void print(int h){
    cout << "---" << endl;
    for(int i=1;i<=h;++i){
        for(int j=1;j<=5;++j){
            printf("%2d",board[i][j]);
        }
        cout << endl;
    }
    cout << "***" << endl;
}

int main(){
    int h;
    while(cin >> h, h != 0){
        init(h);
        for(int i=1;i<=h;++i){
            for(int j=1;j<=5;++j){
                cin >> board[i][j];
            }
        }
        //print(h);
        bool res = true;
        int ans = 0;
        do{
            ans += erase(h);
            //print(h);
            res = drop(h);
            //print(h);
        }while(res);
        //print(h);
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3020
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


int d[2001][2001];
int x[2001][2001];
int y[2001][2001];


signed main() {

	int H, W;
	cin >> H >> W;
	rep(i, H) {
		string s;
		cin >> s;
		rep(j, s.length()) {
			if(s[j] == '#')
				d[i][j] = -1;
			else
				d[i][j] = 1;
		}
	}
	rep(i, H) {
		int cnt = 0;
		int prev = 0;
		rep(j, W) {
			if (d[i][j] == 1) {
				cnt++;
			}
			else {
				/// prevから直前まで
				for (int k = prev; k < j; k++) x[i][k] = cnt;
				x[i][j] = 0;
				prev = j+1;
				cnt = 0;
			}
		}
		if(d[i][W-1]==1)
			for (int k = prev; k < W; k++) x[i][k] = cnt;
	}
	rep(j, W) {
		int cnt = 0;
		int prev = 0;
		rep(i, H) {
			if (d[i][j] == 1) {
				cnt++;
			}
			else {
				/// prevから直前まで
				for (int k = prev; k < i; k++) y[k][j] = cnt;
				y[i][j] = 0;
				prev = i+1;
				cnt = 0;
			}
		}
		if (d[H-1][j] == 1)
			for (int k = prev; k < H; k++) y[k][j] = cnt;
	}
	int ans = -INF;
	rep(i, H){
		rep(j, W) {
			ans = max(ans, x[i][j] + y[i][j]);
		}
	}
	cout << ans-1 << endl;

	return 0;
}


Measured memory_bytes: 94080
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> makeRangeArray(int n)
{
        static vector<int> vec;
        for(int i = 1; i <= n; i++){
                vec.push_back(i);
        }

        return vec;
}

void exchangeInArray(vector<int>& vec, int a, int b)
{
        if(a <= 0 || b <= 0)
                throw "エラー発生";

        a--;
        b--;

        swap(vec[a],vec[b]);
}

int reader(string str, int& a, int& b)
{
        int i;

        a = 0;
        b = 0;
        for(i=0; str[i] != ','; i++)
        {
                a *= 10;
                a += str[i] - '0';
        }

        for(i++; str[i];i++){
                b *=10;
                b += str[i] - '0';
        }
}

int main()
{
        try{
                int w;
                int n;
                cin >> n;
                cin >> w;
                vector<int> vec = makeRangeArray(n);
                for(int i=0;i<w;i++){
                        int a,b;
                        string str;
                        cin >> str;
                        reader(str, a, b);
                        exchangeInArray(vec, a, b);
                }

                for(auto x:vec){
                        cout << x << endl;
                }
        }
        catch (char *str){
                cout << str << endl;
        }
}

Measured memory_bytes: 1228
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

constexpr int LEN = 100010;

void impossible() { cout << "Impossible" << endl; exit(0); }

int N, M;
ll A[LEN];

vector<vector<int>> G0;

char visited[LEN];
pair<int, ll> check(int v) {
    int idx = v; ll mv = A[v];
    visited[v] = true;
    for (int w : G0[v]) {
        if (!visited[w]) {
            pair<int, ll> pr = check(w);
            if (mv > pr.second) {
                mv = pr.second;
                idx = pr.first;
            }
        }
    }
    return make_pair(idx, mv);
}

char used[LEN];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    G0.resize(N);

    for (int j = 0; j < N; ++j) { cin >> A[j]; }
    for (int j = 0; j < M; ++j) {
        int x, y; cin >> x >> y;
        G0[x].push_back(y); G0[y].push_back(x);
    }

    ll ans = 0;
    int num = 0;

    fill(visited, visited+N, false); fill(used, used+N, false);
    for (int j = 0; j < N; ++j) {
        if (!visited[j]) {
            ++num;
            auto pr = check(j);
            used[pr.first] = true;
            ans += pr.second;
        }
    }

    if (num == 1) {
        cout << 0 << endl;
        return 0;
    }

    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int j = 0; j < N; ++j) {
        if (!used[j]) pq.push(A[j]);
    }

    int req = 2 * (num-1);
    if (N < req) impossible();

    req = req - num;
    assert(pq.size() >= req);
    while (req-- > 0) { ans += pq.top(); pq.pop(); }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7928
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

struct Edge{
    int s, t, c;
    bool operator < (const Edge& e) const {
        if(c != e.c) return c < e.c;
        return make_pair(s, t) < make_pair(e.s, e.t);
    }
};

struct UnionFind{
    vector<int> data;
    UnionFind(int N) : data(N) {
        REP(i, N) data[i] = i;
    }
    bool merge(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        data[x] = y;
        return true;
    }
    int root(int x){
        if(x == data[x]) return x;
        return data[x] = root(data[x]);
    }
};

int main(){
    int N, M;
    while(cin >> N >> M && N){
        vector<Edge> edges;
        REP(i, M){
            Edge e;
            cin >> e.s >> e.t >> e.c;
            e.s--; e.t--;
            edges.push_back(e);
        }
        sort(edges.begin(), edges.end());
        UnionFind uf(N);
        vector<int> costs;
        REP(i, M){
            Edge& e = edges[i];
            if(uf.merge(e.s, e.t)){
                costs.push_back(e.c);
            }
        }
        cout << costs[ costs.size() / 2 ] << endl;
    }
    return 0;
}

Measured memory_bytes: 1440
#include <iostream>

int main() {
	std::string str;
	int m, h;

	while(true){
		std::cin >> str;
		if(str == "-") break;
		std::cin >> m;

		for(int i=0; i<m; i++){
			std::cin >> h;
			str =  str.substr(h) +  str.substr(0, h);
		}
		std::cout << str << std::endl;
	}
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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 long long INF = 1LL << 60;

int count(int bit, int n){
    int cnt=0;
    REP(i, n){
        if(bit&1<<i) cnt++;
    }
    return cnt;
}

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

    vector<int> a(N); 
    REP(i, N) cin>>a[i];

    ll cost_min=INF;
    int bitsave=0;
    // 見える建物を仮定
    REP(bit, 1<<N){

        // 見える建物の個数と一致しない場合はスルー
        if(count(bit, N)!=K) continue;

        // 仮定した建物が見えるようにするコストを計算
        int maxnow=-1;
        ll cost = 0;
        REP(i, N){
            if(bit&1<<i){
                if(maxnow<a[i]){
                    maxnow=a[i];
                }
                else{
                    cost+=(maxnow+1-a[i]);
                    maxnow+=1;
                }
            }
            maxnow=max(maxnow, a[i]);
        }
        if(cost_min>cost){
            cost_min = cost;
            bitsave = bit;
        }
    }

    //cout << bitset<5>(bitsave) << endl;

    cout << cost_min << endl;

    return 0;
}

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

const int maxn = 1e5 + 100;

typedef long long ll;

ll dp[maxn][2];

vector<int>graph[maxn];

const ll mod = 1e9 + 7;

void solve(int u, int p)
{
    dp[u][0] = 1;
    dp[u][1] = 1;

    for(auto &v : graph[u])
    {
        if(v == p)
            continue;
        solve(v,u);

        dp[u][0] = dp[u][0] * (dp[v][1] + dp[v][0]) % mod;
        dp[u][0] %= mod;

        dp[u][1] = dp[u][1] * dp[v][0];
        dp[u][1] %= mod;
    }
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1; i < n ; i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    solve(1,1);
    printf("%lld\n",(dp[1][0] + dp[1][1]) % mod);
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;


// ABC124C - Coloring Colorfully
// https://atcoder.jp/contests/abc124/tasks/abc124_c
void ABC124C() {
	string S;
	cin >> S;

	/*
		スタートが0 : 奇数番目は1、偶数番目は0
		スタートが1 : 奇数番目は0、偶数番目は1
	*/

	int ans = 0;
	for (int i = 1; i < S.size(); i++)
	{
		int s = int(S[i] - '0'); //i番目の数字を数値に変換

		if (S[0] == '0') //
		{
			if (i % 2 == 1 && s != 1) { ///奇数番目なのに1でないときは書き換えが必要
				ans++;
			}
			else if (i % 2 == 0 && s != 0) { //偶数番目なのに0でないときは書き換えが必要
				ans++;
			}
		}
		else if (S[0] == '1')
		{
			if (i % 2 == 1 && s != 0) { //奇数番目なのに0でないときは書き換えが必要
				ans++;
			}
			else if (i % 2 == 0 && s != 1) { //偶数番目なのに1でないときは書き換えが必要
				ans++;
			}
		}
	}

	cout << ans << endl;
}

int main() {
	ABC124C();

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    int df = abs(a-b);
    if(df % 2 == 0){
        df = df /2;
        cout << df + min(a,b);
    }else{
        cout << "IMPOSSIBLE";
    }
}

Measured memory_bytes: 256
N,M = map(int,input().split())
p = ['0']*M
S = ['0']*M
for i in range(M):
  p[i],S[i]= map(str,input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)
i = 0
for i in range(M):
  if S[i] == 'WA':
    if AC[int(p[i])] == 0:
      WA[int(p[i])] = WA[int(p[i])]+1
    else:
      None
  else:
    AC[int(p[i])]=1
count = 0
for i in range(N+1):
  if AC[i]==0:
    count = count+WA[i]
print(sum(AC),sum(WA)-count)

Measured memory_bytes: 17788
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

typedef long long ll;

const int Maxn = 200005;
const int mod = 1000000007;

int pw2[Maxn], inv2[Maxn];
int n;
vector <int> neigh[Maxn];
int cnt[Maxn];
int res;

void Traverse(int v, int p)
{
    int dp[3] = {1, 0, 0};
    cnt[v] = 1;
    for (int i = 0; i < neigh[v].size(); i++) {
        int u = neigh[v][i];
        if (u == p) continue;
        Traverse(u, v);
        cnt[v] += cnt[u];
        int my[2] = {inv2[cnt[u]], (1 - inv2[cnt[u]] + mod) % mod};
        for (int j = 2; j >= 0; j--) {
            int prob = dp[j]; dp[j] = 0;
            for (int k = 0; k < 2; k++) {
                int nj = min(2, j + k);
                dp[nj] = (dp[nj] + ll(prob) * my[k]) % mod;
            }
        }
    }
    if (cnt[v] < n) {
        int my[2] = {inv2[n - cnt[v]], (1 - inv2[n - cnt[v]] + mod) % mod};
        for (int j = 2; j >= 0; j--) {
            int prob = dp[j]; dp[j] = 0;
            for (int k = 0; k < 2; k++) {
                int nj = min(2, j + k);
                dp[nj] = (dp[nj] + ll(prob) * my[k]) % mod;
            }
        }
    }
    res = (res + ll(dp[2]) * inv2[1]) % mod;
}

int main()
{
    pw2[0] = inv2[0] = 1;
    pw2[1] = 2; inv2[1] = (mod + 1) / 2;
    for (int i = 2; i < Maxn; i++) {
        pw2[i] = ll(pw2[1]) * pw2[i - 1] % mod;
        inv2[i] = ll(inv2[1]) * inv2[i - 1] % mod;
    }
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].push_back(b);
        neigh[b].push_back(a);
    }
    Traverse(1, 0);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 26880
n,a,b,c,d=map(int,input().split())
e=abs(b-a)
if c+d+e==0:
    print("YES")
    exit()
upper=(e+(n-1)*d)//(c+d)
lower=(e+(n-1)*c)//(c+d)
if upper==lower:
    if (e+(n-1)*c) % (c+d) == 0 and 0<=lower and (e+(n-1)*c)/(c+d) <= n-1 and e <= (n-1)*max([c,d]):
        print("YES")
    else:
        print("NO")
else:
  if 0<=lower and (e+(n-1)*c)/(c+d) <= n-1 and e <= (n-1)*max([c,d]):
	    print("YES")
  else:
        print("NO")


Measured memory_bytes: 3064
#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;

int main() {
    i64 x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<pair<i64, int>> t;
    for (int k = 0; k < 3; ++k) {
        i64 d[3] = {a, b, c};
        for (int i = 0; i < d[k]; ++i) {
            int v;
            cin >> v;
            t.emplace_back(v, k);
        }
    }
    sort(begin(t), end(t));
    i64 ans = 0;
    i64 rest = x + y;
    while (rest > 0) {
        i64 k, v;
        tie(v, k) = t.back();
        t.pop_back();
        if (k == 0 && x == 0) continue;
        if (k == 1 && y == 0) continue;
        ans += v;
        rest--;
        if (k == 0) x--;
        if (k == 1) y--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10604
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
bool f(string a, string b, string c) {
  if((a[a.size()-1] == b[0]) && (b[b.size()-1] == c[0])) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  YORN(f(a, b, c));
  return 0;
}

Measured memory_bytes: 256
fun main() {
    val x = readInt()
    val ratings = (400..2000 step 200)
    var kyu = 8
    for (rate in ratings) {
        if (x in rate until (rate + 200)) break
        kyu--
    }
    println(kyu)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 34840
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
	int a, b;
	int area, perimeter;
	scanf("%d %d", &a, &b);
	area=a*b;
	perimeter=2*(a+b);
	printf("%d %d\n",area, perimeter);

	return 0;

}


Measured memory_bytes: 3200
//winnable
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	long double l;
	cin>>l;
	cout<<fixed<<setprecision(12)<<l*l*l/27<<'\n';
}
int main()
{
	int t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 256
import sys
from collections import deque
import numpy as np

sys.setrecursionlimit(10**9)

H, W = map(int, input().split())

# 最短距離で行って通ったところ以外を黒マスにする
# . : 0, # : 1
S = np.zeros((H + 2, W + 2), dtype='int')
S[0, :] = 1
S[-1, :] = 1
S[:, 0] = 1
S[:, -1] = 1

cost = np.zeros((H + 2, W + 2), dtype='int')
cost[:, :] = -1

subset = S[1:-1, 1:-1]
for h in range(H):
    s = list(input())
    subset[h:] = np.array([0 if i == '.' else 1 for i in s], dtype='i')

dd = ((-1, 0), (1, 0), (0, -1), (0, 1))
q = deque([(1, 1)])
cost[1, 1] = 0

while q:
    x, y = q.popleft()
    for dx, dy in dd:
        nx = x + dx
        ny = y + dy
        if S[nx, ny] == 0 and cost[nx, ny] == -1:
            cost[nx, ny] = cost[x, y] + 1
            q.append((nx, ny))

if cost[H, W] == -1:
    print(-1)
    exit()

ans = (H + 2) * (W + 2) - (S == 1).sum() - cost[H, W] - 1
print(ans)


Measured memory_bytes: 12460
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[][] array = new int[3][3];
		double l = sc.nextDouble();
		double l_3 = l/3;
		System.out.println(Math.pow(l_3, 3));
	}
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    deque<int> d;
    rep(i, n){
        int p = lower_bound(all(d), a[i]) - d.begin();
        if (p == 0){
            d.push_front(a[i]);
        } else d[p - 1] = a[i];
    }
    int ans = d.size();
    print(ans);

}



Measured memory_bytes: 1024
# coding: utf-8
# Your code here!

def gcd(x, y):
   if x < y:
      x, y = y, x
   if x % y == 0:
      return y
   else:
      return gcd(y, x % y)

n = int(input())
A = list(map(int, input().split()))

l = A[0]
for i in range(1, n):
   l = l * A[i] / gcd(l, A[i])
print(int(l))



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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	vector<lli> a(3);
	REP(i,0,3)cin>>a[i];

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

	lli ans = 0;
	if(a[0]%2 != a[2]%2){
		a[0]++;
		a[1]++;
		ans++;
	}
	if(a[1]%2 != a[2]%2){
		a[0]++;
		a[1]+=2;
		a[2]++;
		ans+=2;	
	}
	ans += (a[2]-a[0])/2;
	ans += (a[2]-a[1])/2;
	cout<<ans<<endl;
  
  return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, dp[101][25], c[75];

int main(){
	int p[25] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
	cin >> n;
	for(int i=1;i<=n;i++){
		for(int j=0;j<25;j++){
			dp[i][j] = dp[i-1][j];
			int m = i;
			while(m%p[j]==0&&m!=0){
				dp[i][j]++;
				m /= p[j];
			}
		}
	}
	for(int i=0;i<75;i++){
		for(int j=0;j<25;j++){
			if(dp[n][j]>=i) c[i]++;
		}
	}
	cout << c[74] + max(0, (c[2]-1)*c[24]) + max(0, (c[4]-1)*c[14]) + max(0, c[4]*(c[4]-1)/2*(c[2]-2)) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int[] dp = new int[n];
            for (var i = 0; i < dp.Length; i++)
                dp[i] = int.MaxValue;

            dp[0] = 0;

            for (var i = 1; i < dp.Length; i++)
            {
                dp[i] = dp[i - 1] + Math.Abs(h[i] - h[ i -1]);
                if (i == 1) continue;
                dp[i] = Math.Min(dp[i], dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
            }


            Console.WriteLine(dp[n -1]);
        }
    }
}


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

int main(){
    string days;
    cin >> days;
    int start = days[0] == 'R';
    int ans = start;
    for(int i = 1; i < days.size();++i){
        if(days[i] != 'R')
            start = 0;
        else
            ++start;
        ans = max(ans,start);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main(){
	int len,count=0;
	string S;
	cin>>S;
	len = S.length();
	for(int i=0;i<(len-len%2)/2;i++){
		if(S[i]!=S[len-i-1])count++;
	}
	cout<<count;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 100000000000

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

	ll N, M;
	cin >> N >> M;

	vector<P> m;
	ll list[10] = { 2,5,5,4,5,6,3,7,6 };
	ll tmp;
	rep(i, M) {
		cin >> tmp;
		m.push_back(make_pair(tmp, list[tmp - 1]));
	}

	sort(ALL(m), greater<P>());

	vector<ll> dp(N+1,-INF);
	dp[0] = 0;
	rep2(i, 1, N+1) {
		rep(j, M) {
			if(i - m[j].second >= 0) {
				dp[i] = max(dp[i], dp[i - m[j].second] + 1);
			}
		}
	}

	ll num = N;
	deque<ll> ans;
	while (num > 0) {
		rep(j, M) {
			if ((num - m[j].second >= 0) && (dp[num] - 1 == dp[num - m[j].second])) {
				ans.push_back(m[j].first);
				num -= m[j].second;
				break;
			}
		}
	}

	rep(i,dp[N]) cout << ans[i];
	cout << "\n";

	return 0;
}

Measured memory_bytes: 384
S = int(input())
h = int(S/3600) if 9 < int(S/3600) else int(S/3600)
m = int(S/60) % 60 if 9 < int(S/60) % 60 else int(S/60) % 60
s = S % 60 if 9 < S % 60 else S % 60
print("{0}:{1}:{2}".format(h, m, s))


Measured memory_bytes: 5592
#include <string>
#include <iostream>
#include <unordered_map>
#include <utility>

using namespace std;

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

	unordered_map<int, int> likes;
	int pairs = 0;

	int r2;
	for (int r1=1; r1 <= N; ++r1)
	{
		cin >> r2;

		likes[r1] = r2;
		//cout << "likes[" << r1 <<"] == " << r2 << endl;
		if (likes.find(r2) != likes.end())
		{
			if (likes[r2] == r1) ++pairs;

		}		
	}	
	cout << pairs << "\n";
	return 0;
}

Measured memory_bytes: 4388
# = int(input())
# = str(input())
N, K = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

for i in range(K, N):
    if A[i] > A[i-K]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 31492
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,n,p,i;
  cin>>k>>n;
  int a[n],max=-1;
  cin>>a[0];
  for(i=1;i<n;i++)
  {cin>>a[i];
   if(a[i]-a[i-1]>max)
   {
     max=a[i]-a[i-1];
   }
  }
  p=k-a[n-1]+a[0];
  if(p>max)
  {max=p;}
  cout<<k-max<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	int count = 0;

	for (int i = A; i <= B; i++) {
		int s = i % 10; // iの左から5桁目
		int t = i /	10000 % 10; // iの左から1桁目
		int u = i /	10 % 10; // iの左から4桁目
		int v = i /	1000 % 10; // iの左から2桁目
		if(s == t && u == v)
			count++;
	}
	cout << count << '\n';
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                var a = ReadInt();
                if (IsPrime(a))
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        public static void debuglist(List<int> x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debuglist(List<string> x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debugarray(int[] x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debugarray(string[] x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }

        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}



Measured memory_bytes: 13908
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s >> s;
  cout << (count(begin(s), end(s), 'R') > count(begin(s), end(s), 'B') ? "Yes"
                                                                       : "No")
       << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,x,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(x!=i) ans++;
	} 
	if(ans>2) printf("NO");
	else printf("YES");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveB();
    }
    
    private void solveA() {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
	if (s.contains("a") && s.contains("b") && s.contains("c"))
	    {
		System.out.println("Yes");
	    }
	else {
	    System.out.println("No");
	}
    }

    private void solveB() {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    	int b = sc.nextInt();
	int k = sc.nextInt();

	for(int i=a; i <= b; i++){
	    if (i<a+k || i>b-k) System.out.println(i);
	}
    }
    private void solveC() {	
    }
}


Measured memory_bytes: 21716
# 約分無視できる！！
# A+B/100で勝負がつくので、最後に100/A+Bをかける
MOD = 10**9 + 7

def inv_mod(a):
  return pow(a,MOD-2,MOD)

U = 10**5
UU = 2*U
N,A,B,C = map(int,input().split())
pow_A = [1] * (U+1)
pow_B = [1] * (U+1)
pow_AB = [1] * (U+1)
for n in range(1,U+1):
  pow_A[n] = (pow_A[n-1]*A)%MOD
  pow_B[n] = (pow_B[n-1]*B)%MOD
  pow_AB[n] = (pow_AB[n-1]*(A+B))%MOD

fact = [1] * (UU+1)
for n in range(1,UU+1):
  fact[n] = (n*fact[n-1])%MOD
fact_inv = [1] * (UU+1)
fact_inv[UU] = inv_mod(fact[UU])
for n in range(UU,0,-1):
  fact_inv[n-1] = (n*fact_inv[n])%MOD

def comb(n,k):
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x

num = 0 # 分母を(A+B)^Nと見て分子
for k in range(N):
  # N-1勝k敗になった後1勝
  x = comb(N-1+k,k)
  x *= pow_B[k]
  x %= MOD
  x *= pow_A[N]
  x %= MOD
  x *= pow_AB[N-k]
  x %= MOD
  x *= (N+k)
  x %= MOD
  num += x
  
for k in range(N):
  # N-1勝k敗になった後1勝
  x = comb(N-1+k,k)
  x *= pow_A[k]
  x %= MOD
  x *= pow_B[N]
  x %= MOD
  x *= pow_AB[N-k]
  x %= MOD
  x *= (N+k)
  x %= MOD
  num += x

# 分母は(A+B)^N
den = pow(A+B,N+N,MOD)

answer = num * inv_mod(den)
answer %= MOD

# 最後に引き分けの補正
answer *= inv_mod(A+B)
answer %= MOD
answer *= 100
answer %= MOD

print(answer)
  
  

Measured memory_bytes: 30708
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <stack>
#include <queue>
#include <string>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define getddd(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d\n",a);
#define pfii(a,b) printf("%d %d\n",a,b);
#define pfl(a) printf("%lld\n",a);
#define pfll(a,b) printf("%lld %lld\n",a,b);
#define  SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;


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

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

int grid [1003][1003];


long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}
ll isprime(ll i){
    if (i==2 || i == 3){
        return 0;
    }
    bool ctr =0;
    for(ll k = 2;k*k <i;k++){
        if(i%k==0)ctr=1;
    }
    if(ctr)return 1;
    else return 0;

}


double x1,x2,y11,y2,v1,v2;
double timet=0;
double f ( double dd){
    timet = 0;
    timet +=sqrt(((dd-x1)*(dd-x1)+(0-y11)*(0-y11)))/v1;
    timet +=sqrt(((dd-x2)*(dd-x2)+(0-y2)*(0-y2)))/v2;
    return timet;
}

double tesearch(double left,double right,double eps = 1e-7){
    while(right-left > eps){
        double mid1= left+(right-left)/3;
        double mid2 = right-(right-left)/3;
        if(f(mid1) > f(mid2)){
            left = mid1;
        }else{
            right=mid2;
        }

    }
    return f(left);
}

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

    vl vec;
    ll t;
    FOR(c,a){
        getL(t);
       vec.pb(t);
    }
    vl vec2;
    vec2.pb(0);
    for(ll i = 1 ;i < a+1;i++ ){
        ll k = vec2[i-1]+vec[i-1];
        vec2                                                                                                                                        .pb(k);
    }
    ll res =0 ;
    for(int i = 0 ; i < vec2.size();i++){
        if(vec2[i]<=b)res++;
        else break;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef pair<lli, lli> P;

const int MAX = 1e5;
int main() {
	lli N, K;
		cin >> N >> K;
	vector<P> a(N);
	rep(i, N) {
		lli s, t;
		cin >> s >> t;
		a[i]=make_pair(s,t);
	}
	sort(a.begin(), a.end());

	lli sum = 0;
	rep(i, N) {
		sum += a[i].second;
		if (K <= sum) {
			cout << a[i].first;
			break;
		}
	}
}

Measured memory_bytes: 1792
fun main() {
    class BinSearch<T: Comparable<T>> (inp:List<T>) {
        val li = inp.sorted()

        fun find(tar:T, opt: String="default"):Int{
            var l=0
            var r=this.li.size-1
            var ans=-1
            var tmp=-1
            while (opt=="default" && l<=r){
                tmp=(l+r)/2
                if (this.li[tmp]<tar) {l=tmp+1}
                if (tar<this.li[tmp]) {r=tmp-1}
                if (this.li[tmp]==tar) {break}
            }
            while (opt=="upper" && l<=r){
                tmp=(l+r)/2
                if (this.li[tmp]<tar) {l=tmp+1}
                if (tar<=this.li[tmp]) {r=tmp-1}
            }
            while (opt=="lower" && l<=r){
                tmp=(l+r)/2
                if (this.li[tmp]<=tar) {l=tmp+1}
                if (tar<this.li[tmp]) {r=tmp-1}
            }
            when {
                this.li[tmp]==tar->ans=tmp
                this.li[tmp]<tar->{
                    when(opt){
                        "lower"->ans=tmp
                        "upper"->ans=tmp+1
                    }
                }
                this.li[tmp]>tar->{
                    when(opt){
                        "upper"->ans=tmp
                        "lower"->ans=tmp-1
                    }
                }
            }
            return ans
        }
    }
    var n= readLine()!!.toLong()
    var a=BinSearch(readLine()!!.split(" ").map { it.toLong() }.sorted())
    var b=BinSearch(readLine()!!.split(" ").map { it.toLong() }.sorted())
    var c=BinSearch(readLine()!!.split(" ").map { it.toLong() }.sorted())
    var ans:Long=0
    for (i in b.li){
        var ind1=a.find(i-1, "lower")
        var ind2=c.find(i+1, "upper")
        ans+=(ind1+1)*(n-ind2)

    }
    println(ans)
}

Measured memory_bytes: 69236
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        String ans = "";
        for (int i = 0; i < n; i++) {
            if (i == k - 1) {
                ans += Character.toLowerCase(s.charAt(i));
                continue;
            }
            ans += s.charAt(i);
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#!/bin/bash

read s

char_count=$(echo ${s} | wc -c)

if [ ${char_count} -lt 2 -o ${char_count} -gt 1001 ]; then
  exit
fi

echo "${s}" | egrep ".*C.*F.*" > /dev/null
if [ $? -eq 0 ]; then
  echo "Yes"
else
  echo "No"
fi

Measured memory_bytes: 724
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderCS {
    class Program {
        static void Main(string[] args) {
            int[] ND = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = ND[0], D = ND[1];

            int count = 0;
            for(int i = 0; i < N; i++) {
                if (Math.Sqrt(Console.ReadLine().Split(' ').Select(i => Math.Pow(int.Parse(i), 2)).Sum()) <= D)
                    count++;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 41532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
 
int main() {
  int N, M, T;
  cin >> N >> M >> T;
  int a[N];
  rep(i, N) cin >> a[i];
  a[N] = T + M;
  int ans = a[0] - M;
  for (int i = 0; i < N; i++)
    ans += max(0, a[i + 1] - a[i] - 2 * M);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	int i;
	cin>>N;
	vector<long long> A(N,0);

	for (i=0;i<N;i++){
		cin>>A[i];
	}
	int aw=0;
	long long Max=0;
	int add=0;
	Max=A[0];
	for (i=1;i<N;i++){
		if (Max<A[i]){
			if (add==0){
				add=1;//増す
			}
			if (add==2){//減る
				aw++;
				add=0;
			}
		}
		if (Max>A[i]){
			if (add==0){
				add=2;
			}
			if (add==1){
				aw++;
				add=0;
			}
		}
		Max=A[i];
	}
	cout<<aw+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())

w = n - k + 1

if n < k:
    l = n
else:
    l = k - 1

C = []
for i in range(1, l + 1):
    c = 0
    while i < k:
        i *= 2
        c += 1
    C.append(c)

ans = 0
for c in C:
    ans += (1 / n) * (1 / 2)**c
if w > 0:
    ans += w / n

print(ans)


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

vector< int > c;
vector< int > s;
map<int, int> mp;

int main(void){
  int n,m;
  cin >> n >> m;
  c.resize(m);
  s.resize(m);
  fill(c.begin(),c.end(),0);
  fill(s.begin(),s.end(),0);
  for(int i = 0;i < n;++i){
    int a;
    cin >> a;
    ++c[a % m];
    ++mp[a];
  }
  for(map<int, int>::iterator itr = mp.begin();
      itr != mp.end();++itr) {
    s[(itr->first) % m] += (itr->second)/2;
  }

  int res = 0;
  for(int i = 0;i < m;++i) {
    /*
    for(int j = 0;j < m;++j) {
      cout << c[j] << " ";
    }
    cout << endl;
    */
    int p;
    if(i != (m-i) % m){
      p = min(c[i],c[(m-i) % m]);
    } else {
      p = c[i]/2;
    }
    res += p;
    c[i] -= p;
    c[(m-i) % m] -= p;
  }
  /*
  for(int j = 0;j < m;++j) {
    cout << s[j] << " ";
  }
  cout << endl;
  */
  for(int i = 0;i < m;++i){
    res += min(s[i]*2, c[i]) / 2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5888
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if(A == 7 && B == 5 && C == 5){
			System.out.println("YES");
		}else if(A == 5 && B == 7 && C == 5){
			System.out.println("YES");
		}else if(A == 5 && B == 5 && C == 7){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
		
	}
}

Measured memory_bytes: 35564
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
    int n,m;
  cin>>n>>m;
  vector<int> a(n);
    rep(i,n) cin>>a[i];
  ld s=0;
  rep(i,n) s+=a[i];
  double std=s/(4*m);
  int count=0;
  rep(i,n){
if(a[i]>=std) count++;
  }
  if(count>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
MOD = 2019

ans = 0

if R - L >= 2019:
    pass
else:
    A = set()

    for i in range(L, R):
        for j in range(i+1, R+1):
            A.add(i*j % MOD)
            if i * j % MOD == 0:
                break

    ans = min(A)

print(ans)


Measured memory_bytes: 41068
#include<stdio.h>
#include<stdlib.h>

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

int main(){
	int n,i,ans=0,count=0;;
	long a[100000],b[100000],ue[100000];
	long long sum=0,sumb=0,sita=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%ld",&a[i]);
		sum+=a[i];
	}
	for(i=0;i<n;i++){
		scanf("%ld",&b[i]);
		sumb+=b[i];
	}
	if(sumb>sum){
		puts("-1");
		return 0;
	}
	for(i=0;i<n;i++){
		if(a[i]<b[i]){
			ans++;
			sita+=(b[i]-a[i]);
		}else if(a[i]>b[i]){
			ue[count]=(a[i]-b[i]);
			count++;
		}
	}
	qsort(ue,count,sizeof(long int),compare_int);
	for(i=0;sita>0;i++){
		sita-=ue[i];
		ans++;
		
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2812