akhauriyash/Code-Regression huggingface dataset:
N,K=map(int,input().split())
V=list(map(int,input().split()))
from collections import deque
#K=min(N,K)
ans=-10**10
for k in range(0,min(K+1, N+1)):
    for n in range(0,k+1):
        A=V[0:n]+V[N-(k-n):]
        if len(A)==0:
            A=[0]
        A.sort()
        tmp=sum(A)
        for i in range(0, min(K-k,len(A))):
            if A[i]<0:
                tmp-=A[i]
            else:
                break
        if ans<tmp:
            ans=tmp
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a = 0;
  int b = 0;
  cin >> a >> b;
  int iDiv = (a + b) /2;
  double dDiv =  (double)(a + b) /2;
  int output = 0;
  if (dDiv - iDiv >= 0.5) {
    output = iDiv + 1;
  } else {
    output = iDiv;
  }
  cout << output  << endl;
}

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

class Main {

	public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(in.readLine());
        System.out.println(x*x*x);
        
	}

}

Measured memory_bytes: 16928
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 1e9;
  for (int i = 0; i < s.size() - 2; i++) {
	  ans = min(ans, abs(753 - stoi(s.substr(i, 3))));
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
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() {
	A, P := nextInt(), nextInt()
	fmt.Println((A*3 + P) / 2)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    p = list(map(int, input().split()))
    
    a = [(int(x)+1)*30000 for x in range(n)]
    b = [int(x)*30000 for x in range(n, 0, -1)]
    
    for i in range(n):
        v = p[i]-1
        a[v] += i+1
        b[v] += i+1
        
    print(*a)
    print(*b)
    
    
    
if __name__ == "__main__":
    main()


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

int main() {
	string s, t;
	cin >> s >> t;
	t.pop_back();      //末尾を削除
	if (s == t)
		cout << "Yes" << endl;


	else
		cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

static const int MOD = 1e+9 + 7;

unordered_map<int, int> fact(int x)
{
    unordered_map<int, int> prime_counts;

    int size = (int)sqrt(x) + 1;
    for (int i = 2; i <= size; ++i) {
        while (x % i == 0) {
            x /= i;
            ++prime_counts[i];
        }
    }

    if (x > 1) {
        ++prime_counts[x];
    }

    return prime_counts;
}

template<class T>
T modpow(T base, T exp, T mod)
{
    base %= mod;
    T res = 1;

    while (exp > 0) {
        if (exp & 1) {
            res = (res * base) % mod;
        }

        base = (base * base) % mod;
        exp >>= 1;
    }

    return res;
}

ll comb(int n, int k)
{
    ll x = 1;

    for (int i = n; i >= n - k + 1; --i) {
        x = (x * i) % MOD;
    }

    for (int i = 1; i <= k; ++i) {
        x = (x * modpow<ll>(i, MOD-2, MOD)) % MOD;
    }

    return x;
}

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

    auto f = fact(M);

    int ans = 1;

    for(auto&& fi : f) {
        int b = fi.second;

        ans = (ans * comb(b + N - 1, b)) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007


int main() {
	long long int x, y;
	cin >> x >> y;

	int cnt = 0;
	for (int i = 0; y >= (long long int)(x * pow(2, i)); i++) {
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        X.at(i) = A.at(i);
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) {
        if (X.at(i) <= A.at(N/2-1)) cout << A.at(N/2) << endl;
        else cout << A.at(N/2-1) << endl;;
    }
}

Measured memory_bytes: 4776
#include <stdio.h>
#include <math.h>
#define MAX 20

double d;
int n, b;
struct data{
	double hi, li;
};
data targ[MAX];

double go(double D){
	int i, j;
	data t[MAX];
	double vx=100000000.0, vy;
	for (i=1;i<=n;i++){
		t[i]=targ[i];
		for (;;){
			if (t[i].li<=D) break;
			t[i].li-=D;
		}
		double k;
		k=D*t[i].li-t[i].li*t[i].li;
		k/=(2.0*t[i].hi);
		if (vx>sqrt(k)) vx=sqrt(k);
	}

	if (vx>sqrt(D/2)) return sqrt(D);
	else{
		vy=D/(2*vx);
		return sqrt(vx*vx+vy*vy);
	}
}

int main(void){
	int i;
	double ret, ans=10000000000.0;
	scanf("%lf %d %d", &d, &n, &b);
	for (i=1;i<=n;i++) scanf("%lf %lf", &targ[i].li, &targ[i].hi);
	for (i=0;i<=b;i++){
		ret=go(d/(double)(i+1));
		if (ret<ans) ans=ret;
	}
	printf("%.6lf\n", ans);
	return false;
}

Measured memory_bytes: 1072
/* created   : 2019-09-04 00:54:58
 * accepted  : 2019-09-04 00:55:58
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n; cin >> n;
  cout << (ll) (n - 1) * (1 + n - 1) / 2 << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string s;
    cin >> s;

    cout << s.rfind('Z') - s.find('A') + 1 << endl;

    return 0;
}


Measured memory_bytes: 832
using System;

namespace teisyutusensei
{
    class Program
    {
        static void Main(string[] args)
        {
            
            ////?????????????????????
            string dmmy = Console.ReadLine();

            //string[] input = dmmy.Split(' ');

            int dmmy1 = int.Parse(dmmy);

            int result = 0;

            result = dmmy1 * dmmy1 * dmmy1;

            Console.WriteLine(result);  
            Console.ReadLine();
        }
    }

}

Measured memory_bytes: 5596
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			for (int j = i; j < s.length() + 1; j++) {
				String tmp = s.substring(i, j);
				if (tmp.replace("A", "").replace("T", "").replace("G", "").replace("C", "").equals("")) {
					ans = ans < (j - i) ? j - i : ans;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24148
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j;
            cin>>n;
            for(i=1;i<=9;++i)
                for(j=1;j<=9;++j)
                {
                    if(i*j==n)
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
                cout<<"No"<<endl;
        }
        return 0;
    }


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

int main()
{
    long long a, b, fnl, GCD;
    cin >> a >> b;

    fnl = a * b;

    GCD = __gcd(a, __gcd(b, fnl));

    fnl =  fnl / GCD;

    cout << fnl << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = 0; i <= a; i++)
    for(int j = 0; j <= b; j++)
      for(int k = 0; k <= c; k++)
        if(500*i+100*j+50*k == x)
          ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		long sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		long sunuke = 0, dif = Long.MAX_VALUE;
		for (int i = 0; i < n - 1; i++) {
			sum = sum - a[i];
			sunuke += a[i];
			dif = Math.min(dif, Math.abs(sum - sunuke));
		}
		System.out.println(dif);
	}
}


Measured memory_bytes: 65564
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

void assign_if(int& a0, const int& a1) {
    if (a1 < a0) a0 = a1;
}

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

    const int C = 100 * n;
    const int M = 400;
    int dp[M + 1][M + 1];
    fill_n(&dp[0][0], sizeof(dp) / sizeof(dp[0][0]), C + 1);
    dp[0][0] = 0;

    for (int h = 0; h < n; h++) {
        int a, b, c;
        cin >> a >> b >> c;
        for (int i = M - a; i >= 0; i--) {
            for (int j = M - b; j >= 0; j--) {
                assign_if(dp[i + a][j + b], dp[i][j] + c);
            }
        }
    }

    int r = C + 1;
    dp[0][0] = r;
    for (int i = 0; i <= M; i++) {
        for (int j = 0; j <= M; j++) {
            if (i * mb == ma * j) assign_if(r, dp[i][j]);
        }
    }

    cout << (r <= C ? r : -1) << endl;

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n;
    cin >> n;
    for (ll i = n; i <= 999; ++i) {
        auto a = i / 100;
        auto b = (i / 10) % 10;
        auto c = i % 10;
        if (a == b && b == c) {
            cout << i << endl;
            break;
        }
    }
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto &x : A) {
		cin >> x;
	}
	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += A[i] / 2;
		A[i] %= 2;
		if (A[i] != 0 && i + 1 < N && A[i + 1] != 0) {
			--A[i];
			--A[i + 1];
			++ans;
		}
	}
	cout << ans << endl;
}


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

using namespace std;

#define inti long long int

int main()
{
    inti i,j,k,n,m,x,y,z;
    cin>>x>>n;
    inti arr[n+2];
    for(i=1;i<=n;i++)cin>>arr[i];
 //   sort(arr+1,arr+n+1);

    int frr[105];
    for(i=0;i<=105;i++)frr[i]=1;

    for(i=1;i<=n;i++){
        frr[arr[i]]=0;
    }

    inti mini=INT_MAX,ans;
    for(i=0;i<=102;i++){
        if(frr[i]==1){
            if(abs(i-x)<mini){
                ans=i;
                mini=abs(i-x);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

const lint mod = MOD;
class mint{
    public:
        long long x;

    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};

int main(){
    lint n_, k_; cin >> n_ >> k_;
    mint n = n_, k = k_;
    mint ans = 0;
    for (lint i = k_; i <= n_+1; i++){
        mint j = i;
        ans += (n+1-j)*j + 1;
    }

    out(ans);
    
}

Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc115/tasks/abc115_a

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

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

    cout << "Christmas";
    for (int i = 0; i < 25 - d; i++) {
        cout << " Eve";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())

a = list(map(int,input().split()))

x = len(a)

Alice = 0
Bob = 0

for i in range(x):
    for j in range(x - 1 - i):
        if a[j] < a[j + 1]:
            tmp = a[j]
            a[j] = a[j + 1]
            a[j + 1] = tmp

for i in range(x):
    if i % 2 == 0:
        Alice += a[i]
    else:
        Bob += a[i]

   
z = Alice - Bob

print(z)

Measured memory_bytes: 3064
n, k = map(int, raw_input().split())
A = map(int, raw_input().split())
B = [0]*(n+1)
C = [0]*(n+1)
for i in xrange(n):
    B[i+1] = B[i] + A[i]
    C[i+1] = C[i] + A[i]*(A[i] > 0)
print max(C[i] + C[n]-C[i+k] + max(B[i+k]-B[i], 0) for i in xrange(n-k+1))

Measured memory_bytes: 12228
s = input()
k = int(input())

ans = 0
now = 0
flag = 1
onaji = False
kazu = 1

if len(s) == 1:
    print(int(k//2))
    exit()

for i in range(len(s)):
    #print(i,now,ans,flag)
    if now >= len(s) - 1:
        break
    if s[now] == s[now+1]:
       ans += 1
       if now+1 == len(s) -1:
           flag = 0
       now += 2
    else:
        now += 1

if len(s) == 2:
    print(int(ans*k))
    exit()

for i in range(len(s)-1):
    if s[i] != s[i+1]:
        break
    kazu += 1
    if i == len(s) - 2:
        onaji = True

if flag == 1:
    if s[0] == s[-1]:
        if s[0] == s[1]:
            flag = 2
        else:
            flag = 1
    else:
        flag = 0
#print(flag)

if flag != 2:
    print(int(ans*k+flag*(k-1)))
else:
    if onaji == True:
        print(int(ans*k+k//2))
    else:
        if kazu % 2 == 0:
            print(int(ans*k))
        else:
            print(int(ans*k+1*(k-1)))
        
#print(ans,ans*k,ans*k+flag*(k-1))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int l,r,MOD=2019,min=50000000000,i,j;
    cin >> l >> r;
    for(i=l;i<r;i++)
    {
        for(j=i+1;j<=r;j++)
        {
            if(min>(i%MOD)*(j%MOD)%MOD)
            {
                min=(i%MOD)*(j%MOD)%MOD;
            }
            if(min==0)
            {
                cout << min << endl;
                return 0;
                break;
            }
        }
    }
    cout << min << endl;
                                    
    return 0;

}


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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int64_t N, ans = 0;
    cin >> N;
    vector<int64_t> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    for (int i = 1; i < N; i++)
    {
        if (list[i - 1] > list[i])
        {
            ans += list[i - 1] - list[i];
            list[i] = list[i - 1];
        }
    }
    cout << ans;
}

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

const ll INF = 1LL << 60;

struct Edge {
	int from;
	int to;
	int cost;
};

int main() {
  int n, m, p;
	cin >> n >> m >> p;
	vector<Edge> g(m);
	rep(i, m) {
		cin >> g[i].from >> g[i].to >> g[i].cost;
		g[i].from--, g[i].to--;
		g[i].cost = p - g[i].cost;
	}
	
	vector<ll> ans(n, INF);
	ans[0] = 0;
	rep(i, n) {
		rep(j, m) {
			Edge e = g[j];
			if (ans[e.from] == INF) continue;
			if (ans[e.from] + e.cost < ans[e.to]) {
				ans[e.to] = ans[e.from] + e.cost;
			}
		}
	}
	
	vector<bool> neg(n, false);
	rep(i, n) {
		rep(j, m) {
			Edge e = g[j];
			if (ans[e.from] == INF) continue;
			if (ans[e.from] + e.cost < ans[e.to]) {
				ans[e.to] = ans[e.from] + e.cost;
				neg[e.to] = true;
			}
			if (neg[e.from]) neg[e.to] = true;
		}
	}
	
	if (neg[n - 1]) cout << -1 << endl;
	else if (ans[n - 1] < 0) cout << -ans[n - 1] << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3688
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := nextInt(sc)
	b := nextInt(sc)
	c := nextInt(sc)

	var cnt int64
	for i := a; i <= b; i++ {
		if c%i == 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1108
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main(void) {

    int N, M;
    cin >> N >> M;
    int a[M];
    int sum = 0; 
    rep(i,M) cin >> a[i];
    rep(i,M) sum += a[i];
    int ans = N - sum;
    if (ans < 0) ans = -1;
    out(ans);


    


    return 0;
}











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



int main(){
int a,b,c,d,e,f;
cin >> a >> b >> c >> d >> e >> f;
double conc = -1.0;
int xmax  = 0;
int ymax = 0;
rep(i,f){
    rep(j,f){
        int y = i*c+j*d;//砂糖の量計算
        if(y<=f){
            for (int k = 0; k < f; k+=100){
                for (int l = 0; l < f; l+=100){
                    int x = k*a+l*b;//水の量計算
                    if(x>f || x<=0) continue;//xの条件
                    if(x+y>f)continue;//xy合計条件
                    if(100*y>x*e)continue;//飽和条件

                    if(conc*(x+y) < y){
                         ymax = y;
                         xmax = x;
                        conc = double(y)/double(x+y);
                    }

                }
                
            }
            
        }



    }
}


cout << xmax+ymax << " " << ymax << endl;


}

Measured memory_bytes: 256
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int k = nextInt();

    String s = next();
    String[] ss = splitString(s);

    int lng = ss.length;

    if(lng<=k){
      System.out.println(s);
    }
    else{
      for(int i=0;i<k;i++){
        System.out.print(ss[i]);
      }
      System.out.print("...");
    }



    //System.out.println();

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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


int a[15][1005];
int n,m,k;
int ans = 1e9;
int t[15],pre[15];


void inp()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            char c = 'a';
            while (c < '0' || c > '9') cin >> c;
            a[i][j] = c - '0';
            a[i][j] += a[i][j-1] + a[i-1][j] - a[i-1][j-1];
        }
    }
}





int doit(int x)
{
    int dem = 0;
    for (int i = 1; i < n; i++)
    {
        t[i] = (x >> (i-1)) & 1;
        dem += t[i];
        pre[i] = 0;
    }
    t[n] = 1;
    pre[n] = 0;
    pre[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        if (t[i-1]) pre[i] = i-1;
        else pre[i] = pre[i-1];
    }
    int last = 0,cur = 0;
    for (int i = 1; i <= m; i++)
    {
        bool b = false;
        for (int j = 1; j <= n; j++)
        if (t[j])
        {
            int tmp = a[j][i] - a[j][last] - a[pre[j]][i] + a[pre[j]][last];
            if (tmp > k)
            {
                b = true;
            }
        }

        if (b) last = i-1;

        for (int j = 1; j <= n; j++)
        if (t[j])
        {
            int tmp = a[j][i] - a[j][last] - a[pre[j]][i] + a[pre[j]][last];
            if (tmp > k)
            {
                return 1e9;
            }
        }


        if (last == i-1 && i > 1) dem++;
    }

    return dem;
}


void proc()
{
    for (int i = 0; i < (1 << (n-1)); i++)
    {
        ans = min(ans,doit(i));
    }
    cout << ans;
}



int main()
{
    inp();
    proc();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n;
    vector<double> v;
    cin>>n;
    rep(i,n)
    {
        double t;
        cin>>t;
        v.push_back(t);
    }
    int d=n-1;
    rep(i,d)
    {
        sort(v.begin(),v.end(),greater<double>());
        double a=v[v.size()-1];
        double b=v[v.size()-2];
        double nv=(a+b)/2;
        v.pop_back();
        v.pop_back();
        v.push_back(nv);
    }
    cout<<v[0]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<vector<int>> B(1);
  for (int i = 0; i < N; i++){
    if (B.back().size() == 0){
      B.back().push_back(A[i]);
    } else if (B.back().size() == 1){
      B.back().push_back(A[i]);
    } else if (B.back().front() == B.back().back()){
      B.back().push_back(A[i]);
    } else if (B.back().front() < B.back().back()){
      if (B.back().back() <= A[i]){
        B.back().push_back(A[i]);
      } else {
        B.push_back(vector<int>(1, A[i]));
      }
    } else {
      assert(B.back().front() > B.back().back());
      if (B.back().back() >= A[i]){
        B.back().push_back(A[i]);
      } else {
        B.push_back(vector<int>(1, A[i]));
      }
    }
  }
  cout << B.size() << endl;
}

Measured memory_bytes: 3256
import numpy as np

n = input()
v = input().split()
c = input().split()
N = int(n)
V = np.array(v, dtype=int)
C = np.array(c, dtype=int)

max_xy = 0

for i in range(N):
    if V[i] - C[i] > 0:
        max_xy += V[i] - C[i]
print(max_xy)

Measured memory_bytes: 12396
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"reflect"
	"strconv"
	"strings"
)

func mapf(f interface{}, list interface{}) interface{} {
	fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

	if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
		return nil
	}

	len := listv.Len()
	ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

	for i := 0; i < len; i++ {
		v := fv.Call([]reflect.Value{listv.Index(i)})
		ret.Index(i).Set(v[0])
	}

	return ret.Interface()
}

func readLine(reader *bufio.Reader, size int) string {
	buf := make([]byte, 0, size)
	for {
		line, p, err := reader.ReadLine()
		if err == io.EOF {
			break
		} else if err != nil {
			panic(err)
		}
		buf = append(buf, line...)

		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	size := 1000000
	reader := bufio.NewReaderSize(os.Stdin, size)
	readLine(reader, size)
	arr, _ := mapf(strconv.Atoi, strings.Split(readLine(reader, size), " ")).([]int)

	min, max, sum := arr[0], arr[0], 0
	for _, n := range arr {
		if n < min {
			min = n
		} else if n > max {
			max = n
		}
		sum += n
	}
	fmt.Printf("%d %d %d\n", min, max, sum)
}


Measured memory_bytes: 4368
#include<bits/stdc++.h>
#include <cstddef>
#include <cstdint>
using namespace std;
#define ll long long
int main()
{
  string S;
  cin>>S;
  ll s=0;
  int ans=0;
  ll b=(S[0]-'0')*pow(10,S.size()-1);
  ans+=S[0]-'0';
  reverse(S.begin(),S.end());
  for(int i=0;i<S.size();i++){
    s+=(S[i]-'0')*pow(10,i);
  }
  ll a=pow(10,S.size()-1);
  ans+=(S.size()-1)*9;
  a-=1;
  if(s<a+b){
    b-=pow(10,S.size()-1);
    ans--;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    set<string> st;
    string s;
    REP(i, n) {
        cin >> s;
        st.emplace(s);
    }
    cout << sz(st) << endl;
}

Measured memory_bytes: 19208
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int an() {
    int a,b;
    cin>>a>>b;
    int n1=a;
    int n2=b;
    int max = (n1 > n2) ? n1 : n2;
    do
    {
        if (max % n1 == 0 && max % n2 == 0)
        {
            cout << max;
            break;
        }
        else
            ++max;
    } while (true);
	return 0;
}
 
int main(void) {
    ll a,b;
    cin>>a>>b;
    long long ans = a * b;
	if(a < b){swap(a, b);}
 
	int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  ans /= b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	int V[21], C[21];
	for (int i = 0; i < N; ++i)cin >> V[i];
	for (int i = 0; i < N; ++i)cin >> C[i];
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (V[i] - C[i] >= 0) {
			ans += V[i] - C[i];
		}
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;
#define ll long long int
ll a[200002],b[200002],pa[200002],pbb[200002];

int main(){
    int t=1;
    //cin >> t;
    while (t--) {
        ll n,m,x;
        cin >> n >> m >> x;
		for (ll i = 0; i < n; i++)
		{
			cin >> a[i];
			pa[i+1] = pa[i] + a[i];
		}
		for (ll i = 0; i < m; i++)
		{
			cin >> b[i];
			pbb[i+1] = pbb[i] + b[i];
		}
		ll ans = 0;
		for (ll i = 0; i <= n; i++)
		{
			if (pa[i] <= x)
			   ans = max(ans, i+(ll)(upper_bound(pbb, pbb+m+1, x-pa[i])-pbb-1));
			else
				break;
		}
		cout << ans << endl;
    }
    return 0;
}

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

int main() {
   int N;
   cin >> N;
   vector<int> a(N - 1), b(N - 1);

   for(int i = 0; i < N - 1; i++) {
       cin >> a[i] >> b[i];
       a[i]--; b[i]--;
   }

   vector<int> G[N];
   vector<pair<int, int>> E_in;
   for(int i = 0; i < N - 1; i++) {
       G[a[i]].emplace_back(b[i]);
       G[b[i]].emplace_back(a[i]);
       E_in.emplace_back(make_pair(a[i], b[i]));
   }

   
   queue<int> q;
   q.push(0);

   int used[N] = {0};
   int parent[N] = {0};
   map<pair<int, int>, int> E_out;
   used[0] = 1;
   int color_max = 0;
   while(!q.empty()) {
       int state = q.front();
       q.pop();
       int color_num = 0;
       for(auto i : G[state]) {
        if(used[i] != 1) {
            used[i] = 1;
            color_num++;

            if(color_num == parent[state]) color_num++;
            E_out[make_pair(state, i)] = color_num;
            parent[i] = color_num;
            q.push(i);
        }

       }
       if(color_max < color_num) color_max = color_num;

   }

   cout << color_max << endl;
   for(auto a : E_in) {
       cout << E_out[a] << endl;
   }

    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m;
	t = 1;
	while(t--) {
	 cin >> n >> m;
	 cout << (3 * n + m) / 2 << endl;
	}
	return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A.at(i) % 2 == 0) {
            A.at(i) = A.at(i) / 2;
            if (A.at(i) % 3 == 0 || A.at(i) % 5 == 0) ans++;
        }
        else if (A.at(i) % 2 != 0) ans++;
    }

    if (ans != N) cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

int main(){
    int n, m, x, a, ans;
    cin >> n >> m >> x;
    int cnt = 0;
    rep(i,n){
        cin >> a;
        if(a < x) cnt++;
        else break;
    }
    ans = min(cnt, m - cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
////////////////////////////////////////////////
//  ********  *      *    *******    * *      //                 :
//  *         *      *   *       *   *   *    //     64 BITS     C     64 BITS
//  *****     *      *  *         *  *     *  //                 +
//  *         *      *  ***********  *     *  //:  20 - 6 - 2020 +   20 - 6 - 2020 :
//  *         *      *  *         *  *   *    //                 1
//  *         ********  *         *  * *      //     64 BITS     7     64 BITS
////////////////////////////////////////////////                 :
#define ll long long
#define ui unsigned int
#define ud unsigned double
#define mp make_pair
#define pii pair<int,int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pdi pair<double,int>
#define pb push_back
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
const double pi = acos(-1.0);
int main()
{
    int a;
    int c;
    scanf("%d%d",&a,&c);
    if (a == c){
        puts("Yes\n");
    }
    else{
        puts("No\n");
    }
    return 0;
}

Measured memory_bytes: 3684
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
const ll INF = 1e18 + 10 ;
const double EPS = 1e-6 ; 
vector<int> parent(N) ; 
int Find(int x){
    if ( x == parent[x] ) return x ;
    return parent[x] = Find(parent[x]) ; 
}
void Union(int x,int y){
    int X = Find(x) ; 
    int Y = Find(y) ; 
    if ( X == Y ) return ;
    parent[X] = Y ; 
}
signed main(){
    fastio
    for(int i = 0; i < N; i++){
        parent[i] = i ; 
    }
    int n , m , k ; 
    cin >> n >> m >> k ; 
    vector<int> v[n + 1] ; 
    set<int> blocked[n + 1] ;
    vector<int> ans(n + 1) ; 
    for(int i = 0; i < m; i++){
        int x , y ; 
        cin >> x >> y ; 
        v[x].push_back(y);
        v[y].push_back(x);
        Union(x, y) ;
    }
    for(int i = 0; i < k; i++){
        int x , y ; 
        cin >> x >> y ; 
        blocked[x].insert(y) ; 
        blocked[y].insert(x) ;
    }
    for(int i = 1; i < n + 1; i++){
        ans[Find(i)]++ ; 
    }
    debug() << imie(ans) ;
    for(int i = 1; i < n + 1; i++){
        int net = ans[Find(i)];
        net-- ; 
        for(int c : blocked[i]){
            if ( Find(c) == Find(i) ) net--;
        }
        cout << net - v[i].size() << ' ' ;
    }
    cout << endl;
    return 0; 
}

Measured memory_bytes: 23156
#include <stdio.h>
int main()
{
	long long int n,i,x=0;
	char nem[100];
	scanf("%lld",&n);
	while(n!=0){
		n--;
		int b=n%26;
		nem[x]='a'+b;
		n/=26;
		x++;
	}
	for(i=x-1;i>=0;i--){
		printf("%c",nem[i]);
	}
	return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    vector<int> v(n);
    rep(i, 0, n)
    {
        cin >> v[i];
        sum += v[i];
    }
    sum = round(sum / (float)n);
    ll res = 0;
    rep(i, 0, n)
        res += (v[i] - sum) * (v[i] - sum);
    cout << res;
    return 0;
}

Measured memory_bytes: 256
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    n = int(input())
    s = input()
    r = 0
    g = 0
    b = 0
    for i in range(n):
        if s[i] == 'R':
            r += 1
        elif s[i] == 'G':
            g += 1
        else:
            b += 1
    ans = r*g*b
    
    for i in range(n-2):
        for j in range(i, n-1):
            if s[i] != s[j] and 2*j-i < n and s[j] != s[2*j-i] and s[i] != s[2*j-i]:
                ans -= 1
    print(ans)
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 68340
import numpy as np
import sys
input = sys.stdin.buffer.readline

def baku(x):
    g = h - b*x
    g = g[g>0]
    g += a-b-1
    g //= a-b
    if sum(g) <= x:
        return True
    else:
        return False

n, a, b = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
h = np.array(h, dtype=np.int64)

lb = 0
ub = 10**9 + 1
while ub - lb > 1:
    x = (ub+lb) //2
    if baku(x):
        ub = x
    else:
        lb = x
print(ub)

Measured memory_bytes: 31888
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n,m;
bool vis[10];

bool check(int x){
    while(x){
        if(vis[x%10]) return 0;
        x/=10;
    }
    return 1;
}

int main(){
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        vis[x]=1;
    }
    for(int i=m;;i++){
        if(check(i)){
            printf("%d\n",i);
            return 0;
        }
    }
}


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

bool comp(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second > b.second;
}

int main()
{
    int N, p, t;
    for (; ;) {
        std::scanf("%d %d", &N, &p);
        if (N == 0 && p == 0) break;
        std::pair<int, int> arr[p];
        for (int i = 0; i < p; i++) arr[i] = std::make_pair(i+1, 0);
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < p; j++) {
                std::scanf("%d", &t);
                arr[j].second += t;
            }
        }
        std::sort(arr, arr+p, comp);
        for (int j = 0; j < p; j++) {
            if (j) std::printf(" ");
            std::printf("%d", arr[j].first);
        }
        std::printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3132