akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
int main(){
	long double a,b,c;
	cin>>a>>b>>c;
	long double eps= 1.0E-14;
	if(sqrt(a) +sqrt(b) +eps < sqrt(c))
	{
		cout<< "Yes" <<endl;
		}
	else{
		cout<< "No" <<endl;
	}
}


Measured memory_bytes: 256
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

bool is(lli x){
  for(int i = 2;i*i<=x;i++){
    if(x%i==0)return false;
  }
  return true;
}
void solve(long long X) {
  for(lli i = X;i<=3 *X;i++){
    if(is(i)){
      cout << i << endl;
      return;
    }

  }
}

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


Measured memory_bytes: 256
(in-package :cl-user)
(eval-when (:compile-toplevel :load-toplevel :execute)
  (sb-int:defconstant-eqx opt
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))
    #'equal)
  #+swank (ql:quickload '(:cl-debug-print :fiveam :cp/util) :silent t)
  #+swank (use-package :cp/util :cl-user)
  #-swank (set-dispatch-macro-character
           #\# #\> (lambda (s c p) (declare (ignore c p)) `(values ,(read s nil nil t)))))
#+swank (set-dispatch-macro-character #\# #\> #'cl-debug-print:debug-print-reader)

(macrolet ((def (b)
             `(progn (deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))
                     (deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))))
           (define-int-types (&rest bits) `(progn ,@(mapcar (lambda (b) `(def ,b)) bits))))
  (define-int-types 2 4 7 8 15 16 31 32 62 63 64))

(defconstant +mod+ 1000000007)

(defmacro dbg (&rest forms)
  #+swank (if (= (length forms) 1)
              `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
              `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

;; BEGIN_INSERTED_CONTENTS
;; BEGIN_USE_PACKAGE
(in-package :cl-user)

;;;
;;; Body
;;;

(defun main ()
  (let* ((k (read)))
    (dotimes (_ k (terpri))
      (write-string "ACL"))))

#-swank (main)

;;;
;;; Test and benchmark
;;;

#+swank
(progn
  (defparameter *lisp-file-pathname* (uiop:current-lisp-file-pathname))
  (defparameter *dat-pathname* (uiop:merge-pathnames* "test.dat" *lisp-file-pathname*))
  (defparameter *problem-url* "https://atcoder.jp/contests/abl/tasks/abl_a"))

#+swank
(defun gen-dat ()
  (uiop:with-output-file (out *dat-pathname* :if-exists :supersede)
    (format out "")))

#+swank
(defun bench (&optional (out (make-broadcast-stream)))
  (time (run *dat-pathname* out)))

#-swank
(eval-when (:compile-toplevel)
  (when (or (> sb-c::*compiler-warning-count* 0)
            sb-c::*undefined-warnings*)
    (error "count: ~D, undefined warnings: ~A"
           sb-c::*compiler-warning-count*
           sb-c::*undefined-warnings*)))

;; To run: (5am:run! :sample)
#+swank
(5am:test :sample
  (5am:is
   (equal "ACLACLACL
"
          (run "3
" nil))))


Measured memory_bytes: 23832
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    static Map<String, Integer> map = new HashMap<>();
    static {
        map.put("M", 0);
        map.put("A", 1);
        map.put("R", 2);
        map.put("C", 3);
        map.put("H", 4);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());

        int[] march = new int[5];
        for (int i = 0; i < N; i++) {
            String initial = String.valueOf(sc.next().charAt(0));
            if (map.containsKey(initial)) {
                march[map.get(initial)]++;
            }
        }

        long ans = solve(N, march);

        System.out.println(ans);
    }

    public static long solve(int n, int[] march) {
        long ans = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = i + 1; j < 5; j++) {
                for (int k = j + 1; k < 5; k++) {
                    int mi = march[i];
                    int mj = march[j];
                    int mk = march[k];
                    ans += (long) mi * mj * mk;
                }
            }
        }
        return ans;
    }
}


Measured memory_bytes: 46972
#include<iostream>
#include<queue>
using namespace std;
struct ST {
	char name[11];
	int time;
};
ST x;
ST y;
queue <ST> Q;
queue <ST> ans;
int main(){
	int n,p;
	int i,j,sum=0;
	cin>>n>>p;
	for(i=0;i<n;i++){
		cin>>x.name>>x.time;
		Q.push(x);
	}
	while(!Q.empty()){
		y=Q.front();
		Q.pop();
		if(y.time>p){
			sum+=p;
			y.time-=p;
			Q.push(y);
		}
		else{
			sum+=y.time;
			y.time=sum;
			ans.push(y);
		}
	}
	while(!ans.empty()){
		x=ans.front();
		ans.pop();
		cout<<x.name<<" "<<x.time<<endl;
	}
	return 0;
}
	

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

int main(){
	
	deque<int> dp;
	
	int n;
	cin >> n;
	
	if(n%2){
		for(int i = 0; i < n; i++){
			int t; 
			cin >> t;
			if(i%2){
				dp.push_back(t);
			}else{
				dp.push_front(t);
			}
		}
	}else{
		for(int i = 0; i < n; i++){
			int t; 
			cin >> t;
			if(i%2==0){
				dp.push_back(t);
			}else{
				dp.push_front(t);
			}
		}
	}
	
	for(int i = 0; i < n; i++)
		cout << dp[i] << (i == n-1? '\n' : ' ');
	
}

Measured memory_bytes: 2944
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	if b-a <= 2*(k-1) {
		for i := a; i <= b; i++ {
			fmt.Println(i)
		}
		return
	}
	for i := a; i < a+k; i++ {
		fmt.Println(i)
	}
	for i := b - k + 1; i <= b; i++ {
		fmt.Println(i)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
// z[i] is the length of the longest common prefix between s and the suffix of s starting at i
vector<int> make_z_function(const string& s) {
    vector<int> z(s.length());
    z[0] = s.length();
    for(int i = 1, L = 0, R = 0; i < s.length(); i++) {
        z[i] = i < R ? min(z[i - L], R - i) : 0;
        while(i + z[i] < s.length() and s[i + z[i]] == s[z[i]]) {
            z[i]++;
        }
        if(R < i + z[i]) {
            L = i, R = i + z[i];
        }
    }
    return z;
}
vector<int> get_periods(string& s) {
    auto z = make_z_function(s);
    vector<int> periods(s.size() + 1);
    iota(periods.begin(), periods.end(), 0);
    for(int k = s.size() - 1; k >= 1; k--) {
        bool can = true;
        for(int i = 0; i + k <= s.size() and can; i += k) {
            if(can &= z[i] >= k) {
                periods[i + k] = k;
            }
        }
    }
    return periods;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    vector<int> period_left = get_periods(s);
    reverse(s.begin(), s.end());
    vector<int> period_right = get_periods(s);
    if(period_left[s.size()] == s.size()) {
        cout << 1 << endl;
        cout << 1 << endl;
    } else if(period_left[s.size()] == 1) {
        cout << s.size() << endl;
        cout << 1 << endl;
    } else {
        cout << 2 << endl;
        int ans = 0;
        for(int i = 1; i < s.size(); i++) {
            ans += period_left[i] == i and period_right[s.size() - i] == s.size() - i;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6652
a,b,m=map(int,input().split())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
x=[ list(map(int,input().split())) for i in range(m)]
hantei=1000000000000
for i in range(m):
  if hantei>=(aa[x[i][0]-1]+bb[x[i][1]-1]-x[i][2]):
    hantei=(aa[x[i][0]-1]+bb[x[i][1]-1]-x[i][2])
if hantei>=min(aa)+min(bb):
  hantei=min(aa)+min(bb)
print(hantei)
    

Measured memory_bytes: 38560
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  double v;
  while (cin >> v) {
    double t = v / 9.8;
    double y = 4.9 * t * t;
    // y <= 5n-5 <=> n >= (y+5)/5
    int n = ceil((y + 5) / 5);
    cout << n << endl;
  }
}

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

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

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

int main() {
  string s;
  long long k;
  cin >> s;
  cin >> k;

  long long now = 0;
  char ans;
  for ( int i = 0; i < s.size(); i++ ) {
    if ( s[i] != '1' ) { ans = s[i]; break; }
    if ( ++now == k ) { ans = s[i]; break; }
  }

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


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

int main(){
	int n;
	cin>>n;
	
	vector<int> a(n);
	int cnt=0;//負の整数の数.
	bool jud=false;//負の整数の数が偶数個かどうか.
	bool jud0=false;//0があるかどうか.
	REP(i,n){
		scanf("%d",&a[i]);
		if(a[i]<0){
			++cnt;
			continue;
		}
		if(a[i]==0) jud0=true;
	}
	if(cnt%2==0) jud=true;
	
	llong sum=0;
	if(jud||jud0){
		REP(i,n){
			if(a[i]<0) a[i]*=-1;
			sum+=a[i];
		}
		cout<<sum<<endl;
		return 0;
	}else{
		int tmp=INF;
		REP(i,n){
			if(a[i]<0) a[i]*=-1;
			tmp=min(tmp,a[i]);
			sum+=a[i];
		}
		cout<<sum-2*tmp<<endl;
		return 0;
	}
}//解説参考.かっこいい解法.

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}



int main() {
	ll n, m;
	cin >> n >> m;
	if (n == 1 && m == 1) { cout << 1 << endl; return 0; }
	if (n == 1) { cout << m - 2 << endl; return 0; }
	if (m == 1) { cout << n - 2 << endl; return 0; }

	ll ans = (n - 2) * (m - 2);

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



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	rep(i, n) {
		if (i != k - 1) {
			cout << s[i];
		}
		else {
			cout << (char)(s[i] + 32);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#D
import itertools
N,M,R = map(int,input().split())
rlist = list(map(int,input().split()))

#warshall_floyd法
def warshall_floyd(dist):
    #dist[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j])
    return dist

inf = float("inf")
dist = [[inf for i in range(N)] for j in range(N)]
for i in range(N):
    dist[i][i] = 0

for i in range(M):
    a,b,c = map(int,input().split())
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
    
dist = warshall_floyd(dist)
per = [i for i in range(R)]
ind = list(itertools.permutations(per,R))

MIN = inf
for index in ind:
    now = 0
    for i in range(R-1):
        f = index[i]
        b = index[i+1]
        now+=dist[rlist[f]-1][rlist[b]-1]
    MIN = min(MIN,now)
    
print(MIN)


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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int x;
    cin >> x;
    for (Int i = -1000; i < (Int)1000; i++) {
        for (Int j = -1000; j < (Int)1000; j++) {
            Int a = i * i * i * i * i;
            Int b = j * j * j * j * j;
            if (a - b == x) {
                print(i, j);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3596
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::iter::Iterator;

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    let n: u64 = sc.next();
    let m: u64 = sc.next();
    let l: u64 = sc.next();

    let v_a: Vec<Vec<u64>> = (0..n)
        .map(|_| (0..m).map(|_| sc.next()).collect())
        .collect();
    let v_b: Vec<Vec<u64>> = (0..m)
        .map(|_| (0..l).map(|_| sc.next()).collect())
        .collect();

    for i in 0..n {
        for j in 0..l {
            print!(
                "{}{}",
                (0..m).fold(0, |acc, k| acc
                    + v_a[i as usize][k as usize] * v_b[k as usize][j as usize]),
                if j != l - 1 { " " } else { "\n" }
            );
        }
    }
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vec<vec<ll>> dp(N + 1, vec<ll>(W + 1, 0));

    rep(i, N) {
        dp[i + 1][w[i]] = max(dp[i + 1][w[i]], v[i]);
        rep(j, W + 1) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + w[i] <= W) {
                dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
            }
        }
    }


    ll ans = 0;
    rep(i, W+1) ans= max(ans,dp[N][i]);
    cout << ans << endl;
}


Measured memory_bytes: 83124
n = int(input())
a = [int(i) for i in input().split()]

def func_gcd(a,b):
    if b == 0:
        return a
    else:
        return func_gcd(b,a%b)

if len(a) == 1:
    print(a[0])
else:
    res = func_gcd(a[0],a[1])
    for i in range(2,n):
        res = func_gcd(res,a[i])
    print(res)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> x(110,vector<long long>(2)),dp(110,vector<long long>(100010,-1));
long long n,w;

long long ans(long long curr , long long last){
    if(curr == n){
        return 0;
    }
    if(dp[curr][last] != -1){
        return dp[curr][last];
    }
    long long ret = ans(curr+1,last);
    if(x[curr][0] <= last){
        ret = max(ret , x[curr][1] + ans(curr+1 , last - x[curr][0]));
    }
    dp[curr][last] = ret;
    return ret;
}

int main()
{
    cin >> n >> w;
    for(int i = 0 ; i < n ; i += 1){
        cin >> x[i][0] >> x[i][1];
    }
    cout << ans(0,w);
}

Measured memory_bytes: 87296
//+a[i]されるのは2回まで。+maxされるのは1回まで。2分木のようなものを考えると上手くいった。
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[200000];

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

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a > 9 || b > 9 ? -1 : a * b) << endl;
}


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

int main()
{
    char c;
    cin >> c;
    string a = "aeiou";
    string ans = "consonant";

    rep(i, a.size()){
        if (c==a[i]){
            ans = "vowel";
            break;
            }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long x1 = 0;
        long y1 = 0;
        long s = in.nextLong();
        in.close();
        /*
         * |x1y2 - x2y1| = 2S(公式利用)
         */
        long dom = (long) Math.sqrt(s); // 入力の平方根の小数点切りsage
        long dom2 = dom * dom;// 平方化
        if (dom2 < s) {
            dom++;
            dom2 = dom * dom;

        }
        long y3 = 1;
        long x2 = dom2 - s;
        System.out.println(x1 + " " + y1 + " " + x2 + " " + dom + " " + dom + " " + y3);
    }
}


Measured memory_bytes: 23508
def warshall_floyd(graph):
    num_v = len(graph)
    for k in range(num_v):
        for i in range(num_v):
            for j in range(num_v):
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])
    return graph


H, W = map(int, input().split())
items = []
for i in range(10):
    items.append(list(map(int, input().split())))

a_list = []
for i in range(H):
    a_list.append(tuple(map(int, input().split())))
graph = warshall_floyd(items)

ans = 0
for a in a_list:
    for item in a:
        if item == -1:
            continue
        ans += graph[item][1]
print(ans)


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int a, b, k;
  cin >> a >> b >> k;

  fo(i, a, b+1) {
    if(i - a < k || b - i < k) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [p - 1 for p in P]
C = list(map(int, input().split()))

vis = [False] * N
ans = [-float("inf")] * N

for root in range(N):
  if vis[root]:
    continue
  vis[root] = True
  
  cycle = [root]
  costs = [C[root]]
  u = P[root]
  vis[u] = True
  
  while u != root:
    cycle.append(u)
    costs.append(C[u])
    u = P[u]
    vis[u] = True

  L = len(cycle)
  S = sum(costs)
  for i, v in enumerate(cycle):
    cnt = 0
    for step in range(1, min(L, K) + 1):
      cnt += costs[(i + step) % L]
      val1 = cnt
      val2 = cnt + (K - step) // L * S
      ans[v] = max(ans[v], val1, val2)

print(max(ans))

Measured memory_bytes: 74644
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int D = sc.nextInt();
        final int T = sc.nextInt();
        final int S = sc.nextInt();
        
        System.out.println(D <= S * T ? "Yes" : "No");
    }
}


Measured memory_bytes: 35688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  //竹は高々8本
  //8本について(A,B,C,未使用)の4つを割り振ると65536通り
  //N-未使用<3ならありえない
  //(N-未使用-3)*10が合成mp
  int N,A,B,C,tmp;
  cin>>N>>A>>B>>C;
  int stick[N];
  int ans=10000;
  int ans_tmp=0;
  for(int i=0;i<N;++i){
    cin>>tmp;
    stick[i]=tmp;
  }
  int num[4];
  int limit=1;
  for(int i=0;i<N;i++){
    limit*=4;
  }
  for(int i=0;i<limit;i++){
    //numをリセット
    for(int j=0;j<4;j++){
      num[j]=0;
    }
    //計算
    tmp=0;
    tmp+=i;
    for(int j=0;j<N;j++){
      if(tmp%4!=3){
      num[tmp%4]+=stick[j];}
      else{
        num[3]+=1;
      }
      tmp=tmp/4;
    }
    if(N-num[3]<3 || num[0]==0 || num[1]==0 || num[2]==0){
      continue;
    }
    else{
    ans_tmp=abs(num[0]-A)+abs(num[1]-B)+abs(num[2]-C)+(N-num[3]-3)*10;
  }
  ans=min(ans,ans_tmp);
  }
  cout<<ans<<"\n";
return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; i++)
		cin >> data[i];

	sort(data.begin(), data.end(),greater<int>());
	
	long sum = 0;
	if (n > 1)
		sum = data[0];

	for (int i = 2; i < n; i++)
		sum += data[i / 2];

	cout << sum << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    vector<ll> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    ll ret = 0;
    for (ll c = 1; c < n - 1; c++)
    {
        if((n-1)%c==0)
        {
            ll dp = 0;
            for(int i=0,j=n-1;i<j;i+=c, j-=c)
            {
                dp += s[i] + s[j];
                ret = max(ret, dp);
            }
        }
        else
        {
            ll dp = 0;
            for(int i=0, j=n-1;i<n-1 && c < j;i+=c, j-=c)
            {
                dp += s[i] + s[j];
                ret = max(ret, dp);
            }
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
// Get numbers
        int n = input.nextInt();
        int[] nums = new int[n];

// fill array
        for(int i = 0; i < n; i++){
            nums[i] = input.nextInt();
        }

        insertSort(n, nums);
    }

    public static void insertSort(int n, int[] nums){
        for(int i = 1; i<= nums.length-1; i++){
            printHelp(nums);
            int key = nums[i];
            // insert A[i] into the sorted sequence A[0,...,j-1]
            int j = i - 1;
            while(j >= 0 && nums[j] > key){
                nums[j+1] = nums[j];
                j--;
            }
            nums[j+1] = key;
        }
        printHelp(nums);
    }

    private static void printHelp(int[] nums){
        for(int i = 0; i < nums.length - 1; i++){
            System.out.print(nums[i] + " ");
        }
        System.out.print(nums[nums.length-1] + "\n");
    }
}


Measured memory_bytes: 30400
n=int(input())
inputs=[i for i in range(n+1) if i%2==1]

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return len(divisors)

ans=0
for i in inputs:
  if make_divisors(i)==8:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int W,H,N,i,x,y,nx,ny,r,p,q;

int mx(int a,int b){a=abs(a);b=abs(b);return a>b?a:b;}
int mn(int a,int b){a=abs(a);b=abs(b);return a<b?a:b;}
int main()
{
	scanf("%d%d%d",&W,&H,&N);
	scanf("%d%d",&nx,&ny);
	for(i=r=0;i<N-1;i++)
	{
		scanf("%d%d",&x,&y);
		p=nx-x;q=ny-y;
		if(p*q>0)
			r+=mx(p,q);
		else
			r+=abs(p)+abs(q);
		nx=x;
		ny=y;
	}
	printf("%d\n",r);
	return 0;
}

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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    string check;
    while(K--) {
        int D;
        cin >> D;
        check.push_back('0'+D);
    }

    for(int ans=N; ; ans++) {
        if(to_string(ans).find_first_of(check) == string::npos) {
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
while True:
    x = [int(i) for i in input().split()]
    if x[0] == 0 and x[1] == 0:
        break
    for w in range(x[1]):
        print("#",end="")
    print("")
    for h in range(x[0] - 2):
        print("#", end="")
        for w in range(x[1] - 2):
            print(".", end="")
        print("#", end="")
        print("")
    for w in range(x[1]):
        print("#",end="")
    print("\n")




Measured memory_bytes: 7020
x,k,d= map(int,input().split())
if abs(x) >= k*d:
    print(abs(x)-k*d)
else:
    if k%2==0:
        print(min(2*d-x%(2*d),x%(2*d)))
    else:
        print(min(2 * d - (x+d) % (2 * d), (x+d) % (2 * d)))

Measured memory_bytes: 9060
import sys
readline = sys.stdin.readline

N,X,Y = map(int,readline().split())
X -= 1
Y -= 1
ans = [0] * N
for i in range(N - 1):
  for j in range(i + 1, N):
    val = min(abs(i - j),abs(i - X) + 1 + abs(j - Y), abs(i - Y) + 1 + abs(j - X))
    ans[val] += 1
    
for i in range(1, len(ans)):
  print(ans[i])

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

int main() {
  int N,M;
  cin >> N>> M;
  int ans[N];
  for(int i=1;i<N+1;i++){
    ans[i]=0;
  }

  for(int i =0;i<M;i++){
    int a,b;
    cin >> a>> b;
    ans[a]++;
    ans[b]++;    
    }
    
  for (int i=1;i<N+1;i++){
    cout << ans[i]<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  ll X;
  cin >> X;
  /*
  ll b = (X % 2 == 0) ? 0 : -1;
  ll a = pow((X + (pow(b, 5))), (1 / 5.00));
  cout << a << " " << b << endl;*/
  for (int i = -1000; i <= 1000; i++)
  {
    for (int j = -1000; j <= 1000; j++)
    {
      if (pow(i, 5) - pow(j, 5) == X)
      {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4068
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

long long Lcm(long long a,long long b){
	return (((a)*(b)))/__gcd(a,b);
}

int solve() 
{
  //happy coding

  ll n;
  cin>>n;
  ll a[n];
  ll lcm = 1LL;
  for(ll i=0LL;i<n;i++){
  	cin>>a[i];
  	lcm = Lcm(lcm,a[i]);
  }
  ll sum = 0LL;
  for(ll i=0LL;i<n;i++){
  	sum += (lcm/a[i]);
  }

 // cout<<lcm<<endl;

  cout<<point(20)<<(long double)((long double)lcm/(long double)sum)<<endl;

  
  return 0;
}
int main(){
  int test = 1;
  //scanf("%d", &test);
  while (test--)solve();return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n, x; cin >> n >> x;
        vector<int> a(n); cin >> a;
        ll ans = 0;

        if (a[0] > x) {
                ans += a[0] - x;
                a[0] = x;
        }

        for (int i = 0; i + 1 < n; i++) {
                if(a[i] + a[i + 1] > x) {
                        int temp = x - a[i];
                        ans += a[i + 1] - temp;
                        a[i + 1] = temp;
                }
        }
        cout << ans;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3700
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T>
constexpr bool chmin(
    T a, T b, function<bool(T, T)> f = [](T a, T b) { return a > b; }) {
  // when f is true, b is more 'smaller'
  if (f(a, b)) {
    swap(a, b);
    return true;
  }
  return false;
}
template <typename T> constexpr bool chmax(T a, T b) {
  return chmin(a, b, [](T a, T b) { return a < b; });
}
template <typename ite> void print_ite(ite start, ite end, char c = ' ') {
  for (auto i = start; i != end; i++)
    cout << i << c;
  cout << endl;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int k;
void dfs(string s, int digit, int &count) {
  if (s.length() == digit) {
    count++;
    if (count == k) {
      cout << s << endl;
      exit(0);
    }
    return;
  }
  if (s.length() == 0) {
    for (char c = '1'; c <= '9'; c++) {
      s.push_back(c);
      dfs(s, digit, count);
      s.pop_back();
    }
    return;
  }
  if (s.back() == '0') {
    s.push_back('0');
    dfs(s, digit, count);
    s.pop_back();
    s.push_back('1');
    dfs(s, digit, count);
  } else if (s.back() == '9') {
    s.push_back('8');
    dfs(s, digit, count);
    s.pop_back();
    s.push_back('9');
    dfs(s, digit, count);
  } else {
    char c = s.back();
    s.push_back(c - 1);
    dfs(s, digit, count);
    s.pop_back();
    s.push_back(c);
    dfs(s, digit, count);
    s.pop_back();
    s.push_back(c + 1);
    dfs(s, digit, count);
  }
}

int main() {
  cin >> k;
  int d = 1;
  int count = 0;
  while (true) {
    dfs("", d, count);
    d++;
  }
}


Measured memory_bytes: 256
#ttps://atcoder.jp/contests/abc134/submissions/6459172
from bisect import bisect
import sys
input = sys.stdin.readline
n = int(input())
A = [int(input()) for _ in range(n)]
dp = [1]
for a in A:
    a *= -1
    i = bisect(dp,a)   #既存に-aを挿入した時のindex

    if i < len(dp):    #挿入位置が長さより小さい時（要はabsが一番小さくない時
        dp[i] = a     #-aにする
    else:
        dp.append(a)    #右端に-aを普通に追加


print(len(dp))

Measured memory_bytes: 11032
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);
    vector <vector <int>> dp(n + 1, vector <int> (m + 1, -1000));
    forn (i, 0, n + 1)
        dp[i][0] = 0;
    forn (j, 0, m + 1)
        dp[0][j] = 0;
    vector <vector <pii>> par(n + 1, vector <pii> (m + 1));
    forn (i, 1, n + 1) {
        forn (j, 1, m + 1) {
            if (dp[i - 1][j] > dp[i][j]) {
                dp[i][j] = dp[i - 1][j];
                par[i][j] = {i - 1, j};
            }
            if (dp[i][j - 1] > dp[i][j]) {
                dp[i][j] = dp[i][j - 1];
                par[i][j] = {i, j - 1};
            }
            if (s[i - 1] == t[j - 1] && dp[i - 1][j - 1] + 1 > dp[i][j]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                par[i][j] = {i - 1, j - 1};
            }
        }
    }
    //cout << dp[n][m] << "\n";
    string ans;
    int i = n, j = m;
    while (i && j) {
        int new_i = par[i][j].fs, new_j = par[i][j].sc;
        if (i == new_i + 1 && j == new_j + 1)
            ans += s[new_i];
        i = new_i, j = new_j;
        //cout << i << " " << j << "\n";
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}

Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;
const ll M=2000;

bool ab[MAXn],bc[MAXn],ac[MAXn];
bool chk(char a,char b){
    return a == '?' || b == '?' || a == b;
}
int main(){
    IOS();
    string a,b,c;
    cin >> a >> b >> c;
    int A = SZ(a), B = SZ(b), C = SZ(c);
    REP (i,A) REP (j,B) if (!chk(a[i],b[j])) ab[i-j+50000] = true;
    REP (i,B) REP (j,C) if (!chk(b[i],c[j])) bc[i-j+50000] = true;
    REP (i,A) REP (j,C) if (!chk(a[i],c[j])) ac[i-j+50000] = true;

    int ans = INF;
    for (int i=-2*M;i<=2*M;i++) {
        for (int j=-2*M;j<=2*M;j++) {
            if ((!ab[i+50000]) && (!ac[j+50000]) && (!bc[j-i+50000])) {
                int L = min({0,i,j});
                int R = max({A,i+B,j+C});
                ans = min(ans,R-L);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N = NI()
    grid = make_grid(10, 10, 0)
    ans = 0
    for i in range(N+1):
        s = str(i)
        t = int(s[0])
        b = int(s[-1])
        grid[t][b] += 1
    for i in range(1, 10):
        for j in range(1, 10):
            if i != j:
                ans += grid[i][j] * grid[j][i]
            else:
                ans += grid[i][j] ** 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9416
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int  a, b, c;
  int N;

  map<vector<int>, int> map;

  int cnt = 0;
  cin >> N;
  for ( int i = 0; i < N; i++) {
    cin >> a >> b >> c;;
    vector<int> r = {a, b, c};
    sort(r.begin(), r.end());
    map[r] += 1;
    if (map[r] > 1) {
      cnt += 1;
    }
  }

  cout << cnt << endl;


  return 0;
}


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

int main(){
    int n;
    int a[100005],c[100005];
    cin>>n;
    int p=0;
    int cnt=0;
    c[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt+=abs(a[i]-p);
        p=a[i];
        c[i]=p;
    }
    cnt+=abs(a[n]);
    a[n+1]=0;
    for(int i=1;i<=n;i++){
        int zz=abs(c[i-1]-a[i])+abs(a[i]-a[i+1]);
        int xx=abs(c[i-1]-a[i+1]);
        cout<<cnt-zz+xx<<endl;
    }
}


Measured memory_bytes: 2048
h, w = map(int, input().split())
a = []

for i in range(h):
    a.append(input())

b = []

for i in range(h):
    if any(c == '#' for c in a[i]):
        b.append(a[i])

#print(b)

c = []
for i in range(w):
    s = ''
    for j in range(len(b)):
        s += b[j][i]
    c.append(s)

#print(c)
d = []

for i in range(len(c)):
    if any(c == '#' for c in c[i]):
        d.append(c[i])

#print(d)

e = []
for i in range(len(d[0])):
    s = ''
    for j in range(len(d)):
        s += d[j][i]
    e.append(s)

for i in range(len(e)):
    print(e[i])


Measured memory_bytes: 39792
N,M=map(int,input().split())

ab=[list(map(int,input().split())) for i in range(N)]
cd=[list(map(int,input().split())) for i in range(M)]

ans=[0 for i in range(N)]
for i in range(N):
    dis=10**9
    for j in range(M):
        xx=abs(ab[i][0]-cd[j][0])
        yy=abs(ab[i][1]-cd[j][1])
        temp=xx+yy
        if dis>temp:
            dis=temp
            ans[i]=j
for a in ans:
    print(a+1)

Measured memory_bytes: 9220
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="111"){
    cout<<"3";
  }
  else if(s=="000"){
    cout<<"0";
  }
  else if(s=="100"||s=="001"||s=="010"){
    cout<<"1";
  }
  else if(s=="110"||s=="101"||s=="011"){
    cout<<"2";
  }
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define pb push_back

int main(){
	int N;
	cin >> N;
	vector<int> W(N);
	for(int x= 0; x<N;x++){
		cin >> W[x];
	}
	int t=0;
	int sumMin =INT_MAX;
	
	for(;t<N;t++){
		int sumX=0,sumY=0;
		for(int x = 0;x<t;x++){
			sumX+=W[x];
		}
		for(int y = t; y<N;y++){
			sumY+=W[y];
		}
		sumMin = min(sumMin, abs(sumY-sumX));
	}
	cout << sumMin << endl;

}


Measured memory_bytes: 256
adjR = [-1, 0, 0, 1]
adjC = [0, 1, -1, 0]

def isValid(row, col, ROWS, COLS):
    return row >= 0 and row < ROWS and col >= 0 and col < COLS

def floodfill(board, row, col, ROWS, COLS):
    global adjR
    global adjC

    if not isValid(row, col, ROWS, COLS):
        return 0
    if board[row][col] == '#':
        return 0

    board[row][col] = '#'
    total = 1
    for x in range(4):
        rr = row + adjR[x]
        cc = col + adjC[x]
        total += floodfill(board, rr, cc, ROWS, COLS)
    return total
    

if __name__ == '__main__':
    while True:
        COLS, ROWS = list(map(int, input().split()))
        if ROWS == 0 and COLS == 0:
            break

        board = []
        for i in range(ROWS):
            line = input()
            board.append([ c for c in line ])
            if '@' in line:
                row = i
                col = line.find('@')
        
        print(  floodfill(board, row, col, ROWS, COLS)  )


Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long long N, ans;

bool SFT(long long N){
	string str = to_string(N);
	bool S = false, F = false, T = false;
	for(int i = 0; i < str.length(); i++){
		switch(str[i]){
			case '7':
				S = true;
				break;
			case '5':
				F = true;
				break;
			case '3':
				T = true;
				break;
			default:
				return false;
		}
	}
	return S&F&T;
}

void func(long long X){
	if(X > N)return;
	if(SFT(X))ans++;
	func(X * 10 + 7);
	func(X * 10 + 5);
	func(X * 10 + 3);
}

int main(){
	cin >> N;
	func(0);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B)cout << C << endl;
	else if (B == C)cout << A << endl;
	else if (A == C)cout << B << endl;
	return 0;
}

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

int main(){
  string S; cin >> S;
  if(S == "SUN") cout << "7" << endl;
  if(S == "MON") cout << "6" << endl;
  if(S == "TUE") cout << "5" << endl;
  if(S == "WED") cout << "4" << endl;
  if(S == "THU") cout << "3" << endl;
  if(S == "FRI") cout << "2" << endl;
  if(S == "SAT") cout << "1" << endl;
}

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

int main() {
  string s;
  cin >> s;
  vt<int> RL;
  rep(i,s.size()-1)
    if(s[i]!=s[i+1])
      RL.push_back(i);
  RL.push_back(0);
  vt<int> total(s.size());
  int k=0;
  rep(i,s.size()){
    if(s[i]=='R'){
      if(RL[k]>i){
        if((RL[k]-i)%2==0)
          total[RL[k]]++;
        else
          total[RL[k]+1]++;
      }
      if(RL[k]==i){
        total[i]++;
        k++;
      }
    }

    else if(s[i]=='L'){
      if(RL[k]>=i || RL[k]==0){
        if((i-RL[k-1])%2==1)
          total[RL[k-1]+1]++;
        else if((i-RL[k-1])%2==0)
          total[RL[k-1]]++;

        if(i==RL[k])
          k++;
      }
    }
  }


  rep(i,s.size())
    cout << total[i] << " ";
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 4e18;
const ll MOD = 1e9+7;

double dp[3010][1510];
int n;
double p[3010];

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

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n/2; j++) {
      dp[i+1][j] += dp[i][j] * (1-p[i]);
      dp[i+1][j+1] += dp[i][j] * p[i];
    }
  }
  double ans = 1;
  for (int i = 0; i <= n/2; i++) {
    ans -= dp[n][i];
  }
  cout << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i,n) for(ll i = 0;i < (ll)(n);i++)
#define INF 1000000001
#define MAXN 1000
#define MAXM 1000
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a + b >= c)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}
/*
    REP(i,a){
        REP(j,b){

        }
    }
    */



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

int main() {
    while (true) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        char** field = new char* [h];
        for (int i = 0; i < h; i++) {
            field[i] = new char [w + 1];
        }
        for (int i = 0; i < h; i++) {
            cin >> field[i];
        }
        int x = 0, y = 0;
        char op = field[y][x];
        while (op != '.' && op != '0') {
            field[y][x] = '0';
            switch (op) {
            case '>':
                x++;
                break;
            case '<':
                x--;
                break;
            case '^':
                y--;
                break;
            case 'v':
                y++;
                break;
            }
            op = field[y][x];
        }
        if (op == '.') {
            cout << x << " " << y << endl;
        } else if (op == '0') {
            cout << "LOOP" << endl;
        }
        for (int i = 0; i < h; i++) {
            delete[] field[i];
        }
        delete[] field;
    }
}

Measured memory_bytes: 0