akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

struct pyramid {
    int x, y, h;
    pyramid(int i, int j, int k):x(i), y(j), h(k) {}
} ;

int main() {
    int n;
    cin >> n;
    vi x(n), y(n);
    vector<ll> h(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
    }

    vector<pyramid> pp;

    rep(i, 101) {
        rep(j, 101) {
            ll h_ = -1LL;

            rep(ii, n) {
                if(h_ == -1LL) {
                    if(!h[ii]) {
                        if(ii && abs(i-x[ii]) + abs(j-y[ii]) > 1) break;
                        h_ = -(abs(i-x[ii]) + abs(j-y[ii]));
                    }
                    else h_ = abs(x[ii]-i) + abs(y[ii]-j) + h[ii];
                }
                if(h_< -1LL) {
                    if(!h[ii]) {
                        if(abs(i-x[ii]) + abs(j-y[ii]) < -h_) {
                            h_ = -(abs(i-x[ii]) + abs(j-y[ii]));
                        }
                    } else {
                        if(abs(i-x[ii]) + abs(j-y[ii])+h[ii] <= -h_) {
                            h_ = abs(i-x[ii]) + abs(j-y[ii])+h[ii];
                        } else {
                            break;
                        }
                    }
                } else if(h_ >= 0LL) {
                    if(!h[ii]) {
                        if(abs(i-x[ii]) + abs(j-y[ii]) < h_) break;
                    } else {
                        if(abs(i-x[ii]) + abs(j-y[ii]) + h[ii] != h_) break;
                    }
                } 
                if(h_ > 0 && ii == n-1) {
                    pp.push_back(pyramid(i, j, h_));
                }
            }
        }
    }

    for(pyramid xx:pp) {
        rep(i, n) {
            if(h[i] != max(0, xx.h-abs(xx.x-x[i]) - abs(xx.y-y[i]))) {
                break;
            }
            if(i == n-1) {
                cout << xx.x << ' ' << xx.y << ' ' << xx.h << endl;
                return 0;
            }
        }
    }
}

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

int main(void) {
	int a, b, n, ans = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		int num = i;
		int ketasum = 0;
		while (num) {
			ketasum += num % 10;
			num = num / 10;
		}
		if (a <= ketasum && ketasum <= b) ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()[::-1]
l = len(s)
MOD = 2019
ans = 0
mods = [0] * 2019
mods[0] = 1
num = 0
cnt = 0
d = 1
for i in s:
    num += int(i) * d
    num %= MOD
    mods[num] += 1
    d *= 10
    d %= MOD

for j in mods:
    ans += int(j*(j-1)/2)

print(ans)


Measured memory_bytes: 9232
using CompLib.Util;
using System;
using System.Collections.Generic;
using System.Text;

public class Program
{
    int N;
    int M;
    List<int>[] E;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        E = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            E[i] = new List<int>();
        }
        for (int i = 0; i < M; i++)
        {
            int a = sc.NextInt() - 1;
            int b = sc.NextInt() - 1;
            E[a].Add(b);
            E[b].Add(a);
        }
        int[] ans = new int[N];
        for (int i = 0; i < N; i++)
        {
            ans[i] = int.MaxValue;
        }
        ans[0] = 0;
        var q = new Queue<int>();
        q.Enqueue(0);
        while (q.Count > 0)
        {
            var d = q.Dequeue();
            foreach (int to in E[d])
            {
                if (ans[to] != int.MaxValue) continue;
                ans[to] = d;
                q.Enqueue(to);
            }
        }

        bool f = true;
        var sb = new StringBuilder();
        for (int i = 1; i < N; i++)
        {
            if (ans[i] == int.MaxValue) {
                f = false;
                break;
            }
            sb.AppendLine((ans[i] + 1).ToString());
        }
        if (f)
        {
            Console.WriteLine("Yes");
            Console.Write(sb);
        }
        else
        {
            Console.WriteLine("NO");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

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

    string S;
    cin >> S;
    cout << (S[0] == S[1] && S[1] == S[2] ? "No\n" : "Yes\n");

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    long long a[n];
    long long set[200001]={0};
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        set[a[i]]++;
    }
    long long sum=0;
    for(int i=1;i<=n;i++){
        sum+=(set[i]*(set[i]-1)/2);
    }
    for(int i=0;i<n;i++){
        printf("%lld\n",sum-(set[a[i]]*(set[a[i]]-1))/2+(set[a[i]]-1)*(set[a[i]]-2)/2);
    }
    
    
    
    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 4005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, K, a[MAXN], tot;
int dp[2][MAXN][2], fac[MAXN], ans;;

namespace ModCalculator {
	const int MOD = 924844033;
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;

void solve() {
	read(n); read(K);
	for (int i=1;i<=K;++i) {
		for (int j=i;j<=n;j+=K) {
			a[++tot] = (j == i);
		}
		for (int j=i;j<=n;j+=K) {
			a[++tot] = (j == i);
		}
	}
	dp[0][0][0] = 1;
	int cur = 0, nxt = 1;
	for (int i=0;i<(n<<1);++i) {
		mset(dp[nxt], 0);
		for (int j=0;j<=i;++j) {
			dp[nxt][j][0] = Add(dp[cur][j][0], dp[cur][j][1]);
			if (!a[i+1]) dp[nxt][j+1][1] = dp[cur][j][0];
		}
		cur = nxt; nxt = cur ^ 1;
	}
	fac[0] = 1;
	for (int i=1;i<=n;++i) {
		fac[i] = Mul(fac[i-1], i);
	}
	for (int i=0;i<=n;++i) {
		int tmp = Mul(Add(dp[cur][i][0], dp[cur][i][1]), fac[n-i]);
		(i & 1)? Dec(ans, tmp) : Inc(ans, tmp);
	}
	printf("%d\n", ans);
}

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


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
def main():
    N,M = map(int,input().split())
    L = []
    R = []
    for _ in range(M):
        l,r = map(int,input().split())
        L.append(l)
        R.append(r)
    L.sort(reverse=True)
    R.sort()
    lmax = L[0]
    rmin = R[0]
    print(max(0,rmin-lmax+1))



if __name__ == '__main__':
    main()

Measured memory_bytes: 11408
#include <bits/stdc++.h>
#define N 5010
#define int long long
#define mod 1000000007
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge
{
	int v,next;
}vs[N<<1];
inline int qpow(int bas,int pw)
{
	int ret=1;
	for(;pw;pw>>=1,bas=1ll*bas*bas%mod)
		if(pw&1) ret=1ll*ret*bas%mod; return ret;
}
int n,ee,st[N],p1,s1,p2,s2;
int size[N],fac[N],inv[N],fa[N];
int bs[N],tot,F[N],G[N];
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline void dfs(int rt)
{
	size[rt]=1; int mx=0;
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==fa[rt]) continue;
		fa[vs[i].v]=rt; dfs(vs[i].v);
		size[rt]+=size[vs[i].v];
		mx=max(mx,size[vs[i].v]);
	}
	int sd=max(mx,n-size[rt]),pd=rt;
	if(sd<s1) swap(sd,s1),swap(pd,p1);
	if(sd<s2) swap(sd,s2),swap(pd,p2);
}
inline void Add(int &x,int y)
{
	x+=y; if(x>=mod) x-=mod;
	if(x<0) x+=mod;
}
inline int C(int n,int m)
{
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<=5000;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[5000]=qpow(fac[5000],mod-2); 
	for(int i=4999;i>=1;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	n=read(); 
	s1=s2=n+1;
	for(int i=1;i<n;i++)
	{
		int u=read(), v=read();
		addedge(u,v); addedge(v,u);
	}
	dfs(1);
	if(!(s1^s2)){cout << 1ll*fac[n/2]*fac[n/2]%mod << endl; return 0;}
	else 
	{
		for(int i=st[p1];i;i=vs[i].next)
		{
			if(vs[i].v==fa[p1]) continue;
			bs[++tot]=size[vs[i].v];
		}
		bs[++tot]=n-size[p1]; F[0]=1;
		for(int i=1;i<=tot;i++)
		{
			for(int j=0;j<=n-1;j++) G[j]=F[j];
			for(int j=1;j<=bs[i];j++)
				for(int k=n-1;k>=j;k--) if(F[k-j])
					Add(G[k],1ll*F[k-j]*fac[bs[i]]%mod*inv[bs[i]-j]%mod*C(bs[i],j)%mod);
			for(int j=0;j<=n-1;j++) F[j]=G[j];
		}
		int Ans=fac[n];
		for(int i=1,f=-1;i<=n-1;i++,f*=-1)
			Add(Ans,f*F[i]*fac[n-i]%mod);
		cout << Ans << endl;
	}
	return 0;
}

Measured memory_bytes: 768
n, m = map(int, input().split())

A = []
for line in range(n):
    A.append(list(map(int, input().split())))

[A[i].append(sum(A[i])) for i in range(n)]

t = []
for i in range(m+1):
    t.append([A[j][i] for j in range(n)])
    t[i].append(sum(t[i]))

r = []
for i in range(n+1):
    r.append([t[j][i] for j in range(m+1)])
    print(' '.join(map(str, r[i])))


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

int main() {
    double a, b;
    while (cin >> a >> b) {
        if (a < 35.5 && b < 71) {
            cout << "AAA" << endl;
        } else if (a < 37.5 && b < 77) {
            cout << "AA" << endl;
        } else if (a < 40 && b < 83) {
            cout << "A" << endl;
        } else if (a < 43 && b < 89) {
            cout << "B" << endl;
        } else if (a < 50 && b < 105) {
            cout << "C" << endl;
        } else if (a < 55 && b < 116) {
            cout << "D" << endl;
        } else if (a < 70 && b < 148) {
            cout << "E" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	static const ULL M = 998244353;

	void Solve(){
		ULL N, A, B, K; cin >> N >> A >> B >> K;

		vector<ULL> C(N + 1);
		{
			vector<ULL> I(N + 1); I[1] = 1;
			for (UL i = 2; i <= N; i++) I[i] = M - M / i * I[M % i] % M;
			vector<ULL> iF(N + 1); iF[0] = 1;
			for (UL i = 1; i <= N; i++) iF[i] = iF[i - 1] * I[i] % M;
			vector<ULL> F(N + 1); F[0] = 1;
			for (UL i = 1; i <= N; i++) F[i] = F[i - 1] * i % M;
			rep(i, N + 1) C[i] = F[N] * iF[i] % M * iF[N - i] % M;
		}

		ULL ans = 0;
		rep(i, N + 1) {
			ULL AA = A * i;
			if (AA > K) continue;
			if ((K - AA) % B != 0) continue;
			ULL j = (K - AA) / B;
			if (j > N) continue;
			ans += C[i] * C[j] % M;
		}
		ans %= M;
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 9600
N=int(input())
D,X=map(int,input().split())
A=[int(input()) for i in range(N)]
cnt=0
for i in range(N):
    cnt+=1
    day=1
    for j in range(1,101):
        if D>=j*A[i]+1:
            day=j*A[i]+1
            cnt+=1
        else:
            break
print(cnt+X)

Measured memory_bytes: 3060
/*
 * @Author: Kaizyn
 * @Date: 2020-03-07 20:53:28
 * @LastEditors: Kaizyn
 * @LastEditTime: 2020-03-07 21:00:56
 * @FilePath: \Code\atcoder\abc158D.cpp
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 1e5+7;
const int MOD = 1e9+7;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;

string s, pre, bac;
int q, rev;

inline void solve()
{
    int t, f;
    char c;
    cin >> s >> q;
    while (q--) {
        cin >> t;
        if (t == 1) rev ^= 1;
        else {
            cin >> f >> c;
            if (f == 1 && rev) {
                bac += c;
            } else if (f == 1 && !rev) {
                pre += c;
            } else if (f == 2 && rev) {
                pre += c;
            } else {
                bac += c;
            }
        }
    }
    if (!rev) {
        reverse(pre.begin(), pre.end());
        cout << pre << s << bac << endl;
    } else {
        reverse(bac.begin(), bac.end());
        reverse(s.begin(), s.end());
        cout << bac << s << pre << endl;
    }
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}
typedef tuple<int, int, int, int> tset;

int coinmap[510][510] = {0};

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

    rep(i, h)rep(j, w){
        int tmp; cin >> tmp;
        coinmap[i][j] = tmp%2;
    }

    // rep(i, h){
    //     rep(j, w){
    //     cout <<coinmap[i][j];
    //     }
    //     cout << endl;
    // }

    vector<tset> sousa;
    rep(i, h)rep(j, w){
        if (coinmap[i][j]){
            if (i == h-1 && j == w-1) continue;
            tset tmp;
            coinmap[i][j] ^= 1;
            if (j != w-1){
                coinmap[i][j+1] ^= 1;
                tmp = make_tuple(i+1, j+1, i+1, j+2);                
            } else {
                coinmap[i+1][j] ^= 1;
                tmp = make_tuple(i+1, j+1, i+2, j+1);                
            }
            sousa.push_back(tmp);
        }
    }

    cout << sousa.size() << endl;
    rep(i, sousa.size()){
        cout << get<0>(sousa[i]) << " " << get<1>(sousa[i]) << " "  << get<2>(sousa[i]) << " "  << get<3>(sousa[i]) << endl;
    }

}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)

int n;
vector<int> A;

void insertionSort(int n) {
    REP(i, n) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        REP(k, n - 1) cout << A[k] << " ";
        cout << A[n - 1] << endl;
    }
}

int main() {
    cin >> n;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    insertionSort(n);
    return 0;
}

Measured memory_bytes: 3140
"""
14:07-
"""
import bisect
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))

MOD = 10 ** 9 + 7

A.sort()
B.sort()

if any([a == b for a, b in zip(A[:-1], A[1:])]) or any([a == b for a, b in zip(B[:-1], B[1:])]):
    # 同じのが複数ある
    print(0)
    exit()
if max(A) != N * M or max(B) != N * M:
    # 最大値がおかしい
    print(0)
    exit()

fixed = 0
ans = 1
top = len(A) - 1
left = len(B) - 1
for k in range(1, N * M + 1)[::-1]:
    # k が入る場所どこ？
    while top - 1 >= 0 and A[top - 1] >= k:
        top -= 1
    while left - 1 >= 0 and B[left - 1] >= k:
        left -= 1
    top = bisect.bisect_left(A, k)
    left = bisect.bisect_left(B, k)
    if A[top] == k and B[left] == k:
        # このマスに入れるしかない
        pattern = 1
        fixed += 1
    elif A[top] == k:
        # この行のどっか
        pattern = len(B) - left
        fixed += 1
    elif B[left] == k:
        # この列のどっか
        pattern = len(A) - top
        fixed += 1
    else:
        # どこでも OK
        pattern = (len(A) - top) * (len(B) - left) - fixed
        fixed += 1
    ans *= pattern
    ans %= MOD
print(ans)


Measured memory_bytes: 3188
from sys import stdin
from collections import defaultdict
input = stdin.readline
# ~ T = int(input())
T = 1
for t in range(1,T + 1):
	s = input()
	s = s[:len(s) - 1]
	if s[len(s) - 1] == 's':
		s += 'es'
	else:
		s += 's'
	print(s)


Measured memory_bytes: 9332
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	long long x = min(n, b - 1);
	long long ans = a * x / b;
	cout << ans << endl;
	return 0;
}


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

namespace abc100_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(x.Max() <= 8 ? "Yay!" : ":(");
        }
    }
}


Measured memory_bytes: 13396
package main

// Solution for https://atcoder.jp/contests/abc073/tasks/abc073_b

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	s := 0
	for i := 0; i < n; i++ {
		var l, r int
		con.Scan(&l, &r)
		s += r - l + 1
	}
	con.Println(s)
	return nil
}


Measured memory_bytes: 1868
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    funds = 1000
    stock = 0

    for i in range(n):
        if i > 0 and A[i] > A[i-1]:
            # sell
            funds += A[i] * stock
            stock = 0
        if i < n-1 and A[i] < A[i+1]:
            # buy
            stock += funds // A[i]
            funds -= A[i] * stock

    print(funds)

resolve()

Measured memory_bytes: 61792
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let n: i64 = s.parse().unwrap();

    let odd_num = (n+1) / 2;
    println!("{}", odd_num as f64 / n as f64)
}


Measured memory_bytes: 4352
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

l=I()
print((l/3)**3)



Measured memory_bytes: 39020
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, M;

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

  cin >> N >> M;

  if (N >= 3 && M >= 3) {
    cout << (ll)(N - 2) * (M - 2) << endl;
  }
  else if (N == 1 && M == 1) {
    cout << 1 << endl;
  }
  else if (N == 1 || M == 1) {
    if (N == 1) {
      cout << M - 2 << endl;
    }
    else {
      cout << N - 2 << endl;
    }
  }
  else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
$h = Hash.new(false)
def solve(s)
    return true if s == "" || s == "mew"
    return $h[s] if $h.has_key?(s)
    return false if s[0] != "m" || s[s.length - 1] != "w"
    t = s[1...(s.length - 1)]
    if !t.index("e")
        $h[s] = false
        return false
    end
    t.each_char.with_index do |c, i|
        next if c != "e"
        if solve(t[0...i]) && solve(t[(i+1)...t.length])
            $h[s] = true
            return true
        end
    end
    $h[s] = false
    return false
end
s = gets.chomp
puts solve(s) ? "Cat" : "Rabbit"

Measured memory_bytes: 11524
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define debug(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

constexpr ll LL_MOD = 1000000009;
constexpr int I_MOD = 1000000007;
constexpr double EPS = numeric_limits<double>::epsilon();
constexpr double PI = 3.14159265358979323846264338327950288;

void sI(int *pa, int size);
void sLL(ll *pa, int size);
void sD(double *pa, int size);
void sC(char *pa, int size);
void wS(string *ps, int size);
void lS(string *ps, int size);

bool dp[5001][5000];
bool dp2[5001][5000];

int main(int argc, char *argv[]) {
	// INFILE();
  int n, k;
  int needs = 0;

  cin >> n >> k;

  int cards[n];
  sI(cards, n);

  for (int i = 0; i < 5001; ++i) {
    dp[i][0] = dp2[i][0] = true;
  }

  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < k; ++j) {
      bool prev = (j - cards[i - 1] < 0) ? false : dp[i - 1][j - cards[i - 1]];
      if (dp[i - 1][j] || prev) {
        dp[i][j] = true;
      }

      bool prev2 =
          (j - cards[n - i] < 0) ? false : dp2[i - 1][j - cards[n - i]];
      if (dp2[i - 1][j] || prev2) {
        dp2[i][j] = true;
      }
    }
  }

  for (int i = 0; i < n; ++i) {
    if (cards[i] >= k) {
      needs++;
      continue;
    }

    bool b = false;

    for (int nv = k - cards[i]; nv < k; ++nv) {
      if (i == 0) {
        if (dp2[n - 1][nv]) {
          needs++;
          b = true;
          break;
        }
        continue;
      }

      if (i == n - 1) {
        if (dp[n - 1][nv]) {
          needs++;
          b = true;
          break;
        }
        continue;
      }

      for (int nv2 = 0; nv2 <= nv; ++nv2) {
        if (dp[i][nv2] && dp2[n - i - 1][nv - nv2]) {
          b = true;
          needs++;
          break;
        }
      }

      if (b)
        break;
    }
  }

  cout << n - needs << "\n";
  return 0;
}

void sI(int *pa, int size) {
  for (int i = 0; i < size; ++i) {
    scanf("%d", pa + i);
  }
}

void sLL(ll *pa, int size) {
  for (int i = 0; i < size; ++i) {
    scanf("%lld", pa + i);
  }
}

void sD(double *pa, int size) {
  for (int i = 0; i < size; ++i) {
    scanf("%lf", pa + i);
  }
}

void sC(char *pa, int size) {
  for (int i = 0; i < size; ++i) {
    scanf(" %c", pa + i);
  }
}

void wS(string *ps, int size) {
  for (int i = 0; i < size; ++i) {
    cin >> ps[i];
  }
}

void lS(string *ps, int size) {
  int i = 0;
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    ps[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, ps[i]);
  }
}


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

// main.cpp

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::vector<std::int_fast64_t> buckets(n + 1, 0);
  std::int_fast64_t answer = 0;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t a_i;
    std::cin >> a_i;
    if (a_i > n) ++answer;
    else ++buckets[a_i];
  }
  for (std::int_fast64_t i = 0; i <= n; ++i) {
    answer += buckets[i] >= i ? buckets[i] - i : buckets[i];
  }
  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll H,W;
  cin>>H>>W;
  ll h=(H+1)/2;
  ll w=(W+1)/2;
  ll ans=MOD;
  if(H%3==0)ans=0;
  else ans=min(ans,W);
  if(W%3==0)ans=0;
  else ans=min(ans,H);
  for(ll i=1;i<H;i++){
    ans=min(ans,max(abs(W*i-w*(H-i)),max(abs(W*i-(W-w)*(H-i)),(H-i)*(2*w-W))));
  }
  for(ll i=1;i<W;i++){
    ans=min(ans,max(abs(H*i-h*(W-i)),max(abs(H*i-(H-h)*(W-i)),(W-i)*(2*h-H))));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

s = ""
for i in S:
	if ord(i)+N<=90:
		s = s + chr(ord(i) + N)
	else:
		s = s + chr(ord(i) + N - len(ascii_uppercase))

print(s)

Measured memory_bytes: 62184
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    ll a,sum=0;
    rep(i,n){
        cin>>a;
        sum+=a-1;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#define INF 1000000000
#define MN 200005
using namespace std;
vector<long long> vec;
int n, k;
int a[MN];
long long left[MN][2], right[MN][2];
int main() {
	scanf("%d", &n);
	int i;
	for (i = 1; i <= n; i++) scanf("%d", &a[i]);
	int l = 1;
	long long lsum = a[1],rsum=0;
	for (i = 2; i <= n - 2; i++) {
		rsum += a[i];
		while (abs(rsum - lsum) > abs(rsum - a[l + 1] - (lsum + a[l+1]))) {
			l++; lsum += a[l]; rsum -= a[l];
		}
		left[i][0] = lsum; left[i][1] = rsum;
	}
	lsum = a[n]; rsum = 0;
	l = n;
	for (i = n-1; i >=3; i--) {
		rsum += a[i];
		while (abs(rsum - lsum) > abs(rsum - a[l - 1] - (lsum + a[l - 1]))) {
			l--; lsum += a[l]; rsum -= a[l];
		}
		right[i][0] = lsum; right[i][1] = rsum;
	}
	long long ans = -1;
	for (i = 2; i <= n - 2; i++) {
		vec.clear();
		vec.push_back(left[i][0]);
		vec.push_back(left[i][1]);
		vec.push_back(right[i + 1][0]);
		vec.push_back(right[i + 1][1]);
		sort(vec.begin(), vec.end());
		if (ans == -1) ans = vec[3] - vec[0];
		else ans = ans > (vec[3] - vec[0]) ? vec[3] - vec[0] : ans;
	}
	printf("%lld", ans);
	return 0;
}




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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

const int MOD = 1000000007;

template<typename T>
T pown(T b, ll e) {
    if(e == 0) return 1;
    T p = pown(b, e / 2);
    if(e % 2 == 0) return p * p;
    return p * p * b;
}

template<const int mod>
struct Intmod {
    ll a;
    Intmod(ll a = 0): a(((a % mod) + mod) % mod) {}

    Intmod operator-() const {return Intmod(-a);}

    Intmod& operator+=(const Intmod b) {
        if((a += b.a) >= mod) a -= mod;
        return *this;
    }
    Intmod& operator+=(const ll b) {
        if((a += b) >= Intmod(mod).a) a -= mod;
        return *this;
    }
    Intmod& operator-=(const Intmod b) {
        if((a -= b.a) < 0) a += mod;
        return *this;
    }
    Intmod& operator-=(const ll b) {
        if((a -= Intmod(b).a) < 0) a += mod;
        return *this;
    }
    Intmod& operator*=(const Intmod b) {
        (a *= b.a) %= mod;
        return *this;
    }
    Intmod& operator*=(const ll b) {
        (a *= Intmod(b).a) %= mod;
        return *this;
    }

    template<typename T> Intmod operator+(const T b) const {return Intmod(*this) += b;}
    template<typename T> Intmod operator-(const T b) const {return Intmod(*this) -= b;}
    template<typename T> Intmod operator*(const T b) const {return Intmod(*this) *= b;}

    // Valid for prime mod. pown() needs to be included.
    int i = 0;
    Intmod inv() {
        if(a == 0) throw "Inverse of zero does not exist.";
        if(!i) i = pown(*this, mod - 2).a;
        return Intmod(i);
    }
    Intmod& operator/=(const Intmod b) {return *this *= b.inv();}
    Intmod& operator/=(const ll b) {return *this *= Intmod(b).inv();}
    template<typename T> Intmod operator/(const T b) const {return Intmod(*this) /= b;}
};
template<const int mod> Intmod<mod> operator+(const ll b, Intmod<mod> a) {return a += b;}
template<const int mod> Intmod<mod> operator-(const ll b, Intmod<mod> a) {return a -= b;}
template<const int mod> Intmod<mod> operator*(const ll b, Intmod<mod> a) {return a *= b;}
template<const int mod> Intmod<mod> operator/(const ll b, Intmod<mod> a) {return a /= b;} //Valid for prime mod.

Intmod<MOD> comb(int n, int r) {
    Intmod<MOD> ret = 1;

    if(r > n / 2) r = n - r;

    rep(i, r) ret *= n - i;
    rep(i, r) ret /= i + 1;

    return ret;
}

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

    int s;
    cin >> s;

    Intmod<MOD> ans = 0;
    int left;

    for(int i = 1; i <= s / 3; ++i) {
        left = s - i * 3;
        ans += comb(left + i - 1, i - 1);
    }

    printf("%d\n", ans.a);

    return 0;
}

Measured memory_bytes: 3720
n=int(input())
book={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
    s=input()
    book[s]+=1
print("AC x "+ str(book["AC"]))
print("WA x "+ str(book["WA"]))
print("TLE x "+ str(book["TLE"]))
print("RE x "+ str(book["RE"]))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	priority_queue<int> pq;
	string s;
	int k;
	while(cin >> s) {
		if(s == "insert") {
			cin >> k;
			pq.push(k);
		} else if(s == "extract") {
			P(pq.top());
			pq.pop();
		} else if(s == "end") break;
	}
	return 0;
}

Measured memory_bytes: 6876
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int mod = (int)1e9 + 7;
        long sum = 0;
        for(int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        long res = 0;
        for(int i = n - 1; i >= 0; i--){
            res += arr[i] * sum;
            sum += (long)arr[i];
            sum %= mod;
            res %= mod;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 59768
H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

black = []
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            black.append((i, j))

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
flag = [False] * len(black)
index = 0
for y, x in black:
    index += 1
    for i, j in zip(dx, dy):
        nx = x + i
        ny = y + j
        if 0 <= nx < W and 0 <= ny < H:
            if maze[ny][nx] == '#':
                flag[index - 1] = True
                #continue
        #else:
            #continue
        
if all(flag):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
// ------------------------------------
// Date:2018/ 2/26
// Problem:ABC 051 SumOfThreeIntegers b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

#define MOD 1000000007

int main()
{
  int K,S,cnt = 0;
  cin >> K >> S;
  REP(i,K+1) {
    REP(j,K+1) {
      if (S-i-j >= 0 && S-i-j <= K) {
        ++cnt;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

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

    a = toupper(a[0]);
    b = toupper(b[0]);
    c = toupper(c[0]);

    std::cout << a[0] << b[0] << c[0] << std::endl;
}

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

int main() {
	string s;
	cin>>s;
	ll cnt1,cnt0;
	cnt1=cnt0=0;
	for(ll i=0;i<s.size();i++){
		char now=s[i];
		if(now=='0'){
			cnt0++;
		}
		else{
			cnt1++;
		}
	}
	cout << min(cnt1,cnt0)*2;
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456][2], cnt[213456];
int keta(int x) {
	int res = 0;
	while(x >= 1) {
		x /= 10; res++;
	}return res;
}
void output(int x) {
	for (int i = 0; i < 6 - keta(x); i++)cout << '0'; cout << x; return;
}
signed main() {
	int n, m, a, b; cin >> n >> m;
	vector<vector<int> > G(n + 1);
	for (int h = 0; h < m; h++) {
		cin >> a >> b;
		test[h][0] = a; test[h][1] = b;
		G[a].push_back(b); cnt[a]++;
	}
	for (int h = 0; h <= n; h++) {
		sort(G[h].begin(), G[h].end());
	}
	for (int h = 0; h < m; h++) {
		int ok = 0, ng = cnt[test[h][0]], mid = (ok + ng) / 2;
		while (ng - ok > 1) {
			if (G[test[h][0]][mid] > test[h][1]) { ng = mid; }
			else { ok = mid; }
			mid = (ok + ng) / 2;
		}
		output(test[h][0]); output(ok + 1); cout << endl;
	}
	cin >> n;
	return 0;
}

Measured memory_bytes: 10112
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<ll> a(n);

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

  sum %= mod;
  ll ans = 0;
  REP(i, n) {
    sum -= a[i];
    if(sum < 0) sum += mod;

    ans += a[i] * sum;
    ans %= mod;
  }
  cout << ans << endl;

}


Measured memory_bytes: 4780
#include<iostream>
using namespace std;
int main(){
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(s.length()>k)
  {
    for(int i=0;i<k;i++)
    {
      cout<<s[i];
    }
    cout<<"...";
  }
  else
  cout<<s;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while(1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }

        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }

    }
}

Measured memory_bytes: 3636
var GET = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));
    return f?r:r.map(a=>a.map(a=>+a));
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+=n);
    return f?r:r.map(a=>+a);
  }
  return f;
})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var m = 0;
  for(var i = 0; i < n; i++){
    m += a[i];
  }
  m /= n;
  var k = 9e9, f = 0;
  for(i = 0; i < n; i++){
    var t = Math.abs(m - a[i]);
    if(t < k)k = t, f = i;
  }
  return f;
}

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

int main(){
  int ctr[40] = {0};
  int bts[40] = {0};
  int n;
  long k;
  
  cin >> n >> k;
  
  for(int i=0; i<n; i++){
    long long a;
    cin >> a;
    for(int b=0; b<40; b++){
      if(a & 1 == 1) ctr[b]++;
      a >>= 1;
    }
  }
  
  for(int i=0; i<40; i++){
    if( ctr[i] <= n/2 ) bts[i] = 1;
  }
  
  long long x = 0;
  for(int i=39; i>=0; i--){
    if(bts[i] == 1){
      if( x + ((long)1<<i) <= k){
        x += ((long)1<<i);
      } else {
        bts[i] = 0;
      }
    }
  }
  
  long long ans = 0;
  for(int i=0; i<40; i++){
    if(bts[i] == 0){
      ans += ((long)1<<i) * ctr[i];
    } else {
      ans += ((long)1<<i) * (n - ctr[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let x: i64 = read();
    let y: i64 = read();
    let mut ans = a * x + b * y;
    for i in 0..std::cmp::max(x, y) + 1 {
        let sum = i * 2 * c + a * std::cmp::max(0, x - i) + b * std::cmp::max(0, y - i);
        ans = std::cmp::min(ans, sum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int D,N; cin>>D>>N;
    if(D==0) {
        if(N==100) cout<<101<<endl;
        else cout<<N<<endl;
    }
    else if(D==1) {
        if(N==100) cout<<101*100<<endl;
        else cout<<N*100<<endl;
    }
    else if(D==2) {
        if(N==100) cout<<101*100*100<<endl;
        else cout<<N*100*100<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

int a[100];
signed main(){
  int n,k;cin>>n>>k;
  rep(i,n)cin>>a[i];
  sort(a,a+n,greater<int>());
  int ans=0;
  rep(i,k)ans+=a[i];
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//#define READ_NUMBER(i) scanf("%d",i)
 
int main(){
	int count_0 = 0;
	int count_1 = 0;
	string S;
	cin >> S;
	int length = S.length();
	for(int i = 0;i < length;i++){
		if(S.at(i) == '0'){
			count_0++;
		}else{
			count_1++;
		}
	}
	cout << length - abs(count_0 - count_1) << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

/* #include <bits/stdc++.h> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int r,d,x;
    while (cin >> r >> d >> x) {
        FOR(i,1,11) {
            x = r*x - d;
            cout << x << endl;
        }
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    long long int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    long long int r=0;
    long long int p=a[0]; long long int x=a[0];
    long long int ans=0;
    for(long long int l=0;l<n;l++){
        while(p==x && r<n){
            r++;
            if(r<n){
                p+=a[r]; x^=a[r];
            }
        }
        ans+=(r-l);
        p-=a[l]; x^=a[l];
    }
    cout << ans;
}

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


int main()
{
	int N;
	cin>>N;
	string S;
	cin>>S;
	vector<int> l(N+1);
	l[0]=0;
	vector<int> r(N+1);
	r[0]=0;
	rep(i,N)
	{
		r[i+1]=r[i];
		if(S[i]=='W') r[i+1]++;
	}
	rep(i,N)
	{
		l[i+1]=l[i];
		if(S[N-1-i]=='E') l[i+1]++;
	}
	int ans=N;
	rep(i,N)
	{
		int val=r[i]+l[N-1-i];
		ans=min(ans,val);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6144