akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long gcd(long long x, long long y);

signed main() {
    int n;
    long long t[100], g, ans;

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

    for ( int i = 1; i < n; i++ ) {
        if ( t[i] % g == 0 ) {
            g = t[i];
        } else if ( g % t[i] != 0 ) {
            g = (t[i] / gcd(t[i], g)) * g;  
        }
    }

    cout << g << endl;

    return (0);
}

long long gcd(long long x, long long y) {
    if ( y > x ) {
        swap(x, y);
    }

    long long z = x % y;
    while ( z != 0 ) { 
        x = y;
        y = z;
        z = x % y;
    }

    return (y);
}

Measured memory_bytes: 3568
#include<iostream>

bool comunicate(int d1 , int d2 , int d3 , int d){
    if(d3 <= d) return true;
    if(d1 <= d && d2 <= d) return true;
    return false;
}

int main(){

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);

    int a , b , c , d;
    std::cin >> a >> b >> c >> d;

    int dist_ab = abs(b - a);
    int dist_bc = abs(c - b);
    int dist_ac = abs(c - a);

    std::string s = comunicate(dist_ab,dist_bc,dist_ac,d) ? "Yes" : "No";

    std::cout << s;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) a[i]--;
    vector<int> s(n+1);
    for(int i=0; i<n; i++) s[i+1] = (s[i]+a[i])%k;
    map<int,int> mp;
    ll ans = 0;
    queue<int> q;
    for(int j=0; j<n+1; j++)
    {
        ans += mp[s[j]];
        mp[s[j]]++;
        q.push(s[j]);
        if(q.size() == k)
        {
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12032
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] board = new int[H][W];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                board[i][j] = sc.nextInt();
            }
        }
        ArrayList<String> ans = new ArrayList<String>();
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W - 1; j++) {
                right(i, j, board, ans);
            }
            if (++i < H) {
                down(i - 1, W - 1, board, ans);
                for (int j = W - 1; j > 0; --j) {
                    left(i, j, board, ans);
                }
                if (i + 1 < H) {
                    down(i, 0, board, ans);
                }
            }
        }
        System.out.println(ans.size());
        for (String str : ans) {
            System.out.println(str);
        }
    }

    static void right(int i, int j, int[][] board, ArrayList<String> ans) {
        if (board[i][j] % 2 != 0) {
            board[i][j + 1]++;
            ans.add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
        }
    }

    static void left(int i, int j, int[][] board, ArrayList<String> ans) {
        if (board[i][j] % 2 != 0) {
            board[i][j - 1]++;
            ans.add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j));
        }
    }

    static void down(int i, int j, int[][] board, ArrayList<String> ans) {
        if (board[i][j] % 2 != 0) {
            board[i + 1][j]++;
            ans.add((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1));
        }
    }
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

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

    a <= c && c <= b ? cout << "Yes" : cout << "No";
}


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

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static _T tp_modpow(_T base, _T exp, _T mod = (_T)1) {
	_T ans = 1;
	while (exp > 0) {
		if (exp & 1) {
			ans = (ans * base) % mod;
		}
		base = (base * base) % mod;
		exp >>= 1;
	}
	return ans;
}
template <class _T> static _T tp_modinv(_T a, _T mod) {
	return tp_modpow<_T>(a, mod - 2, mod);
}

static void E();

int main()
{
	E();
	fflush(stdout);
	return 0;
}

static void E()
{
	int N;
	get(N);

	std::vector<std::pair<LLONG, LLONG>> pt(N);
	for (int i = 0; i < N; i++) {
		get(pt[i].first, pt[i].second);
	}

	auto pp = [](std::pair<LLONG, LLONG>& a, std::pair<LLONG, LLONG>& b) {
		return (a.first + a.second) > (b.first + b.second);
	};
	auto mp = [](std::pair<LLONG, LLONG>& a, std::pair<LLONG, LLONG>& b) {
		return (-a.first + a.second) > (-b.first + b.second);
	};
	auto mm = [](std::pair<LLONG, LLONG>& a, std::pair<LLONG, LLONG>& b) {
		return (-a.first - a.second) > (-b.first - b.second);
	};
	auto pm = [](std::pair<LLONG, LLONG>& a, std::pair<LLONG, LLONG>& b) {
		return (a.first - a.second) > (b.first - b.second);
	};
	std::pair<LLONG, LLONG> pp1, mp1, mm1, pm1;
	std::sort(pt.begin(), pt.end(), pp);
	pp1 = pt[0];

	std::sort(pt.begin(), pt.end(), pm);
	pm1 = pt[0];

	std::sort(pt.begin(), pt.end(), mp);
	mp1 = pt[0];

	std::sort(pt.begin(), pt.end(), mm);
	mm1 = pt[0];

	LLONG ans = pp1.first - mp1.first + pp1.second - mp1.second;
	ans = std::max(ans, tp_abs(pp1.first - mm1.first) + tp_abs(pp1.second - mm1.second));
	ans = std::max(ans, tp_abs(pp1.first - pm1.first) + tp_abs(pp1.second - pm1.second));
	ans = std::max(ans, tp_abs(pm1.first - mp1.first) + tp_abs(pm1.second - mp1.second));
	ans = std::max(ans, tp_abs(pm1.first - mm1.first) + tp_abs(pm1.second - mm1.second));
	printf("%lld\n", ans);
}


Measured memory_bytes: 6484
import java.util.*;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();

    	if (C-(A-B) >= 0) {
    		System.out.println(C-(A-B));
    	} else {
    		System.out.println(0);
    	}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int h, w;
int muri=0;
char a[10][10];
int x[11][11]={};
int sta[10];
int goa[10];
int main()
{
	cin >> h >> w;
	repp(i, 1, h+1)
	{
		repp(j, 1, w+1)
		{
			cin >> a[i][j];
			if(a[i][j]=='#')
			{
				x[i][j]=1;
			}
			else
			{
				x[i][j]=0;
			}
		}
	}
	repp(i, 1, h+1)
	{
		int c=0;
		repp(j, 1, w+2)
		{
			if((x[i][j]==1)&&(c==0))
			{
				sta[i]=j;
				c++;
			}
			if((x[i][j]==0)&&(x[i][j-1]==1)&&(c==1))
			{
				goa[i]=j-1;
				c++;
			}
			if((x[i][j]==1)&&(c==2))
			{
				muri=1;
			}
		}
		if(c==0)
		{
			muri=1;
		}
	}
	if(sta[1]!=1)
	{
		muri=1;
	}
	repp(i, 2, h+1)
	{
		if(sta[i]!=goa[i-1])
		{
			muri=1;
		}
	}
	if(goa[h]!=w)
	{
		muri=1;
	}
	if(muri==1)
	{
		cout << "Impossible" << endl;
	}
	else
	{
		cout << "Possible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
// using namespace std;
// typedef long long ll;
// const int INF = 0x3f3f3f3f;
// const int N = 1e5 + 10;
// const int MAX = 1e5 + 10;
// void rev(string& s) {
//     char ch;
//     for (int i = 0, j = s.size() - 1; i < j; ++i, --j) {
//         ch = s[i];
//         s[i] = s[j];
//         s[j] = ch;
//     }
// }
// int main() {
//     cin.tie(0);
//     cout.tie(0);
//     string str;
//     int q, t, f;
//     char ch;
//     cin >> str;
//     scanf("%d", &q);
//     int cnt = 0;
//     while (q--) {
//         scanf("%d", &t);
//         if (t == 1) {
//             cnt++;
//         } else {
//             scanf("%d %c", &f, &ch);
//             if (f == 1) {
//                 if (cnt & 1)
//                     str += ch;
//                 else
//                     str = ch + str;
//             } else {
//                 if (cnt & 1)
//                     str = ch + str;
//                 else
//                     str += ch;
//             }
//         }
//     }
//     if (cnt & 1) rev(str);
//     cout << str;
// }
// 这题傻逼了，用deque
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }

int main() {
    string str;
    cin >> str;
    deque<char> d;
    d.assign(str.begin(), str.end());
    int q, t, f;
    char ch;
    scanf("%d", &q);
    int cnt(0);
    while (q--) {
        scanf("%d", &t);
        if (t == 1) {
            cnt++;
        } else {
            scanf("%d %c", &f, &ch);
            if (f == 1) {
                if (cnt & 1)
                    d.push_back(ch);
                else
                    d.push_front(ch);
            } else {
                if (cnt & 1)
                    d.push_front(ch);
                else
                    d.push_back(ch);
            }
        }
    }
    if (cnt & 1) {
        for (int i = d.size() - 1; i >= 0; --i) printf("%c", d[i]);
    } else {
        for (auto s : d) printf("%c", s);
    }
}

Measured memory_bytes: 896
from math import pi, cos, sqrt
from sys import stdin

a,b,h,m = map(int,stdin.readline().rstrip().split())

l = 2*pi*m/60
s = 2*pi*(h+m/60)/12
theta = s-l
ans = sqrt(a**2+b**2-2*a*b*cos(theta))
print(ans)

Measured memory_bytes: 9472
//bool banned[10];
//bool valid(int x){
//    while(x > 0){
//        if(banned[x%10])
//            return false;
//        x /= 10;
//    }
//    return true;
//}
//int _(){
//    int n,k;
//    cin >> n >> k;
//    vi d(k);
//    cin >> d;
//    for(int x : d)
//        banned[x] = true;
//    for(int i = n; ; ++i)
//        if(valid(i))
//            return i;
//}
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef vector<int> vi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
bool banned[10];
bool valid(int x){
    while(x > 0){
        if(banned[x%10])
            return false;
        x /= 10;
    }
    return true;
}
int _(){
    int n,k;
    cin >> n >> k;
    vi d(k);
    cin >> d;
    for(int x : d)
        banned[x] = true;
    for(int i = n; ; ++i)
        if(valid(i))
            return i;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/cumsum.hpp
#ifndef CUMSUM_HPP
#define CUMSUM_HPP


/*
usage:

std::vector<std::vector<std::int_fast64_t>> a;
const std::vector<std::vector<std::int_fast64_t>> cumsum = tools::cumsum(a);
*/

namespace tools {
  template <typename T, typename OP>
  std::vector<T> cumsum(const std::vector<T>& source, const T& init, const OP& op) {
    std::vector<T> result({init});
    result.reserve(source.size() + 1);
    for (const T& x : source) {
      result.push_back(op(result.back(), x));
    }
    return result;
  }

  template <typename T>
  std::vector<T> cumsum(const std::vector<T>& source) {
    return cumsum<T>(source, static_cast<T>(0), std::plus<T>());
  }

  template <typename T, typename OP>
  std::vector<std::vector<T>> cumsum(const std::vector<std::vector<T>>& source, const T& init, const OP& op) {
    if (source.empty()) return std::vector<std::vector<T>>({std::vector<T>({init})});
    const std::size_t n1 = source.size();
    const std::size_t n2 = source.front().size();
    std::vector<std::vector<T>> result(n1 + 1, std::vector<T>(n2 + 1, init));
    for (std::size_t i = 0; i < n1; ++i) {
      for (std::size_t j = 0; j < n2; ++j) {
        result[i + 1][j + 1] = op(result[i + 1][j], source[i][j]);
      }
    }
    for (std::size_t j = 0; j < n2; ++j) {
      for (std::size_t i = 0; i < n1; ++i) {
        result[i + 1][j + 1] = op(result[i][j + 1], result[i + 1][j + 1]);
      }
    }
    return result;
  }

  template <typename T>
  std::vector<std::vector<T>> cumsum(const std::vector<std::vector<T>>& source) {
    return cumsum<T>(source, static_cast<T>(0), std::plus<T>());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string S;
  std::cin >> N >> S;

  std::vector<i64> costs_e(N, 0);
  std::vector<i64> costs_w(N, 0);
  for (i64 i = 0; i < N; ++i) {
    switch (S[i]) {
    case 'E':
      ++costs_w[i];
      break;
    case 'W':
      ++costs_e[i];
      break;
    }
  }

  const std::vector<i64> costs_e_sum = tools::cumsum(costs_e);
  const std::vector<i64> costs_w_sum = tools::cumsum(costs_w);

  i64 answer = std::numeric_limits<i64>::max();
  for (i64 i = 0; i < N; ++i) {
    answer = std::min(answer, (costs_e_sum[i] - costs_e_sum[0]) + (costs_w_sum[N] - costs_w_sum[i + 1]));
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 9988
x,y=list(map(int, input().split()))
z=list(map(int, input().split()))
ans=0
chk=0
for i in range(y):
	ans=ans+z[i]
	chk=ans
for i in range(x-y):
	chk=chk-z[i]+z[i+y]
	if chk>ans:
		ans=chk
print((ans+y)/2)

Measured memory_bytes: 24548
# Acceptance of input

import sys

file_input = sys.stdin

V, E = map(int, file_input.readline().split())

adj_mat = [[0] * V for i in range(V)]

for line in file_input:
    u, v, c = map(int, line.split())
    adj_mat[u][v] = c

# Ford???Fulkerson algorithm

import collections

# BFS for residual capacity network
def bfs(start, goal, parent):
    unvisited = [True] * V
    queue = collections.deque()
    queue.append(start)
    unvisited[start] = False
    while queue:
        u = queue.popleft()
        for v, flow in enumerate(adj_mat[u]):
            if unvisited[v] and (flow > 0):
                queue.append(v)
                unvisited[v] = False
                parent[v] = u
    return not unvisited[goal]

def ford_fulkerson(source, sink):
    parent = [None] * V
    max_flow = 0
    while bfs(source, sink, parent):
        aug_path_flow = 10000
        v = sink
        while (v != source):
            aug_path_flow = min(aug_path_flow, adj_mat[parent[v]][v])
            v = parent[v]
        max_flow += aug_path_flow
        v = sink
        while (v != source):
            u = parent[v]
            adj_mat[u][v] -= aug_path_flow
            adj_mat[v][u] += aug_path_flow
            v = u
    return max_flow

# output
print(ford_fulkerson(0, V - 1))

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

using namespace std;
typedef long long ll;


int main() 
{
  int n, k;
  cin >> n >> k;
  vector<int> A(n + 1);
  for ( int i = 1; i <= n; ++i ) cin >> A[i];

  sort(A.begin(), A.end());
  A[0] = 0;
  for ( int i = 1; i <= n; ++i )
  {
    A[i] += A[i - 1];
  }

  cout << A[k];
  return 0;
}

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

using namespace std;

const int MAXN = 2e5 + 5;

int n , m;
double a[MAXN];

int main()
{
    cin>>n>>m;
    for(int i = 0;i<n;i++)
    {
        double t ;
        cin>>t;
        a[i] = 1.0*( t * (t+1.0)/2.0 ) / t;
    }
    double ans = 0.0 , sol= 0.0;
    for(int i = 0;i<m-1;i++)
        ans+=a[i];
    for(int i = m-1;i<n;i++)
    {
        ans+=a[i];
        if(i - m>=0)
            ans-=a[i-m];
        sol = max(sol , ans);
    }
    cout<<fixed<<setprecision(10)<<sol;
    return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

public class Main {
    

    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter p = new PrintWriter(System.out);
        //int T = sc.nextInt();
        //for(int x=1;x<=T;++x){
        String str=sc.next();//String s1="",s2="";boolean flag=false;
        if(str.charAt(str.length()-1)=='s'){
            System.out.println(str+"es");
        }
        else{
            System.out.println(str+"s");
        }
        
    
    }
}

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

using namespace std;

string field[12];

void dfs(int i, int j){
  int dx[4] = {-1, 0, 0, 1};
  int dy[4] = {0, 1, -1, 0};
  if(field[i][j] != '1'){
    return;
  }else{
    field[i][j] = '*';
    for(int m = 0;m < 4;m++){
      int x = i+dx[m], y = j + dy[m];
      if(0 <= x && x < 12 && 0 <= y && y < 12){
        dfs(x, y);
      }
    }
    return;
  }
  return;
}

int solve(){
  int cnt = 0;
  for(int i = 0;i < 12;i++){
    for(int j = 0;j < 12;j++){
      if(field[i][j] == '1'){
        cnt++;
        dfs(i, j);
      }
    }
  }
  return cnt;
}

int main(void){
  while(cin >> field[0] && field[0].size()){
    for(int i = 1;i < 12;i++){
      cin >> field[i];
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a[3] = {};
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] == a[1] && a[1] != a[2]) {
        cout << "Yes\n";
        rr;
    }
    else if (a[1] == a[2] && a[1] != a[0]) {
        cout << "Yes\n";
        rr;
    }
    cout << "No\n";
    rr;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = long long;
    
    
int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    
    ll ans = 0;
    ans += min(A, K);
    K -= A;
    K -= B;
    
    if(K > 0){
        ans -= K;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = Str;
		var min = int.MaxValue;
		for (var i = 0; i < S.Length - 2; i++)
		{
			var X = int.Parse(S.Substring(i, 3));
			min = Min(min, Abs(X - 753));
		}
		WriteLine(min);
	}
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
	cin >> h[i];
  }  
  sort(h.begin(),h.end());
  int min=h[K-1]-h[0];
  for(int i=0;i<N-K+1;i++){
	if(h[i+K-1]-h[i]<min){
	  min=h[i+K-1]-h[i];
	}
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

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

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 15; j++) {
			if ((4 * i + 7 * j) == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    set<int> S;
    rep(i,N) {
        int A;
        cin>>A;
        if(S.count(A)==1) S.erase(A);
        else S.insert(A);
    }
    cout<<S.size()<<endl;
}

Measured memory_bytes: 4864
#include<stdio.h>
#define M 500000
int a[M],b[M],count=0;
void mergeSort(int *a,int l,int r){
  int i,j,k,m;
  if(r>l){
    m=(r+l)/2;
    mergeSort(a,l,m);
    mergeSort(a,m+1,r);
    for(i=m+1;i>l;i--)
      b[i-1]=a[i-1];
    for(j=m;j<r;j++)
      b[r+m-j]=a[j+1];
    for(k=l;k<=r;k++){
      a[k]=(b[i]<b[j])?b[i++]:b[j--];
      count++;
    }
  }
}

main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  mergeSort(a,0,n-1);
  for(i=0;i<n-1;i++)
    printf("%d ",a[i]);
  printf("%d\n%d\n",a[n-1],count);
  return 0;
}

Measured memory_bytes: 4504
w,h,n = map(int,input().split())
W = ["."] * w
H = ["."] * h

for _ in range(n):
  x,y,a = map(int,input().split())
  
  if a==1:
    tmp = ["#"]*x + W[x:]
    W = tmp
  elif a==2:
    tmp = W[:x] + ["#"]
    W = tmp
  elif a==3:
    tmp = ["#"]*y + H[y:]
    H = tmp
  elif a==4:
    tmp = H[:y] + ["#"]
    H = tmp
    
print(W.count('.')*H.count('.'))


Measured memory_bytes: 9168
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


void push(int);
void pop(int);
int ans[100],point = 0;


int main(){
  int x = 0,y = 0,i = 0;
  char s[100];

  while( scanf("%s", s) != EOF ){

    if ( s[0] == '+' ){
      pop(1);
    } 
    
    else if ( s[0] == '-' ){  
      pop(2);
    } 

    else if ( s[0] == '*' ){
      pop(3);      
    } 
    
    else {

      push(atoi(s));
     

    }


  }

  
  printf("%d\n",ans[point - 1]);


  return 0;
}




void push(int mu){

  ans[point] = mu;
  point++;

}

void pop(enzan){

  if(enzan == 1){
    ans[point - 2] = ans[point - 1] + ans[point - 2];
    point--;      
      }
  else if(enzan == 2){
    ans[point - 2] = ans[point - 2] - ans[point - 1];
    point--;
  }
  else {
    ans[point - 2] = ans[point - 2] * ans[point - 1];
    point--;
  }

}

Measured memory_bytes: 548
#include<stdio.h>
    int main()
    {
      int l , r , d,c=0;
      scanf("%d %d %d", &l, &r, &d);
      for(int i=l;i<=r;i++)
      {
        if(i%d==0)
          c++;
      }
      printf("%d",c);
    }

Measured memory_bytes: 1700
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n,y = LI()
    for i in range(n+1):
        for j in range(n+1-i):
            k = n-i-j
            if 10000*i+5000*j+1000*k == y:
                print(i,j,k)
                quit()
    print(-1,-1,-1)

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 39280
using System;
using System.Linq;

namespace AtCoderCs
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());
            bool even = true;

            foreach (var num in Console.ReadLine().Split(' ').Select(c => int.Parse(c)))
            {
                if (num % 2 != 0) // odd
                {
                    even = !even;
                }
            }

            Console.WriteLine(even ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 11992
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(num_list[1]-num_list[0])
    
    for i in range(2,n):
        dp[i] = min(abs(num_list[i-1]-num_list[i])+dp[i-1], abs(num_list[i-2]-num_list[i])+dp[i-2])
    
    print(dp[n-1])

if __name__ == '__main__':
    main()

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

int main() {
    ll n;
    cin >> n;
    ll ans = n - 1;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans = std::min(ans, i + n / i - 2);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

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

    int max,min;
    sort(a.begin(),a.end());
    max=a[n-1];
    min=a[0];

    cout << max-min << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String result = "No";
		
		String [] group = {" 1 3 5 7 8 10 12 ", " 4 6 9 11 ", " 2 "};
		
		String x = sc.next();
		String y = sc.next();
		
		for (int i = 0; i < group.length; i++) {
		    if(group[i].contains(" " + x + " ") && group[i].contains(" " + y + " ")) {
		        result = "Yes";
		    }
		}
		
		// output
		System.out.println(result);
	}
}

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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	friend modnum inv(const modnum& m) { return m.inv(); }
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	friend modnum neg(const modnum& m) { return m.neg(); }

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9)+7>;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vector<num> fact(2*N+1);
	fact[0] = 1;
	for (int i = 1; i <= 2*N; i++) fact[i] = fact[i-1] * num(i);
	vector<num> ifact(2*N+1);
	ifact[2*N] = inv(fact[2*N]);
	for (int i = 2*N; i >= 1; i--) ifact[i-1] = ifact[i] * num(i);

	auto choose = [&](int n, int r) {
		return fact[n] * ifact[r] * ifact[n-r];
	};

	num ans = 0;
	for (int i = 0; i < N && i <= K; i++) {
		ans += choose(N, i) * choose(N-i-1 + i, i);
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
int main() {
	int n;
	long long int val = 0;
	scanf("%d",&n);
	
	for (int i = 1 ; i <= n; i++)
	{
		if (i % 3 == 0 && i % 5 == 0)
		{
			continue;
		}
		else if (i % 3 == 0)
		{
			continue;
		}
		else if (i % 5 == 0)
		{
			continue;
		}
		else
		{
			val += i;
		}
	}
	printf("%lld",val);
	return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>
int main(void){
    int N,X,T,ans;
    scanf("%d",&N);
    scanf("%d",&X);
    scanf("%d",&T);

    ans=N/X;
    if(N%X!=0){
        ans++;
    }
    ans=ans*T;

    printf("%d\n",ans);
    return 0;

}

Measured memory_bytes: 2156
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <stack>

using P = std::pair<int, int>;
using int64 = long long;

struct Data{
    int64 ans, depth;

    std::vector<P> counter;

    Data(int64 ans, int64 depth, std::initializer_list<P> counter):counter(counter) {
        this->ans = ans, this->depth = depth;
    }
};

int main() {
    std::string str;

    std::cin >> str;

    int64 ans = 0, depth = 0;
    std::vector<int> counter(str.size() + 100);
    std::stack<Data> st;
    for(int i = 0; i < str.size(); ++i) {
        if(str[i] == '(') {
            st.push(Data{ans, depth, {}});
            depth = std::max(depth + 1, 1ll);
        }else if (str[i] == ')') {
            if(depth > 0) {
                st.push(Data{ans, depth, {P{depth, counter[depth]}, P{depth - 1, counter[depth - 1]}}});

                counter[depth] = 0;
                --depth;
                ans += counter[depth] + 1;
                ++counter[depth];
            }else {
                st.push(Data{ans, depth, {P{0, counter[0]}}});
                counter[0] = 0;
            }
        }else {
            auto t = st.top(); st.pop();

            ans = t.ans;
            depth = t.depth;

            for(auto& v: t.counter) {
                counter[v.first] = v.second;
            }
        }

        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 18328
fn main() {
    let n = readln();
    let a: Vec<usize> = readlns(n);
    let mut ans = 1;
    for &x in &a {
        ans = ans / gcd(ans, x) * x;
    }
    println!("{}", ans);
}

fn gcd(x: usize, y: usize) -> usize {
    let mut x = x;
    let mut y = y;
    while y != 0 {
        let t = y;
        y = x % y;
        x = t;
    }
    x
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

main :: IO ()
main = do
  n <- readLn
  as <- readIntsLine
  let es = [x | x <- [2,4..n+4], x <= n]
  let os = [x | x <- [1,3..n+4], x <= n]
  let is = map fst . sortOn snd . zip [1..] $ if even n
                                              then reverse es ++ os
                                              else reverse os ++ es
  putStrLn . unwords . map (show . snd) . sortOn fst $ zip is as

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

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) { cin >> vec[i]; }

  bool flag = 1;
  int count = 0;

  while (flag) {
    flag = 0;

    for (int i = n - 1; i > 0; i--) {
      if (vec[i] < vec[i - 1]) {
        swap(vec[i], vec[i - 1]);
        count++;
        flag = 1;
      }
    }
  }

  rep(i, n) {
    if (i) {
      printf(" ");
    }
    printf("%d", vec[i]);
  }

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



Measured memory_bytes: 3212
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	rep(i,4) cout<<S[i];
	cout<<" ";
	for(int i=4;i<S.size();i++) cout<<S[i];
	kaigyo;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
bool isPrime(int n) {
  // returns whether n is prime number or not
  // n should be in range [0, lim].
  // to see detail, search "Sieve of Eratosthenes"
  static int lim = 1e5 + 1;
  static bool done = false;
  static vector<bool> isp(lim + 1, 1);
  if (!done) {
    isp[0] = isp[1] = false;
    for (int i = 2; i <= lim; i++) {
      if (isp[i]) {
        for (int j = i + i; j <= lim; j += i) {
          isp[j] = false;
        }
      }
    }
    done = true;
  }
  return isp[n];
}

int main() {
  int lim = 1e5 + 1;
  VEC<int> cs(lim, 0);
  REP(i, 1, lim) {
    if (i % 2 == 1) {
      if (isPrime(i) && isPrime((i + 1) / 2)) {
        ++cs[i] ;
      }
    }
    cs[i]+=cs[i-1];
  }
  //DUMP(cs);

  int q;
  cin >> q;
  REP(i,0,q){
    int l,r;
    cin>>l>>r;
    cout<<cs[r]-cs[l-1]<<endl;

  }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll x, y;
    cin >> x >> y;
    
    if(abs(x - y) <= 1){
        cout << "Brown\n";
    }
    else{
        cout << "Alice\n";
    }
}

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

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	if(a + k - 1 < b - k + 1)
	{
		for(int i = a; i <= a + k - 1; i++)
			printf("%d\n", i);
		for(int i = b - k + 1; i <= b; i++)
			printf("%d\n", i);
	}
	else
	{
		for(int i = a; i <= b; i++)
			printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b;
	c=b-a+1;
	if(a<b)
	{
		if(a>0&&b>0)
		{
			cout<<"Positive"<<endl;
		}
		else
		{
			if(a<=0&&b>0)
			{
				cout<<"Zero"<<endl;
			}
			else
			{
				if(a<0&&b<=0)
				{
					if(b==0)
					{
						cout<<"Zero"<<endl;
					}
					else
					{
						if(c%2==0)
						{
							cout<<"Positive"<<endl;
						}
						else
						{
							cout<<"Negative"<<endl;
						}
					}
				}
			}
		}
	}
	else
	{
		return 0;
	}
	return 0;	
}

Measured memory_bytes: 256
n = int(input())
A = [0] + list(map(int, input().split())) + [0]

D = [abs(A[i+1]-A[i]) for i in range(len(A)-1)]
base = sum(D)

for i in range(n):
  print(base-D[i]-D[i+1]+abs(A[i+2]-A[i]))

Measured memory_bytes: 14048
#include<stdio.h>
int main(void){
	int a,b;
	int i,tmp;
	for(i=0;i<3000;i++){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0){
			break;
		}
		if(a>b){
			tmp=a;
			a=b;
			b=tmp;
		}
		printf("%d %d\n",a,b);
	}
return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int max( int a, int b );
static int isATCG( int ch );
static int cntATCGstr( char *str );

void main()
{
  char str[10+1];
  int  len;
  int  strlen_max;
  
  scanf( "%s", str );

  len = strlen( str );
  strlen_max = 0;

  for( int i = 0; i < len; i++ ){
    if( !isATCG( str[ i ] ) ) continue;
    strlen_max = max( strlen_max, cntATCGstr( &str[ i ] ) );
  }
  printf("%d\n", strlen_max );
  exit(0);
}

static int max( int a, int b )
{

  return (a >= b)?a:b;
}

static int isATCG( int ch )
{
  if( ch == 'A'
   || ch == 'T'
   || ch == 'C'
   || ch == 'G' ){
    return 1;
  }
  return 0;
}

static int cntATCGstr( char *str )
{
  int i;
  
  for( i = 0; isATCG( str[ i ] ); i++ );
  return i;
}


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

struct Edge{
	int a,b,c;
};
bool operator < (const Edge &a, const Edge &b){
	return a.c < b.c;
}
int n,m;

int uf[10010];
int get(int x){
	return x == uf[x] ? x : uf[x] = get(uf[x]);
}
int unite(int x,int y){
	if( rand() & 1 ) swap(x,y);
	uf[get(x)] = get(y);
}

vector<Edge> es;
int check(){
	for(int i = 0 ; i < n ; i++) uf[i] = i;
	vector<int> v;
	for(int i = 0 ; i < es.size() ; i++){
		auto &e = es[i];		
		if( get(e.a) != get(e.b) ){
			unite(e.a,e.b);
			v.push_back(e.c);
		}
	}
	
	return v[v.size()/2];
}
int main(){
	while(cin >> n >> m && n){
		es.resize(m);
		for(int i = 0 ; i < m ; i++) cin >> es[i].a >> es[i].b >> es[i].c, es[i].a--, es[i].b--;
		sort(es.begin(),es.end());
		cout << check() << endl;
	}
			
}

Measured memory_bytes: 1360
def main():
    n, k = map(int, input().split())
    v = list(map(int, input().split()))
    reversed_v = [0] + v[::-1]
    v = [0] + v
    ans = -float("inf")
    for i in range(n + 1):
        for j in range(n + 1):
            if i + j > min(n, k):
                continue
            now_k = k - i - j
            if now_k < 0:
                continue
            q = []
            for l in range(1, i + 1):
                q.append(v[l])
            for l in range(1, j + 1):
                q.append(reversed_v[l])
            q.sort()
            for l in range(len(q)):
                if q[l] < 0 and now_k > 0:
                    q[l] = 0
                    now_k -= 1
            ans = max(ans, sum(q))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9016
package main

import (
	"bufio"
	"container/list"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100000-1), 100000-1)
}

func main() {
	s := scanString()
	ls := list.New()
	for _, r := range s {
		ls.PushBack(string(r))
	}
	rv := false
	q := scanInt()
	for i := 0; i < q; i++ {
		t := scanInt()
		switch t {
		case 1:
			rv = !rv
		case 2:
			f, c := scanInt(), scanString()
			if rv {
				f = 3 - f
			}
			if f == 1 {
				ls.PushFront(c)
			} else {
				ls.PushBack(c)
			}
		}
	}

	var wr = bufio.NewWriter(os.Stdout)
	if rv {
		for e := ls.Back(); e != nil; e = e.Prev() {
			wr.WriteString(e.Value.(string))
		}
	} else {

		for e := ls.Front(); e != nil; e = e.Next() {
			wr.WriteString(e.Value.(string))
		}
	}
	wr.WriteString("\n")
	wr.Flush()
}


Measured memory_bytes: 21760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EDGE
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskAtcoderC solver = new TaskAtcoderC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskAtcoderC {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();

            int ar[] = in.nextIntArray(n);
            int mean = Integer.MAX_VALUE;
            for (int k = 1; k < 100; k++) {


                int sum = 0;
                for (int i = 0; i < n; i++) {
                    sum = sum + (ar[i] - k) * (ar[i] - k);
                }
                mean = Math.min(sum, mean);
            }
            out.println(mean);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 22612
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = 0

s = input()
t = input()
l = len(t)
if l == 1:
    if t in s: ans = 0
    else: ans = 1
else:
    mx = 0
    for idx, _ in enumerate(s[:-(l-1)]):
        word = ''
        for i in range(l):
            word += s[idx+i]
        x = 0
        for a, b in zip(word, t):
            if a == b: x += 1
        if x > mx: mx = x

    ans = l - mx

print(ans)

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

int n,ans;
double t,a,last;
double AAA(double a){if(a<0)return -a;return a;}
int main(){
    scanf("%d%lf%lf",&n,&t,&a);
    for(int i=1;i<=n;i++){
        double db;
        scanf("%lf",&db);
        if(AAA(t-0.006*db-a)<AAA(t-0.006*last-a)||!ans)ans=i,last=db;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256