akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll H, W;
  cin >> H >> W;
  vvl A = VVL(H, W, 0);
  vector<pll> B, C;
  REP(i, H) REP(j, W) cin >> A[i][j];
  REP(i, H) REP(j, W - 1) {
    if (A[i][j] % 2 != 0) {
      A[i][j + 1]++;
      A[i][j]--;
      B.push_back(make_pair(i + 1, j + 1));
      C.push_back(make_pair(i + 1, j + 2));
    }
  }
  REP(i, H - 1) {
    if (A[i][W - 1] % 2 != 0) {
      A[i][W - 1]--;
      A[i + 1][W - 1]++;
      B.push_back(make_pair(i + 1, W));
      C.push_back(make_pair(i + 2, W));
    }
  }
  cout << B.size() << endl;
  REP(i, B.size()) {
    cout << B[i].first << " " << B[i].second << " " << C[i].first << " "
         << C[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 8124
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
S = input()
change_count = 0
first = S[0]
for i in range(1,N):
    if first != S[i]:
        change_count += 1
        first = S[i]
print(N - 1 - max(0,change_count-K*2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }


int main() {
  int k, n; cin>>k>>n;
  vector<int> a(2*n);
  rep(i, n) cin>>a[i];
  rep(i, n) a[i+n] = k+a[i];
  int ans = INF;
  REP(i, n-1, 2*n) {
    ans = min(ans, a[i]-a[i-(n-1)]);
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> a(8, 0);
  int A = 0;
  REP(i, N){
    int tmp; cin >> tmp;
    if(tmp < 400){
      a[0]++;
    }else if(tmp >=400 && tmp < 800){
      a[1]++;
    }else if(tmp >= 800 && tmp < 1200){
      a[2]++;
    }else if(tmp >= 1200 && tmp < 1600){
      a[3]++;
    }else if(tmp >= 1600 && tmp < 2000){
      a[4]++;
    }else if(tmp >= 2000 && tmp < 2400){
      a[5]++;
    }else if(tmp >= 2400 && tmp < 2800){
      a[6]++;
    }else if(tmp >= 2800 && tmp < 3200){
      a[7]++;
    }else{
      A++;
    }
  }
  int m = 0;
  REP(i, 8){
    if(a[i] != 0) m++;
  }
  cout << (m == 0 ? 1 : m) << " " << m + A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll r;

int main() {
	cin >> r;
	cout << r * r << endl;
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int vec[110];
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  sort(vec, vec+N);
  int count=N;
  for(int i=0; i<N-1; i++){
    if(vec[i] == vec[i+1]){
      count--;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N;
    cin >> N;
    cout << N + pow(N, 2) + pow(N, 3) << endl;
    return 0;
}


Measured memory_bytes: 4152
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            // RRRRR....RRWWWWW..WW
            var n = IO.RInt;
            var s = ReadLine().ToCharArray();

            if (s.Where(x => x == 'R').Count() == 0)
            {
                WriteLine(0);
                return;
            }

            int j = s.Length - 1;
            int ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'W')
                {

                    while (s[j] != 'R')
                    {
                        j--;
                    }

                    if (i >= j) break;

                    s[i] = 'R';
                    s[j] = 'W';

                    j--;
                    ans++;
                }
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 19224
s = input()
x, y = map(int, input().split())

dpx = {0}
dpy = {0}

f = s.split("T")

fx = []
fy = []

for i, fi in enumerate(f):
    if i % 2:
        fy.append(len(fi))
    else:
        fx.append(len(fi))

for i, fxi in enumerate(fx):
    nex = set([])
    for j in dpx:
        nex.add(j+fxi)
        if i > 0:
            nex.add(j-fxi)
    dpx = nex
        
for fyi in fy:
    nex = set([])
    for j in dpy:
        nex.add(j+fyi)
        nex.add(j-fyi)
    dpy = nex

if x in dpx and y in dpy:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 81064
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        explicit Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll r, D, x;
    is >> r >> D >> x;
    if(!is) return;
    for (auto &&i : Repeater(0, 10)) {
        x = r*x - D;
        cout << x << endl;
    } // end i
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_B.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fo(i,a,b) for (int i = a;i <= b;i ++)

using namespace std;

const int maxn = 105;
int n,m,step[3],dist[maxn];
bitset<maxn> d[maxn][maxn];

int main()
{
	scanf("%d%d%d%d%d",&n,&m,&step[0],&step[1],&step[2]);
	sort(step,step+3);
	fo(i,1,m)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		d[u][1][v] = 1;
	}
	fo(j,2,step[2])
		fo(i,1,n)
			fo(k,1,n)
				if (d[i][1][k]) d[i][j] = d[i][j] | d[k][j-1];
	fo(i,1,n) dist[i] = 0x7f7f7f7f;
	dist[n] = 0;
	while (1)
	{
		bool flag = 0;
		fo(i,1,n)
		{
			int len = 0;
			fo(k,0,2)
			{
				int tmp = 0x7f7f7f7f;
				fo(j,1,n)
					if (d[i][step[k]][j])
						tmp = min(tmp,dist[j]+1);
				len = max(len,tmp);
			}
			if (len < dist[i])
			{
				dist[i] = len;
				flag = 1;
			}
		}
		if (!flag) break;
	}
	if (dist[1] == 0x7f7f7f7f) puts("IMPOSSIBLE");
	else printf("%d\n",dist[1]);
	return 0;
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N, A[200000]; cin >> N;
	set<int> st;
	map<int, int> mp;
	REP(i, N){
		cin >> A[i];
		mp[A[i]]++;
	}
	vint vec;
	REP(i, N){
		if(mp[A[i]] == 1) vec.eb(A[i]);
		else st.insert(A[i]);
	}
	sort(ALL(vec));
	int ans = vec.size();
	REP(i, vec.size()){
		for(int j = 1; j*j <= vec[i]; j++){
			if(vec[i] % j == 0){
				int n = j, m = vec[i]/j;
				if(st.count(n)){
					ans--; break;
				}
				if(st.count(m)){
					ans--; break;
				}
			}
		}
		st.insert(vec[i]);
	}
	cout << ans << ln;
}

Measured memory_bytes: 23628
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, v):
        if self.parents[v] < 0:
            return v
        else:
            self.parents[v] = self.find(self.parents[v])
            return self.parents[v]

    def unite(self, u, v):
        u = self.find(u)
        v = self.find(v)

        if u == v:
            return

        if self.parents[u] > self.parents[v]:
            u, v = v, u

        self.parents[u] += self.parents[v]
        self.parents[v] = u

    def size(self, v):
        return -self.parents[self.find(v)]

    def same(self, u, v):
        return self.find(u) == self.find(v)

N, M, K = map(int, input().split())
uf = UnionFind(N+1)
F = [0] * (N+1)
B = [0] * (N+1)
for _ in range(M):
    a, b = map(int, input().split())
    uf.unite(a, b)
    F[a] += 1
    F[b] += 1

for _ in range(K):
    c, d = map(int, input().split())
    if uf.same(c, d):
        B[c] += 1
        B[d] += 1

for i in range(1, N+1):
    ans = uf.size(i) - F[i] - B[i] - 1
    print(ans, end=' ')

print()

Measured memory_bytes: 14544
def solve(arr,n,k):
	if k==1:
		ss=0 
		for i in range(1,n):
			ss+=abs(arr[i]-arr[i-1]) 
		print(ss) 
		return  
	if k>=n:
		print(abs(arr[-1]-arr[0]))
		return
	dp=[0]*n 
	for i in range(k):
		dp[i]=abs(arr[i]-arr[0])  
	for i in range(k,n):
		f=float('inf') 
		for x in range(1,k+1):
			f=min(dp[i-x]+abs(arr[i-x]-arr[i]),f)  
		dp[i]=f 
	#print(dp)
	print(dp[-1]) 
n,k=map(int,input().split()) 
a=[int(x) for x in input().split()] 
solve(a,n,k) 

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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] ND = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = ND[0];
            var D = ND[1];
            var ans = 0;

            for (int i = 0; i < N; ++i) {
                long[] XY = Console.ReadLine().Split().Select(long.Parse).ToArray();
                var x = XY[0];
                var y = XY[1];

                if (D * D >= (x * x + y * y)) {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 41332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
struct edge{ll to, cost;};
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define INF 1000000000000
#define ALL(a)  (a).begin(),(a).end()

std::string rsubstr(std::string str, size_t pos, size_t len = std::string::npos)
{
    // 元の文字列の長さを取得します。
    const size_t strlen = str.length();

    // 切り出す文字列の長さが省略された、または切り出し開始位置+1より長い場合
    if ((std::string::npos == len) || ((pos + 1) < len))
    {
        // 切り出す文字列の長さを文字列の末尾までに変更します。
        len = pos + 1;
    }

    // 文字列を切り出します。
    std::string dst = str.substr(strlen - pos - 1, len);
    return dst;
}


int main(){
    ll n,m;
    cin >> n >> m;
    ll p[100000],y[100000];
    vector<ll> hoge[100001];
    for(ll i = 0; i < m; i++){
        ll temp1,temp2;
        cin >> temp1 >> temp2;
        p[i] = temp1;
        y[i] = temp2;
        hoge[p[i]].push_back(y[i]);
    }
    for(int i=1; i <= n ; i++){
        sort(hoge[i].begin(),hoge[i].end());
    }
    for(int i = 0; i < m; i++){
        string  pre = "000000"+to_string(p[i]);
        auto iter = lower_bound(ALL(hoge[p[i]]),y[i]);
        string city = "000000"+to_string(iter-hoge[p[i]].begin()+1);
        cout << rsubstr(pre,5) << rsubstr(city,5) << endl;

    }

}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A), q(B), r(C);

  rep(i, A){
    cin >> p[i];
  }

  rep(i, B){
    cin >> q[i];
  }

  rep(i, C){
    cin >> r[i];
  }

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());

  vector<pair<ll, int>> H;
  rep(i, X){
    H.push_back(make_pair(p[i], 0));
  }

  rep(i, Y){
    H.push_back(make_pair(q[i], 1));
  }

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

  int ind_r = 0;
  for(int i = 0; i < H.size(); i++){
    if(r[ind_r] > H[i].first){
      H[i].first = r[ind_r];
      ind_r++;
      if(ind_r == C) break;
    }
  }

  ll ans = 0;
  for(int i = 0; i < H.size(); i++){
    ans += H[i].first;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main () {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	long long sum = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	cout << sum;
	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int maxn = (1 << 18) + 10;
const int D = 9;
V<pii> vec[maxn];
pii pt[maxn];
int dep[maxn];

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

    rep(i, N) {
        int V, W;
        cin >> V >> W;
        pt[i + 1] = mp(W, V);
    }

    for (int i = 1; i <= N; ++i) {
        debug(i);
        if (i > 1) {
            dep[i] = dep[i / 2] + 1;
        }
        auto v = vec[i / 2];
        if (dep[i] == D) {
            v.clear();
        }
        if (v.size() == 0) {
            v.eb(0, 0);
        }
        debug(v);
        V<pii> nx(v.size());
        rep(j, SZ(v)) { nx[j] = mp(v[j].fi + pt[i].fi, v[j].se + pt[i].se); }
        vec[i].resize(nx.size() + v.size());
        merge(ALL(v), ALL(nx), vec[i].begin());
        debug(i, vec[i]);
    }

    int Q;
    cin >> Q;

    while (Q--) {
        int v, L;
        cin >> v >> L;
        if (dep[v] < D) {
            int ans = 0;
            for (auto p : vec[v]) {
                if (p.fi <= L) {
                    chmax(ans, p.se);
                }
            }
            cout << ans << '\n';
            continue;
        }
        int vc = v;
        while (dep[vc] >= D) {
            vc /= 2;
        }
        auto& v1 = vec[vc];
        int p1 = 0;
        int ans = 0;

        int maxi = -1;
        for (int i = SZ(vec[v]) - 1; i >= 0; --i) {
            auto p = vec[v][i];
            while (p1 < v1.size() && v1[p1].fi + p.fi <= L) {
                chmax(maxi, v1[p1++].se);
            }
            if (maxi != -1) {
                chmax(ans, p.se + maxi);
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 717144
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s
getIntListBC = map readInt . BC.words <$> BC.getLine

f :: Int -> Int -> Int
f 1 m= 1
f a m = if m `mod` a == 0
    　  then a
　　　  else f (a-1) m
        
main = do
    [n,m] <- (map read . words) <$> getLine
    let p = m `div` n
    
    let ans = f p m
    print $ ans

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define X first
#define Y second
#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ull a,b,k;
	cin>>a>>b>>k;
	if(k>=a+b)cout<<"0 0"<<endl;
	else if(k>=a)cout<<"0 "<<a+b-k<<endl;
	else cout<<a-k<<" "<<b<<endl;
return 0;
}


Measured memory_bytes: 256
/* Sometimes you win , sometimes you learn . */
/* Sometimes you win , sometimes you learn . */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
int main(){
    FAST
    ld l;
    cin >> l;
    ld s = l / 3;
    cout << fixed << setprecision(12) << s * s * s << endl;
    return 0 ;
    }
/*
[#]=============================================================[#]
         ___    ____              ____          ___ _
        |_ _|  / ___|__ _ _ __   |  _ \  ___   |_ _| |_
         | |  | |   / _` | '_ \  | | | |/ _ \   | || __|
         | |  | |__| (_| | | | | | |_| | (_) |  | || |_
        |___|  \____\__,_|_| |_| |____/ \___/  |___|\__|
                     it's just about time

[#]=============================================================[#]
*/


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {
    map<string, ll> m;

    int n;
    cin >> n;
    rep(i, n) {
        int command;
        string k;
        cin >> command >> k;
        if (command == 0) {
            ll v;
            cin >> v;
            m[k] = v;
        } else {
            cout << m[k] << endl;
        }
    }

}



Measured memory_bytes: 27820
#include <iostream>

int main(){
  std::string s;
  std::cin >> s;
  for(auto i = s.begin(); i < s.end()-1; ++i)
    if(*i == *(i+1)){
      std::cout << "Bad" << std::endl;
      return 0;
    }
  std::cout << "Good" << std::endl;
  return 0;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

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

  set<int> st;
  int x = 0;
  rep(i, N){
    int a;
    cin >> a;
    if(a < 3200){
      st.insert(a / 400);
    }else{
      x++;
    }
  }
  int ansMin = st.size();
  int ansMax = st.size();
  ansMax += x;
  if(ansMin == 0){
    ansMin = 1;
  }

  cout << ansMin << " " << ansMax << endl;
  return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define LL  long long


int main(void)
{
    IOS
    int n;
    cin >> n;
    vector<string> s(n);
    int a = 0;
    int b = 0;
    int ab = 0;
    int count = 0;
    for(int i = 0; i < n; i++) {
        cin >> s[i];

        size_t pos = s[i].find("AB",0);
        //cerr << pos << endl;
        while (pos != string::npos) {
            pos = s[i].find("AB",pos+1);
            count++;
        }

        if (s[i].front() == 'B') {
            if (s[i].back() == 'A') {
                ab++;
            } else {
                b++;
            }
        } else if (s[i].back() == 'A') {
            a++;
        }
    }
    //cerr << "a:" << a << " b:" << b << " ab:" << ab << endl; 
    int minab = min(a,b);
    //cerr << "minab:" << minab << endl;
    int amari = max(a,b) - min(a,b);
    count += minab;
    if (ab != 0) {
        if ((amari != 0) || (minab != 0) ) {
            count += ab;
        } else {
            count += ab -1;
        }
    }


    cout << count << endl;
    return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif

static int N, M;
static ll s[1024];
static ll c[1024][1024];
static bool edge[1024][1024];

static void relax()
{
	int i, j;
	rep1 (i, N)
	rep1 (j, N) if (edge[i][j]) {
		DEBUG("S %i <- %lli\n", j, s[i] + c[i][j]);
		s[j] = max(s[j], s[i] + c[i][j]);
	}
}

int main()
{
	cin >> N >> M;
	int i;
	fill(c[0], c[1024], -1);
	fill(s, s+1024, -100000000000000LL);
	s[1] = 0;
	rep (i, M) {
		int a, b;
		cin >> a >> b;
		cin >> c[a][b];
		edge[a][b] = true;
	}
	int k;
	rep (k, N)
		relax();
	ll x = s[N];
	relax();
	if (s[N] > x)
		cout << "inf" << endl;
	else
		cout << x << endl;
	return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n >> k;
    if (2 * n < k) {
        END(0)
    }

    ans = pow(n / k, 3);
    if (k % 2 == 0) {
        ans += pow((n - k / 2) / k + 1, 3);
    }

    MSG(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    vec in(3);
    cin >> N;
    rep(i, 3) cin >> in[i];
    ll sum = accumulate(ALL(in), 0LL);
    vector<char> ans(N);
    map<string, int> mp{{"AB", 0}, {"BC", 1}, {"AC", 2}};
    vec id(N);
    rep(i, N) {
        string s;
        cin >> s;
        id[i] = mp[s];
    }
    id.push_back(0);
    rep(i, N) {
        int a = id[i], b = (id[i] + 1) % 3;
        if (max(in[a], in[b]) == 0) {
            cout << "No" << endl;
            return 0;
        }else if (in[a] < in[b] || (in[a] == 1 && in[b] == 1 && i != N - 1 && sum == 2 && (a != (id[i + 1] + 2) % 3))) {
            ans[i] = char('A' + a);
            ++in[a];
            --in[b];
        }else {
            ans[i] = char('A' + b);
            --in[a];
            ++in[b];
        }
    }
    cout << "Yes" << endl;
    rep(i, N) cout << ans[i] << endl;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int N, A, B, C;
vector<int> L;

void chmin(int& a, int b) {
	if (a > b) a = b;
}

int rec(int i, int a, int b, int c) {
	if (i == N) {
		if (!a || !b || !c) return 1e9;
		else {
			int sum = abs(A - a) + abs(B - b) + abs(C - c);
			//cout << sum << endl;
			return sum;
		}
	}

	int res = rec(i + 1, a, b, c);
	chmin(res, rec(i + 1, a + L[i], b, c) + (a ? 10 : 0));
	chmin(res, rec(i + 1, a, b + L[i], c) + (b ? 10 : 0));
	chmin(res, rec(i + 1, a, b, c + L[i]) + (c ? 10 : 0));

	return res;
}

int main() {
	cin >> N >> A >> B >> C;

	L.resize(N);
	for (int i = 0; i < N; i++) cin >> L[i];

	int ans = rec(0, 0, 0, 0);

	cout << ans << endl;
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = in.nextIntArray(n);

			int[] len = new int[n+1];

			for (int i = 0; i < n; i++) {
				len[a[i]] = len[a[i]-1] + 1;
			}

			int ans = 0;
			for (int i = 0; i <= n; i++) {
				ans = Math.max(ans, len[i]);
			}

			out.println(n-ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 46352
import math


def c_cnt(n, r):
    if n - r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * (math.factorial(r)))


N, K = map(int, input().split())
red = N - K
div = 1
for i in range(1,K+1):
    place = c_cnt(red+1, i)
    if 1 < i < K:
        div = c_cnt(K-1, i-1)
    else:
        div = 1
    print(place * div % (10**9+7))



Measured memory_bytes: 3316
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		int N = s.nextInt();
		int[] card = new int[N];
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < N; i++) {
			card[i] = s.nextInt();
		}
		Arrays.sort(card);

		for (int i = N - 1; 0<=i ; i=i-2) {
			alice += card[i];
			if (0<i) {
				bob += card[i-1];
			}
		}

		System.out.println(alice-bob);

	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
unordered_map<string, int> days = {
    {"SUN",7},
    {"MON",6},
    {"TUE",5},
    {"WED",4},
    {"THU",3},
    {"FRI",2},
    {"SAT",1}
};
    
int Main(string s)
{
    return days[s];
}

int main(void){
    string s;
    cin >> s;
    cout << Main(s) << endl;
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    multiset<ll> st;
    for(ll i=0;i<n;i++) cin >> a[i];
    for(ll i=0;i<n;i++){
        auto itr = st.lower_bound(a[i]);
        if(st.begin()!=itr){
            itr--;
            st.erase(itr);
            st.insert(a[i]);
        }
        else st.insert(a[i]);
    }
    cout << st.size() << endl;
    return 0;
} 

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N;
  cin>>N;
  vector<ll>x(N);
  vector<ll>y(N);
  
  rep(i,N){
cin>>x[i]>>y[i];
  }
  double sum=0;
  
  ll a=1;
  ll b=1;
  
  for(ll i=1;i<=N;i++){
    a*=i;
  }
for(ll j=1;j<=N-1;j++){
b*=j;
}

  
  for(ll i=0;i<N;i++){
for(ll j=i+1;j<N;j++){
  sum+=sqrt(power(x[i]-x[j],2)+power(y[i]-y[j],2));
}
  }

  printf("%0.10lf\n",(2*b*sum)/a*1.0);
  

  }


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

using namespace std;

int main() {
  int h, n;
  cin >> h >> n;

  long res[h + 1];
  for (int k = 0; k <= h; k++) { res[k] = 10000000000; }
  for (int i = 0; i < n; i++) {
    long dam, mag;
    cin >> dam >> mag;
    for (int k = 1; k <= h; k++) {
      if (k <= dam) {
        if (res[k] > mag) res[k] = mag;
      } else {
        long use = res[k - dam] + mag;
        if (res[k] > use) res[k] = use;
      }
    }
  }
  cout << res[h] << endl;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=100000;
long long w[MAXN],v[MAXN],f[MAXN];
long long ans;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			f[j]=max(f[j],f[j-w[i]]+v[i]);
			ans=max(f[j],ans);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static Scanner scanner;
    static PrintWriter out;
    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        out = new PrintWriter(System.out);
        int a = nextInt();
        int b = nextInt();
        int c = nextInt();
        if (((double)a / (double)c) > b) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
        out.flush();
    }

    public static void println(Object o) {
        out.println(o);
    }

    public static void print(Object o) {
        out.print(o);
    }

    public static void printf(String format, Object... o) {
        out.printf(format, o);
    }

    public static String next() {
        return scanner.next();
    }

    public static int nextInt() {
        return Integer.parseInt(scanner.next());
    }

    public static long nextLong() {
        return Long.parseLong(scanner.next());
    }

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

    public static short nextShort() {
        return Short.parseShort(scanner.next());
    }

    public static float nextFloat() {
        return Float.parseFloat(scanner.next());
    }

    public static void printYes() {
        System.out.println("Yes");
    }

    public static void printYES() {
        System.out.println("YES");
    }

    public static void printNo() {
        System.out.println("No");
    }

    public static void printNO() {
        System.out.println("NO");
    }

    public static String nextLine() {
        return scanner.nextLine();
    }

    public static double distance(double x, double y, double x2, double y2) {
        return Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
    }

    public static int MOD = 1_000_000_007;
    public static int MAX = 100000;
    public static long[] fac = new long[MAX];
    public static long[] finv = new long[MAX];
    public static long[] inv = new long[MAX];

    public static void combinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    public static long combination(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    public static long factorial(long n) {
        return n <= 0 ? 1 : n * factorial(n - 1);
    }
}

Measured memory_bytes: 29344
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define lowbit(x) (x&-x)

struct node { int l,r,len; }a[300010];

int c[100010],n,m;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool cmp(node x,node y) { return x.len<y.len; }

inline void add(int x,int y) { for (;x<=m;x+=lowbit(x)) c[x]+=y; }

inline int query(int x)
{
	int res=0;
	for (;x;x-=lowbit(x)) res+=c[x];
	return res;
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=n;i++)
	{
		a[i].l=rd();a[i].r=rd();
		a[i].len=a[i].r-a[i].l+1;
	}
	sort(a+1,a+n+1,cmp);
	int hh=1;
	for (int i=1;i<=m;i++)
	{
		for (;a[hh].len<i&&hh<=n;hh++) add(a[hh].l,1),add(a[hh].r+1,-1);
		int ans=n-hh+1;
		for (int j=0;j<=m;j+=i) ans+=query(j);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 2e5+5;
const int MOD = 1e9+7;


int arr[MSIZE];
int dp[MSIZE];

int main(){
    FIO
    int n, k ; cin>>n>>k;
    f(i,0,n-1)  cin>>arr[i];
    dp[0] = 0;
    f(i,1,n-1) {
        dp[i] = 1e9+7;
        fr(j,i-1,max(i-k,0))
        dp[i] = min(dp[i],dp[j] + abs(arr[i]-arr[j]));
    }
    cout<<dp[n-1]<<endl;
    return 0;

}
    


Measured memory_bytes: 1024