akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <complex>

using namespace std;
typedef complex<double> xy_t;  
const double eps = 1e-11;
double cross_product(xy_t a, xy_t b) {
    return (conj(a) * b).imag();
}

int main() {
    int n; // データセット数
    cin >> n;
    double x[4], y[4];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 4; j++) {
            cin >> x[j] >> y[j];
        }
        xy_t a[2] = {
            xy_t(x[0], y[0]) - xy_t(x[1], y[1]),
            xy_t(x[2], y[2]) - xy_t(x[3], y[3])
        };
        bool p = abs(cross_product(a[0], a[1])) * 0.5 < eps;
        cout << (p ? "YES" : "NO") << endl;
    }
}


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

int main() {
    int x[2];cin>>x[0]>>x[1];
    for(int i=0;i<2;++i){
        if(x[i]==2)x[i]=2;
        else if(x[i]==4||x[i]==6||x[i]==9||x[i]==11)x[i]=1;
        else x[i]=0;
    }
    if(x[0]==x[1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

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


int n;
long long dp[100];


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    dp[0] = 2;
    dp[1] = 1;
    cin >> n;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i - 2] + dp[i - 1];
    }
    cout << dp[n];
}


Measured memory_bytes: 256
import sys
from bisect import bisect_left, bisect_right


def inputs(func=lambda x: x, sep=None, maxsplit=-1):
	return map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))

def input_2d_T(nrows : int, ncols : int, type=int, **kwargs):
	data = [[None] * nrows for _ in range(ncols)]
	for i in range(nrows):
		for j, v in enumerate(inputs(type)):
			data[j][i] = v
	return data

from collections import deque

N, M = inputs(int)
A, B, C = input_2d_T(N, 3)
D, E, F = input_2d_T(M, 3)
xs = sorted(set(C))
ys = sorted(set(D))

x_guard = [[False for _ in range(len(ys)+1)] for _ in range(len(xs)+1)]
y_guard = [[False for _ in range(len(ys)+1)] for _ in range(len(xs)+1)]

for a, b, c in zip(A, B, C):
	c = bisect_right(xs, c)
	a = bisect_left(ys, a) + 1
	b = bisect_right(ys, b)
	for i in range(a, b):
		x_guard[c][i] = True

for d, e, f in zip(D, E, F):
	d = bisect_right(ys, d)
	e = bisect_left(xs, e) + 1
	f = bisect_right(xs, f)
	for i in range(e, f):
		y_guard[i][d] = True

cow = (
	bisect_right(xs, 0),
	bisect_right(ys, 0)
)
nexts = deque([cow])
visited = [[0 for _ in range(len(ys)+1)] for _ in range(len(xs)+1)]
visited[cow[0]][cow[1]] = True

area = 0

while nexts:
	xi, yi = nexts.popleft()
	
	if 0 < xi < len(xs) and 0 < yi < len(ys):
		area += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])
		if not visited[xi-1][yi] and not x_guard[xi][yi]:
			visited[xi-1][yi] = True
			nexts.append((xi-1, yi))
		if not visited[xi+1][yi] and not x_guard[xi+1][yi]:
			visited[xi+1][yi] = True
			nexts.append((xi+1, yi))
		if not visited[xi][yi-1] and not y_guard[xi][yi]:
			visited[xi][yi-1] = True
			nexts.append((xi, yi-1))
		if not visited[xi][yi+1] and not y_guard[xi][yi+1]:
			visited[xi][yi+1] = True
			nexts.append((xi, yi+1))
	else:
		area = 'INF'
		break

print(area)



Measured memory_bytes: 127156
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 100005;
const int MOD = 1000000007;

ll arr[MAXN] , dp[MAXN][2] , f[MAXN][2] , g[2];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,a,b; cin >> n >> g[0] >> g[1];
	for(int i=1;i<=n;i++) cin >> arr[i];
	f[1][0] = f[1][1] = 1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<2;j++){
			f[i][j] = f[i-1][j];
			if(arr[i] - arr[i-1] >= g[j]) f[i][j]++;
		}
	}
	dp[1][0] = dp[1][1] = 1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<2;j++){
			auto it = lower_bound(arr+1,arr+1+n,arr[i] - g[j] + 1);
			int k = it - arr;
			if(k == i) dp[i][j] = dp[i-1][0] + dp[i-1][1];
			else if(f[i-1][j^1] - f[k][j^1] == i-1-k) dp[i][j] = dp[k][j^1];
			dp[i][j] %= MOD;
			//cout << i << ' ' << j << ' ' << dp[i][j] << endl;
		}
	}
	ll ans = dp[n][0] + dp[n][1]; ans %= MOD;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll b1,b2,b3;
	cin>>b1>>b2>>b3;
	bool ans=true;
	for(int i=0;i<2;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		ll now=x-b1;
		if(now!=y-b2||now!=z-b3){
			ans=false;
		}
	}
	cout << (ans?"Yes":"No");
	return 0;
}

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

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

	int temp = -1*a + b;
	if (temp <= 0) cout << "delicious";
	else if (temp <= x) cout << "safe";
	else cout << "dangerous";


	return 0;
}

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

using namespace std;

int cnt[2005];

int main() {
	int n, x, y;
	scanf("%d%d%d", &n, &x, &y);
	
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int dist = j - i;
			
			dist = min(dist, abs(x - i) + 1 + abs(y - j));
			cnt[dist]++;
		}
	}
	
	for (int i = 1; i <= n - 1; i++) printf("%d\n", cnt[i]);
}


Measured memory_bytes: 3768
#include "iostream"
using namespace std;

int main() {
  int n, y;
  cin >> n >> y;
  y /= 1000;
  bool check = false;
  if (n == y) cout << 0 << " " << 0 << " " << n << endl;
  else {
    for (int i = y % 5; i < y; i += 5) {
      if (5 * (n - i) <= y - i && y - i <= 10 * (n - i)) {
        cout <<  ((y - i) - 5 * (n - i)) / 5  << " " << (10 * (n - i) - (y - i)) / 5 << " " << i << endl;
        check = true;
        break;
      }
    }
    if (check == 0) {
      cout << -1 << " " << -1 << " " << -1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int mi = INF;
    int ans = 0;
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        cin >> c[i];
        for (int j = 0; j < w; j++) {
            if (c[i][j] == 'B') {
                chmax(ans, i + j - mi);
                chmin(mi, i + j);
            }
        }
    }
    mi = INF;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (c[i][j] == 'B') {
                chmax(ans, i - j - mi);
                chmin(mi, i - j);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3256
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

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

    int n, m;
    cin >> n >> m;
    vector adjs(n, vector<int>());
    rep(i, m)
    {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        adjs[s].push_back(t);
    }

    // iからはじめてjを経由する
    vector dp(n, vector(n, 0.l));
    vector dps(n, 0.l);
    rep(s, n)
    {
        dp[s][s] = 1.l;
        auto d = adjs[s].size();
        rep(i, s + 1)
        {
            for (auto t : adjs[s])
            {
                dp[i][t] += dp[i][s] / d;
            }
        }
    }
    rep(s, n)
    {
        dps[s] = accumulate(dp[s].begin(), dp[s].end() - 1, 0.l);
    }

    debug(dp);
    debug(dps);

    auto ans = dps[0];
    rep(s, n)
    {
        auto d = adjs[s].size();
        if (d <= 1)
        {
            continue;
        }
        debug(s);
        auto sum = accumulate(adjs[s].begin(), adjs[s].end(), 0.l, [&](auto acc, int t) {
            return acc + dp[0][s] * dps[t] * (1.l / (d - 1.l) - 1.l / d);
        });
        ans = accumulate(adjs[s].begin(), adjs[s].end(), ans, [&](auto acc, int t) {
            debug(dps[0] + sum - dps[t] / (d - 1.l));
            return min(acc, dps[0] + sum - dp[0][s] * dps[t] / (d - 1.l));
        });
    }

    cout << ans << '\n';

    return 0;
}


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

ld pi = 3.141592653589793238462643383;
ld eps = 1e-7;

ld solve(ld ax, ld ay, ld bx, ld by, ld cx, ld cy) {
    ld A = hypot(bx-cx, by-cy), B = hypot(ax-cx, ay-cy), C = hypot(ax-bx, ay-by);
    ld angb = acos(((ax-bx)*(cx-bx)+(ay-by)*(cy-by))/(A*C));
    ld angc = acos(((ax-cx)*(bx-cx)+(ay-cy)*(by-cy))/(A*B));
    if (angb >= pi/2 || angc >= pi/2) return 0;
    ld l = 0, r = A;
    angb /= 2;
    angc /= 2;
    for (int z = 0; z < 100; z++) {
        ld c = (l+r)/2;
        if (2*c+c/tan(angb)+c/tan(angc) > A) r = c;
        else l = c;
    }
    return l;
}

int main() {
    ld x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    ld ans = 0;
    ans = max(ans, solve(x1, y1, x2, y2, x3, y3));
    ans = max(ans, solve(x2, y2, x3, y3, x1, y1));
    ans = max(ans, solve(x3, y3, x1, y1, x2, y2));
    cout << setprecision(20) << ans << endl;
    return 0;
}

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

template <class T, class F = multiplies<T>>
T power(T a, long long n, F op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long a = 0) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= M) v -= M; return *this; }
  m& operator-=(m r) { if (v < r.v) v += M; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % M; return *this; }
  m& operator/=(m r) { return *this *= power(r, M - 2); }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend m operator/(m l, m r) { return l /= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int d;
  cin >> d;
  vector<int> l(d);
  for (auto&& e : l) {
    cin >> e;
  }
  int s;
  cin >> s;
  vector<vector<mint>> dp(2, vector<mint>(s));
  if (s) {
    dp[0][0] = 1;
  }
  for (auto e : l) {
    auto ndp = dp;
    for (int p : {0, 1}) {
      for (int x = 0; x + e < s; ++x) {
        ndp[p ^ 1][x + e] += dp[p][x];
      }
    }
    swap(dp, ndp);
  }
  mint res;
  for (int p : {0, 1}) {
    for (int x = 0; x < s; ++x) {
      res += power(-1, p) * dp[p][x] * power(mint(s - x), d);
    }
  }
  cout << res.v << '\n';
}



Measured memory_bytes: 4160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String S = sc.next();
		String[] a = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
				"t", "u", "v", "w", "x", "y", "z" };
		int[] b = new int[26];
		String ans = "yes";

		for (int j = 0; j < S.length(); j++) {
			for (int i = 0; i < 26; i++) {
				if (S.substring(j, j + 1).equals(a[i])) {
					b[i]++;
					if (b[i] > 1) {
						ans = "no";
						break;
					}
				}
			}
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = s; i <= (int)(e); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int ans = 0;
  FOR(i, 1, N)
  {
    if (i <= K)
      ans += X;
    else
      ans += Y;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)
#define RALL(x) (x).rbegin(), (x).rend()


template<typename T>
class compress_fn_t {
public:
  void add(T x) {
    if (! map_.count(x))
      map_[x] = 0;
  };

public:
  void clear() {
    map_.clear();
  };

public:
  std::pair<std::map<T, int>, std::vector<T>> get() {
    int size = map_.size(), i = 0;

    std::pair<std::map<T, int>, std::vector<T>> pair;

    pair.second.resize(size);

    for (auto& kv : map_) {
      kv.second = i;

      pair.second[i] = kv.first;

      i ++;
    }

    pair.first = map_;

    return std::move(pair);
  };

private:
  std::map<T, int> map_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  long long N, A, B;

  std::cin >> N >> A >> B;

  if (N < A + B - 1 || N > A * B) {
    std::cout << -1 << std::endl;

    return 0;
  }

  std::vector<std::pair<int, long long>> a;

  bool used[333333] = {0};

  int i;

  long long j;
  
  for (i = 0, j = A * B - A + 1; j >= 1; i ++, j -= A) {
    if (i == 0) {
      for (int k = 0; k < A; k ++) {
        a.emplace_back(i, j + k);

        if (j + k <= N)
          used[j + k] = true;
      }
    }
    else {
      a.emplace_back(i, j);

      if (j <= N)
        used[j] = true;
    }
  }

  for (int i = 1; a.size() < N; i ++)
    if (! used[i])
      a.emplace_back(B - (i - 1) / A - 1, i);

  std::sort(ALL(a));

  compress_fn_t<long long> fn;

  for (const auto& pair : a)
    fn.add(pair.second);

  auto map = fn.get().first;

  for (const auto& pair : a)
    std::cout << map[pair.second] + 1 << ' ';
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 48488
#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 x;
    cin >> x;
    int l,s;
    l = x / 500;
    s = (x - l*500)/5;
    cout << l*1000 + s*5 << endl;
    return 0;
}


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

int main() {
	int N; string S; cin >> N >> S;
	int m=0, now=0;
	for(int i=0; i<N; ++i){
	    if(S[i]=='I') ++now;
	    else --now;
	    m=max(m, now);
	}
	cout << m << endl;
	return 0;
}


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

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

    int count=0;
    for(int i=0;i<S.size();i++){
      if(S.at(i)!=T.at(i)){
        count++;
      }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int H,W,N; cin >> H >> W >> N;
	cout << (N-1)/max(H,W)+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
static unsigned int inf = 1e9+7;
static int bn = 1e5;
int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;
    rep(i, n-1){
        if(s[i]==s[i+1])score++;
    }
    int ans = min(score+2*k, n-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std ;
int main()
{
    int n,a[100],b[100],c[100],sum=0;
    cin >> n ;
    for(int i=1;i<=n;i++){cin >>a[i];}
    for(int i=1;i<=n;i++){cin >>b[i];}
    for(int i=1;i<=n-1;i++){cin >>c[i];}
    sum+=b[a[1]];
     for(int i=2;i<=n;i++)
    {
        sum+=b[a[i]];
        if(a[i]-a[i-1]==1){sum+=c[a[i-1]];}
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const ldb PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;
const int INF = 1e9+7;
bool ok(string &s ,int l ,int r)
{
while(s[l]==s[r]) l++,r--;
return l>=r; 
}/*
ll por(ll a,int b)
{
ll res=1,M=998244353;
while(b)
{
if(b&1)
res=(res*a)%M;
a=(a*a)%M;
b/=2;
}
return res;
}
void rev(vector<int>&arr,int l,int r)
{
    for(;l<r;l++,r--) swap(arr[l],arr[r]);
}
*/
int prime[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89,97,101,103};
int add(int a,int b)
{
long x=a+b;
if(x>=INF)
x-=INF;
return x;
}
void pl() // To analyse
{
string s; cin>>s;
int l=s.length();
bool arr[l][l];
mem(arr,0);
int st=0,mx=1;
rep(i,0,l)
arr[i][i]=1;
rep(i,0,l-1)
{
if(s[i]==s[i+1])
{
arr[i][i+1]=1;
st=i; mx=2;
}
}
rep(k,3,l+1)
{
rep(i,0,l-k+1)
{
int j=i+k-1;
if(arr[i+1][j-1]&&s[i]==s[j]) // i+1 & j-1 suggest minimum length of 3
{
arr[i][j]=1;
if(k>mx)
{
mx=k; st=i;
}
}
}
}
cout<<mx<<"\n";
string str;
str=s.substr(st,mx);
cout<<str;
}
void pl2()
{
string s; cin>>s;
int mx=1,st=0,l=s.length(),lw,hg;
rep(i,1,l)
{
lw=i-1; hg=i;
while(lw>=0 && hg<l && s[lw]==s[hg])
{
if(hg-lw+1>mx)
{
st=lw; mx=hg-lw+1;
}
--lw; ++hg;
}
lw=i-1; hg=i+1;
while(lw>=0 && hg<l && s[lw]==s[hg])
{
if(hg-lw+1>mx)
{
st=lw; mx=hg-lw+1;
}
--lw; ++hg;
}
}
string str;
str=s.substr(st,mx);
cout<<mx<<"\n";
cout<<str;
}
void frog()
{
int n,k,mn; cin>>n>>k;
int h[n];
rep(i,0,n) cin>>h[i];
int ans[n];
ans[n-1]=0;
for(int i=n-2;i>=0;i--)
{
mn=INT_MAX;
rep(j,i+1,min(i+k+1,n))
{
mn=min(mn,abs(h[j]-h[i])+ans[j]);
ans[i]=mn;
}
}
cout<<ans[0];
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
 //pl(); cout<<"\n"; 
// pl2();
frog();
}
return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int K, X;
	vector<int> ans;
	
	cin>>K>>X;
	
	for(int i = -1000000; i <= 1000000; i++){
		// if(abs(i-X) <= K) cout<<i<<endl;
		if(abs(i-X) < K)  ans.push_back(i);
	}
	
	for(int i = 0; i < ans.size(); i++){
		if(i) cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

struct ufind {
  struct node {
    int par, rank, size;
    void init(int i) {
      par = i;
      rank = 0;
      size = 1;
    }
  };
  vector<node> nodes;
  ufind(int n) {
    nodes.resize(n);
    rep(i, n) nodes[i].init(i);
  }
  int find(int x) {
    return nodes[x].par == x ? x : (nodes[x].par = find(nodes[x].par));
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return;
    if (nodes[x].rank < nodes[y].rank) {
      nodes[x].par = y;
      nodes[y].size += nodes[x].size;
    } else {
      nodes[y].par = x;
      if (nodes[x].rank == nodes[y].rank)
        nodes[x].rank++;
      nodes[x].size += nodes[y].size;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return nodes[find(x)].size; }
};
void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B) {
  ufind uf(N);
  rep(i, M) {
    A[i]--, B[i]--;
    uf.unite(A[i], B[i]);
  }
  int ret = 1;
  rep(i, N) chmax(ret, uf.size(i));
  cout << ret << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


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

using namespace std;

template<typename T> class SegmentTree {
private:
  const T DEFAULT;
  int n;
  vector<T> d;
  
  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return DEFAULT;
    if (a <= l && r <= b) return d[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return function(vl, vr);
  }

protected:
  virtual T function(T l, T r) = 0;
  
public:
  SegmentTree(int m, T def = numeric_limits<T>::max()) : DEFAULT(def) {
    n = 1 << (32 - __builtin_clz(m - 1));
    d.resize(2 * n - 1, DEFAULT);
  }

  void update(int k, T a) {
    k += n - 1;
    d[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      d[k] = function(d[k * 2 + 1], d[k * 2 + 2]);
    }
  }

  // [a,b)
  T query(int a, int b) {
    return query(a, b, 0, 0, n);
  }

  T getValue(int k) {
    return d[k + n - 1];
  }
};

template<typename T> class RSQ : public SegmentTree<T> {
protected:
  T function(T l, T r) {
    return l + r;
  }
  
public:
  RSQ(int n) : SegmentTree<T>(n, 0) {}
};

int main() {
  int n, q;
  cin >> n >> q;
  RSQ<int> rsq(n + 1);
  for (int i = 0; i < q; ++i) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) rsq.update(x, rsq.getValue(x) + y);
    else cout << rsq.query(x, y + 1) << endl;
  }
}

Measured memory_bytes: 2052
'use strict';
process.stdin.on('data', function(chunk) {
 
  var inputs = chunk.toString().trim();
  var data = inputs.split(' ').map(Number);
  var a = data[0];
  var b = data[1];
  var c = data[2];
  var count = 0;
   
  for (var i = a; i < b + 1; i++) {
    if (c % i === 0) {
      count++;
    }
  }
  console.log(count);
 
 
});
process.stdin.resume();
process.stdin.setEncoding('utf8')

Measured memory_bytes: 15588
#include <stdio.h>

int main(void)
{
    int n=0,b=0,flag=0;
    int A[3][3]={};
    for(int i=0;i<3;i++){
        scanf("%d %d %d",&A[i][0],&A[i][1],&A[i][2]);
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&b);
        for(int j=0;j<9;j++){
            if(A[j/3][j%3]==b){
                A[j/3][j%3]=0;
                break;
            }
        }
    }

    for(int i=0;i<3;i++){
        if(A[i][0]==0 && A[i][1]==0 && A[i][2]==0) flag=1;
        if(A[0][i]==0 && A[1][i]==0 && A[2][i]==0) flag=1;
    }
    if(A[0][0]==0 && A[1][1]==0 && A[2][2]==0) flag=1;
    if(A[2][0]==0 && A[1][1]==0 && A[0][2]==0) flag=1;

    if(flag==1) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 1736
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

bool dp[100010];

int main(){
  int n,k; cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,k+1){
    rep(j,n){
      if(i-a[j]>=0) dp[i]|=(!dp[i-a[j]]);
    }
  }
  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;

	vvi e(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	V<bool> vis(n, false);
	queue<int> que;
	que.push(0);
	vis[0] = true;
	vi ans(n - 1);

	while (!que.empty()) {
		int v = que.front();que.pop();
		rep(i, e[v].size()) {
			int vv = e[v][i];
			if (vis[vv])continue;
			vis[vv] = true;
			ans[vv - 1] = v;
			que.push(vv);
		}
	}

	cout << "Yes" << endl;
	rep(i, n - 1)cout << ans[i] + 1 << endl;

}

Measured memory_bytes: 10128
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<lint> zyo,rzyo;
lint mo=1000000007;
lint dp[18][(1<<16)+10];
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint co(int a,int b){
	if(a<0 || b<0 || a<b) return 0;
	return ((zyo[a]*rzyo[b])%mo*rzyo[a-b])%mo;
}
int main()
{
	zyo.pb(1);rep(i,70000) zyo.pb((zyo[i]*(i+1))%mo);
	rep(i,70000) rzyo.pb(invMod(zyo[i],mo));
	int n,m;int a[18];
	cin>>n>>m;
	rep(i,m) cin>>a[i];
	sort(a,a+m);reverse(a,a+m);
	memset(dp,0,sizeof(dp));dp[0][0]=1;
	rep(i,m) rep(j,(1<<n)){
		if(dp[i][j]<1LL) continue;
		dp[i+1][j]+=dp[i][j];
		if(dp[i+1][j]>=mo) dp[i+1][j]-=mo;
		rep(k,n){
			if((j&(1<<k))) continue;
			//cout<<k<<' '<<(1<<n)-a[i]-j<<' '<<(1<<k)-1<<endl;
			dp[i+1][j+(1<<k)]+=(dp[i][j]*co((1<<n)-a[i]-j,(1<<k)-1))%mo*zyo[(1<<k)];
			dp[i+1][j+(1<<k)]%=mo;
		}
	}
	lint out=0;
	rep(i,(1<<n)){
		//cout<<i<<' '<<dp[m][i]<<endl;
		if(__builtin_popcount(i)%2==0){
			out+=dp[m][i]*zyo[(1<<n)-i-1];
		}
		else{
			out-=dp[m][i]*zyo[(1<<n)-i-1];
		}
		out%=mo;
	}
	out*=(1<<n);out%=mo;if(out<0) out+=mo;out%=mo;
	cout<<out<<endl;
}


Measured memory_bytes: 10740
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	vector<int> operations;
	while (seq.size()) {
		vector<int>::iterator pos = seq.end();
		int i = 1;
		for (auto it = seq.begin(); it != seq.end(); ++it) {
			if (*it == i) {
				pos = it;
			}

			++i;
		}

		if (pos == seq.end()) {
			cout << "-1\n";
			return 0;
		}

		operations.push_back(*pos);
		seq.erase(pos);
	}

	for (int i = n - 1; i >= 0; --i) {
		cout << operations[i] << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
N = int(input())
coinsize = int(input())
yes = False

if coinsize is 0:
    if(N % 500 is 0):
        print("Yes")
        yes = True
        
else:
    for i in range(coinsize):
#    print("aaa")
        if((N - 1*i) % 500 is 0):
            print("Yes")
            yes = True
            break
    
if yes is False:
    print("No")
        
        


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <unordered_map>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> v(n);

    rep(i, n) cin >> v[i];
    sort(all(v));
    ll ans = v[n/2] - v[n/2 - 1];
    cout << ans; 



}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(a >= b) cout << "delicious" << endl;
    else if(a + x >= b) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    
}

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

using namespace std;

int number=0;
int a[100];
int numberOfSwap;

void bubble_sort(int a[]);
void print(int a[]);

int main(){
    numberOfSwap=0;
    cin>>number;
    for (int i=0; i<number; i++) {
        cin>>a[i];
    }
    bubble_sort(a);
    print(a);
    cout<<numberOfSwap<<endl;
}

void bubble_sort(int a[]){
    for (int i=0; i<number; i++) {
        for (int j=number-1; j>i; j--) {
            if (a[j] < a[j-1]) {
                swap(a[j],a[j-1]);
                numberOfSwap++;
            }
        }
    }
}

void print(int a[]){
    for (int i=0; i<number-1; i++) {
        cout<<a[i]<<" ";
    }
    cout<<a[number-1]<<endl;
}

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

namespace _1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            if (n[0] * n[1] % 2 == 1)
                Console.WriteLine("Odd");
            else Console.WriteLine("Even");
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
#define M 1000000007
#define MAX 100005
int A[MAX], tree[4 * MAX];
int power(int x, int p)
{
    if (p == 0)
        return 1;
    int y = power(x, p / 2);
    y *= y;
    y %= M;
    if (p % 2 == 0)
        return y;
    y *= x;
    y %= M;
    return y;
}
void build(int node, int start, int end)
{
    if (start == end)
        //Leaf node will have a single element
        tree[node] = start;
    else
    {
        int mid = (start + end) / 2;
        //Recurse on the left child
        build(2 * node, start, mid);
        //Recurse on the right child
        build(2 * node + 1, mid + 1, end);
        // Internal node will have the sum of both of its children
        tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
}
void update(int node, int start, int end, int idx, int val)
{
    if (start == end)
    {
        //Leaf Node
        A[idx] = val;
        tree[node] += val;
    }
    else
    {
        int mid = (start - end) / 2 + end;
        if (start <= idx && idx <= mid)
        {
            // If idx is in the left child, recurse on the left child
            update(2 * node, start, mid, idx, val);
        }
        else
        {
            // if idx is in the right child, recurse on the right child
            update(2 * node + 1, mid + 1, end, idx, val);
        }
        // Internal node will have the sum of both of its children
        tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
}
int query(int node, int start, int end, int l, int r)
{
    if (r < start || l > end)
    {
        // range represented by a node is completely outside the given range
        return 0;
    }
    if (l <= start && end <= r)
    {
        // range represented by a node is completely inside the given range
        return tree[node];
    }
    // range represented by a node is partially inside and partially outside the given range
    int mid = (start + end) / 2;
    int p1 = query(2 * node, start, mid, l, r);
    int p2 = query(2 * node + 1, mid + 1, end, l, r);
    return p1 + p2;
}
void Baap_ko_mat_sikha()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int c = 0;
    rep(i, 0, n - 2)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            c++;
    }
    cout << c << endl;
}

signed main()
{

    rootdada;
    int t;
    t = 1;
    while (t--)
    {
        Baap_ko_mat_sikha();
    }
}

Measured memory_bytes: 256
def BF(p,n,s):
    inf=float("inf")
    d=[inf for i in range(n)]
    d[s-1]=0
    for i in range(n+1):
        for e in p:
            if e[0]!=inf and d[e[1]-1]>d[e[0]-1]+e[2]:
                d[e[1]-1] = d[e[0]-1] + e[2]
        if i==n-1:t=d[-1]
        if i==n and t!=d[-1]:
            return [0,'inf']
    return list(map(lambda x:-x, d))
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a=[[x,y,-z] for x,y,z in a]
print(BF(a, n, 1)[-1])

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

typedef long long ll;
const ll mod=1e9+7;
const ll N=1e5+1;
const ll INF=1e10;
const double PI=acos(-1.0);

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double th1=6*m*PI/180,th2=(60*h+m)/2*PI/180;
	double x=pow(b*cos(th1)-a*cos(th2),2),y=pow(b*sin(th1)-a*sin(th2),2),ans=sqrt(x+y);
	printf("%.9lf",ans);	
}


Measured memory_bytes: 4076
n,m = map(int,input().split())
wa = [0]*n
ac = [False]*n
for i in range(m):
    p,s = map(str,input().split())
    if s == "AC":
        ac[int(p)-1] = True
    else:
        if not ac[int(p)-1]:
            wa[int(p)-1] += 1
ac_num = 0
wa_num = 0
for i in range(n):
    if ac[i]:
        ac_num += 1
        wa_num += wa[i]
print(ac_num, wa_num)



Measured memory_bytes: 4596
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
P = np.array(read().split(),np.int64)

P.sort()

P *= np.arange(N+N)
answer = P.sum() / (N+N-1)
print(answer)

Measured memory_bytes: 23088
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
G=[[0]*W for i in range(H)]
import numpy
from bisect import bisect_right
w=numpy.cumsum(A)
count=0
for i in range(H):
  if i%2==0:
    a=0
    b=W
    c=1
  else:
    a=W-1
    b=-1
    c=-1
  for j in range(a,b,c):
    G[i][j]=bisect_right(w,count)+1
    count+=1
  print(*G[i])

Measured memory_bytes: 13044
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}

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

	cout << 3*(a*a) << endl;

	return 0;
}

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 14.07.2020 14:01:13
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int n;
  cin>>n;

  ll a[n];
  ll sum=0;
  REP(i,n)
  {
    cin>>a[i];
    sum+=a[i];
  }

  ll ans=LONG_LONG_MAX;
  ll sunuke=0;
  REP(i,n-1)
  {
    sunuke+=a[i];
    sum-=a[i];
    chmin(ans,abs(sunuke-sum));
  }

  cout<<ans<<endl;


  return 0;
}

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

using namespace std;

const int N=1e5+10;
const int M=1e5+10;

struct Edge
{
    int to,nxt;

    Edge(){}
    Edge(int to,int nxt):to(to),nxt(nxt){}
}e[M<<1];
int head[N],cnt;

void addedge(int u,int v)
{
    e[++cnt]=Edge(v,head[u]);
    head[u]=cnt;
}

bool vis[N];

int dfs(int now,int v)
{
    if(now==v)
    {
        return 1;
    }
    vis[now]=1;
    int res=0;
    for(int i=head[now];i;i=e[i].nxt)
    {
        int vs=e[i].to;
        if(vis[vs]) continue;
        res+=dfs(vs,v);
    }
    return res;
}

int dgr[N];

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        addedge(u,v);
        addedge(v,u);
        dgr[u]++;
        dgr[v]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(dgr[i]&1)
        {
            cout<<"No"<<'\n';
            return 0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(dgr[i]>=6)
        {
            cout<<"Yes"<<'\n';
            return 0;
        }
    }
    int tot=0,u=0,v=0;
    for(int i=1;i<=n;i++)
    {
        if(dgr[i]==4)
        {
            tot++;
            if(!u) u=i;
            else if(!v) v=i;
        }
    }
    if(tot>=3) cout<<"Yes"<<'\n';
    else dfs(u,v)==2?cout<<"Yes"<<'\n':cout<<"No"<<'\n';
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>

int main()
{
	int n, a, b;
	std::cin >> n >> a >> b;

	int sum = 0;
	for( int i = 1; i <= n; i++ ) {
		int x = i;
		int s = 0;
		while( x > 0 ) {
			s += x % 10;
			x = x / 10;
		}
		if( a <= s and s <= b ) {
			sum += i;
		}
	}

	std::cout << sum << std::endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

ll gcd(ll a, ll b) {
    if(b==0) return a;
    a %= b;
    return gcd(b, a);
}
void solve() {
    int n;cin>>n;
    ll res=1;
    for(int i=0;i<n;i++) {
        ll x; cin>>x;
        res /= gcd(res, x);
        res *= x;
    }
    cout<<res<<endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
blue = Hash.new(0)
red = Hash.new(0)
max = 0

n = gets.to_i
n.times { blue[gets.chomp] += 1 }
m = gets.to_i
m.times { red[gets.chomp] += 1 }

blue.keys.each do |k|
	sum = blue[k] - red[k]
	max = sum if max < sum
end
puts max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
    #define debug(...) printf(__VA_ARGS__)
#else
    #define debug(...) (void)0
#endif
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>

#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
//const int inf = 0x7fffffff; //beware overflow
//const LL INF = 0x7fffffffffffffff; //beware overflow
#define mem(x, y) memset(x, (y), sizeof(x) );
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
     return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
    s << "[ ";
    for (auto it : c) s << it << " ";
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    o << "{";
    for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it;
    return o << "}";
}
template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se;
    }
    o << "}";
    return o;
}
inline LL getint(){
   LL _x=0,_tmp=1; char _tc=getchar();
   while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
   if( _tc == '-' ) _tc=getchar() , _tmp = -1;
   while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
   return _x*_tmp;
}
#define maxn 100005
vector<int> G[maxn];
bool vis[maxn];
int sz;
int patt[maxn];
int dfs(int u, int p=-1, int pattern=0) {
    patt[u] = pattern;
    assert( !vis[u]);
    sz++;
    vis[u] = true;
    int res=0;
    for(int v : G[u]) if(v!=p) {
        if(vis[v]) res = max(res, patt[v]^pattern^1);
        else res = max( res, dfs(v, u, pattern^1) );
    }
    return res;
}
int main() {
    int n=getint(), m=getint();
    for(int i=0;i<m;i++) {
        int x, y; scanf("%d %d", &x, &y);
        x--, y--;
        G[x].PB(y), G[y].PB(x);
    }
    vector<int> v;
    LL cnt1=0;
    for(int i=0;i<n;i++)if(!vis[i]) {
        sz=0;
        int tmp=dfs(i);
        if( sz==1 ) cnt1++;
        else v.PB(tmp);
    }

    LL cyc=0, nocyc=0;
    for(int i=0;i<SZ(v);i++) {
        if(v[i]) cyc++;
        else nocyc++;
    }
    LL ans = 0;
    while(cnt1){
      ans += 2*n - 1;
      n--; cnt1--;
    }
    ans+=cyc*cyc+nocyc*nocyc*2+cyc*nocyc*2;
    cout << ans << endl;
}


Measured memory_bytes: 11008
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {a[i]=sc.nextInt();}
        int a=sc.nextInt();
        int b=sc.nextInt();

        if(a+b==15)
        out.println("+");
        else if(a*b==15)
        out.println("*");
        else
        out.println("x");
        out.flush();
    }
    

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    

    class P implements Comparable<P>{
        long x;
        double d;
        P(long x, double d) {
            this.x=x;
            this.d=d;
        } 
          
        public int compareTo(P p){
            return (d - p.d)>0?1:-1;//des
        } 
    }
}
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 22996