akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll n, m;
vl visited;

void dfs(const vvl &G, ll v) {
    visited[v] = 1;
    rep(u, n) {
        if(visited[u]) {
            continue;
        }
        if(G[v][u]) {
            dfs(G, u);
        }
    }
}

int main() {
    
    cin >> n >> m;    

    vvl G(n, vl(n));
    vl a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }

    ll bridge = 0;
    rep(i, m) {
        G[a[i]][b[i]] = G[b[i]][a[i]] = 0;
        visited.assign(n, 0);
        dfs(G, 0);
        rep(j, n) {
            if(!visited[j]) {
                bridge++;
                break;
            }
        }
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }

    out(bridge);
    re0;
}

Measured memory_bytes: 256
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import pprint
# for debug
pp = pprint.PrettyPrinter(width = 150)
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


N, T = MI()
t = LI()
diff = [max(0, T - (t[i+1] - t[i])) for i in range(0,N-1)]
print(T * N - sum(diff))


Measured memory_bytes: 27608
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define xxx         exit(0);
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x)/log(base));
}
ll n,W,dp[105][100005],w[105], v[105];
ll cc(ll ind,ll wt)
{
	if(ind==n && wt<=W) return 0;
	if(wt>W) return nmod;
	if(dp[ind][wt]!=-1) return dp[ind][wt];
	ll ans = 0;
	ans=max(cc(ind+1,wt),cc(ind+1,wt+w[ind])+v[ind]);
	return dp[ind][wt]=ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll i,l,j,x1,y1,ans,x,y,q;
    	cin>>n>>W;
    	rep(i,0,n) cin>>w[i]>>v[i];
		repi(i,0,n){
			repi(p,0,W){
				dp[i][p]=-1;
			}
		}
		cout<<cc(0,0);
	}
	return 0;
}


Measured memory_bytes: 82616
/**
 *   author: master3214
 *   created: Sep-15-2020
**/

#include <bits/stdc++.h>

using namespace std;

int main(){
	int a;
	cin >> a;
	if(a  == 0){
		cout << 1;
		return 0;
	}
	cout << 0;
	
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int solve(int a[],int b[],int c[],int n,vector<vector<int>>&dp,int choice)
{
  if(n==0)
    return 0;
  if(dp[n][choice]!=-1)
    return dp[n][choice];
  if(choice==1)
    return dp[n][choice]=max(solve(a,b,c,n-1,dp,2)+b[n-1],solve(a,b,c,n-1,dp,3)+c[n-1]);
  else if(choice==2)
    return dp[n][choice]=max(solve(a,b,c,n-1,dp,1)+a[n-1],solve(a,b,c,n-1,dp,3)+c[n-1]);
  else if(choice==3)
    return dp[n][choice]=max(solve(a,b,c,n-1,dp,1)+a[n-1],solve(a,b,c,n-1,dp,2)+b[n-1]);
  else return dp[n][choice]=max(max(solve(a,b,c,n-1,dp,1)+a[n-1],solve(a,b,c,n-1,dp,2)+b[n-1]),solve(a,b,c,n-1,dp,3)+c[n-1]);
}
int main()
{
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    cin>>b[i];
    cin>>c[i];
  }
  int ans;
  vector<int>temp(4,-1);
  vector<vector<int>>dp(n+1,temp);
  ans=solve(a,b,c,n,dp,0);
  cout<<ans;
}


Measured memory_bytes: 16256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

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

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ll N, X, Y;
    in >> N >> X >> Y;
    --X;
    --Y;
    vector<ll> v(N);

    auto dist = [&](ll i, ll j) {
        if (i > j) swap(i,j);
        ll dist1 = 0;
        if (i <= X) {
            dist1 += X-i;
        } else {
            dist1 += i-X;
        };
        dist1++;
        if (j <= Y) {
            dist1 += Y-j;
        } else {
            dist1 += j-Y;
        };
        return min(j-i, dist1);
    };
    map<ll, ll> counts{};
    REP(i, N-1) {
        RANGE(j, i+1, N-1) {
            counts[dist(i, j)]++;
        }
    }
    REP(i,N-1) {
        out << counts[i+1] << endl;
    }
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 384
import Data.List( nub, sort)
main = do
    s <- getLine
    let directions = sort $ nub s
	judge
	  | directions == "ENSW"    = "Yes"
	  | directions == "EW"	    = "Yes"
	  | directions == "NS"	    = "Yes"
	  | otherwise		    = "No"
    putStr judge

Measured memory_bytes: 508
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    x = ii()
    for a in range(-500, 500):
        for b in range(-500, 500):
            if a ** 5 - b ** 5 == x:
                print(f"{a} {b}")
                exit()



if __name__ == "__main__":
    main()


Measured memory_bytes: 64936
# TLE

import numpy as np
import sys
input = sys.stdin.readline


def main():
    N,K = map(int, input().split())
    A = np.array(sorted([int(i) for i in input().split()]))

    zero_left = np.searchsorted(A, 0, side='left')
    zero_right = np.searchsorted(A, 0, side='right')

    negative = zero_left
    positive = N - zero_right
    zero = zero_right - zero_left
    non_posi = negative * positive + zero * (N - zero) + zero * (zero - 1) // 2

    if K <= negative * positive:
        Nega = A[A < 0]
        Posi = A[A > 0]

        left = -(10**18)
        right = 0
        while right - left > 1:
            x = (left + right) // 2
            count = np.searchsorted(Nega, x // Posi, side='right').sum()

            if count < K:
                left = x
            else:
                right = x

        print(right)

    elif K <= non_posi:
        print(0)

    else:
        Nega = np.sort(np.abs(A[A < 0]))
        Posi = A[A > 0]

        left = 0
        right = 10**18
        while right - left > 1:
            x = (left + right) // 2
            n = np.searchsorted(Nega, x // Nega, side='right')
            p = np.searchsorted(Posi, x // Posi, side='right')
            count = 0
            count += n.sum()
            count += p.sum()
            count -= np.int_(np.where(n >= np.arange(1,negative+1), True, False)).sum()
            count -= np.int_(np.where(p >= np.arange(1,positive+1), True, False)).sum()
            count //= 2

            if count + non_posi < K:
                left = x
            else:
                right = x

        print(right)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32308
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

ll N, M;
string S, T;

void input() {
    cin >> N >> M;
    cin >> S >> T;
}

ll bcd(ll a, ll b) {
    if (b > a) {
        ll t = a;
        a = b;
        b = t;
    }
    ll r = a % b;
    while (r) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll gcm(ll a, ll b) {
    return a * b / bcd(a, b);
}

ll solve() {
    const ll L = gcm(N, M);
    const ll Sshift = L / M;
    const ll Tshift = L / N;
    for (auto i = 0; i < bcd(N, M); i++) {
        if (S[i * Sshift] != T[i * Tshift]) {
            return -1;
        }
    }
    return L;
}

int main() {
    input();
    
    cout << solve() << endl;
    
    
    return 0;
}



Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
long long pos[100010],sum[100010];
using namespace std;
int main()
{
	int n,k,x;long long ans=- int(1e9);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		sum[i]=sum[i-1]+x;
		pos[i]=x<0?pos[i-1]:pos[i-1]+x;
	//	cout<<sum[i]<<" "<<pos[i]<<endl;
	}
	for(int i=k;i<=n;i++)
	{
		long long s=pos[n]-(pos[i]-pos[i-k]);//Çø¼äÍâË¢Õý 
		if(sum[i]-sum[i-k]>0) s+=sum[i]-sum[i-k];//Èç¹ûÇø¼äºÍ´óÓÚÁã¾ÍË¢ºÚ 
		ans=max(s,ans);
	}
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Exerwizerds2019
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int[] abc = ReadInts();
            if (abc[0]== abc[1] && abc[1] == abc[2])
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans;
	ll N,A[200010];
	set<int> S;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>N;
	REP(i,N){
		cin>>A[i];
		S.insert((A[i]));
	}
	sort(A,A+N);
	auto it=S.upper_bound((A[N-1]/2.0));
	auto itr=prev(it);
	DEB(*it)DEB(*(itr))
	cout<<A[N-1]<<" "<<(abs(*it-double(A[N-1]/2.0))>=abs(*(itr)-double(A[N-1]/2.0))?*(--it):*it)<<endl;
	return 0;
}

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

 int main()
 {
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b)
	{
		printf("0\n");
		return 0;
	}

	if((n==1)&&(a!=b)) 
	{
		printf("0\n");
		return 0;
	}
	
	printf("%lld\n",(n-1)*b+a-(n-1)*a-b+1);
	return 0;
 }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public void run()
    {
        var input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int x = int.Parse(input[1]);
        input = Console.ReadLine().Split();
        int[] a = Array.ConvertAll(input, int.Parse);
        long total = 0;
        for(int i = 1; i < N; i++)
        {
            int sum = a[i - 1] + a[i];
            if(sum > x)
            {
                int dec = sum - x;
                total += dec;
                if(dec > a[i])
                {
                    a[i] = 0;
                }
                else
                {
                    a[i] -= dec;
                }
            }
        }
        Console.WriteLine(total);
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }
    /*
    最小公倍数
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
    */
    //a<=c, b<=d;
}

//Split().Select
//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


Measured memory_bytes: 26844
#include <stdio.h>
#define Mod 1000000007

long long pow_mod(long long a, long long k, long long M){
  if(k == 1) return a % M;
  if(k == 0) return 1;
  long long temp = pow_mod(a, k/2, M);
  if(k % 2 == 1) return ((a*temp%M) *temp)%M;
  return (temp*temp)%M;
}

int
main(int argc, char *argv[])
{
  long long k, n;
  scanf("%lld %lld", &n, &k);

  n = n - k;
  long long int a = n + 1; long long b;
  for(long long i = 1; i <= k; i++){
    printf("%lld\n", a);
    if(i == k) break;
    b = (k - i)*a%Mod;
    b = (n - i + 1)*b%Mod;
    b = b*pow_mod(i*(i+1), Mod - 2, Mod)%Mod;
    a = b;
  }

  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


vector<bool> visited(100000+1,0);
vector<int> graph[100000+1];

void dfs(int node) {
    visited[node] = true;
    for (int next_node : graph[node]) {
        if (!visited[next_node]) {
            dfs(next_node);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,u,v;
    cin >> n >> m;
    forn(i,m) {
        cin >> u >> v;
        graph[u-1].pb(v-1);
        graph[v-1].pb(u-1);
    }
    int ans = -1;
    forn(i,n) {
        if (!visited[i]) {
            dfs(i);
            ans++;
        }
    }
    cout << ans;
    return 0;
} 

Measured memory_bytes: 9540
#include<stdio.h>
int main(void){
int W,H;
int x,y,r;
scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
if((0<=x-r)&&(x+r<=W)&&(0<=y-r)&&(y+r<=H))
{
printf("Yes\n");
}
else printf("No\n");
return 0;
}

Measured memory_bytes: 580
*n,t=open(0).read().split()
n,k,r,s,p=map(int,n)
d={'r':p,'s':r,'p':s}
b=['']*n*2
a=0
for i,c in enumerate(t[:n]):
  if c!=b[i-k]:
    b[i]=c
    a+=d[c]
print(a)

Measured memory_bytes: 5492
package main

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

func main() {
	mod := newModInt(1e+9 + 7)
	n := readI()
	sum := make([]int, n+1)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		tmp := readI()
		sum[i+1] = sum[i] + tmp
		a[i] = tmp
	}

	ans := 0
	for i := 0; i < n; i++ {
		ans = mod.add(ans, mod.mul(a[i], mod.sub(sum[n], sum[i+1])))
	}
	fmt.Println(ans)
}

type modInt struct {
	modNum int
}

func newModInt(mod int) *modInt {
	m := modInt{modNum: mod}
	return &m
}

func (m modInt) mod(a int) int {
	a %= m.modNum
	if a < 0 {
		return a + m.modNum
	}
	return a
}

func (m modInt) pow(base, exponent int) int {
	res := 1
	for exponent > 0 {
		if exponent&1 == 1 {
			res = m.mod(res * base)
		}
		base = m.mod(base * base)
		exponent >>= 1
	}
	return res
}

func (m modInt) inv(a int) int {
	return m.pow(a, m.modNum-2)
}

func (m modInt) add(a, b int) int {
	return m.mod(a + b)
}

func (m modInt) sub(a, b int) int {
	return m.mod(a - b)
}

func (m modInt) mul(a, b int) int {
	return m.mod(a * b)
}

func (m modInt) div(a, b int) int {
	return m.mul(a, m.inv(b))
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


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

long long digitsum(long long b, long long n) {
    long long result = 0;
    while (n > 0) {
        result += n % b;
        n /= b;
    }
    return result;
}

int main() {
    long long n, s, result = LLONG_MAX;
    cin >> n >> s;
    if (n == s) {
        result = n + 1;
    } else {
        for (long long b = 2; b * b <= n; b++) {
            if (digitsum(b, n) == s) {
                result = b;
                break;
            }
        }
        for (long long i = 1; i * i <= n - s; i++) {
            if ((n - s) % i == 0) {
                if (digitsum((n - s) / i + 1, n) == s) {
                    result = min(result, (n - s) / i + 1);
                }
                if (digitsum(i + 1, n) == s) {
                    result = min(result, i + 1);
                }
            }
        }
        if (s == 1) {
            result = min(result, n);
        }
    }
    if (result == LLONG_MAX) {
        result = -1;
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main(){
  string s;
  cin>>s;
  if (s[0] == 'A' && s[s.size()-1] >= 'a' && s[s.size()-1] <= 'z'){
    if ('a' <= s[1] && s[1] <= 'z'){
    	bool flag = false;
      for (int i(2);i<s.size()-1;i++){
        if ('a' <= s[i] && s[i] <= 'z'){
        }else if(s[i] == 'C' && flag == false){
          flag = true;
        }else{
          cout << "WA" << endl;
          return 0;
        }
      }
      if (flag){
        cout << "AC" << endl;
      }else{
        cout << "WA" << endl;
      }
      return 0;
    }
  }
  cout << "WA" << endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e6+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
bool dp[MAXN][7];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;
    dp[0][0] = 1;
    for(int i = 1; i <= 6; i++){
        for(int j = 0; j < MAXN; j++){
            dp[j][i] = max(dp[j][i],dp[j][i - 1]);
            if(j >= 100 + i - 1){
                dp[j][i] = max(dp[j][i],dp[j - 100 - i + 1][i - 1]);
                dp[j][i] = max(dp[j][i],dp[j - 100 - i + 1][i]);
            }
        }
    }

    if(dp[n][6]){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if(x==0){
    if(y>0){
      cout << y <<endl;
    }else{
      cout << -y+1 << endl;
    }
    return 0;
  }
  if(y==0){
    if(x>0){
      cout << 1+x << endl;
    }else{
      cout << -x << endl;
    }
    return 0;
  }
  if(x>0 && y>x){
    cout << y-x << endl;
    return 0;
  }
  if(y>0 && x>y){
    cout << x-y+2 << endl;
    return 0;
  }
  if(x>0 && y<0){
    cout << abs(y+x)+1 << endl;
    return 0;
  }
  if(y>0 && x<0){
    cout << abs(y+x)+1 << endl;
    return 0;
  }
  if(y<0 && y>x){
    cout << y-x << endl;
    return 0;
  }
  if(x<0 && y<x){
    cout << x-y+2 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
typedef long long int lli;
#define mxint 1000000007 
const int mod = int(1e9+7);
long long int  t[2000001];
/*
    int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0; 
        *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 
  

*/

int main()
{
   string str1;
   string str2;
   cin>>str1;
   cin>>str2;
   int count=0;
   for(int i=0;i<str1.length();i++)
   {
       if(str1[i]!=str2[i])
       count++;
   }
   cout<<count<<endl;
   
   
   
}

Measured memory_bytes: 3856
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] A = new int[n];

        for(int i = 0;i < n;i++){
            A[i] = sc.nextInt();
        }

        int minj,tmp,count = 0;
        for(int i = 0;i < n - 1;i++){
            minj = i;
            for(int j = i;j < n;j++){
                if(A[j] < A[minj]){
                    minj = j;
                }
            }
            if(minj != i){
                tmp = A[i];
                A[i] = A[minj];
                A[minj] = tmp;
                count++;
            }
        }
        for(int i = 0;i < n;i++){
            if(i != 0) System.out.print(" ");
            System.out.print(A[i]);
        }
        System.out.println();
        System.out.println(count);

    }
}


Measured memory_bytes: 26232
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 1e5 + 5;
ll a[maxn];
int main(int argc, char const *argv[])
{
	ll n;
	cin>>n;
	ll ans1 = 0,ans2 = 0;
	for(ll i = 1;i <= n; ++i)
	{
		scanf("%lld",&a[i]);
	}
	sort(a + 1,a + n + 1);
	ll l = 1,r = n,x = a[(n + 1) / 2];
	for(ll i = 1;i < n; ++i)
	{
		if(i & 1)
		{
			ans1 += abs(a[l] - x);
			x = a[l++];
		}
		else
		{
			ans1 += abs(a[r] - x);
			x = a[r--];
		}
	}
	l = 1,r = n,x = a[(n + 1) / 2];
	for(ll i = 1;i < n; ++i)
	{
		if(i & 1)
		{
			ans2 += abs(a[r] - x);
			x = a[r--];
		}
		else
		{
			ans2 += abs(a[l] - x);
			x = a[l++];
		}
	}
	printf("%lld\n",max(ans1,ans2));
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#define ll long long
using namespace std;

int main(){
  ll n,a,b,ans=0; cin>>n>>a>>b;
  ll x[n];
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=1;i<n;i++){
    ans+=min(b,a*(x[i]-x[i-1]));
  }
  cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

int n;
char a[123], b[123];
int main() {
    scanf("%d %s %s", &n, a, b);
    fo(i,0,n+1) {
        bool g = 1;
        fo(j,0,n-i) if (a[i+j] != b[j]) g = 0;
        if (g) {
            printf("%d\n", n+i); break;
        }
    }


        return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)      //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++)    //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/
vi move1 = {0,0,1,-1};
vi move2 = {1,-1,0,0};

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    int n, m, h; cin >> n>>m>>h;


    cout << (n+m+h>=22? "bust" : "win") << '\n';
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);
const int MAX_N = (int)(1e5 + 5);

int n, k;

ll h[MAX_N];

ll ans;

int main(void) {
    // Here your code !

    scanf("%d %d", &n, &k);

    for (int i = 0; i < n; ++i) {
      scanf("%d\n", &(h[i]));
    }

    sort(h, h + n);

    ans = INF;

    for (int i = 0; i + k - 1 < n; ++i) {
      ans = min(ans, h[i + k - 1] - h[i]);
    }

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

    return 0;
}


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

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<bool>> g(10,vector<bool>(10,false));
  for(int i=0;i<m;i++){
    int from,to;
    cin >> from >> to;
    from--;
    to--;
    g[from][to]=true;
    g[to][from]=true;
  }
  vector<int> p(n);
  for(int i=0;i<n;i++){
    p[i]=i;
  }
  int ans=0;
  do{
    bool flag=true;
    for(int i=0;i<n-1;i++){
      if(!g[p[i]][p[i+1]]){
        flag=false;
        break;
      }
      else if(p[0]!=0){
        flag=false;
        break;
      } 
    }
    if(flag) ans++;
  }while(next_permutation(p.begin(),p.end()));
  cout << ans << endl;
}


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

int main() {

	int n, k; cin >> n >> k;
	const int p = 200001;
	vector<int> num(p);
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		num[a]++;
	}
	sort(num.begin(), num.end(), greater<int>());
	int cnt = 0;
	for (int i = 0; i < k; i++) {
		cnt += num[i];
	}
	cout << n - cnt << endl;
	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  ll n;
  cin >> n;
  if(n&1) return cout << 0 << endl, 0;
  ll ans = 0;
  n /= 2;
  ll c = 5;
  while (c <= n) {
    ans += n/c;
    if(c==n)break;
    c *= 5;
  }
  cout << ans << endl;
}

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

const int mod = 1e9+7;

int main() {
	int n;
	long long ans = 1;

	cin >> n;
	for (int i=2; i<=n; ++i)
		ans = ans * i % mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
p = [int(input()) for _ in range(5)]
minr = 10
ans = 0
for x in p:
    if x % 10 == 0:
        ans += x // 10
    else:
        ans += x // 10 + 1
        minr = min(minr, x % 10)
print(ans * 10 - (10 - minr))

Measured memory_bytes: 2940
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]


def main():
    N, K = map(int, input().split(" "))
    ks = format(K, "b")
    masks = [K]
    for i in range(len(ks)):
        if ks[-i-1] == "1":
            nks = ks[:-i-1] + "0" + "1" * i
            masks.append(int(nks, 2))
    l = len(masks)
    vs = [0] * l
    for _ in range(N):
        a, b = map(int, input().split())
        for i in range(l):
            if a & masks[i] == a:
                vs[i] += b
    return max(vs)


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
int main() {
  ll n;
  cin >> n;
  vl a(n);
  vvl g(n,vl(n,-1));
  rep(i,n){
    cin >> a[i];
    rep(j,a[i]){
      ll x,y;
      cin >> x >> y;
      x--;
      g[i][x]=y;
    }
  }
  ll ans=0;
  rep(i,(1<<n)){
    bool ok=true;
    ll cnt=0;
    vl d(n,0);
    rep(j,n){
      if(i>>j&1){
        d[j]=1;
        cnt++;
      }
    }
    rep(j,n){
      if(d[j]){
        rep(k,n){
          if(g[j][k]!=-1){
            if(g[j][k]!=d[k]){
              ok=false;
            }
          }
        }
      }
    }
    if(ok){
      ans=max(ans,cnt);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

map<long long, long long> memo;
long long f(long long x) {
    if( memo.count(x))
        return memo[x];
    if (x == 1) {
        return 1;
    }
    if (x == 0) {
        return 0;
    }
    return memo[x] = 2 * f(x / 2) + 1;
}

void solve(long long H) {
    cout << f(H) << endl;
}

int main() {
    long long H;
    scanf("%lld", &H);
    solve(H);
    return 0;
}



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

int main() {
  int n, c, k;
  cin >> n >> c >> k;

  vector<ll> t(n);
  rep(i, n) cin >> t[i];

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

  ll ans = 0;
  for (int i = 0; i < n;) {
    ll lim = t[i] + k;
    int cnt = 0;
    while (i < n && cnt < c && t[i] <= lim)
      ++cnt, ++i;
    ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
struct people { ll v, k, year; };
bool comp(const etree& e1, const etree& e2) {
	return e1.cost < e2.cost;
}
bool comp2(const people& e1, const people& e2) {
	return e1.year < e2.year;
}
#define ALL(x) (x).begin(),(x).end()

ll FACT[201100] = { 0 }, IFACT[201100] = { 0 };
ll h, w, a, b;
ll extgcd(ll a, ll b, ll &x, ll &y) {
	ll g = a;
	x = 1;
	y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
ll invMod(ll a, ll m) {
	ll x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m;
	else                         return 0;
}
ll mpow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll d = mpow(a, n / 2);
		return d * d % MOD;
	}
	return a * mpow(a, n - 1) % MOD;
}
void inverse(ll N) {
	FACT[0] = 1;
	IFACT[0] = 1;
	for (int i = 1;i <= N;i++) {
		FACT[i] = FACT[i - 1] * i % MOD;
		IFACT[i] = invMod(FACT[i], MOD);
	}
}
ll combi(ll n, ll r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD;
}


int main() {
	ll ans = 0, lack = 0;
	cin >> h >> w >> a >> b;
	inverse(h + w + 10);
	ans += combi(h + w - 2, w - 1);
	for (int i = h - a;i < h;i++) {
		lack += ((combi(i + b - 1, b - 1) % MOD)*(combi(h - i - 1 + (w - b - 1), h - i - 1) % MOD) + MOD) % MOD;
	}
	cout << (MOD + (ans - lack + MOD) % MOD) % MOD << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> aa(n);
    for(int i = 0; i < n; i++) {
        cin >> aa.at(i);
    }
    int res0, res1;
    sort(aa.begin(), aa.end());
    res0 = aa.at(n - 1);
    for (int i = 0; i < n; i++) {
        if (aa.at(i) > res0 / 2) {
            if (i == 0) {
                res1 = aa.at(i);
            } else if (res0 - aa.at(i) > aa.at(i - 1)) {
                res1 = aa.at(i);
            } else {
                res1 = aa.at(i - 1);
            }
            break;
        }
    }
    cout << res0 << " " << res1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A+B>=C)
  cout<<"Yes"<<endl;
  else if(A+B<C)
  cout<<"No"<<endl;
    }

   
  
   


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
 
#define ll long long
 
int main(){
	ll w,n;

	std::cin >> n >> w;
	
	std::vector<ll> dp(w+1);
	
	for(int i = 0; i < n; ++i){
		ll weight, value;
		std::cin >> weight >> value;
		std::vector<ll> toInsert;
		for(int j = w-weight; j >= 0; j--){
			if(j+weight >= 0 && dp[j] + value > dp[j+weight]){
				dp[j+weight] = dp[j] + value;
			}
		}
	}
	
	ll answer = 0;
	for(int i = 0; i < dp.size(); ++i){
		if(dp[i] > answer)
			answer = dp[i];
	}
	std::cout << answer;
}

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

int main() {
	int W, a, b,Len;
	cin >> W >> a >> b;
	if (a > b) {
		Len = a - (b + W);
		if (Len < 0) {
			cout << "0" << endl;
		}
		else cout << Len << endl;
	}
	else if (a < b) {
		Len = b - (a + W);
		if (Len < 0) {
			cout << "0" << endl;
		}
		else cout << Len << endl;
	}
	else cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n; cin>> n;
    vector<int> a(100000);
    map<int, int> mp;
    int MAX=0;
    int MIN = 1000000000;
    for(int i=0; i<n; i++){
        cin >> a[i];
        MAX = max(MAX, a[i]);
        MIN = min(MIN, a[i]);
        if(!mp.count(a[i])){
            mp[a[i]]=1;
        }else{
            mp[a[i]]++;
        }
    }
    int ans = 0;

    for (auto p: mp) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 8180
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    	long X = sc.nextInt();
    	if(X == 0){
    		System.out.println("0 0");
    		return;
    	}
    	List<Integer> divList = getDiv((int)X);
    	for(long i = 0; i < 200; i++) {
    		long i5 = i * i * i * i * i;
    		for(int div : divList) {
    			if(i > 70 && i < div){
    				break;
    			}
    			long j = i - div;
    			long j5 = j * j * j * j * j;
    			if(i5 - j5 == X) {
    				System.out.println(i + " " + j);
    				return;
    			}
    		}
    	}
    }
	
	private static List<Integer> getDiv(int X){
		List<Integer> divList = new ArrayList<>();
		for(int i = 1; i < 200; i++) {
			if(X % i == 0) {
				divList.add(i);
			}
		}
		return divList;
	}
}

Measured memory_bytes: 27032
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long int n,i,d;
  cin>>n;
  
    multiset<long int>last;
    for(i=0;i<n;i++){
      
      cin>>d;
      multiset<long int>::iterator it = last.lower_bound(d);
      if(it==last.begin())
        last.insert(d);
      else{
        it--;
        last.erase(it);
        last.insert(d);
      }
    }
    cout<<last.size();
  
  return 0;
}

Measured memory_bytes: 4992
// Try AtCoder
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var k float64
	fmt.Scan(&n, &k)
	ans := 0.0
	for i := 0; i < n; i++ {
		var x float64
		fmt.Scan(&x)
		ans += math.Min(x*2, math.Abs(x-k)*2)
	}
	fmt.Println(int(ans))
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int n,ans=1,hl=0;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for (int i=1; i<n; i++){
        if (a[i]<a[i-1]){
            if (hl==0){
                hl=-1;
            } else if (hl==1){
                ans++;
                hl=0;
            }
        } else if (a[i]>a[i-1]){
            if (hl==0){
                hl=1;
            } else if (hl==-1){
                ans++;
                hl=0;
            }
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
a = list(map(int, input().split()))
dist = []
for i in range(K):
    if i == K-1:
        d = a[0] - 0 + N - a[i]
    else:
        d = a[i+1] - a[i]
    dist.append(d)
dist.sort()
dist.pop(-1)
print(sum(dist))

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

int main(){
	int n1, n2;
	int salesNumbers[5];
	while(cin >> n1 >> n2, n1+n2 != 0){
		int maxNum = n1+n2;
		salesNumbers[0] = n1+n2;
		for(int i = 1; i < 5; i++){
			cin >> n1 >> n2;
			salesNumbers[i] = n1+n2;
			maxNum = max(maxNum, salesNumbers[i]);
		}
		for(int i=0; i < 5; i++){
			if(maxNum == salesNumbers[i])
				cout << (char)('A'+i) << " " << maxNum << endl;
		}
	}
}

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

int main(void) {
	string n;
	cin >> n;
	for (int i = 0; i < n.length(); i++) {
		if (n[i] == '1') {
			n[i] = '9';
		}
		else if (n[i] == '9') {
			n[i] = '1';
		}
	}
	cout << n;
	return 0;
}

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

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

    priority_queue<ull> a;
    ull ai;
    for (int i = 0; i < n; i++)
    {
        cin >> ai;
        a.push(ai);
    }

    ull s;
    while (m-- > 0)
    {
        s = a.top()/2;
        a.pop();
        if (s == 0 && a.empty()) break;
        if (s > 0) a.push(s);
    }

    ull res = 0;
    //for (ull i: a) res += i;
    while (!a.empty())
    {
        res += a.top();
        a.pop();
    }
    cout << res << endl;

    return 0;

}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

int n, val[110000], a, b;
ll sum = 0;
vector< int > c;
vector< vector< int > > tree(110000);
vector< vector< int > > lev(110000);

void dfs(int index, int par, int l)
{
	lev[l].pb(index);
	for (int node : tree[index])
	{
		if (node == par)
			continue;
		dfs(node, index, l+1);
	}
}

int main()
{
	fastio;		
	cin>>n;
	for (int i = 1; i <= n-1; i++)
	{
		cin>>a>>b;
		tree[a].pb(b);
		tree[b].pb(a);
	}

	for (int i = 1; i <= n; i++)
	{
		cin>>a;
		c.pb(a);
	}

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

	dfs(1, -1, 1);

	int cnt = n-1;

	for (int i = 1; i <= n; i++)
	{
		for (int j : lev[i])
		{
			val[j] = c[cnt];
			cnt--;
		}
	}

	for (int i = 0; i < n-1; i++)
		sum += c[i];

	cout<<sum<<endl;
	for (int i = 1; i <= n; i++)
		cout<<val[i]<<" ";
	cout<<endl;

	return 0;
}


Measured memory_bytes: 6784