akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
    #include <math.h> 
    int main(void){
        // Your code here!
        int H,W,K;
        char map[6][7] = {};
        int ans = 0;
        
        scanf("%d%d%d",&H,&W,&K);
        
        for(int i = 0; i < H; i++){
            scanf("%6s",map[i]);
            //printf("%s\n",map[i]);
        }
        
        for(int Hb = 0; Hb < (int)pow(2,H); Hb++ ){
            for(int Wb = 0; Wb < (int)pow(2,W); Wb++){
                int brack = 0;
                for(int i = 0; i < H; i++){
                    for(int j = 0; j < W; j++){
                        if((Hb>>i & 1) == 0 && (Wb>>j & 1) == 0 && map[i][j] == '#'){
                            brack++;
                        }
                    }
                }
                if(brack == K){
                    ans++;
                }
            }
        }
        
        printf("%d\n",ans);
    }

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

int main(){
  int N;
  cin >> N;
  int H[N];
  for (int i=0; i < N; i++){
    cin >> H[i];
  }

  int out = 1;

  for (int i=1; i < N; i++){
    // i番目の山から海が見えるかどうか
    int visivle = 1;
    for (int j=0; j < i; j++){
      if (H[j] > H[i]){
        visivle = 0;
        break;
      }
    }
    if (visivle == 1){
      out += 1;
    }
  }

  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a;
  int b[3];
  int ans;
  
  scanf("%d", &a);
  
  b[0] = a/100;
  b[1] = a%100/10;
  b[2] = a%10;
  
  ans = b[0] + b[1] + b[2];

  printf("%d", ans);
  return(0);
}

Measured memory_bytes: 128
n, a, b = map(int, raw_input().split(' '))
v = map(int, raw_input().split(' '))

res = 0
for i in range(0, n - 1):
	if (v[i + 1] - v[i]) * a > b:
		res += b
	else:
		res += (v[i + 1] - v[i]) * a

print res

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

int main()
{
  string S;
  cin >> S;
  int64_t ans = 0, N = S.size();
  for (int s = 0; s < (1 << (N - 1)); s++){
    bitset<12> d(s);
    int64_t A = 0, tmp = S.at(0)-'0';
    for (int i = 0; i < N - 1; i++){
      if (d.test(i)){
        tmp = (tmp * 10) + S.at(i + 1)-'0';
      }
      else{
        A += tmp;
        tmp =S.at(i + 1)-'0';
      }
    }
    ans += (A + tmp);
  }
  cout << ans << endl;

}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int m;
    cin>>m;
    cout<<48-m<<endl;

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <math.h>
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1)
 
using ll = unsigned long long;
using pll = pair<ll,ll>;
using ii = pair<int,int>;
using iii = pair<pair<int,int>,int>;
using viii = vector<iii>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using ui = unsigned int;
 




int main() {
    ofstream out("output.txt");
    ios_base::sync_with_stdio(false);

    string s;
    cin>>s;

    int l = s.size();
    int res = 0;

    for(int i =0;i<(l/2);i++){
        if(s[i] != s[l-i-1]) res++;
    }

    cout<<res<<endl;


    return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const bool DBG = 1;

#define TRACE(x)    x
#define WATCH(x)    TRACE(cout << #x" = " << x << endl)
#define WATCHR(a,b) TRACE(for(auto it=a; it!=b;) cout<<*(it++)<<" ";cout<<endl)
#define WATCHC(V)   TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

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

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

void solve() {
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);

    string S; cin >> S;
    vll m(2019);
    m[0]++;
    int cur = 0;
    int pow10 = 1;
    F0Rd(i,S.size()) {
        cur += pow10*(S[i]-'0');
        cur %= 2019;
        m[cur]++;
        pow10 *= 10;
        pow10 %= 2019;
    }
    ll ans = 0;
    F0R(i,2019) {
        if(m[i] > 1) {
            ans += m[i]*(m[i]-1)/2;
        }
    }
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3796
n = int(input())
action = []
for i in range(n):
    action.append([int(i) for i in input().split()])
dp = [[0 for _ in range(3)] for _ in range(n+1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + action[i][k])
print(max(dp[n]))

Measured memory_bytes: 74840
#include<stdio.h>

int main(void){
	int S;
	scanf("%d",&S);
	int h,m,s;
	if(S>=3600){
		h=S/3600;
	}
	else{h=0;}
	m=(S-3600*h)/60;
	s=S-(3600*h)-60*m;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


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

// clang-format off
#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

inline void br(ostream &os = cerr) { os << endl; }

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
  int N = input();
  vector<int> A(N);
  cin >> A;

  whole(sort, A);

  int64 ans = 1;

  range(i, 0, N) {
    if ((N & 1) && A[i] != (i + 1) / 2 * 2) ans = 0;
    if (!(N & 1) && A[i] != i / 2 * 2 + 1) ans = 0;
  }

  range(i, 0, N / 2) (ans *= 2) %= mod;

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc071/tasks/arc081_b
# 横ドミノと縦ドミノの場合わけを考える
# 横ドミノ→横ドミノの場合 : いままでの通り*3通り
# 横ドミノ→縦ドミノ : いままで*1通り ok
# 縦ドミノ→横ドミノ : いままで*2通り ok
# 縦ドミノ→縦ドミノ : いままで*2通り ok

MOD = 10**9+7
N = int(input())
S1 = input()
S2 = input()
pre1 = S1[0]
pre2 = S2[0]

if pre1 != pre2:
    ans = 6
else:
    ans = 3
for s1, s2 in zip(S1[1:], S2[1:]):
    if pre1 == s1 and pre2 == s2:
        pass
    elif pre1 != pre2 and s1 != s2:
        # 横→横
        ans *= 3
    elif pre1 != pre2 and s1 == s2:
        # 横→縦
        pass
    elif pre1 == pre2 and s1 != s2:
        # 縦→横
        ans *= 2
    elif pre1 == pre2 and s1 == s2:
        # 縦→縦
        ans *= 2

    if ans >= MOD:
        ans %= MOD

    pre1, pre2 = s1, s2


print(ans % MOD)


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

int main() {
string S;
cin >> S;
bool ans = true;
int N = S.length();
for (int i = 0; i < N / 2; i++) {
    if(S[i] != S[N - 1 - i]) ans = false;
    if(S[i] != S[(N - 3) / 2 - i]) ans = false;
}
for (int i = 0; i < (N - 1) / 2; i++) {
    if(S[i] != S[(N - 1) / 2 - 1 - i]) ans = false;
}
if (ans) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int N;
	int N_1=0, N_2=0;
	scanf("%d", &N);
		N_1 = N / 10;
		N_2 = N - (int)(N / 1000) * 1000;
		for (int i = 0; i < 10; i++) {
			if (N_1 == (i * 100 + i * 10 + i) || N_2 == (i * 100 + i * 10 + i)) {
				printf("Yes");
				return 0;
			}
		}
		printf("No");
	
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	static int N;
	static long A, B;
	static long[] S;
	static long[][] dpA;
	static long[][] dpB;
	static BinaryIndexedTree bitA;
	static BinaryIndexedTree bitB;
	static final long MOD = 1_000_000_000 + 7;
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextLong();
		B = sc.nextLong();
		S = new long[N];
		dpA = new long[2][N];
		dpB = new long[2][N];
		bitA = new BinaryIndexedTree(N);
		bitB = new BinaryIndexedTree(N);
		Stack<Query> stackA = new Stack<>();
		Stack<Query> stackB = new Stack<>();
		for (int i = 0; i < N; ++i) {
			S[i] = sc.nextLong();
		}
		Arrays.sort(S);
 
		bitA.addVal(0 + 1, 1);
		bitB.addVal(0 + 1, 1);
		stackA.push(new Query(0 + 1, 1));
		stackB.push(new Query(0 + 1, 1));
		int leftA = -1;
		int leftB = -1;
		for (int i = 0; i + 1 < N; ++i) {
			long sA = 0;
			long sB = 0;
			while (S[i + 1] - S[leftA + 1] >= A)
				++leftA;
			while (S[i + 1] - S[leftB + 1] >= B)
				++leftB;
			sB = bitA.getVal((leftB + 1) + 1);
			sA = bitB.getVal((leftA + 1) + 1);
			if (S[i + 1] - S[i] < A) {
				while (!stackA.isEmpty()) {
					Query q = stackA.pop();
					bitA.addVal(q.pos, -q.val);
				}
			}
			if (S[i + 1] - S[i] < B) {
				while (!stackB.isEmpty()) {
					Query q = stackB.pop();
					bitB.addVal(q.pos, -q.val);
				}
			}
			bitA.addVal((i + 1) + 1, sA);
			bitB.addVal((i + 1) + 1, sB);
			stackA.add(new Query((i + 1) + 1, sA));
			stackB.add(new Query((i + 1) + 1, sB));
		}
		System.out.println((bitA.getVal(N) + bitB.getVal(N)) % MOD);
	}
 
	static class BinaryIndexedTree {
		int n;
		long[] val;
 
		public BinaryIndexedTree(int n) {
			this.n = n;
			val = new long[n + 1];
		}
 
		void addVal(int k, long v) {
			while (k <= n) {
				val[k] += v;
				val[k] = (val[k] + MOD) % MOD;
				k += k & -k;
			}
		}
 
		long getVal(int k) {
			long s = 0;
			while (k > 0) {
				s += val[k];
				s = (s + MOD) % MOD;
				k -= k & -k;
			}
			return s;
		}
 
		void clear() {
			val = new long[n + 1];
		}
	}
 
	static class Query {
		int pos;
		long val;
 
		public Query(int pos, long val) {
			this.pos = pos;
			this.val = val;
		}
	}
 
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

int main(){
  int n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  int ans = 0;
  vector<bool> f(k,false);
  rep(i,n) {
    if(i-k>=0 && t[i] == t[i-k] && f[i%k]) {
      f[i%k] = false;
      continue;
    }
    if(t[i] == 'r') ans += p;
    else if(t[i] == 's') ans += r;
    else ans += s;
    f[i%k] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define maxn 1000
#define fr(a) freopen(a,"r",stdin)
#define fw(a) freopen(a,"w",stdout)
vector<int> g[maxn];// vector lưu trữ đỉnh kề
/*queue<int> s;// hàng đợi
stack<int> s1;
int cl[maxn];//mảng đánh dấu
int distance1[maxn];
int dd[maxn]; // mảng đánh dấu
vector<bool> visited(100, false);
void clear( queue<int> &q )
{
   queue<int> empty;
   swap( q, empty );
}
void bfs(int u) // u là đỉnh xuất phát
{
    clear(s); // dọn sạch hàng đợi
    s.push(u); // bỏ đỉnh xuất phát vào
    distance1[u]=0;
    cl[u] = 1; // đánh dấu đỉnh xuất phát
    while(!s.empty()) // chừng nào hàng đợi còn chưa rỗng
    {
        int u = s.front(); // lấy ra đỉnh ở đầu queue
        s.pop(); // bỏ đỉnh ở đầu queue ra khỏi queue
        for(int v : g[u]) // với mỗi đỉnh v kề với đỉnh u
        {
            if(cl[v]==0) // nếu đỉnh v chưa được đánh dấu
            {
                s.push(v); // bỏ đỉnh v vào queue
                distance1[v]=distance1[u]+1;
                cl[v]=1; // đánh dấu đỉnh v

            }
        }
    }
}
void visit(int u) {
    cout << u << " ";
}
void dfs(int u) // dfs đệ quy
{   visit(u);
    dd[u]=1; // đánh dấu đỉnh u đã đi qua
    for(int v : g[u]) // với mỗi đỉnh v kề với đỉnh u // tương đương for(int i=0;i<g[u].size();i++) int v=g[u][i]
    {
        if(dd[v] == 0)
            dfs(v); // nếu v chưa đánh dấu, tới thăm đỉnh u
    }
}
map<int,int> sav;
void add_edge(int u, int v) {
    g[u].push_back(v);
    g[v].push_back(u);
}
int dem;
int main()
{
   int mon[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
   int monn[100];
   int n;
   cin>>n;
   while(n--){
    int r;
   cin>>r;
    if(r==28)
        r=r;
    else if(r==29)
        r=r-1;
    monn[dem++]=r;
   }
   int m=0,r;
    for(int i=1;i<=12;i++){
        if(monn[m]==mon[i]){
             r=m+1;
            for(int j=i+1;j<=14;j++){

                if(j==13)
                        j=1;
                if(r==dem)
                   {
                       cout<<"YES";
                       return 0;
                   }
                if(monn[r]!=mon[j])
                    break;
                r++;
            }
        }


    }
    cout<<"NO";
}*/
typedef long long int ll;
ll a[2000],n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==1)
        {
            cout<<0;
            return 0;
        }
    }
    int dem=0;
    while(true){

    for(int i=0;i<n;i++){
        a[i]/=2;
        if(a[i]%2==1)
        {
            cout<<dem+1;
            return 0;
        }
    }   dem++;
    }
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdint>
using namespace std;

int main(){
    int x1, y1, x2, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    x3 = x2 + (y1 - y2);
    y3 = y2 + (x2 - x1);
    x4 = x1 + (y1 - y2);
    y4 = y1 + (x2 - x1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> a(n);
    rep(i,n){
        cin >> a[i].first >> a[i].second;
    }
    // rep(i,n){
    //     cout  << a[i].first << a[i].second;
    // }
    sort(a.begin(),a.end());
    ll cost=0;
    ll num=0;
    ll i=0;
    while(num<m){
        if(a[i].second<=m-num){
            cost+=(a[i].first)*a[i].second;
            num+=a[i].second;
        }
        else{
            cost+=(a[i].first)*(m-num);
            num = m;
        }
        i++;
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    int gmin = m;
    for (int i = 0; i <= n - m; i++)
    {
        int cnt = 0, k = i;
        for (int j = 0; j < m; j++)
        {
            if (s[k++] != t[j])
            {
                cnt++;
            }
        }
        if (cnt < gmin)
        {
            gmin = cnt;
        }
    }
    cout << gmin << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
   int n, ans=1;
   cin >> n;
   vector<int> d(n);
   rep(i, n)cin >> d.at(i);
   sort(all(d));
   REP(i, n-1){
     if(d.at(i) != d.at(i-1))ans++;
   }
   cout << ans;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4.2")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define PI acos(-1)
#define all(x) x.begin(),x.end()
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define vb vector<bool>
#define vvi vector<vector<ll> >
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define AS assign
#define S second
#define debug(x) cout<<(#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define mod 1000000007
#define lg2(x) 63-(__builtin_ctzll(x))
#define RZ resize
#define IN insert
#define X real()
#define Y imag()
#define FBO find_by_order
#define OFK order_of_key
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
typedef unsigned long long ull;
typedef long double d64;
typedef complex<d64>P;
ll modpow(int a,int b,int m){if(!b)return 1%m;ll u=modpow(a,b/2,m);u=(u*u)%m;if(b&1)u=(u*a)%m;return u;}



int main(){
read(n);
cout<<n*n;
return 0;
}




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

const int NM=1e5+5;

ll dp[3005][3005];

int main()
{   int n;
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>dp[i][i];
    for(int k=1; k<n; k++)
        for(int i=1,j; i+k<=n; i++)
        {   j=i+k;
            dp[i][j]=max(dp[i][i]-dp[i+1][j],dp[j][j]-dp[i][j-1]);
        }
    cout<<dp[1][n];
    return 0;
}

Measured memory_bytes: 49704
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

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

int r,c,cnt=0; 
string s[55]; 
bool vis[55][55];
int dis[55][55];

bool check(int i,int j){ 
    if (i<0 or j<0 or i>=r or j>=c or vis[i][j] or s[i][j]=='#') return false; 
    return true; 
} 
 
void bfs(){
    dis[0][0] = 1;
    queue <pii> q;
    q.push({0,0});
    vis[0][0]=true;
    while (q.size()){
        int x = q.front().ff ; 
        int y = q.front().ss ; 
        //cout << x<<','<<y<<" -> ";
        q.pop();
        for (int i=0;i<4;i++){
            int ii = x+dx[i];
            int jj = y+dy[i];
            if (check(ii,jj)){
                vis[ii][jj]=true;
                dis[ii][jj] = dis[x][y]+1;
                q.push({ii,jj});
            }
        }
    }
}

inline void solve(){
    cin>>r>>c; 
    for (int i=0;i<r;i++) cin>>s[i]; 
    for (int i=0;i<r;i++) 
        for (int j=0;j<c;j++) 
            if (s[i][j]=='.') cnt++; 
    bfs();
    int ans=-1;
    if (vis[r-1][c-1]) ans = cnt-dis[r-1][c-1];
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}

/*
6 6
..#...
#...#.
####..
.....#
.#####
......

*/

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxv = 11;

int d[maxv][maxv];
int V;     //?点数
int x[maxv];     //以x[i]?起点?最短路?之和

void warshall_floyd()
{
    for(int k=0; k<V; k++)
        for(int i=0; i<V; i++)
            for(int j=0; j<V; j++)
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
}

int main()
{
    int E;
    while(scanf("%d", &E)==1 && E)
    {
        memset(d, 0x3f, sizeof(d));
        for(int i=0; i<maxv; i++)
            d[i][i] = 0;
        V = 0;
        for(int i=0; i<E; i++)
        {
            int u, v, cost;
            scanf("%d%d%d", &u, &v, &cost);
            d[u][v] = cost;
            d[v][u] = cost;
            V = max(V, max(v, u)+1);
        }
        warshall_floyd();
        memset(x, 0, sizeof(x));
        for(int i=0; i<V; i++)
        {
            for(int j=0; j<V; j++)
                x[i] += d[i][j];
        }
        int ans = min_element(x, x + V) - x;
        cout << ans << ' ' << x[ans] << endl;
    }
    return 0;
}

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

using ll = long long;
using Pi = pair < int , int >;

map < ll , ll > mp;
ll N, K;
ll ans = 0;
ll sum[200005] = {};
ll A[200005];

int main()
{
    mp[0] = 1;
    cin >> N >> K;
    for ( int i = 1; i <= N; i++ ) {
        cin >> A[i];
        sum[i] = (sum[i - 1] + A[i] - 1) % K;
        if ( i >= K ) mp[sum[i - K]]--;
        ans += mp[sum[i]]++;
    }

    cout << ans << endl;

    return ( 0 );
}


Measured memory_bytes: 15872
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    char :"%c",char*:"%s")

#define mswap(x,y) _Generic((x),int:swap_int,unsigned int:swap_uint,\
                            long long:swap_ll,unsigned long long:swap_ull)(&(x),&(y))

void swap_int(int *a,int *b){int tmp = *a;*a = *b;*b= tmp;return;}
void swap_uint(unsigned int *a,unsigned int *b){unsigned int tmp = *a;*a = *b;*b= tmp;return;}
void swap_ll(long long *a,long long *b){long long tmp = *a;*a = *b;*b= tmp;return;}
void swap_ull(unsigned long long *a,unsigned long long *b){unsigned long long tmp = *a;*a = *b;*b= tmp;return;}

int main(void){
    char str[101];
    scanf("%s",str);
    for(int i = 0;i < strlen(str);i++){
        printf("x");
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007

int main() {
    int S, W;
    cin >> S >> W;
    if (S <= W)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    return 0;
}

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

if sum(A) < sum(B):
    print(-1)
else:
    minus_count = []
    plus_count = []
    for i in range(N):
        dist = A[i] - B[i]
        if dist > 0:
            plus_count.append(dist)
        elif dist < 0:
            minus_count.append(dist)
    plus_count.sort()
    minus_sum = sum(minus_count)
    count = len(minus_count)
    while minus_sum < 0:
        minus_sum += plus_count.pop()
        count += 1
    print(count)

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int h, w, n;
  cin >> h >> w >> n;
  int max_n = max(h, w);
  int ans = (int)ceil((double)n / max_n);
  cout << ans << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, K; double P, E[200010] = {}; cin >> N >> K;
  REP(i, N){
    cin >> P;
    E[i+1] = (1.0+P) / 2.0;
  }
  for(int i = 1; i <= N; i++){
    E[i] += E[i-1];
  }
  double ans = 0;
  for(int i = K; i <= N; i++){
    chmax(ans, E[i]-E[i-K]);
  }
  dcout << ans << endl;
}

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

int main() {
  int a;
  cin >> a;
  int s3 = a%10;
  int s2 = (a-s3)%100/10;
  int s1 = (a-s2-s3)/100;
  cout << s1+s2+s3<< endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    ll N;
    cin >> N;
    if(N % 2 == 0){cout << N / 2 << endl;return 0;}
    else{cout  << N / 2 + 1 << endl;return 0 ;}

    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
	map<string, int> counter;
	string longest;

	{
		string input;
		while(cin >> input)
		{
			if(longest.length() < input.length())
				longest = input;

			if(counter.find(input) == counter.end())
				counter[input] = 0;
			else
				counter[input]++;
		}
	}

	int frequency = 0;
	string word;
	for(auto i : counter)
		if(frequency < i.second)
		{
			frequency = i.second;
			word = i.first;
		}

	cout << word << ' ' << longest << endl;

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
	string s;
	cin>>s;
	int a[26]={0};
	for(int i=0;i<s.size();i++){
		a[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(a[i]==0){
			cout<<(char)(i+'a')<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
}


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

int main()
{
  long long A, B, K;
  cin >> A >> B >> K;
  if ((A - K) >= 0) {
    A -= K;
    cout << A << " " << B << endl;
    return 0;
  } else {
    K -= A;
    if ((B - K) >= 0) {
      B -= K;
      cout << 0 << " " << B << endl;
      return 0;
    }
  }
  cout << 0 << " " << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

char t[200001];
int a[13];
int b[531441];
int c[13][531441];
int last[531441];
int ans[13][531441];

int main() {
    int n, m, i, j;
    
    scanf("%d", &n);
    scanf("%s", t);
    
    m = strlen(t);
    
    a[0] = 1;
    for (i = 1; i <= n; i++) a[i] = a[i - 1] * 3;
    
    for (i = 0; i < n; i++) {
        int s = 0;
        
        for (j = 0; j < a[i]; j++) {
            b[j] = 0;
            b[j + a[i]] = 1;
            b[j + a[i] * 2] = 2;
            last[j] = 0;
        }
        
        for (j = 0; j < m; j++) {
            int x = c[i][j];
            
            if ((s - last[x]) % 2 == 1) {
                last[x] = s;
                
                b[x] = (3 - b[x]) % 3;
                b[x + a[i]] = (3 - b[x + a[i]]) % 3;
                b[x + a[i] * 2] = (3 - b[x + a[i] * 2]) % 3;
            }
            
            if (b[x] == 2) {
                c[i + 1][j] = x;
            } else if (b[x + a[i]] == 2) {
                c[i + 1][j] = x + a[i];
            } else {
                c[i + 1][j] = x + a[i] * 2;
            }
            
            if (t[j] == 'S') {
                s++;
            } else {
                b[x] = (b[x] + 1) % 3;
                b[x + a[i]] = (b[x + a[i]] + 1) % 3;
                b[x + a[i] * 2] = (b[x + a[i] * 2] + 1) % 3;
            }
        }
        
        for (j = 0; j < a[i]; j++) {
            if ((s - last[j]) % 2 == 1) {
                b[j] = (3 - b[j]) % 3;
                b[j + a[i]] = (3 - b[j + a[i]]) % 3;
                b[j + a[i] * 2] = (3 - b[j + a[i] * 2]) % 3;
            }
            
            ans[i + 1][j] = ans[i][j] + b[j] * a[i];
            ans[i + 1][j + a[i]] = ans[i][j] + b[j + a[i]] * a[i];
            ans[i + 1][j + a[i] * 2] = ans[i][j] + b[j + a[i] * 2] * a[i];
        }
    }
    
    for (i = 0; i < a[n]; i++) {
        if (i > 0) putchar(' ');
        printf("%d", ans[n][i]);
    }
    puts("");
    
    return 0;
}


Measured memory_bytes: 19536
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // int[] nx = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // long K = long.Parse(Console.ReadLine());
            int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int a = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int h = int.Parse(Console.ReadLine());
            // int Y = int.Parse(Console.ReadLine());
            // string A = Console.ReadLine();
            // string B = Console.ReadLine();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(int.Parse);
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // for(int i = 0; i<A_num.Length;i++){
            //     A_num[i] = 0;
            // }
            Array.Sort(abc);
            Console.WriteLine(abc[2]==(abc[1]+abc[0])?"Yes":"No");
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector< pair<int, int>> ab(n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    ab[i] = make_pair(b, a);
  }

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

  int cur = 0;
  bool is_valid = true;
  for (int i = 0; i < n; ++i) {
    cur += ab[i].second;
    if (cur > ab[i].first) {
      is_valid = false;
      break;
    }
  }

  if (is_valid) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



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

int main() 
{
    char c;
    
    cin >> c;
    
    if(c >= 'a' && c <= 'z'){
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
    
    return (0);
}

Measured memory_bytes: 3632
import java.util.*;

class Main{

	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);

		int n=s.nextInt(),k=s.nextInt();
		ArrayList<HashSet<Integer>> g=new ArrayList<>();

		for(int i=0;i<n;++i)
			g.add(new HashSet<>(1));
		for(int i=0;i<n-1;++i){
			int a=s.nextInt()-1,b=s.nextInt()-1;
			g.get(a).add(b);
			g.get(b).add(a);
		}

		//System.err.println(g);

		System.out.println(f(0,k,g,-1)*k%mod);
	}

	private static long f(int i,int k,ArrayList<HashSet<Integer>> g,int parent){
		HashSet<Integer> h=g.get(i);
		long r=1;

		//child pattern
		{
			int c=k-(parent==-1?1:2);
			int child=h.size()-(parent==-1?0:1);
			for(int l=0;l<child;++l){
				r*=c-l;
				r%=mod;
			}
		}

		//reduction
		for(int j:h){
			if(j==parent)
				continue;
			r*=f(j,k,g,i);
			r%=mod;
		}
		return r;
	}
}

Measured memory_bytes: 125976
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B;
	string s;
	cin >> A >> B >> s;
	bool ok = true;
	for (int i = 0; i < A + B + 1; i++)
	{
		if(i == A){
			if (s[i] != '-')
				ok = false;
		}
		else {
			if (s[i] < '0' || s[i] > '9')
				ok = false;
		}
	}

	if(ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> B(N - 1);
  rep(i,N - 1) cin >> B[i];
  vector <int> A(N);
  A[0] = B[0];
  for (int i = 1; i <= N - 2; i++){
    A[i] = min(B[i], B[i - 1]);
  }
  A[N - 1] = B[N - 2];
  int ans = accumulate(A.begin(), A.end(), 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	int cnt = 0 ;
	for(int i=0;i<s.size();i++) if(s.at(i)=='x') cnt++ ;
	cout << YorN(cnt<=7) << endl ;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;
vector<P> vec;

int main(void){
	cin >> str;
	int n=str.size();
	if(str[0]=='0' || str[n-1]=='1' || str[n-2]=='0'){
		printf("-1\n");
		return 0;
	}
	bool flag=false;
	for(int i=0;i<n-1;i++){
		if(str[i]!=str[n-2-i]){
			flag=true;
		}
	}
	if(flag){
		printf("-1\n");
		return 0;
	}
	int cur=1;
	for(int i=0;i<n-1;i++){
		if(str[i]=='0'){
			vec.push_back(P(cur,i+2));
		}else{
			vec.push_back(P(cur,i+2));
			cur=i+2;
		}
	}
	for(int i=0;i<n-1;i++){
		printf("%d %d\n",vec[i].first,vec[i].second);
	}
	return 0;
} 

Measured memory_bytes: 2420
#include<iostream>
#include<utility>
#include<vector>

using namespace std;
#define cerr cerr << "[DBG] "
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { s << v[i]; if (i < v.size() - 1) s << "\t"; } return s; }

typedef long long ll;

int main(){
	int k, t;
	cin >> k >> t;
	vector<int> a(t);
	int max_a = 0;
	int sub = 0;
	for(int i=0; i<t; i++){
		cin >> a[i];
		if(a[i] > max_a) max_a = a[i];
		sub += a[i];
	}
	sub -= max_a;
	int result = max_a - sub - 1;
	if(result < 0) result = 0;
	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int i,j,t;
  double a,b,ans,ans1;
  cin >> a >> b ;
  t = a;
  int A[t];
  for(i=0;i<a;i++){
  	cin >> A[i] ;
  }
  ans1=0;
    for(i=0;i<a;i++){
  	ans1=ans1+A[i] ;
  }
ans = 0;
    for(i=0;i<a;i++){
  	if(A[i] >= ans1/(4*b)){
      ans=ans+1;} 
  }
  
 if(ans >= b){
    cout << "Yes" ;
  }
  else{
    cout << "No" ;
  }
  
 
 
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

typedef pair<ll,int> P;
vector<ll> dijkstra(int s, const vector<vector<pair<int,int> > >& G){
    priority_queue< P, vector<P>, greater<P> > que;
    vector<ll> d(G.size(), LINF);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()){
        int curr  = que.top().second;
        ll  dcurr = que.top().first;
        que.pop();
        if(d[curr] < dcurr) continue;
        int i;
        for(i=0; i<(int)G[curr].size(); i++){ 
            int next = G[curr][i].first;
            ll  dist = G[curr][i].second;
            if(d[next] > d[curr] + dist){
                d[next] = d[curr] + dist;
                que.push(P(d[next], next));
            }
        }
    }
    return d;
}

vector<vector<pair<int, int> > > g;

void solve()
{
    int n;
    scanf("%d", &n);
    g.resize(n);
    int i;
    for (i = 0; i < n - 1; i++) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c); a--; b--;
        g[a].push_back(make_pair(b, c));
        g[b].push_back(make_pair(a, c));
    }
    int Q, K;
    scanf("%d%d", &Q, &K); K--;

    vector<ll> dist = dijkstra(K, g);
    for (i = 0; i < Q; i++) {
        int x, y;
        scanf("%d%d", &x, &y); x--; y--;
        ll ans=dist[x] + dist[y];
        printf("%lld\n", ans);
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d%d", &T, &B);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 9460
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define N_MAX 21

bool g[N_MAX][N_MAX] = {false};

int main(){

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  
  for (int i = 0; i < m; i++){
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u][v] = true;
    g[v][u] = true;
  }

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
  }

  int ans = 0;

  do {

    if ( p[0] != 0 ) continue;

    bool ok = true;

    for (int i = 0; i < n - 1; i++) {

      if (!g[p[i]][p[i+1]]) {
	ok = false;
      }
    }

    if ( ok ) {
      ans++;
    }
    
  } while ( next_permutation(p.begin(), p.end()) );
  
  cout << ans << "\n";
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(br.readLine());
        String[] st = br.readLine().split(" ");
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = Integer.parseInt(st[i]);
        }
        Object[] obj = bubbleSort(data, n);
        data = (int[]) obj[0];
        bw.append("" + data[0]);
        for (int i = 1; i < n; i++) {
            bw.append(" " + data[i]);
        }
        bw.newLine();
        bw.append((int) obj[1] + "\n");

        bw.flush();
    }

    static Object[] bubbleSort(int[] data, int n) {
        Object[] obj = new Object[2];
        int counting = 0;
        while (true) {
            boolean found = false;
            for (int i = 0; i < n - 1; i++) {
                if (data[i] > data[i + 1]) {
                    found = true;
                    swap(data, i, i + 1);
                    counting++;
                }
            }
            if (!found) {
                break;
            }
        }
        obj[0] = data;
        obj[1] = counting;
        return obj;
    }

    static void swap(int[] arr, int a, int b) {
        int tmp = arr[a];
        arr[a] = arr[b];
        arr[b] = tmp;
    }

}


Measured memory_bytes: 24536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,A[100002],i,NA,answer;
    cin >> N;
    A[0] = 0;
    A[N+1] = 0;
    for (i = 1;i <= N;i++) {
        cin >> A[i];
    }

    for (i = 0;i <= N + 1;i++) {
            NA += abs(A[i + 1] - A[i]);
    }
    for (i = 1;i <= N;i++) {
        int answer = NA - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]);
        cout << answer <<endl;
        answer = 0;
    }
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main(void){
char s[100],p[100],ss[200];
scanf("%s %s",s,p);
strcpy(ss,s);
strcat(ss,s);
if(strstr(ss,p)==NULL)printf("No\n");
else printf("Yes\n");
return 0;
}


Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long g = sc.nextLong();
		long c = 0;
		long s;
		int n = 5;
		c = (g / 11) * 2; 
		
		for(s = (g / 11) * 11; s < g;){
		c += 1;		
		switch(n){
		case 6: s = s + 5; n = 5; break;
		case 5: s = s + 6; n = 6; break;
		default:}}		
		System.out.println(c);	
		}
	}



Measured memory_bytes: 9808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;



int main() {

    int h, a;
    cin >> h >> a;
    int cnt = 0;
    for (int i = 0; true; i++)
    {
        h -= a;
        cnt++;
        if(h<=0)
            break;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
n=int(input())

print(0)
sexlow=input()
if(sexlow=='Vacant'):
    sys.exit()

print(n-1)
sexhigh=input()
if(sexhigh=='Vacant'):
    sys.exit()

low=0
high=n-1
piv=0
while(True):
    piv=(low+high)//2

    print(piv)
    sexn=input()
    if(sexn=='Vacant'):
        break
    elif(( (piv-low)%2==0 and sexlow!=sexn) or ( (piv-low)%2!=0 and sexlow==sexn)):
        high=piv
        sexhigh=sexn
    elif(( (high-piv)%2==0 and sexhigh!=sexn) or ( (high-piv)%2!=0 and sexhigh==sexn)):
        low=piv
        sexlow=sexn



Measured memory_bytes: 3660
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++)
    cin>>p[i];
    int a=0;
    for(int i=1;i<n-1;i++)
    {
        if(p[i-1]<p[i] && p[i]<p[i+1]) a++;
        if(p[i-1]>p[i] && p[i]>p[i+1]) a++;
    }
    cout<<a<<"\n";
}

Measured memory_bytes: 3640
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1, n - 1):
	list = []
	list.append(p[i-1])
	list.append(p[i])
	list.append(p[i+1])
	list.sort()
	if list[1] == p[i]:
		count += 1

print(count)

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args){
 
		Scanner scan = new Scanner(System.in);
		int first	= scan.nextInt();
		int second	= scan.nextInt();
		int third	= scan.nextInt();
		
		if ((first == 5 || first == 7) & (second == 5 || second == 7) &(third == 5 || third == 7) &(first + second + third == 17)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 9676