akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

class Main implements Runnable {
	public static final long MOD = 1000000007;
	private final FastScanner sc;
	private final PrintWriter out;
	int n;
	int sum;
	

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16L * 1024 * 1024).start();
	}

	Main() {
		sc = new FastScanner();
		out = new PrintWriter(System.out);
	}

	private void init() throws Exception {
		n = sc.nextInt();
		for(int i=0;i<n;i++){
			sum += sc.nextInt();
		}
	}

	private void solve() throws Exception{
		if(sum%2==0){
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	/*
	 * private void exit(int status){ out.flush(); out.close();
	 * System.exit(status); } //
	 */
	public void run() {
		try {
			init();
			solve();
		} catch (Exception e) {
			e.printStackTrace();
		}
		out.flush();
		out.close();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean read() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
			return true;
		}
	}

	private boolean hasNext() {
		while (read() && !isVisibleChar(buffer[ptr]))
			ptr++;
		return read();
	}

	private int getNextChar() {
		if (read()) {
			ptr++;
			return buffer[ptr - 1];
		} else {
			return -1;
		}
	}

	private static boolean isVisibleChar(int code) {
		return code >= 33 && code <= 126;
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = getNextChar();
		while (isVisibleChar(b)) {
			sb.appendCodePoint(b);
			b = getNextChar();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean sign = true;
		int b = getNextChar();
		if (b == '-') {
			sign = false;
			b = getNextChar();
		}
		if (b < '0' || b > '9') {
			throw new NumberFormatException();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isVisibleChar(b)) {
				return sign ? n : -n;
			} else {
				throw new NumberFormatException();
			}
			b = getNextChar();
		}
	}

	public int nextInt() {
		long n = nextLong();
		if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) n;
	}

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

	public void close() {
		try {
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class IntQueue {
	protected int[] a;
	protected int head, tail;

	public IntQueue(int max) {
		a = new int[max];
	}

	public void offer(int x) {
		a[tail++] = x;
	}

	public int poll() {
		return a[head++];
	}

	public int peek() {
		return a[head];
	}
}


Measured memory_bytes: 26872
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(a: int, s: str):
    if a >= 3200:
        print(s)
    else:
        print('red')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    solve(a, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5732
# Stable sort
class Card:
    def __init__(self, c):
        self.suit = c[0]
        self.value = int(c[1])
def toi(c):
    return c.value
def toStr(c):
    return c.suit + str(c.value)
def bubble_sort(C,N):
    for i in range(0, N):
        for j in range(N-1,i,-1):
            if C[j].value < C[j-1].value:
                tmp = C[j]
                C[j] = C[j-1]
                C[j-1] = tmp
    return (C,True)
def selection_sort(C,N):
    st = True
    for i in range(0,N):
        minj = i
        for j in range(i,N):
            # ????????§??????????´??????????????????°??????????????§?????????????????????????????????
            if C[j].value < C[minj].value:
                minj = j
        if not i == minj:
            if (list(map(toi, C[i:]))).count(C[i].value) > 1: st = False
            tmp = C[i]
            C[i] = C[minj]
            C[minj] = tmp
    return (C, st)
N = int(input())
C = [Card(i) for i in input().split(' ')]
C1, isstable1 = bubble_sort(C[:],N)
print(' '.join(list(map(toStr, C1))))
if isstable1: print('Stable')
else: print('Not stable')
C2, isstable2 = selection_sort(C[:],N)
print(' '.join(list(map(toStr, C2))))
if isstable2: print('Stable')
else: print('Not stable')


Measured memory_bytes: 7840
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k;cin>>n>>k;
  int c,d,i,j,cnt=0;
  vector<int> a(n,0);
  for(i=0; i<n; ++i){
    cin>>d;
    for(j=0; j<d; ++j){ cin>>c;a[c-1]++;}
  }
  for(i=0; i<n; ++i)
    if(a[i]==0) ++cnt;
  cout<<cnt<<endl;
  return 0;
}
      


Measured memory_bytes: 3628
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

ans = deque()
ans.append(1)
seen = [False] * (N + 1)
seen[1] = True
v = 1
ok = True
while ok:
    ok = False
    for u in graph[v]:
        if not seen[u]:
            ans.append(u)
            seen[u] = True
            v = u
            ok = True
            break
v = 1
ok = True
while ok:
    ok = False
    for u in graph[v]:
        if not seen[u]:
            ans.appendleft(u)
            seen[u] = True
            v = u
            ok = True
            break
print(len(ans))
print(*ans)


Measured memory_bytes: 48480
a, b, c, x, y = map(int, input().split())
d = min(x, y)
e = max(x, y) - d
s = 0
if a + b <= 2 * c: s += d * (a + b)
else: s += d * c * 2
if x > y:
    if a <= 2 * c: s += e * a
    else: s += e * 2 * c
else:
    if b <= 2 * c: s += e * b
    else: s += e * 2 * c
print(s)


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

//素因数分解 o(√n)
map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

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

  int n;
  cin >> n;
  int ans = 0;

  if (n == 0) {
    cout << 0 << '\n';
    return 0;
  }

  map<int, int> mp = prime_factor(n);

  arep(e, mp) {
    int tmp = e.second;
    int tt = 1;
    while (tt <= tmp) {
      ++ans;
      tmp -= tt;
      ++tt;
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <cmath>
#include <complex>
#include <cfloat>

using namespace std;

#define INFD numeric_limits<double>::infinity()
#define INFL (int)1e8
#define INFLL (long long)1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

class LIS {
  vll result;
  vll id_result;
  int n;
public:
  LIS(vll a, bool non_decreasing_flag) {
    int n = a.size();
    vll record;
    vi id_record, parents(n, -1);
    Loop(i, n) {
      auto itr = non_decreasing_flag ? upper_bound(record.begin(), record.end(), a[i])
        : lower_bound(record.begin(), record.end(), a[i]);
      if (itr == record.end()) {
        record.push_back(a[i]);
        id_record.push_back(i);
        itr = record.end();
        itr--;
      }
      else {
        *itr = a[i];
        id_record[distance(record.begin(), itr)] = i;
      }
      if (itr != record.begin()) {
        parents[i] = id_record[distance(record.begin(), itr) - 1];
      }
    }
    result = {};
    id_result = {};
    int focus = id_record.back();
    do {
      id_result.push_back(focus);
      result.push_back(a[focus]);
      focus = parents[focus];
    } while (focus != -1);
    reverse(result.begin(), result.end());
    reverse(id_result.begin(), id_result.end());
  }
  vll get_lis() {
    return result;
  }
  vll get_lisid() {
    return id_result;
  }
  int get_lisn() {
    return result.size();
  }
};
/*
vll accumulate_interval(vector<pair<int, int>> a) {
  int n = a.size();
  int m = 0;
  Loop(i, n) m = max(m, a[i].second + 1);
  vi l(m), r(m);
  Loop(i, n) {
    l[a[i].first]++;
    r[a[i].second]++;
  }
  vll ret(m);
  Loop(i, m) {
    ret[i] += l[i];
    if (i >= 1) ret[i] += ret[i - 1];
    if (i < m - 1) ret[i + 1] -= r[i];
  }
  return ret;
}
*/

int main() {
  int n; cin >> n;
  vll a(n); Loop(i, n) cin >> a[i];
  LIS lis(a, false);
  cout << lis.get_lisn() << endl;
}


Measured memory_bytes: 8768
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <set>
#include <map>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;
const lli inf = 1e18;
typedef pair<lli, lli> pll;

int main(){
    int l,r;
    cin >> l >> r;
    
    vector<int> num;
    for(int i=l; i<=r; i++){
        num.push_back(i % 2019);
        if((int)num.size() >= 2019) break;
    }

    int n = num.size();
    int ans = 1e9;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            ans = min(ans, num[i]*num[j] %2019);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int x;
  cin>>x;
  int a[130];
  int j=0;
  for(int i=1;i<=32;i++){
     a[j]=i*i;
     a[j+1]=i*i*i;
     a[j+2]=i*i*i*i;
     a[j+3]=i*i*i*i*i;
     j=j+4;
  }
  sort(a,a+128);
  int f=1;
  for(int i=0;i<128;i++){
    if(a[i]>x){
    	f=a[i-1];
    	i=128;
    }
  }
  cout<<f;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

/*
  最長共通部分列　LCS
*/

void solve(){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();

  int dp[n+1][m+1];
  REP(i,n+1) dp[i][0] = 0;
  REP(j,m+1) dp[0][j] = 0;

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      if(s[i-1] == t[j-1]){
        dp[i][j] = max({dp[i-1][j], dp[i][j-1],dp[i-1][j-1]+1});
        //最後の項が，最長距離を更新できるかを決める．
      }
      else{
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }


  cout << dp[n][m]  << endl;
  return;

}

int main(){
  int t;
  cin >> t;
  REP(i,t) solve();

  return 0;
}



Measured memory_bytes: 7100
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N,vector<int>(M));
    for(int i = 0; i < M; i++) cin >> B[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++) cin >> A[i][j];
    }
    int ans = 0;
    int AC = 0;
    for(int i = 0; i < N; i++){
        AC = C;
        for(int j = 0; j < M; j++) AC += A[i][j]*B[j];
        if(AC > 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int e,small ;
	while(cin >> e && e>0){
		small = e;
		for(int z = 0;  z*z*z <= e; z++){
			for(int y = 0; y*y+z*z*z <= e; y++){
				int x = e-y*y-(z*z)*z;
				small=min(small, x+y+z);
			}
		}
	cout << small << endl ;
	}
return 0;
}

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

int main(){

    int N, M, X;
    int A[100];
    int ans_l, ans_r;
    int ans;

    cin >> N >> M >> X;
    for(int i = 0; i < M; i++){
        cin >> A[i];
    }
    
    ans_l = 0;
    ans_r = 0;
    for(int i = X-1; i >= 0; i--){
        for(int j = 0; j < M; j++){
            if(i != X && i != 0 && i != N && i == A[j]){
                ans_l += 1;
            }
        }
    }

    for(int i = X+1; i <= N; i++){
        for(int j = 0; j < M; j++){
            if(i != X && i != 0 && i != N && i == A[j]){
                ans_r += 1;
            }
        }
    }

    ans = min(ans_l, ans_r);

    cout << ans;

    return 0;
}


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

int main(){
  int x,y,tmp;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    if(x < y) swap(x,y);
    int cou = 0;
    while(y != 0){
      tmp = x % y;
      x = tmp;
      swap(x,y);
      cou++;
    }
    cout << x << " " << cou << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int min = 100;
  for(int i = 0; i < N; i++){
    int Ni;
    cin >> Ni;
    int count = 0;
    for(int j = 2; true; j *= 2)
      if(Ni % j == 0){
        count++;
      }else{
        break;
      }
    if(count < min){
      min = count;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,x;cin >> n >> x;
    int mini = 1001001001;
    int ans = n;
    rep(i,n){
        int m;cin >> m;
        mini = min(mini,m);
        x -= m;
    }
    ans += x/mini;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
count=0
i=0
while 1:
    if i>n-1:
        print(count)
        break
    b=a[i]%2
    if b!=0:
        i+=1
    elif b==0:
        a[i]/=2
        count+=1

Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
  char a;
  cin >> a;
  printf("%c\n", a+1);
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++) cin >> vec[i];
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    queue<int> q;

    ll ans = 0;
    for(int i=0;i<n;i++){
        if(i==0) q.push(vec[i]);
        else {q.push(vec[i]); q.push(vec[i]);}

        if(i==0) continue;
        ans += q.front();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4828
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();
        int D = sc.nextInt();
        sc.close();

        int ans = 0;

        if (B <= C || D <= A) {
            // not overlay
        } else if ((B > C) && (A < C)) {
            ans = B <= D ? B - C : D - C;
        } else {
            ans = D <= B ? D - A : B - A;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
N, M = gets.chomp.split.map(&:to_i)
cities = []
M.times do |i|
  p, y = gets.chomp.split.map(&:to_i)
  cities.push([p, y, i])
end
cities.sort_by!{|city| city[1]}
code = Array.new(M)
pref = [1] * (N + 1)

cities.each do |city|
  p = city[0]
  x = pref[p]
  number = p.to_s.rjust(6, '0') + x.to_s.rjust(6, '0')
  code[city[2]] = number
  pref[p] += 1
end
puts code


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

using namespace std;

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

int main(void)
{
	int n, m;
	cin >> n >> m;
	cout << (n + m) % 24 << endl;
	return 0;
}

Measured memory_bytes: 764
// https://atcoder.jp/contests/abc153/tasks/abc153_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll H, A;
  cin >> H >> A;

  ll res = (H + A - 1) / A;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, now = 0, p = 0;
  scanf("%lld%lld", &n, &k);
  --k;
  ll a[n], nex[n], f[n];
  bool flg = false;
  set< pair<ll, ll> > s;
  set< pair<ll, ll> >::iterator it;
  pair<ll, ll> t;
  for(i = 0; i < n; ++i) f[i] = -1;
  for(i = 0; i < 2 * n; ++i) {
    if(i < n) scanf("%lld", &a[i]);
    t = make_pair(a[i % n], 0);
    it = s.lower_bound(t);
    if(it != s.end() && (*it).first == a[i % n]) {
      t = *it;
      s.erase(it);
      if(t.second < n) nex[t.second] = i;
    }
    t.second = i;
    s.insert(t);
  }
  f[0] = 0;
  while(now < k) {
    p = nex[p] + 1;
    if(p >= n) now++, p -= n;
    if(!p) break;
    if(p < n) f[p] = now;
    else {
      ++now, p = 0;
      flg = true;
      break;
    }
  }
  if(!p && k) k %= now;
  if(flg && k == now - 1) return 0;
  for(i = 0; i < n; ++i) if(k == f[i]) break;
  for(; i < n; ++i) {
    if(nex[i] < n) i = nex[i];
    else printf("%lld ", a[i]);
  }
  return 0;
}

Measured memory_bytes: 18688
package main

import "fmt"

type edge struct {
	from int
	to   int
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	m := make(map[edge]int, 2*N)
	var x, y int
	for i := 0; i < M; i++ {
		fmt.Scan(&x, &y)
		if x == 1 || y == N {
			e := edge{from: x, to: y}
			m[e]++
		}
	}

	found := false
	for i := 1; i <= N; i++ {
		if i == 1 {
			if m[edge{from: 1, to: N}] != 0 {
				found = true
				break
			}
		} else {
			if m[edge{from: 1, to: i}] != 0 && m[edge{from: i, to: N}] != 0 {
				found = true
				break
			}
		}
	}

	if found {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


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

void solve_A() {
	int S, W;
	std::cin >> S >> W;
	//std::string result = (S <= W ? "unsafe" : "safe");
	std::cout << (S <= W ? "unsafe" : "safe") << std::endl;
}

void solve_B() {
	int A, B, C, D;
	std::cin >> A >> B >> C >> D;
	while (!( A <= 0 || C <= 0)) {
		C -= B;
		if (C <= 0) break;
		A -= D;
	}
	std::cout << (A <= 0 ? "No" : "Yes") << std::endl;
}

int main()
{
	//solve_A();
	solve_B();
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ff first
#define ss second
#define cy cout<<"Yes"<<endl;
#define cn cout<<"No"<<endl;
#define urs(r...)          typename decay<decltype(r)>::type
#define fi(i,n)                for(urs(n) i=0;i<n;i++)
#define rep(i,n)               for(urs(n) i=1;i<=n;i++)
#define pb push_back
#define gap ' '
#define endl '\n'
#define mex 300000
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>*/
main()
{
	int i,j,k,n,q;
	int cnt=0;
	bool flag=0,ok=0,f=0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
  	if(i%3==0 or i%5==0) continue;
  	else cnt+=i;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

int main() {
	int a[3];
	rep(i,0,3) cin >> a[i];

	sort(a, a + 3);

	rep(i,0,3) {
			if (i > 0) cout << " ";
			cout << a[i];
	}
	cout << endl;
}

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

int main()
{
    int l, r;
    cin >> l >> r;

    vector<int> remainderOf2019Vec;
    for (int i = l; i <= r; ++i)
    {
        if (i == l + 2019 * 3)
        {
            break;
        }

        int singleRemainder = i % 2019;
        remainderOf2019Vec.push_back(singleRemainder);
    }

    sort(remainderOf2019Vec.begin(), remainderOf2019Vec.end());

    int minMod = 2018;
    for (int x = 0; x < remainderOf2019Vec.size(); ++x)
    {
        for (int y = x + 1; y < remainderOf2019Vec.size(); ++y)
        {
            minMod = min(minMod, remainderOf2019Vec.at(x) * remainderOf2019Vec.at(y) % 2019);
        }
    }

    cout << minMod << endl;
}

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

int n, k;

int main() {
	cin>>n>>k;
	long long ans = 0;
	if(k == 0){	cout<<(long long)n*n; return 0;}
	for(int i = k+1;i<=n;i++){
		int maxQuotient = n/i;
		ans += maxQuotient*(i-k);
		if(maxQuotient*i+k<=n)	ans += n-maxQuotient*i-k+1;
	}
	cout<<ans;
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    scanf(" %d", &n);

    vector<int> a(n);
    vector<int> f(n+1);
    rep(i,n)
    {
        scanf(" %d", &a[i]);
        f[a[i]]=i;
    }

    set<int> ids;
    ids.insert(-1);
    ids.insert(n);

    ll ans=0;

    for(int i=1; i<=n; ++i)
    {
        auto l = ids.lower_bound(f[i]);
        auto r = ids.lower_bound(f[i]);
        --l;

        ans += (ll)(f[i] - *l)*(*r - f[i])*i;
        ids.insert(f[i]);
    }

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


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <map>
#define int long long

using namespace std;

typedef long double ld;
typedef pair<int, int> pa;
typedef long long ll;

const int mod = 998244353, N = 1e5;
const ld pi = 3.1415926535;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cout.precision(6);
    cout << fixed;

    int n;
    cin >> n;
    vector<int> cnt(n + 1, 0);
    for (int i = 1; i < n; ++i) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    for (int i = 1; i <= n; ++i)
        cout << cnt[i] << '\n';
}

Measured memory_bytes: 4752
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

static const int MAX = 70000;
static const int INF = (1<<21);

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

    int A[m];
    for (int i = 0; i < m; i++) scanf("%d", &A[i]);

    int dp[MAX];
    for (int i = 0; i < MAX; i++) dp[i] = INF;

    dp[0] = 0;
    for (int i = 0; i <= n; i++){
        if (dp[i] == INF) continue;
        for (int j = 0; j < m; j++) dp[i + A[j]] = min(dp[i + A[j]], dp[i] + 1);
    }

    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3492
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    A--; B--;
    cout << 100 << " " << 100 << endl;
    rep(i, 50) {
        rep(j, 100) {
            if (A > 0 && i % 2 == 1 && j % 2 == 1) {
                cout << ".";
                A--;
            } else {
                cout << "#";
            }
        }
        cout << endl;
    }
    rep(i, 50) {
        rep(j, 100) {
            if (B > 0 && i % 2 == 1 && j % 2 == 1) {
                cout << "#";
                B--;
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }

    return 0;
}
// .#.#.#.#.#

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  ll n, m; cin >> n >> m;

  vector<ll> h(n+1); REP(i, n) cin >> h[i];
  vector<ll> a(m+1);
  vector<ll> b(m+1);
  vector<ll> t(n+1); REP(i, n) t[n] = 0;
  REP(i, m) {
    cin >> a[i] >> b[i];
    a[i] --; b[i] --;
    if(h[a[i]] >= h[b[i]]) {t[b[i]] = 1; }
    if(h[b[i]] >= h[a[i]]) {t[a[i]] = 1; }
  }
  ll ans = 0;

  REP(i, n) {
    if(t[i]==0) ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 6424
def gcd(X0,X1):
    Y0=max([X0,X1])
    Y1=min([X0,X1])
    if Y0%Y1==0:
        return Y1
    else:
        return gcd(Y1,Y0%Y1)

def canbuy(A,B,C,D):
    if B>A:
        return False
    elif B>D:
        return False
    elif C>=B:
        return True
    else:
        g=gcd(B,D)
        X=B-g+(A%g)
        if X>C:
            return False
        else:
            return True

T=int(input())
S=["" for i in range(T)]
for i in range(T):
    a,b,c,d=map(int,input().split())
    if canbuy(a,b,c,d):
        S[i]="Yes"
    else:
        S[i]="No"

for i in range(T):
    print(S[i])


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

int main() {

  int X, N;
  cin >> X >> N;

  vector<bool> p(101);
  for (int i = 0; i < N; i++) {
    int P;
    cin >> P;
    p[P] = true;
  }

  if (p[X] == false) {
    cout << X << endl;
    return 0;
  }
  
  int d = 1000;
  int ans = 100;

  for (int i = 0; i < 102; i++) {
    if (p[i] == false) {
      int D = abs(i - X);
      if (D < d) {
        d = D;
        ans = i;
      }
    }
  }

  cout << ans << endl;
  
  return 0;

}

Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>
#include <queue>

const int Inf = 0x3f3f3f3f;
const int MN = 500005, MS = 1 << 20 | 7;

int N, K, P[MN], Ans[MN];

#define li (i << 1)
#define ri (li | 1)
#define mid ((l + r) >> 1)
#define ls li, l, mid
#define rs ri, mid + 1, r
int mxp[MS];
void Build(int i, int l, int r) {
	if (l == r) return mxp[i] = l, void();
	Build(ls), Build(rs);
	mxp[i] = P[mxp[li]] > P[mxp[ri]] ? mxp[li] : mxp[ri];
}
void Del(int i, int l, int r, int p) {
	if (l == r) return mxp[i] = 0, void();
	p <= mid ? Del(ls, p) : Del(rs, p);
	mxp[i] = P[mxp[li]] > P[mxp[ri]] ? mxp[li] : mxp[ri];
}
int Qur(int i, int l, int r, int a, int b) {
	if (r < a || b < l) return 0;
	if (a <= l && r <= b) return mxp[i];
	int v1 = Qur(ls, a, b), v2 = Qur(rs, a, b);
	return P[v1] > P[v2] ? v1 : v2;
}

int inq[MN];
std::priority_queue<int> pq;
inline void check(int id) {
	if (inq[id]) return ;
	if (Qur(1, 1, N, id - K + 1, id + K - 1) == id)
		pq.push(id), inq[id] = 1;
}

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; ++i) scanf("%d", &P[i]);
	P[0] = -Inf;
	Build(1, 1, N);
	for (int i = 1; i <= N; ++i) check(i);
	for (int i = N; i >= 1; --i) {
		int u = pq.top(); pq.pop();
		Ans[u] = i;
		Del(1, 1, N, u);
		int pos;
		if ((pos = Qur(1, 1, N, u - K + 1, u - 1))) check(pos);
		if ((pos = Qur(1, 1, N, u + 1, u + K - 1))) check(pos);
	}
	for (int i = 1; i <= N; ++i) printf("%d\n", Ans[i]);
	return 0;
}

Measured memory_bytes: 15600
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n,k,q;cin >> n >> k >> q;
  vector<int> a(n,k);
  vector<int> comand(n,0);
  for(int i=0;i<q;i++){
    int t;cin >> t;
    comand[t-1]++;
  }
  for(int i=0;i<n;i++){
    a[i]=a[i]-q+comand[i];
  }
  for(auto &i:a) cout << (i>0?"Yes":"No") << endl;

}


Measured memory_bytes: 1408
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

int main(){
  for(int N,D;cin>>N>>D,N;){
    complex<double> p;
    double ang=0;
    while(N--){
      int l,r,t;
      cin>>l>>r>>t;
      double a=l*t*acos(0)/90,b=r*t*acos(0)/90;
      if(l==r){
	p+=polar(a,ang+acos(0));
      }else{
	double x=2*a*D/(b-a);
	double theta=l?a/x:b/2/D;
	complex<double> c=p-polar(x+D,ang);
	p=(p-c)*polar(1.,theta)+c;
	ang+=theta;
      }
    }
    cout.precision(9);
    cout<<fixed<<p.real()<<endl;
    cout<<fixed<<p.imag()<<endl;
  }
}

Measured memory_bytes: 1236
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s = sc.nextInt();
		if (s != 1000000000) {
			if (n == k) {
				for (int i = 0; i < n - 1; i++) {
					System.out.print(s);
					System.out.print(" ");
				}
				System.out.println(s);
				return;
			}
			for (int i = 0; i < k; i++) {
				System.out.print(s);
				System.out.print(" ");
			}
			for (int i = 0; i < n - k - 1; i++) {
				System.out.print(1000000000);
				System.out.print(" ");
			}
			System.out.println(1000000000);

		} else {
			if (n == k) {
				for (int i = 0; i < n - 1; i++) {
					System.out.print(s);
					System.out.print(" ");
				}
				System.out.println(s);
				return;
			}
			for (int i = 0; i < k; i++) {
				System.out.print(s);
				System.out.print(" ");
			}
			for (int i = 0; i < n - k - 1; i++) {
				System.out.print(1);
				System.out.print(" ");
			}
			System.out.println(1);
		}
	}
}



class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 42296
#include <stdio.h>
int main(void){
	
	int h,w,i,j;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0)break;
		
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if((i+j)%2==0)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prac
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a = inputs[0];
            var b = inputs[1];
            Console.WriteLine((a / b).ToString() + " " + (a % b).ToString() + " " + ((double)a / (double)b).ToString("F8"));
        }
    }
}

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

int main(){
    int n, h;

    while(scanf("%d%d",&n,&h)==2){
        int A = -1, b[n];

        for(int i=0; i<n; i++){
            int a;
            scanf("%d %d",&a, &b[i]);
            A = max(A, a);
        }

        sort(b, b+n);
        int cnt=0;

        for(int i=n-1; i>=0 && h>0 && b[i]>A; i--){
            h-=b[i];
            cnt++;
        }

        if(h>0)
            cnt += h/A + (h%A!=0);

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

    return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int p = sc.nextInt();
			int q = sc.nextInt();
			if (p + q == 0) {
				break;
			}
			ArrayList<ArrayList<Integer>> equation = new ArrayList<ArrayList<Integer>>();
			ArrayList<ArrayList<Integer>> solve = new ArrayList<ArrayList<Integer>>();
			int br = 0;
			int bc = 0;
			int bs = 0;
			for(int i=0;i<p;i++) {
				String s = sc.next();
				int j = 0;
				int dots = 0;
				for(j=0;j<s.length();j++) {
					char c = s.charAt(j);
					if (c == '.') {
						dots++;
					}else{
						break;
					}
				}
				if (true) {
					ArrayList<Integer> al = new ArrayList<Integer>();
					al.add(br);
					al.add(bc);
					al.add(bs);
					al.add(dots);
					equation.add(al);
				}
				for(;j<s.length();j++) {
					char c = s.charAt(j);
					switch (c) {
					case '(':
						br++;
						break;
					case ')':
						br--;
						break;
					case '{':
						bc++;
						break;
					case '}':
						bc--;
						break;
					case '[':
						bs++;
						break;
					case ']':
						bs--;
						break;
					}
				}
			}
			for(ArrayList<Integer> al:equation) {
				//System.out.println(al);
			}
			for(br=1;br<=20;br++) {
				for(bc=1;bc<=20;bc++) {
					for(bs=1;bs<=20;bs++) {
						boolean flag = true;
						for(ArrayList<Integer> al:equation) {
							if (br * al.get(0) + bc * al.get(1) + bs * al.get(2) != al.get(3)) {
								flag = false;
								break;
							}
						}
						if (flag) {
							ArrayList<Integer> al = new ArrayList<Integer>();
							al.add(br);
							al.add(bc);
							al.add(bs);
							solve.add(al);
							//System.out.println(br + "," + bc + "," + bs);
						}
					}
				}
			}
			br = 0;
			bc = 0;
			bs = 0;
			for(int i=0;i<q;i++) {
				int dots = -1;
				for(ArrayList<Integer> sol:solve) {
					int d = br * sol.get(0) + bc * sol.get(1) + bs * sol.get(2);
					if (dots == -1) {
						dots = d;
					}else{
						if (dots != d) {
							dots = -2;
						}
					}
				}
				if (dots < 0) {
					dots = -1;
				}
				if (i != q-1) {
					System.out.print(dots + " ");
				}else{
					System.out.println(dots);
				}
				String s = sc.next();
				for(int j=0;j<s.length();j++) {
					char c = s.charAt(j);
					switch (c) {
					case '(':
						br++;
						break;
					case ')':
						br--;
						break;
					case '{':
						bc++;
						break;
					case '}':
						bc--;
						break;
					case '[':
						bs++;
						break;
					case ']':
						bs--;
						break;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 64488
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<LLI> A(N); cin >> A;
    sort(ALL(A));

    vector<LLI> b(N);
    REP(i,N) b[i] = abs(A[i]);

    LLI ans = 0;
    vector<pair<int,int>> ans_op;

    if(A[0] >= 0){ // all positive
      LLI x=A.front();

      FOR(i,1,N-1){
	ans_op.push_back({x,A[i]});
	x -= A[i];
      }

      ans_op.push_back({A.back(), x});

      ans = accumulate(ALL(A), 0LL) - 2*A[0];
      
    }else if(A.back() < 0){ // all negative

      reverse(ALL(b));
      reverse(ALL(A));
      LLI x=A.front();

      FOR(i,1,N){
	ans_op.push_back({x,A[i]});
	x -= A[i];
      }

      ans = accumulate(b.begin()+1, b.end(), 0LL) - b[0];
      
      
    }else{
      ans = accumulate(ALL(b), 0LL);

      LLI x=A.front(),y=A.back();

      FOR(i,1,N){
	if(A[i]>=0) break;
	ans_op.push_back({y,A[i]});
	y -= A[i];
      }

      REV(i,N-2,1){
	if(A[i]<0) break;
	ans_op.push_back({x,A[i]});
	x -= A[i];
      }

      ans_op.push_back({y,x});
    }
    
    cout << ans << endl;
    for(auto &p : ans_op){
      cout << p.fst << " " << p.snd << endl;
    }
  }
  
  return 0;
}


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

int main() {
  double a, b, c;
  int d;
  cin >> a >> b;
  c = (a + b) / 2;
  d = (a + b) / 2;
  if (c == d) {
    cout << d << endl;
  } else {
    cout << d + 1 << endl;
  }
}


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

int main(){
    int L;
    double x;
    long double max;
    cin >> L;
    max = 0.0;
    x = L/3.0;
    max = x*x*x;

    cout << setprecision(15) << max << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from math import gcd

N = int(input())
A = list(map(int, input().split()))
era = [-1]*(10**6+1)

for i in range(2, 10**6+1):
    if era[i]==-1:
        era[i] = i

        for j in range(2*i, 10**6+1, i):
            if era[j]==-1:
                era[j] = i

s = set()
flag = True

for Ai in A:
    f = []
    t = Ai
    
    while t>1:
        f.append(era[t])
        t //= era[t]
    
    for fi in f:
        if fi in s:
            flag = False
    
    for fi in f:
        s.add(fi)

if flag:
    print('pairwise coprime')
    exit()

G = 0

for Ai in A:
    G = gcd(G, Ai)

if G==1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 182828
// B - Chocolate
// https://atcoder.jp/contests/abc092/tasks/abc092_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli b, c, d, x, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  cin >> d >> x;
  vi a(n);
  rep(i, 0, n)
  {
    cin >> a[i];
  }
  for (lli i = 0; i < n; i++)
  {
    for (lli j = 1; j <= d; j += a[i])
    {
      count++;
    }
  }
  cout << x + count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define en         cout<<endl;
#define pb         push_back
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI 3.1415926535897932384626433832795

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
    sf1(n);
    n--;
    res=n*(n+1);
    res/=2;
    co<<res;
}



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


int main() {
    long N;
    cin >> N;
    long ans = (N / 500) * 1000 + ((N % 500) / 5) * 5;
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  if(v <= w) cout << "NO" << endl;
  else{
    ll des = abs(a-b);
    ll gap = abs(v-w);
    if(des <= gap*t) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624