akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

ll euclid(ll a, ll b) {
    ll r;
    while(b) {
        r = a % b;
        a = b;
        b = r;
    }

    return a;
}

ll getcmmc(ll a, ll b) {
    ll cmmdc = euclid(a, b);
    return (a * b) / cmmdc;
}

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

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

    ll n, m;
    cin >> n >> m;
    vector<ll> v(n + 1, 0);
    ll cmmc = 1;
    for(int i = 1; i <= n; i ++) {
        cin >> v[i];
        v[i] /= 2;

        cmmc = getcmmc(cmmc, v[i]);
    }


    ll ans = m / cmmc;
    if(ans == 0) {
        cout << 0;
        return 0;
    }
    for(int i = 1; i <= n; i ++) {
        if((cmmc / v[i]) % 2 == 0) {
            cout << 0;
            return 0;
        }
    }

    ans = (ans + 1) / 2;
    cout << ans;

    return 0;
}


Measured memory_bytes: 1024
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)
var sc *bufio.Scanner
func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}
const MOD = 1000000007
const DIV = 13
const BASE = 10
func main() {
    sc = bufio.NewScanner(os.Stdin)
sc.Buffer(make([]byte, 0), 1000000009)
    sc.Split(bufio.ScanWords)
    sc.Scan()
    rs := append([]rune{'0'}, []rune(sc.Text())...)
    n := len(rs) - 1
    dp := make([][]int, n+1)
    for i := range dp {
        dp[i] = make([]int, DIV)
    }
    dp[0][0] = 1
    for i := 1; i <= n; i++ {
        var digit int
        switch {
        case rs[i] == '?':
            digit = -1
        default:
            digit = int(rs[i] - '0')
        }
        for j := 0; j < BASE; j++ {
            if digit != -1 && digit != j {
                continue
            }
            for k := 0; k < DIV; k++ {
                dp[i][(k*BASE+j)%DIV] = (dp[i][(k*BASE+j)%DIV] + dp[i-1][k]) % MOD
            }
        }
    }
    fmt.Println(dp[n][5])
}


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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}

const int N = 600, K = 600, OO = 0x3f3f3f3f;

ll power(ll b, ll p){
    if(p == 0)return 1;
    ll res = power(b,p/2);
    res *= res;
    //res %= modulo;
    if(p & 1)res *= b;
    return res;// % modulo;
}

int main(){
    init();

    int n;  cin >> n;
    cout << power(n, 3);
}

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

using namespace std;
typedef long long ll;

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

   vector<ll> a(n + 1), b(n);
   for (int i = 0; i < n + 1; i++)
      cin >> a.at(i);
   for (int i = 0; i < n; i++)
      cin >> b.at(i);
   ll cnt = 0;
   ll b_tmp;
   for (int i = 0; i < n; i++)
   {
      if (a.at(i) > b.at(i))
      {
         cnt += b.at(i);
         continue;
      }
      else
      {
         cnt += a.at(i);
         b.at(i) -= a.at(i);
         if (a.at(i + 1) > b.at(i))
         {
            a.at(i + 1) -= b.at(i);
            cnt += b.at(i);
         }
         else
         {
            cnt += a.at(i + 1);
            a.at(i + 1) = 0;
         }
      }
   }

   cout << cnt << endl;

   return 0;
}


Measured memory_bytes: 1792
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = map(int, readline().split())

    print((a + b + 1) // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61828
#include <iostream>
#include <vector>
#include <string.h>

#define pb push_back

using namespace std;

int dp[35];

int main(void)
{
	int n;
	int maxx=0;
	vector<int> v;
	int year;
	int i1;

	while(1){
		cin>>n;
		if(n==0) break;
		v.pb(n);
		maxx=max(maxx,n);
	}

	dp[0]=1;
	dp[1]=1;
	dp[2]=2;
	for(i1=3;i1<=maxx;i1++){
		dp[i1]=dp[i1-1]+dp[i1-2]+dp[i1-3];
	}

	for(i1=0;i1<v.size();i1++){
		if(dp[v[i1]]%10==0) {
			year=dp[v[i1]]/10;
		}
		else {
			year=dp[v[i1]]/10+1;
		}

		if(year%365==0){
			year=year/365;
		}
		else {
			year=year/365+1;
		}
		cout<<year<<endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k, n;
int main()
{

    while(scanf("%lld", &k)==1)
    {
        n = 50;
        printf("%lld\n", n);
        ll a = k / n, b = k % n;
        int cot = 0;
        for(ll i = 1; i <= b; i++)
        {
            cot++;
            cout << 49 + a + 50 - (b-1) << (cot == n ? '\n' : ' ');
        }
        for(ll i = 1; i <= (n - b); i++)
        {
            cot++;
            cout << 49 + a - b << (cot == n ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin >> s;
    for (int i=1; i<=s.length(); i++){
        if ( (i%2==0 && s[i-1]=='R') || (i%2==1 && s[i-1]=='L') ){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
s={}

for _ in range(n):
    ss = str(sorted(input()))
    if ss not in s:
        s[ss] = 1
    else:
        s[ss] += 1

ans=0
for c in s.values():
    ans += (c*(c-1)//2)
print(ans)


Measured memory_bytes: 22372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    COMinit();

    ll N, K;
    cin >> N >> K;

    vector<ll> p(N);
    vector<double> d(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> p[i];
        if(i != 0) d[i] = d[i-1] + (1.0+p[i])/2;
        else d[i] = (1.0+p[i])/2;

    }

    double maxv = 0;
    for(int i = 0; i + K - 1 < N;i++) {
        if(i != 0) maxv = max(maxv, d[i + K - 1] - d[i-1]);
        else maxv = max(maxv,  d[i + K - 1]);
    }

    cout << fixed << setprecision(10) << maxv << endl;



    return 0;
}


Measured memory_bytes: 15360
/*
int n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToList();
*/

using System;
using System.Linq;
using System.Collections.Generic;

namespace abc088b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int num = s.Length;
            string ans = "";
            var temp = Enumerable.Repeat("x", num).ToList();
            foreach (var item in temp)
            {
                ans += item;
            }
            Console.Write(ans);
        }
    }
}
    /*

    var s = Console.ReadLine().Split().ToArray();
    var a = Console.ReadLine().Split().Select(b => int.Parse(b)).ToArray();
    var u = Console.ReadLine();
            if(s.All(name => name == u))
            {
                Console.WriteLine(a[0]);
                Console.WriteLine(a[1]);
            }
            else
            {
                if (u == s[0])
                {
                    a[0] = a[0] - 1;
                    Console.Write($"{a[0]} {a[1]}");
                }
                else
                {
                    a[1] = a[1] - 1;
                    Console.Write($"{a[0]} {a[1]}");

                }

            }
        }
*/


Measured memory_bytes: 13268
n, k = map(int, input().split())
a = list(map(int, input().split()))

l = 0
r = 10**9 + 1
ref = 0
ans = 10**9

while r - l > 1:
    now = (l + r)//2
    for i in a:
        ref += 0 - -i//now - 1
    if ref <= k:
        ans = now
        ref = 0
        r = now
    else:
        ref = 0
        l = now
print(ans)

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

int main() {
    ll N, T; cin >> N >> T;
    vector<ll> t(N + 1);
    ll cnt = T;
    for (int i = 1; i <= N; i++){
        cin >> t[i];
        cnt += min(T, t[i] - t[i-1]);
    }
    cout << cnt << endl;
}



Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

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()

def factorization(n):
   arr = []
   temp = n
   for i in range(2, int(-(-n**0.5//1))+1):
       if temp%i==0:
           cnt=0
           while temp%i==0:
               cnt+=1
               temp //= i
           arr.append([i, cnt])
   if temp!=1:
       arr.append([temp, 1])
   if arr==[]:
       arr.append([n, 1])
   return arr
if N == 1:
	print(1)
	sys.exit()

dic = defaultdict(int)
for i in range(2, N+1):
	fact = factorization(i)
	for n, power in fact:
		dic[n] += power

ans = 1
for n in dic.values():
	ans = (ans*(n+1))%mod
print(ans)


Measured memory_bytes: 19496
N = int(input())
H = [int(s) for s in input().split(" ")]

max = 0
current = 0

for i in range(1, N):
    if H[i] <= H[i-1]:
        current = current + 1
    else:
        if current > max:
            max = current
        current = 0

if current > 0:
    if current > max:
        max = current

print(max)

Measured memory_bytes: 14252
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}
	for y > 0 {
		r := x % y
		x = y
		y = r
	}
	return x
}

func main() {
	n, _ := strconv.Atoi(input())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
	}
	left := make([]int, n+2)
	right := make([]int, n+2)
	left[0] = 0
	for i := 0; i < n; i++ {
		left[i+1] = gcd(left[i], a[i])
	}
	right[n+1] = 0
	for i := n; i > 0; i-- {
		right[i] = gcd(right[i+1], a[i-1])
	}
	m := make([]int, n)
	for i := 0; i < n; i++ {
		m[i] = gcd(left[i], right[i+2])
	}
	ans := m[0]
	for i := 1; i < n; i++ {
		ans = max(m[i], ans)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(S: str):
    if len(set(list(S))) == 1:
        no()
    else:
        yes()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


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

#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repn(i, n) for(int i = 1; i < n; ++i)
#define repm(n, m)  for(int i = n; i <= m; ++i)

int main(){
    int n; cin >> n;
    int count[4];
    set<string> set;
    rep(i, n){
        string s; cin >> s;
        set.insert(s);
    }
    
    string ans;
    if(set.size() == 4) ans = "Four";
    else if(set.size() == 3)    ans = "Three";

    cout << ans << endl;

    return 0;
}


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

bool graph[50][50];
bool visited[50];
int A[50], B[50];

void dfs(int v, int N)
{
    visited[v] = true;
    rep(i, N)
    {
        if (graph[v][i] == false)
            continue;
        if (visited[i] == true)
            continue;
        dfs(i, N);
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        A[i] = b - 1;
        B[i] = a - 1;
        graph[a - 1][b - 1] = true;
        graph[b - 1][a - 1] = true;
    }
    int counter = 0;
    rep(i, M)
    {
        rep(i, N) visited[i] = false;
        int a = A[i];
        int b = B[i];
        graph[a][b] = false;
        graph[b][a] = false;
        dfs(0, N);
        bool ans = true;
        rep(i, N)
        {
            if (visited[i] == false)
            {
                ans = false;
                break;
            }
        }
        if (ans == false)
            counter++;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
 
vector<char> sol[200005];
int main(){
	string s;
	cin>>s;
	if(s=="ABC")cout<<"ARC";
	else cout<<"ABC";
}

Measured memory_bytes: 8316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int n, r;

int main()
{
    read(n), read(r);
    printf("%d\n", n < 10 ? 100 * (10 - n) + r : r);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int h,w,n,sr,sc;
    cin>>h>>w>>n>>sr>>sc;
    string s,t;
    cin>>s>>t;
    bool ans=true;
    int l=1,r=w;
    if(s[n-1]=='R')--r;
    else if(s[n-1]=='L')++l;
    if(r<l)ans=false;
    for(int i=n-2;i>=0;--i){
        if(t[i]=='R')l=max(l-1,1);
        else if(t[i]=='L')r=min(r+1,w);
        if(s[i]=='R')--r;
        else if(s[i]=='L')++l;
        if(r<l){
            ans=false;
            break;
        }
    }
    if(sc<l||r<sc)ans=false;
    int d=1,u=h;
    if(s[n-1]=='D')--u;
    else if(s[n-1]=='U')++d;
    if(u<d)ans=false;
    for(int i=n-2;i>=0;--i){
        if(t[i]=='D')d=max(d-1,1);
        else if(t[i]=='U')u=min(u+1,h);
        if(s[i]=='D')--u;
        else if(s[i]=='U')++d;
        if(u<d){
            ans=false;
            break;
        }
    }
    if(sr<d||u<sr)ans=false;
    cout<<(ans?"YES":"NO")<<endl;
}


Measured memory_bytes: 776
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll K, S;
    cin >> K >> S;
    ll ans = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - (x + y);
            if (0 <= z && z <= K) ans++;
        }
    }
    cout << ans << '\n';
}


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

using namespace std;

class unionFind{
    int nodeSize;
    vector<int> parent;

public:
    unionFind(int n):nodeSize(n){
        parent = vector<int>(n+1,-1);
    }

    int getRoot(int a){
        if(parent[a] < 0){
            return a;
        }
        return parent[a] = getRoot(parent[a]);
    }

    bool isSameParent(int a,int b){
        return getRoot(a) == getRoot(b);
    }

    bool isRoot(int a){
        if(parent[a] < 0){
            return true;
        }
        return false;
    }

    void unite(int a,int b){
        if(isSameParent(a,b)){
            return;
        }
        int aParent = getRoot(a);
        int bParent = getRoot(b);

        if(abs(parent[aParent]) > abs(parent[bParent])){
            parent[aParent] += parent[bParent];
            parent[bParent] = aParent;
        }else{
            parent[bParent] += parent[aParent];
            parent[aParent] = bParent;
        }
    }
};

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

    vector<int> x(m),y(m),z(m);
    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i] >> z[i];
    }

    unionFind uf(n);

    for(int i = 0; i < m; i++){
        uf.unite(x[i],y[i]);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(uf.isRoot(i)){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    ll n;
    cin>>n;
    ll ans = 0;
    ll now = 100;
    while(now < n){
        now += now/100;
        ans++;
    }
    cout << ans<< endl;
}

Measured memory_bytes: 3648
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = ["".join(sorted(str(readline().rstrip().decode('utf-8')))) for _ in range(n)]
    s = collections.Counter(s).most_common()
    t = 0
    for k, v in s:
        if v > 1:
            t += (1 + v - 1) * (v - 1) // 2
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 71644
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long
#define ld long double

int main(){
    ll n=0,m=0,d=0;
    ld ans=0.0;
    cin>>n>>m>>d;
    if(d!=0){
        ans=(ld)(2.0*(n-d))*((m-1.0)/(ld)(n))/(ld)(n);//(ld)powl((ld)n,(ld)m);
    }else{
        ans=(ld)(m-1.0)/(ld)n;
    }
    //ans=;

    cout <<setprecision(10)<<(ld)ans<<endl;

    return 0;
}

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

int main(void)
{
    //input
    int n, m;
    cin >> n >> m;
    int tmp, sum = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> tmp;
        sum += tmp;
    }

    //output
    if (n - sum >= 0)
        cout << n - sum << endl;
    else
        cout << -1 << endl;
}


Measured memory_bytes: 3620
import java.util.Scanner;

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

		if(a.length() != b.length()) {
			if(a.length() > b.length()) System.out.print("GREATER");
			else System.out.print("LESS");
			return;
		} else {
			for (int i = 0; i < a.length(); i++) {
				if(a.charAt(i) > b.charAt(i)) {
					System.out.print("GREATER");
					return;
				} else if(a.charAt(i) < b.charAt(i)) {
					System.out.print("LESS");
					return;
				}
			}
		}

		System.out.print("EQUAL");
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  double d;
  while(cin >> d){
    string s;
    if(d<=48.0) s="light fly";
    else if(d<=51.0) s="fly";
    else if(d<=54.0) s="bantam";
    else if(d<=57.0) s="feather";
    else if(d<=60.0) s="light";
    else if(d<=64.0) s="light welter";
    else if(d<=69.0) s="welter";
    else if(d<=75.0) s="light middle";
    else if(d<=81.0) s="middle";
    else if(d<=91.0) s="light heavy";
    else s="heavy";
    cout << s << endl;
  }
  return 0;
}


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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> str(N);
  
  for(int i = 0;i < N;i ++){
    cin >> str.at(i);
  }
  
  sort(str.begin(),str.end());
  
  for(int i = 0;i < N;i ++){
    cout << str.at(i);
  }
}

Measured memory_bytes: 256
//RAY
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
int main(){

	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
		string s;
		cin >> s;
		ll count = 0, temp=0;
		ll n = s.size(), x=0;
		ll acount = 0;
			for(ll i= 0; i<n-1; i++)
			{

			 if(s[i]=='A')
						acount++;


				else if(s[i] == 'B' && s[i+1] == 'C')
				{
					count+=acount;
					i++;
				}
				else
					acount = 0;

			}

	cout << count;

return 0;
}

  

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

int dp[100001][3];

int main() {
  int n; cin >> n;
  int a[n][3];
  REP(i,n) REP(j,3) cin >> a[i][j];

  REP(i,n) {
    REP(j,3) {
      REP(k,3) {
        if (j==k) continue;
        dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i][j]);
      }
    }
  }
  int ans = 0;
  REP(i,3) ans = max(ans, dp[n][i]);
  cout << ans << endl;
}

Measured memory_bytes: 2688
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
 int a[5];
 for(int i=0;i<5; i++)
 {
  scanf("%d",&a[i]);
 }
 sort(a,a+5);
 int x=a[4]-a[0];
 int k;
 scanf("%d",&k);
 if(x<=k){printf("Yay!");}
 else{printf(":(");}
}

Measured memory_bytes: 128
/**
*    author:  y_takano
*    created: 18.06.2020 16:13:07
**/

#include <bits/stdc++.h>

using namespace std;

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

  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  if (w >= r + x && h >= r + y && r <= x && r <= y) 
  {
      cout << "Yes" << endl;
  }
  else
  {
      cout << "No" << endl;
  }
  
  return 0;
}


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

using namespace std;

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

  vector<int> a(n + 2);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }

  int64_t ans = 0;
  for (int i = 1; i < a.size(); ++i) {
    ans += abs(a[i - 1] - a[i]);
  }

  for (int i = 1; i <= n; ++i) {
    cout << ans - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) + abs(a[i - 1] - a[i + 1]) << endl;
  }
}


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

int rec(int x){
    if(x < 1) return 0;
    if(dp.at(x)!=-1) return dp.at(x);
    int res = 0;
    
    if(x==1) res =  abs(h.at(x)-h.at(0));
    else{
        res = min(abs(h.at(x)-h.at(x-1))+rec(x-1), abs(h.at(x)-h.at(x-2))+rec(x-2));
    }
    return dp.at(x)=res;
}

int main(){
    int n, res;
    cin >> n;
    rep(i,n){
        cin >> h.at(i);
        dp.at(i) = -1;
    }
    res = rec(n-1);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
int n,k;cin>>n>>k;
ll sum=0;
vector<ll> v(n);
for(int i=0;i<n;i++){cin>>v[i];sum+=v[i];}
sort(v.begin(),v.end());
for(int i=0;i<n-k;i++)sum-=v[i];
cout<<sum;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int m,d,days=0;
	for(;;){
		cin>>m>>d;
		if(m==0){return 0;}
		switch(m){
			case 2:
		days=31;break;
			case 3:
		days=60;break;
			case 4:
		days=91;break;
			case 5:
		days=121;break;
			case 6:
		days=152;break;
			case 7:
		days=182;break;
			case 8:
		days=213;break;
			case 9:
		days=244;break;
			case 10:
		days=274;break;
			case 11:
		days=305;break;
			case 12:
		days=335;break;
		}
		days+=d;
		days=days%7;
		if(days==0)cout<<"Wednesday"<<endl;
		if(days==1)cout<<"Thursday"<<endl;
		if(days==2)cout<<"Friday"<<endl;
		if(days==3)cout<<"Saturday"<<endl;
		if(days==4)cout<<"Sunday"<<endl;
		if(days==5)cout<<"Monday"<<endl;
		if(days==6)cout<<"Tuesday"<<endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
int main()
{
	int a, b, c, d;
	int at=0, tt=0;
	scanf("%d%d%d%d", &a, &b, &c, &d);

	while (a > 0) {
		a = a - d;
		tt++;
	}
	while (c > 0) {
		c = c - b;
		at++;
	}

	if (tt >= at)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 1660
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn main() {
  input! {
    n: usize,
    m: usize,
    q: usize,
    train: [(usize1, usize1); m],
    query: [(usize1, usize1); q],
  }
  let mut dp = vec![vec![0usize; n+1]; n+1];
  for &(l, r) in &train {
    dp[l][r] += 1;
  }
  for i in 0 .. n + 1 {
    for j in 0 .. n {
      dp[i][j+1] += dp[i][j];
    }
  }
  for i in (0 .. n).rev() {
    for j in 0 .. n + 1 {
      dp[i][j] += dp[i+1][j];
    }
  }
  for &(p, q) in &query {
    println!("{}", dp[p][q]);
  }
}


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

int n, join[1001];
string str;
long long int dp[1001][1 << 3], ans = 0;

int main(){
	cin >> n;
	cin >> str;
	for(int i = 0; i < n; i++){
		if(str[i] == 'J')
			join[i] = 1 << 0;
		else if(str[i] == 'O')
			join[i] = 1 << 1;
		else
			join[i] = 1 << 2;
	}

	for(int i = 0; i < (1 << 3); i++)
		if(i & join[0] && i & (1 << 0))
			dp[0][i] = 1;

	for(int i = 1; i < n; i++){
		for(int j = 0; j < (1 << 3); j++){
			for(int k = 0; k < (1 << 3); k++){
				if(j & k && j & join[i])
					dp[i][j] += dp[i - 1][k];
			}
                        dp[i][j] %= 10007;
		}
	}

	for(int i = 0; i < (1 << 3); i++)
		ans += dp[n - 1][i];
	
	cout << ans % 10007 << endl;

	return 0;
}

Measured memory_bytes: 3224
module ABC129

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_A

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer(INT16) :: cost(1:3)

    ! STEP.01
    ! read out the costs to move
    read(unit=INPUT_UNIT, fmt=*) cost(1:3)

    ! STEP.02
    ! calculate the monimium value of total cost to visit all airports
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') sum( cost(:), dim=1 ) - maxval( cost(:), dim=1 )

    ! STEP.END
    return

  end subroutine task_A

end module ABC129


program main

  ! <module>s to import
  use, non_intrinsic :: ABC129

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 768
n=int(input())
list=list(map(int,input().split()))
ans=0
for i in range(len(list)):
    if list[i]%2==0:
        if list[i]%3==0 or list[i]%5==0:
            ans=0
        else:
            ans=1
            break
print("APPROVED" if ans==0 else "DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  long long s[n];
  REP(i,n){
    cin>>s[i];
  }
  
  long long ans = 0;
  //cはa-bとする
  for(int c = 1; c<=n-2; c++){
    long long score = 0;
    bool visited[n] = {};
    int x = 0;
    while(x*c < n){
      int a = n - 1 - x*c;
      int b = a - c;
      if(a <= 0 || b <= 0)break;
      if(visited[x*c])break;
      visited[x*c] = true;
      if(visited[n-1-x*c])break;
      visited[n-1-x*c] = true;
      score += s[x*c];
      score += s[n-1-x*c];
      ans = max(ans, score);
      x++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


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

#define N 500050
#define M 500050
int f[N], nxt[N], last[N], n, m, a[N];

struct node{
    int l, r, ans, id;
}q[M];

int lowbit(int x){
    return x & (-x);
}

void add(int x, int k){
    for(int i = x; i <= n; i += lowbit(i)) {
        f[i] += k;
    }
}

int get(int x){
    int res = 0;
    for(int i = x; i; i -= lowbit(i)){
        res += f[i];
    }
    return res;
}

bool cmp(node a, node b){
    if(a.l == b.l) return a.r < b.r;
    else return a.l < b.l;
}
bool cmp1(node a, node b){
    return a.id < b.id;
}

int main(){
    cin>>n>>m;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        nxt[i] = n + 1;
        if(!last[a[i]]) last[a[i]] = i, add(i, 1);
        else nxt[last[a[i]]] = i, last[a[i]] = i;
    }
    for(int i = 1; i <= m; i++){
        scanf("%d%d", &q[i].l, &q[i].r);
        q[i].id = i;
    }
    sort(q + 1, q + 1 + m, cmp);
    int cur = 1;
    for(int l = 1; l <= n; l++){
        while(q[cur].l == l && cur <= m){
            // cout<<cur<<endl;
            q[cur].ans = get(q[cur].r) - get(q[cur].l - 1);
            cur++;
        }
        // cout<<nxt[l]<<endl;
        add(l, -1); add(nxt[l], 1);
    }
    sort(q + 1, q + 1 + m, cmp1);
    for(int i = 1; i <= m; i++){
        printf("%d\n", q[i].ans);
    }
    return 0;
}


Measured memory_bytes: 19404
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np


mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    # sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("../output.txt", "w")
except:
    pass


# @lru_cache(None)

n,D=L()
count=0
A=[L() for i in range(n)]
for i in A:
    x,y=i
    if (x*x+y*y)<=D*D:
        count+=1
print(count)


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

using namespace std;

int b[105];

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n - 1; i++) scanf("%d", &b[i]);

    int res = b[0] + b[n - 2];
    for (int i = 0; i < n - 2; i++) res += min(b[i], b[i + 1]);

    printf("%d\n", res);
}


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

map<string,int> table;
const int dir[4] = {1,-1,4,-4};
void bfs()
{
	queue<string> q;
	q.push("01234567");
	table["01234567"] = 0;
	while(!q.empty())
	{
		string now = q.front();q.pop();
		int j;
		for(j = 0;j < 8;++j)
		{
			if(now[j] == '0')
				break;
		}
		
		for(int i = 0;i < 4;++i)
		{
			int n = j + dir[i];
			if(n >= 0 && n < 8 && !(j == 3 && i == 0) && !(j == 4 && i == 1))
			{
				string next = now;
				swap(next[j],next[n]);
				if(!table.count(next))
					table[next] = table[now] + 1,q.push(next);
			}
		}
	}
}
int main()
{
	bfs();
	string line;
	while(getline(cin,line))
	{
		line.erase(remove(line.begin(),line.end(),' '),line.end());
		cout << table[line] << endl;
	}
	return 0;
}


Measured memory_bytes: 5284
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define Ifor(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dfor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Ifoz(i, a) Ifor(i, 0, a)
#define Dfoz(i, a) Dfor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int h, w, n;

int solve() {
	int x = max(h, w), y = min(h, w);
	Ifor(i, 1, y + 1) if (x * i >= n) return i;
	return -1;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> h >> w >> n;
	cout << solve() << '\n';	
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def dfs(v,path):
  for u in g[v]:
    if check[u]==0:
      check[u]=1
      path.append(u)
      return dfs(u,path)
  else:
    return path

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  u,v=map(int,input().split())
  g[u].append(v)
  g[v].append(u)
check=[0]*(n+1)
check[1]=1
ans=dfs(1,[])[::-1]
ans+=[1]
ans+=dfs(1,[])
print(len(ans))
print(*ans)

Measured memory_bytes: 103252
#include <iostream>

using namespace std;

int main(){
    int n,count = 0;
    int *syorui,*tmp;

    cin >> n;
    syorui = new int[n];
    tmp = new int[n];

    for(int i = 0;i < n;i++){
        cin >> syorui[i];
        if(syorui[i] % 2 == 0){
            tmp[count] = syorui[i];
            count++;
        }
    }

    for(int i = 0;i < count;i++){
        if(tmp[i] % 6 != 0){
            if(tmp[i] % 10 != 0){
                printf("DENIED\n");
                return 0;
            }
        }
    }

    printf("APPROVED\n");

    delete [] tmp,syorui;

    return 0;



            

    

}

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

int m, n, ans = 0, diff = 0;
char flag[1010][1010];
char sample[3][3];

int status[1010][1010];

int color(char c)
{
  if(c == 'J')
    return 1; 
  if(c == 'O')
    return 2;
  if(c == 'I')
    return 3;
}

int judge(int x, int y)
{
  return
    (flag[x][y] == sample[1][1]) +
    ((flag[x][y + 1] == sample[1][2]) << 1) +
    ((flag[x + 1][y] == sample[2][1]) << 2) +
    ((flag[x + 1][y + 1] == sample[2][2]) << 3);
}

int pls(int x, int y)
{
  int ret[4] = {0, 0, 0, 0};
  if(status[x][y] == 14)
    ret[color(sample[1][1])]++;
  if(status[x][y] == 15){
    ret[1]--;
    ret[2]--;
    ret[3]--;
    ret[color(sample[1][1])]++;
  }

  if(status[x][y - 1] == 13)
    ret[color(sample[1][2])]++;
  if(status[x][y - 1] == 15){
    ret[1]--;
    ret[2]--;
    ret[3]--;
    ret[color(sample[1][2])]++;
  }

  if(status[x - 1][y] == 11)
    ret[color(sample[2][1])]++;
  if(status[x - 1][y] == 15){
    ret[1]--;
    ret[2]--;
    ret[3]--;
    ret[color(sample[2][1])]++;
  }

  if(status[x - 1][y - 1] == 7)
    ret[color(sample[2][2])]++;
  if(status[x - 1][y - 1] == 15){
    ret[1]--;
    ret[2]--;
    ret[3]--;
    ret[color(sample[2][2])]++;
  }
  
  return max(max(ret[1], ret[2]), ret[3]);
}
    

int main()
{
  cin >> m >> n;
  for(int i = 1; i <= m; i++)
    for(int j = 1; j <= n; j++)
      cin >> flag[i][j];

  for(int i = 1; i <= 2; i++)
    for(int j = 1; j <= 2; j++)
      cin >> sample[i][j];

  for(int i = 1; i <= m; i++)
    for(int j = 1; j <= n; j++){
      status[i][j] = judge(i, j);
      if(status[i][j] == 15)
	ans++;
    }

  for(int i = 1; i <= m; i++)
    for(int j = 1; j <= n; j++)
      diff = max(diff, pls(i, j));

  cout << ans + diff << endl;
  return 0;
}

Measured memory_bytes: 6136
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          int[] kn = ReadLine().Split(' ').Select(int.Parse).ToArray();
          int[] homedis = ReadLine().Split(' ').Select(int.Parse).ToArray();

          int[] homedisspc = new int[kn[1]];

          for(int i = 0; i < homedis.Length; i++){
              if((i + 1) == homedis.Length) homedisspc[i] = (kn[0] - homedis[i]) + homedis[0];
              else homedisspc[i] = homedis[i + 1] - homedis[i];
          }

          WriteLine(homedisspc.Sum() - homedisspc.Max());
      }
   }
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t a = 1, b = n;
    for (auto i : irange(0L, m)) {
        cout << a << " " << b << "\n";

        if (n % 2 == 0 && 2 * (b - a) > n && 2 * (b - a - 2) <= n) {
            --b;
        }
        ++a;
        --b;
    }
}

Measured memory_bytes: 3632
n = int(input())
numList = map(int,input().split())
numList = list(numList)

multiplyList = []
start = 0
for i in range(n+1):
    start += 1
    for j in range(start, n):
        multiplyList.append(numList[i] * numList[j])

print(sum(multiplyList))

Measured memory_bytes: 9192
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

typedef complex<double> Point;

const double Eps = 1e-8;

double dot(const Point& a, const Point& b)
{
	return a.real()*b.real() + a.imag()*b.imag();
}
double cross(const Point& a, const Point& b)
{
	return a.real()*b.imag() - a.imag()*b.real();
}
double distance_line_point(const Point& point, const Point& a, const Point& b)
{
	return abs(cross(a-b, point-b) / (a-b));
}
double distance_linesegment_point(const Point& point, const Point& a, const Point& b)
{
	if (dot(b-a, point-a) < 0)
		return abs(a-point);
	else if (dot(a-b, point-b) < 0)
		return abs(b-point);
	else
		return distance_line_point(point, a, b);
}
int main()
{
	int R, N;
	while (scanf("%d %d", &R, &N), R | N)
	{
		double r[1000], v[1000], d[1000], angle[1000];
		for (int i = 0; i < N; ++i)
		{
			double x, y;
			scanf("%lf %lf %lf %lf", &x, &y, r+i, v+i);
			d[i] = sqrt(x*x + y*y);
			angle[i] = atan2(y, x);
		}

		int ans = 0;
		bool used[1000];
		fill(used, used+N, false);
		while (true)
		{
			double shot_angle;
			double near = 1e30;
			for (int i = 0; i < N; ++i)
			{
				if (used[i])
					continue;

				d[i] -= v[i];
				if (d[i] < R + Eps)
				{
					++ans;
					used[i] = true;
				}
				else if (abs(d[i]) < near)
				{
					near = (d[i]);
					shot_angle = angle[i];
				}
			}
			if (near > 1e29)
				break;

			for (int i = 0; i < N; ++i)
				if (!used[i]
				&& distance_linesegment_point(Point(d[i]*cos(angle[i])
					, d[i]*sin(angle[i])), Point(1e10*cos(shot_angle), 1e10*sin(shot_angle))
					, Point(R*cos(shot_angle), R*sin(shot_angle))) < r[i] + Eps)
					used[i] = true;
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
 
int main(){
	io;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll t1=c/b+(c%b>0);
	ll t2=a/d+(a%d>0);
	if(t1<=t2){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <utility>
#include <valarray>
#include <cmath>
//#include "../cxx-prettyprint/prettyprint.hpp"
using std::valarray;

void print_point(valarray<double> p) {
    std::cout << std::fixed << std::setprecision(8)
        << p[0] << " " << p[1] << std::endl;
}

void koch(int depth, valarray<double> p1, valarray<double> p2) {
    if (depth == 0) {
        return;
    }

    valarray<double> s, t, u(2);
    s = (p1 * 2.0 + p2) / 3.0;
    t = (p1 + p2 * 2.0) / 3.0;
    auto vec = (t - s);
    u[0] = std::cos(M_PI / 3) * vec[0] - std::sin(M_PI / 3) * vec[1] + s[0];
    u[1] = std::sin(M_PI / 3) * vec[0] + std::cos(M_PI / 3) * vec[1] + s[1];

    koch(depth - 1, p1, s);
    print_point(s);
    koch(depth - 1, s, u);
    print_point(u);
    koch(depth - 1, u, t);
    print_point(t);
    koch(depth - 1, t, p2);
}

int main() {
    int n;
    std::cin >> n;

    valarray<double> p1 = {0, 0};
    valarray<double> p2 = {100, 0};

    print_point(p1);
    koch(n, p1, p2);
    print_point(p2);
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
#define mod (long)(1e9 + 7)
using namespace std;

long dp[100001][2];

long solve(int curr, int color, int par, vector<int> nbs[]) {
	// cout<<curr<<" "<<color<<"\n";
	if(dp[curr][color] != -1) return dp[curr][color];
	if(color == 1) {
		long res = 1;
		for(auto i : nbs[curr]) {
			if(i == par) continue;
			res = (res * solve(i, 0, curr, nbs)) % mod;
		}
		return dp[curr][color] = res;
	}
	long res = 1;
	for(auto i: nbs[curr]) {
		if(i == par) continue;
		// cout<<"->"<<i<<endl;
		long black = solve(i, 1, curr, nbs);
		long white = solve(i, 0, curr, nbs);
		long sum = (black + white) % mod;
		res = (res * sum) % mod;
	}
	// cout<<res<<endl;
	return dp[curr][color] = res;
	
}
	

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<int> nbs[n + 1];
	for(int i = 0; i < n - 1; ++i) {
		int u, v;
		cin >> u >> v;
		nbs[u].push_back(v);
		nbs[v].push_back(u);
	}
	memset(dp, -1, sizeof dp);
	long res = solve(1, 0, 0, nbs);
	res = (res + solve(1, 1, 0, nbs)) % mod;
	cout<<res;
	return 0;
}

Measured memory_bytes: 18084