akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V, E;

struct Edge {
	int from, to, cap, flow;
	Edge(int u, int v, int c, int f) :from(u), to(v), cap(c), flow(f) {}
};

struct Graph {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];
	int a[NUM];
	int p[NUM];

	void init(int n) {
		for (int i = 0; i < n; i++)
			G[i].clear();
		edges.clear();
	}

	void AddEdge(int from, int to, int cap) {
		edges.push_back(Edge(from, to, cap, 0));
		edges.push_back(Edge(to, from, 0, 0));
		m = edges.size();
		G[from].push_back(m - 2);
		G[to].push_back(m - 1);
	}

	int Maxflow(int s, int t) {
		int flow = 0;
		for (;;) {
			memset(a, 0, sizeof(a));
			queue<int> Q;
			Q.push(s);
			a[s] = INF;
			while (!Q.empty()) {
				int x = Q.front();
				Q.pop();
				for (int i = 0; i < G[x].size(); i++) {
					Edge& e = edges[G[x][i]];
					if (!a[e.to] && e.cap > e.flow) {
						p[e.to] = G[x][i];
						a[e.to] = min(a[x], e.cap - e.flow);
						Q.push(e.to);
					}
				}
				if (a[t])
					break;
			}
			if (!a[t])
				break;
			for (int u = t; u != s; u = edges[p[u]].from) {
				edges[p[u]].flow += a[t];
				edges[p[u] ^ 1].flow -= a[t];
			}
			flow += a[t];
		}
		return flow;
	}
	
};

Graph solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int u, v, c;
	cin >> V >> E;
	solve.init(V);
	for (int i = 0; i < E; i++) {
		scanf("%d%d%d", &u, &v, &c);
		solve.AddEdge(u, v, c);
	}
	cout << solve.Maxflow(0, V - 1) << endl;;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 6036
import Foundation


class Scanner {
    static func readInt() -> Int {
        return Int(readLine()!)!
    }
    
    static func readIntArr() -> [Int] {
        return readLine()!.split(separator: " ").map { Int($0)! }
    }
    
    static func readM(_ n: Int) -> [[Int]] {
        var res = [[Int]]()
        for _ in 0..<n {
            res.append(readIntArr())
        }
        return res
    }
    
    static func readUknownIntMat() -> [[Int]] {
        var res = [[Int]]()
        while let line = readLine() {
            res.append(line.split(separator: " ").map { Int($0)! })
        }
        return res
    }
    
    static func readString() -> String {
        return readLine()!
    }
}

class Printer {
    static func printIntArray(_ arr: [Int]) {
        print(arr.map { String($0) }.joined(separator: " "))
    }
}

let nt = Scanner.readIntArr()
let n = nt[0], t = nt[1]
let arr = Scanner.readM(n)


func find(_ cv: [[Int]], _ t: Int, _ n: Int) -> Int {
    var dp = [[Int]](repeating: [Int](repeating: 0, count: n+1), count: t+1)
    let costVal = cv.sorted(by: { $0[0] < $1[0] })
    var res = 0
    for i in stride(from: 0, to: t, by: 1) {
        for j in stride(from: 0, to: n, by: 1) {
            dp[i][j+1] = max(dp[i][j+1], dp[i][j])
            if(i + costVal[j][0] < t) {
                dp[i + costVal[j][0]][j+1] = max(dp[i + costVal[j][0]][j], costVal[j][1] + dp[i][j])
            }
            res = max(res, dp[t-1][j] + costVal[j][1])
        }
    }
    
//    print(dp)
    return res
}

print(find(arr, t, n))


Measured memory_bytes: 83956
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
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;}

struct SCC{
  vector<vector<int> > G,R,T,C;//T:強連結分解後のグラフ
  vector<int> vs,used,blg;
  SCC(int n):G(n),R(n),used(n),blg(n){}

  void add_edge(int u,int v){
    G[u].emplace_back(v);
    R[v].emplace_back(u);
  }

  int size(){
    return T.size();
  }

  void dfs(int v){
    used[v]=1;
    for(int u:G[v])
      if(!used[u]) dfs(u);
    vs.emplace_back(v);
  }

  void rdfs(int v,int k){
    used[v]=1;
    blg[v]=k;
    C[k].emplace_back(v);
    for(int u:R[v])
      if(!used[u]) rdfs(u,k);
  }

  int build(){
    int n=G.size();
    for(int v=0;v<n;v++)
      if(!used[v]) dfs(v);

    fill(used.begin(),used.end(),0);
    int k=0;
    for(int i=n-1;i>=0;i--){
      if(!used[vs[i]]){
        T.emplace_back();
        C.emplace_back();
        rdfs(vs[i],k++);
      }
    }
    for(int v=0;v<n;v++)
      for(int u:G[v])
        if(blg[v]!=blg[u])
          T[blg[v]].push_back(blg[u]);

    for(int i=0;i<k;i++){
      sort(T[i].begin(),T[i].end());
      T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
    }
    return k;
  }
  int operator[](int k) const{return blg[k];};//頂点kの属する強連結成分
};

int n,m;

void solve(){
    cin >> n >> m;
    SCC scc(n);
    rep(i,m){
        int a,b;cin >> a >> b;
        scc.add_edge(a,b);
    }
    int k=scc.build();
    vector<vector<int>> ls(k);
    cout << k << endl;
    rep(i,n){
        ls[scc[i]].push_back(i);
    }
    rep(i,k){
        cout << ls[i].size() << " ";
        for(int t:ls[i]){
            cout << t << " ";
        }
        cout << "" << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 131036
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second
#define sz(a) ((int)(a.size()))

const int MAX = 500005;
const int mod = 998244353;
int dist[100005];
vector<int> g[100005];
int main()
{
	memset(dist, -1 , sizeof dist);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i = 1; i < n; i++)
	{
		int u, v;
		cin >> u >> v;
		u--;v--;
		g[u].pb(v);
		g[v].pb(u);
	}
	int k;
	cin >> k;
	priority_queue<pair<int , int> > pq;
	for(int i = 0; i < k; i++)
	{
		int v, p;
		cin >> v >> p;
		v--;
		pq.push({-p, v});
		dist[v] = p;
	}
	while(!pq.empty())
	{
		int u = pq.top().y;
		int d = -pq.top().x;
		pq.pop();
		for(auto v : g[u])
			if(dist[v] == -1)
			{
				dist[v] = d + 1;
				pq.push({-dist[v] , v});
			}
	}
	for(int i = 0; i < n; i++)
		for(auto j : g[i])
			if(abs(dist[i] - dist[j]) != 1)
			{
				cout << "No";
				return 0;
			}
	cout << "Yes" << endl;
	for(int i = 0; i < n; i++)
		cout << dist[i] << endl;
	
	
			
}


Measured memory_bytes: 8832
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,k= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しに4 3sum変数使用はsum関数使用できないので注意
s = k
for i in range(1,n):
    s+=min(k,a[i]-a[i-1])
print(s)

Measured memory_bytes: 27256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const long long INF = 1e9+2;

int main() {
    cout << fixed << setprecision(10);
    
    ll N, W; cin >> N >> W;
    vector<pair<ll, ll>> wv(N);
    rep(i, N) {
        ll w, v;
        cin >> w >> v;
        wv[i] = make_pair(w, v);
    }

    vector<vector<ll>> dp(N+1, vector<ll>(100001, INF));
    dp[0][0] = 0;

    rep(i, N) {
        ll w, v;
        w = wv[i].first;
        v = wv[i].second;
        rep(j, 100001) {
            if (j >= v) {
                dp[i+1][j] = min(dp[i][j], dp[i][j-v] + w);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    ll res = 0;
    rep(i, 100001) {
        if (dp[N][i] <= W) {
            res = i;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 80256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<long long int>dp(M + 1);
	dp[0] = power(2, N, MOD);
	for (auto i : v) {
		for (int j = M; j >= i; j--) {
			dp[j] += dp[j - i] * ((MOD+1)/2);
			dp[j] %= MOD;
		}
	}
	cout << dp.back() << endl;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n); INT(m);
    if(n > m) swap(n,m);
    int ans;
    if(n == 1){
        if(m == 1) ans = 1;
        else ans = m-2;
    }else if(n == 2)ans = 0;
    else ans = (n-2) * (m-2);
    ANS;

    return 0;
}

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

std::string a, b, c;

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

    if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
    std::cout << "YES\n";
    else
    std::cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;
using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<int, int> pairs;
typedef complex<ll> G;
const int N = 1e5+5;

void solve(){

    int a, b;
    cin >> a >> b;
    if(b > a*4 || b < a*2)cout << "No";
    else if(b%2==1)cout << "No";
    else cout << "Yes";



}
int main() {
    fast;
    solve();


}


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

int main() {
	long N, A, B; cin >> N >> A >> B;
	if(A+B-1>N || A*B<N){
		cout << -1 << endl;
		return 0;
	}
	if(B==1){
		cout << 1;
		for(int i=2; i<=N; ++i) cout << ' ' << i;
		return 0;
	}
	long mx=N-A, other=(N-A)/(B-1), res=(N-A)%(B-1);
	cout << mx+1;
	for(long i=mx+2; i<=N; ++i) cout << ' ' << i;
	for(long i=1; i<B; ++i){
		if(i<=res) ++other;
		mx -= other;
		for(long c=1; c<=other; ++c) cout << ' ' << mx+c;
		if(i<=res) --other;
	}
	cout << endl;
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a), greater<int>());
    int alice = 0, bob = 0;
    rep(i, n)
    {
        if (i % 2 == 0)
            alice += a[i];
        else
            bob += a[i];
    }
    cout << alice - bob << endl;
}

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


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

int main(){
  int N; cin >>N;
  int ans=N*800-(N/15)*200;
  cout <<ans <<endl;
}


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

int main(){
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	for(int i=0;i<n;){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
			cnt++;
			i += 3;
		}else{
			i++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3140
#include <cstdio>
#include <algorithm>
#define R register
#define ll long long
using namespace std;

ll base[40];
int D;
int ans=0;
int st[40];

inline void dfs(int now,int len,ll sum)
{
	if(now>=len/2+1)
	{
		if(sum!=D) return ;
		int tans=st[1]>=0?(9-st[1]):(9+st[1]);
		for(R int i=2;i<now;i++) tans=tans*(st[i]>=0?(10-st[i]):(10+st[i]));
		ans+=len&1?tans*10:tans;
		return ;
	}
	if(sum+10ll*(base[len-now]-base[now-1])<D) return ;
	if(sum-10ll*(base[len-now]-base[now-1])>D) return ;
	for(R int ss=(now==1?-8:-9);ss<=(now==1?8:9);ss++)
	{
		st[now]=ss;
		dfs(now+1,len,sum+st[now]*(base[len-now]-base[now-1]));
	}
	return ;
}

int main()
{
	scanf("%d",&D);
	base[0]=1;
	for(R int i=1;i<=18;i++) base[i]=base[i-1]*10;
	for(R int i=1;i<=18;i++) dfs(1,i,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	for {
		n := nextInt()
		if n == 0 {
			break
		}
		an := make([]int, n)
		min := 1000000
		for i := 0; i < n; i++ {
			an[i] = nextInt()
		}
		sort.Ints(an)
		for i := 1; i < n; i++ {
			sub := an[i] - an[i-1]
			if min > sub {
				min = sub
			}
		}
		fmt.Println(min)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}



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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<ll> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  sort(va.begin(), va.end(), greater<ll>());

  vector<ll> vb;
  for (int i = 1; i < va.size(); ++i) {
    vb.push_back(va[i]);
    vb.push_back(va[i]);
  }

  ll ans = va.front();
  for (int i = 0; i < n - 2; ++i) {
    ans += vb[i];
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int A, B;
    cin >> A >> B;
    int ans = 0;
    FOR(i, A, B + 1){
        int s[5];
        s[0] = i % 10;
        s[1] = (i / 10) % 10;
        s[3] = (i / 1000) % 10;
        s[4] = (i / 10000) % 10;
        if(s[0] == s[4] && s[1] == s[3]) ans++;
    }

    cout << ans;
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

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

int main () {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());

    int ans = 0;
    rep(i, k) ans += p[i];

    cout << ans;
}


Measured memory_bytes: 3656
class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納　xが根のとき-(サイズ)を格納
        self.par = [-1 for i in range(n)]
        self.n = n

    def find(self, x):
        #根ならその番号を返す
        if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_same(self, x, y):
        #根が同じならTrue
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return

        #木のサイズを比較し、小さいほうから大きいほうへつなぐ
        if self.par[x] > self.par[y]:
            x, y = y, x

        self.par[x] += self.par[y]
        self.par[y] = x

    def size(self, x):
        return -self.par[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = map(int, input().split())
graph = [set() for _ in range(N)]
block = [set() for _ in range(N)]
union = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    graph[a-1].add(b-1)
    graph[b-1].add(a-1)
    union.unite(a-1, b-1)
for i in range(K):
    a, b = map(int, input().split())
    block[a-1].add(b-1)
    block[b-1].add(a-1)

blocking = [0] * N
for i, blo in enumerate(block):
    for b in blo:
        if union.is_same(i, b):
            blocking[i] += 1

for i in range(N):
    ans = union.size(i) - len(graph[i]) - blocking[i] - 1
    print(ans)


Measured memory_bytes: 75292
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b==c+d) printf("Balanced\n");
	else if(a+b>c+d) printf("Left\n");
	else printf("Right\n");
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		
		int[]list  = new int[N];
		int all = 0;
		for(int i=0; i<N; i++){
			list[i] = sc.nextInt();
			all += list[i];
}
	if(H <= all){
		System.out.println("Yes");
	}else{
		System.out.println("No");
	}
}
}


Measured memory_bytes: 50208
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H,W,N;
    cin>> H>>W>>N;
    if(N>=1){
        int X[N], Y[N], Z[N];
        rep(i,0,N) {
            cin>>X[i]>>Y[i];
            Z[i]=X[i]-Y[i];
        }
        P p[N];
        rep(i,0,N) p[i]=make_pair(X[i], Z[i]);
        sort(p,p+N);
        int temp1=0, temp2=0;
        if(p[temp1].second>=1) {
            cout<<p[temp1].first-1<<"\n";
            return 0;
        }
        else{
            rep(i,1,N){
                if(p[temp2].first<p[i].first&&p[temp2].second<p[i].second){
                    if(p[i].second>max(p[temp2].second+1,0)){
                        if(temp1==0){
                            if(!(p[temp1].first+1==p[i].first&&p[temp1].second+1==p[i].second)){
                                cout<<p[i].first-1<<"\n";
                                return 0;
                            }
                        }
                        else{
                            if(!(p[temp1].first+1==p[i].first&&p[temp1].second+1==p[i].second)&&!(p[temp1-1].first+1==p[i].first&&p[temp1-1].second+1==p[i].second)){
                                cout<<p[i].first-1<<"\n";
                                return 0;
                            }
                        }
                    }
                    temp1=temp2;
                    temp2=i;
                }
                else{
                    if(p[temp2].first==p[i].first){
                        if(p[i].second>max(p[temp1].second+1,0)){
                            if(temp1==0){
                                if(!(p[temp1].first+1==p[i].first&&p[temp1].second+1==p[i].second)){
                                    cout<<p[i].first-1<<"\n";
                                    return 0;
                                }
                            }
                            else{
                                if(!(p[temp1].first+1==p[i].first&&p[temp1].second+1==p[i].second)&&!(p[temp1-1].first+1==p[i].first&&p[temp1-1].second+1==p[i].second)){
                                    cout<<p[i].first-1<<"\n";
                                    return 0;
                                }
                            }
                        }
                        temp2++;
                    }
                }
            }
        }
        cout<<H<<"\n";
    }
    else cout<<H<<"\n";
}


Measured memory_bytes: 4224
N = int(input())
dp = [10 ** 6] * (N + 1)
dp[0] = 0

for i in range(N+1):
    p = 1
    while p <= N:
        dp[i] = min(dp[i], dp[i-p] + 1)
        p *= 6
    p = 1
    while p <= N:
        dp[i] = min(dp[i], dp[i-p] + 1)
        p *= 9

print(dp[N])

Measured memory_bytes: 3828
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	h: usize,
        a: usize,
    }
    println!("{}", calc(h, a));
}

fn calc(h:usize, a:usize) -> usize {
	if h%a>0 { h/a+1 } else { h/a}
}

Measured memory_bytes: 4476
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    string s;
    cin >>n >>k;
    cin >>s;
    for(int i = 0; i < n; i++){
        if(i == k - 1)
            cout <<(char)tolower(s[i]);
        else 
            cout <<s[i];
    }
    return 0;
}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

string s;
int N, Q;

bool ok(int m, vector<char> t, vector<char> d, char dir) {
    int p = m;
    char cur = s[p];
    for (int i = 0; i < Q; i++) {
        if (t[i] == cur) {
            if ((p == ((dir == 'L') ? 1 : N)) and d[i] == dir) {
                return true;
            }
            p += (d[i] == 'L') ? -1 : 1;
            cur = s[p];
        }
    }
    return false;
}

int main() {
    cin >> N >> Q;
    cin >> s;
    s = ' ' + s;

    vector<char> t(Q), d(Q);
    for (int i = 0; i < Q; i++) {
        cin >> t[i] >> d[i];
    }

    int ans = N;
    int ansL = 0, ansR = N + 1;
    int left = 0, right = N + 1;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (ok(mid, t, d, 'L'))left = mid;
        else right = mid;
    }
    ansL = left;

    left = 0, right = N + 1;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (ok(mid, t, d, 'R'))right = mid;
        else left = mid;
    }
    ansR = right;

    cout << ansR - ansL - 1 << endl;

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define int long long
//int  solve(int n){
//    if(n%2!=0){
//        return (n/2)+1;
//    }
//    else{
//        return (n/2);
//    }
//}
signed main(){
    int ans=-1;
    for(int i=0;i<6;i++){
        int x;cin>>x;
        if(x==0 && ans==-1){
            ans=i;
        }
    }
    cout<<ans+1<<"\n";
}

Measured memory_bytes: 3600
MAX = 50025
SQRT = 223     # sqrt(MAX)
 
prime = [True for i in range(MAX)]
def sieve():
    for i in range(4, MAX, 2):
        prime[i] = False
    for i in range(3, SQRT, 2):
        if prime[i] is True:
            for j in range(i*i, MAX, i):
                prime[j] = False
sieve()
 
while True:
    try:
        n = int(input())
    except EOFError:
        break
         
    for i in range(n-1, 1, -1):
        if prime[i]:
            a = i
            break
    for i in range(n+1, MAX):
        if prime[i]:
            b = i
            break   
    print(a, b)



Measured memory_bytes: 5912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=51;
int n,k;
ll ans,x[N<<2],y[N<<2],p[N<<2][2];
bool check(ll x,ll a,ll b){
	if(a<b){
		if(x>=a&&x<=b) return 1;
	}
	else{
		if(x<=a&&x>=b) return 1;
	}
	return 0;
}
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		x[i]=a;y[i]=b;
		p[i][0]=a;p[i][1]=b;
	}
	sort(x+1,x+1+n);sort(y+1,y+1+n);
	ans=9e18;
	for(int a=1;a<=n;++a)
		for(int b=1;b<=n;++b)
			for(int c=1;c<=n;++c)
				for(int d=1;d<=n;++d){
					ll tmp=abs(x[a]-x[b])*abs(y[c]-y[d]);
					if(tmp==0) continue;
					int cnt=0;
					for(int i=1;i<=n;++i) if(check(p[i][0],x[a],x[b])&&check(p[i][1],y[c],y[d])) cnt++;
//					if(cnt>=k) printf("%lld\n",tmp);
					if(cnt>=k&&tmp<ans) ans=tmp;
				}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int N; cin >> N;
    cout << (N / 2) + (N % 2);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

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

ll faster(int N, vector<ll>& As) {
  vector<ll> table(N+1);
  map<ll, ll> seen;
  seen[0] = 1;
  ll ans = 0;
  REP(n,N) {
    table[n+1] = table[n] + As[n];
    ans += seen[table[n+1]];
    seen[table[n+1]]++;
//    cout << "n, ans = " << n << "," << ans << endl;
  }
  return ans;
}


int main(void) {
  int N; cin >> N;
  vector<ll> As(N);
  REP(n,N) cin >> As[n];

  auto ans = faster(N, As);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15872
N = int(input())
p_array = []
price_sum = 0
price_max = 0
for _ in range(N):
    price = int(input())
    #都度、足していく
    price_sum += price
    #都度、最大値を更新していく
    price_max = max(price, price_max)

print(price_sum - price_max//2)

Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
#define MAXN 1000010
#define ll long long 
using namespace std;
int main()
{
    ll n,a,b,x1,x2,k;
    cin>>n>>a>>b;
    x1=n%(a+b);
    x2=n/(a+b);
    if(x1>a)
    k=a;
    else
    {
        k=x1;
    }
    cout<<x2*a+k<<"\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const long long MOD=1000000007,MAXM=100005;

struct Matrix
{
	long long h,w;
	long long A[4][4];

    long long * operator [] (long long i)
    {return A[i];}
    const long long * operator [] (long long i) const
    {return A[i];}

	Matrix(){h=w=0;}
	Matrix(long long _h,long long _w)
	{
		h=_h;w=_w;
		for(long long i=0;i<h;i++)
			for(long long j=0;j<w;j++)
				A[i][j]=0;
	}
	Matrix operator * (const Matrix &t)
	{
		if(w!=t.h)return Matrix();
		Matrix res(h,t.w);
		for(long long i=0;i<h;i++)
			for(long long j=0;j<t.w;j++)
				for(long long k=0;k<w;k++)
					res.A[i][j]=(res.A[i][j]+(1LL*A[i][k]*t.A[k][j])%MOD)%MOD;
		return res;
	}
	Matrix pow(long long n)const
	{
		if(h!=w)return Matrix();
		Matrix res(h,w);
		Matrix f=(*this);
		for(long long i=0;i<4;i++)
			for(long long j=0;j<4;j++)
				res.A[i][j]=(i==j);
		while(n)
		{
			if(n&1LL)
				res=res*f;
			f=f*f;
			n>>=1LL;
		}
		return res;
	}
};

/*
dp[0]=S[0]=T[0]=1;

dp[i]=dp[i-1]+S[i-1]+2*T[i-2];
 S[i]=dp[i]+S[i-1];
 T[i-1]=S[i-1]+T[i-2];

dp[i-1]     {1,1,2}   dp[i]
 S[i-1]  *  {1,2,2} =  S[i]
 T[i-2]     {0,1,1}    T[i-1]
*/

long long N,M,X[MAXM];
Matrix f,g;

int main()
{
    scanf("%lld%lld",&N,&M);
    for(long long i=1;i<=M;i++)
        scanf("%lld",&X[i]);

    f=Matrix(3,3);
    f[0][0]=1;f[0][1]=1;f[0][2]=2;
    f[1][0]=1;f[1][1]=2;f[1][2]=2;
    f[2][0]=0;f[2][1]=1;f[2][2]=1;

    long long dp=1,S=2,T=1,tdp,tS,tT;
    if(X[1]==1)
        S=1;
    X[0]=1;
    X[M+1]=N;
    for(long long i=1+(X[1]==1);i<=M+1;i++)
    {
        g=f.pow(X[i]-X[i-1]);
        tdp=(1LL*dp*g[0][0]%MOD+1LL*S*g[0][1]%MOD+1LL*T*g[0][2]%MOD)%MOD;
        tS=(1LL*dp*g[1][0]%MOD+1LL*S*g[1][1]%MOD+1LL*T*g[1][2]%MOD)%MOD;
        tT=(1LL*dp*g[2][0]%MOD+1LL*S*g[2][1]%MOD+1LL*T*g[2][2]%MOD)%MOD;
        dp=tdp;S=tS;T=tT;

        S=(S-dp+MOD)%MOD;
    }

    printf("%lld\n",dp);

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}


struct ConvexHullTrick{
  std::deque<std::pair<long long, long long> > dq; //（傾き、切片）

  void add(long long a, long long b){
    std::pair<long long, long long> p0=std::make_pair(a, b);
    while(dq.size()>=2){
      int sz=dq.size();
      std::pair<long long, long long> p1=dq[sz-1];
      std::pair<long long, long long> p2=dq[sz-2];
      if((p0.second-p1.second)*(p0.first-p2.first) < (p0.second-p2.second)*(p0.first-p1.first))break;//交点のx座標を比較
      dq.pop_back();
    }
    dq.push_back(p0);
  }

  long long query(long long x){
    while(dq.size()>=2){
      long long v1=dq[0].first*x+dq[0].second;
      long long v2=dq[1].first*x+dq[1].second;
      if(v1<=v2)break;
      dq.pop_front();
    }
    return dq[0].first*x+dq[0].second;
  }

};

int main(){
  ll n,c;cin >>  n >> c;
  vl h(n);rep(i,n)cin >> h[i];
  vl dp(n);
  ConvexHullTrick ch;
  rep(i,n){
    if(i!=0){
      dp[i]=h[i]*h[i]+c+ch.query(h[i]);
    }
    ch.add(-h[i]*2,h[i]*h[i]+dp[i]);
  }
  //rep(i,n)cout << dp[i] <<" ";cout << endl;
  cout << dp[n-1] <<endl;
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

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

    vector<ll> a(100001);

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

    int Q;
    cin >> Q;
    rep(q, Q) {
        ll B,C;
        cin >> B >> C;

        sum -= (B*a[B]);
        sum += (C*a[B]);

        a[C] += a[B];
        a[B] = 0;

        cout << sum << endl;
    }
}


Measured memory_bytes: 3996
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <bits/stdc++.h>

#define mod 104857601
#define pb push_back
#define ep emplace_back
#define fr first
#define sc second
#define linf  (((1ll << 62) - 1) << 1)
#define inf (((1 << 30) - 1) << 1)

const double eps = 0.000000001;
#define ll long long
#define leps 1e-18
#define mkp make_pair
#define mpi unordered_map<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) begin(v), end(v)
#define vi vector<int>
#define vvi vector<vi>

using namespace std;

// ==============================Utils=================================//
random_device rd;
mt19937 mt(rd());

const int N_ = 100001;
vector<int> primes;
int *least_prime;
void cieve() {
  least_prime = new int[N_];
  fill(least_prime, least_prime + N_, -1);

  for (int i = 2; i < N_; i++) {
    if (least_prime[i] == -1) {
      least_prime[i] = i;
      primes.pb(i);
    }
    for (auto &c: primes) {
      if (c * i >= N_ || c > least_prime[i]) break;
      least_prime[c * i] = c;
    }
  }
}

template<typename NType>
NType gcd(NType a, NType b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template<typename NType>
NType lcm(NType a, NType b) { return a / gcd(a, b) * b; }
template<typename NType>
NType phi(NType n_) {
  NType ans = n_;
  for (NType i = 2; i * i <= n_; i++) {
    if (n_ % i == 0) {
      while (n_ % i == 0) n_ /= i;
      ans -= ans / i;
    }
  }
  if (n_ > 1) ans -= ans / n_;
  return ans;
}

int binpow(ll a, int n, const int M = mod) {
  ll res = 1;
  while (n) {
    if (n & 1) {
      res = (a * res) % M;
      n--;
    } else {
      a = (a * a) % M;
      n >>= 1;
    }
  }
  ((res %= M) += M) %= M;
  return res;
}
// ==========================End of Utils==============================//

void solve(int _T) {
  int n;
  cin >> n;
  vector<ll>v(n);
  for(int i = 0; i < n; i ++) cin >> v[i];

  int cnt{};
  for(int i = 0; i < n; i ++){
    for(int j = i + 1; j < n; j ++){
      for(int k = j + 1; k < n; k ++){
        if(v[i] == v[j]) continue;
        if(v[j] == v[k]) continue;
        if(v[i] == v[k]) continue;
        ll mx = max(v[i], max(v[j], v[k]));
        if(mx * 2 < v[i] + v[j] + v[k]) {
          cnt ++;
        }
      }
    }
  }
  cout << cnt << endl;
}

#define MULTIPLE_TEST 0
#define PRECALC_CIEVE 0
int main(int argc, char const *argv[]) {
//  freopen("traffic.in", "r", stdin);
//  freopen("traffic.out", "w", stdout);

  int t{1};
  if (MULTIPLE_TEST) scanf("%d\n", &t);
  if (PRECALC_CIEVE) cieve();

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

  int i{0};
  while (t --> 0) {
    solve(++i);
  }
}
/*

3 1 2
1 2
1 1

 */

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

int main(){
    string s;
    cin >> s;
    vector<string> t(8);
    for(int i=0;i<8;i++){
        for(int j=0;j<4;j++){
            t[i]+=s[j];
            if(j==3) break;
            if((i>>j)%2 and 1) t[i]+='+';
            else t[i]+='-';
        }
    }
    int ans=s[0]-'0';
    for(int i=0;i<8;i++){
        int ans=(s[0]-'0');
        for(int j=1;j<=5;j+=2){
            if(t[i][j]=='-') ans-=t[i][j+1]-'0';
            else ans+=t[i][j+1]-'0';
        }
        if(ans==7){
            cout << t[i] << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3564
#include<cstdio>
#define MAXN 100010
int gcd(int a,int b)
{
	while(b)
	{
		int t=a;a=b;b=t%b;
	}
	return a;
}
int n,a[MAXN];
bool dfs()
{
	int cnt0=0,cnt1=0;
	for(int i=1;i<=n;i++)
		(a[i]&1)?cnt1++:cnt0++;
	if(cnt0&1) return 1;
	if(cnt1>1) return 0;
	for(int i=1;i<=n;i++)
		if(a[i]&1)
		{
			if(a[i]==1) return 0;
			a[i]--;
			break;
		}
	int d=a[1];
	for(int i=2;i<=n;i++)
		d=gcd(a[i],d);
	for(int i=1;i<=n;i++)
		a[i]/=d;
	return !dfs();
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(dfs()) printf("First\n");
	else printf("Second\n");
}

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

int main() {
  int x,y;
  cin >> x >> y;
  
  vector<int> vec = {1,3,1,2,1,2,1,1,2,1,2,1};
  
  if(vec.at(x-1) == vec.at(y-1)) {
    cout << "Yes" <<endl;
  }
  
  else {
    cout << "No" <<endl;
  }
  
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

string s;
int k;

int main() {
    cin >> s;
    cin >> k;
    forn(i, (int)s.length() - 1) {
        int need = 26 - (s[i] - 'a');
        if (need == 26) need = 0;
        //cerr << need << endl;
        if (need <= k) {
            k -= need;
            s[i] = 'a';
        }
    }
    int sz = (int)s.length();
    int cur = s[sz - 1] - 'a';
    cur += k;
    cur %= 26;
    s[sz - 1] = char('a' + cur);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {{
        let s = getline();
        let iter = s.trim().split(' ');
        iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    };
}
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display,
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn eratosthenes(n: usize) -> Vec<bool> {
    let n = n + 1;
    let mut res = vec![true; n];
    res[0] = false;
    res[1] = false;
    for i in (2..).take_while(|i| i * i <= n) {
        let mut j = i*2;
        while j < n {
            res[j] = false;
            j += i;
        }
    }
    res
}

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }

    let n = readl!(usize);
    // debug!(eratosthenes(10));
    let era = eratosthenes(55555);
    let ans = era.into_iter()
        .enumerate()
        .filter(|&(i, f)| f && i % 5 == 1)
        .map(|x| x.0)
        .take(n);
    printfln!("{}", show(ans));
}


Measured memory_bytes: 4352
n=int(input())
a=list(map(float, input().split()))
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(n):
        if dp[i][j]==0:continue
        dp[i+1][j+1]+=dp[i][j]*a[i]
        dp[i+1][j]+=dp[i][j]*(1-a[i])
print(sum(dp[-1][n//2+1:]))

Measured memory_bytes: 269320
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    double r = scan.nextDouble();
    System.out.printf("%f %f",r*r*Math.PI,2*r*Math.PI);
    scan.close();
  }
}


Measured memory_bytes: 28332
from math import ceil, floor, log, sqrt


def solve(string):
    x = int(string)
    ans = [1]
    for i in range(2, floor(sqrt(x)) + 1):
        ans.append(i**floor(log(x, i)))
        if i**ceil(log(x, i)) <= x:
            ans.append(i**ceil(log(x, i)))
    return str(max(ans))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3060
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();
		String sD = "";
		String tD = "";
		List<String> sList = new ArrayList<String>();
		List<String> tList = new ArrayList<String>();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < s.length(); i++) {
			sList.add(s.substring(i, i + 1));
		}
		for(int i = 0; i < t.length(); i++) {
			tList.add(t.substring(i, i + 1));
		}
		Collections.sort(sList);
		Collections.sort(tList, Collections.reverseOrder());
		for(int i = 0; i < sList.size(); i++) {
			sD += sList.get(i);
		}
		for(int i = 0; i < tList.size(); i++) {
			tD += tList.get(i);
		}
		list.add(sD);
		list.add(tD);
		Collections.sort(list);
		if(sD.equals(list.get(0)) && !sD.equals(tD)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		scan.close();

	}

}


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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	int cnt = 0;
	rep(i, n) {
		cin >> p[i];
		if (p[i] != (i + 1)) {
			cnt++;
		}
	}
	if (cnt <= 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main(){
  ll N,M;
  ll mod = 1e9+7;
  cin >> N >> M;
  vector<ll> hole(N,0);
  for(ll i=0;i<M;++i){
    ll a;
    cin >> a;
    hole[a]=1;
  }
  ll dp[N+10];
  fill(dp,dp+N+10,0);
  dp[0]=1;
	for(ll i=0; i<N+5; i++){
		if(hole[i]) continue;
		dp[i+1] = (dp[i+1]+dp[i])%mod;
		dp[i+2] = (dp[i+2]+dp[i])%mod;
	}
  cout << dp[N] << endl;
}

Measured memory_bytes: 1792