akhauriyash/Code-Regression huggingface dataset:
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;

	vector<int> v(n);

	for(int i = 0; i < n; i++) cin >> v[i];

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

	long long ans = v[n - 1];

	int get = n - 2;

	for(int i = n - 2; i >= 0; i--) {
		if(get) {
			get--;
			ans += v[i];
		}
		if(get) {
			get--;
			ans += v[i];
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 3996
#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(){
    int x,y;
    cin >> x >> y;
    string enable = "No";
    rep(i, x+1){
        int kame4 = y-i*2;
        if(kame4%4==0 && kame4/4+i == x){
            enable = "Yes";
        }
    }
    cout << enable << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
 int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
 if((A==5&&B==5&&C==7)||(A==5&&B==7&&C==5)||(A==7&&B==5&&C==5))printf("YES");
 else printf("NO");
 return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.math.BigInteger;

class Main {

    static void solve (BigInteger a, BigInteger b, int n) {
        int result = 0;

        for(int i = 1; i <= n; i++) {
            a = a.multiply(BigInteger.TEN);
            result += a.divide(b).mod(BigInteger.TEN).intValue();
        }


        System.out.println(result);
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            BigInteger a = new BigInteger(sc.next());
            BigInteger b = new BigInteger(sc.next());
            int n = sc.nextInt();

            solve(a, b, n);
        }

    }
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <string.h>

int memo[1024][1024];
int w[1024];
int v[1024];
int n;

int search(int i, int u)
{
	int a, b;
	
	if (memo[i][u] > -1){
		return (memo[i][u]);
	}
	
	if (i == n){
		return (0);
	}
	
	if (u - w[i] < 0){
		a = 0;
	}
	else {
		a = v[i] + search(i + 1, u - w[i]);
	}
	
	b = search(i + 1, u);
	
	if (a > b){
		memo[i][u] = a;
		return (a);
	}
	
	memo[i][u] = b;
	return (b);
}


int main(void)
{
	int i, u;
	int max;
	int ca = 1;
	
	while (scanf("%d", &u), u){
		memset(memo, -1, sizeof(memo));
		
		scanf("%d", &n);
		
		for (i = 0; i < n; i++){
			scanf("%d,%d", &v[i], &w[i]);
		}
				
		for (i = 0; i <= u; i++){
			if (search(0, i) == search(0, u)){
				printf("Case %d:\n", ca++);
				printf("%d\n%d\n", search(0, i), i);
				break;
			}
		}
		
	}
	
	return (0);
}

Measured memory_bytes: 4756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, A;
            N = int.Parse(Console.ReadLine());
            A = int.Parse(Console.ReadLine());
 
            Console.WriteLine(N * N - A);
            Console.ReadKey();
        }
        
    }
}

Measured memory_bytes: 11092
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	if b >= a*c {
		fmt.Println(c)
		return
	}

	if a > b {
		fmt.Println(0)
		return
	}

	fmt.Println(b / a)
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define orep(i, n) for(int i = 1; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
    int token0, token1;
    double ans = 0, n;
    cin >> n;
    vi v;
    vvi distance(n, vi(2, 0));

    rep(i, n) {
        v.push_back(i);
        cin >> token0 >> token1;
        distance[i][0] = token0;
        distance[i][1] = token1;
    }


    do {
        rep(i, n - 1) {
            ans += sqrt(
                    pow((distance[v[i]][0] - distance[v[i + 1]][0]), 2) + pow((distance[v[i]][1] - distance[v[i + 1]][1]), 2));
        }
    } while (next_permutation(v.begin(), v.end()));

    double factorial = 1;
    for (int j = 2; j <= n; j++) {
        factorial *= j;
    }

    cout << fixed << setprecision(10) << ans / factorial << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int main() {

	int n;
	cin >> n;

	n++;
	vector<pii> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}

	sort(a.begin(), a.end());
	pii twice_i;
	for (int i = 1; i <= n;i++) {
		if (a[i].first == a[i - 1].first) {
			twice_i = make_pair(a[i - 1].second, a[i].second);
			break;
		}
	}
	int t_len = twice_i.second - twice_i.first + 1;

	vector<ll> facto(n + 2);
	facto[0] = 1;
	for (int i = 1; i <= n + 1;i++) {
		facto[i] = (facto[i - 1] * i) % MOD_CONST;
	}
	vector<ll> inv_mod(n + 2);
	inv_mod[1] = 1;
	for (int i = 2; i <= n + 1;i++) {
		inv_mod[i] = (MOD_CONST - (inv_mod[MOD_CONST %i] * (MOD_CONST / i)) % MOD_CONST) % MOD_CONST;
	}
	vector<ll> inv_facto(n + 2);
	inv_facto[0] = 1;
	for (int i = 1; i <= n + 1;i++) {
		inv_facto[i] = (inv_facto[i - 1] * inv_mod[i]) % MOD_CONST;
	}


	for (int i = 1; i <= n;i++) {
		ll ans = (((facto[n] * inv_facto[n - i]) % MOD_CONST) * inv_facto[i]) % MOD_CONST;
		if (t_len + i - 1 <= n) {
			ans = (ans + MOD_CONST - (((facto[n - t_len] * inv_facto[n - t_len - (i - 1)]) % MOD_CONST) * inv_facto[i - 1]) % MOD_CONST) % MOD_CONST;
		}



		cout << ans << endl;
	}

}



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



int main() {

    int n; cin >> n;
    set<int> d;

    rep(i,n) {
        int tmp; cin >> tmp;
        d.insert(tmp);
    }

    cout << d.size() << endl;

    return 0;
}





Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    long long a,b,c,d;
	while(~scanf("%lld %lld %lld",&a,&b,&c))
	{
		d =(a/(b+c));
		if((b+c)*d+c<=a) printf("%lld\n",d);
		if((b+c)*d+c>a) printf("%lld\n",d-1);
		}
}

Measured memory_bytes: 128
N, S = open(0).read().split()
S = list(map(int, list(S)))
N = int(N)

cnt = 0
for i in range(0, 10):
        for j in range(0, 10):
            for k in range(0, 10):
                try:
                    n = S.index(i)
                    m = S[n+1:].index(j)
                    o = S[n+m+2:].index(k)
                    cnt += 1
                except ValueError:
                    pass
print(cnt)

Measured memory_bytes: 9536
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int n, X, x[100010], ans;
    cin>>n>>X;
    for (int i=0; i<n; i++) cin>>x[i];
    x[n]=X;
    sort(x, x+n+1);
    for (int i=1; i<=n; i++)
    {
        if (i==1) ans=x[1]-x[0];
        else
        {
            ans=__gcd(ans, x[i]-x[i-1]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
S = input()
N = len(S)
count = 0
max = 0
for i in range (N):
  if S[i] == "A" or S[i] == "T" or S[i] == "C" or S[i] == "G":
    count = count + 1
  else:
    if count > max:
      max = count
    count = 0
if count > max:
  max = count
  
print(max)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  long int a,b,c;
  scanf("%ld",&a);
  scanf("%ld",&b);
  scanf("%ld",&c);
  if((c-a-b)<=0){
  	printf("No");
  	return 0;
  }
  a=(c-a-b)*(c-a-b)-4*a*b;
  if(a<=0){
    printf("No");
  }else{
    printf("Yes");
  }
  return 0;
}


Measured memory_bytes: 128
from collections import deque

N = int(input())

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

def calc(n, k):
  if n % k == 0:
    return calc(n // k, k)
  elif n < k:
    return n
  else:
    return calc(n % k, k)

ans = make_devision(N-1)

for i in make_devision(N):
  if i == 1:
    continue
  if calc(N, i) == 1:
    ans.append(i)
    
print(len(ans)-1)

Measured memory_bytes: 3700
S = list(input())
N = len(S)
li = [0 for x in range(N)]
col = 0
while col <= N-1:
    counter = 1
    if S[col] == "R":
        while S[col+counter] == "R":
            counter += 1
        r = counter
        li[col+counter] += r // 2
        if r % 2 == 0:
            li[col+counter-1] += r // 2
        else:
            li[col+counter-1] += r // 2 + 1
        col += counter
    else:
        while col + counter <= N-1 and S[col+counter] == "L":
            counter += 1
        l = counter
        li[col-1] += l // 2
        if l % 2 == 0:
            li[col] += l // 2
        else:
            li[col] += l // 2 + 1
        col += counter       
   
print(*li)

Measured memory_bytes: 7092
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
abcds = [tuple(map(int, input().split()))for _ in range(Q)]


def cal_score(A):
    score = 0
    for a, b, c, d in abcds:
        if A[b-1] - A[a-1] == c:
            score += d
    return score


ans = 0
for A in combinations_with_replacement([i for i in range(M)], N):
    ans = max(ans, cal_score(A))
print(ans)


Measured memory_bytes: 9140
a,b,m = gets.split.map(&:to_i)
arr1 = gets.split.map(&:to_i)
arr2 = gets.split.map(&:to_i)
min = arr1.min + arr2.min
m.times do
  x,y,c = gets.split.map(&:to_i)
  min = (arr1[x-1] + arr2[y-1] - c) if (arr1[x-1] + arr2[y-1] - c) < min
end
puts min

Measured memory_bytes: 18588
n=int(input())

a=input().split(' ')
b=[int(i) for i in a]
s=0
for k in range(2,n):
  for j in range(1,k):
    for i in range(j):
      if (b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]):
        m=max(b[i],b[j],b[k])
        if 2*m<b[i]+b[j]+b[k]:
          s+=1
print(s)

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int get_digit(ll n){
    int digit = 0;
    if(n == 0){
        return 1;
    }
    while(n != 0){
        digit++;
        n /= 10;
    }
    return digit;
}
bool is_junretu(ll n){
    int digit = get_digit(n);
    string s;
    s = to_string(n);
    bool flg= true;
    for(int i = 1; i <= digit; i++){
        if(s.find(i) == string::npos){
            flg = false;
            break;
        }
    }
    return flg;
}

int main(){

    int n;
    cin >> n;
    map<string, int> v;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(v[s] == 0) cnt++;
        v[s] = 1;
    }
    cout << cnt << endl;
    return 0;
}

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

void nosol()
{
	printf("-1\n");
	exit(0);
}

int m,k;

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

	if(m==0)
	{
		if(k!=0)nosol();
		else printf("0 0\n");
	}
	else if(m==1)
	{
		if(k!=0)nosol();
		else printf("0 0 1 1\n");
	}
	else 
	{
		if(k>=(1<<m))nosol();
		else
		{
			int n=1<<m;
			for(int i=0;i<n;i++)
				if(i!=k)printf("%d ",i);
			printf("%d ",k);
			for(int i=n-1;~i;i--)
				if(i!=k)printf("%d ",i);
			printf("%d\n",k);
		}
	}

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[200010],sum[200010] = {};
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++){
		sum[i + 1] = sum[i] + a[i];
	}
	int dp[200010][2][3];
	for(int i = 0;i <= n;i++){
		for(int j = 0;j < 2;j++){
			for(int k = 0;k < 3;k++) dp[i][j][k] = INF;
		}
	}
	dp[0][0][0] = 0;
	int ans = INF;
	for(int i = 0;i < n;i++){
		chmin(dp[i][0][0],sum[i]);
		for(int j = 0;j < 2;j++){
			for(int k = 0;k < 3;k++){
				for(int l = 0;l < 2;l++){
					int nk = k + (j != l);
					if(nk >= 3) continue;
					if(l == 0 && a[i] == 0){
						chmin(dp[i + 1][l][nk],dp[i][j][k] + 2);
						chmin(ans,dp[i][j][k] + sum[n] - sum[i]);
					}else{
						chmin(dp[i + 1][l][nk],dp[i][j][k] + (a[i] % 2 != l));
					}
				}
			}
		}
	}
	for(int j = 0;j < 2;j++){
		for(int k = 0;k < 3;k++) chmin(ans,dp[n][j][k]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Input in = new Input(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		DChatInACircle solver = new DChatInACircle();
		solver.solve(1, in, out);
		out.close();
	}
	static class DChatInACircle {
		public void solve(int testNumber, Input in, PrintWriter pw) {
			int n = in.nextInt();
			int[] arr = new int[n];
			for(int i = 0; i<n; i++) {
				arr[i] = in.nextInt();
			}
			Arrays.sort(arr);
			PriorityQueue<Integer> pq = new PriorityQueue<>((o1, o2) -> Integer.compare(o2, o1));
			pq.add(arr[n-1]);
			long ans = 0;
			for(int i = n-2; i >= 0; i--) {
				int cur = pq.poll();
				ans += cur;
				pq.add(arr[i]);
				pq.add(arr[i]);
			}
			pw.println(ans);
		}

	}

	static class Input {
		BufferedReader br;
		StringTokenizer st;

		public Input(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			try {
				st = new StringTokenizer(br.readLine());
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public boolean hasNext() {
			try {
				while(!st.hasMoreTokens()) {
					String s = br.readLine();
					if(s==null) {
						return false;
					}
					st = new StringTokenizer(s);
				}
				return true;
			}catch(Exception e) {
				return false;
			}
		}

		public String next() {
			if(!hasNext()) {
				throw new InputMismatchException();
			}
			return st.nextToken("\r\n\t\f ");
		}

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

	}
}



Measured memory_bytes: 59404
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long n;
    long long sum=0;
    scanf("%lld",&n);
        for(long long  i = 1; i*i <= n; i++)
            sum = i * i;
        printf("%lld\n",sum);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
int n;
int a[maxx], b[maxx], t[maxx];

int main() {
	bool flg = 1;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d %d %d", &t[i], &a[i], &b[i]);
	for(int i = 1; i <= n; i++) {
		if(t[i] - t[i - 1] < abs(a[i] - a[i - 1]) + abs(b[i] - b[i - 1])) {
			flg = 0; break;
		}
		else {
			int tmp = t[i] - t[i - 1];
			int dx = abs(a[i] - a[i - 1]), dy = abs(b[i] - b[i - 1]);
			int d = dx + dy;
			if(tmp % d) {
				flg = 0; break;
			}
		}
	}
	if(flg) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 1408
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int h = sc.nextInt();
        int a = sc.nextInt();
        int ans = h / a;
        if(h % a != 0) ans++;
        System.out.println(ans);
    }



    private static 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 || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

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

}



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

int main(){
	char a[3];
	int i=0;
	while(cin>>a[i]){i++;}
	if(i==2){cout<<a[0]<<a[1]<<endl;}
	else{cout<<a[2]<<a[1]<<a[0]<<endl;}
	
	return 0;
}

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

long long L,R,Ans;

int main()
{
	cin>>L>>R;
	Ans=0;
	if(R-L<2019)
	{
		Ans=2019;
		for(long long i=L;i<=R;i++) 
			for(long long j=i+1;j<=R;j++) 
				Ans=min(Ans,((i%2019ll)*(j%2019ll))%2019ll);
	}
	cout<<Ans<<endl;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  ll h;
  cin >> h;
  ll ans = 0;
  ll cnt = 1;
  rep(i, 60) {
    if (h > 1) {
      h = h >> 1;
      ans += cnt;
      cnt = cnt << 1;
    } else {
      ans += cnt;
      break;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int p,q,r;
	cin >> p >> q >> r;
	cout << min({p+q,q+r,r+p}) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
  int N; double M; cin >> N >> M;
  vector<double> A(N);
  double sum = 0.;
  rep(i, N) cin >> A[i], sum += A[i];
  int cnt = 0;
  rep(i, N) {
    if(A[i] >= sum/(4.*M)) cnt++;
  }
  if(cnt >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 50 + 5;
const ll INF = 1ll << maxn;
ll f[maxn][maxn]; 
ll in[maxn];
ll ans;
int n;
int a[maxn], b[maxn];
int main()
{
	for(int i = 0; i <= 50; ++i) in[i] = 1;
	for(int i = 0; i <= 50; ++i)
		for(int j = 0; j <= 50; ++j)
			f[i][j] = i == j ? 0 : INF;
	for(int i = 0; i <= 50; ++i)
		for(int j = 2 * i + 1; j <= 50; ++j)
		{
			for(int k = i + 1; k <= j; ++k)
				f[i][j] = min(f[i][j], f[i][j % k] + (in[k] << k));
		}
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &b[i]);
		if(f[b[i]][a[i]] == INF)
		{
			puts("-1");
			return 0;
		}
	}
	while(true)
	{
		ll ret = 0;
		for(int i = 1; i <= n; ++i) ret = max(f[b[i]][a[i]], ret);
		if(!ret) break;
		for(int i = 50; ~i; --i) if(ret & (1ll << i)) { ans |= (1ll << i); in[i] = 0; break;}
		for(int i = 0; i <= 50; ++i)
		for(int j = 0; j <= 50; ++j)
			f[i][j] = i == j ? 0 : INF;
		for(int i = 0; i <= 50; ++i)
			for(int j = 2 * i + 1; j <= 50; ++j)
			{
				for(int k = i + 1; k <= j; ++k)
					f[i][j] = min(f[i][j], f[i][j % k] + (in[k] << k));
			}
	}
	printf("%lld\n", ans);
	return 0;
}
				

Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
long long n, k, a[200009], bit[200009], ret; vector<long long>B;
void add(long long s, long long x) { while (s <= B.size()) { bit[s] += x; s += (s&-s); } }
long long sum(long long s) {
	long long t = 0;
	while (s >= 1) { t += bit[s]; s -= (s&-s); }
	return t;
}
void add2(long long V) {
	long long pos1 = lower_bound(B.begin(), B.end(), V) - B.begin();
	add(pos1, 1);
}
int main() {
	cin >> n >> k; for (int i = 1; i <= n; i++)cin >> a[i], a[i] -= k;
	for (int i = 1; i <= n; i++)a[i] += a[i - 1], B.push_back(a[i]);
	B.push_back(-(1LL << 60)); B.push_back(0);
	sort(B.begin(), B.end()); add2(0);
	for (int i = 1; i <= n; i++) {
		long long pos1 = upper_bound(B.begin(), B.end(), a[i]) - B.begin(); pos1--;
		ret += sum(pos1);
		add2(a[i]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int i;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=n-1;i>=0;i--)
  {
    if(i>=1)
    {
    cout<<a[i]<<" ";
  }else{
    cout<<a[i];
  }
  }
  cout<<endl;
return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<utility>
#include<climits>
#include<queue>
using namespace std;

int main(void)
{
    int N;
    cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    sort(A.begin(), A.end());
    if (N == 2) {
        cout << A[1] - A[0] << endl;
        cout << A[1] << " " << A[0] << endl;

        return 0;
    }

    priority_queue<int> minus, plus;
    for (int i = 0; i < N; i++) {
        if (A[i] > 0)
            plus.push(-A[i]);
        else
            minus.push(A[i]);
    }

    vector<pair<int, int>> op;
    if (plus.size() == 0) {
        int l = minus.top();
        minus.pop();
        int r = minus.top();
        minus.pop();

        op.push_back(make_pair(l, r));
        plus.push(l - r);
    }
    else if (minus.size() == 0) {
        int l = -plus.top();
        plus.pop();
        int r = -plus.top();
        plus.pop();

        op.push_back(make_pair(l, r));
        minus.push(l - r);
    }

    while (plus.size() > 1) {
        int l = minus.top();
        minus.pop();
        int r = -plus.top();
        plus.pop();

        op.push_back(make_pair(l, r));
        minus.push(l - r);
    }

    while (minus.size() > 0) {
        int l = -plus.top();
        plus.pop();
        int r = minus.top();
        minus.pop();

        op.push_back(make_pair(l, r));
        plus.push(-(l - r));
    }

    cout << -plus.top() << endl;
    for (int i = 0; i < (int)op.size(); i++) {
        cout << op[i].first << " " << op[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 3700
arg = input()
a = int((arg.split())[0])
b = int((arg.split())[1])
c = int((arg.split())[2])
d = int((arg.split())[3])

while True:
    c -= b
    if c <= 0:
        print('Yes')
        break
    a -= d
    if a <= 0:
        print('No')
        break

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

signed main() {
	int n;
	int a, b;
	string s;
	cin >> a >> b;
	if (a < 6) {
		cout << 0 << endl;
	}
	else if (a < 13) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
    	cin >> v[i];
    	v[i] -= i + 1;
    }
    sort(v.begin(), v.end());
    long long int res = 0;
    for (int i = 0; i < n - 1 - i; i++) {
    	res += v[n - 1 - i] - v[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 3960
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

    ll n,m,k;
    cin>>n>>m>>k;  

    char a[n][m];  ll total=0; ll how_many=0;

    For(i,0,n)
    {
        For(j,0,m)
        {
           cin>>a[i][j];
           if (a[i][j]=='#')
            how_many+=1;
        }
    }




    for(int i=0;i<=(int)(1<<n)-1;i++)
    {   
        vector <ll> rows;

        for(int k=0;k<n;k++)
        {
            if (i&(1<<k))
                rows.pb(k);
        }

        for(int j=0;j<=(int)(1<<m)-1;j++)
        {
            vector <ll> columns;

            for(int l=0;l<m;l++)
            {
                if (j&(1<<l))
                    columns.pb(l);
            }

    
                ll check[n][m]={};
               

                 ll cnt=0;

                for(int s=0;s<siz(rows);s++)
                {
                    for(int q=0;q<m;q++)
                    {
                        if (a[rows[s]][q]=='#'&&check[rows[s]][q]==0)
                        {
                            check[rows[s]][q]=1;
                            cnt+=1;
                        }
                    }
                }

               // cout<<siz(rows)<<' '<<cnt<<endl;

                for(int s=0;s<siz(columns);s++)
                {
                    for(int q=0;q<n;q++)
                    {
                        if (a[q][columns[s]]=='#'&&check[q][columns[s]]==0)
                        {
                            check[q][columns[s]]=1;
                            cnt+=1;
                        }
                    }
                }

                //cout<<cnt<<endl;

                if (how_many-cnt==k)
                    total+=1;
        }
    }


    cout<<total;

return 0;
}

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

int solve(int n){
  int count = 0;
  for(int i=1;i<=n/2;i++){
    if(n % i == 0){count++;}
  }
  return count+1;
}

int main(void){
  int N;
  cin >> N;
  
  int count = 0;
  for(int i=1;i<=N;i+=2){
    if(solve(i)==8){count++;}
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long N,cnt=0;
    cin >> N;
    vector<string>S(N),ans(N,"A");
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    sort(S.begin(),S.end());
    for(int i=0;i<N;i++){
        if(i==0){
            cnt++;
        }else if(S[i]!=S[i-1]){
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 15672
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int,int> P;
constexpr ll SIZE= 100010;

ll Fact[SIZE];
ll Com[SIZE];
ll LP(ll x,ll y);
void FC(ll x);
ll MC(ll x,ll y);
ll LP(ll x,ll y){
    if(y==0)return 1;
    if(y%2==0)return LP((x*x)%MOD,y/2)%MOD;
    else return LP(x,y-1)*x%MOD;
}
void FC(ll x){
    Fact[0]=Com[0]=1;
    ll temp=1;
    EREP(i,x){
        //temp=temp*i%MOD;
        temp=(temp*(ll)i)%MOD;
        Fact[i]=temp;
        //Com[i]=LP(temp,MOD-2);
        Com[i]=LP(i,MOD-2);
    }
}
ll MC(ll x,ll y){
    if(y==0)return 1;
    if(x<y)return 0;
    return (Fact[x]*(Com[y]*Com[x-y]%MOD))%MOD;
}

ll N,M;
ll S[100010];
ll ans=0;
bool F=true;
int main() {
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    FC(N);
    S[0]=Com[1];
    //ComとFactは1-indexed
    REP(i,N){
        S[i+1]+=S[i]+Com[i+2];
        S[i+1]%=MOD;
    }
    REP(i,N){
        ll a;
        cin>>a;
            ll s=S[N-1-i];
            s+=S[i]-S[0];
        s%=MOD;ans+=s*a%MOD;ans%=MOD;
    }
    cout<<(ans*Fact[N])%MOD<<endl;
    return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int A, B, C;
  int K;
  cin >> A >> B >> C;
  cin >> K;
  REP(k,K) {
    if (B <= A) {
      B *= 2;
    } else if (C <= B) {
      C *= 2;
    }
  }

  if (A < B && B < C) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        List<Integer> li = new ArrayList<>();
        for (int i = 0; i < N; ++i) li.add(fs.nextInt());

        int ans = 0;
        for (int i = 0; i < N-1; ++i) {
            for (int j = i+1; j < N; ++j) {
                ans += li.get(i) * li.get(j);
            }
        }

        System.out.println(ans);
    }
}

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 || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




Measured memory_bytes: 32492
//
//  main.c
//  Recurring Decimals
//
//  Created by x15071xx on 2016/06/09.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>


void swap(int x,int y){
    int tmp;
    tmp = x;
    x = y;
    y= tmp;
}

int main(int argc, const char * argv[]) {
    
    
    while (1) {
        
        int i,j;
        int dai_1=0,sho_1=0;
        int a,keta,bu=1;
        int array_a[21]={0},count=1,tmp,c=0;
        int dai_array[6]={0},sho_array[6]={0};
        scanf("%d %d",&a,&keta);
        
        if (a==0&&keta==0) {
            break;
        }
        
        array_a[0] = a;
        
        while (count != 21) {
            
            bu=1;
            for (i=0; i<keta-1; i++) {
                bu*=10;
            }
            
            for (i=0; i<keta; i++) {
                dai_array[i] = a/bu;
                sho_array[i] = a/bu;
                a = a - bu*dai_array[i];
                bu = bu /10;
            }
            
            for (i=0; i<keta-1; i++) {
                for (j=keta-1; j>i; j--) {
                    if (dai_array[j-1] < dai_array[j]) {
                        //swap(dai_array[j-1],dai_array[j]);
                        tmp = dai_array[j-1];
                        dai_array[j-1] = dai_array[j];
                        dai_array[j] = tmp;
                    }
                    if (sho_array[j-1] > sho_array[j]) {
                        //swap(sho_array[j-1],sho_array[j]);
                        tmp = sho_array[j-1];
                        sho_array[j-1] = sho_array[j];
                        sho_array[j] = tmp;
                        
                    }
                }
            }
            bu=1;
            for (i=0; i<keta-1; i++) {
                bu*=10;
            }
            dai_1 = 0;
            sho_1 = 0;
            for (i=0; i<keta; i++) {
                dai_1 +=dai_array[i] * bu;
                sho_1 +=sho_array[i] * bu;
                
                bu = bu/10;
            }
            
            a = dai_1 - sho_1;
            
            array_a[count] = a;
            count++;
            for (i=0; i<6; i++) {
                dai_array[i] = 0;
                sho_array[i] = 0;
            }
        }
        
        for (i = 1; i < 21; i++) {
            for (j=0; j < i; j++) {
                if (array_a[i] == array_a[j]) {
                    printf("%d %d %d\n",j,array_a[i],i-j);
                    c=1;
                    break;
                }
            }
            if (c==1) {
                break;
            }
        }
    }
    return 0;
}

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

int main(){
  using namespace std;
  int n;
  cin >> n;
  string str1,str2;
  int taro{0},hanako{0};
  
  for(int i{0}; i<n; i++){
    cin >> str1 >> str2;
    if(str1.compare(str2)==0) {
      taro++;
      hanako++;
    }
    else if(str1.compare(str2)>0) {taro+=3;}
    else {hanako+=3;}
  }
  cout << taro << " " << hanako << endl;
}



Measured memory_bytes: 3132
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun a -> a in
  Array.sort compare as_;
  Printf.printf "%d\n" @@
  if n mod 2 = 0
  then
    2 * Array.fold_left ( + ) 0 (Array.sub as_ ((n + 1) / 2) (n / 2))
    - 2 * Array.fold_left ( + ) 0 (Array.sub as_ 0 ((n + 1) / 2))
    - as_.(n / 2)
    + as_.(n / 2 - 1)
  else
    max
      ( 2 * Array.fold_left ( + ) 0 (Array.sub as_ ((n + 1) / 2) (n / 2))
      - 2 * Array.fold_left ( + ) 0 (Array.sub as_ 0 ((n + 1) / 2))
      + as_.(n / 2)
      + as_.(n / 2 - 1) )
      ( 2 * Array.fold_left ( + ) 0 (Array.sub as_ (n / 2) ((n + 1) / 2))
      - 2 * Array.fold_left ( + ) 0 (Array.sub as_ 0 (n / 2))
      - as_.(n / 2)
      - as_.(n / 2 + 1) )
    


Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
    
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        
        while (true) {
            String[] numbers = scanner.nextLine().split(" ");
            int a = Integer.parseInt(numbers[0]);
            String op = numbers[1];
            int b = Integer.parseInt(numbers[2]);

            if (op.equals("?")) {
                break;
            }
            
            switch(op) {
                case "+":
                    System.out.println(""+(a+b));
                    break;
                case "-":
                    System.out.println(""+(a-b));
                    break;
                case "*":
                    System.out.println(""+(a*b));
                    break;
                case "/":
                    System.out.println(""+(a/b));
                    break;
                default:
                    break;
            }
        }
    }
}


Measured memory_bytes: 26092
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string s,t,n;
  int s1,t1;
  cin >> s >> t;
  cin >> s1 >> t1;
  cin >> n ;
  if (n==s)
    cout << s1-1 << ' ' << t1;
  else cout << s1 << ' ' << t1-1;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	const ll MOD=1000000007;
	ll n=0,ans=0,sum=0;
	cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++){
	       	cin>>a[i];
		sum+=a[i];
		sum%=MOD;
	}
	for(ll i=0;i<n-1;i++){
		sum-=a[i];
		if(sum<0) sum+=MOD;
		ans+=a[i]*sum;
		ans%=MOD;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 4820
/* AUTHOR: Naman */
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define IOS     ios_base::sync_with_stdio(0); cin.tie(NULL);
const ll N=2*1e6+1;


int main() {
	IOS
    ll t=1;
	//cin>>t;	
	
	for(ll _=1;_<=t;_++)
	{
	   //cout<<"Case #"<<_<<": ";
	    ll i,n;	
	    string s;
	    cin>>s;
	    
	    if(s[s.size()-1]!='s')s+="s";
	    else s+="es";
	    cout<<s;
	    
	   
	   
	   


	   cout<<endl;
	   
	}
	
    
}

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


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll n, m;
    cin >> n >> m;
    vector<int> o, e, a, b;
    for (int i = 1; i <= m; i++) {
        ll t;
        cin >> t;
        if (t&1) o.pb(t);
        else e.pb(t);
    }
    if (SZ(o) > 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (SZ(o)) {
        a.pb(o.back());
        o.pop_back();
    } else {
        a.pb(e.back());
        e.pop_back();
    }
    if (a[0] > 1)
        b.pb(a[0] - 1);
    for (auto t:e) {
        a.pb(t);
        b.pb(t);
    }
    if (SZ(o)) {
        a.pb(o[0]);
        b.pb(o[0] + 1);
    }
    else b.pb(1);
    for (int i = 0; i < SZ(a); i++)
        cout << a[i] << " \n"[i == SZ(a) - 1];
    cout << SZ(b) << endl;
    for (int i = 0; i < SZ(b); i++)
        cout << b[i] << " \n"[i == SZ(b) - 1];
}


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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int main(){
	int k, a, b;
	scanf("%d %d %d", &k, &a, &b);
	for(int i = a; i <= b; i++){
		if(i%k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
	int n;
	cin >> n;
	int *a;
	a = new int[2*n];
	REP(i, 0, 2*n)
		cin >> a[i];
	sort(a, a + 2*n);
	int sum = 0;
	for (int i = 2*n - 2; i >= 0; i-=2)
	{
		sum += a[i];
	}
	cout << sum;
	//system("pause");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <map>
const int MaxN = 2e5;
using namespace std;
map < pair<int , int> , bool> vis;
int n , m;
int main()
{
	while(~scanf("%d%d" , &n , &m)){
		bool ok = 0;
		for(int i = 1;i <= m;i++) {
			int u , v;
			scanf("%d%d" , &u , &v);
			vis[make_pair(u , v)] = 1;
		}
		for(int i = 2;i <= n - 1;i++){
			if(vis[make_pair(1 , i)] && vis[make_pair(i , n)]) ok = 1;
		}
		if(ok) printf("POSSIBLE\n");
		else printf("IMPOSSIBLE\n");
	}
}

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

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if(abs(a-c)>d){
	    if(abs(a-b)>d || abs(b-c)>d) cout << "No" << endl;
	    else cout << "Yes" << endl;
	}
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256