akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

// https://qiita.com/ta-ka/items/a023a11efe17ab097433
struct Edge {
    int to, silver;
    ll time;

    Edge(int to, int silver, ll time) : to(to), silver(silver), time(time) {};
};

const ll MAX = 50 * 50;

struct Exchange {
    ll silver, time;
};

struct Data {
    int to_v, use_silver;
    ll time;

    Data(int to_v, int use_silver, ll time) : to_v(to_v), use_silver(use_silver), time(time) {}

    bool operator<(const Data &a) const {
        return time > a.time;
    }
};

// https://atcoder.jp/contests/abc164/submissions/12451637
int main() {
    int n, m;
    ll s;
    cin >> n >> m >> s;
    cmin(s, MAX);

    vector<vector<Edge>> edges(n);

    rep(i, m) {
        int u, v, silver;
        ll time;
        cin >> u >> v >> silver >> time;

        u--;
        v--;

        edges[u].emplace_back(v, silver, time);
        edges[v].emplace_back(u, silver, time);
    }

    vector<Exchange> exchanges(n);
    rep(i, n) cin >> exchanges[i].silver >> exchanges[i].time;
    vector<vector<ll>> dist(n, vector<ll>(MAX + 1, INF));
    priority_queue<Data> q;

    auto push = [&](int to_v, int to_silver, ll value) {
        if (to_silver < 0) return;
        if (dist[to_v][to_silver] <= value) return;
        dist[to_v][to_silver] = value;
        q.emplace(to_v, to_silver, value);
    };

    push(0, s, 0);

    while (!q.empty()) {
        Data d = q.top();
        q.pop();

        int to_v = d.to_v, use_silver = d.use_silver;
        ll time = d.time;
        if (dist[to_v][use_silver] != time) continue;

        int ns = min(use_silver + exchanges[to_v].silver, MAX);
        push(to_v, ns, time + exchanges[to_v].time);

        for (Edge e : edges[to_v]) {
            push(e.to, use_silver - e.silver, time + e.time);
        }
    }

    for (int i = 1; i < n; i++) {
        cout << *min_element(dist[i].begin(), dist[i].end()) << endl;
    }

}


Measured memory_bytes: 6280
N, K = map(int, input().split())
trees = []
for i in range(N):
  trees.append(int(input()))
  
trees = sorted(trees)
ans = 10000000000000

for i in range(N-K+1):
  cost = trees[i+K-1] - trees[i]
  if cost < ans:
    ans = cost
    
print(ans)

Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,M,p,ac=0,wa=0;
  cin>>N>>M;
  vector<int> C(N,0),W(N,0);
  string S;
  for(int i=0;i<M;i++)
  {
    cin>>p>>S;
    if(S=="WA"){if(C.at(p-1)==0) W.at(p-1)++;}
    else C.at(p-1)=1;
  }
  for(int i=0;i<N;i++)
  {
    ac+=C.at(i);
    if(C.at(i)==1) wa+=W.at(i);
  }
  cout<<ac<<" "<<wa<<endl;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll N;
    ll M;
    cin >> N >> M;
    for (int i = 0; i < M; ++i)
    {
        ll A;
        cin >> A;
        N -= A;
        if (N < 0)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << N << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z)                                                        \
  cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z  \
       << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  vec< vec< int > > T(H, vec< int >(W));
  REP(i, H) {
    REP(j, W) {
      if (i < 2 * B && j < 2 * A) {
        T[i][j] = (i + j) % 2;
      } else if (i >= 2 * B && j >= 2 * A) {
        T[i][j] = 1;
      } else if (j >= 2 * A) {
        T[i][j] = i % 2;
      } else {
        T[i][j] = j % 2;
      }
    }
  }
  REP(i, H) {
    REP(j, W) { cout << T[i][j]; }
    cout << "\n";
  }
}

Measured memory_bytes: 9088
n=int(input())
l=[]
import math
for i in range(n):
    l.append(list(map(int,input().split())))
#print(l)   
soukyori=[] 
for j in range(n-1):
    for k in range(j+1,n):
        kyori=math.sqrt((l[j][0]-l[k][0])**2+(l[j][1]-l[k][1])**2)
        soukyori.append(kyori)
#print(soukyori)
total=sum(soukyori)
#print(total)
ave=total*2/n
print(ave)

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

int main(){
    int n,x,t;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int dp[1000000];
string S;
int main() {
	cin >> S; dp[0] = 1;
	for (int i = 0; i < S.size(); i++) {
		if (dp[i] == 0)continue;
		if (i + 5 <= S.size() && S.substr(i, 5) == "dream")dp[i + 5] = 1;
		if (i + 7 <= S.size() && S.substr(i, 7) == "dreamer")dp[i + 7] = 1;
		if (i + 5 <= S.size() && S.substr(i, 5) == "erase")dp[i + 5] = 1;
		if (i + 6 <= S.size() && S.substr(i, 6) == "eraser")dp[i + 6] = 1;
	}
	if (dp[S.size()] == 1)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

int main() {
  int n,c,d,ans=0;
  cin >> n;
  for(int i=1 ;i<=n ;i++){
    c = 0;
    d = i;
    while(d){
      d /= 10;
      c++;
    }
    if(c%2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*Wiz*/
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

const int MAXN=10;

int n,G,P[MAXN+5],C[MAXN+5];

int main() {
	scanf("%d %d",&n,&G);
	for(int i=1;i<=n;i++)
		scanf("%d %d",&P[i],&C[i]);
	int ans=1e9;
	for(int s=0;s<(1<<n);s++) {
		int sum=0,val=0,x=-1;
		for(int i=1;i<=n;i++)
			if(s&(1<<(i-1))) {
				val+=P[i]*100*i+C[i];
				sum+=P[i];
			}
			else x=i;
		if(val<G) {
			int tmp=100*x;
			int ned=ceil(1.0*(G-val)/tmp);
			if(ned>=P[x])
				continue;
			sum+=ned;
		}
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> as(n), bs(n);
    rep(i, n) cin >> as[i];
    rep(i, n) cin >> bs[i];

    ll asum = accumulate(as.begin(), as.end(), 0ll);
    ll bsum = accumulate(bs.begin(), bs.end(), 0ll);

    ll x = bsum - asum;

    if (x < 0) {
        cout << "No" << endl;
        ret();
    }


    ll ba = 0;
    rep(i, n) if (as[i] < bs[i]) ba += (bs[i] - as[i] + 1) / 2;

    if (ba <= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


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

using namespace std;

struct item {
	int weight;
	int value;
	double value_per_weight;

	istream& operator>>(istream &is) {
		is >> value >> weight;
		value_per_weight = (double) value / weight;
		return is;
	}

	bool operator<(item &i) {
		return value_per_weight > i.value_per_weight;
	}
};

istream& operator>>(istream &is, item &it) {
	return it>>is;
}

int main(void) {
	int N, W;
	item temp_item;
	vector<item> vec;

	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		// 读取每一个物品的重量与价值, 然后计算出他们的单位重量价值
		cin >> temp_item;
		vec.push_back(temp_item);
	}
	// 根据物品的单位重量价值从大到小排序
	sort(vec.begin(), vec.end());

	int remain = W;
	double total_value = 0;
	// 停止装入物品条件1: 所有的物品都已经装进去了
	for (int i = 0; i < vec.size(); i++) {
		if (remain > vec[i].weight) {
			// 如果剩余空间足够装入整个物品, 那么全部装入
			remain -= vec[i].weight;
			total_value += vec[i].value;
		} else {
			// 剩余空间不足以装入所有物品, 能装多少装多少
			total_value += vec[i].value_per_weight * remain;
			remain = 0;
			break;
		}
	}

	cout << fixed << setprecision(8) << total_value << endl;
}


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

int main() {
  string S;
  cin >> S;

  bool can = false;
  if(S[0] != S[1] || S[1] != S[2] || S[0] != S[2]){
    can = true;
  }

  if(can) cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#define N 100
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define NIL -1

int M[N][N];
int color[N], nt[N], d[N], f[N];
int tt;
int n;

// uの隣接点を番号順に取得する
// nt[N]には番号順での探索開始位置を保存する
// 隣接点がなければ-1を返す
int next(int u)
{
	for (int v = nt[u]; v < n; v++)
	{
		nt[u]++;
		if (M[u][v]) return v;
	}
	return NIL;
}

// rを開始地点として深さ優先探索を行う
void dfs_visit(int r)
{
	std::stack<int> S;
	S.push(r);
	color[r] = GRAY;
	d[r] = tt++;

	while (!S.empty())
	{
		int u = S.top();
		int v = next(u);
		if (v != NIL)
		{
			if (color[v] == WHITE)
			{
				S.push(v);
				color[v] = GRAY;
				d[v] = tt++;
			}
		}
		else
		{
			S.pop();
			color[u] = BLACK;
			f[u] = tt++;
		}
	}
}

//初期化処理、探索、結果出力を行う
void dfs()
{
	for (int i = 0; i < n; i++)
	{
		color[i] = WHITE;
		nt[i] = 0;
	}
	tt = 1;

	for (int i = 0; i < n; i++)
	{
		if (color[i] == WHITE) dfs_visit(i);
	}

	for (int i = 0; i < n; i++)
	{
		std::cout << i + 1 << " " << d[i] << " " << f[i] << std::endl;
	}
}

int main()
{
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			M[i][j] = 0;
		}
	}

	int u, k, v;
	for (int i = 0; i < n; i++)
	{
		std::cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++)
		{
			std::cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	dfs();
}


Measured memory_bytes: 3128
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;

int main(){
    Shazam;
    long double a,b,x; cin>>a>>b>>x;
    if(x >= a*a*b/2)
        cout<<fixed<<setprecision(10)<<(atan(2.0*(a*a*b-x)/(a*a*a)))*180.0/(acos(-1))<<endl;
    else
        cout<<fixed<<setprecision(10)<<(atan(b/(2*x/(a*b))))*180.0/(acos(-1))<<endl;
    return 0;
}

Measured memory_bytes: 3832
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  ll M;
  while (cin >> N >> M) {
    vector<ll> cand;
    for (ll g = 1; g * g <= M; g++) {
      if (M % g == 0) {
        cand.push_back(g);
        cand.push_back(M / g);
      }
    }
    ll res = 0;
    for (ll g : cand) {
      if (N <= M / g) {
        res = max(res, g);
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

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

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

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

struct SegTree {
  int n_count;
  vector<ll> pos;

  SegTree(ll N) {
    n_count = 1; while(n_count<N) n_count<<=1;
    pos.resize(2*n_count, 0);
  }

  ll operator[](const ll &k) const { return pos[k+n_count]; }

  void set(ll k, const ll x) { pos[k+n_count] = x; }
  void build() { for (int i=n_count-1; i>=0; i--) pos[i] = pos[i*2] + pos[i*2+1]; }
  void update(ll k, const ll x) { set(k,x); k += n_count; while(k >>= 1) pos[k] = pos[k*2] + pos[k*2+1]; }
  ll query(ll a,ll b) {
    ll L = 0, R = 0;
    for ( a+=n_count, b+=n_count; a<b; a>>=1, b>>=1 ) {
      if (a&1) { L+=pos[a]; a++; }
      if (b&1) { b--; R+=pos[b]; }
    }
    return L + R;
  }

};

struct num { ll i; ll v; ll n; };

int main() {
  ll N, K; cin >> N >> K;
  num a[N+1]; a[0] = {0,0,0};
  rep(i,N) { ll tmp; cin >> tmp; a[i+1] = {i+1,a[i].v+(tmp-K),0}; }
  sort(a,a+(N+1),[](const num &x, const num &y){return x.v<y.v;});
  // rep(i,N+1) a[i].v = i;
  repr(i,1,N+1) a[i].n = a[i-1].n + (a[i].v!=a[i-1].v);
  sort(a,a+(N+1),[](const num &x, const num &y){return x.i<y.i;});
  // rep(i,N+1) cout << a[i].i << ":" << a[i].n << " "; cout << endl;
  SegTree tree(N+1);
  ll result = 0;
  rep(i,N+1) {
    result += tree.query(0,a[i].n+1);
    tree.update(a[i].n,tree[a[i].n]+1);
  }
  cout << result << endl;
  return 0;
}

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

int main(){
	
	int t = 1;
	//cin >> t;
	while(t--){
		int a, b;
		cin >> a >> b;
		cout << a * b;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int k;
  int sum=0;
  cin >> k;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        sum += gcd(gcd(a,b),c);
      }
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <stack>


using namespace std;
typedef long long LL;
const int MaxN = 1e6 + 5;
const int Mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double esp = 1e-6;

int a,b,c,x,y,z;

int main(){
    cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);
    cout << a << ' ' << b << ' '<< c;
    return 0 ;
}


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

int main() {
   int s, w;
   cin >> s >> w;

   if (s <= w) {
       cout << "unsafe" << endl;
   } else {
       cout << "safe" << endl;
   }
}

Measured memory_bytes: 3636
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import qualified Data.Sequence as Seq
import qualified Data.IntSet as IS

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    [a,b] <- r'
    let ini = IS.fromList $ factor (gcd a b) 
    print $ IS.size ini + 1


factor 1 = []
factor n = let divisors = dropWhile ((/= 0) . mod n) [2 .. ceiling $ sqrt $ fromIntegral n]
           in let prime = if null divisors then n else head divisors
              in (prime :) $ factor $ div n prime



Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Integer[] length = new Integer[3];

		for (int i = 0; i < length.length; i++) {
			length[i] = Integer.parseInt(scanner.next());
		}

		System.out.println(length[0] * length[1] / 2);

		scanner.close();
	}

}


Measured memory_bytes: 24020
from collections import deque
h,w = map(int,input().split())

visited = [[-1 for i in range(w)] for j in range(h)]

s = []
cnt = 0
for i in range(h):
    ss = input()
    s.append(ss)
    cnt += ss.count('#')

queue = deque([(0,0)])

visited[0][0] = 1

while queue:
    a = queue.popleft()
    dydx = [[1,0],[-1,0],[0,1],[0,-1]]
    for j,k in dydx:
        newy,newx = a[1]+j,a[0]+k
        if (0 <= newy <h) and (0 <= newx < w):
            if (visited[newy][newx] == -1) and (s[newy][newx] == "."):
                visited[newy][newx] = visited[a[1]][a[0]] + 1
                queue.append((newx,newy))




if(visited[h-1][w-1] == -1): print("-1")
else:
    print(h*w-visited[h-1][w-1]-cnt)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using lol = long long int;
int main(void)
{
	lol tam, num, minimo = 1e9;
	cin >> tam >> num;
	vector <lol> entrada(tam);
	for(lol i = 0 ; i < tam ; i++)
		cin >> entrada[i];
	sort(entrada.begin(), entrada.end());
	for(lol i = 0 ; i < (tam - num + 1) ; i++)
	{
		minimo = min(minimo, entrada[i + (num - 1)] - entrada[i]);
//		cout << entrada[i] << " " << entrada[i + (num - 1)] << "\n";
	}
		cout << minimo << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli t,n,x,d;
	cin>>x>>n>>d;
	x=abs(x);
	t=x/d;
	if(t>=n){
		cout<<x-n*d;
		return 0;
	}
	x=x-t*d;
	n=n-t;
	if(n&1){
		cout<<abs(x-d);
	}
	else
	cout<<abs(x);
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i,b)   for(int i=0;i<(b);i++)
#define f1(i,b)   for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define forr(i,n)    for(i=0; i<n; i++)
#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld",a)

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);
//scanf("%d",&x);
//printf("%d\n",x);

//vector <int> A;
//deque <int> A;
//queue <int> A;
//stack <int> A;
//set <int> A;
//map <int,int> A;
//pair <int,int> A ;
//vector <pair <int,int>> A ;
//char ch;
//string S, T, U;
ll i, j, k, a, b, c, d, f, g, h, l, m, n=10, p, q, r, s, t, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int A[10];

    forr(i,n)
    {
        cin>>A[i];
    }
    sort(A,A+n, greater<>());
    forr(i,3)
    {
        cout<<A[i]<<endl;
    }
    return 0;
}



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

void swap(int *nx, int *ny)
{
    int temp = *nx;
    *nx = *ny;
    *ny = temp;
}
/*--- *n1≦*n2≦*n3となるように並べ替える ---*/
void sort3(int *n1, int *n2, int *n3)
{
    if (*n1 > *n2) swap(n1, n2);
    if (*n2 > *n3) swap(n2, n3);
    if (*n1 > *n2) swap(n1, n2);
}
int main(void)
{
  int a,b,c;
  cin>>a>>b>>c;
  sort3(&a,&b,&c);
  cout<<c*10+b+a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    ll n,d;cin>>n>>d;
    ll ans=0;
    rep(i,n){
        ll x,y;cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(ll i=1;i<=(n);++i)
#define ifr(i,n) for(ll i=(n)-1;i>=0;--i)
#define iFr(i,n) for(ll i=(n);i>0;--i)
//グローバルな場所に配列を置くとすべて0に初期化される。

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
 ll a,b;
 cin>>a>>b;
 cout<<(3*a+b)/2;
}

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

string point;
long long ans;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>point;
    for(int i=1;i<point.length();i++)
      if(point[i-1]!=point[i]) 
        ans++;
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    assert(n>=2);
    ll sum = 0;
    REP(i,n){
      ll x;
      cin>>x;
      sum += x;
    }
    vi edge(n-1);
    REP(i,n-1){
      cin>>edge[i];
    }
    ll cnt = n;
    ll res = sum*cnt;
    sort(ALL(edge));
    reverse(ALL(edge));
    REP(i,n-1){
      --cnt;
      sum += edge[i];
      res = max(res,sum*cnt);
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 1472
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string s;
  cin >> s;

  if('A' <= s[0] && s[0] <= 'Z') cout << "A" << endl;
  else cout << "a" << endl;
  
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,l;cin>>n>>m>>l;
    ll lim = 1e+15;
    vector<vector<pair<ll,ll>>> mat(n, vector<pair<ll,ll>>(n, pair<ll,ll>(1e+15, 0)));
    vector<vector<ll>> d(n,vector<ll>(n,1e+15));
    vector<set<ll>> nbs(n);
    rep(i,n) {
        mat[i][i].first = 0;
        d[i][i] = 0;
    }
    rep(i,m) {
        ll a,b,c;cin>>a>>b>>c;
        a--;b--;
        if(c<=l) {
            d[a][b] = c;
            d[b][a] = c;
            nbs[a].insert(b);
            nbs[b].insert(a);
            // mat[a][b].first = mat[b][a].first = 0;
            // mat[a][b].second = mat[b][a].second = c;
        }
    }
    ll q;cin>>q;
    vector<ll> s(q), t(q);
    rep(i,q) {
        cin>>s[i]>>t[i];
        s[i]--;t[i]--;
    }
    
    rep(i,n) {
        vector<bool> flg(n,false);
        priority_queue<tuple<ll,ll,ll>, vector<tuple<ll,ll,ll>>, greater<tuple<ll,ll,ll>>> pq;
        pq.emplace(0, 0, i); 
        while(!pq.empty()) {
            auto tmp = pq.top();
            pq.pop();
            ll now = get<2>(tmp), cnt= get<0>(tmp), dist = get<1>(tmp);
            DEBUG{
                printf("now: %lld, cnt: %lld, dist: %lld\n", now,cnt,dist);
            }
            if (flg[now]) continue;
            for(auto x:nbs[now]) {
                if (flg[x]) continue;
                ll _cnt, _dist;
                if(dist + d[now][x] <= l) {
                    _cnt = cnt;
                    _dist = dist + d[now][x];
                }else if(d[now][x] <= l) {
                    _cnt = cnt+1;
                    _dist = d[now][x];
                }
                if(_cnt < mat[i][x].first || _cnt == mat[i][x].first && _dist < mat[i][x].second) {
                    mat[i][x].first = _cnt;
                    mat[i][x].second = _dist;
                    pq.emplace(_cnt, _dist, x);
                }
            }
            flg[now] = true; 
        }
        DEBUG{
            cout << endl;
        }
    }
    rep(i,q) {
        cout << (mat[s[i]][t[i]].first == ll(1e+15) ? -1 : mat[s[i]][t[i]].first)  << endl;
    }
    return 0;
}


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

int main() {
    string s;
    cin >> s;

    int res = 7;
    if (s == "SAT") res = 1;
    if (s == "FRI") res = 2;
    if (s == "THU") res = 3;
    if (s == "WED") res = 4;
    if (s == "TUE") res = 5;
    if (s == "MON") res = 6;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3600
s = input()
n = len(s)
result = "Yes"
for i in range(n//2):
    if s[i] != s[-i-1]:
        result = "No"

first = s[:n//2]
for i in range((n//2)//2):
    if first[i]!= first[-i-1]:
        result = "No"

last = s[n//2+1:]
for i  in range((n//2)//2):
    if last[i] != last[-i-1]:
        result = "No"

print(result)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 3e4 + 20;

ll fact[MAXN];

void prec(){

}

void solve() {

    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    ll times = h2 * 60 + m2 - h1 * 60 - m1;
    if (h1 * 60 + m1 > h2 * 60 + m2)
        times += 24 * 60;

    times -= k;


    cout << max(times, 0ll);
}

#else

void solve() {

}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case " << (i++) << ": ";
        solve();
        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

using namespace std;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  FOR(i, K-1, N-1) {
    if (A[i-K+1] >= A[i+1]) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}

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

int n, k, q;
int c[100000];
int main() {
  cin >> n >> k >> q;
  for (int i = 0; i < q; ++i) {
    int a;
    cin >> a;
    --a;
    ++c[a];
  }
  
  for (int i = 0; i < n; ++i) {
    cout << (c[i] > q - k ? "Yes" : "No") << endl;
  }
}



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

using namespace std;

typedef pair<int,int> pi;

int N, K, Q, A[2005], active[2005];

int par[2005];
vector<int> seg[2005];
vector<pi> v;
set<int> pars;

int find_par(int x){
	if (par[x] != x) par[x] = find_par(par[x]);
	return par[x];
}

void merg(int x, int y){
	int X = find_par(x), Y = find_par(y);
	if (X == Y) return;
	if (seg[X].size() < seg[Y].size()) swap(X,Y);
	par[Y] = X;
	vector<int> temp;
	merge(seg[X].begin(),seg[X].end(),seg[Y].begin(),seg[Y].end(),back_inserter(temp));
	seg[X] = temp;
	pars.erase(Y);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K >> Q;
	for (int i = 1; i <= N; ++i){
		cin >> A[i];
		v.push_back(pi(A[i],i));
		par[i] = i;
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	int mini = 1e9+1;
	for (auto it : v){
		//cerr << it.first << ' ' << it.second << '\n';
		active[it.second] = 1;
		pars.insert(it.second);
		seg[it.second].push_back(it.first);
		if (active[it.second-1]) merg(it.second,it.second-1);
		if (active[it.second+1]) merg(it.second,it.second+1);
		vector<int> usable;
		//cerr << "YEET0\n";
		for (auto it2 : pars){
			//cerr << it2 << '\n';
			for (int i = 0; i < (int) (seg[it2].size())-K+1; ++i){
				usable.push_back(seg[it2][i]);
			}
		}
		//cerr << "YEET1\n";
		sort(usable.begin(),usable.end());
		if (usable.size() < Q) continue;
		else mini = min(mini,usable[Q-1]-usable[0]);
	}	
	cout << mini << '\n';
}

Measured memory_bytes: 512
import sys
from math import gcd

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    if N == 2:
        ans = max(A)
        print(ans)
        exit()

    L_GCD = [0] * N
    L_GCD[0] = A[0]
    for i in range(N - 1):
        L_GCD[i + 1] = gcd(L_GCD[i], A[i + 1])

    R_GCD = [0] * N
    R_GCD[-1] = A[-1]
    for i in reversed(range(N - 1)):
        R_GCD[i] = gcd(R_GCD[i + 1], A[i])

    ans = 1
    for i in range(N):
        if i == 0:
            ans = max(ans, R_GCD[1])
        elif i == N - 1:
            ans = max(ans, L_GCD[-2])
        else:
            res = gcd(L_GCD[i - 1], R_GCD[i + 1])
            ans = max(ans, res)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21072
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

constexpr int mpow(const int &a, int n) noexcept {
   if(n == 0) return 1;
   auto t = mpow(a, n / 2);
   t = t * t;
   if(n & 1) t = t * a;
   return t;
}
  
signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);
  
  int n;
  cin >> n;
  vector<int> b(n - 1);
  REP(i,n - 1) cin >> b[i];
  
  vec a(n);
  a[0] = b[0];
  a[n - 1] = b[n - 2];

  FOR(i, 1, n - 1){
    a[i] = min(b[i - 1], b[i]);
  }

  int ans = 0;
  for(int v : a){
    ans += v;
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
int dp[100001];
bool visited[100001];
void dfs(int s)
{
    visited[s]=true;
    for(auto i:adj[s])
    {
        if(!visited[i])
        dfs(i);
        
        dp[s] = max(dp[s],1+dp[i]);
    }
    
}
int main()
{
    int n,m,i,a,b;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
    }
    for(i=1;i<=n;i++)
    {
        if(!visited[i])
        dfs(i);
    }
    int mini = 0;
    for(i=1;i<=n;i++)
    if(dp[i]>mini)
    mini = dp[i];
    
    cout<<mini<<endl;
        
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define LINF (ll)1e18
#define INF (int)1e9
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
    int n;
    in(n);
    int a[n];
    rep(i,0,n)in(a[i]);
    out(accumulate(a, a+n,0)-n);
}



















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

int main(){
    int h, w;
    
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i % 2 == 1 && j % 2 == 1) cout << '#';
                if(i % 2 == 1 && j % 2 == 0) cout << '.';
                if(i % 2 == 0 && j % 2 == 0) cout << '#';
                if(i % 2 == 0 && j % 2 == 1) cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Aoj.ALDS.Chapter4C
{
    class Program
    {
        public static void Solve()
        {
            var dic = new Dictionary<string, int>();

            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] inputs = Console.ReadLine().Split(' ');
                switch (inputs[0])
                {
                    case "insert":
                        if (! dic.ContainsKey(inputs[1]))
                            dic[inputs[1]] = 1;
                        break;
                    case "find":
                        Console.WriteLine(dic.ContainsKey(inputs[1]) ? "yes" : "no");
                        break;
                    default:
                        throw new System.IO.IOException("");
                }
            }
        }

        public static void Main()
        {
            // Console.SetIn(new System.IO.StreamReader("Aoj/AlgorithmsAndDataStructures/Input/04_Search_C_01.txt"));
            // var sw = new Stopwatch();
            // sw.Start();

            Solve();

            // Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
        }
    }
}

Measured memory_bytes: 41292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
#define INF (ll)(1ll<<60)
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
	long double a,b;cin>>a>>b;
	cout<<(ll)(a*b)<<endl;
	return 0;
}

Measured memory_bytes: 3780
N, W = map(int, input().split())

w = [[] for _ in range(4)]
w1, v1 = map(int, input().split())
w[0].append(v1)
for _ in range(N - 1):
    a, b = map(int, input().split())
    w[a - w1].append(b)

for i in range(4):
    w[i].sort(reverse = True)
    for j in range(1, len(w[i])):
        w[i][j] += w[i][j - 1]

# print (w)
ans = 0
for a in range(len(w[0]) + 1):
    if a == 0:
        v_a = 0
    else:
        v_a = w[0][a - 1]
    for b in range(len(w[1]) + 1):
        if b == 0:
            v_b = 0
        else:
            v_b = w[1][b - 1]
        for c in range(len(w[2]) + 1):
            if c == 0:
                v_c = 0
            else:
                v_c = w[2][c - 1]
            cost = a * w1 + b * (w1 + 1) + c * (w1 + 2)
            if cost > W:
                pass
            else:
                lest = W - cost
                d = min(lest // (w1 + 3), len(w[3]))
                # print (d)
                if d == 0:
                    v_d = 0
                else:
                    v_d = w[3][d - 1]

                ans = max(ans, v_a + v_b + v_c + v_d)

print (ans)            


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int N;

ll bit[2][1000000];

void init(){
  rep(i, 2) rep(j, 1000000) bit[i][j] = 0;
}

void add(int l, int r, int val){
  for(int i = l; i <= N; i+= (i & -i)) bit[0][i] += -val * (l-1);
  for(int i = l; i <= N; i+= (i & -i)) bit[1][i] += val;
  for(int i = r+1; i <= N; i += (i & -i)) bit[0][i] += val*r;
  for(int i = r+1; i <= N; i += (i & -i)) bit[1][i] += -val;
}

ll sum(int i){
  vector<ll> ret(2);
  for(int idx = i; idx > 0; idx -= (idx & -idx)) ret[0] += bit[0][idx];
  for(int idx = i; idx > 0; idx -= (idx & -idx)) ret[1] += bit[1][idx];
  ret[1] *= i;
  return ret[0] + ret[1];
}

int mod = 1000000007;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  int Q; cin >> N >> Q;
  vector<int> A(N+1); rep(i, N) cin >> A[i+1];
  vector<int> prev(N+1, 0);
  vector<pair<pair<int, int>, int>> query(Q);
  vector<ll> ans(Q);
  
  rep(i, Q){
    int l, r; cin >> l >> r;
    query[i] = make_pair(pair<int, int>(r, l), i);
  }
  sort(query.begin(), query.end());

  int idx = 1;
  rep(q, Q){
    int right = query[q].first.first, left = query[q].first.second;
    while(idx <= right){
      add(prev[A[idx]]+1, idx, 1);
      prev[A[idx]] = idx;
      idx++;
    }
    ans[query[q].second] = sum(left) - sum(left-1);
  }
  rep(i, Q) printf("%d\n", ans[i]);
  
  /*
  add(1, 3, 1);
  rep(i, N) cout << sum(i+1) << " "; cout << endl;
  add(1, 1, 1);
  rep(i, N) cout << sum(i+1) << " "; cout << endl;
  add(3, 5, 1);
  rep(i, N) cout << sum(i+1) << " "; cout << endl;
  */
  return 0;
}

Measured memory_bytes: 33052
# 方針はX回で出来るかどうかの二分探索
N, A, B = map(int, input().split())
demon_health = [0 for i in range(N)]
for i in range(N):
    demon_health[i] = int(input())

high = int(1e10)
low = 0
mid = 0
ad_attack = B - A

while low < high:
    big_magic = 0
    mid = (high + low) // 2
    # mid*Bを使ってB-Aが何回必要かみたいな
    for i in range(N):
        big_magic += max((demon_health[i] - B * mid + (A - B - 1)) // (A - B), 0)
        # print(big_magic)
    if big_magic > mid:
        # cannot
        low = mid + 1
    else:
        high = mid
    # print("high, low -> " + str(high) + " " + str(low))

print(low)


Measured memory_bytes: 45984
def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    for i in range(n):
        if a[i]%2==0:
            if (a[i] %3 != 0) and (a[i] % 5 != 0):
                print('DENIED')
                return
    
    print('APPROVED')

if __name__ == '__main__':
    main()

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = accumulate(p.begin(), p.begin() + k, 0);
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>

using namespace std;

int main()
{
	string S;
	cin >> S;
	if(S.length() <= 1 || S.length() % 2 == 1 || S.length() > 10 || S[0] != 'h' || S[1] != 'i')
	{
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < S.length(); i++)
	{
		if ((i % 2 == 0 && S[i] == 'h') || (i % 2 == 1 && S[i] == 'i'))
		{
			continue;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;

}

Measured memory_bytes: 256
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

p = p[:X]
q = q[:Y]

SB = p + q + r
SB.sort(reverse=True)
ans = 0
for i in range(X+Y):
    ans += SB[i]
print(ans)

Measured memory_bytes: 23328
#include <stdio.h>
#include <math.h>

#define TRUE 1
#define FALSE 0

int isPrime(int, double);
int main() {
    int num = 0,
        prm = 0,
        ret = 0,
        inp = 0,
        i = 0;

    scanf( "%d", &num );
    for ( i=0; i < num; i++ ) {
        scanf("%d", &inp );
        ret = isPrime( inp, sqrt( inp ) );
        if ( ret == TRUE ) prm++;
    }
    printf("%d\n", prm);
    return 0;
}

int isPrime(int x, double xx) {
    int i = 3;

    if ( x == 2 )
        return TRUE;

    else if ( x < 2 || x%2 == 0 )
        return FALSE;

    while ( i <= xx ) {
        if ( x % i == 0 ) return FALSE;
        i = i + 2;
    }

    return TRUE;
}



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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 200005
char c[N];
string s;
int main() {
	ios::sync_with_stdio(0);
	cin>>s;
	int n = s.size();
	int i=0, j=n-1, cnt=0;
	while(i<j) {
		if(s[i]==s[j]) {i++, j--;}
		else if(s[i]=='x') {
			cnt++, i++;
		}
		else if(s[j]=='x') {
			cnt++, j--;
		}
		else {cout<<-1<<endl; return 0;}
	}
	/*int j=0;
	int cnt=0;
	F(s.size()) {
		if(s[i]=='x') cnt++;
		else c[j++] = s[i];
	}
	c[j++] = 0;
	int len = strlen(c);
	F(len/2) {
		//cout<<c[i]<<' '<<c[len-1-i]<<endl;
		if(c[i] != c[len-1-i]) {cout<<-1<<endl; return 0;}
	}
	*/
	cout<<cnt<<endl;
	return 0;
}

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

int main() {
    double N,K,t,s=0,m=0;
    cin >> N >> K;
    vector<double> p(N);

    rep(i,N) {
        cin >> t;
        p.at(i) = t*(t+1)/(2*t);
    }

    rep(i,K)
        s += p.at(i);
    m = s;
    rep(i,N-K) {
        s -= p.at(i);
        s += p.at(i+K);
        m = max(s,m);
    }
    cout << setprecision(10) << m << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	
	int result = 0;
	int size = s.size();
	for (int i = 0; i < size; ++i) {
		if (s[i] == '+')
			++result;
		else
			--result;
	}
	
	cout << result << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main (void) {
    char in[100];
    int count = 0;
    scanf("%s", in);
    int len = strlen(in);

    for (int i = 0; i < len / 2; i++) {
        if (in[i] != in[len - i - 1]) {
            count++;
        }
    }

    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128