akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`


		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	k, n := nextInt(), nextInt()
	a := nextInts(n)

	max := k + a[0] - a[n-1]

	for i := 1; i < n; i++ {
		if max < a[i]-a[i-1] {
			max = a[i] - a[i-1]
		}
	}

	ans := k - max

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll a[5], n, b[6], m = infll, ind;
int main()
{
    cin >> n;
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
        if (a[i] < m)
        {
            ind = i, m = a[i];
        }
    }
    cout << (n + m - 1) / m + 4 << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
for i in range(m):
    ks = list(map(int, input().split()))
    s.append(ks[1:])
p = list(map(int, input().split()))

count = 0
for i in range(2**n):
    for j in range(m):
        switch_on = 0
        for k in range(len(s[j])):
            switch_on += (i >> (s[j][k]-1)) & 1
        if switch_on % 2 != p[j]:
            break
    else:
        count += 1
print(count)

Measured memory_bytes: 39920
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
const int N=2e5+5;
int n,m,A,B,nu,now,b[N],v[N],vi[N],nex[N],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
void gg(){
	puts("No"),exit(0);
}
void nice(){
	puts("Yes"),exit(0);
}
void dfs(int x){
	vi[x]=1;
	for(int i=head[x];i;i=nex[i])
		if(!vi[v[i]])	dfs(v[i]);
		else	if(vi[v[i]]==2)	A?B=v[i]:A=v[i];
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		addedges(x,y),++b[x];
		addedges(y,x),++b[y];
	}
	for(int i=1;i<=n;i++)	nu+=(b[i]==4);
	for(int i=1;i<=n;i++)	if(b[i]&1)	gg();
	for(int i=1;i<=n;i++)	if(b[i]>4)	nice();

	if(nu<2)	gg();
	if(nu>2)	nice();

	nu=0;
	for(int i=1;i<=n;i++)	if(b[i]==4)	vi[i]=2;
	for(int i=1;i<=n;i++)	if(!vi[i])	A=B=0,dfs(i),nu|=(A==B);
	nu?nice():gg();
	return 0;
}


Measured memory_bytes: 3328
package main

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

func main() {
	n := 0
	s := bufio.NewScanner(os.Stdin)
	if s.Scan() {
		n, _ = strconv.Atoi(s.Text())
	}

	e := make([]int, n)
	for i := range e {
		if !s.Scan() {
			break
		}
		e[i], _ = strconv.Atoi(s.Text())
	}

	g, c := shellSort(e)

	fmt.Println(len(g))
	fmt.Println(trimBracket(fmt.Sprint(g)))
	fmt.Println(c)
	t := trimBracket(fmt.Sprint(e))
	fmt.Println(strings.Replace(t, " ", "\n", -1))
}

func trimBracket(s string) string {
	return strings.Trim(s, "[]")
}

func insertionSort(e []int, g int) int {
	cnt := 0
	for i := g; i < len(e); i++ {
		v := e[i]
		j := i - g
		for j >= 0 && e[j] > v {
			e[j+g] = e[j]
			j = j - g
			cnt++
		}
		e[j+g] = v
	}
	return cnt
}

func shellSort(e []int) ([]int, int) {
	cnt := 0
	g := []int{}
	for i := 1; i <= len(e); i = 3*i + 1 {
		g = append(g, 0)
		copy(g[1:], g[0:])
		g[0] = i
	}

	for j := 0; j < len(g); j++ {
		cnt += insertionSort(e, g[j])
	}

	return g, cnt
}



Measured memory_bytes: 72824
#include<iostream>
using namespace std;
int main()
{
  	//変数の定義
    int a,b;
  	//入力
  	cin >> a >> b;
  	//偶奇の判定
    if( (a*b) % 2 ){
        cout << "Odd" << endl;
    } else{
        cout << "Even" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

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

void Main(){
    int N, M;
    cin >> N >> M;
    vec<int> card(N+1);
    REP(i, M){
        int L, R;
        cin >> L >> R;
        L--;R--;
        card[L]++;
        card[R+1]--; 
    }
    int sum = 0;
    int cnt = 0;
    REP(i, N){
        sum += card[i];
        if(sum == M){
            cnt++;
        }
    }
    cout << cnt << el;
}



Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD = 1000000009;
const int INF = INT_MAX / 3;

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main() {
	int n;
	int a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int acnt = 0;
	int bcnt = 0;
	REP(i, s.size()) {
		if (s[i] == 'c')
			cout << "No" << endl;
		else if (s[i] == 'a') {
			if (acnt + bcnt < a + b) {
				acnt++;
				cout << "Yes" << endl;

			}
			else
				cout << "No" << endl;
		}
		else {
			if (acnt + bcnt < a + b && bcnt < b) {
				bcnt++;
				cout << "Yes" << endl;
			}
			else
				cout << "No" << endl;


		}


	}

}


Measured memory_bytes: 896
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**9+1]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    for j in range(1, min(i+1, k+1)):
        dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
print(dp[n-1])
    

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a=0,b=0,i;
	string s;
	cin>>s;
	for (i=0;i<s.size();i++){
		if (s[i]=='0'){
			a++;
		}
		else {
			b++;
		}
	}
	cout<<2*min(a,b);
	return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var line string
	fmt.Scan(&n, &line)
	cnt1, cnt2 := 0, 0
	es, ws := make([]int, n), make([]int, n)
	for i, s := range line {
		if string(s) == "E" {
			cnt1++
		}
		if string(s) == "W" {
			cnt2++
		}
		es[i] = cnt1
		ws[i] = cnt2
	}
	min := math.MaxInt32
	for i := 0; i < n; i++ {
		var wc, ec int
		if i - 1 > -1 {
			wc = ws[i - 1]
		}
		ec = es[n - 1] - es[i]
		if wc + ec < min {
			min = wc + ec
		}
	}
	fmt.Println(min)
}

Measured memory_bytes: 7296
#include <stdio.h>
int main(void){
    // Your code here!
    int s,flag = 0,kou = 1;
    char slot[1000001] = {};
    scanf("%d",&s);
    slot[s] = kou;
    while(flag == 0)
    {
        if(s%2 == 0)
        {
            s = s/2;
        }
        else
        {
            s = 3*s+1;
        }
        kou++;
        //printf("a_%d: %d\n",kou,s);
        if(slot[s] > 0)
        {
            flag = 1;
        }
        else
        {
            slot[s] = kou; 
        }
    }
    printf("%d\n",kou);
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
    string s;
    int k;
    cin >> s >> k;
    set<string> se;
    rep(i,s.size()) se.insert(s.substr(i,1));
    if(s.size()>1)rep(i,s.size()-1) se.insert(s.substr(i,2));
    if(s.size()>2)rep(i,s.size()-2) se.insert(s.substr(i,3));
    if(s.size()>3)rep(i,s.size()-3) se.insert(s.substr(i,4));
    if(s.size()>4)rep(i,s.size()-4) se.insert(s.substr(i,5));
    int cnt = 1;
    for(auto it = se.begin();it!=se.end();it++){
        if(cnt == k) {
            cout << *it << endl;
            break;
        }
        cnt++;
    }
}

Measured memory_bytes: 4680
h,w,a,b=map(int,input().split())
l1=[]
l2=[]
for c in range(a):
    l1.append("0")
    l2.append("1")
for c in range(w-a):
    l1.append("1")
    l2.append("0")
s1="".join(l1)
s2="".join(l2)
for c in range(b):
    print(s1)
for c in range(h-b):
    print(s2)

Measured memory_bytes: 3956
import java.util.Scanner;

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

        char[] strChar = new char[str.length()];
        for(int i = 0; i<str.length(); i++){
            strChar[i] = str.charAt(i);
        }
        if(strChar[str.length()-1] == 's'){
            System.out.println(str + "es");
        }
        else{
            System.out.println(str + "s");
        }
    }
}

Measured memory_bytes: 38448
//============================================================================
// Name        : rough.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;



int main() {

	int n;
	cin>>n;

	pair<int,int> p[n];
	int mark[n]={0};

	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a;
		cin>>b;

		p[i].first=a;
		p[i].second=b;

		if(a==b)
			mark[i]=1;
	}

	int consecutive=0;

	for(int i=0;i<n;i++)
	{
		if(consecutive>=3)
			break;

		if(mark[i])
			consecutive++;
		else
			consecutive=0;
	}

	if(consecutive>=3)
		cout<<"Yes";
	else
		cout<<"No";

}


Measured memory_bytes: 3584
from collections import defaultdict
N, K = map(int,input().split())
A = list(map(int,input().split()))

dic = defaultdict(int)
for a in A:
    dic[a] += 1

key_n = len(dic)

ans = 0
if key_n > K:
    dic2 = sorted(dic.items(), key=lambda x:x[1])
    for i in range(key_n - K):
        ans += dic2[i][1]
print(ans)

Measured memory_bytes: 39344
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;
immutable long INF = 1L << 59;

alias Node = Tuple!(long, "sum", long, "lmax", long, "rmax", long, "allmax");

Node merge(Node l, Node r) {
    long lmax = max(l.lmax, l.sum + r.lmax);
    long rmax = max(r.rmax, r.sum + l.rmax);
    long allmax = max(l.allmax, r.allmax, l.rmax + r.lmax);
    return Node(l.sum + r.sum, lmax, rmax, allmax);
}

class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        if (r < l) return e;
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}


void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto Q = s[1];
    auto A = readln.split.map!(to!long).array;

    auto st = new SegmentTree!(Node, merge, Node(0L, -INF, -INF, -INF))(N);
    foreach (i; 0..N) st.assign(i, Node(A[i], A[i], A[i], A[i]));
    writeln(max(0L, st.query(0, N-1).allmax));

    while (Q--) {
        auto q = readln.split;
        auto i = q[0].to!int - 1;
        auto x = q[1].to!long;
        st.assign(i, Node(x, x, x, x));
        writeln(max(0L, st.query(0, N-1).allmax));
    }
}



Measured memory_bytes: 15220
<?php  
  fscanf(STDIN,"%d",$n);
  $keta = strlen($n);
  $count = 0;
  $kari = 0;
  $ket = 1;
  for($i=1;$i<$keta;$i++){
    if($i%2!=0){
      $count += 9*$ket;
    }
    $kari += 9*$ket;
    $ket *= 10;
  }
  if($keta%2!=0){
    $count += ($n-$kari);
  }
  echo($count);


Measured memory_bytes: 3828
ABCD = input()

for i in range(2**(len(ABCD)-1)):
    n = int(ABCD[0])
    ans = ABCD[0]
    for j, c in enumerate(format(i, '0' + str(len(ABCD)-1) + 'b')):
        if c == '0':
            n += int(ABCD[j+1])
            ans += '+'
        else:
            n -= int(ABCD[j+1])
            ans += '-'
        ans += ABCD[j+1]
    if n == 7:
        print(ans + '=7')
        exit(0)


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

int gcd(int a, int b){
    int g = max(a,b);
    int l = min(a,b);
    if(g % l){
        return gcd(l, g % l);
    }else{
        return l;
    }
}

int main(){
    int A,B,K;
    int n,m;
    int cnt = 0;
    cin >> A >> B >> K;
    n = gcd(A,B);
    for(int i=n;i > 0;i--){
        if(n%i == 0){
            cnt++;
            if(cnt == K){
                m = i;
                break;
            }
        }
    }
    cout << m << endl;

}


Measured memory_bytes: 256
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<cmath>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
int breakcount= 1000000000;
/*******************************/

int func(int *a, int count){
  if(a[0] == a[1] && a[0] == a[2]){
    breakcount = count;
    if(DEBUG)
      cout << "found !! ";
      cout << breakcount << endl;

    return count ;
  }
  if(count >= breakcount)
    return 1000000000;
  int b[3];
  int c[3];
  sort(a,a+3);
  REP(i,3){
    b[i] = a[i] ;
    c[i] = a[i] ;
  }
  b[0] += 2 ;
  a[0]++;
  a[1]++;
  count++;
  if(DEBUG){
    if(count==2){
      REP(i,3){
        cout << a[i] << " ";
      }
      cout << endl;
    return count;
    }
  }
  return min(func(a,count),func(b,count));

}

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  int a[3],count ;
  cin >> a[0] >> a[1] >> a[2] ;
  count = 0 ;
  sort(a,a+3);
  int X;
  int sum = a[0]+a[1]+a[2];
  if((sum)%2 == 0){
    if(a[2]%2 ==0){
      X = a[2];
    }else{
      X = a[2]+1;
    }
  }else{
    if(a[2]%2 ==0){
      X = a[2]+1;
    }else{
      X = a[2];
    }
  }
  cout << (((3*X)-sum)/2) << endl;

  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) {
        	System.out.println("Possible");
        } else {
        	System.out.println("Impossible");
        }
    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        a[0] = -1;
        int count = 0;
        for (int i = 1;i<a.length;++i)
        {
            a[i] = sc.nextInt();
            if (i%2 == 1 && a[i]%2 ==1) ++count;
        }
        System.out.println(count);
        sc.close();
    }
}


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

int a[100001];


int main(){
    int n,q;
    
    ll b,c;
    ll sum=0;
    cin>>n;
    int temp;
    for(int i=0;i<n;++i){
        cin>>temp;
        sum=sum+temp;
        a[temp]++;
    }
    cin>>q;
    while(q--){
        cin>>b>>c;
        ll count=a[b];
        sum = sum-(count*b);
        a[b]=0;
        a[c]=a[c]+count;
        sum = sum+(count*c);
        cout<<sum<<endl;
    }
    
    
    return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;


int main(){

    int a,b;
    cin >> a >> b;

    bool check = false;

    for(int i = 1; i <= 1300; i++){
        int tmp8 = floor(0.08 * i);
        int tmp10 = floor(0.1 * i);

        if(a == tmp8 && b == tmp10){
            check = true;
            cout << i << endl;
            break;
        }
    }

    if(!check){
        cout << -1 << endl;
    }

    return 0;
}


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

int main() {
  int x,y;
  while(1){
  cin >> x >> y;
    if(x>y){
      swap(x,y);
    }
    
    if(x==0 && y==0)
      break;
    
    cout << x << ' ' << y << endl;
  }
  
  
  
}
 


Measured memory_bytes: 3004
import numpy as np

N = int(input())
X = np.zeros([N,4], dtype=int)

for i in range(N):
    X[i,0], X[i,1] = map(int, input().split())
    X[i,2], X[i,3] = X[i,0] - X[i,1], X[i,0] + X[i,1]    

col_num = 3
X = X[np.argsort(X[:, col_num])]
cnt = 1
r_min = X[0,3]
for i in range(1,N):
    if X[i,2] >= r_min:
        cnt += 1
        r_min = X[i,3]
print(cnt)

Measured memory_bytes: 19492
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int sum[26];
const int maxn = 1e5+10;
char str[maxn];
int main()
{
    scanf("%s",str);
    int len=strlen(str);
    for(int i=0;i<len;i++)
    sum[str[i]-'a']++;
    for(int i=0;i<26;i++)
    {
        if(sum[i]>0&&sum[i]%2==1)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
As = input().split()
dic = {}
for c in As:
    if c in dic:
        dic[c] += 1
    else:
        dic[c] = 1

values = list(sorted(dic.values()))

if len(values) <= K:
    print(0)
else:
    print(sum(values[:len(values)-K]))




Measured memory_bytes: 35616
/*
神题
答案>=max(W,H)*2+2
画出两条中线x=W/2，y=H/2
若一个矩形没跨过中线，则周长<=((W+1)/2+(H+1)/2)*2<=W+H+2<=max(W,H)*2+2
【故只需要考虑跨过某条中线的矩形即可】
对两条中线分别考虑
考虑中线y=H/2
点按x排序，枚举矩形右边界=a[i].x，线段树维护矩形左边界=a[j].x时矩形的高度
上下各维护一个单调队列即可
O(nlogn)
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 300010
#define pa(a, b) (data){a, b}
using namespace std;

struct tt{int l, r, f, mx;}t[N*2];
struct aa{int x, y;}a[N];
struct data{int x, id;}d1[N], d2[N];
int n, W, H, l, cl1, cl2, ans;

inline bool cmp(aa a, aa b){return a.x<b.x;}

inline void maketree(int L, int R){
	t[l].l=t[l].r=t[l].f=t[l].mx=0;
	if(L<R){
		int mid=(L+R)>>1, l1=l;
		l++; t[l1].l=l; maketree(L, mid);
		l++; t[l1].r=l; maketree(mid+1, R);
	}
}
inline void pushdown(int i){
	if(t[i].f){
		t[t[i].l].f+=t[i].f; t[t[i].l].mx+=t[i].f;
		t[t[i].r].f+=t[i].f; t[t[i].r].mx+=t[i].f;
		t[i].f=0;
	}
}
inline void ins(int i, int a, int b, int c, int L, int R){
	if(a>b)return;
	if(a<=L&&R<=b){t[i].f+=c; t[i].mx+=c; return;}
	pushdown(i);
	int mid=(L+R)>>1;
	if(a<=mid)ins(t[i].l, a, b, c, L, mid);
	if(mid<b)ins(t[i].r, a, b, c, mid+1, R);
	t[i].mx=max(t[t[i].l].mx, t[t[i].r].mx);
}

inline void solve(int W, int H){
	sort(a+1, a+1+n, cmp);
	l=1; maketree(0, n); ins(1, 0, 0, H, 0, n);
	cl1=cl2=1; d1[0].id=d2[0].id=0; d1[1]=pa(0, 0); d2[1]=pa(H, 0);
	for(int i=1; i<=n; i++){
		ins(1, i, i, H-a[i].x, 0, n);
		ans=max(ans, t[1].mx+a[i].x);
		if(a[i].y<=H/2){
			ins(1, d1[cl1].id, i-1, -a[i].y, 0, n);
			while(cl1&&d1[cl1].x<=a[i].y){
				ins(1, d1[cl1-1].id, d1[cl1].id-1, d1[cl1].x-a[i].y, 0, n);
				cl1--;
			}
			d1[++cl1]=pa(a[i].y, i);
		}else{
			ins(1, d2[cl2].id, i-1, a[i].y-H, 0, n);
			while(cl2&&d2[cl2].x>=a[i].y){
				ins(1, d2[cl2-1].id, d2[cl2].id-1, a[i].y-d2[cl2].x, 0, n);
				cl2--;
			}
			d2[++cl2]=pa(a[i].y, i);
		}
	}
	ans=max(ans, t[1].mx+W);
}

int main(){
	scanf("%d%d%d", &W, &H, &n);
	for(int i=1; i<=n; i++)scanf("%d%d", &a[i].x, &a[i].y);
	ans=max(W, H)+1;
	solve(W, H);
	for(int i=1; i<=n; i++)swap(a[i].x, a[i].y);
	solve(H, W);
	ans<<=1; printf("%d", ans);
	return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <functional>

typedef long long ll;
using namespace std;

int cnt = 0;
vector<ll> a;


void re(int p, vector<ll> v){
    if(v.size() == 3){
        if(v[0] + v[1] > v[2]){
            if(v[0] != v[1] && v[0] != v[2] && v[1] != v[2]){
                cnt++;
            }
        }
    }
    else if(p == a.size()){
        return;
    }
    else {
        re(p + 1, v);
        v.push_back(a[p]);
        re(p + 1, v);
    }
}


int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;
        a.push_back(x);
    }
    sort(a.begin(), a.end());
    vector<ll> b;
    re(0, b);
    cout << cnt << endl;
}


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

#include <atcoder/all>

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;
using namespace atcoder;

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;

inline char getcha() {
  if (ci - cn == cm) {
    fread(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}

inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm) {
    while ((ct = getcha()) >= '0') {
      A = A * 10 + ct - '0';
    }
  } else {
    while ((ct = *ci++) >= '0') {
      A = A * 10 + ct - '0';
    }
  }
  return A;
}

int main() {
  // ios::sync_with_stdio(false);
  // cin.tie(0);
  int n = getint(), m = getint();
  vector<int> a(n), b(m);
  for (int i = 0; i < n; i++) {
    a[i] = getint();
  }
  for (int i = 0; i < m; i++) {
    b[i] = getint();
  }
  vector<int> c = convolution(a, b);
  for (int i = 0; i < n + m - 1; i++) {
    printf("%d ", c[i]);
  }
  return 0;
}

Measured memory_bytes: 19152
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main() {
  int N;
  cin >> N;
  vector<int> cnt1(N + 1, 0), cnt2(N + 1, 0), A(N + 1, 0);
  for (int i = 1; i <= N; ++i) {
    int a;
    cin >> a;
    cnt1[i] = cnt1[i - 1] + a;
  }
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  int sum = accumulate(A.begin(), A.end(), 0);
  cnt2[1] = sum;
  for (int i = 2; i <= N; ++i) {
    cnt2[i] = cnt2[i - 1] - A[i - 1];
  }
  int max_n = 0;
  for (int i = 1; i <= N; ++i) {
    max_n = max(max_n, cnt1[i] + cnt2[i]);
  }
  cout << max_n << endl;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int dfs(vvi &v, vi &visited, int i) {
	visited[i] = 1;
	int ret = 1;
	REP(j, v[i].size()){
		if(!visited[v[i][j]])ret += dfs(v, visited, v[i][j]);
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vvi v(n);
	REP(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	queue<int> q;
	q.push(0);
	vi level(n, INF), level2(n, INF);
	level[0] = 0;
	while (!q.empty()) {
		int p = q.front(); q.pop();
		REP(i, v[p].size()) {
			if (level[v[p][i]] == INF) {
				level[v[p][i]] = level[p] + 1;
				q.push(v[p][i]);
			}
		}
	}
	level2[n - 1] = 0;
	q.push(n - 1);
	while (!q.empty()) {
		int p = q.front(); q.pop();
		REP(i, v[p].size()) {
			if (level2[v[p][i]] == INF) {
				level2[v[p][i]] = level2[p] + 1;
				q.push(v[p][i]);
			}
		}
	}
	int a, b;
	if (level[n - 1] % 2 == 0){
		REP(i, n) {
			if (level[i] + level2[i] == level[n - 1]&&level[i]==level2[i]+2) {
				a = i;
			}
			if (level[i] + level2[i] == level[n - 1]&&level[i]==level2[i]) {
				b = i;
			}
		}
	}
	else {
		REP(i, n) {
			if (level[i] + level2[i]  == level[n - 1]) {
				if (level[i] + 1 == level2[i])a = i;
				if (level[i] == level2[i] + 1)b = i;
			}
		}
	}
	REP(i, v[a].size()) {
		if (v[a][i] == b)v[a].erase(v[a].begin() + i);
	}
	REP(i, v[b].size()) {
		if (v[b][i] == a)v[b].erase(v[b].begin() + i);
	}
	vi visited(n, 0), visited2(n, 0);
	int c = dfs(v, visited, 0), d = dfs(v, visited2, n - 1);
	//cout << c << " " << d << endl;
	if (c>d)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	
	
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M; cin >> N >> M;
	vector<int> A(N, 0), B(N, 0);
	rep (i, N){
		cin >> A[i] >> B[i];
	} // end rep

	vector<P> ab(N);
	rep (i, N){
		ab[i].first = A[i];
		ab[i].second = B[i];
	} // end rep
	
	sort(ALL(ab));

	int curr = 0;
	ll res = 0LL;
	rep (i, N){
		int ai = ab[i].first;
		int bi = ab[i].second;
		if (curr + bi < M){
			curr += bi;
			res += (ll)ai * bi;
		}else{ // if (curr + bi >= M)
			int remain = M - curr;
			curr += remain;
			res += (ll)ai * remain;
			break;
		} // end if
	} // end rep

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python

x = int(input())
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)


Measured memory_bytes: 9172
# comb_mod(n, c, r, mod, fac, den) ≡ nCr
def prepare(n, mod):
    # fac[i] ≡ i!
    fac = [1]
    for i in range(1, n+1):
        fac.append((fac[-1] * i) % mod)

    # rec ≡ 1 / n!
    rec = pow(fac[-1], mod-2, mod)

    # den[i] ≡ 1 / i!
    den = [1 for _ in range(n+1)]
    den[n] = rec
    for i in range(n-1, 0, -1):
        rec = (rec * (i+1)) % mod
        den[i] = rec
    
    return fac, den

def comb_mod(n, r, mod, fac, den):
    return (fac[n] * den[r] * den[n - r]) % mod

r1, c1, r2, c2 = map(int, input().split())

# n:max(n), mod:prime number を入力
mod = 10**9 + 7
fac, den = prepare(r2+c2+2, mod)

ans = comb_mod(r2+1+c2+1, c2+1, mod, fac, den)
ans -= comb_mod(r2+1+c1, c1, mod, fac, den)
ans -= comb_mod(r1+c2+1, c2+1, mod, fac, den)
ans += comb_mod(r1+c1, c1, mod, fac, den)

print(ans % mod)

Measured memory_bytes: 161332
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#define INF (1<<25)
using namespace std;
 
typedef pair<int,int> P;
 
struct range{
    int reg,cost;
};
 
range co[5050];
 
map<int,vector<int> > es;
int n_map[5050][5050];
 
 
bool used[5050];
void bfs(int s){

    queue<P> que;
    que.push(P(s,0));
    while(que.size()){
        P p=que.front();que.pop();
        if(n_map[s][p.first]!=INF)continue;
        if(p.second>co[s].reg)break;
        n_map[s][p.first]=co[s].cost;
        used[p.first]=true;
        for(int i=0;i<es[p.first].size();i++){
           que.push(P(es[p.first][i],p.second+1));
        }
    }
}
 
int n,k;
 
int d[5050];
int dijkstra(int s){
    fill(used,used+5050,false);
    fill(d,d+5050,INF);
    d[s]=0;
    while(true){
        int v=-1;
        for(int u=1;u<5050;u++){
            if(!used[u] && (v==-1|| d[u]<d[v]))v=u;
        }
        if(v==-1)break;
         
        used[v]=true;
        for(int u=1;u<5050;u++){
            d[u]=min(d[u],d[v]+n_map[v][u]);
        }
    }
    return d[n];
}
int main(){
    fill((int*)n_map,(int*)n_map+5050*5050,INF);
    cin>>n>>k;
     
    for(int i=1;i<=n;i++){
        cin>>co[i].cost>>co[i].reg;
    }
    for(int i=0;i<k;i++){
        int a,b;
        cin>>a>>b;
        es[a].push_back(b);
        es[b].push_back(a);
    }
     
    for(int i=1;i<=n;i++)bfs(i);
     
     
    cout<<dijkstra(1)<<endl;
     
    //for(int i=0;i<10;i++)cout<<d[i]<<endl;
}

Measured memory_bytes: 101592
a,b,c,d = gets.split(" ").map(&:to_i)
ac = a * c
bd = b * d
if (a < 0 && c < 0) && (b >= 0 && d >= 0)
  if ac.abs() >= bd.abs()
    puts ac
  else
    puts bd
  end
elsif a < 0 && c < 0
  puts ac
elsif b >= 0 && d >= 0
  puts bd
else
  if a < 0
    puts b * c
  else c < 0
    puts a * d
  end
end


Measured memory_bytes: 14348
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    string s;
    cin>>s;
    if(s=="ABC")
    cout<<"ARC";
    else
    cout<<"ABC";
}
    

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 50
#define MAX_M 20

vector<pair<int, int>> G[MAX_N];

bool covered[MAX_M][MAX_N - 1];

vector<int> es;
bool visited[MAX_N];

void dfs(int v, int to, int q){
    if(v == to){
        for(auto e : es){
            covered[q][e] = true;
        }
        return;
    }
    visited[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        int u = G[v][i].first;
        if(!visited[u]){
            es.emplace_back(G[v][i].second);
            dfs(u, to, q);
            es.pop_back();
        }
    }
}

signed main(){
    int n;
    cin >> n;
    REP(i,n - 1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    int m;
    cin >> m;
    int u[m],v[m];
    REP(i,m){
        cin >> u[i] >> v[i];
        u[i]--;
        v[i]--;
        dfs(u[i], v[i], i);
        memset(visited, false, sizeof(visited));
    }
    ll ans = 0;
    for(int bit = 0; bit < 1 << m; bit++){
        int cnt = 0;
        bool covereds[n - 1] = {};
        for(int i = 0; i < m; i++){
            if(bit & 1 << i){
                cnt++;
                for(int j = 0; j < n - 1; j++){
                    covereds[j] |= covered[i][j];
                }
            }
        }
        ll cntes = 0;
        for(int i = 0; i < n - 1; i++){
            if(!covereds[i]) cntes++;
        }
        ans += (cnt % 2 == 0 ? 1 : -1) * pow(2, cntes);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
        vector<ll> x(5);
        for (int i = 0; i <5; ++i) {
                cin >> x[i];
                if (x[i] == 0) {
                        cout << i+1 << endl;
                        exit(0);
                }
        }



}


Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>

void swap(char x[], char y[]){
	char tmp[3];
	strcpy(tmp,x);
	strcpy(x,y);
	strcpy(y,tmp);
}

void bubbleSort(char a[][3], int n){
  int i,j;

  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      if(a[j][1]<a[j-1][1]){
        swap(a[j],a[j-1]);
      }
    }
  }
  for(i = 0; i<n-1; i++){
    printf("%s ",a[i]);
  }
  printf("%s\n",a[n-1]);
}



void selectionSort(char a[][3], int n){

  int i,j,minj;

  for(i=0; i<n; i++){
    minj = i;
    for(j=i+1; j<n; j++){
      if(a[j][1]<a[minj][1]){
        minj=j;
      }
    }
    if(a[i]!=a[minj]){
      swap(a[i],a[minj]);
    }
  }
  for(i=0; i<n-1; i++){
    printf("%s ",a[i]);
  }
  printf("%s\n",a[n-1]);


}


int main(void){
  int i,n;

  scanf("%d",&n);

  char a[n][3];
  char b[n][3];



  for(i = 0; i<n; i++){
    scanf("%s",&a[i]);
  	strcpy(b[i],a[i]);
  }

 	bubbleSort(a,n);
	printf("Stable\n");

	int k=0;
	selectionSort(b,n);
	for(i=0; i<n; i++){
		if(strcmp(a[i],b[i])==0){
			k=0;
		}else{
			k=1;
			break;
		}
	}
	if(k==0){
		printf("Stable\n");
	}
	if(k==1){
		printf("Not stable\n");
	}

  return 0;
}



Measured memory_bytes: 2036
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

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

Measured memory_bytes: 256
n, m, x, y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
ans = 'War'
for z in range(max(xs) + 1, min(ys) + 1):
    if x < z <= y:
        ans = 'No War'
        break
print(ans)

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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

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

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

   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(abs(a-c)<=d)cout<<"Yes"<<endl;
   else if(abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 256
A, B, Q = gets.chomp.split(" ").map(&:to_i)
S = []
T = []
X = []
A.times do
  S << gets.chomp.to_i
end
B.times do
  T << gets.chomp.to_i
end
Q.times do
  X << gets.chomp.to_i
end

X.each do |x|
  si = S.bsearch_index{|v| v >= x}
  sc = []
  if si.nil?
    sc = [S[-1]]
  elsif si.zero?
    sc = [S[0]]
  else
    sc = [S[si-1], S[si]]
  end
  ti = T.bsearch_index{|v| v >= x}
  tc = []
  if ti.nil?
    tc = [T[-1]]
  elsif ti.zero?
    tc = [T[0]]
  else
    tc = [T[ti-1], T[ti]]
  end
  min_cost = Float::INFINITY
  sc.each do |ss|
    tc.each do |tt|
      if (ss <= x && tt <= x) || (ss >= x && tt >= x)
        # 同じ方向
        cost = [(ss-x).abs, (tt-x).abs].max
      else
        # 逆方向
        cost = [(ss - x).abs + (tt - ss).abs, (tt - x).abs + (ss - tt).abs].min
      end
      min_cost = cost if cost < min_cost
    end
  end
  puts min_cost
end


Measured memory_bytes: 5624
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string x;
    cin>>x;
    int l=x.length();
    int out=753;
    
    for(int i=0;i<l-2;i++){
        int testv=(x[i]-'0')*100+(x[i+1]-'0')*10+(x[i+2]-'0');
        int testd=abs(testv-753);
        if(testd<out){
            out=testd;
        }
    }
    
    cout<<out<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	ll n, a; ll x[200001] = {};
	cin >> n;
	ll i;
	for (i = 1; i <= n; i++) {
		cin >> a; x[a] = i;
	}
	set<ll> b; ll sum=0;
	b.insert(0); b.insert(n + 1);
	for (i = 1; i <= n; i++) {
		b.insert(x[i]);
		auto sta = b.find(x[i]);
		sta--;
		ll le = *sta;
		sta++; sta++;
		ll ri = *sta;
		sum += (x[i] - le)*(ri - x[i])*i;
	}
	cout << sum << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

class Main {
    public static void main(String[] z) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        while(n-->0) {
            double x1,y1,x2,y2,x3,y3;
            x1=sc.nextDouble();
            y1=sc.nextDouble();
            x2=sc.nextDouble();
            y2=sc.nextDouble();
            x3=sc.nextDouble();
            y3=sc.nextDouble();
            double a1=2*(x2-x1);
            double b1=2*(y2-y1);
            double c1=x1*x1-x2*x2+y1*y1-y2*y2;
            double a2=2*(x3-x1);
            double b2=2*(y3-y1);
            double c2=x1*x1-x3*x3+y1*y1-y3*y3;
            double x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
            double y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
            double r=Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
            System.out.printf("%.3f %.3f %.3f\n",x,y,r);
        }
    }
}




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

#define lli long long int
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli Sum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(n)
  LLIV(a, n)
  for(lli y = 0;;y++) {
    for(int i = 0;i < n;i++) {
      if(a.at(i) % 2 != 0) {
      cout << y << endl;
      return 0;
      }
      a.at(i) /= 2;
    }
  }
}


Measured memory_bytes: 256
n = int(raw_input())
x = raw_input()
ints = []
for i in x.split(" "):
  ints.append(int(i))
  
tmin=922337203685477580
for p in range(1,101):
  t = 0
  for i in ints:
    t += (i - p)**2
  if t<tmin:
    tmin = t

print(tmin)

Measured memory_bytes: 2568
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        Deque<Character> ns = new ArrayDeque<>();
        Deque<Character> ew = new ArrayDeque<>();
        for (int i = 0; i < d.length; i++) {
            if (d[i] == 'N' || d[i] == 'S') {
                if (!ns.isEmpty() && ns.getLast() == d[i]) {
                    continue;
                }
                ns.add(d[i]);
            }
            if (d[i] == 'E' || d[i] == 'W') {
                if (!ew.isEmpty() && ew.getLast() == d[i]) {
                    continue;
                }
                ew.add(d[i]);
            }
        }
        if (ns.size() == 1 || ew.size() == 1) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 23636
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		int[] num = new int[N];
		int max = 0;
		int min = 0;
		for (int i = 0; i < N; i++) {
			num[i] = sc.nextInt();
			if ( max < num[i]) {
				max = num[i];
			}
		}
		min = num[0];
		for (int i = 0; i < N; i++) {
			if (min > num[i]) {
				min = num[i];
			}
		}
		int result = max - min;
		System.out.println(result);
	}
}

Measured memory_bytes: 25812
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            String s=sc.next();
            if(s.equals("0")) break;
            int ans=0;
            for(int i=0;i<s.length();i++){
                ans+=s.charAt(i)-'0';
            }
            System.out.println(ans);
        }
        
    }
}


Measured memory_bytes: 26484
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int sz=1e5+9;
int n,f,t,w;
vector<pair<int,int>> v[sz];
int c[sz];

void dfs(int i,int p=1){
    int myv;
    if(i==p) myv=0;
    else myv=c[i];
    for(auto u:v[i]){
        int nxt=u.x;
        int val=u.y;
        if(nxt==p) continue;
        if(val) c[nxt]=!myv;
        else c[nxt]=myv;
        dfs(nxt,i);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        scanf("%d %d %d",&f,&t,&w);
        w&=1;
        v[t].push_back(make_pair(f,w));
        v[f].push_back(make_pair(t,w));
    }
    dfs(1);
    for(int i=1;i<=n;i++) printf("%d\n",c[i]);
    return 0;
}


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

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    rep(i, n){
        if(i == k - 1){
            cout << (char)tolower(s[i]);
            continue;
        }
        cout << s[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    int n1=0;
   int m1=1;
    int count=0;
    cin>>n>>m;
    vector<int> vece,veco;
    for(int i=0;i<n;i++)
    {
       vece.push_back(n1);
       n1+=2;
    }
    for(int j=0;j<m;j++)
    {
        veco.push_back(m1);
        m1+=2;
    }
    vector<int>::iterator it,ij,it1,ij1;
    for( it=vece.begin();it<vece.end();it++)
    {//cout<<*it<<endl;
        for( ij=it+1;ij<vece.end();ij++)
        {
       //     cout<<*ij<<" ";
            count++;
        }
        //cout<<endl;
    }
   for( it1=veco.begin();it1<veco.end();it1++)
    {
        //cout<<*it1<<endl;
        for( ij1=it1+1;ij1<veco.end();ij1++)
        {
          //  cout<<*ij1<<" ";
            count++;
        }
        //cout<<endl;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ll = []
rl = []
 
for i in range(m):
  l,r = list(map(int,input().split()))
  ll.append(l)
  rl.append(r)
  
if min(rl)<max(ll):
  print("0")
 
else:
  print(abs(min(rl)-max(ll)+1))

Measured memory_bytes: 11068
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int[] digit=new int[5];
		int cnt=0;
		for(int i=a;i<=b;i++) {
			digit[0]=i/10000%10;
			digit[1]=i/1000%10;
			digit[3]=i/10%10;
			digit[4]=i%10;
			if(digit[0]==digit[4] && digit[1]==digit[3])	cnt++;
		}
		System.out.println(cnt);
	}

}

Measured memory_bytes: 21332
using System;

namespace abc166_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int k = int.Parse(str[1]);
            int[] a = new int[n];
            for(int i = 0; i < n; ++i)
            {
                a[i] = 0;
            }
            for(int j = 0; j < k; ++j)
            {
                int d = int.Parse(Console.ReadLine());
                string[] stra = Console.ReadLine().Split(' ');
                foreach (string z in stra)
                {
                    a[int.Parse(z) - 1] += 1;
                }
            }
            int num = 0;
            for(int s = 0; s < n; ++s)
            {
                if (a[s] == 0)
                {
                    num++;
                }
            }
            Console.WriteLine(num);
        }
    }
}


Measured memory_bytes: 27596