akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define MAXN 1000010
#define INF 0x3f3f3f3f
using namespace std;
int a[MAXN];
int main(){
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int maxans=-INF;
		int minans=a[0];
		for(int i=1;i<n;i++){
			maxans=max(maxans,a[i]-minans);
			minans=min(minans,a[i]);
		}
		cout<<maxans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3888
//Contribted By - Rahul Roy
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	
	static long M = (long)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();
		long h = sc.nextLong();
		
		long a =  sc.nextLong();
		long sum = (h/a) + (h%a==0 ? 0 : 1);
		System.out.println(sum);
	}
	
	public static class pair{
		int x =0;
		int y=0;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			if(o1.x==o2.x)
				return o1.y-o2.y;
			return o1.x-o2.x;
		}
	}

	
	
	
	
		
		
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;


		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
}
/* class Triplet{
	int threeSumClosest(ArrayList<Integer> arr, int target) {
        int flag=0,n = arr.size();
        int res=0;
        
        Collections.sort(arr);
		
        for(int i = 0 ; i < n-2 ; ++ i ) {  
            
            int j = i+1, k = n-1;
            
            while(j<k) {
                int sum=arr.get(i)+arr.get(j)+arr.get(k);   // get the sum of the triplet
                
                if(flag==0){  // if its your 1st triplet updated res
                    res=sum;
                    flag=1;
                }
                
                if(Math.abs(sum-target)<=Math.abs(res-target)) {   // compare the difference if sum is closer to target then res
                    if(Math.abs(sum-target)==Math.abs(res-target)){
                        if(res<sum)
                            res=sum;
                    }
                    else
                        res=sum;
                }
                
                if(target>sum)  // if sum is smaller than target
                    j++;
                else        // if sum is greater than target
                    k--;
            }
        }
        return res; // return the answer 
    }
} */

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define repj(j, a, b) for (ll j = a; j < b; j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define mod 1000000007
#define lim 100001
#define pi 3.14159265

using namespace std;
ll factorial(ll n) { return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); }
int max3(int a, int b, int c) { return max(a, max(c, b)); }
int gcd(int a, int b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
ll power(ll a, ll n)
{
    if (n == 1)
        return a;
    else if (n == 0)
        return 1;
    else
    {
        ll r = power(a, n / 2);
        if (n % 2 == 0)
            return r * r;
        else
            return r * a * r;
    }
}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector<vector<int>> &v, vi &check, int start)
{
    check[start - 1] = 1;
    repj(j, 0, v[start - 1].size())
    {
        if (!check[v[start - 1][j] - 1])
        {
            dfs(v, check, v[start - 1][j]);
        }
    }
}
bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
//works under 2 till 1e12

double newPrecision(double n)
{
    return floor(pow(10, 250) * n) / pow(10, 250);
}

ll f( ll arr[], ll rec[], ll pos, ll n, ll k){
    if(pos>=(n-1 -k))
        return abs(arr[n-1] - arr[pos]);
    if(rec[pos]!=-1)
        return rec[pos];
    ll num = INT_MAX;
    ll jump;
    for (int i = 1; i < k + 1; i++)
    {
        ll loc = abs(arr[pos] - arr[pos + i]) + f(arr, rec, pos + i, n, k);
        if(loc<=num){
            jump = i;
            num = loc;
        }
    }
    return rec[pos] = num;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    ll k;
    cin >> k;
    ll arr[t];
    for (ll i = 0; i < t; i++)
    {
        cin >> arr[i];
    }
    ll rec[t];
    memset(rec, -1, sizeof(rec));
    cout << f(arr,rec,0,t,k);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin>>s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
from typing import List, Union


class Dijkstra:
  """Dijkstra Algorithm returns the shortest path at graph.

  Args:
    edge (List[List[int]]): adjacent list
  """
  def __init__(self, edge):
    self.edge = edge
    n = len(edge)
    self.prev = list(range(n))
    self.dist = [n] * n

  def fit(self):
    self.dist[0] = 0
    queue = deque([0])
    while queue:
      vertex = queue.popleft()
      for destination in self.edge[vertex]:
        tmp = self.dist[vertex] + 1
        if self.dist[destination] > tmp:
          self.dist[destination] = tmp
          self.prev[destination] = vertex
          queue.append(destination)

  def get_path(self, vertex: int) -> List[int]:
    previous = self.prev[vertex]
    path = [vertex]
    while vertex != previous:
      vertex = previous
      previous = self.prev[vertex]
      path.append(vertex)
    return path[::-1]
  

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
dijkstra = Dijkstra(edge)
dijkstra.fit()
print('Yes')
for previous in dijkstra.prev[1:]:
  print(previous + 1)

Measured memory_bytes: 38692
#include <iostream>

using namespace std;

struct Node{
    int key;
    Node *p, *l, *r;
};

Node *root, *NIL;

void Insert(int key){
    Node *x, *y, *z;

    z = new Node;
    z->key = key;
    z->l = NIL;
    z->r = NIL;

    x = root;
    y = NIL;

    while(x!=NIL){
        y = x;
        if(x->key>z->key){
            x = x->l;
        }
        else{
            x = x->r;
        }
    }

    if(y==NIL) {root = z;}
    else if(y->key>z->key) {y->l = z;}
    else if(y->key<=z->key) {y->r = z;}
}

void PreOrder(Node *nk){
    if(nk==NIL) return;
    //cout << nk->key << " ";
    cout << " " << nk->key;
    PreOrder(nk->l);
    PreOrder(nk->r);
}

void InOrder(Node *nk){
    if(nk==NIL) return;
    InOrder(nk->l);
    //cout << nk->key << " ";
    cout << " " << nk->key;
    InOrder(nk->r);
}

int main(){
    int n, num;
    string cmd;
    cin >> n;

    for(int i=0;i<n;i++){
        cin >> cmd;
        if(cmd[0]=='i'){
            cin >> num;
            Insert(num);
        }
        else{
            InOrder(root);
            cout << endl;
            PreOrder(root);
            cout << endl;
        }
    }
    return 0;
}




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

int main()
{
    string S;
    int ans = 0;

    cin >> S;

    for(int i = 0; i < S.size(); i++) {
        if(i < (S.size() - 1) / 2 + 1) ans -= S[i] == 'p';
        else ans += S[i] == 'g';
    }

    cout << ans << endl;

    return (0);
}


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

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        v: [usize; n],
    }
    let mut odd_nums = HashMap::new();
    let mut even_nums = HashMap::new();
    for i in 0..n {
        if i % 2 == 0 {
            *even_nums.entry(v[i]).or_insert(0) += 1
        } else {
            *odd_nums.entry(v[i]).or_insert(0) += 1
        }
    }
    let mut odd_nums = odd_nums.iter().collect::<Vec<_>>();
    odd_nums.sort_by_key(|&(_, count)| count);
    odd_nums.reverse();
    let mut even_nums = even_nums.iter().collect::<Vec<_>>();
    even_nums.sort_by_key(|&(_, count)| count);
    even_nums.reverse();

    if odd_nums[0].0 == even_nums[0].0 {
        if odd_nums.len() == 1 {
            println!("{}", n - even_nums[0].1);
            return;
        } else if even_nums.len() == 1 {
            println!("{}", n - odd_nums[0].1);
            return;
        } else if odd_nums[1].1 < even_nums[1].1 {
            println!("{}", n - odd_nums[0].1 - even_nums[1].1);
        } else {
            println!("{}", n - even_nums[0].1 - odd_nums[1].1);
        }
    } else {
        println!("{}", n - odd_nums[0].1 - even_nums[0].1);
    }
}


Measured memory_bytes: 12540
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	int sum = 0;
	bitset<4000001> B(1);
	for(int i=0;i<N;i++){
		int a = rei();
		B = B | (B << a);
		sum += a;
	}
	for(int i=(sum+1)/2;;i++){
		if(B[i]){
			cout << i << endl;
			return;
		}
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 1920
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = ReadLine();
            var N = S.Length;
            var aCnt = 0L;
            var ans = 0L;
            for(var i=0;i<N;++i)
            {
                if (S[i] == 'A')
                    ++aCnt;
                else if (i < N - 1 && S.Substring(i, 2) == "BC")
                {
                    ans += aCnt;
                    ++i;
                }
                else
                    aCnt = 0;
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 15288
def main():
    n = int(input())
    s = 0

    for i in range(1, n + 1, 2):
        if num_factor(i) == 8:
            s += 1
    print(s)


def num_factor(n):
    if n == 1:
        return 1

    s = 2
    i = 2

    while i * i <= n:
        if n % i == 0:
            if i * i != n:
                s += 2
            else:
                s += 1
        i += 1
    return s

main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <ostream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template <typename T, typename U>
std::ostream& operator << (std::ostream& out, std::pair<T, U> p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T>
std::ostream& operator << (std::ostream& out, std::vector<T> v) {
  out << "[";
  for (int i = 0; i < v.size(); ++i) {
    out << v[i] << (i == (v.size() - 1) ? "" : ", ");
  }
  out << "]";
  return out;
}

int main() {
  int N, ans = 0;

  cin >> N;

  std::unordered_map<std::string, bool> mp;

  for (int t = 1; t < 9; ++t) {
    for (int f = 1; f < 9; ++f) {
      for (int e = 1; e < 9; ++e) {
        std::string s = std::string(t, '3') + std::string(f, '5') + std::string(e, '7');
        std::vector<std::pair<int, char> > v(t + f + e);
        for (int k = 0; k < t + f + e; ++k) {
          v[k] = {k, s[k]};
        }

        if (t + f + e > 9 or std::stoi(s) > N) continue;

        do {
          s = "";
          for (int k = 0; k < t + f + e; ++k) {
            s += v[k].second;
          }

          if (std::stoi(s) > N or mp[s]) continue;

          mp[s] = true;

          ans++;
        } while (std::next_permutation(v.begin(), v.end()));
        
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3200
N = int(input())

A_dict = {}
for a in input().split():
    a = int(a)
    if a in A_dict:
        A_dict[a] += 1
    else:
        A_dict[a] = 1

total = 0
for key in A_dict:
    total += key * A_dict[key]

Q = int(input())

for _ in range(Q):
    B, C = [int(n) for n in input().split()]
    if B in A_dict:
        val_B = A_dict.pop(B)
        if C in A_dict:
            A_dict[C] += val_B
        else:
            A_dict[C] = val_B
        total += (C - B) * val_B
    print(total)

Measured memory_bytes: 21676
#include <stdio.h>
 
int main() {
	int n;
	int i;
	int cnt;
	char s[100][3];
	int a[100];
 
	while(scanf("%d",&n),n){
		for(i = 0;i < n;i++){
			scanf("%s",s[i]);
		}
		cnt = 0;
 
		for(i = 0;i < n;i++){
			switch(s[i][0]){
				case 'l':
					if(s[i][1] == 'u'){
						a[i] = 0;
					}else if(s[i][1] == 'd'){
						a[i] = 2;
					}
					break;
				case 'r':
					if(s[i][1] == 'u'){
						a[i] = 1;
					}else if(s[i][1] == 'd'){
						a[i] = 3;
					}
					break;
			}
		}

		for(i = 0;i < n-1;i++){
			if(a[i] == 0 && a[i+1] == 1 || a[i] == 1 && a[i+1] == 0
			 ||a[i] == 2 && a[i+1] == 3 || a[i] == 3 && a[i+1] == 2)cnt++;
		}
		
		printf("%d\n",cnt);
	}
	return 0;
}

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

int main()
{
    long long n;
    int k;
    cin >> n >> k;
    long long ans = 1;
    long long int t = k;
    while(t <= n)
    {
        ++ans;
        t *= k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mi map<int,int>
#define mii map<pii,int>
const int N=(1e5+1);//mod=(1e9)+7;
int n,k,d;//
int a[N],dp[N];
string s;
int flag=1;
int rec(int x)
{
    if(x>=n-1)return 0;
    if(dp[x]!=-1)return dp[x];
    int ans=INT_MAX;
    for(int i=1;i<=k;i++)
    {
        if(x+i<n)
        ans=min(ans,rec(x+i)+abs(a[x+i]-a[x]));
    }
    dp[x]=ans;
    return dp[x];
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i]=-1;
    }
    cout<<rec(0)<<endl;
}
/*
test cases:-
100000000000000012 1000000000032
*/

Measured memory_bytes: 5760
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <deque>
#include <vector>

auto main() -> int {
  std::string S;
  std::cin >> S;

  const auto y = std::stoi(S.substr(0, 4));
  const auto m = std::stoi(S.substr(5, 2));
  const auto d = std::stoi(S.substr(8, 2));

  if (y >= 2019) {
    if (m > 4) {
      std::cout << "TBD\n";
    } else {
      std::cout << "Heisei\n";
    }
  } else {
    std::cout << "Heisei\n";
  }
}


Measured memory_bytes: 256
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3941667
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

LL a[18][18];
LL G[(1 << 17)];
LL dp[(1 << 17)];

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) scanf("%lld", &a[i][j]);
    
    // 2. dp更新.
    for(int i = 0; i < (1 << N); i++){
        for(int j = 0; j < N; j++){
            for(int k = j + 1; k < N; k++){
                if((i & (1 << j)) && (i & (1 << k))) G[i] += a[j][k];
            }
        }
    }
    dp[0] = 0;
    for(int i = 1; i < (1 << N); i++){
        dp[i] = -LL(1e18);
        for(int j = i;; j = (j - 1) & i){
            dp[i] = max(dp[i], G[j] + dp[i ^ j]);
            if(j == 0) break;
        }
    }
    // for(int i = 0; i < (1 << N); i++) printf("%lld ", G[i]);
    // printf("\n");
    // for(int i = 0; i < (1 << N); i++) printf("%lld ", dp[i]);
    // printf("\n");
    
    // 3. 出力.
    printf("%lld\n", dp[(1 << N) - 1]);
    return 0;
}

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

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

using namespace std;


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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
sum_rain = sum(a) // 2

rest_rain = 0
for i in range(1, n, 2):
    rest_rain += a[i]
first_ans = (sum_rain - rest_rain) * 2

res = []

res.append(first_ans)
prev_ans = first_ans

for i in range(n - 1):
    ans = (a[i] - prev_ans // 2) * 2
    res.append(ans)
    prev_ans = ans

print(*res)


Measured memory_bytes: 14616
import sys
from collections import deque
readline = sys.stdin.readline

inf = 10**9+7
direc = [(0, 1), (1, 0), (-1, 0), (0, -1)]
def bfs(h, w):
    Q = deque([(h, w)])
    used = set([(h, w)])
    dist = [[inf]*(W+2) for _ in range(H+2)] 
    dist[h][w] = 0
    while Q:
        nx, ny = Q.pop()
        for dx, dy in direc:
            if G[nx+dx][ny+dy]:
                continue
            if (nx+dx, ny+dy) in used:
                continue
            used.add((nx+dx, ny+dy))
            dist[nx+dx][ny+dy] = min(dist[nx+dx][ny+dy], 1+dist[nx][ny])
            Q.appendleft((nx+dx, ny+dy))
    res = 0
    for i in range(H+2):
        for j in range(W+2):
            if dist[i][j] < inf:
                res = max(res, dist[i][j])
    return res
H, W = map(int, readline().split())
X = (H+2)*(W+2)
G = [[1]*(W+2)] + [[1] + [1 if s == '#' else 0 for s in readline().strip()] + [1] for _ in range(H)] + [[1]*(W+2)]
ans = 0
for h in range(1, H+1):
    for w in range(1, W+1):
        if not G[h][w]:
            ans = max(ans, bfs(h, w))
print(ans)


Measured memory_bytes: 47964
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int X; cin>>X;
    int ans=1;
    for(int b=2;b<=X;b++){
        for(int p=2;;p++){
            int k=pow(b,p);
            if(k<=X){
                ans=max(ans,k);
            }
            else break;
        }
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
d[1<<19];m[1<<19];a[1<<19];
i;e;Q;j;
main(N){
for(;i<*d+2;i>1?m[i]=Q=2*Q>e?abs(Q-e):Q:i?Q=e:0,d[i++]=e)scanf("%d",&e);
for(;i-->2;N+=d[i+1]<2*N?d[i+1]:0)a[i]=m[i]<N;
for(a[1]=d[1]<N;~scanf("%d",&e);)j++&&puts(a[e]?"NO":"YES");
}
////////////////////////////////////////////////////////////////////////////////

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

int main()
{
    string s;
    cin >> s;
    if (s[s.size() - 1] == 's')
    {
        s = s + "es";
    }
    else
    {
        s = s + "s";
    }

    cout << s;
}

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

int main(){
    while(1){
        int k, a, sum = 0;
        cin >> k;
        if(k == 0)break;
        for(int i = 0; i < k * (k - 1) / 2; i++){
            cin >> a;
            sum += a;
        }
        cout << sum / (k - 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int D, G;
  cin >> D >> G;

  vector<pair<int,int>> pc(D), pc_org;
  REP(i,D) cin >> pc[i].fi >> pc[i].se;
  pc_org = pc;

  int ans = MAX;
  for (int bit = 0; bit < (1<<D); bit++) {
    int g = G;
    int n = 0;
    pc = pc_org;
    //cout << "new bit: " << bitset<2>(bit) << endl;
    //i番目のbitが立ってるとき、100(i+1)点問題を制覇するものとする。
    for (int i = 0; i < D; i++) {
      if (bit & (1<<i)) {
        n += pc[i].fi;
        g -= (100*(i+1)*pc[i].fi) + pc[i].se;
        pc[i].fi = 0;
      }
    }
    //completeしていない問題で、completeしないように最大の点数の問題から解いていく。
    for (int i = D-1; i>=0; i--) {
      if (g <= 0) {
        break;
      }
      while (pc[i].fi > 1 && g > 0) {
        g -= 100*(i+1);
        n++;
        pc[i].fi--;
      }
    }

    if (g<=0) {
      ans = min(ans, n);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i=0,c=0;
  string s;
  cin>>s;
   while(i!=s.size()){
    if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r')i+=6;
    else if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e')i+=5;
else if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'&&s[i+6]=='r'&&s[i+7]=='a')i+=5;
else if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'&&s[i+6]=='r')i+=7;
else if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m')i+=5;
else {c++;break;}
    }
if(c)cout<<"NO"<<endl;
else cout<<"YES"<<endl;

  return 0;
}

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

#define YES(condition) if(condition){ cout << "YES" << endl; }else{ cout << "NO" << endl; }
#define Yes(condition) if(condition){ cout << "Yes" << endl; }else{ cout << "No" << endl; }
#define POSS(condition) if(condition){ cout << "POSSIBLE" << endl; }else{ cout << "IMPOSSIBLE" << endl; }
#define Poss(condition) if(condition){ cout << "Possible" << endl; }else{ cout << "Impossible" << endl; }
long power(long base, long exponent, long mod){ if(exponent % 2){ return power(base, exponent - 1, mod) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2, mod); return root_ans * root_ans % mod; }else{ return 1; }}

int main(){
    int N;
    cin >> N;
    int nums[N];
    int nums_sorted[N];
    for(int i = 0; i < N; i++){
        cin >> nums[i];
        nums_sorted[i] = nums[i];
    }
    sort(nums_sorted, nums_sorted + N);
    for(int i = 0; i < N; i++){
        if(nums[i] >= nums_sorted[N / 2]){
            cout << nums_sorted[(N - 1) / 2] << endl;
        }else{
            cout << nums_sorted[N / 2] << endl;
        }
    }
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
//#define f first
//#define s second
//#define mp make_pair
#define gg return 0;
#define pii pair < int, int>
 
using namespace std;
 
const int maxn = 132675;
const int INF = (int)1e9;
 
ll a,b[maxn],c,d,cnt,e[(int)2e3 + 1][(int)2e3 + 1],cost[maxn],tout[maxn],mn = INF,mx = -INF,l,r;
 
ll x[maxn],y[maxn],x2[maxn],y2[maxn];
 
bool u[maxn], m, f;
 
vector <int> v;
 /*
void forn( int s, int f, int inter){
	for(int i = s; i <= f; i += inter){
		b[i] = i;
	}
}
*/ 
ll ans;
 
ll pref;
 
//vector <int> g[maxn],d[maxn];
 
ll lvlc,lvl[maxn];
/*
void dfs(int v){
	lvlc++;
	lvl[v] = lvlc;
	d[lvl[v]].pb(v);
	u[v] = 1;
	for(int i = 0; i < g[v].size(); ++i){
		int to = g[v][i];
		if(!u[to]){
			dfs(to);
		}
	}
	lvlc--;
}*/

map <int, int> col; 
 
char ch;

string s; 

int main()
{
	cin >> s;
	for(int i = s.size() - 2; i >= 0; --i){
		if(s[i] != s[i + 1]){
			cnt++;
			s[i + 1] = s[i];
		}
	}
	cout << cnt;
	gg
}

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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long[] nr = Console.ReadLine().Split().Select(long.Parse).ToArray();

        //abcがすべて異なる場合
        if (nr[0] <= 10)
        {
            Console.WriteLine((100*(10-nr[0]))+nr[1]);
        }
        else
        {
            Console.WriteLine(nr[1]);
        }
    }
}

Measured memory_bytes: 13268
while 1:
 n=int(input())
 if n==0:break;
 a=[list(map(int,input().split()))for _ in[0]*n]
 for r in a:
  for s in r:print(f"{s:5}",end='')
  print(f"{sum(r):5}")
 for c in zip(*a):print(f"{sum(c):5}",end='')
 print(f"{sum([sum(r)for r in a]):5}")


Measured memory_bytes: 5648
n=int(input())
ans=chk=0
d=set()
l=[int(i) for i in input().split()]
for i in range(n):
    a,b=min(i+1,l[i]),max(i+1,l[i])
    if (a,b) in d:
        ans+=1
    else:
        d.add((a,b))

print(ans)

Measured memory_bytes: 59760
import java.util.Scanner;

public class Main {
	
	public static String properties(int[] ls, int n) {
		
		if(n == 1) {
			if(ls.length == 1) {
				return null;
			}
			else if(ls.length == 2) {
				return ", left key = " + ls[1];
			}
			else {
				return ", left key = " + ls[1] + ", right key = " + ls[2];
			}
		}
		else {
			
			if(ls.length > n*2) {
				return ", parent key = " + ls[(int) Math.floor(n/2)-1] + ", left key = " + ls[n*2-1] + ", right key = " + ls[n*2];
			}
			else if(ls.length == n*2) {
				return ", parent key = " + ls[(int) Math.floor(n/2)-1] + ", left key = " + ls[n*2-1];
			}
			else {
				return ", parent key = " + ls[(int) Math.floor(n/2)-1];
			}
			
		}
	}

	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int length = in.nextInt();
		int[] ls = new int[length];
		for(int i = 0; i < length; i++) {
			ls[i] = in.nextInt();
		}
		
		for(int j = 1; j <= length; j++) {
			System.out.println("node " + j + ": key = " + ls[j-1] + properties(ls, j) + ", ");
		}
		
		in.close();
		
	}
}


Measured memory_bytes: 27708
//#define _GLIBCXX_DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long double ld;

#define mk make_pair
#define inb push_back
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define sqr(x) (x) * (x)
#define TIME 1.0 * clock() / CLOCKS_PER_SEC
#define y1 AYDARBOG
//continue break pop_back return

int solve();

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
#define TASK "hypercube"
#ifndef _DEBUG
	//freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
	solve();
#ifdef _DEBUG
	fprintf(stderr, "\nTIME: %.3f\n", TIME);
#endif
}

const int BUFSZ = (int)1e5 + 7;
char buf[BUFSZ];
string get_str()
{
	scanf(" %s", buf);
	return string(buf);
}

int solve()
{
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	vector<vi> dp(f + 1, vi(f + 1));
	dp[0][0] = 1;
	for (int m = 1; m <= f; ++m)
	{
		for (int s = 0; s <= m; ++s)
		{
			int w = m - s;
			//a
			{
				if (w >= 100 * a)
				{
					dp[m][s] |= dp[m - 100 * a][s];
				}
			}
			//b
			{
				if (w >= 100 * b)
				{
					dp[m][s] |= dp[m - 100 * b][s];
				}
			}
			//c
			{
				if (s >= c)
				{
					dp[m][s] |= dp[m - c][s - c];
				}
			}
			//d
			{
				if (s >= d)
				{
					dp[m][s] |= dp[m - d][s - d];
				}
			}
		}
	}
	int mans = 1, sans = 0;
	for (int m = 1; m <= f; ++m)
	{
		for (int s = 0; s <= m; ++s)
		{
			if (!dp[m][s])
				continue;
			int w = m - s;
			if (w / 100 * e < s)
				continue;
			if (100.0 * s / m >= 100.0 * sans / mans)
			{
				sans = s;
				mans = m;
			}
		}
	}
	printf("%d %d\n", mans, sans);
	return 0;
}

Measured memory_bytes: 32896
# coding: utf-8
# Your code here!
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
c=0
c1=0
c2=0
for i in range(n):
    if p[i]<=a:
        c+=1
    elif a<p[i]<=b:
        c1+=1
    else:
        c2+=1
print(min(c,c1,c2))

Measured memory_bytes: 3064
#!/usr/bin/env python3
import numpy as np
stdin = open(0)

A = np.fromstring(stdin.read(),np.int64,sep= ' ')[1:]
A=A[A%2 ==0]
if np.all((A % 3 == 0)|(A % 5 ==0)):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 12488
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 10;
int n;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n;
	vector<VI> all;
	
	if (n % 2 == 0)
	{
		FOR(i, 1, n / 2 + 1)
			all.PB({i, n + 1 - i});
	}
	else
	{
		FOR(i, 1, n / 2 + 1)
			all.PB({i, n - i});
		all.PB({n});
	}	
	
	vector<PII> e;
	FOR(i, 0, SZ(all))
		for(auto x: all[i])
			FOR(j, i + 1, SZ(all))
				for(auto y: all[j])
					e.PB({x, y});
	
	cout << SZ(e) << endl;
	for(auto i: e)
		cout << i.X << ' ' << i.Y << endl;
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        final int N = Integer.parseInt(sc.next());
        Set<String> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
            set.add(sc.next());
        }
        out.println(set.size() == N ? "YES" : "NO");
        
        out.flush();
    }
}

Measured memory_bytes: 76624
n, m = map(int, input().split())
z = 10**9 + 7
ans = 1

if abs(n-m) > 1:
    print(0)
    exit()
else:
    for x in range(1, n+1):
        ans *= x
        ans %= z
    for y in range(1, m+1):
        ans *= y
        ans %= z

if n == m:
    ans *= 2
    ans %= z

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M (ll)1000000007
#define MM (ll)1e8
#define INF (ll)1e18
#define arep(i, x, n) for (long long i = x; i < n; i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
int main() {
    ll n;
    cin >> n;

    cout << 8 - ( n - 400)/200 << endl;
}

Measured memory_bytes: 3632
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char rev[100001];
int starta, startb, enda, endb,ab;


unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい
long long int L[100003], R[100003],maxL=0,minR=9999999;
int main()
{
	cin >> a >> b;
	rep(i, b) {
		cin >> L[i] >> R[i];
		if (L[i] > maxL) {
			maxL = L[i];
		}
		if (R[i] < minR) {
			minR = R[i];
		}
	}
	if (minR - maxL + 1 > 0) {
		cout << minR - maxL + 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%lf\n", sqrt(pow(x1-x2, 2) + pow(y1-y2, 2)));
    return 0;
}


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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector <ll> v;
typedef vector <v> vv;
typedef vector <ld> vld;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef pair <ll, ll> pll;
typedef vector <pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector <T> ga(ll n, bool oneIndexed = false) {
    vector <T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector < T, A >
const &a,
ll begin = 0, ll
end = -1
) {
if (end == -1)
end = sz(a) - 1;
for (
ll i = begin;
i <=
end;
i++) {
cout << a[i] << " ";
}
cout <<
endl;
}

void solve() {
    map <ll, ll> freq;
    ll n;
    cin >> n;
    v a = ga(n);
    for (auto x : a)freq[x]++;
    ll ans = 0;
    for (auto x : freq) {
        ans += x.second * (x.second - 1) / 2;
    }

    for (auto x : a) {
        ll a2 = ans - freq[x] * (freq[x] - 1) / 2;
        a2 = a2 + (freq[x] - 1) * (freq[x] - 2) / 2;
        cout << a2 << endl;
    }
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			List<Integer> x = new ArrayList<>();
			List<Integer> y = new ArrayList<>();

			x.add(0);
			y.add(0);

			for (int i = 0; i < n; i++) {
				x.add(in.nextInt());
				y.add(in.nextInt());
			}

			Collections.sort(x, Comparator.reverseOrder());
			Collections.sort(y);

			long ans = 0;
			for (int i = 0; i < n+1; i++) {
				if (x.get(i) > y.get(i)) {
					ans += 2 * (x.get(i) - y.get(i));
				}
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 45204
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> vec(n);
    int four=0,two=0,zero=0;
    rep(i,n){
        cin >> vec[i];
        if (vec[i]%4==0){
            four++;
        }else if(vec[i]%2==0){
            two++;
        }else{
            zero++;
        }
    }
    if (two==0){
        if (zero <= four+1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    } else {
        if (zero<=four){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }


        
}

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i=0;i<N;i++){
    cin >> h[i];
  }
  vector<int> dp(N);
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for (int i=2;i<N;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, q; cin >> a >> b >> q;
    vector<ll> s(a);
    vector<ll> t(b);
    s.push_back(LLINF);
    t.push_back(LLINF);
    s.push_back(-LLINF);
    t.push_back(-LLINF);
    rep(i,a) cin >> s[i];
    rep(i,b) cin >> t[i];
    sort(ALL(s));
    sort(ALL(t));
    rep(i,q) {
        ll ans = LLINF;
        ll x; cin >> x;
        ll s1 = *lower_bound(ALL(s),x);
        ll s2 = *(--lower_bound(ALL(s),x));
        ll t1 = *lower_bound(ALL(t),x);
        ll t2 = *(--lower_bound(ALL(t),x));
        ans = min(ans,abs(s1-x+abs(s1-t1)));
        ans = min(ans,abs(s1-x+abs(s1-t2)));
        ans = min(ans,abs(x-s2+abs(s2-t1)));
        ans = min(ans,abs(x-s2+abs(s2-t2)));
        ans = min(ans,abs(t1-x+abs(t1-s1)));
        ans = min(ans,abs(t1-x+abs(t1-s2)));
        ans = min(ans,abs(x-t2+abs(t2-s1)));
        ans = min(ans,abs(x-t2+abs(t2-s2)));
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
    //
    int row1, col1, row2, col2;

    cin >> row1 >> row2;

    col1 = row1;
    col2 = row2;

    vector<string> vec(row1);
    vector<string> vec2(row2);

    for (int i = 0; i < row1; i++) cin >> vec.at(i);
    for (int i = 0; i < row2; i++) cin >> vec2.at(i);

    for (int i = 0; i <= row1 - row2; i++) {
        for (int j = 0; j <= col1 - col2; j++) {
            bool okFlg = true;
            for (int k = 0; k < row2; k++) {
                string tmp1, tmp2;
                tmp1 = vec.at(i+k);
                tmp2 = vec2.at(k);
                //cout << tmp1.substr(j, row2) << ":::" << tmp2 << endl;
                if (tmp1.substr(j, row2) != tmp2) {
                    okFlg = false;
                    break;
                }
            }

            if (okFlg == true) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    //
}


Measured memory_bytes: 3628
N = int(input()) #1行目のNを取得する
s = []
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(max_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)

Measured memory_bytes: 12520
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int N;
int a[10005]; 

int main() {
    scanf("%d", &N);
    for (int j = 0; j < N; ++j) {
        scanf("%d", a+j);
    }
    sort(a, a+N);

    stringstream ss;
    int z;

    vector<int> c;
    for (int j = 0; j < min(N, 4); ++j) {
        for (int k = 0; k < min(N, 4); ++k) {
            if (j == k) { continue; }
            ss.clear();
            ss << a[j];
            ss << a[k];
            ss >> z;
            c.push_back(z);
        }
    }

    sort(begin(c), end(c));
    cout << c[2] << endl;
    
    return 0;
}

Measured memory_bytes: 3236