akhauriyash/Code-Regression huggingface dataset:
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let rec sum n i len =
    if i > len then 0 else (n / (int_of_float (10. ** float_of_int (i-1)))) mod 10 + sum n (i+1) len in
  Printf.printf "%s\n" (if n mod (sum n 1 (String.length (string_of_int n))) = 0 then "Yes" else "No")


Measured memory_bytes: 4188
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

#define UF uftree
#define MAX_UF 101000
#define rep(i, n) for (int i = 0; i < n; i++)

typedef pair<int, int> i_i;

int n, k, l;

class uftree 
{
    public:
        int size;
        vector<int> par, rank;
        uftree(int n) : size(n), par(n), rank(n) {
            for (int i = 0; i < size; i++) {
                par[i] =  i;
                rank[i] = 0;
            }
        }
        int find(int x) {
            if (par[x] == x) {
                return x;
            } else {
                return par[x] = find(par[x]);
            }
        }
        void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) {
                return ;
            }

            if (rank[x] < rank[y]) {
                par[x] = y;
            } else {
                par[y] = x;
                if (rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }
        bool same(int x, int y) {
            return find(x) == find(y);
        }
};

signed main()
{
    cin >> n >> k >> l;

    UF road(n);
    rep(i, k) {
        int a, b;
        cin >> a >> b;
        road.unite(a-1, b-1);
    }
    UF line(n);
    rep(i, l) {
        int a, b;
        cin >> a >> b;
        line.unite(a-1, b-1);
    }
    map<i_i, int> ans;
    rep(i, n) {
        ans[i_i(road.find(i), line.find(i))]++;
    }
    rep(i, n) {
        cout << (i ? " " : "") << ans[i_i(road.find(i), line.find(i))];
    }
}



Measured memory_bytes: 15104
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

#Union-Find ****0スタートなので注意！****
class UnionFind():
    # 作りたい要素数（ノードの数）nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ついでに経路圧縮（調べた辺を根に直接つなぎ直す）をかけておく
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい集合に属する各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y] #要素数を足す(根のrootは"-要素数")
            self.root[y] = x #ノードyの親をx（新しい集合の根）とする
        else:
            self.root[y] += self.root[x] #要素数を足す
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす（根(rnk1)+繋げる集合のrnkということで、1増えることになる）
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)] #-符号を外す

#組み合わせ計算
cmbDP = [-1]*500002 #組み合わせDP用
def cmb(n, r):
    global cmbDP
    if cmbDP[n]+1: return cmbDP[n] #計算済みなら
    if n - r < r: r = n - r
#    if r == 0: return 1
#    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    cmbDP[n] = result
    return result


N, M = mi()
ABs = [list(mi()) for _ in range(M)][::-1]

#UnionFind用のインスタンスを要素数Mで作成(0スタート)
UFNodes = UnionFind(M)

#橋が全て崩落した場合の不便さから順（逆順）に答えを入れていく
nowans = cmb(N, 2) #全ての島の組み合わせ数=全て崩落した場合の不便さ
anslist = [nowans,]
#ここからは、nowans-=新しく繋がった島の組み合わせ数（橋が復旧した場合の便利さ）で要素を足していく
#最後の一つは、「全て復旧した場合」＝初期状態ということで、出力対象外なので注意

for a, b in ABs:
  #0スタートに変える
  a, b = a-1, b-1
  if UFNodes.isSameGroup(a, b): #既に同じ木なら、行き来可能状況に変化は起きないので、同じansを再度入れればいいだけ
    anslist.append(nowans)
  else: #違う場合、uniteすることになるが、unite前の要素数が欲しい
    prevacnt = UFNodes.Count(a)
    prevbcnt = UFNodes.Count(b)
    UFNodes.Unite(a,b)
    nowans -= prevacnt * prevbcnt
    anslist.append(nowans)


for eachans in anslist[:-1][::-1]:
  print(eachans)


Measured memory_bytes: 118748
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e16;

int main(){
    ll x;
    cin >> x;
    ll now = 100;
    ll ans = 0;
    while(now<x){
        now=now*1.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


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

    int a = n - h;
    int b = n - w;
    if(a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }
    a++;
    b++;
    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x;cin>>x;
  int ans=0;
  while(x>=500)
  {
    x=x-500;
    ans+=1000;
  }
  while(x>=5)
  {
    x=x-5;
    ans+=5;
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main(){
    int n, w;
    cin >> n >> w;
    long long dp[n + 1][w + 1];
    int mar[n][2];
    for(int i = 0; i <= n; i++) for(int j = 0; j <= w; j++) dp[i][j] = 0;
    for(int i = 0; i < n; i++) {cin >> mar[i][0]; cin >> mar[i][1];}

    for(int i = 1; i <= n; i++){
        int weight = mar[i - 1][0];
        int value = mar[i - 1][1];
        for(int j = 0; j <= w; j++){
            if(j < weight){dp[i][j] = dp[i - 1][j];}
            else{
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight] + value);
            }
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 79104
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List

main :: IO ()
main = do
    [n,x0] <- map read . words <$> getLine :: IO [Int]
    x <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    let xs = sort (x0:x)
    print . foldr1 gcd . tail $ zipWith (-) xs (0:xs)


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

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, int cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<int> Array;
typedef vector<Array> Matrix;

int const inf = 1e9;

typedef int Capacity;
struct FordFulkerson {
    typedef vector<vector<Capacity>> Matrix;
    int n, t;
    Capacity res;
    vector<bool> vis;
    Matrix cap, flow;
    vector<vector<int>> g;
    FordFulkerson(const Graph &graph = Graph())
        : n(graph.size()), res(0), cap(n, Array(n)), flow(n, Array(n)), g(n, vector<int>()){
        rep(i,n)rep(j,graph[i].size()){
            int u = graph[i][j].src, v = graph[i][j].dst; Capacity c = graph[i][j].cap;
            cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        }
        rep(i,n)rep(j,n) if(cap[i][j]) g[i].push_back(j), g[j].push_back(i);
    }
    void add_edge(int u, int v, Capacity c){
        g[u].push_back(v); g[v].push_back(u);
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
    }
    Capacity solve(int s, int t){
        this->t = t;
        Capacity f = -1;
        while(f) vis.assign(n,false), res += (f = augment(s,inf));
        return res;
    }
    Capacity augment(int v, Capacity lim){
        vis[v] = true;
        if(v == t) return lim;
        for(const int &i : g[v]){
            if(vis[i] || flow[v][i] == cap[v][i]) continue;
            Capacity f = augment(i, min(lim, cap[v][i] - flow[v][i]));
            flow[v][i] += f; flow[i][v] -= f;
            if(f) return f;
        }
        return 0;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    cout << FordFulkerson(g).solve(0,N-1) << endl;
}

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

signed main() {
  int h, w; cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++) cin >> s[i];

  vector<bool> row(h, false);
  vector<bool> col(w, false);

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(s[i][j]=='#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }
  for(int i = 0; i < h; i++) {
    if(row[i]) {
      for(int j = 0; j < w; j++) {
        if(col[j]) {
          cout << s[i][j];
        }
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll x;
    cin >> x;
    cout << x/11*2+(x%11 <= 6 ? (x%11 == 0 ? 0 : 1) : 2) << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
for a in A:
    D[a] += 1

Q = int(input())
SUM = sum(A)
for q in range(Q):
    b, c = map(int, input().split())
    SUM -= D[b] * b
    SUM += D[b] * c
    D[c] += D[b]
    D[b] = 0
    print(SUM)


Measured memory_bytes: 89716
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
 string s,t;
  cin >> s >> t;
  rep(i, s.size()){
    if (s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3620
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto s = readln.chomp;

    char[] cs;
    for (int i = 0; i < s.length; i += 2)
        cs ~= s[i];
    writeln(cs);
}


Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//UnionFind
struct UnionFind{

	std::vector<ll> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(ll size): data(size, -1) {}
	
	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	void unite(ll x, ll y){
		x=root(x);
		y=root(y);
		if( x != y ){
			// 要素数の大きな方へ合併するためのswap
			if( data[y] < data[x] ) std::swap(x, y);
			// 要素数を加算する
			data[x] += data[y];
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		//return x!=y;
	}

	// 同じ集合かどうか判定
	bool find(ll x, ll y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	ll root(ll x){
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}

	// 集合の要素数を返す
	ll size(ll x){
		return -data[ root(x) ];
	}
};

//UnionFind tree(n);

int main(){
    ll n,m; cin>>n>>m;
    vector<ll> a(m),b(m);
    rep(i,m) cin>>a[i]>>b[i];
    ll res=0;
    rep(i,m){
        UnionFind tree(n);
        rep(j,m){
            if(i==j) continue;
            tree.unite(a[j]-1,b[j]-1);
        }
        rep(i,n){
            if(tree.size(i)<n){
                res++;
                break;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && c != a && c != b) {
        cout << c;
    } else if (a == c && b != a){
        cout << b;
    } else{
        cout<<a;
    }

}

Measured memory_bytes: 256
fun main(args: Array<String>?): Unit {
    val (n, t, s) = readLine()!!.trim().split(' ').map(String::toInt)
    val stores = Array(n){
        val (a, b) = readLine()!!.trim().split(' ').map(String::toInt)
        Store(a, b)
    }
    val memo = IntArray(t + 1){0}
    for (store in stores) {
        for (i in t - store.time downTo s)
            memo[i + store.time] = Math.max(memo[i] + store.benefit, memo[i + store.time])
        for (i in s - store.time downTo 0)
            memo[i + store.time] = Math.max(memo[i] + store.benefit, memo[i + store.time])
    }
    println(memo.max())
}
data class Store(val benefit: Int, val time: Int)


Measured memory_bytes: 40924
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	set<long long> s;
	for (auto i = 0; i < N; ++i)
	{
		long long A;
		cin >> A;
		if (s.find(A) != s.end())
		{
			s.erase(A);
		}
		else
		{
			s.insert(A);
		}
	}

	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 4864
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
    int ans = 0;
  	int t[5];
    int n;
  	int m;
  	for(n = a;n<=b;n++){
      	m = n;
      	t[0] = m%10;
      	m /= 10;
     	t[1] = m%10;
      	m /= 10;
      	t[2] = m%10;
      	m /= 10;
      	t[3] = m%10;
      	m /= 10;
      	t[4] = m%10;
      	if((t[0]==t[4]) && (t[1] == t[3])){
          ans++;
        }
    }
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

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

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, m := scanInt(), scanInt()

	a := scanInts(n)
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	sum := 0

	for i := 0; i < n; i++ {
		sum += a[i]
	}

	for i := 0; i < m; i++ {
		if 4*m*a[i] < sum {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

int main() {
  char x;
  cin>>x;
  if(x=='A'){
    cout<<'T'<<endl;
  }
  if(x=='T'){
    cout<<'A'<<endl;
  }
  if(x=='C'){
    cout<<'G'<<endl;
  }
  if(x=='G'){
    cout<<'C'<<endl;
  }
}

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

int main(){
	int i, j, k, l;
	int N, M, temp,temp2[55], count, ans, temp4[55];
	while(1){
		int map[55][55] = {}, temp3[55][55] = {},  date = 1;
		cin>>N;
		
		if(N == 0) break;
		
		for(i = 1; i <= N; i++)map[i][i] = 1;
		
		for(i = 1; i <= N;i ++){
			cin>>M;
			for(j = 1; j <= M; j++){
				cin>>temp;
				temp3[i][temp] = 1;
			}
		}
		ans = -1; 
		while(date <= 30){
			for(i = 0; i <= N; i++)temp4[i] = 0;
			
			count = 0;
			
			for(k = 1; k <= N; k++){
				if(temp3[k][date])temp2[count++] = k;
			}
			for(l = 0; l < count; l++){
				for(k = 1; k <= N; k++){
					if(map[temp2[l]][k]) temp4[k] = 1;
				}
			}
			
			for(l = 0; l < count; l++){
				for(k = 1; k <= N; k++){
					map[temp2[l]][k] = temp4[k];
				}
			}
			for(k = 1; k <= N; k++){
				for(l = 1; l <= N; l++){
					if(!map[k][l]) break;
				}
				if(l > N){
					ans = date;
				}
			}
			if(ans != -1) break;
			date++;
		}
		
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main() {
  bool ok=true;
  int n; cin >> n;
  rep(i,n){
    int a;
    cin >> a;
    if(a%2==0){
      if(a%3!=0 && a%5!=0) ok=false;
    }
  }
  if(ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	ll n,i,ans;
	while(1){
		cin>>n;
		if(n==0)break;
		ll p,j[n-1],sum=0;
		for(i=0;i<n;i++){
			cin>>p;
			sum+=p;
		}
		for(i=0;i<n-1;i++)cin>>j[i];
		sort(j,j+n-1);
		ans=sum*n;
		i=n-2;
		while(n>1){
			sum+=j[i];
			n--;
			i--;
			ans=max(ans,sum*n);
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3568
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
  int n; ll e, t;
  cin>>n>>e>>t;
  ll dp[100002], dp2[100002], mn[100002], x[100002];
  dp[0]=0; x[0]=0;
  for(int i=1; i<=n; i++){
    cin>>x[i];
  }
  mn[0]=dp[0]-2*x[1]-x[0];
  dp2[0]=0;
  deque<int> deq;
  deq.push_back(0);
  int i0=0;
  for(int i=1; i<=n; i++){
    while(t-2*(x[i]-x[i0+1])<0) i0++;
    while(deq.front()<i0) deq.pop_front();
    dp[i]=dp2[deq.front()]+t+x[i];
    if(i0>0) dp[i]=min(dp[i], mn[i0-1]+3*x[i]);
    if(i==n) break;
    mn[i]=min(mn[i-1], dp[i]-2*x[i+1]-x[i]);
    dp2[i]=dp[i]-x[i];
    while(!deq.empty() && dp2[deq.back()]>=dp2[i]) deq.pop_back();
    deq.push_back(i);
  }
  cout<<dp[n]+e-x[n]<<endl;
  return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;

 vector<int> i2g;          // i2g[i] := アイテム i の所属するグループの番号(find)
 vector<vector<int>> g2i;  // g2i[g] := グループ g に所属するアイテムたち

 void union_init(int n) {
   i2g.resize(n);
   g2i.resize(n);
   for (int i = 0; i < n; ++i) {
     // 最初はアイテム i はグループ i に所属
     i2g[i] = i;
     g2i[i].assign(1, i);
   }
 }

 int find(int i){
   return i2g[i];
 }

 // アイテム ia の所属するグループとアイテム ib の所属するグループを 1 つにする
 void merge(int ia, int ib) {
   if(i2g[ia]==i2g[ib])return;
   // ia の所属するグループが ib の所属するグループより小さくならないようにする
   if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
     swap(ia, ib);
   }
   int ga = i2g[ia], gb = i2g[ib];
   // グループ gb に所属する全てのアイテムをグループ ga に移す
   for (int j : g2i[gb]) i2g[j] = ga;
   g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
   g2i[gb].clear();
 }

 // アイテム ia とアイテム ib は同じグループに所属しているか？
 bool is_same_group(int ia, int ib) {
   return i2g[ia] == i2g[ib];
 }


int main(){
  int n,m;
  cin>>n>>m;
  int ans=n;
  union_init(n);
  FOR(i,0,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    if(!is_same_group(a,b)){
      merge(a,b);
      n--;
    }
  }
  cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 9696
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
//cout << std::fixed << std::setprecision(15) << y << endl;



struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

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

    pair<ll, ll> leader[N + 1];
    REP(i, N){
        leader[i] = make_pair(i, 1);
    }

    ll A, B;
    ll largestGroupSize = 1;
    ll group[N + 1];
    REP(i, N){
        group[i] = 0;
    }
    UnionFind tree(N + 1);
    rep(i, M){
        cin >> A >> B;

        tree.unite(A, B);
    }
    REP(i, N){
        group[tree.root(i)]++;
        largestGroupSize = max(largestGroupSize, group[tree.root(i)]);
    }

    cout << largestGroupSize << endl;

    return 0;
}


Measured memory_bytes: 15360
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        long[] A = new long[N];

        for (int i = 0; i < N; i++) {
            A[i] = s.nextLong();
        }

        Arrays.sort(A);
        long n = 0;

        if (N % 2 != 0) {
            n += A[N / 2];
            for (int i = N / 2 + 1; i < N - 1; i++) {
                n = n + 2 * A[i];
            }
            n += A[N - 1];
        } else {
            for (int i = N / 2; i < N - 1; i++) {
                n = n + 2 * A[i];
            }
            n += A[N - 1];
        }

        System.out.println(n);
    }
}

Measured memory_bytes: 61876
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A, key=lambda x: -x)
    a, b = 0, 0
    for i in range(N):
        if i % 2 == 0:
            a += A[i]
        else:
            b += A[i]
    print(a-b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n,m=map(int,input().split())
xy=[list(map(int,input().split())) for _ in range(m)]
ans=[1]*n
a=list(range(n))
def find(a, x):
    if a[x] != x:
        a[x] = find(a, a[x])
    return a[x]
 
 
def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    if x != y:
        a[x] = min(x, y)
        a[y] = a[x]
 
for i,j ,k in xy:
    unite(a,i-1,j-1)
q=[]
for i in range(n):
    p=find(a,i)
    q.append(p)
print(len(set(q)))

Measured memory_bytes: 92632
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1000000001;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;cin>>n>>m;
    int a[n];
    int sum=0;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    int cnt=0;
    rep(i,0,n){
        if(a[i]*4*m>=sum)cnt++;
    }
    if(cnt>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;



int main() {
    int k; cin >> k;
    ll a = 7ll;
    a %= k;
    int res = 1;
    if(k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    while(a != 0) {
        a = a * 10 + 7ll;
        a %= k;
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c;
    cin >> a >> b >> c;
    if(c>=a && c<=b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var wab = Console.ReadLine().Split();
        var w = int.Parse(wab[0]);
        var a = int.Parse(wab[1]);
        var b = int.Parse(wab[2]);

        if ((a <= b && b <= a + w) ||
            (a - w <= b && b <= a))
        {
            Console.WriteLine(0);
        }
        else
        {
            var ans = Math.Min(
                Math.Abs(a - b + w),
                Math.Abs(a - b - w));

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;
const int INF = 1 << 25;
int ans;
int b[10][10];
int W, H;

int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
bool in(int x, int y) {
	return  0 <= x && x < W && 0 <= y && y < H;
}

void copy_board(int dst[10][10], int src[10][10]) {
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			dst[i][j] = src[i][j];
		}
	}
}

typedef pair<int, int> P;

int vis[10][10];
void color(int b[10][10], int c) {
	memset(vis, 0, sizeof vis);
	int cc = b[0][0];
	queue<P> q;
	q.push({ 0, 0 });
	b[0][0] = c;
	while(q.size()) {
		int x = q.front().first, y = q.front().second;
		q.pop();
		for(int k = 0; k < 4; k++) {
			int nx = x + dx[k], ny = y + dy[k];
			if(in(nx, ny) && b[ny][nx] == cc && !vis[ny][nx]) {
				vis[ny][nx] = 1;
				b[ny][nx] = c;
				q.push({ nx, ny });
			}
		}
	}
}

void dfs(int n) {
	if(n == 20 || ans < n) return;
	for(int c = 0; c < 3; c++) {
		int cnt = 0;
		for(int i = 0; i < H; i++) {
			cnt += count(b[i], b[i] + W, c);
		}
		if(cnt == H * W) {
			ans = min(ans, n);
			return;
		}
	}

	int tmp[10][10];
	copy_board(tmp, b);
	for(int i = 0; i < 3; i++) {
		copy_board(b, tmp);
		if(b[0][0] != i) {
			color(b, i);

			dfs(n + 1);
		}
	}
	copy_board(b, tmp);
}

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

	while(cin >> W >> H, W) {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				char c;
				cin >> c;
				if(c == 'R') b[i][j] = 0;
				if(c == 'G') b[i][j] = 1;
				if(c == 'B') b[i][j] = 2;
			}
		}

		ans = INF;
		dfs(0);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3092
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ene = 0
for i in range(n):
    if b[i] >= a[i]+a[i+1]:
        ene += a[i]+a[i+1]
        a[i]=0
        a[i+1]=0
        #print("a1")
    elif b[i] >= a[i]:
        ene += b[i]
        a[i+1] -= b[i]-a[i]
        a[i]=0
        #print("a2")
    else:
        ene += b[i]
        a[i] -= b[i]
        #print("a3")
    #print(a)
print(ene)

Measured memory_bytes: 24076
sub g{($d[$x=@@[@_]]-$d[$y=$@["@_"+1]])/($H[$y]-$H[$x])-$H[$x]-$H[$y]}<>=~$";map{shift@@while@@>1&&-2*$_<g 0;$d[@d]=$X=$d[$@[0]]+$'+($H[$@[0]]-$_)**2;$#@-=2while$@[@@]=$#d,@@>2&&g(-2)>g-3}@H=glob<>;print$X-$'

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

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

    int cnt = 0;
    for (int i = 1; i < n; i++) {
        cnt += (n - 1) / i;
    }
    /*
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < n; j++) {
            for (int k = 1; k < n; k++) {
                if ((n-i) == (j*k)) {
                    cnt++;
                }
            }
        }
    }
    */
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
 
int main(){;
    long long a,b,k;
    scanf("%lld%lld%lld",&a,&b,&k);
    if(a>=k){
        a-=k;
        k=0;
    }else{
        k-=a;
        a=0;
    }
    b-=k;
    if(b<0)b=0;
    printf("%lld %lld",a,b);
    return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <utility>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[200005],h,b(200005,0),f(200005,0);
lli vis[200005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
lli ans=0;
void dfs(lli i,lli pr)
{
    for(auto u:p[i])
    {
        if(u!=pr)
        {
        dfs(u,i);
        f[i]+=f[u];
        }
    }
    f[i]+=1;
    f[i];
}
void sfs(lli i,lli n,lli pr)
{
    for(auto u:p[i])
    {
        if(u!=pr)
        {
        h.pb(((n-f[u])*f[u]));
        sfs(u,n,i);
        }
    }
}
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli n;cin>>n;
    lli ans=0;
    for(lli i=1;i<=n;i++)
    {
        ans+=i*(n-i+1);
    }
    lli x,y;
    for(lli i=1;i<n;i++)
    {
        cin>>x>>y;
        if(x>y)swap(x,y);
        ans-=x*(n-y+1);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 10936
dic = {}
for num1 in range(ord("a"), ord("z") + 1):
  c1 = chr(num1)
  dic[c1] = []
  for num2 in range(ord("a"), ord("z") + 1):
    c2 = chr(num2)
    for num3 in range(ord("a"), ord("z") + 1):
      c3 = chr(num3)
      dic[c1].append(c1 + c2 + c3 + "a")

print("?" + dic["a"].pop())
used = set()
while True:
  s = input()
  if s in used or s[0] != "a":
    print("!OUT")
    break
  used.add(s)
  print("?" + dic[s[-1]].pop())


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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=0;;i++)
    {
        int a=pow(2,i);
        if(a==n)
        {
            cout<<a<<"\n";
            return 0;
        }
        if(a>n)
        {
            cout<<pow(2,i-1)<<"\n";
            return 0;
        }
    }
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  mint sum = 0;
  REP(i, N){
    cin >> A[i];
    sum+=A[i];
  }

  mint ans = 0;
  REP(i,N){
    sum-=A[i];
    ans+=sum*A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4732
s = input()
s1 = s[0]
s2 = s[1]
s3 = s[2]
n = 0
if s1 == '1':
  n = n + 1
if s2 == '1':
  n = n + 1
if s3 == '1':
  n = n + 1
print (n)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}
		Arrays.sort(A);
		int c = 0;
		int j = N - 1;
		long k = 0;
		long S = 0;
		long x[] = { 0, 0 };
		while (c < 2 && j > 0) {
			k = A[j];
			j--;
			if (A[j] == k) {
				x[c] = k;
				c++;
				j--;
			}
		}
		S = x[0] * x[1];

		System.out.println(S);
	}
}


Measured memory_bytes: 49836
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int x;
    cin >> x;
    int ans =0;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
}

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

int main() {
	double n;
	cin >> n;
	double x[100] = {0};
	double y[100] = {0};

	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}

	for (int i = 0; i < n; i++)
	{
		cin >> y[i];
	}

	double p1 = 0;
	for (int i = 0; i < n; i++)
	{
		p1 += fabs(x[i] - y[i]);
	}
	cout <<fixed<< p1 << endl;

	double p2 = 0;

	for (int i = 0; i < n; i++)
	{
		p2 += (x[i] - y[i])*(x[i] - y[i]);
	}
	cout <<fixed<< sqrt(p2) << endl;

	double p3 = 0;

	for (int i = 0; i < n; i++)
	{
		p3 += fabs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
	}
	cout << fixed << pow(p3, 1.0/3) << endl;

	double p0 = 0;
	for (int i = 0; i < n; i++)
	{
		int v = fabs(x[i] - y[i]);
			if (v > p0)
				p0 = v;
	}
	cout <<fixed<< p0 << endl;

	return 0;
}

Measured memory_bytes: 3424
import java.io.PrintWriter

// Helper
private val pw = PrintWriter(System.out)
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readLong() = readStrings().map(String::toLong)
private fun readDouble() = readStrings().map(String::toDouble)
private fun readStrings2() = readLn().split("").filter { it.isNotEmpty() }
private fun readInts2() = readStrings2().map(String::toInt)
private fun initArray(n:Int, v:String) = Array(n) { v }
private fun initIntArray(n:Int, v:Int) = IntArray(n) { v }
private fun println(value : Any) = pw.println(value)

internal fun abc169a() {
    val (A, B) = readInts()
    println(A * B)
}

fun main(args: Array<String>) {
    abc169a()
    pw.flush()
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
char s[100][101];

int main() {
    scanf("%d%d", &n, &m);
    forn(i, n) scanf("%s", s[i]);
    forn(i, n) forn(j, m) {
        if (s[i][j] != '.') {
            continue;
        }
        int cnt = 0;
        for (int ii = i - 1; ii <= i + 1; ++ii) {
            for (int jj = j - 1; jj <= j + 1; ++jj) {
                if (ii < 0 || ii >= n) continue;
                if (jj < 0 || jj >= m) continue;
                cnt += s[ii][jj] == '#';
            }
        }
        s[i][j] = char('0' + cnt);
    }
    forn(i, n) printf("%s\n", s[i]);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 10000000;
typedef pair<int,int> P;
typedef long long ll;
/*
*/

int main() {
  string S;
  cin >> S;
  int N = S.size();
  string s(N,'x');
  cout << s << endl;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

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

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;

  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> l(m), r(m);
  vector<vector<int>> sum(n + 1, vector<int>(n + 1, 0));
  vector<int> p(q), p1(q);
  for(int i = 0; i < m; i++) {
    cin >> l[i] >> r[i];
    sum[l[i]][r[i]]++;
  }
  for(int i = 0; i < q; i++) {
    cin >> p[i] >> p1[i];
  }
  for(int i = 0; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      sum[i][j] += sum[i][j - 1];
    }
  }

  for(int i = 0; i < q; i++) {
    int ans = 0;
    for(int j = p[i]; j <= n; j++) {
      ans += sum[j][p1[i]];
    }
    cout << ans << '\n';
  }

  return 0;
}

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

typedef long long ll;

//不足:-1 完全:0 過剰:1
int judge(ll n){
  ll sum=0;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0)sum+=(i+n/i);
    if(i==1)sum-=n;
    if(i*i==n)sum-=i;
  }
  if(sum>n)return 1;
  if(sum<n)return -1;
  return 0;
}

int main(){
  ll n;
  while(true){
    cin >> n;
    if(n==0)break;
    switch(judge(n)){
    case -1 : cout << "deficient number" << endl; break;
    case 0 : cout << "perfect number" << endl; break;
    case 1 : cout << "abundant number" << endl; break;
    }
  }

  return 0;
}

Measured memory_bytes: 1152
using System;
public class Aprob {
    public static void Main() {
        string[] read = new string[3];
        read = Console.ReadLine().Split(' ');
        int A = int.Parse(read[0]);
        //int B = int.Parse(read[1]);
        int C = int.Parse(read[2]);
        if (read[1] == "+") {
            Console.WriteLine(A+C);
        } else {
            Console.WriteLine(A-C);
        }

    }
}

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

signed main() {
  int n, m;
  cin >> n >> m;
  
  for(int i = 0; i < m; i++){
    int day;
    cin >> day;
    n -= day;
  }

  if(n >= 0){
    cout << n << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    string s;
    int q;
    cin>>s>>q;
    while(q--){
        string t;
        int a,b;
        cin>>t>>a>>b;
        if(t=="print"){
            for(int i=a;i<=b;i++)cout<<s[i];
            cout<<endl;
        }
        if(t=="reverse"){
            reverse(s.begin()+a,s.begin()+b+1);
        }
        if(t=="replace"){
            string u;
            cin>>u;
            rep(i,u.size())s[a+i]=u[i];
        }
    }
    return 0;
}




Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[222222];
ll f[555555];
ll b[222222];
ll dp[2][555555];

ll get(int id, int l, int r)
{
	if(l<=1) return dp[id][r];
	else return dp[id][r]-dp[id][l-2];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]; a[i]*=2;
		sum+=a[i];
	}
	sum/=2;
	for(int i=0;i<n;i++)
	{
		f[i]=a[i];
		f[i+n]=a[i];
		f[i+2*n]=a[i];
	}
	for(int i=0;i<3*n;i++)
	{
		dp[i&1][i]=f[i];
		if(i>=2) dp[i&1][i]+=dp[i&1][i-2];
		//cerr<<i<<' '<<dp[i&1][i]<<'\n';
	}
	for(int i=0;i<n;i++)
	{
		//cerr<<i+1<<' '<<i+n<<' '<<get((i+1)&1,i+1,i+n-2)<<'\n';
		b[i] = sum-get((i+1)&1,i+1,i+n-2);
	}
	for(int i=0;i<n;i++)
	{
		cout<<b[i];
		if(i+1<n) cout<<' ';
	}
	cout<<'\n';
}


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

string make_str(int s, int e) {
    if (s == e) return to_string(s);
    return to_string(s) + '-' + to_string(e);
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> x(n);
        for (int& i : x) cin >> i;
        int idx = 0;
        int prev = -1;
        int start = x[0];
        vector<string> results;
        while (1) {
            if (prev != -1 && (prev + 1 != x[idx] || idx == n)) {
                results.push_back(make_str(start, prev));
                start = x[idx];
                if (idx == n) break;
            }
            prev = x[idx];
            idx++;
        }
        bool first = true;
        for (const string& s : results) {
            if (!first) cout << ' ';
            else first = false;
            cout << s;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1232