akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
int f[N], g[N];
int find(int f[], int x) {
  if (f[x] != f[f[x]]) f[x] = find(f, f[x]);
  return f[x];
}

int main() {
  int n, m1, m2;
  scanf("%d%d%d", &n, &m1, &m2);
  for (int i = 0; i < n; ++i) {
    f[i] = g[i] = i;
  }
  while (m1--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    int rx = find(f, x), ry = find(f, y);
    if (rx != ry) {
      f[ry] = rx;
    }
  }
  while (m2--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    int rx = find(g, x), ry = find(g, y);
    if (rx != ry) {
      g[ry] = rx;
    }
  }
  map<ii, int> cnt;
  for (int i = 0; i < n; ++i) {
    int u = find(f, i), v = find(g, i);
    cnt[{u, v}]++;
  }
  for (int i = 0; i < n; ++i) {
    int u = find(f, i), v = find(g, i);
    printf("%d%c", cnt[{u, v}], " \n"[i + 1 == n]);
  }
  return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main() {
    string a,b,c;cin>>a>>b>>c;
    string ans;
    ans+=(char)(a[0]-'a'+'A');
    ans+=(char)(b[0]-'a'+'A');
    ans+=(char)(c[0]-'a'+'A');
    cout<<ans<<endl;
}

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

const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h, w;
  cin >> h >> w;
  int si, sj;
  cin >> si >> sj;
  int ti, tj;
  cin >> ti >> tj;
  --si; --sj; --ti; --tj;
  vector<string> s(h);
  for(int i=0; i<h; i++) cin >> s[i];
  
  const int INF = 1e9;
  vector<vector<int> > dist(h,vector<int>(w,INF) );
  deque<pair<int,int> > q;
  dist[si][sj] = 0;
  q.emplace_back(si,sj);
  
  while(!q.empty() ){
    int i = q.front().first;
    int j = q.front().second;
    q.pop_front();
    int d = dist[i][j];
    
  for(int v=0;v<4;v++){
    int ni = i+di[v], nj = j+dj[v];
    if(ni < 0 || ni >= h || nj<0 || nj>=w) continue;
    if(s[ni][nj] == '#') continue;
    if(dist[ni][nj] <= d) continue;
    dist[ni][nj] = d;
    q.emplace_front(ni,nj);
  }
  
    for(int ei = -2; ei <=2;++ei){
      for(int ej=-2;ej<=2;++ej){
        int ni = i+ei, nj = j+ej;
        if(ni < 0 || ni >= h || nj<0 || nj>=w) continue;
        if(s[ni][nj]=='#') continue;
        if(dist[ni][nj] <= d+1) continue;
        dist[ni][nj] = d+1;
        q.emplace_back(ni,nj);
      }
    }
  }
  int ans = dist[ti][tj];
  if(ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
      
}


Measured memory_bytes: 9484
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()

	fmt.Fprintln(wtr, (1900*M+100*(N-M))*pow(2, M))
	wtr.Flush()
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        char[][] map = new char[H][W];
        for (int i = 0; i < H; i++) {
            String s = scan.next();
            char[] d = s.toCharArray();
            for (int j = 0; j < W; j++) {
                map[i][j] = d[j];
            }
        }
        for (int i = 1; i <= 2*H; i++) {
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < W; j++) {
                sb.append(map[(i+1)/2-1][j]);
            }
            System.out.println(sb.toString());
        }
    }
}


Measured memory_bytes: 22864
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, X: int, m: "List[int]"):
    print(N + (X - sum(m)) // min(m))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    m = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
#define popc __builtin_popcountll
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
inline ll min(ll x, ll y) {
	return popc(x) < popc(y) ? x : y;
}
inline ll minpop(ll ql, ll qr, ll l = 0, ll r = (1ll << 60) - 1){
	if(ql <= l && r <= qr) return l;
	ll mid = l + r >> 1; ll ans = ql;
	if(ql <= mid) ans = min(ans, minpop(ql, qr, l, mid));
	if(mid < qr) ans = min(ans, minpop(ql, qr, mid + 1, r));
	return ans;
}
int n;
ll a[maxn], b[maxn], k;
std::map<std::vector<ll>, std::vector<std::pair<ll, ll>>> map;
inline void solve(int div, ll dec) {
	std::vector<ll> v(n);
	for(int i = 0;i < n;++i) {
		b[i] = a[i] - dec >> div;
		v[i] = b[i] - b[0];
	}
	if(b[0] >= 0) {
		ll rem_bit = k - div - popc(dec);
		if(rem_bit < 0) {
			return ;
		}
		map[v].emplace_back(std::max<ll>(0, b[0] - rem_bit), b[0]);
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for(int i = 0;i < n;++i) {
		cin >> a[i];
	}
	std::sort(a, a + n);
	solve(0, 0);
	for(int x = 1;x <= k && x <= 60;++x) {
		std::vector<ll> v(a, a + n);
		for(ll & i : v) {
			i &= (1ll << x) - 1;
		}
		v.push_back(-1);
		v.push_back((1ll << x) - 1);
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
		for(int i = 1;i < v.size();++i) {
			solve(x, minpop(v[i - 1] + 1, v[i]));
		}
	}
	int ans = 0;
	for(auto & i : map) {
		std::vector<std::pair<ll, ll>> & v = i.second;
		sort(v.begin(), v.end());
		ll right = -1, s0 = 0;
		for(const auto i : v) {
			if(i.first >= right) right = i.first;
			if(i.second >= right){ 
				s0 += i.second - right + 1;
				right = i.second + 1;
			}
		}
		ans = (ans + s0) % mod;
	}
	cout << ans << '\n';
}


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

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

int main(){
  int H, W;
  vector<vector<char>> S(2010, vector<char>(2010, '#'));

  cin >> H >> W;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> S[i][j];
    }
  }
  
  vector<vector<int>> yoko(2010, vector<int>(2010, 0));
  vector<vector<int>> tate(2010, vector<int>(2010, 0));

  vector<int> A;
  for(int i=0; i<H; i++){
    A.clear();
    for(int j=0; j<=W; j++){
      if(S[i][j] == '.'){
        A.push_back(j);
      } else {
        for(int k=0; k<A.size(); k++){
          yoko[i][A[k]] = A.size();
        }
        A.clear();
      }
    }
  }

  for(int j=0; j<W; j++){
    A.clear();
    for(int i=0; i<=H; i++){
      if(S[i][j] == '.'){
        A.push_back(i);
      } else {
        for(int k=0; k<A.size(); k++){
          tate[A[k]][j] = A.size();
        }
        A.clear();
      }
    }
  }

  int ans = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      ans = max(ans, tate[i][j]+yoko[i][j]-1);
    }
  }

  cout << ans << endl;  
}
  
  

Measured memory_bytes: 35968
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    int[] T=new int[N];
	    int[] X=new int[N];
	    int[] Y=new int[N];

	    for(int i=0; i<N; i++) {
	    	T[i]=gi();
	    	X[i]=gi();
	    	Y[i]=gi();
	    }

	    boolean f=true;
	    int bt=0;
	    int bx=0;
	    int by=0;
	    for (int i=0; i< N; i++) {
	    	int t=T[i];
	    	int x=X[i];
	    	int y=Y[i];
	    	int dt= t-bt;
	    	int dk=Math.abs(x-bx)+Math.abs(y-by);
	    	if(dt<dk || dt%2!=dk%2) {
	    		System.out.print("No");
	    		return;
	    	}
	    	bt=t;
	    	bx=x;
	    	by=y;
	    }

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

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 60116
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n, m, k = map(int, input().split())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))

    a_sum = b_sum = 0
    a_i = b_i = 0
    while a_i < len(a_list) and a_sum + a_list[a_i] <= k:
        a_sum += a_list[a_i]
        a_i += 1
    ans = a_i

    while a_i > 0:
        # a_sum -= a_list[a_i - 1]  # wrong!
        while b_i < len(b_list) and a_sum + b_sum + b_list[b_i] <= k:
            b_sum += b_list[b_i]
            b_i += 1
            ans = max(ans, a_i + b_i)
        a_sum -= a_list[a_i - 1]  # correct!
        a_i -= 1

    while b_i < len(b_list) and a_sum + b_sum + b_list[b_i] <= k:
        b_sum += b_list[b_i]
        b_i += 1
        ans = max(ans, a_i + b_i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42356
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    
    cin>>a>>b;
    
    if(a+b>=10) cout<<"error"<<endl;
    else cout<<a+b<<endl;
   
    
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	A := ScanInt(scanner)
	B := ScanInt(scanner)
	C := ScanInt(scanner)
	K := ScanInt(scanner)
	
	max := Max(Max(A, B), C)
	ans := A + B + C
	for i := 0; i < K; i++ {
	    ans += max * int(math.Pow(2, float64(i)))
	}
	fmt.Println(ans)
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let s:Vec<char> = read::<String>().chars().collect();

    for &ch in s.iter() {
        print!("{}", match ch {
            '1' => '9',
            '9' => '1',
            _ => ch,
        })
    }
    println!("", );

}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
using namespace std;
int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}
int main(){
  string n;
  cin >> n;
  int num = 0;
  for(int i=0;i<(int)n.size();i++){
    num += ctoi(n[i]);
  }
  if(num % 9 == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3700
n = int(input())
a = list(map(int,input().split()))
mod =10**9+7
sd=0
sdd = 0
for i in a:
    sd+=i**2
    sdd +=i
    sd %= mod
    sdd %=mod
print((sdd**2-sd)*(5*10**8+4)%mod)

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

int main() {
	int a, b; cin >> a >> b;
	if (a == b)
	{
		cout << a + b << endl;
	} else {
		int c = max(a, b);
		cout << c * 2 - 1 << endl;
	}
	
}

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

#define INF (1 << 30)

struct edge{

  int cost, to;

};

struct state{

  int node, cost;
  bool operator <(const state &b)const{
    return cost > b.cost;
  }
};

int n;
int d[10001];
vector<edge> glaph[10001];
priority_queue<state> qu;

void sss(){

  fill(d,d+10001,INF);
  qu.push((state){0,0});
  d[0] = 0;

  while(!qu.empty()){

    state info;
    info = qu.top();
    qu.pop();

    for(int i = 0; i < (double)glaph[info.node].size(); i++){
      if(d[glaph[info.node][i].to] > glaph[info.node][i].cost + d[info.node]){
      d[glaph[info.node][i].to] = glaph[info.node][i].cost + d[info.node];
      qu.push((state){glaph[info.node][i].to,d[info.node]}); 
      }
	}
  }

  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }
  



}

int main(){

  cin >> n;

  for(int i = 0; i < n; i++){
    int k, v, c, u;
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v >> c;
      glaph[u].push_back((edge){c,v});
    }
  }

  sss();


}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define MAX_V 100005

int main(void){
 	ll n,k;
 	cin>>n;
 	vector<ll> A;
 	ll a;
 	rep(i,n){
 		cin>>a;
 		A.push_back(a-i-1);
 	}
 	sort(A.begin(),A.end());
 	ll base = A[n/2];
 	ll ans = 0;
 	rep(i,n){
 		ans += abs(A[i] - base);
 	}
 	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2420
antena = [int(input()) for i in range(5)]
k = int(input())
answer = "Yay!"
for i in range(5):
    now = antena[i]
    for j in range(i+1,5):
        sub = abs(now-antena[j])
        if sub > k:
            answer = ":("
    if answer != "Yay!":
        break
print(answer)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int M1 = scan.nextInt();
		int d1 = scan.nextInt();
		int M2 = scan.nextInt();
		int d2 = scan.nextInt();
		if(d2 == 1){
			System.out.println(1);		
			}
		else System.out.println(0);
			}
	}

Measured memory_bytes: 23636
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
int main() {
	ll I, O, T, J, L, S, Z;
	cin >> I >> O >> T >> J >> L >> S >> Z;
	ll ans = I / 2 * 2 + J / 2 * 2 + L / 2 * 2;
	if (I > 0 && J > 0 && L > 0) {
		chmax(ans, (I - 1) / 2 * 2 + (J - 1) / 2 * 2 + (L - 1) / 2 * 2 + 3);
	}
	ans += O;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
const ll INF = 1e15;
const ld eps = 1e-6;

int main() {
	string s;
	cin >> s;
	if (s <= "2019/04/30")
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;
	return 0;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	int n; cin >> n;
	if (n >= 2100)
	{
		cout << "1";
		return;
	}
	set<ll> u, l;
	int mn = n - (n % 100);
	int mx = n - (n % 100) + (mn / 20);
	if (n >= mn && n <= mx) cout << "1";
	else cout << 0;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n,m,d;cin >> n >> m >> d;
    double ans=(d==0?n:(n-d)*2)/((double)n*n);
    ans*=m-1;
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//|| stoll to_string
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	ll N;
	cin>>N;
	vector<pair<ll,int>>Fs;
	ll n=N;
//	for(ll i=2;(i*i)<=N;i++){
	rep(i,2,sqrt(N)+1){
		int cnt=0;
		while(n%i==0){
			n/=i;
			cnt++;
		}
		Fs.emplace_back(i,cnt);
		DBG(i,"^",cnt,"");
		if(n==1) break;
	}
	if(n>1){
		Fs.emplace_back(n,1);
		DBG(n,"^",1,"");
	}
	int ans=0;
	for( auto v: Fs ){
		int cnt=v.second;
		rep(i,1,100){
			if(cnt>=i){
				cnt-=i;
				ans++;
			}
			else{
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 19736
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

vi vs;
const int MAX_X = 100000;
bool dp[MAX_X + 1];
bool vis[MAX_X + 1];

bool rec(int x, int i) {
    if (x == 0) return true;
    if (x < 0 || i == 6) return false;

    if (vis[x]) return dp[x];

    dp[x] |= rec(x, i + 1);
    dp[x] |= rec(x - vs[i], i);
    vis[x] = true;
    return dp[x];
}

int main() {
    fastio();

    int x;
    cin >> x;

    for (int i = 0; i < 6; i++) {
        vs.push_back(i + 100);
    }

    if (rec(x, 0)) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/

long long int min(long long int x, long long int y)
{
	long long int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*ここからmain関数*/

int main()
{
	long long int N, T[5];
	cin >> N;
	for (int i = 0;i < 5;i++)
		cin >> T[i];

	long long int m = min(T[0], T[1]);
	for (int i = 2;i < 5;i++)
		m = min(m, T[i]);

	long long int ans;

	if (N%m == 0)
		ans = N / m + 4;
	else
		ans = N / m + 5;

	cout << ans;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv) {
    int n_in = 3;
    int in = 0, fcount = 0, scount = 0;
    while (--n_in >= 0) {
        scanf("%d",&in);
        if (in == 5) ++fcount;
        else if (in == 7) ++scount;
    }
    if (fcount == 2 && scount == 1)
        printf("YES\n");
    else
        printf("NO\n");
}


Measured memory_bytes: 1632
use std::collections::HashMap;


fn main() {
    let _:i64 = read();
    let an = read_vec::<i64>();    

    let acc_sum = accumulate_each(an.iter(), add, 0);

    let mut counter = HashMap::new();
    for s in acc_sum.iter() {
        let c = counter.entry(s).or_insert(0);
        *c += 1;
    }

    let ans: i64 = counter.values().filter(|&&n| n >= 2).map(|&n| comb(n, 2)).sum();

    println!("{:?}", ans);
}

fn comb(n: i64, r: i64) -> i64 {
    debug_assert!(n >= r);
    let mut res = 1;
    for i in 0..r {
        res *= n - i;
    }
    res / r
}


fn add<T: std::ops::Add<Output=T>>(a: T, b: T) -> T{
    a + b
}

fn accumulate_each<T: std::clone::Clone>(iterable: std::slice::Iter<T>, func: fn(T, T) -> T, init: T) -> Vec<T> {
    let mut res = Vec::new();
    let mut acc = init.clone();
    res.push(acc.clone());
    for element in iterable {
        acc = func(acc, element.clone());
        res.push(acc.clone());
    }
    res
}


fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}



Measured memory_bytes: 18180
def prob(n, k):
    ans = 0
    for i in range(1, n+1):
        now = i
        count = 0
        while (now < k):
            now *= 2
            count += 1
        ans += (0.5) ** count
    return ans / n

def main():
    n, k = map(int, input().split())
    print(prob(n, k))


main()


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

using namespace std;

typedef long long ll;

struct st
{
	ll x, y, z;
};

ll get(st a)
{
	return (a.x)+(a.y)+(a.z);
}

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

    int n, m;
    cin >> n >> m;
    vector<st> a(n);
    for (auto &i : a)
    	cin >> i.x >> i.y >> i.z;

    ll ans = numeric_limits<ll>::min();
    for (int j = 0; j < 8; ++j)
    {
    	auto b = a;
    	for (auto &i : b)
    	{
    		i.x *= ((j&1)?-1:1);
    		i.y *= ((j&2)?-1:1);
    		i.z *= ((j&4)?-1:1);
    	}

        sort(b.begin(), b.end(), [](st &x, st &y) { return get(x) > get(y); });

        ll t = 0;
        for (int i = 0; i < m; ++i)
        	t += get(b[i]);
        ans = max(ans, t);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <tuple>
#include <algorithm>
#include <iomanip>
#include <functional>

long double calcDist(int xi, int xj, int yi, int yj)
{
    return std::sqrt(std::pow(xi-xj, 2) + std::pow(yi-yj, 2));
}

long double clacAllDist(std::vector<std::pair<int, int>>& towns, int& N)
{
    long double pathLen = 0;
    for(int i = 0; i < N - 1; i++)
    {
        pathLen += calcDist(towns[i].first, towns[i+1].first, towns[i].second, towns[i+1].second);
    }
    return pathLen;
}

int main()
{
    std::vector<std::pair<int, int>> towns;
    int N, x, y;
    std::cin >> N;
    for(int i = 0; i<N; i++)
    {
        std::cin >> x >> y;
        towns.emplace_back(std::make_pair(x,y));
    }

    int numOfPermutation = 0;
    long double sumOfPathLen = 0;
    std::sort(towns.begin(), towns.end());
    do
    {
    	numOfPermutation++;
        sumOfPathLen += clacAllDist(towns, N);

    } while(std::next_permutation(towns.begin(), towns.end()));

    std::cout << std::setprecision(10)<< sumOfPathLen/numOfPermutation << std::endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int A;
int B;
int Q;
long long S[100000];
long long T[100000];
long long X;
int main(){
  int Q5VJL1cS, a, b, i, j;
  long long res;
  rd(A);
  rd(B);
  rd(Q);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<A;Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<B;KL2GvlyY++){
      rd(T[KL2GvlyY]);
    }
  }
  for(Q5VJL1cS=0;Q5VJL1cS<Q;Q5VJL1cS++){
    int FmcKpFmN, RZTsC2BF, WYIGIcGE, cTE1_r3A, e98WHCEY, xr20shxY;
    rd(X);
    res = 4611686016279904256LL;
    e98WHCEY = 0;
    cTE1_r3A = A;
    while(e98WHCEY < cTE1_r3A){
      if((e98WHCEY + cTE1_r3A)%2==0){
        RZTsC2BF = (e98WHCEY + cTE1_r3A) / 2;
      }
      else{
        RZTsC2BF = (e98WHCEY + cTE1_r3A - 1) / 2;
      }
      if(X<=S[RZTsC2BF]){
        cTE1_r3A = RZTsC2BF;
      }
      else{
        e98WHCEY = RZTsC2BF + 1;
      }
    }
    a =cTE1_r3A;
    FmcKpFmN = 0;
    xr20shxY = B;
    while(FmcKpFmN < xr20shxY){
      if((FmcKpFmN + xr20shxY)%2==0){
        WYIGIcGE = (FmcKpFmN + xr20shxY) / 2;
      }
      else{
        WYIGIcGE = (FmcKpFmN + xr20shxY - 1) / 2;
      }
      if(X<=T[WYIGIcGE]){
        xr20shxY = WYIGIcGE;
      }
      else{
        FmcKpFmN = WYIGIcGE + 1;
      }
    }
    b =xr20shxY;
    for(i=a-1;i<a+1;i++){
      if(0 <= i  &&  i < A){
        for(j=b-1;j<b+1;j++){
          if(0 <= j  &&  j < B){
            chmin(res, abs(X-S[i]) + abs(S[i]-T[j]));
            chmin(res, abs(X-T[j]) + abs(S[i]-T[j]));
          }
        }
      }
    }
    wt_L(res);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int A, B, Q;
// ll S[1d5], T[1d5], X;
// {
//   int i, j, a, b;
//   ll res;
//   rd(A,B,Q,S(A),T(B));
//   rep(Q){
//     rd(X);
//     res = ll_inf;
//     a = bsearch_min[int,i,0,A](X<=S[i]);
//     b = bsearch_min[int,i,0,B](X<=T[i]);
//     rep(i,a-1,a+1) if(0 <= i < A) rep(j,b-1,b+1) if(0 <= j < B){
//       res <?= abs(X-S[i]) + abs(S[i]-T[j]);
//       res <?= abs(X-T[j]) + abs(S[i]-T[j]);
//     }
//     wt(res);
//   }
// }


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

using namespace std;

string S[100000];

int main()
{
  int N;
  cin>> N;
  for(int i=0;i<N;i++)cin>> S[i];

  unsigned long long ret=0;
  unsigned long long M=0,A=0,R=0,C=0,H=0;
  for(int i=0;i<N;i++)
  {
    if(S[i][0]=='M')M++;
    else if(S[i][0]=='A')A++;
    else if(S[i][0]=='R')R++;
    else if(S[i][0]=='C')C++;
    else if(S[i][0]=='H')H++;
  }
  ret+=R*C*H;
  ret+=A*C*H;
  ret+=A*R*H;
  ret+=A*R*C;
  ret+=M*C*H;
  ret+=M*R*H;
  ret+=M*R*C;
  ret+=M*A*H;
  ret+=M*A*C;
  ret+=M*A*R;
  
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define tp make_tuple
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define pr(a) printf("%lld\n",a)
using namespace std;

#define mod 1000003


int main()
{
    ll n,t,x=26ll,y=25ll,k,i,j,p,q;

    cin>>n;

    //n--;

    /*if(n==0){

        cout<<"a"<<endl;

        return 0;
    }*/

    string st;

    string s[30]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};

    while(n){

        k=n%x;

        if(k==0){

            k=26;
            n--;
        }
        n--;

        st+=s[--k];




       //if(n%x==0 && n/x==1)break;

        n/=x;




    }

    reverse(st.begin(),st.end());

    cout<<st<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( a == c ){
        //cout << "Yes" << endl;
    } else {
        //cout << "No" << endl;
    }
    //*/
    
    cout << a / b + min(a % b, 1) << endl;
    
    return 0; 
}


Measured memory_bytes: 3556
package main
 
import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}
 
//func nextString() string {
//	sc.Scan()
//	return sc.Text()
//}
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	N := nextInt()
	l := make([]int, N)
	for i := 0; i < N; i++ {
		l[i] = nextInt()
	}
	ANS := 0
	BEFORE := 0
	NUM := 0
	for i := 0; i < N - 1; i++ {
		if l[i] >= l[i + 1] {
			NUM++
		} else {
			BEFORE = ANS
			NUM = 0
		}
		ANS = max(NUM, BEFORE)
	}
	fmt.Println(ANS)
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 5260
#include<iostream>
using namespace std;
main()
{
    int N;
    cin>>N;
    N++;
    int a[(N+1)];
    a[0]=0;
    a[N]=0;
    for(int i=1;i<N;i++)
    cin>>a[i];
    int sum=0;
    for(int i=1;i<=N;i++){
            sum+=abs(a[(i)]-a[(i-1)]);
    }
    for(int i=1;i<N;i++){
        cout<<sum-abs(a[(i)]-a[(i-1)])-abs(a[(i+1)]-a[(i)])+abs(a[(i+1)]-a[(i-1)])<<endl;

    }
    return 0;
}

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

int main() {

	int N, Y;
	bool ans = false;
	cin >> N >> Y;

	int x, y, z;

	for (x = 0; x <= N; x++) {
		for (y = 0; y <= N - x; y++) {
			z = N - x - y;
			if (10000 * x + 5000 * y + 1000 * z == Y) {
				ans = true;
				break;
			}
		}
		if (ans == true) break;
	}

	if (ans == true) cout << x << " " << y << " " << z;
	else cout << "-1 -1 -1";
	return 0;
}

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

int main(void) {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) cout << "Yes";
  else cout << "No";
  cout << endl;
}


Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int N;
    cin >> N;
    vector<ll> X(N, 0), U(N, 0);
    double ans = 0;
    for(int i = 0; i < N; i++) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC") ans += x * 380000.0;
        else ans += x;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    int count = 0;
    for (int i = a; i < b + 1; i++) {
        if (c % i == 0) ++count;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3112
# coding: utf-8

a, b, c, d = map(int, input().split())

t = '高橋'

while True:
    if t=='高橋':
        c = c - b
        t = '青木'
        if c <= 0:
            print("Yes")
            break
        
    elif t=='青木':
        a = a - d
        t = '高橋'
        if a <= 0:
            print("No")
            break

Measured memory_bytes: 9064
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    X = int(input())
    n = X // 100
    remain = X - n * 100
    if remain <= 5 * n:
        print(1)
    else:
        print(0)
    # print(remain, n)



if __name__ == '__main__':
    main()


Measured memory_bytes: 66028
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var a = sc.nextInt();
		var b = sc.nextInt();
		if ((b - 2 * a) % 2 != 0 || (b - 2 * a) < 0 || (a - (b - 2 * a) / 2 < 0)) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

void markRbl(int n, auto& nbr, auto& rbl) {
  if (rbl.at(n)) return;
  rbl.at(n) = true;
  for (int j : nbr.at(n)) markRbl(j, nbr, rbl);
}

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, M, P; cin >> N >> M >> P;
  vector<int> A(M), B(M), C(M);
  vector<vector<int>> nbrN(N+1), nbrR(N+1);
  for (int i = 0; i < M; i++)  {
    int a, b, c; cin >> a >> b >> c;
    A.at(i) = a;
    B.at(i) = b;
    C.at(i) = c;
    nbrN.at(a).push_back(b);
    nbrR.at(b).push_back(a);
  }
  vector<bool> rblN(N+1), rblR(N+1);
  markRbl(1, nbrN, rblN);
  markRbl(N, nbrR, rblR);
  assert(rblN.at(N) && rblR.at(1));
  int K = 0;
  for (int i = 1; i <= N; i++) if (rblN.at(i) && rblR.at(i)) K++;
  vector<int> dist(N+1);
  for (int i = 1; i <= N; i++) dist.at(i) = INT_MAX;
  dist.at(1) = 0;
  bool modified;
  for (int k = 0 ; k < K; k++) {
    modified = false;
    for (int i = 0; i < M; i++) {
      int a = A.at(i), b = B.at(i);
      if (! (rblN.at(a) && rblR.at(a) && rblN.at(b) && rblR.at(b))) continue;
      if (dist.at(a) == INT_MAX) continue;
      int newDist = dist.at(a) + P - C.at(i);
      if (newDist >= dist.at(b)) continue;
      dist.at(b) = newDist;
      modified = true;
    }
    if (!modified) break;
  }
  if (modified) cout << "-1\n";
  else          cout << max(0, -dist.at(N)) << "\n";
  return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
bool kirai[10];
bool ok(int x){
	int k=0;
	int i;
	while(x!=0){
		k=x%10;
		if(kirai[k]){
			return false;
		}
		x=x/10;
	}
	return true;

}

int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	int i,j;
	for(i=0;i<k;i++){
		scanf("%d",&j);
		kirai[j]=true;
	}
	for(i=n;1;i++){
		if(ok(i)){
			printf("%d",i);
			return 0;
		}

	}

	


	
	return 0;
}

Measured memory_bytes: 128
from operator import itemgetter
n, c = map(int, input().split())
tmp_info = [list(map(int, input().split())) for i in range(n)]

tmp_info = sorted(tmp_info, key=itemgetter(2,1))
info = []
for i in range(n):
    if not info:
        info.append(tmp_info[i])
    elif info[-1][1] == tmp_info[i][0] and info[-1][2] == tmp_info[i][2]:
        info[-1][1] =tmp_info[i][1]
    else:
        info.append(tmp_info[i])
info = sorted(info, key=itemgetter(1))
n = len(info)
li = []

for i in range(n):
    li = sorted(li, reverse=True)
    for j in range(len(li)):
        if info[i][0] > li[j]:
            li[j] = info[i][1]
            break
    else:
        li.append(info[i][1])
        
print(len(li))

Measured memory_bytes: 36848
#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[3];
  rep(i, 3){
    cin >> s[i];
  }
	
  cout << s[0][0] << s[1][1] << s[2][2] << endl;
  
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef long long ll;
using namespace std;
int main()
{
   string s;
   cin>>s;
   ll cnt=0;
   ll n= s.size();
   for(int i=0;i<n;i++)
   {
       int temp=s[i]-'0';
       cnt+=temp;
   }
   if(cnt%9)
    cout<<"No"<<endl;
   else
    cout<<"Yes"<<endl;

return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int m;
const int mmax=1e5+5;

vector<int>edges[mmax],child[mmax];
vector<pair<int,int>>downs[mmax],pref[mmax],suf[mmax];
pair<int,int>d[mmax],u[mmax];

pair<int,int>merge(const pair<int,int>&a,const pair<int,int>&b){
    pair<int,int>p;
    p.first=(long long)(a.first)*(b.first)%m;
    p.second=((long long)(a.second)*((b.first+b.second)%m)%m+(long long)(a.first)*(b.second)%m)%m;
    return p;
}

pair<int,int>pro(pair<int,int>p){
    return {p.first,(p.first+p.second)%m};
}

void dfs(int current,int prev){
    pair<int,int>p{1,0};
    for(auto x:edges[current]){
        if(x!=prev){
            child[current].push_back(x);
            dfs(x,current);
            p=merge(p,d[x]);
            downs[current].push_back(d[x]);
        }
    }
    d[current]=pro(p);
}

void dfs2(int current,int prev){
    for(int i=0;i<child[current].size();i+=1){
        pair<int,int>p{1,0};
        if(i){
            p=merge(p,pref[current][i-1]);
        }
        if(i!=(downs[current].size()-1)){
            p=merge(p,suf[current][i+1]);
        }
        if(current!=1){
            p=merge(p,u[current]);
        }
        int b=child[current][i];
        u[b]=pro(p);
        dfs2(b,current);
    }
}

int main() {
	int n,a,b;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n-1;i+=1){
	    scanf("%d%d",&a,&b);
	    edges[a].push_back(b);
	    edges[b].push_back(a);
	}
	dfs(1,-1);
	for(int i=1;i<=n;i+=1){
	    int k=downs[i].size();
	    pair<int,int>p{1,0};
	    for(int j=0;j<k;j+=1){
	        p=merge(p,downs[i][j]);
	        pref[i].push_back(p);
	    }
	    p={1,0};
	    for(int j=(k-1);j>-1;j-=1){
	        p=merge(p,downs[i][j]);
	        suf[i].push_back(p);
	    }
	    reverse(suf[i].begin(),suf[i].end());
	}
	dfs2(1,-1);
	for(int i=1;i<=n;i+=1){
	    pair<int,int>p{1,0};
	    if(i!=1){
	        p=merge(p,u[i]);
	    }
	    if(!child[i].empty()){
	        p=merge(p,pref[i].back());
	    }
	    p=pro(p);
	    printf("%d\n",p.second);
	}
	return 0;
}


Measured memory_bytes: 35328